Skip to content

Commit 8de97f7

Browse files
committed
Frontend - Remove caching and add dev mode
1 parent 04ad772 commit 8de97f7

File tree

7 files changed

+70
-18
lines changed

7 files changed

+70
-18
lines changed

frontend/httpd.conf

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,23 @@ SSLProxyEngine On
230230
<IfModule unixd_module>
231231

232232
# Cache rules
233-
<FilesMatch "\.(js|wasm)$">
234-
Header set Cache-Control "public, max-age=31536000, immutable"
235-
</FilesMatch>
233+
234+
# Add cache for web node files
235+
; <FilesMatch "\.(js|wasm)$">
236+
; Header set Cache-Control "public, max-age=31536000, immutable"
237+
; </FilesMatch>
238+
239+
# REMOVE CACHE
240+
<filesMatch "\.(html|htm|js|css)$">
241+
FileETag None
242+
<ifModule mod_headers.c>
243+
Header unset ETag
244+
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
245+
Header set Pragma "no-cache"
246+
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
247+
</ifModule>
248+
</filesMatch>
249+
236250

237251
# Make sure mod_headers is enabled
238252
<IfModule !mod_headers.c>

frontend/src/app/core/services/web-node.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export class WebNodeService {
101101
// }
102102
if (!this.sentryEvents.firstPeerConnected && peers.some((p: any) => p.connection_status === DashboardPeerStatus.CONNECTED)) {
103103
const seconds = (Date.now() - this.webNodeStartTime) / 1000;
104-
sendSentryEvent(`WebNode connected in ${seconds.toFixed(1)}s`);
104+
sendSentryEvent(`WebNode connected in ${seconds.toFixed(1)}s`, 'info');
105105
this.sentryEvents.firstPeerConnected = true;
106106
this.webnodeProgress$.next('Connected');
107107
}

frontend/src/app/features/webnode/web-node-initialization/web-node-initialization.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@ export class WebNodeInitializationComponent extends StoreDispatcher implements O
105105
this.loading[1].status = WebNodeStepStatus.LOADING;
106106
this.advanceProgressFor2ndStep();
107107
} else if (state === 'Started') {
108-
this.updateLoadingMessage('~2 seconds left');
108+
this.updateLoadingMessage('~3 seconds left');
109109
setTimeout(() => {
110110
if (!this.hasError && this.loading[2].status !== WebNodeStepStatus.DONE) {
111111
this.updateLoadingMessage('Slower than usual');
112112
this.hasWarn = true;
113113
this.detect();
114114
}
115-
}, 2000);
115+
}, 3500);
116116
clearInterval(this.secondStepInterval);
117117
this.loading[0].loaded = true;
118118
this.loading[1].loaded = true;

frontend/src/app/features/webnode/web-node-not-supported/web-node-not-supported.component.html

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,47 +14,54 @@
1414
<div>Switch to one of the following platforms</div>
1515
<div class="img-wrapper flex-row align-center w-100 flex-center">
1616
<div class="fx-col-full-cent tertiary">
17-
<img src="assets/images/web-node-demo/windows.svg" alt="" class="mb-8">
17+
<img src="assets/images/web-node-demo/windows.svg" alt="" class="mb-8" (click)="addDevKey(1)">
1818
Windows
1919
</div>
2020
<div class="fx-col-full-cent tertiary">
21-
<img src="assets/images/web-node-demo/android.svg" alt="" class="mb-8">
21+
<img src="assets/images/web-node-demo/android.svg" alt="" class="mb-8" (click)="addDevKey(2)">
2222
Android
2323
</div>
2424
<div class="fx-col-full-cent tertiary">
25-
<img src="assets/images/web-node-demo/macos.svg" alt="" class="mb-8">
25+
<img src="assets/images/web-node-demo/macos.svg" alt="" class="mb-8" (click)="addDevKey(3)">
2626
MacOS
2727
</div>
2828
</div>
2929
</div>
3030

