/// /// /// /// /// module Configs{ export class OperateType{ public static get DELETE():string {return "delete"} public static get UPDATE():string {return "update"} public static get PUT():string{return "put"} public static get MOVE():string{return "move"} public static get EXTRACT():string{return "extract"} } _module.controller('Configs.MenuItemController',['$scope', '$location', ($scope, $location) => { $scope.menuItem=[{ icon: "glyphicon glyphicon-cloud-upload", label: "数据管理配置", title: "配置数据存储信息", href: UrlHelpers.join(context, "/gluster-fs/setting") }, { icon: "glyphicon glyphicon-th-list", label: "服务集群配置", title: "配置服务集群信息", href: UrlHelpers.join(context, "/kube-cluster/setting") }] }]); function createConfigBreadcrumbs($scope, $location, $routeParams){ var url = $location.url(); var label, title; switch (url) { case "/config/gluster-fs/setting": label = "数据管理配置"; title= "配置数据存储信息"; break; case "/config/kube-cluster/setting": label = "服务集群配置"; title= "配置服务集群信息"; break; default: break; } return Developer.activateCurrent([{ href: url, label: label,//item.label, title: title//item.title }]); } export function createOracleInfo(array:Array, id:number){ var result ={"id": id}; angular.forEach(array, (arr) => { result[arr.field] = arr.value; }); return result; } export function shareInit($scope, $location, $routeParams){ $scope. subTabConfig = Developer.createCurrentSubNavBar($scope, $location, $routeParams); } export function createNewObejct(array:Array, obj){ var result =[]; if(obj){ angular.forEach(array, (arr) =>{ result.push({ field: arr.field, name: arr.displayName, value: obj[arr.field] }); }); }else{ angular.forEach(array, (arr) =>{ result.push({ field: arr.field, name: arr.displayName, value: null }); }); } return result; } export function oracleInfoOperate($http, url:string, operate:string, resource, fn?: (data, status)=>void ){ if(resource === null) throw "不能操作空资源对象"; var id = resource["id"] || resource["name"] || resource["_id"] || resource["_key"]; var RESTfulUrl=url; if(id == "undefined"){ RESTfulUrl = UrlHelpers.join(url, operate); }else{ RESTfulUrl = UrlHelpers.join(url, id+"", operate); } $http({ method: "POST", dataType: 'json', url: RESTfulUrl, data: JSON.stringify(resource), }).success((data,header,config,status) => { if(angular.isFunction(fn)) fn(data, header); }).error((data,header,config,status) => { if(angular.isFunction(fn)) fn(data, header); }); } export function createConfigHelperNavBar($scope, $location, $routeParams){ return Developer.activateCurrent([ { href: UrlHelpers.join(context, "regionalism-code/searching"), label: "行政区划检索", title: "检索行政区划代码" }, { href: UrlHelpers.join(context,"system-code/searching"), label: "系统编码检索", title: "检索系统编码" } ]); } export function formatVolume(volume: volume): formatedVolume{ var brick:Array = []; angular.forEach(volume.brick, (block:Block) => { brick.push({ ip: block.ip.split("."), status: block.status, path: block.path }); }); return { name: volume.name, path: volume.path, brick: brick, status: volume.status } } export function formatVolumes(volumes: Array): Array{ var result:Array = []; angular.forEach(volumes, (volume) => { result.push(formatVolume(volume)); }); return result; } export interface formatedVolume{ name: string path: string brick: Array; status: string; } export interface Brick{ ip: Array; status: boolean; path: string; } }