matrix-dimension/web/app/configs/widget/widget.component.ts

24 lines
776 B
TypeScript
Raw Normal View History

import { ScalarService } from "../../shared/scalar.service";
import { Widget, ScalarToWidgets } from "../../shared/models/widget";
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;
});
}
}