Skip to content

Commit e3430f0

Browse files
committed
MB-49189 Take "storageTotals" from a new "pools/default" request.
By applying this patch the memory quota used in Bucket Dialog is synced with the latest add/edit bucket. Change-Id: Icf37fa9dd8cead52028886f5615e64f5635a007f Reviewed-on: https://review.couchbase.org/c/ns_server/+/165535 Tested-by: Raluca Lupu <[email protected]> Reviewed-by: Pavel Blagodov <[email protected]>
1 parent 893837b commit e3430f0

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

priv/public/ui/app/mn.admin.service.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@ class MnAdminService {
103103
this.stream.maxBucketCount =
104104
this.stream.getPoolsDefault.pipe(pluck("maxBucketCount"), distinctUntilChanged());
105105

106-
this.stream.storageTotals =
107-
this.stream.getPoolsDefault.pipe(pluck("storageTotals"), distinctUntilChanged());
108-
109106
this.stream.uiSessionTimeout =
110107
this.stream.getPoolsDefault.pipe(pluck("uiSessionTimeout"), distinctUntilChanged());
111108

priv/public/ui/app/mn.bucket.dialog.component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class MnBucketDialogComponent extends MnLifeCycleHooksToStream {
9090

9191
let formData = this.bucket ?
9292
this.mnBucketsService.createBucketFormData(this.bucket) :
93-
this.mnBucketsService.stream.initialFormData;
93+
this.mnBucketsService.createInitialFormData(this.storageTotals);
9494

9595
this.form = this.mnFormService.create(this)
9696
.setFormGroup(this.formBuilder.group({

priv/public/ui/app/mn.buckets.component.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ licenses/APL2.txt.
1010

1111
import {Component, ChangeDetectionStrategy} from '@angular/core';
1212
import {Subject, BehaviorSubject, combineLatest} from 'rxjs';
13-
import {map, takeUntil, withLatestFrom} from 'rxjs/operators';
13+
import {map, takeUntil, switchMap} from 'rxjs/operators';
1414
import {NgbModal} from '@ng-bootstrap/ng-bootstrap';
1515

1616
import {MnLifeCycleHooksToStream} from "./mn.core.js";
@@ -62,14 +62,15 @@ class MnBucketsComponent extends MnLifeCycleHooksToStream {
6262

6363
this.onAddBucketClick = new Subject();
6464
this.onAddBucketClick
65-
.pipe(withLatestFrom(mnAdminService.stream.storageTotals),
65+
.pipe(switchMap(() => mnAdminService.getPoolsDefault()),
6666
takeUntil(this.mnOnDestroy))
67-
.subscribe(([,storageTotals]) => {
68-
let ram = storageTotals.ram;
67+
.subscribe((resp) => {
68+
let ram = resp.storageTotals.ram;
6969
if (!ram || ram.quotaTotal === ram.quotaUsed) {
7070
this.modalService.open(MnBucketFullDialogComponent);
7171
} else {
72-
this.modalService.open(MnBucketDialogComponent);
72+
let ref = this.modalService.open(MnBucketDialogComponent);
73+
ref.componentInstance.storageTotals = resp.storageTotals;
7374
}
7475
});
7576

@@ -94,5 +95,4 @@ class MnBucketsComponent extends MnLifeCycleHooksToStream {
9495
trackBy(index, bucket) {
9596
return bucket.name;
9697
}
97-
9898
}

priv/public/ui/app/mn.buckets.service.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class MnBucketsService {
4646
this.http = http;
4747
this.modalService = modalService;
4848
this.mnHelperService = mnHelperService;
49+
this.mnAdminService = mnAdminService;
4950
this.mnSettingsAutoCompactionService = mnSettingsAutoCompactionService;
5051

5152
this.stream.bucketsUri = mnAdminService.stream.getPoolsDefault
@@ -85,10 +86,6 @@ class MnBucketsService {
8586
shareReplay({refCount: true, bufferSize: 1}));
8687

8788
this.stream.defaultAutoCompactionData = mnSettingsAutoCompactionService.stream.settingsSource;
88-
this.stream.initialFormData = this.stream.defaultAutoCompactionData
89-
.pipe(withLatestFrom(mnAdminService.stream.storageTotals,
90-
mnAdminService.stream.reallyActiveKVNodes),
91-
map(this.unpackData.bind(this)));
9289

9390
this.stream.deleteBucket =
9491
new MnHttpRequest(this.deleteBucket.bind(this))
@@ -362,11 +359,12 @@ class MnBucketsService {
362359
permissions.cluster.bucket[bucketName].flush;
363360
}
364361

365-
unpackData([autoCompactionSettings, totals, reallyActiveKVNodes]) {
362+
unpackData([autoCompactionSettings, reallyActiveKVNodes], storageTotals) {
366363
let ramQuota = 0;
367-
if (totals.ram) {
364+
let ram = storageTotals.ram;
365+
if (ram) {
368366
ramQuota = Math.floor(
369-
(totals.ram.quotaTotal - totals.ram.quotaUsed) / reallyActiveKVNodes.length);
367+
(ram.quotaTotal - ram.quotaUsed) / reallyActiveKVNodes.length);
370368
}
371369

372370
return {
@@ -428,6 +426,12 @@ class MnBucketsService {
428426
.pipe(map(v => this.getBucketFormData(v, bucket)));
429427
}
430428

429+
createInitialFormData(storageTotals) {
430+
return this.stream.defaultAutoCompactionData
431+
.pipe(withLatestFrom(this.mnAdminService.stream.reallyActiveKVNodes),
432+
map(v => this.unpackData(v, storageTotals)));
433+
}
434+
431435
get(url) {
432436
return this.http.get(
433437
url,

0 commit comments

Comments
 (0)