Skip to content

Commit

Permalink
feat(config): demo mode added to config
Browse files Browse the repository at this point in the history
  • Loading branch information
Izak88 committed Oct 18, 2017
1 parent ab8e615 commit 40efd07
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/api/server-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,18 @@ export function keysRoutes(): express.Router {
return router;
}

export function configRoutes(): express.Router {
const router = express.Router();

router.get(`/demo`, (req: express.Request, res: express.Response) => {
let config: any = getConfig();

return res.status(200).json({ data: config.demo });
});

return router;
}

export function imagesRoutes(): express.Router {
const router = express.Router();

Expand Down
1 change: 1 addition & 0 deletions src/api/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export class ExpressServer implements IExpressServer {
app.use('/api/variables', routes.environmentVariableRoutes());
app.use('/api/logs', routes.logsRoutes());
app.use('/api/keys', routes.keysRoutes());
app.use('/api/config', routes.configRoutes());
app.use('/api/stats', routes.statsRoutes());
app.use('/api/images', routes.imagesRoutes());
app.use('/badge', routes.badgeRoutes());
Expand Down
1 change: 1 addition & 0 deletions src/api/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const defaultConfig = {
publicKey: 'rsa.pub',
privateKey: 'rsa.key',
requireLogin: false,
demo: false,
db: {
client: 'sqlite3',
connection: {
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/app-header/app-header.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<a class="nav-item nav-logo" routerLink="/">
<img src="images/abstruse-text-logo.svg">
</a>
<a class="nav-item is-hidden-mobile" routerLink="/dashboard" routerLinkActive="is-active">
<a class="nav-item is-hidden-mobile" routerLink="/dashboard" routerLinkActive="is-active" name="dashboard" *ngIf="user || demo">
<i class="ionicon ion-pie-graph"></i>
Dashboard
</a>
Expand Down
6 changes: 6 additions & 0 deletions src/app/components/app-header/app-header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component, HostListener, ElementRef, OnInit, Inject, Renderer2 } from '
import { DOCUMENT } from '@angular/common';
import { Router, NavigationEnd } from '@angular/router';
import { AuthService } from '../../services/auth.service';
import { ApiService } from '../../services/api.service';
import { ConfigService } from '../../services/config.service';
import { SocketService } from '../../services/socket.service';
import { NotificationService, NotificationType } from '../../services/notification.service';
Expand All @@ -19,8 +20,10 @@ export class AppHeaderComponent implements OnInit {
version: string;
viewport: any;
view: 'mobile' | 'desktop';
demo: boolean;

constructor(
private apiService: ApiService,
private authService: AuthService,
private router: Router,
private elementRef: ElementRef,
Expand All @@ -38,13 +41,16 @@ export class AppHeaderComponent implements OnInit {

this.notifications = [];
this.version = pkgJson.version;
this.demo = false;
}

ngOnInit() {
this.user = this.authService.getData();
if (this.user) {
this.user.avatar = this.config.url + this.user.avatar;
this.socketService.emit({ type: 'userId', data: this.user.id });
} else {
this.apiService.configDemo().subscribe(demo => this.demo = demo);
}

this.authService.userEvents.subscribe(event => {
Expand Down
4 changes: 4 additions & 0 deletions src/app/services/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ export class ApiService {
return this.get(`${this.url}/setup/login-required`);
}

configDemo(): Observable<any> {
return this.get(`${this.url}/config/demo`, null, true);
}

getAllTokens(): Observable<any> {
return this.get(`${this.url}/tokens`, null, true);
}
Expand Down

0 comments on commit 40efd07

Please sign in to comment.