cic-staff-client/src/app/app.component.ts

64 lines
2.0 KiB
TypeScript
Raw Normal View History

import {Component, HostListener} from '@angular/core';
import {TokenService, TransactionService} from '@app/_services';
import {AuthService} from '@app/_services';
2020-10-30 16:16:05 +01:00
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
title = 'CICADA';
2020-11-08 07:31:52 +01:00
readyStateTarget: number = 3;
readyState: number = 0;
mediaQuery = window.matchMedia('(max-width: 768px)');
2020-11-08 07:31:52 +01:00
constructor(
private authService: AuthService,
private tokenService: TokenService,
private transactionService: TransactionService,
) {
this.authService.mutableKeyStore.loadKeyring().then(r => this.authService.getPublicKeys().then());
this.tokenService.getTokens().then(async r => console.log('Tokens:', await r));
this.mediaQuery.addListener(this.onResize);
this.onResize(this.mediaQuery);
2020-11-08 07:31:52 +01:00
}
// Load resize
onResize(e): void {
const sidebar = document.getElementById('sidebar');
const content = document.getElementById('content');
const sidebarCollapse = document.getElementById('sidebarCollapse');
if (sidebarCollapse?.classList.contains('active')) {
sidebarCollapse?.classList.remove('active');
}
if (e.matches) {
if (!sidebar?.classList.contains('active')) {
sidebar?.classList.add('active');
}
if (!content?.classList.contains('active')) {
content?.classList.add('active');
}
} else {
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;
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;
this.transactionService.setConversion(conversion, 100).then();
2020-11-08 07:31:52 +01:00
}
2020-10-30 16:16:05 +01:00
}