61 lines
1.7 KiB
TypeScript
61 lines
1.7 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { RouteConfigLoadStart, Router } from '@angular/router';
|
|
import { CookiesService } from './services/cookies.service';
|
|
import { JsonrpcService, RpcService } from './services/jsonrpc.service';
|
|
import { lastValueFrom } from 'rxjs';
|
|
|
|
@Component({
|
|
selector: 'app-root',
|
|
templateUrl: './app.component.html',
|
|
styleUrls: ['./app.component.scss'],
|
|
})
|
|
export class AppComponent implements OnInit {
|
|
title = 'Coffee Like Test';
|
|
|
|
constructor(
|
|
private router: Router,
|
|
private cookiesService: CookiesService,
|
|
private jsonRpcService: JsonrpcService
|
|
) {
|
|
this.router.events.subscribe((x) => {
|
|
if (x instanceof RouteConfigLoadStart && x.route.path === '') {
|
|
x.route.loadChildren = () => {
|
|
switch (this.cookiesService.getItem('presentation-option')) {
|
|
case 'first':
|
|
return import(
|
|
'./presentation-options/first-option/first-option.module'
|
|
).then((mod) => mod.FirstOptionModule);
|
|
|
|
default:
|
|
return import(
|
|
'./presentation-options/default-option/default-option.module'
|
|
).then((mod) => mod.DefaultOptionModule);
|
|
}
|
|
};
|
|
}
|
|
});
|
|
}
|
|
|
|
getAdditionalInfo() {
|
|
return this.jsonRpcService.rpc(
|
|
{
|
|
method: 'getAdditionalInfo',
|
|
params: [],
|
|
},
|
|
RpcService.authService,
|
|
true
|
|
);
|
|
}
|
|
|
|
ngOnInit(): void {
|
|
this.getAdditionalInfo().subscribe({
|
|
next: (value) => {
|
|
this.cookiesService.setCookie('presentation-option', value?.data?.interface_id || 'default')
|
|
},
|
|
error: (err) => {
|
|
console.error(err);
|
|
}
|
|
})
|
|
}
|
|
}
|