完善服务集群管理页面

Web_Manager_Develope
wu ming 8 years ago
parent bcf440c67a
commit 566cd7c3ad

@ -7,6 +7,7 @@ declare module Configs {
static UPDATE: string; static UPDATE: string;
static PUT: string; static PUT: string;
static MOVE: string; static MOVE: string;
static EXTRACT: string;
} }
function createOracleInfo(array: Array<any>, id: number): { function createOracleInfo(array: Array<any>, id: number): {
"id": number; "id": number;

@ -12,6 +12,7 @@ declare module Configs {
serviceName: string; serviceName: string;
tableName: string; tableName: string;
status: string; status: string;
id?: number;
} }
interface volume { interface volume {
name: string; name: string;

@ -21,7 +21,7 @@ declare module Developer {
} }
class DataModelService { class DataModelService {
data: any[]; data: any[];
paramOptions: any; paramOptions: OptionsParams;
constructor(); constructor();
protected getDataModel(paramOptions: any): any; protected getDataModel(paramOptions: any): any;
initParamOptions(): void; initParamOptions(): void;

@ -209,7 +209,7 @@ declare module Kubernetes {
function getOracleStatus(labels: any): number; function getOracleStatus(labels: any): number;
function getExtractStatus(labels: any): number; function getExtractStatus(labels: any): number;
function getOracleName(name: string): string; function getOracleName(name: string): string;
function extractDataToOracle($http: any, selectedReplicationControllers: any, targetReplicationController: any): void; function extractDataToOracle($http: any, selectedReplicationControllers: any, targetOracle: Configs.oracleParam): void;
function checkoutOracleRCIsRunning(rc: any): boolean; function checkoutOracleIsRunning(rc: any): boolean;
function replicasIsCreated(replicationcontrollers: Array<any>, name: string): boolean; function replicasIsCreated(replicationcontrollers: Array<any>, name: string): boolean;
} }

File diff suppressed because one or more lines are too long

@ -249,7 +249,7 @@ gulp.task('connect', ['watch'], function() {
}, { }, {
proto: "http", proto: "http",
port: "8080", port: "8080",
hostname: "192.168.0.102", hostname: "192.168.0.181",
path: '/java/console/api', path: '/java/console/api',
targetPath: "/" targetPath: "/"
}]; }];

@ -31,7 +31,7 @@
<hr> <hr>
<div class="row" ng-show="tableForm.length>=0 && (edit || add)" > <div class="row" ng-show="tableForm.length>=0 && (edit || add)" >
<h3 ng-show="edit" >编辑汇总库连接信息:</h3> <h3 ng-show="edit" >编辑汇总库连接信息:</h3>
<h3 ng-show="add mt10 mb10">添加汇总库信息:</h3> <h3 ng-show="add" >添加汇总库信息:</h3>
<div class="col-md-6 col-md-offset-1"> <div class="col-md-6 col-md-offset-1">
<form class="form-horizontal" ng-submit="onSubmit(validForm.$valid)" novalidate="novalidate" name="validForm"> <form class="form-horizontal" ng-submit="onSubmit(validForm.$valid)" novalidate="novalidate" name="validForm">
<div class="form-group" ng-repeat="item in tableForm"> <div class="form-group" ng-repeat="item in tableForm">

@ -7,6 +7,7 @@ module Configs{
public static get UPDATE():string {return "update"} public static get UPDATE():string {return "update"}
public static get PUT():string{return "put"} public static get PUT():string{return "put"}
public static get MOVE():string{return "move"} public static get MOVE():string{return "move"}
public static get EXTRACT():string{return "extract"}
} }
_module.controller('Configs.MenuItemController',['$scope', '$location', ($scope, $location) => { _module.controller('Configs.MenuItemController',['$scope', '$location', ($scope, $location) => {
@ -83,14 +84,17 @@ module Configs{
} }
export function oracleInfoOperate($http, url:string, operate:string, resource, fn?: (data, status)=>void ){ export function oracleInfoOperate($http, url:string, operate:string, resource, fn?: (data, status)=>void ){
var id = resource.id+"", RESTfulUrl;
if(id !="")
RESTfulUrl = UrlHelpers.join(url, resource.id, operate);
else
RESTfulUrl = UrlHelpers.join(url, operate);
if(resource === null) if(resource === null)
throw "不能操作空资源对象"; 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({ $http({
method: "POST", method: "POST",
url: RESTfulUrl, url: RESTfulUrl,

@ -13,7 +13,8 @@ module Configs{
port: string; port: string;
serviceName: string; serviceName: string;
tableName: string; tableName: string;
status: string; status: string;
id?:number;
} }
export interface volume{ export interface volume{
@ -60,8 +61,7 @@ module Configs{
result = data; result = data;
} }
} }
}); });
console.log(result);
this.cluster = result; this.cluster = result;
} }
@ -77,8 +77,8 @@ module Configs{
result = data; result = data;
} }
} }
}); });
this.oracleParam = result; this.oracleParam = result;
} }
public getFolderByVolumeName(name: string){ public getFolderByVolumeName(name: string){

@ -9,8 +9,6 @@ module Configs{
($scope, $templateCache:ng.ITemplateCacheService, $location, $routeParams, $http, $timeout, ConfigsModel) =>{ ($scope, $templateCache:ng.ITemplateCacheService, $location, $routeParams, $http, $timeout, ConfigsModel) =>{
$scope.model = ConfigsModel; $scope.model = ConfigsModel;
$scope.volumes = ConfigsModel.cluster; $scope.volumes = ConfigsModel.cluster;
shareInit($scope, $location, $routeParams);
shareInit($scope, $location, $routeParams);
}]); }]);
} }

