功能完善

This commit is contained in:
wu ming 2016-09-28 17:04:00 +08:00
parent 091edca9cc
commit 7268a3f121
12 changed files with 437 additions and 324 deletions

View File

@ -1,4 +1,5 @@
/// <reference path="../../includes.d.ts" />
/// <reference path="kubernetesHelpers.d.ts" />
declare module Kubernetes {
var hostPorts: any[];
/**
@ -59,4 +60,10 @@ declare module Kubernetes {
function isFilterRC(rc: any): boolean;
function isInclude(rcs: any, rc: any): boolean;
function labelChangeToChines(value: string, key: string): string;
function checkForMigration(replicationControllers: Array<KubePod>, selectItem: Array<any>): any[];
function checkForCreateOracle(transferTasks: Array<any>, selectItems: Array<any>): any[];
/**
**/
function checkForExtract(replicationControllers: Array<any>): any[];
}

File diff suppressed because one or more lines are too long

View File

@ -248,8 +248,8 @@ gulp.task('connect', ['watch'], function() {
targetPath: '/hawtio/git'
}, {
proto: "http",
port: "8080",
hostname: "192.168.191.5",
port: "8088",
hostname: "192.168.0.110",
path: '/java/console/api',
targetPath: "/"
}];

View File

@ -1,65 +0,0 @@
<script type="text/ng-template" id="kubeForm.html">
<form class="form-horizontal" ng-submit="onSubmit(validForm.$valid)" novalidate="novalidate" name="validForm" ng-init="mode=tableForm">
<div class="form-group">
<label class="col-sm-2 control-label">名称</label>
<div class="col-sm-10 sj_form_input">
<input class="form-control " type="text" ng-model="mode.name" id="orcName" ng-minlength="4" ng-maxlength="20" required="required">
<span class="glyphicon glyphicon-ok form-control-feedback" ng-show="validForm.orcName.$valid">请输入长度2-20个字符</span>>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">IP</label>
<div class="col-sm-10">
<input class="form-control" type="text" ng-model="mode.ip" id="orcIP" pattern="((?:(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d))))">
<span class="glyphicon glyphicon-ok form-control-feedback" ng-show="validForm.orcIP.$valid" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">端口号</label>
<div class="col-sm-10">
<input class="form-control" type="text" ng-model="mode.port" id="orcPort" pattern="/^[1-9]$|(^[1-9][0-9]$)|(^[1-9][0-9][0-9]$)|(^[1-9][0-9][0-9][0-9]$)|(^[1-6][0-5][0-5][0-3][0-5]$)/">
<span class="glyphicon glyphicon-ok form-control-feedback" ng-show="validForm.orcPort.$valid">请输入1~65535的端口号</span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">用戶名</label>
<div class="col-sm-10">
<input class="form-control" type="text" ng-model="mode.user" id="orcUser" pattern="^[a-z]{2,15}$">
<span class="glyphicon glyphicon-ok form-control-feedback" ng-show="validForm.orcUser.$valid">请输入长度为2~15个字符(a~z)的用户名</span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">密码</label>
<div class="col-sm-10">
<input class="form-control" type="text" ng-model="mode.password" id="orcPassword" pattern="^\w{2,15}$">
<span class="glyphicon glyphicon-ok form-control-feedback" ng-show="validForm.orcPassword.$valid">请输入长度为2~15个字符(0~9或a~z)的密码</span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">服务名</label>
<div class="col-sm-10">
<input class="form-control" type="text" ng-model="mode.databaseName" id="orcService" pattern="^[a-z]{1,10}$">
<span class="glyphicon glyphicon-ok form-control-feedback" ng-show="validForm.orcService.$valid">请输入长度为2~10个字符(0~9或a~z)的服务名</span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">服务名</label>
<div class="col-sm-10">
<input class="form-control" type="text" ng-model="mode.tableName" id="orcTable" pattern="^[a-z]{1,10}$">
<span class="glyphicon glyphicon-ok form-control-feedback" ng-show="validForm.orcTable.$valid">请输入长度为2~10个字符(0~9或a~z)的服务名</span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">服务名</label>
<div class="col-sm-10">
<input class="form-control" type="text" ng-model="mode.suffix" id="orcSuffix" pattern="^[a-z]{1,10}$">
<span class="glyphicon glyphicon-ok form-control-feedback" ng-show="validForm.orcSuffix.$valid">请输入长度为2~10个字符(0~9或a~z)的服务名</span>
</div>
</div>
<div class="form-group">
<button class="btn" type='submit'>
<span class="glyphicon glyphicon-save"></span> 保存
</button>
</div>
</form>
</script>

