matrix-dimension/web/app/shared/models/widget.ts
2017-08-28 22:09:00 -06:00

43 lines
1.1 KiB
TypeScript

import { WidgetsResponse } from "./scalar_responses";
// Scalar's widget types (known)
export const WIDGET_SCALAR_CUSTOM = "customwidget";
export const WIDGET_SCALAR_ETHERPAD = "etherpad";
export const WIDGET_SCALAR_GOOGLEDOCS = "googledocs";
export const WIDGET_SCALAR_JITSI = "jitsi";
export const WIDGET_SCALAR_YOUTUBE = "youtube";
export const WIDGET_SCALAR_GRAFANA = "grafana";
// Dimension has its own set of types to ensure that we don't conflict with Scalar
export const WIDGET_DIM_CUSTOM = "dimension-customwidget";
export interface Widget {
id: string;
type: string;
url: string;
name?: string;
data?: any;
ownerId?: string;
// used only in ui
newName?: string;
newUrl?: string;
}
export function ScalarToWidgets(scalarResponse: WidgetsResponse): Widget[] {
let widgets = [];
for (let event of scalarResponse.response) {
widgets.push({
id: event.state_key,
type: event.content.type,
url: event.content.url,
name: event.content.name,
data: event.content.data,
ownerId: event.sender,
});
}
return widgets;
}