Skip to content
This repository was archived by the owner on Jul 15, 2022. It is now read-only.

Commit b352952

Browse files
author
Leonardo Chaia
committed
feat: clear cache on demand in settings page
1 parent 30e2224 commit b352952

File tree

5 files changed

+62
-0
lines changed

5 files changed

+62
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<mat-card fxLayout="row"
2+
fxLayoutAlign="start center"
3+
fxLayoutGap="8px"
4+
style="margin-bottom: 16px;">
5+
<mat-icon class="tim-icon-48 tim-text-primary">cached</mat-icon>
6+
7+
<div fxFlex="fill">
8+
<h3 class="tim-text-title"
9+
style="margin:0">
10+
Cache
11+
</h3>
12+
</div>
13+
14+
<div [fxFlex]="loading ? '20' : ''">
15+
<button mat-button
16+
*ngIf="!loading; else loadingTemplate"
17+
(click)="clearCache()">
18+
<mat-icon>delete_forever</mat-icon>
19+
Clear Cache
20+
</button>
21+
<ng-template #loadingTemplate>
22+
<tim-loading></tim-loading>
23+
</ng-template>
24+
</div>
25+
</mat-card>

src/app/settings/cache-clear-card/cache-clear-card.component.scss

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { Component } from '@angular/core';
2+
import { TimCacheService } from '../../tim-cache/tim-cache.service';
3+
import { NotificationService } from '../../shared/notification.service';
4+
5+
@Component({
6+
selector: 'tim-cache-clear-card',
7+
templateUrl: './cache-clear-card.component.html',
8+
styleUrls: ['./cache-clear-card.component.scss']
9+
})
10+
export class CacheClearCardComponent {
11+
12+
public loading = false;
13+
14+
constructor(
15+
private readonly cache: TimCacheService,
16+
private readonly notification: NotificationService) { }
17+
18+
public clearCache() {
19+
this.loading = true;
20+
this.cache.clear()
21+
.subscribe(() => {
22+
this.loading = false;
23+
this.notification.open('Cache has been cleared');
24+
}, e => {
25+
this.loading = false;
26+
this.notification.open(e.message, null, {
27+
panelClass: 'tim-bg-warn',
28+
});
29+
console.error(e);
30+
});
31+
}
32+
33+
}

src/app/settings/settings-container/settings-container.component.html

+2
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ <h2 class="tim-text-title">
128128

129129
</div>
130130

131+
<tim-cache-clear-card></tim-cache-clear-card>
132+
131133
<mat-card fxLayout="row"
132134
fxLayoutAlign="start center"
133135
fxLayoutGap="8px"

src/app/settings/settings.module.ts

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { SharedModule } from '../shared/shared.module';
1212
import { SettingsUpdaterComponent } from './settings-updater/settings-updater.component';
1313
import { JobsModule } from '../jobs/jobs.module';
1414
import { HttpClientModule } from '@angular/common/http';
15+
import { CacheClearCardComponent } from './cache-clear-card/cache-clear-card.component';
1516

1617
@NgModule({
1718
imports: [
@@ -38,6 +39,7 @@ import { HttpClientModule } from '@angular/common/http';
3839
SettingsContainerComponent,
3940
RegistrySettingsModalComponent,
4041
SettingsUpdaterComponent,
42+
CacheClearCardComponent,
4143
],
4244
entryComponents: [
4345
RegistrySettingsModalComponent,

0 commit comments

Comments
 (0)