diff --git a/src/app/components/preference/pages/page-reset/page-reset.component.ts b/src/app/components/preference/pages/page-reset/page-reset.component.ts index 5d8689ce..8182326c 100644 --- a/src/app/components/preference/pages/page-reset/page-reset.component.ts +++ b/src/app/components/preference/pages/page-reset/page-reset.component.ts @@ -6,6 +6,7 @@ import { DialogDeleteAlertComponent } from '../../dialogs'; import { AlertService, AuthenticationService, DashboardService, PreferenceMappingProtocolService, SessionStorageService } from '@app/services'; import { MatDialog } from '@angular/material/dialog'; import { TranslateService } from '@ngx-translate/core'; +import { HttpGetBuffer } from '@app/helpers/http-get-buffer'; @Component({ selector: 'app-page-reset', @@ -27,7 +28,8 @@ export class PageResetComponent implements OnInit { private dialog: MatDialog, private cdr: ChangeDetectorRef, private _pmps: PreferenceMappingProtocolService, - private translateService: TranslateService + private translateService: TranslateService, + private _httpBuffer: HttpGetBuffer ) { this.translateService.get('notifications').subscribe(res => { @@ -93,8 +95,13 @@ export class PageResetComponent implements OnInit { const data = { page: 'Dashboard', message: 'reset' }; this.openDialog(DialogDeleteAlertComponent, data, (result) => { if (result && result === true) { - const resData: any = this.dashboardService.resetDashboard().toPromise(); - this.alertService.success(this.localDictionary.success.dashboardReset); + this.dashboardService.resetDashboard().then(() => { + this.alertService.success(this.localDictionary.success.dashboardReset); + this._httpBuffer.removeAllSubPathsFromBuffer('dashboard'); + }, () => { + + this.alertService.error(this.localDictionary.error.dashboardReset); + }) } else { this.alertService.error(this.localDictionary.error.dashboardReset); return; diff --git a/src/app/helpers/http-get-buffer.ts b/src/app/helpers/http-get-buffer.ts index dd213286..44dddf97 100644 --- a/src/app/helpers/http-get-buffer.ts +++ b/src/app/helpers/http-get-buffer.ts @@ -36,6 +36,13 @@ export class HttpGetBuffer { public removeFromBuffer(url: string) { HttpGetBuffer._buffer = HttpGetBuffer._buffer.filter(request => request.url !== url) } + // Expects subpath as parameter, i.e. if you want to remove all Dashboard store requests + // http://localhost:9080/api/v3/dashboard/store/home, http://localhost:9080/api/v3/dashboard/store/smartsearch + // You pass 'dashboard' and it removes them + public removeAllSubPathsFromBuffer(subpath: string) { + HttpGetBuffer._buffer = HttpGetBuffer._buffer.filter(request => !request.url.includes(`/${subpath}/`)); + console.log(HttpGetBuffer._buffer); + } public get(url: string, delay = HttpGetBuffer.delay): Observable { console.log(HttpGetBuffer._buffer); if (delay === 0) {