增加服务集群配置功能

Web_Manager_Develope
wu ming 8 years ago
parent 18e2092d22
commit 7698e63eb0

@ -0,0 +1,4 @@
/// <reference path="../../includes.d.ts" />
declare module Configs {
function removeElementByValue(array: Array<any>, value: any, key?: string): void;
}

@ -0,0 +1,29 @@
/// <reference path="../../includes.d.ts" />
/// <reference path="configPlugin.d.ts" />
declare module Configs {
interface Block {
ip: string;
path: string;
}
interface oracleParam {
name: string;
ip: string;
port: string;
serviceName: string;
tableName: string;
status: string;
}
interface volume {
name: string;
totalSize: number;
usedSize: number;
block: Block;
folder?: Array<any>;
}
class ConfigsModelService {
cluster: Array<volume>;
oracleParam: Array<oracleParam>;
updateVolumeData($scope: any, $http: any): void;
getFolderByVolumeName(name: string): any[];
}
}

@ -0,0 +1,5 @@
/// <reference path="../../includes.d.ts" />
declare module Configs {
function removeElementByValue(array: Array<any>, value: any, key?: string): void;
function removeElementsByValue(array: Array<any>, elements: Array<any>): void;
}

@ -0,0 +1,6 @@
/// <reference path="../../includes.d.ts" />
/// <reference path="configPlugin.d.ts" />
/// <reference path="configsHelper.d.ts" />
declare module Configs {
var GfsController: ng.IModule;
}

@ -0,0 +1,7 @@
/// <reference path="../../includes.d.ts" />
/// <reference path="configPlugin.d.ts" />
/// <reference path="configsHelper.d.ts" />
/// <reference path="configsUtils.d.ts" />
declare module Configs {
var KubeController: ng.IModule;
}

@ -0,0 +1,5 @@
/// <reference path="../../includes.d.ts" />
/// <reference path="configPlugin.d.ts" />
declare module Configs {
var EableEdit: ng.IModule;
}

@ -0,0 +1,21 @@
<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">
<input class="form-control" type="text" ng-model="mode.name" id="orcName" ng-minlength="4" ng-maxlength="20">
<span class="glyphicon glyphicon-ok form-control-feedback" ng-show="validForm.orcName.$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.name" id="orcName" ng-minlength="4" ng-maxlength="20">
<span class="glyphicon glyphicon-ok form-control-feedback" ng-show="validForm.orcName.$valid" />
</div>
</div>
<div class="form-group">
<button class="btn" type='submit'>
<span class="glyphicon glyphicon-save"></span> 保存
</button>
</div>
</form>

@ -0,0 +1,18 @@
<script type="text/ng-template" id="tableEdit.html" >
<div class="ngCellText" ng-init="entity=row.entity" ng-controller="Configs.EableEdit">
<button class="btn" ng-click="editRow(entity)">
<span class="glyphicon glyphicon-pencil"></span>&nbsp;&nbsp;编辑
</button>
<span class="pull-right">&nbsp;</span>
<button class="btn" ng-click="deleteRow(entity)">
<span class="glyphicon glyphicon-trash"></span>&nbsp;&nbsp;删除
</button>
</div>
</script>
<script type="text/ng-template" id="connectStatus.html">
</script>
<div ng-controller="Kubernetes.TopLevel">
<div class="wiki-icon-view" ng-controller="Kubernetes.FileDropController" nv-file-drop nv-file-over uploader="uploader" over-class="ready-drop">
<div class="row kubernetes-view" ng-view></div>
</div>
</div>

@ -0,0 +1,70 @@
/// <reference path="../../includes.ts"/>
/// <reference path="configPlugin.ts"/>
module Configs{
export interface Block{
ip:string; //存储块的机器ip地址
path: string; //路径
}
export interface oracleParam{
name: string
ip: string;
port: string;
serviceName: string;
tableName: string;
status: string;
}
export interface volume{
name: string; //volume的名字
totalSize: number; //volume空间大小
usedSize: number; // volume已使用空间大小
block: Block; //volume中的存储块
folder?: Array<any>; //volume的文件
}
//字节大小转换成字符大小
function getStringSize(size: number){
var result = size;
var suffix =["B", "KB" ,"MB", "GB", "GB", "TB"];
var count=1;
while(result > 1024){
result = result/1024;
count ++;
}
return result + suffix[count];
}
export class ConfigsModelService{
public cluster: Array<volume>=[];
public oracleParam: Array<oracleParam>;
public updateVolumeData($scope: ConfigsModelService, $http){
console.log($scope);
$http({
method: "POST",
url: "/java/console/api/volume/list"
}).success(function(data, status, headers, config) {
$scope.cluster.push(data);
}).error(function(data, status, headers, config) {
//$scope.voume=data;
});
}
public getFolderByVolumeName(name: string){
if(this.cluster===null)
return null;
for(var i=0; i< this.cluster.length; i++){
if(this.cluster[i].name === name)
return this.cluster[i].folder;
}
}
}
_module.factory('ConfigsModel', ['$rootScope', '$http', '$location', '$resource', ($rootScope, $http, $location, $resource) =>{
var $scope = new ConfigsModelService();
return $scope;
}]);
}

