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/kubernetes/ts/replicationControllers.ts

238 lines
9.7 KiB

9 years ago
/// <reference path="../../includes.ts"/>
/// <reference path="kubernetesHelpers.ts"/>
/// <reference path="kubernetesPlugin.ts"/>
/// <reference path="kubernetesModel.ts"/>
/// <reference path="../../configs/ts/customAlert.ts"/>
9 years ago
module Kubernetes {
export var ReplicationControllers = controller("ReplicationControllers",
["$scope", "KubernetesModel", "KubernetesReplicationControllers", "KubernetesPods", "ConfigsModel", "KubernetesState", "$templateCache", "$location", "$routeParams", "$http", "$timeout", "KubernetesApiURL",
($scope, KubernetesModel: Kubernetes.KubernetesModelService, KubernetesReplicationControllers:ng.resource.IResourceClass<any>, KubernetesPods:ng.resource.IResourceClass<any>, ConfigsModel, KubernetesState,
9 years ago
$templateCache, $location:ng.ILocationService, $routeParams, $http, $timeout, KubernetesApiURL) => {
$scope.kubernetes = KubernetesState;
$scope.configs = ConfigsModel;
$scope.model = KubernetesModel;
9 years ago
$scope.tableConfig = {
data: 'model.replicationControllers',
showSelectionCheckbox: true,
enableRowClickSelection: false,
multiSelect: true,
selectedItems: [],
filterOptions: {
filterText: $location.search()["q"] || ''
},
columnDefs: [
{ field: '$oracleName',
9 years ago
displayName: '服务名称',
cellTemplate: $templateCache.get("idTemplate.html"),
customSortField: (field) => {
return field;
}
9 years ago
},
//{ field: '$replicas',
// displayName: 'Scale',
// cellTemplate:$templateCache.get("desiredReplicas.html")
//},
{ field: '$pods.age',
displayName: '启动时间',
cellTemplate:$templateCache.get("ageTemplate.html")
},
{ field: '$labelsText',
displayName: '数据标签',
cellTemplate: $templateCache.get("labelTemplate.html")
},
{ field: '$pods',
displayName: '连接参数',
cellTemplate: $templateCache.get("connectParamTemplate.html")
},
9 years ago
{ field: '$podCounters',
displayName: '服务状态',
cellTemplate: $templateCache.get("podCountsAndLinkTemplate.html"),
customSortField: (field) => {
8 years ago
console.log(field);
9 years ago
if(field.$podCounters.ready ){
return 3;
}else if(field.$podCounters.valid || field.$podCounters.waiting){
return 2;
}else if(field.$podCounters.error){
return 0;
}else{
return 1;
}
}
9 years ago
},
{ field: '$extractStatus',
displayName: '数据汇总状态',
cellTemplate: $templateCache.get("dataSummaryTemplate.html")
9 years ago
}
],
sortInfo: {
sortBy: "$oracleName",
ascending: false
}
9 years ago
}
9 years ago
Kubernetes.initShared($scope, $location, $http, $timeout, $routeParams, KubernetesModel, KubernetesState, KubernetesApiURL);
$scope.deletePrompt = (selected) => {
9 years ago
if (angular.isString(selected)) {
selected = [{
id: selected
}];
}
8 years ago
var extractItems = checkForExtract(selected);
if(extractItems.length == 0){
UI.multiItemConfirmActionDialog(<UI.MultiItemConfirmActionOptions>{
collection: selected,
index: 'metadata.name',
onClose: (result:boolean) => {
if (result) {
function deleteSelected(selected:Array<KubePod>, next:KubePod) {
if (next) {
Kubernetes.resizeController($http, KubernetesApiURL, next, 0, () => {
KubernetesReplicationControllers.delete({
id: getName(next)
}, undefined, () => {
if(next.metadata.labels.style === "oracle"){
Kubernetes.connectOracle($http, $timeout, "/java/console/api/cancelOracleConection", "delete", next, 0);
}
deleteSelected(selected, selected.shift());
}, (error) => {
log.debug("Error deleting: ", error);
deleteSelected(selected, selected.shift());
});
});
}
9 years ago
}
8 years ago
deleteSelected(selected, selected.shift());
9 years ago
}
8 years ago
},
title: '是否需要删除oracle服务',
action: '以下的oracle服务将会被删除:',
okText: '删除',
okClass: 'btn-danger sj_btn_cir',
custom: "该服务删除后将会清除oracle对应服务的端口等资源占用但不删除数据文件是否删除请确认",
customClass: "alert alert-warning sj_alert-warning",
cancelText: "取消",
cancelClass: 'sj_btn_grey'
}).open();
}else{
var name = "";
angular.forEach(extractItems, (item) => {
name += item.$oracleName + ",";
})
//alert("删除服务失败:" + name + "服务正在执行汇总操作,不能被删除");
Configs.customAlert("提示", "操作失败:正在执行汇总操作的服务不能被删除!", '',null, 0, "error");
8 years ago
}
9 years ago
}
$scope.createRCs= () => {
$http({
url: '/java/console/api/cancelOracleConection',
dataType: 'json',
method:'POST',
params:{param: "data"}
}).success(function(data,header,config,status){
console.log("success");
}).error(function(data,header,config,status){
//log.warn("Failed to connect " + connectParam + " " + data + " " + status);
});
9 years ago
}
8 years ago
$scope.stopPrompt = (selected) =>{
9 years ago
if (angular.isString(selected)) {
selected = [{
id: selected
}];
}
8 years ago
var extractItems = checkForExtract(selected);
if(extractItems.length == 0){
UI.multiItemConfirmActionDialog(<UI.MultiItemConfirmActionOptions>{
collection: selected,
index: 'metadata.name',
onClose: (result:boolean) => {
if (result) {
function stopSelected(selected:Array<KubePod>, next:KubePod) {
if (next) {
Kubernetes.resizeController($http, KubernetesApiURL, next, 0, () => {
if(next.metadata.labels.style === "oracle"){
Kubernetes.connectOracle($http, $timeout, "/java/console/api/cancelOracleConection", "stop", next, 0);
}
stopSelected(selected, selected.shift());
});
}
9 years ago
}
8 years ago
stopSelected(selected, selected.shift());
9 years ago
}
8 years ago
},
title: '是否需要停止oracle服务',
action: '以下的oracle服务将会被停止:',
okText: '停止',
okClass: 'btn-danger sj_btn_cir',
custom: "该服务停止后将无法继续提供连接访问服务,但可通过启动按钮重新启动该服务以进行访问。是否停止,请确认",
customClass: "alert alert-warning sj_alert-warning",
cancelText: "取消",
cancelClass: 'sj_btn_grey'
}).open();
}else{
var name = "";
angular.forEach(extractItems, (item) => {
name += item.$oracleName + ",";
})
//alert("停止服务失败:" + name + "服务正在执行汇总操作,不能停止");
Configs.customAlert("提示", "操作失败:正在执行汇总操作的服务不能被停止!", '',null, 0, "error");
8 years ago
}
};
9 years ago
$scope.reStartPrompt = (selected) => {
9 years ago
function startSelected(selected:Array<KubePod>, next:KubePod){
if(next){
if(next.$replicas === 0)
Kubernetes.resizeController($http, KubernetesApiURL, next, 1, () => {
Kubernetes.connectOracle($http, $timeout, "/java/console/api/connectOracle", "reStart", next, 200);
startSelected(selected, selected.shift());
9 years ago
});
}
}
startSelected(selected, selected.shift());
};
$scope.extractClick = {
items: null,
selectedItem: {name: "当前没有可用的汇总库"},
dialog: new UI.Dialog(),
onOk: () => {
var extractClick = $scope.extractClick;
extractClick.items = $scope.tableConfig.selectedItems;
Kubernetes.extractDataToOracle($http, extractClick.items, extractClick.selectedItem);
//extractClick.selectedItem = $scope.filterReplicationControllers[0] || "";
extractClick.dialog.close();
},
open: (selected) => {
var extractClick = $scope.extractClick;
if($scope.configs && $scope.configs.oracleParam instanceof Array && $scope.configs.oracleParam.length>0)
extractClick.selectedItem = $scope.configs.oracleParam[0];
var result = checkIsStartSuccess($scope.tableConfig.selectedItems);
if(result.length >0){
Configs.customAlert("提示", "操作失败:选择服务中存在未启动的数据,请先启动服务", '',null, 0, "error");
return;
}
extractClick.dialog.open();
/*extractData.selectedItem = $scope.filterReplicationControllers[0] || "";
extractData.items = selected;*/
$timeout(() => {
$('#newDataName').focus();
}, 50);
},
close: () => {
$scope.extractClick.selectedItem = {name: "当前没有可用的汇总库"};
$scope.extractClick.dialog.close();
}
};
9 years ago
}]);
}