31-
<div class="w-100 fx-col-vert-cent sub-headline">And use Chrome, Edge or Safari</div>
31+
<div class="w-100 fx-col-vert-cent sub-headline">And use Chrome, Edge, Safari or Brave</div>
3232
</div>
3333
} @else {
3434
<div class="browser-content flex-column flex-center text-center">
3535
<div class="w-100 fx-col-vert-cent">
3636
<div class="headline mb-16">Your browser isn't supported</div>
3737
<div class="sub-headline tertiary">
3838
<div>To run a Mina node in your browser,</div>
39-
<div>we recommend Chrome or similar.</div>
39+
<div>we recommend one of the following.</div>
4040
</div>
4141
</div>
4242

4343
<div class="browser w-100 fx-col-vert-cent sub-headline">
4444
<div class="img-wrapper flex-row align-center w-100 flex-between">
4545
<div class="fx-col-full-cent tertiary">
46-
<img src="assets/images/web-node-demo/chrome.svg" alt="" class="mb-8">
46+
<img src="assets/images/web-node-demo/chrome.svg" alt="" class="mb-8" (click)="addDevKey(1)">
4747
Chrome
4848
</div>
4949
<div class="fx-col-full-cent tertiary">
50-
<img src="assets/images/web-node-demo/safari.svg" alt="" class="mb-8">
50+
<img src="assets/images/web-node-demo/safari.svg" alt="" class="mb-8" (click)="addDevKey(2)">
5151
Safari
5252
</div>
5353
<div class="fx-col-full-cent tertiary">
54-
<img src="assets/images/web-node-demo/edge.svg" alt="" class="mb-8">
54+
<img src="assets/images/web-node-demo/edge.svg" alt="" class="mb-8" (click)="addDevKey(3)">
5555
Edge
5656
</div>
5757
</div>
5858
</div>
5959
</div>
6060
}
61+
@if (devMode) {
62+
<div>You entered Dev mode!</div>
63+
<div class="fx-row-vert-cent mt-10 mb-10">
64+
<input type="password" placeholder="Password" class="mina-input mr-10 border-rad-8 h-xl p-12" #inp (keyup.enter)="c_hcK1_V_a_l_id(inp)">
65+
<button class="bg-aware-container h-xl p-10 primary" (click)="c_hcK1_V_a_l_id(inp)">Run Web Node</button>
66+
</div>
67+
}

frontend/src/app/features/webnode/web-node-not-supported/web-node-not-supported.component.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
1+
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
2+
import { Platform } from '@angular/cdk/platform';
3+
import { sendSentryEvent } from '@shared/helpers/webnode.helper';
4+
5+
const code = [1, 2, 3, 2];
26

37
@Component({
48
selector: 'mina-web-node-not-supported',
@@ -10,5 +14,31 @@ import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
1014
host: { class: 'h-100 flex-column align-center' },
1115
})
1216
export class WebNodeNotSupportedComponent {
17+
1318
@Input() isPhone!: boolean;
19+
20+
@Output() bypassUnsupportedDevice = new EventEmitter<void>();
21+
22+
devMode: boolean = false;
23+
private codeVerifier: number[] = [];
24+
25+
constructor(private platform: Platform) {}
26+
27+
addDevKey(key: number): void {
28+
this.codeVerifier.push(key);
29+
if (this.codeVerifier.length === code.length) {
30+
if (this.codeVerifier.every((v, i) => v === code[i])) {
31+
this.devMode = true;
32+
} else {
33+
this.codeVerifier = [];
34+
}
35+
}
36+
}
37+
38+
c_hcK1_V_a_l_id(input: HTMLInputElement): void {
39+
if (input.value === 'allowme') {
40+
sendSentryEvent('A developer is testing the app on ' + this.platform, 'debug');
41+
this.bypassUnsupportedDevice.emit();
42+
}
43+
}
1444
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@if (supported) {
22
<mina-web-node-initialization></mina-web-node-initialization>
33
} @else {
4-
<mina-web-node-not-supported [isPhone]="isPhone"></mina-web-node-not-supported>
4+
<mina-web-node-not-supported [isPhone]="isPhone" (bypassUnsupportedDevice)="supported = true"></mina-web-node-not-supported>
55
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as Sentry from '@sentry/angular';
2+
import { SeverityLevel } from '@sentry/angular';
23

3-
export function sendSentryEvent(message: string): void {
4-
Sentry.captureEvent({ message: message, tags: { type: 'webnode' } });
4+
export function sendSentryEvent(message: string, level: SeverityLevel = 'error'): void {
5+
Sentry.captureEvent({ message: message, level, tags: { type: 'webnode' } });
56
}

0 commit comments

Comments
 (0)