2018-01-31 18:30:08 -05:00
|
|
|
import { Component } from "@angular/core";
|
|
|
|
import { AdminAppserviceApiService } from "../../../shared/services/admin/admin-appservice-api.service";
|
|
|
|
import { AdminNebApiService } from "../../../shared/services/admin/admin-neb-api.service";
|
|
|
|
import { ToasterService } from "angular2-toaster";
|
|
|
|
import { ActivatedRoute, Router } from "@angular/router";
|
2018-03-24 14:18:38 -04:00
|
|
|
import {
|
|
|
|
AdminNebAppserviceConfigComponent,
|
|
|
|
AppserviceConfigDialogContext
|
|
|
|
} from "../appservice-config/appservice-config.component";
|
2020-10-23 07:30:20 -04:00
|
|
|
import { TranslateService } from "@ngx-translate/core";
|
2021-08-16 18:00:59 -04:00
|
|
|
import { NgbModal } from "@ng-bootstrap/ng-bootstrap";
|
2018-01-31 18:30:08 -05:00
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
2018-03-24 19:16:52 -04:00
|
|
|
templateUrl: "./add-selfhosted.component.html",
|
|
|
|
styleUrls: ["./add-selfhosted.component.scss"],
|
2018-01-31 18:30:08 -05:00
|
|
|
})
|
|
|
|
export class AdminAddSelfhostedNebComponent {
|
|
|
|
|
|
|
|
public isSaving = false;
|
|
|
|
public userPrefix = "@_neb";
|
|
|
|
public adminUrl = "http://localhost:4050";
|
|
|
|
|
|
|
|
constructor(private asApi: AdminAppserviceApiService,
|
2021-09-01 19:01:01 -04:00
|
|
|
private nebApi: AdminNebApiService,
|
|
|
|
private toaster: ToasterService,
|
|
|
|
private router: Router,
|
|
|
|
private activatedRoute: ActivatedRoute,
|
|
|
|
private modal: NgbModal,
|
|
|
|
public translate: TranslateService) {
|
2021-08-29 17:21:01 -04:00
|
|
|
this.translate = translate;
|
2018-01-31 18:30:08 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public save(): void {
|
|
|
|
this.isSaving = true;
|
|
|
|
this.asApi.createAppservice(this.userPrefix).then(appservice => {
|
|
|
|
return this.nebApi.newAppserviceConfiguration(this.adminUrl, appservice);
|
2018-03-24 14:18:38 -04:00
|
|
|
}).then(neb => {
|
2021-09-01 19:01:01 -04:00
|
|
|
this.translate.get('New go-neb created').subscribe((res: string) => {
|
|
|
|
this.toaster.pop("success", res);
|
|
|
|
});
|
2018-03-24 14:18:38 -04:00
|
|
|
|
2021-08-16 18:00:59 -04:00
|
|
|
const selfhostedRef = this.modal.open(AdminNebAppserviceConfigComponent, {
|
|
|
|
backdrop: 'static',
|
2018-03-24 14:18:38 -04:00
|
|
|
size: 'lg',
|
2021-08-16 18:00:59 -04:00
|
|
|
});
|
|
|
|
selfhostedRef.result.then(() => this.router.navigate(["../.."], {relativeTo: this.activatedRoute}));
|
|
|
|
const selfhostedInstance = selfhostedRef.componentInstance as AppserviceConfigDialogContext;
|
|
|
|
selfhostedInstance.neb = neb;
|
2018-01-31 18:30:08 -05:00
|
|
|
}).catch(err => {
|
|
|
|
console.error(err);
|
|
|
|
this.isSaving = false;
|
2021-09-01 19:01:01 -04:00
|
|
|
this.translate.get('Error creating appservice').subscribe((res: string) => {
|
|
|
|
this.toaster.pop("error", res);
|
|
|
|
});
|
2018-01-31 18:30:08 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|