From 66a92bd4cc4391dc46222d4bb09afa61b90653a4 Mon Sep 17 00:00:00 2001 From: meulta Date: Mon, 1 Feb 2016 11:09:02 +0100 Subject: [PATCH] Fixing for 0.2 --- DeploymentTools/build-docker-image.cmd | 4 +- Server/config.json | 6 +- Server/public/vorlon.dashboardManager.ts | 416 ----------------------- client samples/nodejs/package.json | 1 + 4 files changed, 6 insertions(+), 421 deletions(-) delete mode 100644 Server/public/vorlon.dashboardManager.ts diff --git a/DeploymentTools/build-docker-image.cmd b/DeploymentTools/build-docker-image.cmd index 73e20ce9..0930d409 100644 --- a/DeploymentTools/build-docker-image.cmd +++ b/DeploymentTools/build-docker-image.cmd @@ -10,13 +10,13 @@ IF "%5"=="" GOTO :usage SET DOCKER_HOST=%1 @ECHO "BUILD DOCKER IMAGE" -docker --tls --tlscacert="%2\ca.pem" --tlscert="%2\cert.pem" --tlskey="%2\key.pem" build -t jcorioland/vorlonjs:0.1 . +docker --tls --tlscacert="%2\ca.pem" --tlscert="%2\cert.pem" --tlskey="%2\key.pem" build -t jcorioland/vorlonjs:0.2 . @ECHO "LOG INTO DOCKER HUB" docker --tls --tlscacert="%2\ca.pem" --tlscert="%2\cert.pem" --tlskey="%2\key.pem" login --username="%3" --password="%4" --email="%5" https://index.docker.io/v1/ @ECHO "PUSH IMAGE INTO DOCKER HUB" -docker --tls --tlscacert="%2\ca.pem" --tlscert="%2\cert.pem" --tlskey="%2\key.pem" push jcorioland/vorlonjs:0.1 +docker --tls --tlscacert="%2\ca.pem" --tlscert="%2\cert.pem" --tlskey="%2\key.pem" push jcorioland/vorlonjs:0.2 @ECHO "LOG OUT FROM DOCKER HUB" docker --tls --tlscacert="%2\ca.pem" --tlscert="%2\cert.pem" --tlskey="%2\key.pem" logout diff --git a/Server/config.json b/Server/config.json index 4c6d151c..8d1b2bd0 100644 --- a/Server/config.json +++ b/Server/config.json @@ -17,12 +17,12 @@ "vorlonProxyURL": "", "plugins": [ - { "id": "CONSOLE", "name": "Interactive Console", "panel": "bottom", "foldername": "interactiveConsole", "enabled": true }, + { "id": "CONSOLE", "name": "Interactive Console", "panel": "bottom", "foldername": "interactiveConsole", "enabled": true, "nodeCompliant": true }, { "id": "DOM", "name": "Dom Explorer", "panel": "top", "foldername": "domExplorer", "enabled": true }, { "id": "MODERNIZR", "name": "Modernizr", "panel": "bottom", "foldername": "modernizrReport", "enabled": true }, - { "id": "OBJEXPLORER", "name": "Obj. Explorer", "panel": "top", "foldername": "objectExplorer", "enabled": true }, + { "id": "OBJEXPLORER", "name": "Obj. Explorer", "panel": "top", "foldername": "objectExplorer", "enabled": true, "nodeCompliant": true }, { "id": "WEBSTANDARDS", "name": "Best practices", "panel": "top", "foldername": "webstandards", "enabled": true }, - { "id": "XHRPANEL", "name": "XHR", "panel": "top", "foldername": "xhrPanel", "enabled": true }, + { "id": "XHRPANEL", "name": "XHR", "panel": "top", "foldername": "xhrPanel", "enabled": true, "nodeCompliant": true }, { "id": "NGINSPECTOR", "name": "Ng. Inspector", "panel": "top", "foldername": "ngInspector", "enabled": false }, { "id": "NETWORK", "name": "Network Monitor", "panel": "top", "foldername": "networkMonitor", "enabled": true }, { "id": "RESOURCES", "name": "Resources Explorer", "panel": "top", "foldername": "resourcesExplorer", "enabled": true }, diff --git a/Server/public/vorlon.dashboardManager.ts b/Server/public/vorlon.dashboardManager.ts deleted file mode 100644 index 0508420b..00000000 --- a/Server/public/vorlon.dashboardManager.ts +++ /dev/null @@ -1,416 +0,0 @@ -/// -/// -/// - -module VORLON { - declare var $: any; - declare var vorlonBaseURL: string; - - export class DashboardManager { - static CatalogUrl: string; - static ListenClientid: string; - static DisplayingClient: boolean; - static ListenClientDisplayid: string; - static SessionId: string; - static ClientList: any; - static PluginsLoaded: boolean; - static NoWindowMode: boolean; - - constructor(sessionid: string, listenClientid: string) { - //Dashboard session id - DashboardManager.SessionId = sessionid; - DashboardManager.PluginsLoaded = false; - DashboardManager.DisplayingClient = false; - //Client ID - DashboardManager.ListenClientid = listenClientid; - DashboardManager.ClientList = {}; - DashboardManager.StartListeningServer() - DashboardManager.GetClients(); - DashboardManager.CatalogUrl = vorlonBaseURL + "/getplugins/" + sessionid; - } - - public static StartListeningServer(clientid: string = ""): void{ - var getUrl = window.location; - var baseUrl = getUrl.protocol + "//" + getUrl.host; - VORLON.Core.StopListening(); - VORLON.Core.StartDashboardSide(baseUrl, DashboardManager.SessionId, clientid, DashboardManager.divMapper); - if(!VORLON.Core.Messenger.onAddClient && !VORLON.Core.Messenger.onAddClient){ - VORLON.Core.Messenger.onAddClient = DashboardManager.addClient; - VORLON.Core.Messenger.onRemoveClient = DashboardManager.removeClient; - } - - if(clientid !== ""){ - DashboardManager.DisplayingClient = true; - } - else { - DashboardManager.DisplayingClient = false; - } - } - - public static GetClients(): void { - let xhr = new XMLHttpRequest(); - - xhr.onreadystatechange = () => { - if (xhr.readyState === 4) { - if (xhr.status === 200) { - //Init ClientList Object - DashboardManager.ClientList = {}; - - //Loading client list - var clients = JSON.parse(xhr.responseText); - - //Test if the client to display is in the list - var contains = false; - if (clients && clients.length) { - for (var j = 0; j < clients.length; j++) { - if (clients[j].clientid === DashboardManager.ListenClientid) { - contains = true; - break; - } - } - } - - if (!contains) { - DashboardManager.ListenClientid = ""; - } - - //Get the client list placeholder - var divClientsListPane = document.getElementById("clientsListPaneContent"); - - //Create the new empty list - var clientlist = document.createElement("ul"); - clientlist.setAttribute("id", "clientsListPaneContentList") - divClientsListPane.appendChild(clientlist); - - //Show waiting logo - if(!contains || clients.length === 0){ - DashboardManager.DisplayWaitingLogo(false); - } - - for (var i = 0; i < clients.length; i++) { - var client = clients[i]; - DashboardManager.AddClientToList(client); - } - - if (contains) { - DashboardManager.loadPlugins(); - } - } - } - } - - xhr.open("GET", vorlonBaseURL + "/api/getclients/" + DashboardManager.SessionId); - xhr.send(); - } - - public static AddClientToList(client: any){ - var clientlist = document.getElementById("clientsListPaneContentList"); - - if (!DashboardManager.ListenClientid) { - DashboardManager.ListenClientid = client.clientid; - } - - var pluginlistelement = document.createElement("li"); - pluginlistelement.classList.add('client'); - pluginlistelement.id = client.clientid; - if (client.clientid === DashboardManager.ListenClientid) { - pluginlistelement.classList.add('active'); - } - - var clients = clientlist.children; - - //remove ghosts ones - for (var i = 0; i < clients.length; i++) { - var currentClient = (clients[i]); - if(DashboardManager.ClientList[currentClient.id].displayid === client.displayid){ - clientlist.removeChild(currentClient); - i--; - } - } - - if(clients.length === 0 || DashboardManager.ClientList[(clients[clients.length - 1]).id].displayid < client.displayid){ - clientlist.appendChild(pluginlistelement); - } - else if(clients.length === 1){ - var firstClient = clients[clients.length - 1]; - clientlist.insertBefore(pluginlistelement, firstClient); - } - else{ - for (var i = 0; i < clients.length - 1; i++) { - var currentClient = (clients[i]); - var nextClient = (clients[i+1]); - if(DashboardManager.ClientList[currentClient.id].displayid < client.displayid - && DashboardManager.ClientList[nextClient.id].displayid >= client.displayid){ - clientlist.insertBefore(pluginlistelement, nextClient); - break; - } - else if(i === 0){ - clientlist.insertBefore(pluginlistelement, currentClient); - } - } - } - - var pluginlistelementa = document.createElement("a"); - pluginlistelementa.textContent = " " + (client.identity ? client.identity : client.name) + " - " + client.displayid; - pluginlistelementa.setAttribute("href", vorlonBaseURL + "/dashboard/" + DashboardManager.SessionId + "/" + client.clientid); - pluginlistelement.appendChild(pluginlistelementa); - - DashboardManager.ClientList[client.clientid] = client; - } - - static ClientCount(): number{ - return Object.keys(DashboardManager.ClientList).length; - } - - static UpdateClientInfo(): void { - document.querySelector('[data-hook~=session-id]').textContent = DashboardManager.SessionId; - - if(DashboardManager.ClientList[DashboardManager.ListenClientid] != null){ - DashboardManager.ListenClientDisplayid = DashboardManager.ClientList[DashboardManager.ListenClientid].displayid; - DashboardManager.NoWindowMode = DashboardManager.ClientList[DashboardManager.ListenClientid].noWindow; - } - - document.querySelector('[data-hook~=client-id]').textContent = DashboardManager.ListenClientDisplayid; - } - - static HideWaitingLogo(): void { - //Stop bouncing and hide waiting page - var elt = document.querySelector('.dashboard-plugins-overlay'); - VORLON.Tools.AddClass(elt, 'hidden'); - - elt = document.querySelector('.waitLoader'); - VORLON.Tools.AddClass(elt, 'hidden'); - - elt = document.getElementById('reload'); - VORLON.Tools.RemoveClass(elt, 'hidden'); - } - - static DisplayWaitingLogo(displayWaiter: boolean): void{ - //Hide waiting page and let's not bounce the logo ! - var elt = document.querySelector('.dashboard-plugins-overlay'); - VORLON.Tools.RemoveClass(elt, 'hidden'); - if (displayWaiter) { - elt = document.querySelector('.waitLoader'); - VORLON.Tools.RemoveClass(elt, 'hidden'); - } - elt = document.getElementById('reload'); - VORLON.Tools.AddClass(elt, 'hidden'); - } - - public static loadPlugins(): void { - if(DashboardManager.ListenClientid === ""){ - return; - } - - if(this.PluginsLoaded){ - DashboardManager.StartListeningServer(DashboardManager.ListenClientid); - return; - } - - let xhr = new XMLHttpRequest(); - let divPluginsBottom = document.getElementById("pluginsPaneBottom"); - let divPluginsTop = document.getElementById("pluginsPaneTop"); - let divPluginBottomTabs = document.getElementById("pluginsListPaneBottom"); - let divPluginTopTabs = document.getElementById("pluginsListPaneTop"); - let coreLoaded = false; - - //Hide waiting page and let's bounce the logo ! - DashboardManager.DisplayWaitingLogo(true); - - xhr.onreadystatechange = () => { - if (xhr.readyState === 4) { - if (xhr.status === 200) { - var catalog; - try { - catalog = JSON.parse(xhr.responseText); - } catch (ex) { - throw new Error("The catalog JSON is not well-formed"); - } - - DashboardManager.UpdateClientInfo(); - - var pluginLoaded = 0; - var pluginstoload = 0; - - //Cleaning unwanted plugins - for(var i = 0; i < catalog.plugins.length; i++){ - var plugin = catalog.plugins[i]; - - if(plugin.enabled){ - if (DashboardManager.NoWindowMode) { - if (!plugin.nodeCompliant) { - continue; - } - } - pluginstoload ++; - } - } - - for (var i = 0; i < catalog.plugins.length; i++) { - var plugin = catalog.plugins[i]; - - if (!plugin.enabled){ - continue; - } - - if (DashboardManager.NoWindowMode) { - if (!plugin.nodeCompliant) { - continue; - } - } - - var existingLocation = document.querySelector('[data-plugin=' + plugin.id + ']'); - - if (!existingLocation) { - var pluginmaindiv = document.createElement('div'); - pluginmaindiv.classList.add('plugin'); - pluginmaindiv.classList.add('plugin-' + plugin.id.toLowerCase()); - pluginmaindiv.setAttribute('data-plugin', plugin.id); - - var plugintab = document.createElement('div'); - plugintab.classList.add('tab'); - plugintab.textContent = plugin.name; - plugintab.setAttribute('data-plugin-target', plugin.id); - - if (plugin.panel === "bottom") { - if (divPluginsBottom.children.length === 1) { - pluginmaindiv.classList.add("active"); - } - divPluginsBottom.appendChild(pluginmaindiv); - divPluginBottomTabs.appendChild(plugintab); - } - else { - if (divPluginsTop.children.length === 1) { - pluginmaindiv.classList.add("active"); - } - divPluginsTop.appendChild(pluginmaindiv); - divPluginTopTabs.appendChild(plugintab); - } - } - var pluginscript = document.createElement("script"); - pluginscript.setAttribute("src", vorlonBaseURL + "/vorlon/plugins/" + plugin.foldername + "/vorlon." + plugin.foldername + ".dashboard.min.js"); - - pluginscript.onload = (oError) => { - pluginLoaded++; - if (pluginLoaded >= pluginstoload) { - DashboardManager.StartListeningServer(DashboardManager.ListenClientid); - coreLoaded = true; - this.PluginsLoaded = true; - DashboardManager.HideWaitingLogo(); - } - }; - document.body.appendChild(pluginscript); - } - - var addPluginBtn = document.createElement('div'); - addPluginBtn.className = "tab"; - addPluginBtn.innerText = "+"; - divPluginTopTabs.appendChild(addPluginBtn); - addPluginBtn.addEventListener('click',() => { - window.open("http://www.vorlonjs.io/plugins", "_blank"); - }); - - var collaspseBtn = document.createElement('div'); - collaspseBtn.className = "fa fa-expand expandBtn"; - divPluginBottomTabs.appendChild(collaspseBtn); - collaspseBtn.addEventListener('click',() => { - divPluginsBottom.style.height = 'calc(100% - 58px)'; - divPluginsTop.style.height = '50px'; - $('.hsplitter', divPluginsTop.parentElement).css('top', '50px'); - }); - - var collaspseTopBtn = document.createElement('div'); - collaspseTopBtn.className = "fa fa-expand expandBtn"; - divPluginTopTabs.appendChild(collaspseTopBtn); - collaspseTopBtn.addEventListener('click',() => { - divPluginsBottom.style.height = '50px'; - divPluginsTop.style.height = 'calc(100% - 58px)'; - $('.hsplitter', divPluginsTop.parentElement).css('top', 'calc(100% - 58px)'); - }); - } - } - } - - xhr.open("GET", DashboardManager.CatalogUrl); - xhr.send(); - } - - public static divMapper(pluginId: string): HTMLDivElement { - let divId = pluginId + "div"; - return (document.getElementById(divId) || document.querySelector(`[data-plugin=${pluginId}]`)); - } - - public identify(): void { - Core.Messenger.sendRealtimeMessage("", { "_sessionid": DashboardManager.SessionId }, VORLON.RuntimeSide.Dashboard, "identify"); - } - - public static ResetDashboard(reload: boolean = true): void { - let sessionid = DashboardManager.SessionId; - let xhr = new XMLHttpRequest(); - xhr.onreadystatechange = () => { - if (xhr.readyState === 4) { - if (xhr.status === 200) { - if (reload) { - location.reload(); - } - } - } - } - - xhr.open("GET", vorlonBaseURL + "/api/reset/" + sessionid); - xhr.send(); - } - - public static ReloadClient(): void { - Core.Messenger.sendRealtimeMessage("", DashboardManager.ListenClientid, VORLON.RuntimeSide.Dashboard, "reload"); - } - - public static addClient(client: any): void { - DashboardManager.AddClientToList(client); - if(!DashboardManager.DisplayingClient){ - DashboardManager.loadPlugins(); - } - } - - public static removeClient(client: any): void { - let clientInList = document.getElementById(client.clientid); - if(clientInList){ - if(client.clientid === DashboardManager.ListenClientid){ - DashboardManager.ListenClientid = ""; - DashboardManager.StartListeningServer(); - DashboardManager.DisplayWaitingLogo(false); - } - - clientInList.parentElement.removeChild(clientInList); - DashboardManager.removeInClientList(client); - - if (DashboardManager.ClientCount() === 0) { - DashboardManager.ResetDashboard(false); - DashboardManager.DisplayingClient = false; - } - } - } - - public static removeInClientList(client: any): void{ - if(DashboardManager.ClientList[client.clientid] != null){ - delete DashboardManager.ClientList[client.clientid]; - } - } - - public static getSessionId(): void { - let xhr = new XMLHttpRequest(); - - xhr.onreadystatechange = () => { - if (xhr.readyState === 4) { - if (xhr.status === 200) { - var sessionId = xhr.responseText; - window.location.assign(vorlonBaseURL + "/dashboard/" + sessionId); - } - } - } - - xhr.open("GET", vorlonBaseURL + "/api/createsession"); - xhr.send(); - } - } -} diff --git a/client samples/nodejs/package.json b/client samples/nodejs/package.json index 355a3090..2b0ad1d4 100644 --- a/client samples/nodejs/package.json +++ b/client samples/nodejs/package.json @@ -11,6 +11,7 @@ "dependencies": { "socket.io": "^1.3.7", "socket.io-client": "^1.3.7", + "vorlon-node-wrapper": "0.0.2", "xmlhttprequest": "^1.8.0" } }