mirror of
https://github.com/turt2live/matrix-dimension.git
synced 2024-10-01 01:05:53 -04:00
Add twitch livestreams
This commit is contained in:
parent
a72177b530
commit
2bf7841290
@ -38,6 +38,7 @@ import { NameService } from "./shared/services/name.service";
|
||||
import { GoogleCalendarWidgetConfigComponent } from "./configs/widget/google_calendar/gcal.widget.component";
|
||||
import { GoogleDocsWidgetConfigComponent } from "./configs/widget/google_docs/gdoc.widget.component";
|
||||
import { JitsiWidgetConfigComponent } from "./configs/widget/jitsi/jitsi.widget.component";
|
||||
import { TwitchWidgetConfigComponent } from "./configs/widget/twitch/twitch.widget.component";
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@ -75,6 +76,7 @@ import { JitsiWidgetConfigComponent } from "./configs/widget/jitsi/jitsi.widget.
|
||||
GoogleCalendarWidgetConfigComponent,
|
||||
GoogleDocsWidgetConfigComponent,
|
||||
JitsiWidgetConfigComponent,
|
||||
TwitchWidgetConfigComponent,
|
||||
|
||||
// Vendor
|
||||
],
|
||||
|
@ -11,6 +11,7 @@ import { EtherpadWidgetConfigComponent } from "./configs/widget/etherpad/etherpa
|
||||
import { GoogleCalendarWidgetConfigComponent } from "./configs/widget/google_calendar/gcal.widget.component";
|
||||
import { GoogleDocsWidgetConfigComponent } from "./configs/widget/google_docs/gdoc.widget.component";
|
||||
import { JitsiWidgetConfigComponent } from "./configs/widget/jitsi/jitsi.widget.component";
|
||||
import { TwitchWidgetConfigComponent } from "./configs/widget/twitch/twitch.widget.component";
|
||||
|
||||
const routes: Routes = [
|
||||
{path: "", component: HomeComponent},
|
||||
@ -52,6 +53,11 @@ const routes: Routes = [
|
||||
component: JitsiWidgetConfigComponent,
|
||||
data: {breadcrumb: "Jitsi Widgets", name: "Jitsi Widgets"}
|
||||
},
|
||||
{
|
||||
path: "twitch",
|
||||
component: TwitchWidgetConfigComponent,
|
||||
data: {breadcrumb: "Twitch Livestream Widgets", name: "Twitch Livestream Widgets"}
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
@ -22,6 +22,7 @@
|
||||
<my-ibox *ngFor="let widget of widgetComponent.widgets trackById" [isCollapsible]="true" [defaultCollapsed]="widget.id !== widgetComponent.defaultExpandedWidgetId">
|
||||
<h5 class="my-ibox-title">
|
||||
<i class="far fa-edit"></i> {{ widget.name || widget.url || widgetComponent.defaultName }}
|
||||
<span *ngIf="widget.data.title">- {{ widget.data.title }}</span>
|
||||
</h5>
|
||||
<div class="my-ibox-content">
|
||||
<form (submit)="widgetComponent.saveWidget(widget)" novalidate name="editForm">
|
||||
|
@ -14,7 +14,7 @@ export class EtherpadWidgetConfigComponent extends WidgetComponent {
|
||||
private etherpadWidget: EtherpadWidget = <EtherpadWidget>SessionStorage.editIntegration;
|
||||
|
||||
constructor(private nameService: NameService) {
|
||||
super(WIDGET_ETHERPAD, "Etherpad Widget", "generic", "etherpad");
|
||||
super(WIDGET_ETHERPAD, "Etherpad", "generic", "etherpad");
|
||||
}
|
||||
|
||||
protected OnNewWidgetPrepared(widget: EditableWidget): void {
|
||||
|
@ -8,7 +8,11 @@ import { Component } from "@angular/core";
|
||||
})
|
||||
export class GoogleCalendarWidgetConfigComponent extends WidgetComponent {
|
||||
constructor() {
|
||||
super(WIDGET_GOOGLE_CALENDAR, "Google Calendar Widget", DISABLE_AUTOMATIC_WRAPPING, "googleCalendar");
|
||||
super(WIDGET_GOOGLE_CALENDAR, "Google Calendar", DISABLE_AUTOMATIC_WRAPPING, "googleCalendar");
|
||||
}
|
||||
|
||||
protected OnNewWidgetPrepared(widget: EditableWidget) {
|
||||
widget.dimension.newData.src = "";
|
||||
}
|
||||
|
||||
protected OnWidgetsDiscovered(widgets: EditableWidget[]) {
|
||||
|
@ -8,6 +8,6 @@ import { Component } from "@angular/core";
|
||||
})
|
||||
export class GoogleDocsWidgetConfigComponent extends WidgetComponent {
|
||||
constructor() {
|
||||
super(WIDGET_GOOGLE_DOCS, "Google Docs Widget", "generic", "googleDocs");
|
||||
super(WIDGET_GOOGLE_DOCS, "Google Doc", "generic", "googleDocs");
|
||||
}
|
||||
}
|
11
web/app/configs/widget/twitch/twitch.widget.component.html
Normal file
11
web/app/configs/widget/twitch/twitch.widget.component.html
Normal file
@ -0,0 +1,11 @@
|
||||
<my-widget-config [widgetComponent]="this">
|
||||
<ng-template #widgetParamsTemplate let-widget="widget">
|
||||
<label class="label-block">
|
||||
Channel Name
|
||||
<input type="text" class="form-control"
|
||||
placeholder="TwitchUsername"
|
||||
[(ngModel)]="widget.dimension.newData.channelName" name="widget-url-{{widget.id}}"
|
||||
[disabled]="isUpdating"/>
|
||||
</label>
|
||||
</ng-template>
|
||||
</my-widget-config>
|
43
web/app/configs/widget/twitch/twitch.widget.component.ts
Normal file
43
web/app/configs/widget/twitch/twitch.widget.component.ts
Normal file
@ -0,0 +1,43 @@
|
||||
import { WidgetComponent } from "../widget.component";
|
||||
import { EditableWidget, WIDGET_TWITCH } from "../../../shared/models/widget";
|
||||
import { Component } from "@angular/core";
|
||||
|
||||
@Component({
|
||||
templateUrl: "twitch.widget.component.html",
|
||||
styleUrls: ["twitch.widget.component.scss"],
|
||||
})
|
||||
export class TwitchWidgetConfigComponent extends WidgetComponent {
|
||||
constructor() {
|
||||
super(WIDGET_TWITCH, "Twitch Livestream", "video", "twitch");
|
||||
}
|
||||
|
||||
protected OnNewWidgetPrepared(widget: EditableWidget) {
|
||||
widget.dimension.newData.channelName = "";
|
||||
}
|
||||
|
||||
protected OnWidgetsDiscovered(widgets: EditableWidget[]) {
|
||||
for (const widget of widgets) {
|
||||
if (!widget.data.channelName) {
|
||||
// Convert legacy Dimension widgets to new format
|
||||
widget.data.channelName = widget.data.dimChannelName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected OnWidgetBeforeAdd(widget: EditableWidget) {
|
||||
this.setTwitchUrl(widget);
|
||||
}
|
||||
|
||||
protected OnWidgetBeforeEdit(widget: EditableWidget) {
|
||||
this.setTwitchUrl(widget);
|
||||
}
|
||||
|
||||
private setTwitchUrl(widget: EditableWidget) {
|
||||
if (!widget.dimension.newData.channelName || widget.dimension.newData.channelName.trim().length === 0) {
|
||||
throw new Error("Please enter a shared calendar ID");
|
||||
}
|
||||
|
||||
widget.dimension.newUrl = "https://player.twitch.tv/?channel=$channelName";
|
||||
widget.dimension.newTitle = widget.dimension.newData.channelName;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user