@ -32,7 +32,7 @@ module Configs{
displayName: "密码" displayName: "密码"
}, },
{ {
field: "database", field: "databaseName",
displayName: "服务名" displayName: "服务名"
}, },
{ {
@ -60,7 +60,7 @@ module Configs{
sortBy: "name", sortBy: "name",
ascending: true ascending: true
} }
} }
shareInit($scope, $location, $routeParams); shareInit($scope, $location, $routeParams);
@ -92,7 +92,7 @@ module Configs{
removeElementsByValue($scope.tableForm, [{key: "name", value: "序号"},{key: "name", value: "连接状态"},{key: "name", value: "操作"}]); removeElementsByValue($scope.tableForm, [{key: "name", value: "序号"},{key: "name", value: "连接状态"},{key: "name", value: "操作"}]);
}) ; }) ;
$scope.$on("deleteRow", (event, data) =>{ $scope.$on("deleteRow", (event, data) =>{
oracleInfoOperate($http, "/java/console/api/oracle", OperateType.DELETE, data, (result, status) => { oracleInfoOperate($http, "/java/console/api/oracle", OperateType.DELETE, data, (result, status) => {
if(status===200){ if(status===200){
$scope.model.updateOracleParam(); $scope.model.updateOracleParam();

@ -2,8 +2,7 @@
/// <reference path="configPlugin.ts"/> /// <reference path="configPlugin.ts"/>
module Configs{ module Configs{
export var EableEdit = controller('EableEdit', ['$scope', ($scope) => { export var EableEdit = controller('EableEdit', ['$scope', ($scope) => {
$scope.editRow = (entity)=>{ $scope.editRow = (entity)=>{
console.log(entity);
$scope.$emit('editRow', entity); $scope.$emit('editRow', entity);
} }

@ -48,7 +48,7 @@
<ul class="fr sj_table_bottom"> <ul class="fr sj_table_bottom">
<li class="mr5 ">当前显示1~7行共7行。</li> <li class="mr5 ">当前显示1~7行共7行。</li>
<li class="mr5 ">每页显示 <li class="mr5 ">每页显示
<select ng-options="value for value in pageSizeChoses" ng-change="selectAction()" ng-model="options.currentTableSize"></select> <select ng-options="value for value in model.paramOptions.pagerSizeOption" ng-change="selectAction()" ng-model="options.currentTableSize"></select>
</li> </li>
<li class="mr5 ">当前页码</li> <li class="mr5 ">当前页码</li>
<li> <li>

@ -29,10 +29,10 @@ module Developer{
return result; return result;
} }
public getPageSizeNum(){ public getPageSizeNum(){
var num = Math.ceil(this.totalSize/this.currentTableSize); var num = Math.ceil(this.totalSize/this.currentTableSize);
if(num < this.currentPageNum) if(num < this.currentPageNum)
num = this.currentPageNum; num = this.currentPageNum;
return num; return num;
} }
} }
@ -101,13 +101,10 @@ module Developer{
export class DataModelService{ export class DataModelService{
public data = []; public data = [];
public paramOptions = null; public paramOptions = new OptionsParams();
constructor(){ constructor(){
this.initParamOptions(); this.updateModel();
//this.updateModel();
this.maybeFormat();
} }
//更新数据模型 //更新数据模型
@ -119,10 +116,9 @@ module Developer{
url : "/java/console/api/data.json", url : "/java/console/api/data.json",
dataType : 'json', dataType : 'json',
data: createParamData(paramOptions), data: createParamData(paramOptions),
success : function(data) { success : function(data) {
console.log(paramOptions);
result = data.data; result = data.data;
paramOptions.totalSize=data.length; paramOptions.totalSize=data.length;
} }
}); });
return result; return result;

@ -11,13 +11,13 @@
module Developer { module Developer {
export var WorkspacesController = controller("WorkspacesController", ["$scope", "KubernetesModel", "DataModel", "ConfigsModel", "KubernetesState", "$templateCache", "$location", "$routeParams", "$http", "$timeout", "KubernetesApiURL", "$element", 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, 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.model=DataModel;
init($scope, $location, $routeParams); init($scope, $location, $routeParams);
$scope.model.initParamOptions();
$scope.options = DataModel.paramOptions; $scope.options = DataModel.paramOptions;
console.log($scope.options);
$scope.pageSizeChoses = DataModel.paramOptions.pagerSizeOption; $scope.pageSizeChoses = DataModel.paramOptions.pagerSizeOption;
$scope.options.dataType = getDataType($location); $scope.options.dataType = getDataType($location);
console.log($scope.volumes);
//console.log(JSON.stringify($scope.volumes[0].folderNode)); //console.log(JSON.stringify($scope.volumes[0].folderNode));
@ -160,23 +160,22 @@ module Developer {
$scope.migrationClick = { $scope.migrationClick = {
items:null, items:null,
selectedItem: $scope.volumes[0] || "当前没有可以迁移的集群", selectedItem: $scope.volumes[0] || {"name": "当前没有可以迁移的集群"},
dialog: new UI.Dialog(), dialog: new UI.Dialog(),
onOk: () => { onOk: () => {
var migrationClick = $scope.migrationClick; var migrationClick = $scope.migrationClick;
var volumeName = migrationClick.selectedItem.name; Configs.oracleInfoOperate($http, "/java/console/api/volume", Configs.OperateType.MOVE,
var selectItems = $scope.tableConfig.selectedItems; {
var selectNode = $scope.selectNode; "name": migrationClick.selectedItem.name,
console.log(migrationClick); "selectItems": $scope.tableConfig.selectedItems,
console.log(selectItems); "selectNode": $scope.selectNode
console.log(selectNode); }, (result, status) => {
/*Configs.oracleInfoOperate($http, "/java/console/api/volume", Configs.OperateType.MOVE, {"id":selectedItem.name}, (result, status) => {
if(status===200){ if(status===200){
//$scope.model.updateOracleParam(); //$scope.model.updateOracleParam();
}else{ }else{
throw "资源请求失败"; throw "资源请求失败";
} }
});*/ });
migrationClick.close(); migrationClick.close();
}, },
open: (selected) =>{ open: (selected) =>{
@ -213,7 +212,6 @@ module Developer {
function init($scope,$location,$routeParams){ function init($scope,$location,$routeParams){
$scope.model.updateModel(); $scope.model.updateModel();
if(ConfigsModel.cluster!=null) if(ConfigsModel.cluster!=null)
$scope.volumes = ConfigsModel.cluster; $scope.volumes = ConfigsModel.cluster;
//创建二级菜单 //创建二级菜单

@ -66,7 +66,7 @@
<button ng-show="model.fetched" <button ng-show="model.fetched"
ng-disabled="!id && tableConfig.selectedItems.length == 0" ng-disabled="!id && tableConfig.selectedItems.length == 0"
class="btn btn-success pull-right sj_btn_grey" class="btn btn-success pull-right sj_btn_grey"
ng-click="extractData.open(id || tableConfig.selectedItems)"> ng-click="extractClick.open(id || tableConfig.selectedItems)">
<i class="glyphicon glyphicon-cloud-download"></i> 汇总 <i class="glyphicon glyphicon-cloud-download"></i> 汇总
</button> </button>
<!--<span ng-include="'runButton.html'"></span>--> <!--<span ng-include="'runButton.html'"></span>-->
@ -92,12 +92,12 @@
</div> </div>
<ng-include src="'resizeDialog.html'"/> <ng-include src="'resizeDialog.html'"/>
<div modal="extractData.dialog.show"> <div modal="extractClick.dialog.show">
<form name="createNamespaceForm" class="" ng-submit="extractData.onOk()"> <form name="selectOracle" class="" ng-submit="extractClick.onOk()">
<div class="modal-header"><h4>数据汇总</h4></div> <div class="modal-header"><h4>数据汇总</h4></div>
<div class="modal-body"> <div class="modal-body">
<div class="form-group" ng-class="{'has-error': createNamespaceForm.$invalid}"> <div class="form-group" ng-class="{'has-error': selectOracle.$invalid}">
<label class="col-sm-3 control-label" for="selectedItem"> <label class="col-sm-3 control-label" for="selectedItem">
数据库名称 数据库名称
<a tabindex="0" role="button" data-toggle="popover" data-trigger="focus" data-html="true" title="" <a tabindex="0" role="button" data-toggle="popover" data-trigger="focus" data-html="true" title=""
@ -107,36 +107,35 @@
</label> </label>
<div class="col-sm-9"> <div class="col-sm-9">
<select ng-model="extractData.selectedItem" class="form-control" <select ng-model="extractClick.selectedItem" class="form-control"
title="name of the new namespace" title="name of the new namespace"
id ="selectedItem" id ="selectedItem"
ng-options="x.name for x in oracleParam"> ng-options="x.name for x in configs.oracleParam">
</select> </select>
<span class="help-block" ng-show="oracleParam.length == 0">
当前没有汇总数据库可以选择,请先创建,可以点击创建汇总数据库按钮进行创建或从汇总页面中的服务器数据列表中启动已创建的汇总数据库!
</span>
</div> </div>
</div> </div>
<hr/> <hr/>
<div class="form-group"> <div class="form-group">
<div class="col-sm-12"> <div class="col-sm-12 alert alert-warning">
<span class="help-block" ng-show="extractData.selectedItem"> <span class="help-block " ng-show="configs.oracleParam.length >0 && extractClick.selectedItem">
<br> <br>
您所选择的数据库数据将会被抽取到汇总数据库: 您所选择的数据库数据将会被抽取到汇总数据库:
<font color="Red"><strong>{{extractData.selectedItem.name}}</strong></font> 中,是否继续请确认! <font color="Red"><strong>{{extractClick.selectedItem.name}}</strong></font> 中,是否继续请确认!
</span> </span>
<span class="help-block" ng-show="configs.oracleParam.length == 0">
当前没有汇总数据库可以选择,请先创建,可以点击创建汇总数据库按钮进行创建或从汇总页面中的服务器数据列表中启动已创建的汇总数据库!
</span>
</div> </div>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<input class="btn btn-primary" type="submit" <input class="btn btn-primary" type="submit"
ng-disabled="oracleParam.length == 0" ng-disabled="configs.oracleParam.length == 0"
value="确定"> value="确定">
<button class="btn btn-warning cancel" type="button" ng-click="extractData.close()">取消</button> <button class="btn btn-warning cancel" type="button" ng-click="extractClick.close()">取消</button>
</div> </div>
</form> </form>
</div> </div>

@ -1801,49 +1801,30 @@ module Kubernetes {
} }
} }
export function extractDataToOracle($http, selectedReplicationControllers, targetReplicationController){ export function extractDataToOracle($http, selectedReplicationControllers, targetOracle: Configs.oracleParam){
//console.log(targetReplicationController.length); //console.log(targetReplicationController.length);
if(selectedReplicationControllers.length ===1 && (getName(selectedReplicationControllers[0]) === getName(targetReplicationController))){ var answer = targetOracle && true;
alert("您选择的数据库中不包含需要汇总的数据库,导致汇总操作失败,请重新选择!"); var inneedOracle = [];
return; selectedReplicationControllers.forEach((rc) => {
} answer = answer && checkoutOracleIsRunning(rc);
var answer = checkoutOracleRCIsRunning(targetReplicationController) && targetReplicationController; inneedOracle.push({
var oracleConnectParam = [{ "name": getName(rc),
OracleName: getName(targetReplicationController), "ip": getHost(rc.$pods[0]),
connectHost: getHost(targetReplicationController.$pods[0]), "port": rc.$pods[0].spec.containers[0].ports[0].hostPort,
connectPort: targetReplicationController.$pods[0].spec.containers[0].ports[0].hostPort, "isTarget": false
isTarget: true });
}]; });
selectedReplicationControllers.forEach((rc) => {
if(getName(rc) !== getName(targetReplicationController)){ if(answer){
answer = answer && checkoutOracleRCIsRunning(rc); var data ={"name": targetOracle.id, "target": targetOracle, "inneed": inneedOracle};
oracleConnectParam.push({ Configs.oracleInfoOperate($http, "/java/console/api/oracle", Configs.OperateType.EXTRACT, data);
"OracleName": getName(rc),
"connectHost": getHost(rc.$pods[0]),
"connectPort": rc.$pods[0].spec.containers[0].ports[0].hostPort,
"isTarget": false
});
}
});
if(answer){
$http({
url: '/extractOracleData',
dataType: 'json',
method:'POST',
params:{param: oracleConnectParam}
}).success(function(data,header,config,status){
console.log("success");
}).error(function(data,header,config,status){
//log.warn("Failed to connect " + connectParam + " " + data + " " + status);
});
}else{ }else{
alert("您选择的汇总数据库或需要汇总的数据库中存在未启动成功的数据库,导致汇总操作失败,请重新选择!"); alert("您选择的汇总数据库或需要汇总的数据库中存在未启动成功的数据库,导致汇总操作失败,请重新选择!");
} }
} }
export function checkoutOracleRCIsRunning(rc){ export function checkoutOracleIsRunning(rc){
if(rc.$podCounters.ready && rc.$oracleStatus == 2){ if(rc.$podCounters.ready && rc.$oracleStatus == 2){
return true return true
}else{ }else{
return false; return false;

@ -12,7 +12,7 @@ module Kubernetes {
$scope.kubernetes = KubernetesState; $scope.kubernetes = KubernetesState;
$scope.configs = ConfigsModel; $scope.configs = ConfigsModel;
$scope.model = KubernetesModel; $scope.model = KubernetesModel;
$scope.tableConfig = { $scope.tableConfig = {
data: 'model.replicationControllers', data: 'model.replicationControllers',
@ -69,7 +69,7 @@ module Kubernetes {
} }
] ]
} }
Kubernetes.initShared($scope, $location, $http, $timeout, $routeParams, KubernetesModel, KubernetesState, KubernetesApiURL); Kubernetes.initShared($scope, $location, $http, $timeout, $routeParams, KubernetesModel, KubernetesState, KubernetesApiURL);
$scope.deletePrompt = (selected) => { $scope.deletePrompt = (selected) => {
@ -175,28 +175,28 @@ module Kubernetes {
startSelected(selected, selected.shift()); startSelected(selected, selected.shift());
}; };
$scope.extractData = { $scope.extractClick = {
items: null, items: null,
selectedItem: $scope.oracleParam[0].name || "当前可用的汇总库", selectedItem: $scope.configs.oracleParam[0] || {name: "当前没有可用的汇总库"},
dialog: new UI.Dialog(), dialog: new UI.Dialog(),
onOk: () => { onOk: () => {
var extractData = $scope.extractData; var extractClick = $scope.extractClick;
extractData.dialog.close(); extractClick.items = $scope.tableConfig.selectedItems;
var filterReplicationController = extractData.selectedItem; Kubernetes.extractDataToOracle($http, extractClick.items, extractClick.selectedItem);
Kubernetes.extractDataToOracle($http, extractData.items, filterReplicationController); //extractClick.selectedItem = $scope.filterReplicationControllers[0] || "";
extractData.selectedItem = $scope.filterReplicationControllers[0] || ""; extractClick.dialog.close();
}, },
open: (selected) => { open: (selected) => {
var extractData = $scope.extractData; var extractClick = $scope.extractClick;
extractData.dialog.open(); extractClick.dialog.open();
extractData.selectedItem = $scope.filterReplicationControllers[0] || ""; /*extractData.selectedItem = $scope.filterReplicationControllers[0] || "";
extractData.items = selected; extractData.items = selected;*/
$timeout(() => { $timeout(() => {
$('#newDataName').focus(); $('#newDataName').focus();
}, 50); }, 50);
}, },
close: () => { close: () => {
$scope.extractData.dialog.close(); $scope.extractClick.dialog.close();
} }
}; };

Loading…
Cancel
Save