matrix-dimension/web/app/riot/riot.component.ts
turt2live 0c51d4424b UI for simple matrix.org bots
Part of #11

Needs actual scalar integration
2017-05-27 01:27:36 -06:00

33 lines
1019 B
TypeScript

import { Component } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import { ApiService } from "../shared/api.service";
import { Bot } from "../shared/models/bot";
@Component({
selector: 'my-riot',
templateUrl: './riot.component.html',
styleUrls: ['./riot.component.scss'],
})
export class RiotComponent {
public error: string;
public bots: Bot[] = [];
constructor(private activatedRoute: ActivatedRoute, private api: ApiService) {
let params: any = this.activatedRoute.snapshot.queryParams;
if (!params.scalar_token || !params.room_id) this.error = "Missing scalar token or room ID";
else this.api.checkScalarToken(params.scalar_token).then(isValid => {
if (isValid) this.init();
else this.error = "Invalid scalar token";
});
}
private init() {
this.api.getBots().then(bots => {
this.bots = bots;
bots.map(b => b.isEnabled = Math.random() > 0.75);
});
}
}