diff --git a/assets/js/components/calls/controller.js b/assets/js/components/calls/controller.js index 06b4ec5f..27defd4d 100644 --- a/assets/js/components/calls/controller.js +++ b/assets/js/components/calls/controller.js @@ -4,6 +4,11 @@ * @author Pierre Hubert */ +/** + * @type {Map} + */ +let OpenConversations = new Map(); + class CallsController { /** @@ -12,7 +17,14 @@ class CallsController { * @param {Conversation} conv Information about the target conversation */ static Open(conv) { - alert("Open call for conversation " + conv.ID); + if(OpenConversations.has(conv.ID)) + return; + + console.info("Open call for conversation " + conv.ID); + + // Create a new window for the conversation + const window = new CallWindow(conv); + OpenConversations.set(conv.ID, window) } } \ No newline at end of file diff --git a/assets/js/components/calls/window.js b/assets/js/components/calls/window.js new file mode 100644 index 00000000..f2abf0d9 --- /dev/null +++ b/assets/js/components/calls/window.js @@ -0,0 +1,55 @@ +/** + * Calls window + * + * @author Pierre Hubert + */ + + +class CallWindow { + + /** + * Create a new call window + * + * @param {Conversation} conv Information about the target conversation + */ + constructor(conv) { + this.construct(conv); + } + + async construct(conv) { + // Check if calls target exists or not + if(!byId("callsTarget")) + createElem2({ + appendTo: byId("wrapper"), + type: "div", + id: "callsTarget", + }) + + this.conv = conv; + + this.rootEl = createElem2({ + appendTo: byId("callsTarget"), + type: "div", + class: "call-window" + }) + + + // Construct head + const windowHead = createElem2({ + appendTo: this.rootEl, + type: "div", + class: "head", + innerHTML: "" + + await getConvName(conv) + + " " + }) + + // Close button + this.closeButton = createElem2({ + appendTo: windowHead.querySelector(".pull-right"), + type: "a", + innerHTML: "" + }) + } + +} \ No newline at end of file diff --git a/assets/js/jsconfig.json b/assets/js/jsconfig.json new file mode 100644 index 00000000..56705ead --- /dev/null +++ b/assets/js/jsconfig.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "target": "ES6", + "module": "commonjs" + } +} \ No newline at end of file diff --git a/assets/custom_ts/Utils.d.ts b/assets/js/typings/Utils.d.ts similarity index 100% rename from assets/custom_ts/Utils.d.ts rename to assets/js/typings/Utils.d.ts diff --git a/system/config/dev.config.php b/system/config/dev.config.php index 2463d16b..abea3dfd 100644 --- a/system/config/dev.config.php +++ b/system/config/dev.config.php @@ -457,6 +457,7 @@ class Dev { //Calls component "js/components/calls/controller.js", + "js/components/calls/window.js", // Web app component "js/components/webApp/interface.js",