Skip to content

Commit e987339

Browse files
committed
adding warning message for experimental features
1 parent caa18b5 commit e987339

5 files changed

Lines changed: 106 additions & 11 deletions

File tree

angular/src/app/pages/tools/tools.component.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,11 @@ <h2>API Token Tools</h2>
3939
[ngClass]="{ hidden: view != 'token-usage' }"
4040
(closePopup)="closePopup('token-usage')"
4141
></app-tools-token-usage>
42+
<app-tools-warning
43+
[warningMessage]="warningMessage"
44+
[experimentalMessage]="experimentalMessage"
45+
class="popup transparent"
46+
[ngClass]="{ hidden: view != 'warning' }"
47+
(warningConfirm)="warningConfirm()"
48+
(warningCancel)="warningCancel()"
49+
></app-tools-warning>

angular/src/app/pages/tools/tools.component.ts

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,54 @@ import { BrowserService } from "../../services/browser.service";
1616
export class ToolsComponent implements OnInit {
1717
eventTokenInfo: Subject<boolean> = new Subject<boolean>()
1818
eventTokenUsage: Subject<boolean> = new Subject<boolean>()
19+
eventWarning: Subject<boolean> = new Subject<boolean>()
20+
experimentalMessage: boolean = false;
21+
warningMessage: string = "";
1922
view: string = "";
20-
id_links:boolean = false;
23+
id_links: boolean = false;
2124
constructor(
2225
private _cd: ChangeDetectorRef,
23-
private _browser: BrowserService
26+
private _browser: BrowserService
2427
) { }
2528

2629
ngOnInit() {
27-
this._browser.getStorage("id_links", (result)=>{
30+
this._browser.getStorage("id_links", (result) => {
2831
if (result == "true") this.id_links = true;
2932
else this.id_links = false;
3033
})
3134
}
3235

33-
changeIdLinks():void{
34-
console.log(this.id_links)
35-
if (this.id_links) this._browser.setStorage("id_links", "true");
36-
else this._browser.setStorage("id_links", "false");
36+
changeIdLinks(): void {
37+
if (this.id_links) {
38+
this.view = "warning";
39+
this.experimentalMessage = true;
40+
this.warningMessage = "It may not work as expected and may impact your browser performance, especially on Mist API pages with a large number of entries.";
41+
this.eventWarning.next(true);
42+
this._cd.detectChanges();
43+
//this._browser.setStorage("id_links", "true")
44+
} else this._browser.setStorage("id_links", "false");
3745
}
3846

39-
openPopup(view:string): void {
47+
warningConfirm(): void {
48+
this.view = "";
49+
this.experimentalMessage = false;
50+
this._browser.setStorage("id_links", "true");
51+
this.id_links = true;
52+
this.eventWarning.next(false);
53+
this._cd.detectChanges();
54+
}
55+
warningCancel(): void {
56+
this.view = "";
57+
this.experimentalMessage = false;
58+
this._browser.setStorage("id_links", "false");
59+
this.id_links = false;
60+
this.eventWarning.next(false);
61+
this._cd.detectChanges();
62+
}
63+
64+
openPopup(view: string): void {
4065
this.view = view;
41-
switch(view){
66+
switch (view) {
4267
case "token-info":
4368
this.eventTokenInfo.next(true)
4469
break;
@@ -49,9 +74,9 @@ export class ToolsComponent implements OnInit {
4974
this._cd.detectChanges();
5075
}
5176

52-
closePopup(view:string): void {
77+
closePopup(view: string): void {
5378
this.view = "";
54-
switch(view){
79+
switch (view) {
5580
case "token-info":
5681
this.eventTokenInfo.next(false)
5782
break;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<div class="popup-content">
2+
<div class="popup-header">
3+
<h2>Warning</h2>
4+
</div>
5+
<div class="popup-body">
6+
<div *ngIf="experimentalMessage">This is an experimental feature. </div>
7+
<div>{{ warningMessage }}</div>
8+
<div>Do you want to continue?</div>
9+
</div>
10+
<div class="popup-footer">
11+
<button (click)="cancel()">CANCEL</button>
12+
<button (click)="confirm()">CONFIRM</button>
13+
</div>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.popup-header h2 {
2+
color: #ffa500;
3+
}
4+
.popup-body {
5+
font-size: larger;
6+
margin-bottom: 1em;
7+
div {
8+
margin: 1em 0;
9+
}
10+
}
11+
12+
.popup-footer {
13+
display: flex;
14+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { Component, Output, Input, ChangeDetectionStrategy, EventEmitter, OnInit } from '@angular/core';
2+
3+
4+
@Component({
5+
selector: 'app-tools-warning',
6+
templateUrl: 'warning.component.html',
7+
styleUrls: [
8+
'../../../scss/popup.component.scss',
9+
'../../../scss/button.component.scss',
10+
'warning.component.scss',
11+
],
12+
changeDetection: ChangeDetectionStrategy.OnPush
13+
})
14+
export class ToolsWarningComponent implements OnInit {
15+
16+
@Input() experimentalMessage: boolean = false;
17+
@Input() warningMessage: string;
18+
@Output() warningConfirm = new EventEmitter<string>();
19+
@Output() warningCancel = new EventEmitter<string>();
20+
constructor(
21+
) { }
22+
23+
ngOnInit() {
24+
}
25+
26+
27+
confirm(): void {
28+
this.warningConfirm.emit();
29+
}
30+
cancel(): void {
31+
this.warningCancel.emit();
32+
}
33+
34+
35+
}

0 commit comments

Comments
 (0)