mirror of
https://github.com/turt2live/matrix-dimension.git
synced 2024-08-31 06:02:09 +00:00
Add ability to add self-hosted IRC bridges
This commit is contained in:
parent
aa8ec0ed58
commit
1e437a2f8b
@ -0,0 +1,24 @@
|
|||||||
|
<div class="dialog">
|
||||||
|
<div class="dialog-header">
|
||||||
|
<h4>Add a new self-hosted IRC Bridge</h4>
|
||||||
|
</div>
|
||||||
|
<div class="dialog-content">
|
||||||
|
<p>Self-hosted IRC bridges must have <code>provisioning</code> enabled in the configuration.</p>
|
||||||
|
|
||||||
|
<label class="label-block">
|
||||||
|
Provisioning URL
|
||||||
|
<span class="text-muted ">The provisioning URL for the bridge. This is usually the same as the URL given in the registration. This API is not authenticated and should be treated with caution.</span>
|
||||||
|
<input type="text" class="form-control"
|
||||||
|
placeholder="http://localhost:9999"
|
||||||
|
[(ngModel)]="provisionUrl" [disabled]="isSaving"/>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="dialog-footer">
|
||||||
|
<button type="button" (click)="add()" title="close" class="btn btn-primary btn-sm">
|
||||||
|
<i class="far fa-save"></i> Save
|
||||||
|
</button>
|
||||||
|
<button type="button" (click)="dialog.close()" title="close" class="btn btn-secondary btn-sm">
|
||||||
|
<i class="far fa-times-circle"></i> Cancel
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -0,0 +1,35 @@
|
|||||||
|
import { Component } from "@angular/core";
|
||||||
|
import { ToasterService } from "angular2-toaster";
|
||||||
|
import { DialogRef, ModalComponent } from "ngx-modialog";
|
||||||
|
import { BSModalContext } from "ngx-modialog/plugins/bootstrap";
|
||||||
|
import { AdminIrcApiService } from "../../../../shared/services/admin/admin-irc-api.service";
|
||||||
|
|
||||||
|
export class AddSelfhostedIrcBridgeDialogContext extends BSModalContext {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
templateUrl: "./add-selfhosted.component.html",
|
||||||
|
styleUrls: ["./add-selfhosted.component.scss"],
|
||||||
|
})
|
||||||
|
export class AdminIrcBridgeAddSelfhostedComponent implements ModalComponent<AddSelfhostedIrcBridgeDialogContext> {
|
||||||
|
|
||||||
|
public isSaving = false;
|
||||||
|
public provisionUrl: string;
|
||||||
|
|
||||||
|
constructor(public dialog: DialogRef<AddSelfhostedIrcBridgeDialogContext>,
|
||||||
|
private ircApi: AdminIrcApiService,
|
||||||
|
private toaster: ToasterService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public add() {
|
||||||
|
this.isSaving = true;
|
||||||
|
this.ircApi.newSelfhosted(this.provisionUrl).then(() => {
|
||||||
|
this.toaster.pop("success", "IRC Bridge added");
|
||||||
|
this.dialog.close();
|
||||||
|
}).catch(err => {
|
||||||
|
console.error(err);
|
||||||
|
this.isSaving = false;
|
||||||
|
this.toaster.pop("error", "Failed to create IRC bridge");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -25,7 +25,7 @@
|
|||||||
<tr *ngFor="let bridge of configurations trackById">
|
<tr *ngFor="let bridge of configurations trackById">
|
||||||
<td>
|
<td>
|
||||||
{{ bridge.upstreamId ? "matrix.org's bridge" : "Self-hosted bridge" }}
|
{{ bridge.upstreamId ? "matrix.org's bridge" : "Self-hosted bridge" }}
|
||||||
<span class="text-muted" style="display: inline-block;" *ngIf="!bridge.upstreamId">({{ bridge.adminUrl }})</span>
|
<span class="text-muted" style="display: inline-block;" *ngIf="!bridge.upstreamId">({{ bridge.provisionUrl }})</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{ getEnabledNetworksString(bridge) }}
|
{{ getEnabledNetworksString(bridge) }}
|
||||||
|
@ -6,6 +6,10 @@ import { AdminUpstreamApiService } from "../../../shared/services/admin/admin-up
|
|||||||
import { FE_IrcBridge } from "../../../shared/models/irc";
|
import { FE_IrcBridge } from "../../../shared/models/irc";
|
||||||
import { Modal, overlayConfigFactory } from "ngx-modialog";
|
import { Modal, overlayConfigFactory } from "ngx-modialog";
|
||||||
import { AdminIrcBridgeNetworksComponent, IrcNetworksDialogContext } from "./networks/networks.component";
|
import { AdminIrcBridgeNetworksComponent, IrcNetworksDialogContext } from "./networks/networks.component";
|
||||||
|
import {
|
||||||
|
AddSelfhostedIrcBridgeDialogContext,
|
||||||
|
AdminIrcBridgeAddSelfhostedComponent
|
||||||
|
} from "./add-selfhosted/add-selfhosted.component";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: "./irc.component.html",
|
templateUrl: "./irc.component.html",
|
||||||
@ -87,7 +91,15 @@ export class AdminIrcBridgeComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public addSelfHostedBridge() {
|
public addSelfHostedBridge() {
|
||||||
console.log("TODO: Dialog");
|
this.modal.open(AdminIrcBridgeAddSelfhostedComponent, overlayConfigFactory({
|
||||||
|
isBlocking: true,
|
||||||
|
size: 'lg',
|
||||||
|
}, AddSelfhostedIrcBridgeDialogContext)).result.then(() => {
|
||||||
|
this.reload().catch(err => {
|
||||||
|
console.error(err);
|
||||||
|
this.toaster.pop("error", "Failed to get an update IRC bridge list");
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public editNetworks(bridge: FE_IrcBridge) {
|
public editNetworks(bridge: FE_IrcBridge) {
|
||||||
|
@ -67,6 +67,7 @@ import { AdminBridgesComponent } from "./admin/bridges/bridges.component";
|
|||||||
import { AdminIrcBridgeComponent } from "./admin/bridges/irc/irc.component";
|
import { AdminIrcBridgeComponent } from "./admin/bridges/irc/irc.component";
|
||||||
import { AdminIrcApiService } from "./shared/services/admin/admin-irc-api.service";
|
import { AdminIrcApiService } from "./shared/services/admin/admin-irc-api.service";
|
||||||
import { AdminIrcBridgeNetworksComponent } from "./admin/bridges/irc/networks/networks.component";
|
import { AdminIrcBridgeNetworksComponent } from "./admin/bridges/irc/networks/networks.component";
|
||||||
|
import { AdminIrcBridgeAddSelfhostedComponent } from "./admin/bridges/irc/add-selfhosted/add-selfhosted.component";
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
@ -127,6 +128,7 @@ import { AdminIrcBridgeNetworksComponent } from "./admin/bridges/irc/networks/ne
|
|||||||
AdminBridgesComponent,
|
AdminBridgesComponent,
|
||||||
AdminIrcBridgeComponent,
|
AdminIrcBridgeComponent,
|
||||||
AdminIrcBridgeNetworksComponent,
|
AdminIrcBridgeNetworksComponent,
|
||||||
|
AdminIrcBridgeAddSelfhostedComponent,
|
||||||
|
|
||||||
// Vendor
|
// Vendor
|
||||||
],
|
],
|
||||||
@ -157,6 +159,7 @@ import { AdminIrcBridgeNetworksComponent } from "./admin/bridges/irc/networks/ne
|
|||||||
AdminNebImgurConfigComponent,
|
AdminNebImgurConfigComponent,
|
||||||
ConfigSimpleBotComponent,
|
ConfigSimpleBotComponent,
|
||||||
AdminIrcBridgeNetworksComponent,
|
AdminIrcBridgeNetworksComponent,
|
||||||
|
AdminIrcBridgeAddSelfhostedComponent,
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class AppModule {
|
export class AppModule {
|
||||||
|
Loading…
Reference in New Issue
Block a user