View File

@ -35,14 +35,14 @@
<th ng-show="ngDialogData.status" class="new_left sj_c_green">启用</th>
<th ng-hide="ngDialogData.status" class="new_left sj_c_green">停止</th>
<th colspan="10">
<input type="text" class="sj_txt_box03 mr10" ng-model="ngDialogData.name " pattern="^\w{4,20}$" ng-disabled="!{{ngDialogData.editable}}" />
<input type="text" class="sj_txt_box03 mr10" ng-model="ngDialogData.name " ng-disabled="!{{ngDialogData.editable}}" />
</th>
<th>云目录:</th>
<th>
<input type="text" class="sj_txt_box02 mr5" ng-model="ngDialogData.path" ng-disabled="!{{ngDialogData.editable}}" />
</th>
<th>
<button ng-show="ngDialogData.status" class="sj_btn_red fl" ng-click="stopVolume(ngDialogData)">停止</button>
<button ng-show="ngDialogData.status" class="sj_btn_blue fl" ng-click="stopVolume(ngDialogData)">停止</button>
<button ng-hide="ngDialogData.status" class="sj_btn_red fl" ng-click="startVolume(ngDialogData)">启动</button>
</th>
</tr>

View File

@ -75,22 +75,5 @@ module Configs{
showDeleteVolume.item = null;
}
}
/* (volume) =>{
$http({
url: "/java/console/api/volume/delete",
method: 'POST',
data: volume
}).success(function(data,header,config,status){
/*
volume信息
}).error(function(data,header,config,status){
});
}*/
}]);
}

View File

@ -73,7 +73,7 @@ module Configs{
ip.push(brick["ip"][key]);
brick["ip"] = ip.join("\.");
}
});
});
$http({
url: "/java/console/api/volume/update",

View File

@ -63,15 +63,11 @@ module Developer {
]};
$scope.$on("deleteRow", (event, data) =>{
if(data.status == 1)
alert("无法删除正在迁移的数据");
else{
Configs.oracleInfoOperate($http, "/java/console/api/task/transfer", Configs.OperateType.DELETE, data, (data, status) =>{
if(status === 200)
console.log("删除成功");
});
}
$scope.$on("deleteRow", (event, data) =>{
Configs.oracleInfoOperate($http, "/java/console/api/task/transfer", Configs.OperateType.DELETE, data, (data, status) =>{
if(status === 200)
console.log("删除成功");
});
});
}]);
}

View File

