/// /// /// 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 = createConfigBreadcrumbs($scope, $location, $routeParams); $scope.model.updateAllData(); } 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, resource.id+"", operate); } $http({ method: "POST", url: RESTfulUrl, params: resource }).success(function(data, status, headers, config) { //成功之后做一些事情 if(angular.isFunction(fn)) fn(data, status); }).error(function(data, status, headers, config) { if(angular.isFunction(fn)) fn(data, status); }); } }