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

34 lines
1.4 KiB
TypeScript
Raw Normal View History

2017-12-23 15:32:07 -05:00
import { WidgetComponent } from "../widget.component";
2017-12-23 15:16:05 -05:00
import { EditableWidget, WIDGET_ETHERPAD } from "../../../shared/models/widget";
import { Component } from "@angular/core";
import { FE_EtherpadWidget } from "../../../shared/models/integration";
2017-12-23 15:16:05 -05:00
import { SessionStorage } from "../../../shared/SessionStorage";
import { NameService } from "../../../shared/services/name.service";
@Component({
templateUrl: "etherpad.widget.component.html",
styleUrls: ["etherpad.widget.component.scss"],
})
2017-12-23 15:32:07 -05:00
export class EtherpadWidgetConfigComponent extends WidgetComponent {
2017-12-23 15:16:05 -05:00
private etherpadWidget: FE_EtherpadWidget = <FE_EtherpadWidget>SessionStorage.editIntegration;
2017-12-23 15:16:05 -05:00
constructor(private nameService: NameService) {
2017-12-23 17:03:24 -05:00
super(WIDGET_ETHERPAD, "Etherpad", "generic", "etherpad");
2017-12-23 15:16:05 -05:00
}
protected OnNewWidgetPrepared(widget: EditableWidget): void {
const name = this.nameService.getHumanReadableName();
let template = "https://demo.riot.im/etherpad/p/$roomId_$padName";
if (this.etherpadWidget.options && this.etherpadWidget.options.defaultUrl) {
template = this.etherpadWidget.options.defaultUrl;
}
template = template.replace("$roomId", encodeURIComponent(SessionStorage.roomId));
template = template.replace("$padName", encodeURIComponent(name));
widget.dimension.newUrl = template;
widget.dimension.newName = name;
}
}