Skip to content

Commit

Permalink
fix: dashboard cache persisting after reset
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyOplachko committed Jul 5, 2024
1 parent 6dff37f commit dd203ef
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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 => {
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions src/app/helpers/http-get-buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(url: string, delay = HttpGetBuffer.delay): Observable<T> {
console.log(HttpGetBuffer._buffer);
if (delay === 0) {
Expand Down

0 comments on commit dd203ef

Please sign in to comment.