matrix-dimension/web/app/configs/widget/widget.component.ts
2017-10-09 20:26:46 -06:00

30 lines
1.1 KiB
TypeScript

import { ScalarService } from "../../shared/scalar.service";
import { Widget, ScalarToWidgets } from "../../shared/models/widget";
export const SCALAR_WIDGET_LINKS = [
'https://scalar-staging.riot.im/scalar/api/widgets/generic.html?url=',
'https://scalar-staging.vector.im/scalar/api/widgets/generic.html?url=',
'https://scalar-develop.riot.im/scalar/api/widgets/generic.html?url=',
'https://demo.riot.im/scalar/api/widgets/generic.html?url=',
];
export class WidgetComponent {
constructor(protected scalarApi: ScalarService, protected roomId: string) {
}
protected getWidgetsOfType(type: string, altType: string = null): Promise<Widget[]> {
return this.scalarApi.getWidgets(this.roomId)
.then(resp => ScalarToWidgets(resp))
.then(widgets => {
let filtered: Widget[] = [];
for (let widget of widgets) {
if (widget.type === type || (altType && widget.type === altType))
filtered.push(widget);
}
return filtered;
});
}
}