mirror of
https://github.com/turt2live/matrix-dimension.git
synced 2024-09-14 13:04:59 +00:00
Add ability to create self-hosted go-neb instances
They can't be provisioned or configured correctly yet, but they exist.
This commit is contained in:
parent
1ae69bc563
commit
74054c3962
@ -44,6 +44,11 @@ export class DimensionAppserviceAdminService {
|
|||||||
@POST
|
@POST
|
||||||
@Path("new")
|
@Path("new")
|
||||||
public createAppservice(@QueryParam("scalar_token") scalarToken: string, request: AppserviceCreateRequest): Promise<AppserviceResponse> {
|
public createAppservice(@QueryParam("scalar_token") scalarToken: string, request: AppserviceCreateRequest): Promise<AppserviceResponse> {
|
||||||
|
// Trim off the @ sign if it's on the prefix
|
||||||
|
if (request.userPrefix[0] === "@") {
|
||||||
|
request.userPrefix = request.userPrefix.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
return DimensionAdminService.validateAndGetAdminTokenOwner(scalarToken).then(_userId => {
|
return DimensionAdminService.validateAndGetAdminTokenOwner(scalarToken).then(_userId => {
|
||||||
return AppserviceStore.getAllByUserPrefix(request.userPrefix);
|
return AppserviceStore.getAllByUserPrefix(request.userPrefix);
|
||||||
}).then(appservices => {
|
}).then(appservices => {
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
<my-ibox title="New self-hosted go-neb">
|
||||||
|
<div class="my-ibox-content">
|
||||||
|
<p>Self-hosted go-neb instances are powered by application services installed on your homeserver. The application service is responsible for creating the bots dynamically.</p>
|
||||||
|
|
||||||
|
<label class="label-block">
|
||||||
|
User Prefix
|
||||||
|
<span class="text-muted ">This is the prefix used for all bot users.</span>
|
||||||
|
<input type="text" class="form-control"
|
||||||
|
placeholder="@_neb"
|
||||||
|
[(ngModel)]="userPrefix" [disabled]="isSaving"/>
|
||||||
|
</label>
|
||||||
|
<label class="label-block">
|
||||||
|
API URL
|
||||||
|
<span class="text-muted ">The admin/api url for go-neb. Be sure to not expose the admin API to the outside world because this endpoint is not authenticated.</span>
|
||||||
|
<input type="text" class="form-control"
|
||||||
|
placeholder="http://localhost:4050"
|
||||||
|
[(ngModel)]="adminUrl" [disabled]="isSaving"/>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<button type="button" (click)="save()" title="save" class="btn btn-primary btn-sm" [disabled]="isSaving">
|
||||||
|
<i class="far fa-save"></i> Save
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</my-ibox>
|
38
web/app/admin/neb/add_selfhosted/add_selfhosted.component.ts
Normal file
38
web/app/admin/neb/add_selfhosted/add_selfhosted.component.ts
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
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";
|
||||||
|
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
templateUrl: "./add_selfhosted.component.html",
|
||||||
|
styleUrls: ["./add_selfhosted.component.scss"],
|
||||||
|
})
|
||||||
|
export class AdminAddSelfhostedNebComponent {
|
||||||
|
|
||||||
|
public isSaving = false;
|
||||||
|
public userPrefix = "@_neb";
|
||||||
|
public adminUrl = "http://localhost:4050";
|
||||||
|
|
||||||
|
constructor(private asApi: AdminAppserviceApiService,
|
||||||
|
private nebApi: AdminNebApiService,
|
||||||
|
private toaster: ToasterService,
|
||||||
|
private router: Router,
|
||||||
|
private activatedRoute: ActivatedRoute) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public save(): void {
|
||||||
|
this.isSaving = true;
|
||||||
|
this.asApi.createAppservice(this.userPrefix).then(appservice => {
|
||||||
|
return this.nebApi.newAppserviceConfiguration(this.adminUrl, appservice);
|
||||||
|
}).then(() => {
|
||||||
|
this.toaster.pop("success", "New go-neb created");
|
||||||
|
this.router.navigate(["../.."], {relativeTo: this.activatedRoute});
|
||||||
|
}).catch(err => {
|
||||||
|
console.error(err);
|
||||||
|
this.isSaving = false;
|
||||||
|
this.toaster.pop("error", "Error creating appservice");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -19,8 +19,8 @@ export class AdminEditNebComponent implements OnInit, OnDestroy {
|
|||||||
public nebConfig: FE_NebConfiguration;
|
public nebConfig: FE_NebConfiguration;
|
||||||
|
|
||||||
private subscription: any;
|
private subscription: any;
|
||||||
private overlappingTypes: string[];
|
private overlappingTypes: string[] = [];
|
||||||
private botTypes: string[];
|
private botTypes: string[] = [];
|
||||||
|
|
||||||
constructor(private nebApi: AdminNebApiService, private route: ActivatedRoute, private toaster: ToasterService) {
|
constructor(private nebApi: AdminNebApiService, private route: ActivatedRoute, private toaster: ToasterService) {
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,10 @@
|
|||||||
<td colspan="2"><i>No go-neb configurations.</i></td>
|
<td colspan="2"><i>No go-neb configurations.</i></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr *ngFor="let neb of configurations trackById">
|
<tr *ngFor="let neb of configurations trackById">
|
||||||
<td>{{ neb.upstreamId ? "matrix.org's go-neb" : "Self-hosted go-neb" }}</td>
|
<td>
|
||||||
|
{{ neb.upstreamId ? "matrix.org's go-neb" : "Self-hosted go-neb" }}
|
||||||
|
<span class="text-muted" style="display: inline-block;" *ngIf="!neb.upstreamId">({{ neb.adminUrl }})</span>
|
||||||
|
</td>
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
<span class="appsvcConfigButton" (click)="showAppserviceConfig(neb)"
|
<span class="appsvcConfigButton" (click)="showAppserviceConfig(neb)"
|
||||||
*ngIf="!neb.upstreamId">
|
*ngIf="!neb.upstreamId">
|
||||||
|
@ -4,6 +4,7 @@ import { AdminNebApiService } from "../../shared/services/admin/admin-neb-api.se
|
|||||||
import { AdminUpstreamApiService } from "../../shared/services/admin/admin-upstream-api.service";
|
import { AdminUpstreamApiService } from "../../shared/services/admin/admin-upstream-api.service";
|
||||||
import { AdminAppserviceApiService } from "../../shared/services/admin/admin-appservice-api.service";
|
import { AdminAppserviceApiService } from "../../shared/services/admin/admin-appservice-api.service";
|
||||||
import { FE_Appservice, FE_NebConfiguration, FE_Upstream } from "../../shared/models/admin_responses";
|
import { FE_Appservice, FE_NebConfiguration, FE_Upstream } from "../../shared/models/admin_responses";
|
||||||
|
import { ActivatedRoute, Router } from "@angular/router";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: "./neb.component.html",
|
templateUrl: "./neb.component.html",
|
||||||
@ -21,7 +22,9 @@ export class AdminNebComponent {
|
|||||||
constructor(private nebApi: AdminNebApiService,
|
constructor(private nebApi: AdminNebApiService,
|
||||||
private upstreamApi: AdminUpstreamApiService,
|
private upstreamApi: AdminUpstreamApiService,
|
||||||
private appserviceApi: AdminAppserviceApiService,
|
private appserviceApi: AdminAppserviceApiService,
|
||||||
private toaster: ToasterService) {
|
private toaster: ToasterService,
|
||||||
|
private router: Router,
|
||||||
|
private activatedRoute:ActivatedRoute) {
|
||||||
|
|
||||||
this.reload().then(() => this.isLoading = false).catch(error => {
|
this.reload().then(() => this.isLoading = false).catch(error => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
@ -69,7 +72,7 @@ export class AdminNebComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public addSelfHostedNeb() {
|
public addSelfHostedNeb() {
|
||||||
console.log("ADD Hosted");
|
this.router.navigate(["new", "selfhosted"], {relativeTo: this.activatedRoute});
|
||||||
}
|
}
|
||||||
|
|
||||||
public addModularHostedNeb() {
|
public addModularHostedNeb() {
|
||||||
|
@ -1,8 +1,3 @@
|
|||||||
.text-muted {
|
|
||||||
display: block;
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.label-block {
|
.label-block {
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
}
|
}
|
@ -52,6 +52,7 @@ import { AdminNebApiService } from "./shared/services/admin/admin-neb-api.servic
|
|||||||
import { AdminUpstreamApiService } from "./shared/services/admin/admin-upstream-api.service";
|
import { AdminUpstreamApiService } from "./shared/services/admin/admin-upstream-api.service";
|
||||||
import { AdminNebComponent } from "./admin/neb/neb.component";
|
import { AdminNebComponent } from "./admin/neb/neb.component";
|
||||||
import { AdminEditNebComponent } from "./admin/neb/edit/edit.component";
|
import { AdminEditNebComponent } from "./admin/neb/edit/edit.component";
|
||||||
|
import { AdminAddSelfhostedNebComponent } from "./admin/neb/add_selfhosted/add_selfhosted.component";
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
@ -98,6 +99,7 @@ import { AdminEditNebComponent } from "./admin/neb/edit/edit.component";
|
|||||||
AdminWidgetJitsiConfigComponent,
|
AdminWidgetJitsiConfigComponent,
|
||||||
AdminNebComponent,
|
AdminNebComponent,
|
||||||
AdminEditNebComponent,
|
AdminEditNebComponent,
|
||||||
|
AdminAddSelfhostedNebComponent,
|
||||||
|
|
||||||
// Vendor
|
// Vendor
|
||||||
],
|
],
|
||||||
|
@ -18,6 +18,7 @@ import { AdminHomeComponent } from "./admin/home/home.component";
|
|||||||
import { AdminWidgetsComponent } from "./admin/widgets/widgets.component";
|
import { AdminWidgetsComponent } from "./admin/widgets/widgets.component";
|
||||||
import { AdminNebComponent } from "./admin/neb/neb.component";
|
import { AdminNebComponent } from "./admin/neb/neb.component";
|
||||||
import { AdminEditNebComponent } from "./admin/neb/edit/edit.component";
|
import { AdminEditNebComponent } from "./admin/neb/edit/edit.component";
|
||||||
|
import { AdminAddSelfhostedNebComponent } from "./admin/neb/add_selfhosted/add_selfhosted.component";
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{path: "", component: HomeComponent},
|
{path: "", component: HomeComponent},
|
||||||
@ -57,6 +58,11 @@ const routes: Routes = [
|
|||||||
path: ":nebId/edit",
|
path: ":nebId/edit",
|
||||||
component: AdminEditNebComponent,
|
component: AdminEditNebComponent,
|
||||||
data: {breadcrumb: "Edit go-neb", name: "Edit go-neb"},
|
data: {breadcrumb: "Edit go-neb", name: "Edit go-neb"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "new/selfhosted",
|
||||||
|
component: AdminAddSelfhostedNebComponent,
|
||||||
|
data: {breadcrumb: "Add self-hosted go-neb", name: "Add self-hosted go-neb"},
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -12,4 +12,8 @@ export class AdminAppserviceApiService extends AuthedApi {
|
|||||||
public getAppservices(): Promise<FE_Appservice[]> {
|
public getAppservices(): Promise<FE_Appservice[]> {
|
||||||
return this.authedGet("/api/v1/dimension/admin/appservices/all").map(r => r.json()).toPromise();
|
return this.authedGet("/api/v1/dimension/admin/appservices/all").map(r => r.json()).toPromise();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public createAppservice(userPrefix: string): Promise<FE_Appservice> {
|
||||||
|
return this.authedPost("/api/v1/dimension/admin/appservices/new", {userPrefix: userPrefix}).map(r => r.json()).toPromise();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,3 +36,8 @@ button {
|
|||||||
.label-block {
|
.label-block {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.text-muted {
|
||||||
|
display: block;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user