Skip to content

Commit f314fa8

Browse files
Merge pull request #1693 from rocket-admin/demo-mode-component
separate landing page for demo
2 parents f4cfd96 + f94a88f commit f314fa8

8 files changed

Lines changed: 60 additions & 41 deletions

File tree

frontend/src/app/app-routing.module.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ const routes: Routes = [
2828
canActivate: [configurationGuard],
2929
title: 'Login | Rocketadmin',
3030
},
31+
{
32+
path: 'demo',
33+
loadComponent: () => import('./components/demo-login/demo-login.component').then((m) => m.DemoLoginComponent),
34+
title: 'Demo | Rocketadmin',
35+
},
3136
{
3237
path: 'forget-password',
3338
loadComponent: () =>

frontend/src/app/app.component.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { DomSanitizer } from '@angular/platform-browser';
1313
import { ActivatedRoute, NavigationEnd, Router, RouterModule } from '@angular/router';
1414
import { User } from '@sentry/angular';
1515
import amplitude from 'amplitude-js';
16-
import { Angulartics2, Angulartics2Amplitude, Angulartics2OnModule } from 'angulartics2';
16+
import { Angulartics2Amplitude, Angulartics2OnModule } from 'angulartics2';
1717
import { differenceInMilliseconds } from 'date-fns';
1818
import posthog from 'posthog-js';
1919
import { Subject } from 'rxjs';
@@ -95,7 +95,6 @@ export class AppComponent {
9595
_tables: TablesService,
9696
private _uiSettings: UiSettingsService,
9797
angulartics2Amplitude: Angulartics2Amplitude,
98-
private angulartics2: Angulartics2,
9998
private domSanitizer: DomSanitizer,
10099
private matIconRegistry: MatIconRegistry,
101100
_posthog: PosthogService,
@@ -168,16 +167,6 @@ export class AppComponent {
168167
this.page = this.router.routerState.snapshot.url.split('?')[0];
169168

170169
console.log('Navigated to page:', this.page);
171-
172-
if (this.router.routerState.snapshot.root.queryParams.mode === 'demo') {
173-
console.log('App component, demo mode search params found');
174-
this._auth.loginToDemoAccount().subscribe(() => {
175-
this.angulartics2.eventTrack.next({
176-
action: 'Demo account is logged in',
177-
});
178-
posthog.capture('Demo account is logged in');
179-
});
180-
}
181170
});
182171

183172
const expirationDateFromURL = new URLSearchParams(location.search).get('expires');
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.wrapper {
2+
display: flex;
3+
justify-content: center;
4+
align-items: center;
5+
min-height: 100vh;
6+
}
7+
8+
.demo-loader {
9+
display: flex;
10+
flex-direction: column;
11+
justify-content: center;
12+
align-items: center;
13+
gap: 24px;
14+
}
15+
16+
.demo-loader__text {
17+
color: var(--mat-sidenav-content-text-color);
18+
margin: 0;
19+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<div class="wrapper background-decoration">
2+
<div class="demo-loader">
3+
<mat-spinner diameter="48"></mat-spinner>
4+
<p class="mat-body-1 demo-loader__text">Loading demo account...</p>
5+
</div>
6+
</div>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
3+
import { Angulartics2 } from 'angulartics2';
4+
import posthog from 'posthog-js';
5+
import { AuthService } from 'src/app/services/auth.service';
6+
7+
@Component({
8+
selector: 'app-demo-login',
9+
templateUrl: './demo-login.component.html',
10+
styleUrls: ['./demo-login.component.css'],
11+
imports: [MatProgressSpinnerModule],
12+
})
13+
export class DemoLoginComponent implements OnInit {
14+
constructor(
15+
private _auth: AuthService,
16+
private angulartics2: Angulartics2,
17+
) {}
18+
19+
ngOnInit(): void {
20+
this._auth.loginToDemoAccount().subscribe(() => {
21+
this.angulartics2.eventTrack.next({
22+
action: 'Demo account is logged in',
23+
});
24+
posthog.capture('Demo account is logged in');
25+
});
26+
}
27+
}

frontend/src/app/components/login/login.component.css

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -360,16 +360,3 @@
360360
transform: translateX(100%);
361361
}
362362
}
363-
364-
.demo-loader {
365-
display: flex;
366-
flex-direction: column;
367-
justify-content: center;
368-
align-items: center;
369-
gap: 24px;
370-
}
371-
372-
.demo-loader__text {
373-
color: var(--mat-sidenav-content-text-color);
374-
margin: 0;
375-
}

