2017-05-17 07:29:27 +02:00
|
|
|
// Copyright (c) 2017 VMware, Inc. All Rights Reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
2022-05-13 10:00:45 +02:00
|
|
|
import {
|
|
|
|
Component,
|
2023-03-17 11:52:23 +01:00
|
|
|
ElementRef,
|
2022-05-13 10:00:45 +02:00
|
|
|
EventEmitter,
|
|
|
|
Input,
|
2023-03-17 11:52:23 +01:00
|
|
|
OnDestroy,
|
2022-11-18 07:39:26 +01:00
|
|
|
OnInit,
|
2022-05-13 10:00:45 +02:00
|
|
|
Output,
|
|
|
|
ViewChild,
|
|
|
|
} from '@angular/core';
|
|
|
|
import { TranslateService } from '@ngx-translate/core';
|
|
|
|
import { catchError, finalize, map } from 'rxjs/operators';
|
|
|
|
import { forkJoin, Observable, throwError as observableThrowError } from 'rxjs';
|
|
|
|
import { ConfirmationDialogComponent } from '../../../../../shared/components/confirmation-dialog';
|
|
|
|
import {
|
|
|
|
ConfirmationButtons,
|
|
|
|
ConfirmationState,
|
|
|
|
ConfirmationTargets,
|
|
|
|
} from '../../../../../shared/entities/shared.const';
|
|
|
|
import { ErrorHandler } from '../../../../../shared/units/error-handler';
|
2022-05-05 11:36:11 +02:00
|
|
|
import {
|
|
|
|
clone,
|
2023-03-14 07:41:16 +01:00
|
|
|
getHiddenArrayFromLocalStorage,
|
2022-05-13 10:00:45 +02:00
|
|
|
getPageSizeFromLocalStorage,
|
|
|
|
getQueryString,
|
2022-05-05 11:36:11 +02:00
|
|
|
getSortingString,
|
|
|
|
PageSizeMapKeys,
|
2023-03-14 07:41:16 +01:00
|
|
|
setHiddenArrayToLocalStorage,
|
2022-05-13 10:00:45 +02:00
|
|
|
setPageSizeToLocalStorage,
|
|
|
|
} from '../../../../../shared/units/utils';
|
|
|
|
import {
|
|
|
|
operateChanges,
|
|
|
|
OperateInfo,
|
|
|
|
OperationState,
|
|
|
|
} from '../../../../../shared/components/operation/operate';
|
|
|
|
import { OperationService } from '../../../../../shared/components/operation/operation.service';
|
2023-03-17 11:52:23 +01:00
|
|
|
import { ClrDatagrid, ClrDatagridStateInterface } from '@clr/angular';
|
2022-05-13 10:00:45 +02:00
|
|
|
import { errorHandler } from '../../../../../shared/units/shared.utils';
|
|
|
|
import { ConfirmationAcknowledgement } from '../../../../global-confirmation-dialog/confirmation-state-message';
|
|
|
|
import { ConfirmationMessage } from '../../../../global-confirmation-dialog/confirmation-message';
|
|
|
|
import { BandwidthUnit, Flatten_I18n_MAP } from '../../replication';
|
|
|
|
import { KB_TO_MB } from '../create-edit-rule/create-edit-rule.component';
|
|
|
|
import { ReplicationService } from 'ng-swagger-gen/services/replication.service';
|
2022-05-05 11:36:11 +02:00
|
|
|
import { ReplicationPolicy } from '../../../../../../../ng-swagger-gen/models/replication-policy';
|
2022-11-18 07:39:26 +01:00
|
|
|
import { ReplicationTrigger } from '../../../../../../../ng-swagger-gen/models/replication-trigger';
|
|
|
|
import {
|
|
|
|
TRIGGER,
|
|
|
|
TRIGGER_I18N_MAP,
|
|
|
|
} from '../../../../project/p2p-provider/p2p-provider.service';
|
|
|
|
import { ScheduleService } from '../../../../../../../ng-swagger-gen/services/schedule.service';
|
|
|
|
import { JobType } from '../../../job-service-dashboard/job-service-dashboard.interface';
|
2022-05-05 11:36:11 +02:00
|
|
|
|
2017-05-17 07:29:27 +02:00
|
|
|
@Component({
|
2022-05-13 10:00:45 +02:00
|
|
|
selector: 'hbr-list-replication-rule',
|
|
|
|
templateUrl: './list-replication-rule.component.html',
|
|
|
|
styleUrls: ['./list-replication-rule.component.scss'],
|
2017-05-17 07:29:27 +02:00
|
|
|
})
|
2023-03-17 11:52:23 +01:00
|
|
|
export class ListReplicationRuleComponent implements OnInit, OnDestroy {
|
2018-05-21 13:05:38 +02:00
|
|
|
@Input() selectedId: number | string;
|
|
|
|
@Input() withReplicationJob: boolean;
|
2019-01-09 09:08:56 +01:00
|
|
|
@Input() hasCreateReplicationPermission: boolean;
|
|
|
|
@Input() hasUpdateReplicationPermission: boolean;
|
|
|
|
@Input() hasDeleteReplicationPermission: boolean;
|
|
|
|
@Input() hasExecuteReplicationPermission: boolean;
|
2021-03-17 07:32:45 +01:00
|
|
|
@Input() searchString: string;
|
2022-05-05 11:36:11 +02:00
|
|
|
@Output() selectOne = new EventEmitter<ReplicationPolicy>();
|
|
|
|
@Output() editOne = new EventEmitter<ReplicationPolicy>();
|
|
|
|
@Output() toggleOne = new EventEmitter<ReplicationPolicy>();
|
2018-05-21 13:05:38 +02:00
|
|
|
@Output() hideJobs = new EventEmitter<any>();
|
2022-05-05 11:36:11 +02:00
|
|
|
@Output() redirect = new EventEmitter<ReplicationPolicy>();
|
2018-05-21 13:05:38 +02:00
|
|
|
@Output() openNewRule = new EventEmitter<any>();
|
2022-05-05 11:36:11 +02:00
|
|
|
@Output() replicateManual = new EventEmitter<ReplicationPolicy>();
|
|
|
|
rules: ReplicationPolicy[] = [];
|
|
|
|
selectedRow: ReplicationPolicy;
|
2022-05-13 10:00:45 +02:00
|
|
|
@ViewChild('toggleConfirmDialog')
|
2018-05-21 13:05:38 +02:00
|
|
|
toggleConfirmDialog: ConfirmationDialogComponent;
|
2022-05-13 10:00:45 +02:00
|
|
|
@ViewChild('deletionConfirmDialog')
|
2018-05-21 13:05:38 +02:00
|
|
|
deletionConfirmDialog: ConfirmationDialogComponent;
|
2020-10-16 11:17:33 +02:00
|
|
|
page: number = 1;
|
2022-05-13 10:00:45 +02:00
|
|
|
pageSize: number = getPageSizeFromLocalStorage(
|
|
|
|
PageSizeMapKeys.LIST_REPLICATION_RULE_COMPONENT,
|
|
|
|
5
|
|
|
|
);
|
2020-10-16 11:17:33 +02:00
|
|
|
totalCount: number = 0;
|
|
|
|
loading: boolean = true;
|
2017-05-17 07:29:27 +02:00
|
|
|
|
2022-11-18 07:39:26 +01:00
|
|
|
paused: boolean = false;
|
2023-03-14 07:41:16 +01:00
|
|
|
hiddenArray: boolean[] = getHiddenArrayFromLocalStorage(
|
|
|
|
PageSizeMapKeys.LIST_REPLICATION_RULE_COMPONENT,
|
|
|
|
[false, false, false, false, false, false, false, true, true]
|
|
|
|
);
|
2023-03-17 11:52:23 +01:00
|
|
|
@ViewChild('datagrid')
|
|
|
|
datagrid: ClrDatagrid;
|
2022-05-13 10:00:45 +02:00
|
|
|
constructor(
|
|
|
|
private replicationService: ReplicationService,
|
|
|
|
private translateService: TranslateService,
|
|
|
|
private errorHandlerEntity: ErrorHandler,
|
2022-11-18 07:39:26 +01:00
|
|
|
private operationService: OperationService,
|
|
|
|
private scheduleService: ScheduleService
|
2023-03-17 11:52:23 +01:00
|
|
|
) {}
|
2018-01-26 11:10:39 +01:00
|
|
|
|
2022-11-18 07:39:26 +01:00
|
|
|
ngOnInit() {
|
|
|
|
this.scheduleService
|
|
|
|
.getSchedulePaused({ jobType: JobType.ALL })
|
|
|
|
.subscribe(res => {
|
|
|
|
this.paused = res?.paused;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-03-17 11:52:23 +01:00
|
|
|
ngOnDestroy(): void {
|
|
|
|
this.datagrid['columnsService']?.columns?.forEach((item, index) => {
|
|
|
|
this.hiddenArray[index] = !!item?._value?.hidden;
|
|
|
|
});
|
|
|
|
setHiddenArrayToLocalStorage(
|
|
|
|
PageSizeMapKeys.LIST_REPLICATION_RULE_COMPONENT,
|
|
|
|
this.hiddenArray
|
|
|
|
);
|
2023-03-14 07:41:16 +01:00
|
|
|
}
|
|
|
|
|
2022-11-18 07:39:26 +01:00
|
|
|
getTriggerTypeI18n(t: ReplicationTrigger) {
|
|
|
|
if (t) {
|
|
|
|
if (this.paused && t?.type === TRIGGER.SCHEDULED) {
|
|
|
|
return TRIGGER_I18N_MAP[TRIGGER.SCHEDULED_PAUSED];
|
|
|
|
}
|
|
|
|
return TRIGGER_I18N_MAP[t?.type];
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2018-05-21 13:05:38 +02:00
|
|
|
trancatedDescription(desc: string): string {
|
|
|
|
if (desc.length > 35) {
|
|
|
|
return desc.substr(0, 35);
|
|
|
|
} else {
|
|
|
|
return desc;
|
|
|
|
}
|
2017-08-22 07:33:24 +02:00
|
|
|
}
|
2022-05-05 11:36:11 +02:00
|
|
|
|
|
|
|
replicateRule(rule: ReplicationPolicy): void {
|
2018-09-10 11:12:52 +02:00
|
|
|
this.replicateManual.emit(rule);
|
2017-05-17 07:29:27 +02:00
|
|
|
}
|
2022-05-05 11:36:11 +02:00
|
|
|
|
2018-05-21 13:05:38 +02:00
|
|
|
deletionConfirm(message: ConfirmationAcknowledgement) {
|
|
|
|
if (
|
|
|
|
message &&
|
|
|
|
message.source === ConfirmationTargets.POLICY &&
|
|
|
|
message.state === ConfirmationState.CONFIRMED
|
|
|
|
) {
|
|
|
|
this.deleteOpe(message.data);
|
|
|
|
}
|
2022-05-13 10:00:45 +02:00
|
|
|
if (
|
|
|
|
message &&
|
2020-09-16 12:09:10 +02:00
|
|
|
message.source === ConfirmationTargets.REPLICATION &&
|
2022-05-13 10:00:45 +02:00
|
|
|
message.state === ConfirmationState.CONFIRMED
|
|
|
|
) {
|
2022-05-05 11:36:11 +02:00
|
|
|
const rule: ReplicationPolicy = clone(message.data);
|
2020-09-16 12:09:10 +02:00
|
|
|
rule.enabled = !message.data.enabled;
|
|
|
|
const opeMessage = new OperateInfo();
|
2022-05-13 10:00:45 +02:00
|
|
|
opeMessage.name = rule.enabled
|
|
|
|
? 'REPLICATION.ENABLE_TITLE'
|
|
|
|
: 'REPLICATION.DISABLE_TITLE';
|
2020-09-16 12:09:10 +02:00
|
|
|
opeMessage.data.id = rule.id;
|
|
|
|
opeMessage.state = OperationState.progressing;
|
|
|
|
opeMessage.data.name = rule.name;
|
|
|
|
this.operationService.publishInfo(opeMessage);
|
2022-05-13 10:00:45 +02:00
|
|
|
this.replicationService
|
|
|
|
.updateReplicationPolicy({
|
|
|
|
id: rule.id,
|
|
|
|
policy: rule,
|
|
|
|
})
|
|
|
|
.subscribe({
|
|
|
|
next: () => {
|
|
|
|
this.translateService
|
|
|
|
.get(
|
|
|
|
rule.enabled
|
|
|
|
? 'REPLICATION.ENABLE_SUCCESS'
|
|
|
|
: 'REPLICATION.DISABLE_SUCCESS'
|
|
|
|
)
|
|
|
|
.subscribe(msg => {
|
|
|
|
operateChanges(
|
|
|
|
opeMessage,
|
|
|
|
OperationState.success
|
|
|
|
);
|
|
|
|
this.errorHandlerEntity.info(msg);
|
|
|
|
this.refreshRule();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
error: error => {
|
|
|
|
const errMessage = errorHandler(error);
|
|
|
|
this.translateService
|
|
|
|
.get(
|
|
|
|
rule.enabled
|
|
|
|
? 'REPLICATION.ENABLE_FAILED'
|
|
|
|
: 'REPLICATION.DISABLE_FAILED'
|
|
|
|
)
|
|
|
|
.subscribe(msg => {
|
|
|
|
operateChanges(
|
|
|
|
opeMessage,
|
|
|
|
OperationState.failure,
|
|
|
|
msg
|
|
|
|
);
|
|
|
|
this.errorHandlerEntity.error(errMessage);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
2020-09-16 12:09:10 +02:00
|
|
|
}
|
2018-05-21 13:05:38 +02:00
|
|
|
}
|
2017-05-17 07:29:27 +02:00
|
|
|
|
2022-05-05 11:36:11 +02:00
|
|
|
selectRule(rule: ReplicationPolicy): void {
|
2019-02-01 10:00:01 +01:00
|
|
|
if (rule) {
|
2022-05-13 10:00:45 +02:00
|
|
|
this.selectedId = rule.id || '';
|
2019-02-01 10:00:01 +01:00
|
|
|
this.selectOne.emit(rule);
|
|
|
|
}
|
2018-05-21 13:05:38 +02:00
|
|
|
}
|
2017-06-05 13:18:08 +02:00
|
|
|
|
2022-05-05 11:36:11 +02:00
|
|
|
redirectTo(rule: ReplicationPolicy): void {
|
2018-05-21 13:05:38 +02:00
|
|
|
this.redirect.emit(rule);
|
|
|
|
}
|
2017-12-21 04:00:12 +01:00
|
|
|
|
2018-05-21 13:05:38 +02:00
|
|
|
openModal(): void {
|
|
|
|
this.openNewRule.emit();
|
|
|
|
}
|
2018-01-03 09:57:01 +01:00
|
|
|
|
2022-05-05 11:36:11 +02:00
|
|
|
editRule(rule: ReplicationPolicy) {
|
2018-05-21 13:05:38 +02:00
|
|
|
this.editOne.emit(rule);
|
|
|
|
}
|
2017-09-21 08:50:15 +02:00
|
|
|
|
2022-05-05 11:36:11 +02:00
|
|
|
deleteRule(rule: ReplicationPolicy) {
|
2018-05-21 13:05:38 +02:00
|
|
|
if (rule) {
|
|
|
|
let deletionMessage = new ConfirmationMessage(
|
2022-05-13 10:00:45 +02:00
|
|
|
'REPLICATION.DELETION_TITLE',
|
|
|
|
'REPLICATION.DELETION_SUMMARY',
|
2018-05-21 13:05:38 +02:00
|
|
|
rule.name,
|
|
|
|
rule,
|
|
|
|
ConfirmationTargets.POLICY,
|
|
|
|
ConfirmationButtons.DELETE_CANCEL
|
2018-05-14 14:01:00 +02:00
|
|
|
);
|
2018-05-21 13:05:38 +02:00
|
|
|
this.deletionConfirmDialog.open(deletionMessage);
|
2018-01-23 12:31:53 +01:00
|
|
|
}
|
2018-05-21 13:05:38 +02:00
|
|
|
}
|
2018-01-12 06:06:24 +01:00
|
|
|
|
2022-05-05 11:36:11 +02:00
|
|
|
deleteOpe(rule: ReplicationPolicy) {
|
2018-05-21 13:05:38 +02:00
|
|
|
if (rule) {
|
2019-03-12 11:03:47 +01:00
|
|
|
let observableLists: any[] = [];
|
2019-04-25 08:39:20 +02:00
|
|
|
observableLists.push(this.delOperate(rule));
|
2018-05-21 13:05:38 +02:00
|
|
|
|
2022-05-13 10:00:45 +02:00
|
|
|
forkJoin(...observableLists).subscribe(
|
|
|
|
item => {
|
|
|
|
this.selectedRow = null;
|
|
|
|
this.refreshRule();
|
|
|
|
},
|
|
|
|
error => {
|
|
|
|
this.errorHandlerEntity.error(error);
|
|
|
|
}
|
|
|
|
);
|
2018-05-21 13:05:38 +02:00
|
|
|
}
|
2018-01-12 06:06:24 +01:00
|
|
|
}
|
2017-05-17 07:29:27 +02:00
|
|
|
|
2022-05-05 11:36:11 +02:00
|
|
|
delOperate(rule: ReplicationPolicy): Observable<any> {
|
2018-05-21 13:05:38 +02:00
|
|
|
// init operation info
|
|
|
|
let operMessage = new OperateInfo();
|
|
|
|
operMessage.name = 'OPERATION.DELETE_REPLICATION';
|
|
|
|
operMessage.data.id = +rule.id;
|
|
|
|
operMessage.state = OperationState.progressing;
|
|
|
|
operMessage.data.name = rule.name;
|
|
|
|
this.operationService.publishInfo(operMessage);
|
|
|
|
|
2019-03-12 11:03:47 +01:00
|
|
|
return this.replicationService
|
2022-05-05 11:36:11 +02:00
|
|
|
.deleteReplicationPolicy({
|
2022-05-13 10:00:45 +02:00
|
|
|
id: rule.id,
|
2018-05-21 13:05:38 +02:00
|
|
|
})
|
2022-05-13 10:00:45 +02:00
|
|
|
.pipe(
|
|
|
|
map(() => {
|
|
|
|
this.translateService
|
|
|
|
.get('BATCH.DELETED_SUCCESS')
|
|
|
|
.subscribe(res =>
|
|
|
|
operateChanges(operMessage, OperationState.success)
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
catchError(error => {
|
2021-02-18 02:12:23 +01:00
|
|
|
const message = errorHandler(error);
|
2022-05-13 10:00:45 +02:00
|
|
|
this.translateService
|
|
|
|
.get(message)
|
|
|
|
.subscribe(res =>
|
|
|
|
operateChanges(
|
|
|
|
operMessage,
|
|
|
|
OperationState.failure,
|
|
|
|
res
|
|
|
|
)
|
|
|
|
);
|
2020-07-17 07:25:46 +02:00
|
|
|
return observableThrowError(error);
|
2022-05-13 10:00:45 +02:00
|
|
|
})
|
|
|
|
);
|
2018-05-21 13:05:38 +02:00
|
|
|
}
|
2022-05-05 11:36:11 +02:00
|
|
|
|
|
|
|
operateRule(operation: string, rule: ReplicationPolicy): void {
|
2020-09-16 12:09:10 +02:00
|
|
|
let title: string;
|
|
|
|
let summary: string;
|
|
|
|
let buttons: ConfirmationButtons;
|
|
|
|
switch (operation) {
|
|
|
|
case 'enable':
|
|
|
|
title = 'REPLICATION.ENABLE_TITLE';
|
|
|
|
summary = 'REPLICATION.ENABLE_SUMMARY';
|
|
|
|
buttons = ConfirmationButtons.ENABLE_CANCEL;
|
|
|
|
break;
|
|
|
|
case 'disable':
|
|
|
|
title = 'REPLICATION.DISABLE_TITLE';
|
|
|
|
summary = 'REPLICATION.DISABLE_SUMMARY';
|
|
|
|
buttons = ConfirmationButtons.DISABLE_CANCEL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Confirm
|
|
|
|
const msg: ConfirmationMessage = new ConfirmationMessage(
|
|
|
|
title,
|
|
|
|
summary,
|
|
|
|
rule.name,
|
|
|
|
rule,
|
|
|
|
ConfirmationTargets.REPLICATION,
|
|
|
|
buttons
|
|
|
|
);
|
|
|
|
this.deletionConfirmDialog.open(msg);
|
|
|
|
}
|
2022-05-05 11:36:11 +02:00
|
|
|
|
2020-10-16 11:17:33 +02:00
|
|
|
clrLoad(state?: ClrDatagridStateInterface) {
|
|
|
|
if (state && state.page) {
|
|
|
|
this.pageSize = state.page.size;
|
2022-05-13 10:00:45 +02:00
|
|
|
setPageSizeToLocalStorage(
|
|
|
|
PageSizeMapKeys.LIST_REPLICATION_RULE_COMPONENT,
|
|
|
|
this.pageSize
|
|
|
|
);
|
2020-10-16 11:17:33 +02:00
|
|
|
}
|
|
|
|
this.loading = true;
|
2022-05-05 11:36:11 +02:00
|
|
|
const param: ReplicationService.ListReplicationPoliciesParams = {
|
|
|
|
page: this.page,
|
|
|
|
pageSize: this.pageSize,
|
|
|
|
sort: getSortingString(state),
|
|
|
|
};
|
|
|
|
if (this.searchString) {
|
|
|
|
param.q = encodeURIComponent(`name=~${this.searchString}`);
|
|
|
|
} else {
|
|
|
|
param.q = getQueryString(state);
|
|
|
|
}
|
2022-05-13 10:00:45 +02:00
|
|
|
this.replicationService
|
|
|
|
.listReplicationPoliciesResponse(param)
|
|
|
|
.pipe(finalize(() => (this.loading = false)))
|
2022-05-05 11:36:11 +02:00
|
|
|
.subscribe({
|
|
|
|
next: response => {
|
|
|
|
// job list hidden
|
|
|
|
this.hideJobs.emit();
|
|
|
|
// Get total count
|
|
|
|
if (response.headers) {
|
2022-05-13 10:00:45 +02:00
|
|
|
let xHeader: string =
|
|
|
|
response.headers.get('x-total-count');
|
2022-05-05 11:36:11 +02:00
|
|
|
if (xHeader) {
|
|
|
|
this.totalCount = parseInt(xHeader, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.rules = response.body as ReplicationPolicy[];
|
|
|
|
},
|
|
|
|
error: error => {
|
|
|
|
this.errorHandlerEntity.error(error);
|
2022-05-13 10:00:45 +02:00
|
|
|
},
|
2020-10-16 11:17:33 +02:00
|
|
|
});
|
|
|
|
}
|
2022-05-05 11:36:11 +02:00
|
|
|
|
2020-10-16 11:17:33 +02:00
|
|
|
refreshRule() {
|
|
|
|
this.page = 1;
|
|
|
|
this.totalCount = 0;
|
|
|
|
this.selectedRow = null;
|
2021-03-17 07:32:45 +01:00
|
|
|
this.searchString = null;
|
2020-10-16 11:17:33 +02:00
|
|
|
this.clrLoad();
|
|
|
|
}
|
2022-05-05 11:36:11 +02:00
|
|
|
|
2021-05-12 04:11:04 +02:00
|
|
|
getFlattenLevelString(level: number) {
|
|
|
|
if (level !== null && Flatten_I18n_MAP[level]) {
|
|
|
|
return Flatten_I18n_MAP[level];
|
|
|
|
}
|
|
|
|
return level;
|
|
|
|
}
|
2022-05-05 11:36:11 +02:00
|
|
|
|
2021-09-15 10:59:14 +02:00
|
|
|
getBandwidthStr(speed: number): string {
|
|
|
|
if (speed >= KB_TO_MB) {
|
|
|
|
return '' + (speed / KB_TO_MB).toFixed(2) + BandwidthUnit.MB;
|
|
|
|
}
|
|
|
|
if (speed > 0 && speed < KB_TO_MB) {
|
|
|
|
return '' + speed + BandwidthUnit.KB;
|
|
|
|
}
|
|
|
|
return 'REPLICATION.UNLIMITED';
|
|
|
|
}
|
2018-01-12 06:06:24 +01:00
|
|
|
}
|