2021-03-14 09:23:20 +01:00
|
|
|
import {ChangeDetectionStrategy, Component, HostListener} from '@angular/core';
|
|
|
|
import {AuthService, LoggingService, TokenService, TransactionService} from '@app/_services';
|
|
|
|
import {NGXLogger} from 'ngx-logger';
|
2020-10-30 16:16:05 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-root',
|
|
|
|
templateUrl: './app.component.html',
|
2021-03-14 09:23:20 +01:00
|
|
|
styleUrls: ['./app.component.scss'],
|
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush
|
2020-10-30 16:16:05 +01:00
|
|
|
})
|
2021-03-04 10:35:20 +01:00
|
|
|
export class AppComponent {
|
2021-02-17 12:52:42 +01:00
|
|
|
title = 'CICADA';
|
2020-11-08 07:31:52 +01:00
|
|
|
readyStateTarget: number = 3;
|
|
|
|
readyState: number = 0;
|
2020-11-25 09:05:13 +01:00
|
|
|
mediaQuery = window.matchMedia('(max-width: 768px)');
|
2020-11-08 07:31:52 +01:00
|
|
|
|
2020-11-25 09:05:13 +01:00
|
|
|
constructor(
|
2021-02-17 12:52:42 +01:00
|
|
|
private authService: AuthService,
|
2021-03-10 10:47:01 +01:00
|
|
|
private tokenService: TokenService,
|
2020-11-25 09:05:13 +01:00
|
|
|
private transactionService: TransactionService,
|
2021-03-14 09:23:20 +01:00
|
|
|
private logger: NGXLogger,
|
|
|
|
private loggingService: LoggingService,
|
2020-11-25 09:05:13 +01:00
|
|
|
) {
|
2021-02-17 12:13:08 +01:00
|
|
|
this.authService.mutableKeyStore.loadKeyring().then(r => this.authService.getPublicKeys().then());
|
2021-03-14 09:23:20 +01:00
|
|
|
this.tokenService.getTokens().then(async r => loggingService.sendInfoLevelMessage(await r));
|
2020-11-25 09:05:13 +01:00
|
|
|
this.mediaQuery.addListener(this.onResize);
|
|
|
|
this.onResize(this.mediaQuery);
|
2020-11-08 07:31:52 +01:00
|
|
|
}
|
|
|
|
|
2020-11-25 09:05:13 +01:00
|
|
|
// Load resize
|
|
|
|
onResize(e): void {
|
|
|
|
const sidebar = document.getElementById('sidebar');
|
|
|
|
const content = document.getElementById('content');
|
|
|
|
const sidebarCollapse = document.getElementById('sidebarCollapse');
|
2021-03-04 10:35:20 +01:00
|
|
|
if (sidebarCollapse?.classList.contains('active')) {
|
|
|
|
sidebarCollapse?.classList.remove('active');
|
|
|
|
}
|
2020-11-25 09:05:13 +01:00
|
|
|
if (e.matches) {
|
2021-03-04 10:35:20 +01:00
|
|
|
if (!sidebar?.classList.contains('active')) {
|
|
|
|
sidebar?.classList.add('active');
|
|
|
|
}
|
|
|
|
if (!content?.classList.contains('active')) {
|
|
|
|
content?.classList.add('active');
|
|
|
|
}
|
2020-11-25 09:05:13 +01:00
|
|
|
} else {
|
2021-03-04 10:35:20 +01:00
|
|
|
if (sidebar?.classList.contains('active')) {
|
|
|
|
sidebar?.classList.remove('active');
|
|
|
|
}
|
|
|
|
if (content?.classList.contains('active')) {
|
|
|
|
content?.classList.remove('active');
|
|
|
|
}
|
2020-11-08 07:31:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@HostListener('window:cic_transfer', ['$event'])
|
|
|
|
cicTransfer(event: CustomEvent): void {
|
|
|
|
const transaction = event.detail.tx;
|
2021-03-04 16:56:14 +01:00
|
|
|
this.transactionService.setTransaction(transaction, 100).then();
|
2020-11-08 07:31:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@HostListener('window:cic_convert', ['$event'])
|
|
|
|
cicConvert(event: CustomEvent): void {
|
|
|
|
const conversion = event.detail.tx;
|
2021-03-04 16:56:14 +01:00
|
|
|
this.transactionService.setConversion(conversion, 100).then();
|
2020-11-08 07:31:52 +01:00
|
|
|
}
|
2020-10-30 16:16:05 +01:00
|
|
|
}
|