frontend/src/app/components/login/login.component.html

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
<app-alert></app-alert>
22

3-
@if (isDemoMode) {
4-
<div class="wrapper background-decoration">
5-
<div class="login-page demo-loader">
6-
<mat-spinner diameter="48"></mat-spinner>
7-
<p class="mat-body-1 demo-loader__text">Loading demo account...</p>
8-
</div>
9-
</div>
10-
} @else {
113
<div class="wrapper background-decoration">
124
<div class="login-page">
135
<form
@@ -145,5 +137,4 @@ <h2 class="mat-headline-4 qr-verification__title">Enter 2nd factor code</h2>
145137
</form>
146138
</div>
147139
</div>
148-
}
149140

frontend/src/app/components/login/login.component.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ import { MatDialog } from '@angular/material/dialog';
66
import { MatFormFieldModule } from '@angular/material/form-field';
77
import { MatIconModule } from '@angular/material/icon';
88
import { MatInputModule } from '@angular/material/input';
9-
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
109
import { MatSelectModule } from '@angular/material/select';
11-
import { ActivatedRoute, Router, RouterModule } from '@angular/router';
10+
import { Router, RouterModule } from '@angular/router';
1211
import { Angulartics2, Angulartics2OnModule } from 'angulartics2';
1312
import { accounts } from 'google-one-tap';
1413
import posthog from 'posthog-js';
@@ -37,7 +36,6 @@ declare var google: any;
3736
MatSelectModule,
3837
MatIconModule,
3938
MatButtonModule,
40-
MatProgressSpinnerModule,
4139
EmailValidationDirective,
4240
AlertComponent,
4341
Angulartics2OnModule,
@@ -59,7 +57,6 @@ export class LoginComponent implements OnInit, AfterViewInit {
5957
public submitting: boolean;
6058
public isPasswordFieldShown: boolean = false;
6159
public is2FAShown: boolean = false;
62-
public isDemoMode: boolean = false;
6360
public errors = {
6461
'No_user_registered_with_this_GitHub_account.': 'No user registered with this GitHub account.',
6562
'GitHub_login_failed._Please_contact_our_support_team.': 'GitHub login failed. Please contact our support team.',
@@ -68,7 +65,6 @@ export class LoginComponent implements OnInit, AfterViewInit {
6865
constructor(
6966
private _auth: AuthService,
7067
public router: Router,
71-
private _route: ActivatedRoute,
7268
private angulartics2: Angulartics2,
7369
private ngZone: NgZone,
7470
private _notifications: NotificationsService,
@@ -77,7 +73,6 @@ export class LoginComponent implements OnInit, AfterViewInit {
7773
) {}
7874

7975
ngOnInit(): void {
80-
this.isDemoMode = this._route.snapshot.queryParams['mode'] === 'demo';
8176
this.isCustomDomain = this._company.isCustomDomain() && this.isSaas;
8277

8378
const error = new URLSearchParams(location.search).get('error');
@@ -92,7 +87,7 @@ export class LoginComponent implements OnInit, AfterViewInit {
9287
}
9388

9489
ngAfterViewInit() {
95-
if (this.isSaas && !this.isDemoMode) {
90+
if (this.isSaas) {
9691
const gAccounts: accounts = google.accounts;
9792
gAccounts.id.initialize({
9893
client_id: '681163285738-e4l0lrv5vv7m616ucrfhnhso9r396lum.apps.googleusercontent.com',

0 commit comments

Comments
 (0)