2018-03-31 13:45:19 -04:00
|
|
|
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";
|
2020-10-23 07:30:20 -04:00
|
|
|
import { TranslateService } from "@ngx-translate/core";
|
2018-03-31 13:45:19 -04:00
|
|
|
|
|
|
|
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,
|
2020-10-23 07:30:20 -04:00
|
|
|
private toaster: ToasterService,
|
|
|
|
public translate: TranslateService) {
|
|
|
|
this.translate = translate;
|
2018-03-31 13:45:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public add() {
|
|
|
|
this.isSaving = true;
|
|
|
|
this.ircApi.newSelfhosted(this.provisionUrl).then(() => {
|
2020-10-23 07:30:20 -04:00
|
|
|
this.translate.get('IRC Bridge added').subscribe((res: string) => {this.toaster.pop("success", res); });
|
2018-03-31 13:45:19 -04:00
|
|
|
this.dialog.close();
|
|
|
|
}).catch(err => {
|
|
|
|
console.error(err);
|
|
|
|
this.isSaving = false;
|
2020-10-23 07:30:20 -04:00
|
|
|
this.translate.get('Failed to create IRC bridge').subscribe((res: string) => {this.toaster.pop("error", res); });
|
2018-03-31 13:45:19 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|