diff --git a/web/app/app.module.ts b/web/app/app.module.ts
index aa0a86e..c1717e1 100644
--- a/web/app/app.module.ts
+++ b/web/app/app.module.ts
@@ -58,6 +58,7 @@ import { AdminNebGiphyConfigComponent } from "./admin/neb/config/giphy/giphy.com
import { AdminNebGuggyConfigComponent } from "./admin/neb/config/guggy/guggy.component";
import { AdminNebGoogleConfigComponent } from "./admin/neb/config/google/google.component";
import { AdminNebImgurConfigComponent } from "./admin/neb/config/imgur/imgur.component";
+import { ConfigSimpleBotComponent } from "./configs/simple-bot/simple-bot.component";
@NgModule({
imports: [
@@ -110,6 +111,7 @@ import { AdminNebImgurConfigComponent } from "./admin/neb/config/imgur/imgur.com
AdminNebGuggyConfigComponent,
AdminNebGoogleConfigComponent,
AdminNebImgurConfigComponent,
+ ConfigSimpleBotComponent,
// Vendor
],
@@ -137,6 +139,7 @@ import { AdminNebImgurConfigComponent } from "./admin/neb/config/imgur/imgur.com
AdminNebGuggyConfigComponent,
AdminNebGoogleConfigComponent,
AdminNebImgurConfigComponent,
+ ConfigSimpleBotComponent,
]
})
export class AppModule {
diff --git a/web/app/configs/simple-bot/simple-bot.component.html b/web/app/configs/simple-bot/simple-bot.component.html
new file mode 100644
index 0000000..1804363
--- /dev/null
+++ b/web/app/configs/simple-bot/simple-bot.component.html
@@ -0,0 +1,14 @@
+
+
+
+
{{ bot.description }}
+
+
+
+
\ No newline at end of file
diff --git a/web/app/configs/simple-bot/simple-bot.component.scss b/web/app/configs/simple-bot/simple-bot.component.scss
new file mode 100644
index 0000000..e69de29
diff --git a/web/app/configs/simple-bot/simple-bot.component.ts b/web/app/configs/simple-bot/simple-bot.component.ts
new file mode 100644
index 0000000..658814f
--- /dev/null
+++ b/web/app/configs/simple-bot/simple-bot.component.ts
@@ -0,0 +1,59 @@
+import { Component } from "@angular/core";
+import { FE_SimpleBot } from "../../shared/models/integration";
+import { ToasterService } from "angular2-toaster";
+import { ScalarClientApiService } from "../../shared/services/scalar/scalar-client-api.service";
+import { IntegrationsApiService } from "../../shared/services/integrations/integrations-api.service";
+import { BSModalContext } from "ngx-modialog/plugins/bootstrap";
+import { DialogRef } from "ngx-modialog";
+
+export class SimpleBotConfigDialogContext extends BSModalContext {
+ public bot: FE_SimpleBot;
+ public roomId: string;
+}
+
+@Component({
+ templateUrl: "simple-bot.component.html",
+ styleUrls: ["simple-bot.component.scss"],
+})
+export class ConfigSimpleBotComponent {
+
+ public bot: FE_SimpleBot;
+
+ private roomId: string;
+
+ constructor(public dialog: DialogRef,
+ private toaster: ToasterService,
+ private scalar: ScalarClientApiService,
+ private integrationsApi: IntegrationsApiService) {
+ this.bot = dialog.context.bot;
+ this.roomId = dialog.context.roomId;
+
+ this.bot._isUpdating = false;
+ }
+
+ public toggle() {
+ let promise: Promise = Promise.resolve();
+ if (!this.bot._inRoom) {
+ promise = this.scalar.inviteUser(this.roomId, this.bot.userId);
+ } else promise = this.integrationsApi.removeIntegration(this.bot.category, this.bot.type, this.roomId);
+
+ this.bot._inRoom = !this.bot._inRoom;
+ this.bot._isUpdating = true;
+ promise.then(() => {
+ this.bot._isUpdating = false;
+ if (this.bot._inRoom) this.toaster.pop("success", this.bot.displayName + " was invited to the room");
+ else this.toaster.pop("success", this.bot.displayName + " was removed from the room");
+ }).catch(err => {
+ this.bot._inRoom = !this.bot._inRoom; // revert the status change
+ this.bot._isUpdating = false;
+ console.error(err);
+
+ let errorMessage = null;
+ if (err.json) errorMessage = err.json().error;
+ if (err.response && err.response.error) errorMessage = err.response.error.message;
+ if (!errorMessage) errorMessage = "Could not update integration status";
+
+ this.toaster.pop("error", errorMessage);
+ });
+ }
+}
\ No newline at end of file
diff --git a/web/app/riot/riot-home/home.component.ts b/web/app/riot/riot-home/home.component.ts
index 3e9bdb4..5f5b807 100644
--- a/web/app/riot/riot-home/home.component.ts
+++ b/web/app/riot/riot-home/home.component.ts
@@ -1,5 +1,4 @@
import { Component } from "@angular/core";
-import { ToasterService } from "angular2-toaster";
import { ActivatedRoute, Router } from "@angular/router";
import { ScalarClientApiService } from "../../shared/services/scalar/scalar-client-api.service";
import * as _ from "lodash";
@@ -9,6 +8,8 @@ import { IntegrationsRegistry } from "../../shared/registry/integrations.registr
import { SessionStorage } from "../../shared/SessionStorage";
import { AdminApiService } from "../../shared/services/admin/admin-api.service";
import { IntegrationsApiService } from "../../shared/services/integrations/integrations-api.service";
+import { Modal, overlayConfigFactory } from "ngx-modialog";
+import { ConfigSimpleBotComponent, SimpleBotConfigDialogContext } from "../../configs/simple-bot/simple-bot.component";
const CATEGORY_MAP = {
"Widgets": ["widget"],
@@ -39,8 +40,8 @@ export class RiotHomeComponent {
private scalar: ScalarClientApiService,
private integrationsApi: IntegrationsApiService,
private adminApi: AdminApiService,
- private toaster: ToasterService,
- private router: Router) {
+ private router: Router,
+ private modal: Modal) {
let params: any = this.activatedRoute.snapshot.queryParams;
this.requestedScreen = params.screen;
@@ -128,34 +129,13 @@ export class RiotHomeComponent {
console.log(this.userId + " is trying to modify " + integration.displayName);
if (integration.category === "bot") {
- // It's a bot
- const bot = integration;
- // TODO: "Are you sure?" dialog
+ this.modal.open(ConfigSimpleBotComponent, overlayConfigFactory({
+ bot: integration,
+ roomId: this.roomId,
- let promise: Promise = Promise.resolve();
- if (!integration._inRoom) {
- promise = this.scalar.inviteUser(this.roomId, bot.userId);
- } else promise = this.integrationsApi.removeIntegration(integration.category, integration.type, this.roomId);
- // We set this ahead of the promise for debouncing
-
- integration._inRoom = !integration._inRoom;
- integration._isUpdating = true;
- promise.then(() => {
- integration._isUpdating = false;
- if (integration._inRoom) this.toaster.pop("success", integration.displayName + " was invited to the room");
- else this.toaster.pop("success", integration.displayName + " was removed from the room");
- }).catch(err => {
- integration._inRoom = !integration._inRoom; // revert the status change
- integration._isUpdating = false;
- console.error(err);
-
- let errorMessage = null;
- if (err.json) errorMessage = err.json().error;
- if (err.response && err.response.error) errorMessage = err.response.error.message;
- if (!errorMessage) errorMessage = "Could not update integration status";
-
- this.toaster.pop("error", errorMessage);
- });
+ isBlocking: true,
+ size: 'lg',
+ }, SimpleBotConfigDialogContext));
} else {
console.log("Navigating to edit screen for " + integration.category + " " + integration.type);
this.router.navigate(['riot-app', integration.category, integration.type]);