import { Injectable } from '@angular/core'; import {ApiService} from './api.service'; @Injectable({ providedIn: 'root' }) export class SessionService { public appName!: string; public systemBase!: string; protected data: any = {}; constructor( protected readonly api: ApiService, ) { } async stat() { return new Promise((res, rej) => { this.api.stat().subscribe(response => { res(response.data); }); }); } async initialize() { return new Promise((res, rej) => { this.api.get('/session').subscribe(response => { this.data = response.data; res(); }); }); } buildAppUrl(...parts: string[]): string { parts = parts.map(x => { if ( x.startsWith('/') ) { x = x.slice(1); } if ( x.endsWith('/') ) { x = x.slice(0, -1); } return x; }); return `${this.systemBase}${this.systemBase.endsWith('/') ? '' : '/'}${parts.join('/')}`; } }