添加gfs中brock的删增功能

Web_Manager_Develope
wu ming 8 years ago
parent ab2ccee7ff
commit 669d2c84ab

@ -5,6 +5,8 @@ declare module Configs {
ip: string;
path: string;
status: boolean;
availableSize?: number;
usedSize?: number;
}
interface oracleParam {
name: string;
@ -17,13 +19,21 @@ declare module Configs {
}
interface volume {
name: string;
totalSize: number;
allSize: number;
usedSize: number;
brick: Block;
brick: Array<Block>;
folder?: Array<any>;
status: string;
path: string;
}
/**
volumebrock
*/
function deleteBrock(volume: volume, brock: Block): void;
/**
volumebrock
*/
function addBrock(volume: volume, brock: Block): void;
class ConfigsModelService {
cluster: Array<volume>;
oracleParam: Array<oracleParam>;

@ -4,6 +4,7 @@
/// <reference path="configsUtils.d.ts" />
/// <reference path="configsDataService.d.ts" />
/// <reference path="../../kubernetes/ts/term.d.ts" />
/// <reference path="shareController.d.ts" />
declare module Configs {
var GfsController: ng.IModule;
}

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

2
defs.d.ts vendored

@ -13,10 +13,10 @@
/// <reference path="d.ts/kubernetes/ts/kubernetesPlugin.d.ts"/>
/// <reference path="d.ts/kubernetes/ts/watcher.d.ts"/>
/// <reference path="d.ts/kubernetes/ts/term.d.ts"/>
/// <reference path="d.ts/configs/ts/shareController.d.ts"/>
/// <reference path="d.ts/configs/ts/glusterfsSetting.d.ts"/>
/// <reference path="d.ts/configs/ts/kubeClusterSetting.d.ts"/>
/// <reference path="d.ts/configs/ts/regionalismCodeSearch.d.ts"/>
/// <reference path="d.ts/configs/ts/shareController.d.ts"/>
/// <reference path="d.ts/configs/ts/systemCodeSearch.d.ts"/>
/// <reference path="d.ts/developer/ts/developerPlugin.d.ts"/>
/// <reference path="d.ts/developer/ts/dataManagerModel.d.ts"/>

File diff suppressed because one or more lines are too long

@ -30,7 +30,7 @@
</th>
<th class="no-fade table-header">
<span class="">已用&nbsp;{{volume.usedSize}}&nbsp;&nbsp;/&nbsp;&nbsp;&nbsp;{{volume.allSize}}</span>
<span class="">已用&nbsp;{{volume.formatUsedSize}}&nbsp;&nbsp;/&nbsp;&nbsp;&nbsp;{{volume.formatTotalSize}}</span>
</th>
<th class="no-fade table-header sj_table_td01">
@ -55,7 +55,7 @@
<span class="sj_table_td02">存储路径:{{row.path}}</span>
</td>
<td >
<span class="">已用&nbsp;{{row.usedSize}}&nbsp;&nbsp;/&nbsp;&nbsp;&nbsp;{{row.availableSize}}</span>
<span class="">已用&nbsp;{{row.formatUsedSize}}&nbsp;&nbsp;/&nbsp;&nbsp;&nbsp;{{row.formatAllSize}}</span>
</td>
<td></td>
</tr>

@ -38,7 +38,10 @@
</th>
</tr>
<tr ng-repeat = "row in ngDialogData.brick">
<th class="new_left"><span ng-show ="row.status" class="sj_icon_ok"></span><span ng-hide = "row.status" class="sj_icon_warning"></th>
<th class="new_left">
<span ng-show ="row.status" class="sj_icon_ok"></span>
<span ng-hide = "row.status" class="sj_icon_warning">
</th>
<th colspan="3">
<input type="text" class="sj_txt_box04 mr5" value="服务器 {{$index + 1}} "/>
</th>
@ -62,7 +65,9 @@
<input type="text" class="sj_txt_box02 mr5" ng-model="row.path" />
</th>
<th>
<button class="sj_btn_grey fl">连接</button><a href="#" class="sj_icon_del ml5 fl"></a><a href="#"ng-hide ="$index < ngDialogData.brick.length-1" class="sj_icon_add ml5 fl"></a>
<button class="sj_btn_grey fl">连接</button>
<a href="#" class="sj_icon_del ml5 fl" ng-click="deleteBrock(ngDialogData, row)"></a>
<a href="#" ng-hide ="$index < ngDialogData.brick.length-1" class="sj_icon_add ml5 fl" ng-click="addBrock(ngDialogData)"></a>
</th>
</tr>
<tr>
@ -76,10 +81,11 @@
<th>
<button class="sj_btn_grey mr5" ng-click="cancel()">取消</button>
</th>
<th colspan="5">&nbsp;</th>
<!--<th colspan="5">&nbsp;{{message}}</th>-->
</tr>
</tbody>
</table>
<div class="alert alert-warning" role="alert" ng-show="showMessage">"删除存储块失败:集群中至少包含一个存储块!"</div>
</div>
</div>
</script>

@ -4,8 +4,10 @@ module Configs{
export interface Block{
ip:string; //存储块的机器ip地址
path: string; //路径
status: boolean;
path: string; //存储块路径
status: boolean; //存储块的状态
availableSize?: number, //存储块的大小
usedSize?: number //存储块已使用空间
}
export interface oracleParam{
@ -20,9 +22,9 @@ module Configs{
export interface volume{
name: string; //volume的名字
totalSize: number; //volume空间大小
allSize: number; //volume空间大小
usedSize: number; // volume已使用空间大小
brick: Block; //volume中的存储块
brick: Array<Block>; //volume中的存储块
folder?: Array<any>; //volume的文件
status: string;
path: string;
@ -31,15 +33,54 @@ module Configs{
//字节大小转换成字符大小
function getStringSize(size: number){
var result = size;
var suffix =["B", "KB" ,"MB", "GB", "GB", "TB"];
var suffix =["B", "KB" ,"MB", "GB", "TB", "PB"];
var count=1;
while(result > 1024){
while(result >= 1024){
result = result/1024;
count ++;
}
return result + suffix[count];
return result.toFixed(2) + suffix[count];
}
function formatVolume(volume:volume){
volume["formatTotalSize"] = getStringSize(volume.allSize);
volume["formatUsedSize"] = getStringSize(volume.usedSize);
angular.forEach(volume.brick, (brock) =>{
brock["formatUsedSize"] = getStringSize(brock.usedSize);
brock["formatAllSize"] = getStringSize(brock.availableSize);
})
}
function formatVolumes(volumes:Array<volume>){
angular.forEach(volumes, (volume) => {
formatVolume(volume);
})
}
function IsBrockEquals(brock1: Block, brock2: Block){
return brock1.ip == brock2.ip && brock1.path == brock2.path;
}
/**
volumebrock
*/
export function deleteBrock(volume:volume, brock:Block){
for(var i = 0; i < volume.brick.length; i++){
var brick = volume.brick[i];
if(IsBrockEquals(brick, brock)){
volume.brick.splice(i, 1);
break;
}
}
}
/**
volumebrock
*/
export function addBrock(volume:volume, brock:Block){
if(brock != null && brock != undefined)
volume.brick.push(brock);
}
export class ConfigsModelService{
public cluster: Array<volume>=[];
@ -69,7 +110,7 @@ module Configs{
}
});
this.cluster = result;
formatVolumes(this.cluster);
}
public updateCodeInfo(){

@ -4,6 +4,7 @@
/// <reference path="configsUtils.ts"/>
/// <reference path="configsDataService.ts"/>
/// <reference path="../../kubernetes/ts/term.ts"/>
/// <reference path="shareController.ts"/>
module Configs{
export var GfsController = controller('GfsController', ["$scope", "$templateCache", "$location", "$routeParams", "$http", "$timeout", 'ConfigsModel', 'ngDialog',
@ -15,6 +16,7 @@ module Configs{
$scope.createGfs = () => {
ngDialog.open({
template: 'newDialog.html',
controller:'Configs.VolumeController',
width: 1005,
data: {
name: null,
@ -26,15 +28,7 @@ module Configs{
status: false
}]
},
className: 'ngdialog-theme-default',
controller: ['$scope', function($scope) {
$scope.save = () =>{
$scope.closeThisDialog();
}
$scope. cancel = () =>{
$scope.closeThisDialog();
}
}]
className: 'ngdialog-theme-default'
});
}
@ -45,15 +39,7 @@ module Configs{
width: 1005,
data: fVolume,
className: 'ngdialog-theme-default',
controller: ['$scope', function($scope) {
console.log($scope);
$scope.save = () =>{
$scope.closeThisDialog();
}
$scope. cancel = () =>{
$scope.closeThisDialog();
}
}]
controller: 'Configs.VolumeController'
});
}
}]);

@ -1,5 +1,6 @@
/// <reference path="../../includes.ts"/>
/// <reference path="configPlugin.ts"/>
/// <reference path="configsDataService.ts"/>
module Configs{
export var TableEdit = controller('TableEdit', ['$scope', ($scope) => {
$scope.editRow = (entity)=>{
@ -10,4 +11,30 @@ module Configs{
$scope.$emit('deleteRow', entity);
}
}]);
export var VolumeController = controller('VolumeController', ['$scope', ($scope) => {
$scope.save = () =>{
$scope.closeThisDialog();
}
$scope. cancel = () =>{
$scope.closeThisDialog();
}
$scope.deleteBrock = (volume:volume, brock) => {
if(volume.brick.length>1)
deleteBrock(volume, brock);
else
$scope.showMessage = true;
}
$scope.addBrock = (volume) => {
var block = {
ip: "", //存储块的机器ip地址
path: "", //存储块路径
status: false, //存储块的状态
};
addBrock(volume, block);
$scope.showMessage = false;
}
}]);
}

@ -47,7 +47,7 @@ module Kubernetes {
export class resourceRCTemplate{
public image="oracle:utf8";
public names = ["admin","cfgtoollogs","checkpoints","diag","flash-recovery-area","oradata"];
public names = ["oradata"];
public createRC(Obj){
var labels = {

Loading…
Cancel
Save