Skip to content

Commit 40efd07

Browse files
committed
feat(config): demo mode added to config
1 parent ab8e615 commit 40efd07

File tree

6 files changed

+25
-1
lines changed

6 files changed

+25
-1
lines changed

src/api/server-routes.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,18 @@ export function keysRoutes(): express.Router {
742742
return router;
743743
}
744744

745+
export function configRoutes(): express.Router {
746+
const router = express.Router();
747+
748+
router.get(`/demo`, (req: express.Request, res: express.Response) => {
749+
let config: any = getConfig();
750+
751+
return res.status(200).json({ data: config.demo });
752+
});
753+
754+
return router;
755+
}
756+
745757
export function imagesRoutes(): express.Router {
746758
const router = express.Router();
747759

src/api/server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export class ExpressServer implements IExpressServer {
4848
app.use('/api/variables', routes.environmentVariableRoutes());
4949
app.use('/api/logs', routes.logsRoutes());
5050
app.use('/api/keys', routes.keysRoutes());
51+
app.use('/api/config', routes.configRoutes());
5152
app.use('/api/stats', routes.statsRoutes());
5253
app.use('/api/images', routes.imagesRoutes());
5354
app.use('/badge', routes.badgeRoutes());

src/api/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const defaultConfig = {
3434
publicKey: 'rsa.pub',
3535
privateKey: 'rsa.key',
3636
requireLogin: false,
37+
demo: false,
3738
db: {
3839
client: 'sqlite3',
3940
connection: {

src/app/components/app-header/app-header.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<a class="nav-item nav-logo" routerLink="/">
55
<img src="images/abstruse-text-logo.svg">
66
</a>
7-
<a class="nav-item is-hidden-mobile" routerLink="/dashboard" routerLinkActive="is-active">
7+
<a class="nav-item is-hidden-mobile" routerLink="/dashboard" routerLinkActive="is-active" name="dashboard" *ngIf="user || demo">
88
<i class="ionicon ion-pie-graph"></i>
99
Dashboard
1010
</a>

src/app/components/app-header/app-header.component.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Component, HostListener, ElementRef, OnInit, Inject, Renderer2 } from '
22
import { DOCUMENT } from '@angular/common';
33
import { Router, NavigationEnd } from '@angular/router';
44
import { AuthService } from '../../services/auth.service';
5+
import { ApiService } from '../../services/api.service';
56
import { ConfigService } from '../../services/config.service';
67
import { SocketService } from '../../services/socket.service';
78
import { NotificationService, NotificationType } from '../../services/notification.service';
@@ -19,8 +20,10 @@ export class AppHeaderComponent implements OnInit {
1920
version: string;
2021
viewport: any;
2122
view: 'mobile' | 'desktop';
23+
demo: boolean;
2224

2325
constructor(
26+
private apiService: ApiService,
2427
private authService: AuthService,
2528
private router: Router,
2629
private elementRef: ElementRef,
@@ -38,13 +41,16 @@ export class AppHeaderComponent implements OnInit {
3841

3942
this.notifications = [];
4043
this.version = pkgJson.version;
44+
this.demo = false;
4145
}
4246

4347
ngOnInit() {
4448
this.user = this.authService.getData();
4549
if (this.user) {
4650
this.user.avatar = this.config.url + this.user.avatar;
4751
this.socketService.emit({ type: 'userId', data: this.user.id });
52+
} else {
53+
this.apiService.configDemo().subscribe(demo => this.demo = demo);
4854
}
4955

5056
this.authService.userEvents.subscribe(event => {

src/app/services/api.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ export class ApiService {
103103
return this.get(`${this.url}/setup/login-required`);
104104
}
105105

106+
configDemo(): Observable<any> {
107+
return this.get(`${this.url}/config/demo`, null, true);
108+
}
109+
106110
getAllTokens(): Observable<any> {
107111
return this.get(`${this.url}/tokens`, null, true);
108112
}

0 commit comments

Comments
 (0)