完善服务集群管理页面

This commit is contained in:
wu ming 2016-09-11 17:37:24 +08:00
parent bcf440c67a
commit 566cd7c3ad
18 changed files with 166 additions and 206 deletions

View File

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

View File

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

View File

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

View File

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

File diff suppressed because one or more lines are too long

View File

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

View File

@ -31,7 +31,7 @@
<hr>
<div class="row" ng-show="tableForm.length>=0 && (edit || add)" >
<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">
<form class="form-horizontal" ng-submit="onSubmit(validForm.$valid)" novalidate="novalidate" name="validForm">
<div class="form-group" ng-repeat="item in tableForm">

View File

@ -7,6 +7,7 @@ module Configs{
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) => {
@ -83,14 +84,17 @@ module Configs{
}
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)
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({
method: "POST",
url: RESTfulUrl,

View File

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

View File

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

View File

@ -32,7 +32,7 @@ module Configs{
displayName: "密码"
},
{
field: "database",
field: "databaseName",
displayName: "服务名"
},
{
@ -60,7 +60,7 @@ module Configs{
sortBy: "name",
ascending: true
}
}
}
shareInit($scope, $location, $routeParams);
@ -92,7 +92,7 @@ module Configs{
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) => {
if(status===200){
$scope.model.updateOracleParam();

View File

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

View File

@ -48,7 +48,7 @@
<ul class="fr sj_table_bottom">
<li class="mr5 ">当前显示1~7行共7行。</li>
<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 class="mr5 ">当前页码</li>
<li>

View File

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

View File

@ -11,13 +11,13 @@
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;
init($scope, $location, $routeParams);
$scope.model.initParamOptions();
$scope.model=DataModel;
init($scope, $location, $routeParams);
$scope.options = DataModel.paramOptions;
console.log($scope.options);
$scope.pageSizeChoses = DataModel.paramOptions.pagerSizeOption;
$scope.options.dataType = getDataType($location);
console.log($scope.volumes);
//console.log(JSON.stringify($scope.volumes[0].folderNode));
@ -160,23 +160,22 @@ module Developer {
$scope.migrationClick = {
items:null,
selectedItem: $scope.volumes[0] || "当前没有可以迁移的集群",
selectedItem: $scope.volumes[0] || {"name": "当前没有可以迁移的集群"},
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) => {
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 "资源请求失败";
}
});*/
});
migrationClick.close();
},
open: (selected) =>{
@ -213,7 +212,6 @@ module Developer {
function init($scope,$location,$routeParams){
$scope.model.updateModel();
if(ConfigsModel.cluster!=null)
$scope.volumes = ConfigsModel.cluster;
//创建二级菜单

View File

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

View File

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

View File

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