You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
aggregation-platform/plugins/developer/ts/workspaces.ts

263 lines
8.3 KiB

9 years ago
/// <reference path="../../includes.ts"/>
/// <reference path="../../kubernetes/ts/kubernetesHelpers.ts"/>
/// <reference path="../../kubernetes/ts/kubernetesModel.ts"/>
8 years ago
/// <reference path="../../configs/ts/configsDataService.ts"/>
9 years ago
/// <reference path="developerEnrichers.ts"/>
/// <reference path="developerHelpers.ts"/>
/// <reference path="dataManagerHelper.ts"/>
/// <reference path="dataManagerModel.ts"/>
/// <reference path="../../configs/ts/configsHelper.ts"/>
9 years ago
module Developer {
8 years ago
export var WorkspacesController = controller("WorkspacesController", ["$scope", "KubernetesModel", "DataModel", "ConfigsModel", "KubernetesState", "$templateCache", "$location", "$routeParams", "$http", "$timeout", "KubernetesApiURL", "$element",
($scope, KubernetesModel: Kubernetes.KubernetesModelService, DataModel:Developer.DataModelService, ConfigsModel:Configs.ConfigsModelService, KubernetesState, $templateCache:ng.ITemplateCacheService, $location:ng.ILocationService, $routeParams, $http, $timeout, KubernetesApiURL, $element) => {
$scope.model=DataModel;
8 years ago
init($scope, $location, $routeParams);
$scope.model.initParamOptions();
$scope.options = DataModel.paramOptions;
$scope.pageSizeChoses = DataModel.paramOptions.pagerSizeOption;
8 years ago
$scope.options.dataType = getDataType($location);
//console.log(JSON.stringify($scope.volumes[0].folderNode));
$scope.treeOptions = {
8 years ago
nodeChildren: "childNodes",
dirSelectable: true,
injectClasses: {
ul: "a1",
li: "a2",
liSelected: "a7",
iExpanded: "a3",
iCollapsed: "a4",
iLeaf: "a5",
label: "a6",
labelSelected: "a8"
}
}
//配置数据表格需要显示的内容及显示格式
$scope.tableConfig = {
data: 'model.data',
showSelectionCheckbox: true,
enableRowClickSelection: false,
multiSelect: true,
selectedItems: [],
filterOptions: {
filterText: $location.search()["q"] || ''
},
columnDefs: [
{
field: "_key",
displayName: '编码',
customSortField: (field) =>{
return field.id;
}
},
{
field: "name",
displayName: '市-区/县'
},
{
field: "systemName",
displayName: '系统名称'
},
{
field: "labels",
displayName: '数据标签',
cellTemplate: $templateCache.get("dataLabelsTemplate.html")
},
{
field: "collectingTime",
displayName: '采集时间'
},
{
field: "collectorName",
displayName: '汇总状态'
}
]
};
$scope.selectBatchItem = (item)=> {
$scope.navbarItems.forEach((nav) =>{
nav.class="";
});
item.class="active";
if(item.label === "全部")
$scope.model.updateParamOption("dataBatch", null);
else
$scope.model.updateParamOption("dataBatch", item.alias);
}
$scope.isEmptyOrFirst = () => {
var idx = $scope.model.getParamOption("currentPageNum");
var length =$scope.options.getPageSizeNum();
return length <= 0 || idx <= 1;
}
$scope.isEmptyOrLast = () =>{
var idx = $scope.model.getParamOption("currentPageNum");
var length =$scope.options.getPageSizeNum();
return length < 1 || idx >= length;
}
$scope.first = () => {
var idx = $scope.model.getParamOption("currentPageNum");
if(idx >1)
$scope.model.updateParamOption("currentPageNum", 1);
}
$scope.last = () =>{
var idx = $scope.model.getParamOption("currentPageNum");
var length =$scope.options.getPageSizeNum();
if(idx < length)
$scope.model.updateParamOption("currentPageNum", length);
}
$scope.previous = () => {
var idx = $scope.model.getParamOption("currentPageNum");
var length =$scope.options.getPageSizeNum();
if(idx > 1)
$scope.model.updateParamOption("currentPageNum", idx-1);
}
$scope.next = () =>{
var length =$scope.options.getPageSizeNum();
var idx = $scope.model.getParamOption("currentPageNum");
if(idx < length)
$scope.model.updateParamOption("currentPageNum", idx+1);
}
$scope.$watch('options', (newValue, oldValue) => {
if(newValue && newValue !== oldValue){
if(newValue.currentTableSize !== oldValue.currentTableSize)
$scope.options.priorTableSize = oldValue.currentTableSize;
else
$scope.options.priorTableSize = newValue.currentTableSize;
DataModel.updateModel();
9 years ago
}
}, true);
$scope.deletePrompt = (items) =>{
var idColl = [];
angular.forEach(items,(item) => {
idColl.push(item.id);
console.log(item.id);
});
$http({
method: "POST",
url: "/java/console/api/delete/data",
params: {"data": idColl}
}).success(function(data, status, headers, config) {
//成功之后做一些事情
DataModel.updateModel();
}).error(function(data, status, headers, config) {
});
}
$scope.migrationClick = {
items:null,
selectedItem: $scope.volumes[0] || "当前没有可以迁移的集群",
dialog: new UI.Dialog(),
onOk: () => {
var migrationClick = $scope.migrationClick;
var volumeName = migrationClick.selectedItem.name;
var selectItems = $scope.tableConfig.selectedItems;
var selectNode = $scope.selectNode;
console.log(migrationClick);
console.log(selectItems);
console.log(selectNode);
/*Configs.oracleInfoOperate($http, "/java/console/api/volume", Configs.OperateType.MOVE, {"id":selectedItem.name}, (result, status) => {
if(status===200){
//$scope.model.updateOracleParam();
}else{
throw "资源请求失败";
}
});*/
migrationClick.close();
},
open: (selected) =>{
var migrationClick = $scope.migrationClick;
migrationClick.dialog.open();
},
close: () => {
$scope.migrationClick.dialog.close();
}
};
$scope.createOracleService = (items) =>{
angular.forEach(items,(item)=>{
Kubernetes.createRC({
name: item._key,
labels: {
system: item.systemCode.toString(),
version: item.dataVersion.toString(),
region: item.regionalismCode.toString()
},
annotations: {
cityName: item.cityName,
districtName: item.districtName,
systemName: item.systemName
},
path: item.dataPath+"app/",
isTarget: "false"
}, (rc) =>{
Kubernetes.connectOracle($http, $timeout, "/java/console/api/connectOracle", "create", Kubernetes.getName(rc), 0);
$location.path('/kubernetes/namespace/default/replicationControllers');
});
8 years ago
});
}
function init($scope,$location,$routeParams){
$scope.model.updateModel();
if(ConfigsModel.cluster!=null)
$scope.volumes = ConfigsModel.cluster;
8 years ago
//创建二级菜单
$scope.subTabConfig = Developer.createCurrentSubNavBar($scope, $location, $routeParams);
$scope.navbarItems =[{
herf: "",
label: "全部",
title: "查看全部数据",
class: "active",
alias: null
},
{
herf: "",
label: "批次A",
title: "查看批次A的数据",
class: "",
alias: "A"
},
{
herf: "",
label: "批次B",
title: "查看批次B的数据",
class: "",
alias: "B"
}]
}
function getDataType($location){
var path = $location.path();
var result;
var subPath = path.split("/");
switch (subPath[subPath.length -1]) {
case "financial":
result = "财政"
break;
case "social-security":
result = "社保"
break;
default:
result = null;
break;
}
return result;
}
9 years ago
}]);
}