@ -12,6 +12,7 @@ module Developer {
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;
$scope.replicasModel = KubernetesModel;
init($scope, $location, $routeParams);
$scope.options = DataModel.paramOptions;
$scope.pageSizeChoses = DataModel.paramOptions.pagerSizeOption;
@ -192,23 +193,32 @@ module Developer {
selectedItem: {"name": "当前没有可以迁移的集群"},
dialog: new UI.Dialog(),
onOk: () => {
var migrationClick = $scope.migrationClick;
Configs.oracleInfoOperate($http, "/java/console/api/volume", Configs.OperateType.MOVE,
{
"name": migrationClick.selectedItem.name,
"selectItems": $scope.tableConfig.selectedItems,
"selectNode": $scope.selectNode
}, (result, status) => {
if(status===200){
//$scope.model.updateOracleParam();
}else{
throw "资源请求失败";
}
});
$timeout(() =>{
$location.path("/workspaces/Overview/task");
},250);
migrationClick.close();
var migrationClick = $scope.migrationClick;
var exitedItems = Kubernetes.checkForMigration($scope.replicasModel.replicationControllers,$scope.tableConfig.selectedItems);
if(exitedItems.length == 0){
Configs.oracleInfoOperate($http, "/java/console/api/volume", Configs.OperateType.MOVE,
{
"name": migrationClick.selectedItem.name,
"selectItems": $scope.tableConfig.selectedItems,
"selectNode": $scope.selectNode
}, (result, status) => {
if(status===200){
//$scope.model.updateOracleParam();
}else{
throw "资源请求失败";
}
});
$timeout(() =>{
$location.path("/workspaces/Overview/task");
},250);
migrationClick.close();
}else{
var name = "";
angular.forEach(exitedItems, (item) => {
name += item.name + "-" + item.systemName + ",";
})
alert("迁移数据文件失败:" + name +"数据文件正在使用....");
}
},
open: (selected) =>{
var migrationClick = $scope.migrationClick;
@ -222,32 +232,42 @@ module Developer {
}
};
$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,
id: item.id+""
},
path: item.dataPath+"app/",
isTarget: "false",
isExtract: item.extractStatus
}, (rc) =>{
Kubernetes.connectOracle($http, $timeout, "/java/console/api/connectOracle", "create", rc, 0);
});
});
$timeout(() => {
$location.path('/kubernetes/namespace/default/replicationControllers');
}, 200);
$scope.createOracleService = (items) =>{
var exitedItems = Kubernetes.checkForCreateOracle($scope.model.transferTasks, items);
if(exitedItems.length == 0){
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,
id: item.id+"",
year: item.year
},
path: item.dataPath+"app/",
isTarget: "false",
isExtract: item.extractStatus
}, (rc) =>{
Kubernetes.connectOracle($http, $timeout, "/java/console/api/connectOracle", "create", rc, 0);
});
});
$timeout(() => {
$location.path('/kubernetes/namespace/default/replicationControllers');
}, 200);
}else{
var name = "";
angular.forEach(exitedItems, (item) => {
name += item.name + "-" + item.systemName + ",";
})
alert("迁移数据文件失败:" + name +"数据文件正在使用....");
}
}
function init($scope,$location,$routeParams){

View File

@ -74,40 +74,49 @@ module Kubernetes {
id: selected
}];
}
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());
});
});
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());
});
});
}
}
deleteSelected(selected, selected.shift());
}
deleteSelected(selected, selected.shift());
}
},
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();
},
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 + "服务正在执行汇总操作,不能被删除");
}
}
$scope.createRCs= () => {
@ -123,40 +132,48 @@ module Kubernetes {
});
}
$scope.stopPrompt = (selected) =>{
$scope.stopPrompt = (selected) =>{
if (angular.isString(selected)) {
selected = [{
id: selected
}];
}
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());
});
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());
});
}
}
stopSelected(selected, selected.shift());
}
stopSelected(selected, selected.shift());
}
},
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();
},
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 + "服务正在执行汇总操作,不能停止");
}
};
$scope.reStartPrompt = (selected) => {

View File

@ -118,9 +118,13 @@ module Kubernetes {
show: false,
item: null,
open: (entity) => {
var showDeleteOne = $scope.showDeleteOne;
showDeleteOne.show = true;
showDeleteOne.item = entity;
if(entity.status == 1)
alert("无法删除正在迁移的数据");
else{
var showDeleteOne = $scope.showDeleteOne;
showDeleteOne.show = true;
showDeleteOne.item = entity;
}
},
onOk: () => {
var showDeleteOne = $scope.showDeleteOne;

View File

@ -1,4 +1,5 @@
/// <reference path="../../includes.ts"/>
/// <reference path="./kubernetesHelpers.ts"/>
module Kubernetes {
export var hostPorts =[];
@ -238,4 +239,67 @@ module Kubernetes {
}
return trueValue;
}
/*
,oracle
*/
export function checkForMigration(replicationControllers:Array<KubePod>, selectItem:Array<any>){
var result = [];
angular.forEach(selectItem, (item) => {
if(checkForExit(replicationControllers, item))
result.push(item);
});
return result;
}
function checkForExit(replicationControllers:Array<KubePod>, selectItem){
for(var index in replicationControllers) {
var replicas = replicationControllers[index];
if(getName(replicas)==selectItem._key && getAnnotationValueBykey(replicas,"year") == selectItem["year"])
return true;
}
return false;
}
function getAnnotationValueBykey(replicationController, key:string){
var annotations = getAnnotations(replicationController);
if(annotations && annotations != undefined){
return annotations[key];
}
}
/*
oracle时检查是否正在迁移
*/
export function checkForCreateOracle(transferTasks:Array<any>, selectItems:Array<any>){
var result = [];
angular.forEach(selectItems, (item) => {
if(checkForExitTask(transferTasks, item))
result.push(item);
});
return result;
}
function checkForExitTask(transferTasks:Array<any>, selectItem){
for(var index in transferTasks){
var task = transferTasks[index];
if(task["_key"] == selectItem["_key"] && (task["status"] == "1" || task["status"] == "0") && selectItem["year"] == task.labels.dataYear){
return true;
}
}
return false;
}
/**
**/
export function checkForExtract(replicationControllers: Array<any>){
var result = [];
angular.forEach(replicationControllers, (replicas) => {
var labels = getLabels(replicas);
if(labels["isExtract"] == "1")
result.push(replicas);
});
return result;
}
}