From 7698e63eb0bebb0fa198ae718e8700a8e8d7bcc3 Mon Sep 17 00:00:00 2001
From: wu ming <569287825@qq.com>
Date: Fri, 9 Sep 2016 15:17:33 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9C=8D=E5=8A=A1=E9=9B=86?=
=?UTF-8?q?=E7=BE=A4=E9=85=8D=E7=BD=AE=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
d.ts/configs/ts/configUtils.d.ts | 4 +
d.ts/configs/ts/configsDataService.d.ts | 29 ++++++
d.ts/configs/ts/configsUtils.d.ts | 5 ++
d.ts/configs/ts/glusterfsSetting.d.ts | 6 ++
d.ts/configs/ts/kubeClusterSetting.d.ts | 7 ++
d.ts/configs/ts/shareController.d.ts | 5 ++
plugins/configs/html/kubeForm.html | 21 +++++
plugins/configs/html/shareLayout.html | 18 ++++
plugins/configs/ts/configsDataService.ts | 70 +++++++++++++++
plugins/configs/ts/configsUtils.ts | 27 ++++++
plugins/configs/ts/kubeClusterSetting.ts | 109 +++++++++++++++++++++++
plugins/configs/ts/shareController.ts | 13 +++
12 files changed, 314 insertions(+)
create mode 100644 d.ts/configs/ts/configUtils.d.ts
create mode 100644 d.ts/configs/ts/configsDataService.d.ts
create mode 100644 d.ts/configs/ts/configsUtils.d.ts
create mode 100644 d.ts/configs/ts/glusterfsSetting.d.ts
create mode 100644 d.ts/configs/ts/kubeClusterSetting.d.ts
create mode 100644 d.ts/configs/ts/shareController.d.ts
create mode 100644 plugins/configs/html/kubeForm.html
create mode 100644 plugins/configs/html/shareLayout.html
create mode 100644 plugins/configs/ts/configsDataService.ts
create mode 100644 plugins/configs/ts/configsUtils.ts
create mode 100644 plugins/configs/ts/kubeClusterSetting.ts
create mode 100644 plugins/configs/ts/shareController.ts
diff --git a/d.ts/configs/ts/configUtils.d.ts b/d.ts/configs/ts/configUtils.d.ts
new file mode 100644
index 00000000..170ffb95
--- /dev/null
+++ b/d.ts/configs/ts/configUtils.d.ts
@@ -0,0 +1,4 @@
+///
+declare module Configs {
+ function removeElementByValue(array: Array, value: any, key?: string): void;
+}
diff --git a/d.ts/configs/ts/configsDataService.d.ts b/d.ts/configs/ts/configsDataService.d.ts
new file mode 100644
index 00000000..3267c3b7
--- /dev/null
+++ b/d.ts/configs/ts/configsDataService.d.ts
@@ -0,0 +1,29 @@
+///
+///
+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;
+ }
+ class ConfigsModelService {
+ cluster: Array;
+ oracleParam: Array;
+ updateVolumeData($scope: any, $http: any): void;
+ getFolderByVolumeName(name: string): any[];
+ }
+}
diff --git a/d.ts/configs/ts/configsUtils.d.ts b/d.ts/configs/ts/configsUtils.d.ts
new file mode 100644
index 00000000..df2e6728
--- /dev/null
+++ b/d.ts/configs/ts/configsUtils.d.ts
@@ -0,0 +1,5 @@
+///
+declare module Configs {
+ function removeElementByValue(array: Array, value: any, key?: string): void;
+ function removeElementsByValue(array: Array, elements: Array): void;
+}
diff --git a/d.ts/configs/ts/glusterfsSetting.d.ts b/d.ts/configs/ts/glusterfsSetting.d.ts
new file mode 100644
index 00000000..932d1dd8
--- /dev/null
+++ b/d.ts/configs/ts/glusterfsSetting.d.ts
@@ -0,0 +1,6 @@
+///
+///
+///
+declare module Configs {
+ var GfsController: ng.IModule;
+}
diff --git a/d.ts/configs/ts/kubeClusterSetting.d.ts b/d.ts/configs/ts/kubeClusterSetting.d.ts
new file mode 100644
index 00000000..03686212
--- /dev/null
+++ b/d.ts/configs/ts/kubeClusterSetting.d.ts
@@ -0,0 +1,7 @@
+///
+///
+///
+///
+declare module Configs {
+ var KubeController: ng.IModule;
+}
diff --git a/d.ts/configs/ts/shareController.d.ts b/d.ts/configs/ts/shareController.d.ts
new file mode 100644
index 00000000..3f612af7
--- /dev/null
+++ b/d.ts/configs/ts/shareController.d.ts
@@ -0,0 +1,5 @@
+///
+///
+declare module Configs {
+ var EableEdit: ng.IModule;
+}
diff --git a/plugins/configs/html/kubeForm.html b/plugins/configs/html/kubeForm.html
new file mode 100644
index 00000000..5305d1d5
--- /dev/null
+++ b/plugins/configs/html/kubeForm.html
@@ -0,0 +1,21 @@
+
diff --git a/plugins/configs/html/shareLayout.html b/plugins/configs/html/shareLayout.html
new file mode 100644
index 00000000..d7aafc0d
--- /dev/null
+++ b/plugins/configs/html/shareLayout.html
@@ -0,0 +1,18 @@
+
+
+
diff --git a/plugins/configs/ts/configsDataService.ts b/plugins/configs/ts/configsDataService.ts
new file mode 100644
index 00000000..d9c6617e
--- /dev/null
+++ b/plugins/configs/ts/configsDataService.ts
@@ -0,0 +1,70 @@
+///
+///
+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; //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=[];
+ public oracleParam: Array;
+
+ 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;
+ }]);
+}
\ No newline at end of file
diff --git a/plugins/configs/ts/configsUtils.ts b/plugins/configs/ts/configsUtils.ts
new file mode 100644
index 00000000..719b88fe
--- /dev/null
+++ b/plugins/configs/ts/configsUtils.ts
@@ -0,0 +1,27 @@
+///
+
+module Configs{
+ export function removeElementByValue(array:Array ,value:any, key?:string ){
+ if(key){
+ for(var i=0; i, elements:Array){
+ angular.forEach(elements, (element) =>{
+ removeElementByValue(array, element.value, element.key);
+ });
+ }
+}
\ No newline at end of file
diff --git a/plugins/configs/ts/kubeClusterSetting.ts b/plugins/configs/ts/kubeClusterSetting.ts
new file mode 100644
index 00000000..6ead5770
--- /dev/null
+++ b/plugins/configs/ts/kubeClusterSetting.ts
@@ -0,0 +1,109 @@
+///
+///
+///
+///
+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");
+ }) ;
+ }]);
+}
\ No newline at end of file
diff --git a/plugins/configs/ts/shareController.ts b/plugins/configs/ts/shareController.ts
new file mode 100644
index 00000000..e4b39341
--- /dev/null
+++ b/plugins/configs/ts/shareController.ts
@@ -0,0 +1,13 @@
+///
+///
+module Configs{
+ export var EableEdit = controller('EableEdit', ['$scope', ($scope) => {
+ $scope.editRow = (entity)=>{
+ $scope.$emit('editRow', entity);
+ }
+
+ $scope.deleteRow = (entity) =>{
+ $scope.$emit('deleteRow', entity);
+ }
+ }]);
+}
\ No newline at end of file