You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
frontend/src/app/service/session.service.ts

49 lines
1.1 KiB

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('/')}`;
}
}