@ -0,0 +1,27 @@
/// <reference path="../../includes.ts"/>
module Configs{
export function removeElementByValue(array:Array<any> ,value:any, key?:string ){
if(key){
for(var i=0; i<array.length; i++){
if(array[i][key] === value){
array.splice(i ,1);
break;
}
}
}else{
for(var i=0 ; i<array.length; i++){
if(array[i] === value){
array.splice(i ,1);
break;
}
}
}
}
export function removeElementsByValue(array: Array<any>, elements:Array<any>){
angular.forEach(elements, (element) =>{
removeElementByValue(array, element.value, element.key);
});
}
}

@ -0,0 +1,109 @@
/// <reference path="../../includes.ts"/>
/// <reference path="configPlugin.ts"/>
/// <reference path="configsHelper.ts"/>
/// <reference path="configsUtils.ts"/>
module Configs{
export var KubeController = controller('KubeController', ["$scope", "$templateCache", "$location", "$routeParams", "$http", "$timeout",
($scope, $templateCache:ng.ITemplateCacheService, $location, $routeParams, $http, $timeout) => {
$scope.model= [{
"name": "",
"status": "OK",
"ip": "10.188.2.3",
"_id": 1
},
{
"name": "camel-041",
"status": "OK",
"ip": "10.188.2.20",
"_id": 2
},
{
"name": "activemq-004",
"status": "failed",
"ip": "10.188.2.111",
"_id": 3
}];
$scope.tableConfig={
data: "model",
selectedItems: [{
name: "activemq-004",
status: "failed",
ip: "10.188.2.111",
_id: 2
}],
columnDefs: [{
field: "_id",
displayName: "序号"
},
{
field: "name",
displayName: "名称"
},
{
field: "ip",
displayName: "IP"
},
{
field: "port",
displayName: "端口号"
},
{
field: "userName",
displayName: "用户名"
},
{
field: "password",
displayName: "密码"
},
{
field: "serviceName",
displayName: "服务名"
},
{
field: "status",
displayName: "连接状态"
},
{
field: "entity",
displayName: "操作",
cellTemplate: $templateCache.get("tableEdit.html")
}],
enableRowClickSelection: true,
showSelectionCheckbox: false,
multiSelect: false,
sortInfo: {
sortBy: "_id",
ascending: true
}
}
shareInit($scope, $location, $routeParams);
$scope.create = () =>{
$scope.add= true;
$scope.edit = false;
$scope.tableForm = createNewObejct($scope.tableConfig.columnDefs, null);
removeElementsByValue($scope.tableForm, [{key: "name", value: "序号"},{key: "name", value: "连接状态"},{key: "name", value: "操作"}]);
}
$scope.onSubmit = () => {
$scope.edit = false;
$scope.add = false;
console.log($scope.tableForm);
}
$scope.$on("editRow", (event, data) =>{
$scope.edit = true;
$scope.add = false;
$scope.tableForm = createNewObejct($scope.tableConfig.columnDefs, data);
removeElementsByValue($scope.tableForm, [{key: "name", value: "序号"},{key: "name", value: "连接状态"},{key: "name", value: "操作"}]);
}) ;
$scope.$on("deleteRow", (event, data) =>{
removeElementByValue($scope.model, data._id, "_id");
}) ;
}]);
}

@ -0,0 +1,13 @@
/// <reference path="../../includes.ts"/>
/// <reference path="configPlugin.ts"/>
module Configs{
export var EableEdit = controller('EableEdit', ['$scope', ($scope) => {
$scope.editRow = (entity)=>{
$scope.$emit('editRow', entity);
}
$scope.deleteRow = (entity) =>{
$scope.$emit('deleteRow', entity);
}
}]);
}
Loading…
Cancel
Save