From 3b0b0199ea8e6ed995fd004f166a28446ee996c5 Mon Sep 17 00:00:00 2001 From: Tim Robinson Date: Tue, 10 Feb 2015 11:45:13 +0000 Subject: [PATCH 1/9] Fix logging with vfs disconnections --- README.md | 3 ++- package.json | 2 +- plugins/c9.error/raygun.connect.js | 5 ----- plugins/c9.ide.plugins/debug.js | 10 ++++------ plugins/c9.ide.plugins/loader.js | 8 +++----- plugins/c9.vfs.server/vfs.connect.local.js | 4 +++- 6 files changed, 13 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 95a2bf6f..0a8bb88f 100644 --- a/README.md +++ b/README.md @@ -21,10 +21,11 @@ We have several documentation resources for you: SDK documentationhttp://cloud9-sdk.readme.io/v0.1/docs API documentationhttp://docs.c9.io/api User documentationhttp://docs.c9.io + User docs repohttps://github.com/c9/docs.c9.io Please joing the mailinglist to get support or give support to the growing community of plugin developers: -https://groups.google.com/forum/#!forum/cloud9-sdk +https://groups.google.com/forum/#!forum/cloud9-plugin-development #### Installation #### diff --git a/package.json b/package.json index ebb512b7..2719bccc 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "c9.ide.find": "#be3bca94b7", "c9.ide.find.infiles": "#462928475c", "c9.ide.find.replace": "#fe41fa768d", - "c9.ide.run.debug": "#9a05fadc55", + "c9.ide.run.debug": "#b734a2a47f", "c9.ide.ace.emmet": "#e5f1a92ac3", "c9.ide.ace.gotoline": "#4d1a93172c", "c9.ide.ace.keymaps": "#422e83553b", diff --git a/plugins/c9.error/raygun.connect.js b/plugins/c9.error/raygun.connect.js index 37848ec3..d2793f39 100644 --- a/plugins/c9.error/raygun.connect.js +++ b/plugins/c9.error/raygun.connect.js @@ -71,11 +71,6 @@ function plugin(options, imports, register) { email: req.user.email }; } - else if (req.session) { - customData.user = { - id: req.session.uid - }; - } raygunClient.send(err, customData, function() {}, { host: parsedUrl.hostname, diff --git a/plugins/c9.ide.plugins/debug.js b/plugins/c9.ide.plugins/debug.js index bf7dd44b..b251e6a7 100644 --- a/plugins/c9.ide.plugins/debug.js +++ b/plugins/c9.ide.plugins/debug.js @@ -139,12 +139,10 @@ define(function(require, exports, module) { watch("~/.c9/plugins/" + pluginPath); var cfg = options.plugins[path]; - var host = vfs.baseUrl + "/"; - var base = join(String(c9.projectId), - "plugins", auth.accessToken); - - cfg.packagePath = host + join(base, pluginPath.replace(/^plugins\//, "")); - cfg.staticPrefix = host + join(base, name); + cfg.packagePath = join(vfs.baseUrl, c9.projectId, "plugins", + auth.accessToken, pluginPath.replace(/^plugins\//, "")); + cfg.staticPrefix = join(vfs.baseUrl, c9.projectId, "plugins", + auth.accessToken, name); cfg.apikey = "0000000000000000000000000000="; config.push(cfg); diff --git a/plugins/c9.ide.plugins/loader.js b/plugins/c9.ide.plugins/loader.js index 45c5a41b..d6320a8c 100644 --- a/plugins/c9.ide.plugins/loader.js +++ b/plugins/c9.ide.plugins/loader.js @@ -66,11 +66,9 @@ define(function(require, exports, module) { names.push(name); var path = options.packagePath + ".js"; - var host = vfs.baseUrl + "/"; - var base = join(String(c9.projectId), "plugins", auth.accessToken); - - options.packagePath = host + join(base, path.replace(/^plugins\//, "")); - options.staticPrefix = host + join(base, name); + var base = join(vfs.baseUrl, c9.projectId, "plugins", auth.accessToken); + options.packagePath = join(base, path.replace(/^plugins\//, "")); + options.staticPrefix = join(base, name); if (!options.setup) { wait++; diff --git a/plugins/c9.vfs.server/vfs.connect.local.js b/plugins/c9.vfs.server/vfs.connect.local.js index 5189ccd0..e34ab4b2 100644 --- a/plugins/c9.vfs.server/vfs.connect.local.js +++ b/plugins/c9.vfs.server/vfs.connect.local.js @@ -1,12 +1,13 @@ define(function(require, exports, module) { "use strict"; - main.consumes = ["Plugin"]; + main.consumes = ["Plugin", "logger"]; main.provides = ["vfs.connect"]; return main; function main(options, imports, register) { var Plugin = imports.Plugin; + var logger = imports.logger; var Vfs = require("./vfs"); var localFs = require("vfs-local"); @@ -45,6 +46,7 @@ define(function(require, exports, module) { callback(null, new Vfs(localFs(vfsOptions), master, { debug: options.debug || false, + logger: logger, homeDir: vfsOptions.homeDir, projectDir: vfsOptions.projectDir, extendDirectory: options.extendDirectory, From dcc1e2b7b98ba3a41d697c88a6316eec8a416ed9 Mon Sep 17 00:00:00 2001 From: c9bot Date: Tue, 10 Feb 2015 12:01:15 +0000 Subject: [PATCH 2/9] c9-auto-bump 3.0.829 --- README.md | 3 ++- package.json | 2 +- plugins/c9.ide.plugins/debug.js | 10 ++++------ plugins/c9.ide.plugins/loader.js | 8 +++----- plugins/c9.vfs.server/vfs.js | 13 +------------ 5 files changed, 11 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 95a2bf6f..0a8bb88f 100644 --- a/README.md +++ b/README.md @@ -21,10 +21,11 @@ We have several documentation resources for you: SDK documentationhttp://cloud9-sdk.readme.io/v0.1/docs API documentationhttp://docs.c9.io/api User documentationhttp://docs.c9.io + User docs repohttps://github.com/c9/docs.c9.io Please joing the mailinglist to get support or give support to the growing community of plugin developers: -https://groups.google.com/forum/#!forum/cloud9-sdk +https://groups.google.com/forum/#!forum/cloud9-plugin-development #### Installation #### diff --git a/package.json b/package.json index ebb512b7..2719bccc 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "c9.ide.find": "#be3bca94b7", "c9.ide.find.infiles": "#462928475c", "c9.ide.find.replace": "#fe41fa768d", - "c9.ide.run.debug": "#9a05fadc55", + "c9.ide.run.debug": "#b734a2a47f", "c9.ide.ace.emmet": "#e5f1a92ac3", "c9.ide.ace.gotoline": "#4d1a93172c", "c9.ide.ace.keymaps": "#422e83553b", diff --git a/plugins/c9.ide.plugins/debug.js b/plugins/c9.ide.plugins/debug.js index bf7dd44b..b251e6a7 100644 --- a/plugins/c9.ide.plugins/debug.js +++ b/plugins/c9.ide.plugins/debug.js @@ -139,12 +139,10 @@ define(function(require, exports, module) { watch("~/.c9/plugins/" + pluginPath); var cfg = options.plugins[path]; - var host = vfs.baseUrl + "/"; - var base = join(String(c9.projectId), - "plugins", auth.accessToken); - - cfg.packagePath = host + join(base, pluginPath.replace(/^plugins\//, "")); - cfg.staticPrefix = host + join(base, name); + cfg.packagePath = join(vfs.baseUrl, c9.projectId, "plugins", + auth.accessToken, pluginPath.replace(/^plugins\//, "")); + cfg.staticPrefix = join(vfs.baseUrl, c9.projectId, "plugins", + auth.accessToken, name); cfg.apikey = "0000000000000000000000000000="; config.push(cfg); diff --git a/plugins/c9.ide.plugins/loader.js b/plugins/c9.ide.plugins/loader.js index 45c5a41b..d6320a8c 100644 --- a/plugins/c9.ide.plugins/loader.js +++ b/plugins/c9.ide.plugins/loader.js @@ -66,11 +66,9 @@ define(function(require, exports, module) { names.push(name); var path = options.packagePath + ".js"; - var host = vfs.baseUrl + "/"; - var base = join(String(c9.projectId), "plugins", auth.accessToken); - - options.packagePath = host + join(base, path.replace(/^plugins\//, "")); - options.staticPrefix = host + join(base, name); + var base = join(vfs.baseUrl, c9.projectId, "plugins", auth.accessToken); + options.packagePath = join(base, path.replace(/^plugins\//, "")); + options.staticPrefix = join(base, name); if (!options.setup) { wait++; diff --git a/plugins/c9.vfs.server/vfs.js b/plugins/c9.vfs.server/vfs.js index d75a8adc..9562eef9 100644 --- a/plugins/c9.vfs.server/vfs.js +++ b/plugins/c9.vfs.server/vfs.js @@ -19,11 +19,9 @@ function Vfs(vfs, master, options) { this.vfs = vfs; this.master = master; this.debug = options.debug || false; - this.logger = options.logger || {log: function(){}}; this.readonly = options.readonly || false; this.public = options.public || false; this.vfsOptions = options.vfsOptions || {}; - this.pid = this.vfsOptions.pid; var extendToken = options.extendToken; this.homeDir = options.homeDir; @@ -169,12 +167,6 @@ Vfs.prototype._createEngine = function(vfs, options) { that.socket.disconnect(); that.socket = socket; - socket.on('close', function (reason, description) { - var logMetadata = {collab: options.collab, reason: reason, description: description, id: that.id, sid: socket.id, pid: that.pid}; - console.log("Socket closed", logMetadata); - logMetadata.message = "Socket closed"; - that.logger.log(logMetadata); - }); var transport = new smith.EngineIoTransport(socket, true); var worker = new VfsWorker(vfs); @@ -193,10 +185,7 @@ Vfs.prototype._createEngine = function(vfs, options) { } worker.on("disconnect", function() { - var logMetadata = {collab: options.collab, id: that.id, sid: socket.id, pid: that.pid}; - console.log("VFS socket disconnect:", logMetadata); - logMetadata.message = "VFS socket disconnect"; - that.logger.log(logMetadata); + console.log("VFS socket disconnect:", options.collab, that.id, socket.id); if (options.collab) { if (collabApi) return disposeCollabClient(); From d7ddc864273fe7e94a94422123602577cd639fca Mon Sep 17 00:00:00 2001 From: Tim Robinson Date: Tue, 10 Feb 2015 15:48:20 +0000 Subject: [PATCH 3/9] Listen on socket.socket.socket --- plugins/c9.vfs.server/vfs.js | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/plugins/c9.vfs.server/vfs.js b/plugins/c9.vfs.server/vfs.js index d75a8adc..a6416cc2 100644 --- a/plugins/c9.vfs.server/vfs.js +++ b/plugins/c9.vfs.server/vfs.js @@ -169,10 +169,27 @@ Vfs.prototype._createEngine = function(vfs, options) { that.socket.disconnect(); that.socket = socket; - socket.on('close', function (reason, description) { - var logMetadata = {collab: options.collab, reason: reason, description: description, id: that.id, sid: socket.id, pid: that.pid}; - console.log("Socket closed", logMetadata); - logMetadata.message = "Socket closed"; + if (socket.socket) { // socket is the reliablesocket, socket.socket is the reconnectsocket which has engineio's socket inside it + var listenEIOSocket = function (eioSocket) { + if (!eioSocket) return; + eioSocket.on("close", function (reason, description) { + var logMetadata = {collab: options.collab, reason: reason, description: description, id: that.id, sid: socket.id, pid: that.pid}; + console.log("Socket closed", logMetadata); + logMetadata.message = "Socket closed"; + that.logger.log(logMetadata); + }); + }; + socket.socket.on('away', function() { + listenEIOSocket(socket.socket.socket); + }); + socket.socket.on('back', function() { + listenEIOSocket(socket.socket.socket); + }); + } + socket.on('disconnect', function (err) { + var logMetadata = {collab: options.collab, ere: err, id: that.id, sid: socket.id, pid: that.pid}; + console.log("Socket disconnected", logMetadata); + logMetadata.message = "Socket disconnected"; that.logger.log(logMetadata); }); From 227f1b7a57d2131b95d24164ed126cd51a99081f Mon Sep 17 00:00:00 2001 From: Tim Robinson Date: Tue, 10 Feb 2015 15:51:27 +0000 Subject: [PATCH 4/9] Fix comment --- plugins/c9.vfs.server/vfs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/c9.vfs.server/vfs.js b/plugins/c9.vfs.server/vfs.js index a6416cc2..5a6bfd63 100644 --- a/plugins/c9.vfs.server/vfs.js +++ b/plugins/c9.vfs.server/vfs.js @@ -169,7 +169,7 @@ Vfs.prototype._createEngine = function(vfs, options) { that.socket.disconnect(); that.socket = socket; - if (socket.socket) { // socket is the reliablesocket, socket.socket is the reconnectsocket which has engineio's socket inside it + if (socket.socket) { // socket is the reliablesocket, socket.socket is the reconnectsocket, socket.socket.socket is engineio's socket var listenEIOSocket = function (eioSocket) { if (!eioSocket) return; eioSocket.on("close", function (reason, description) { From 0c99cd47b2d8a244987f50f180f090c7c7377131 Mon Sep 17 00:00:00 2001 From: Tim Robinson Date: Tue, 10 Feb 2015 16:10:39 +0000 Subject: [PATCH 5/9] Adding more documentation and ensure there is only one socket.close listener --- plugins/c9.vfs.server/vfs.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/plugins/c9.vfs.server/vfs.js b/plugins/c9.vfs.server/vfs.js index 5a6bfd63..d5f56352 100644 --- a/plugins/c9.vfs.server/vfs.js +++ b/plugins/c9.vfs.server/vfs.js @@ -154,6 +154,7 @@ Vfs.prototype._createEngine = function(vfs, options) { }); this.keepAliveTimer = null; + var listeningForEIOSocketClose = false; this.workers = 0; @@ -169,21 +170,29 @@ Vfs.prototype._createEngine = function(vfs, options) { that.socket.disconnect(); that.socket = socket; - if (socket.socket) { // socket is the reliablesocket, socket.socket is the reconnectsocket, socket.socket.socket is engineio's socket - var listenEIOSocket = function (eioSocket) { - if (!eioSocket) return; - eioSocket.on("close", function (reason, description) { + /* - socket is the reliablesocket, + - socket.socket is the reconnectsocket, + - socket.socket.socket is engineio's socket */ + if (socket.socket) { + /* Add listener to core Engine.io socket used for user communication + to track and log all reasons causing it to close so when users + complain about disconnects we can investigate what's causing them */ + var listenForEIOSocketClose = function (eioSocket) { + if (!eioSocket || listeningForEIOSocketClose) return; + eioSocket.once("close", function (reason, description) { var logMetadata = {collab: options.collab, reason: reason, description: description, id: that.id, sid: socket.id, pid: that.pid}; console.log("Socket closed", logMetadata); logMetadata.message = "Socket closed"; that.logger.log(logMetadata); + listeningForEIOSocketClose = false; }); + listeningForEIOSocketClose = true; }; - socket.socket.on('away', function() { - listenEIOSocket(socket.socket.socket); + socket.socket.once('away', function() { + listenForEIOSocketClose(socket.socket.socket); }); - socket.socket.on('back', function() { - listenEIOSocket(socket.socket.socket); + socket.socket.once('back', function() { + listenForEIOSocketClose(socket.socket.socket); }); } socket.on('disconnect', function (err) { From 439c0393d4fcf17f519adf0872088ae53b98fcc0 Mon Sep 17 00:00:00 2001 From: Tim Robinson Date: Tue, 10 Feb 2015 18:47:09 +0000 Subject: [PATCH 6/9] Small wording fixes --- plugins/c9.vfs.server/vfs.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/plugins/c9.vfs.server/vfs.js b/plugins/c9.vfs.server/vfs.js index d5f56352..912016a9 100644 --- a/plugins/c9.vfs.server/vfs.js +++ b/plugins/c9.vfs.server/vfs.js @@ -180,9 +180,8 @@ Vfs.prototype._createEngine = function(vfs, options) { var listenForEIOSocketClose = function (eioSocket) { if (!eioSocket || listeningForEIOSocketClose) return; eioSocket.once("close", function (reason, description) { - var logMetadata = {collab: options.collab, reason: reason, description: description, id: that.id, sid: socket.id, pid: that.pid}; - console.log("Socket closed", logMetadata); - logMetadata.message = "Socket closed"; + var logMetadata = {message: "Socket closed", collab: options.collab, reason: reason, description: description, id: that.id, sid: socket.id, pid: that.pid}; + console.log(logMetadata); that.logger.log(logMetadata); listeningForEIOSocketClose = false; }); @@ -196,9 +195,8 @@ Vfs.prototype._createEngine = function(vfs, options) { }); } socket.on('disconnect', function (err) { - var logMetadata = {collab: options.collab, ere: err, id: that.id, sid: socket.id, pid: that.pid}; - console.log("Socket disconnected", logMetadata); - logMetadata.message = "Socket disconnected"; + var logMetadata = {message: "Socket disconnected", collab: options.collab, err: err, id: that.id, sid: socket.id, pid: that.pid}; + console.log(logMetadata); that.logger.log(logMetadata); }); From e985b959437e615efa25fa9e1f540e91a4f09be7 Mon Sep 17 00:00:00 2001 From: Nikolai Onken Date: Wed, 11 Feb 2015 11:39:18 +0100 Subject: [PATCH 7/9] Revert "Created new offline indicator loosely based on slack" --- node_modules/kaefer/lib/client.js | 26 ++- plugins/c9.core/c9.js | 4 +- plugins/c9.ide.dialog.common/error.css | 37 +--- plugins/c9.ide.dialog.common/error.js | 165 ++---------------- plugins/c9.ide.layout.classic/layout.js | 46 +++-- .../themes/default-dark-gray.less | 6 - .../themes/default-dark.less | 6 - .../themes/default-flat-light.less | 6 - .../themes/default-light-gray.less | 6 - .../themes/default-light.less | 6 - plugins/c9.vfs.client/vfs_client.js | 24 +-- 11 files changed, 60 insertions(+), 272 deletions(-) diff --git a/node_modules/kaefer/lib/client.js b/node_modules/kaefer/lib/client.js index 3f6bd7f0..5586f63d 100644 --- a/node_modules/kaefer/lib/client.js +++ b/node_modules/kaefer/lib/client.js @@ -86,29 +86,27 @@ var connectClient = module.exports = function(connectEio, options) { }); } - var timer; - function reconnect(delay) { - if (isReconnecting && typeof delay !== "number") + function reconnect() { + if (isReconnecting) return; reconnectSocket.setSocket(null); connectAttempts += 1; - if (typeof delay !== "number") { - if (connectAttempts < 10) { - delay = 250; - } - else { - delay = Math.min(60000, 250 * Math.pow(2, connectAttempts - 10)); - } + var delay = 250; + if (connectAttempts > 10) { + delay = 10 * 1000; + } + else if (connectAttempts > 5) { + delay = 5 * 1000; + } + else if (connectAttempts > 3) { + delay = 1 * 1000; } isReconnecting = true; console.log("Schedule re-connect in: " + delay); - socket.emit("reconnectDelay", { delay: delay }); - - clearTimeout(timer); - timer = setTimeout(function() { + setTimeout(function() { isReconnecting = false; connect(); }, delay); diff --git a/plugins/c9.core/c9.js b/plugins/c9.core/c9.js index 6e7f9b1c..7f0947d2 100644 --- a/plugins/c9.core/c9.js +++ b/plugins/c9.core/c9.js @@ -57,7 +57,7 @@ define(function(require, module, exports) { }, plugin); vfs.on("disconnect", function(reason) { - setStatus(state & ~STORAGE & ~PROCESS & ~NETWORK); + setStatus(status & ~STORAGE & ~PROCESS & ~NETWORK); emit("disconnect"); }, plugin); @@ -67,7 +67,7 @@ define(function(require, module, exports) { }, plugin); vfs.on("error", function(message) { - setStatus(state & ~STORAGE & ~PROCESS); + setStatus(status & ~STORAGE & ~PROCESS); // TODO: Don't display all errors? if (emit("showerrormessage", message) !== false) { console.error( diff --git a/plugins/c9.ide.dialog.common/error.css b/plugins/c9.ide.dialog.common/error.css index 96f0a115..f3d14fb7 100644 --- a/plugins/c9.ide.dialog.common/error.css +++ b/plugins/c9.ide.dialog.common/error.css @@ -1,23 +1,18 @@ -.errorlabel, .disconnectlabel{ +.errorlabel{ position: absolute; left: 0; right: 0; top: 0; z-index: 10000000; - /*text-align: center;*/ + text-align: center; pointer-events: none; .font-smoothing(@error-font-smoothing); } -.errorlabel.anim, .disconnectlabel.anim{ +.errorlabel.anim{ transition: top 0.2s; -moz-transition: top 0.2s; /* Gecko */ -webkit-transition: top 0.2s; /* Safari */ } -.errorlabel.fade-in{ - transition: opacity 0.2s; - -moz-transition: opacity 0.2s; /* Gecko */ - -webkit-transition: opacity 0.2s; /* Safari */ -} .errorlabel div{ background: @error-background; padding: @error-padding; @@ -31,9 +26,6 @@ max-width: 100%; pointer-events: auto; } -.errorlabel.fade-in div{ - border-radius: 3px; -} .errorlabel u.close{ .image-2x("@{image-path}/@{error-close-image}", 42px, 28px); background-position: @error-close-idle-position; @@ -41,7 +33,7 @@ height: 14px; position: absolute; right: 8px; - top: 6px; + top: 8px; cursor: pointer; } .errorlabel u.close:hover{ @@ -53,25 +45,4 @@ .errorlabel div span{ border-bottom: 1px dotted rgb(255, 174, 174); cursor: help; -} - -.disconnectlabel{ - z-index: 10000001; -} -.disconnectlabel div{ - background: @disconnect-background; - padding: @disconnect-padding; - color: @disconnect-color; - border-radius: 0 0 3px 3px; - box-shadow: @disconnect-box-shadow; - line-height: 1.4; - display: inline-block; - position: relative; - word-wrap: break-word; - text-align: center; - width: 300px; - pointer-events: auto; -} -.disconnectlabel u{ - cursor: pointer; } \ No newline at end of file diff --git a/plugins/c9.ide.dialog.common/error.js b/plugins/c9.ide.dialog.common/error.js index 3d28bb20..3642818a 100644 --- a/plugins/c9.ide.dialog.common/error.js +++ b/plugins/c9.ide.dialog.common/error.js @@ -12,72 +12,22 @@ define(function(require, exports, module) { /***** Initialization *****/ var plugin = new Plugin("Ajax.org", main.consumes); - var emit = plugin.getEmitter(); var topPx = 0; + var error, hideTimeout; var lastCookie = 0; - var offset = 0; - var error, hideTimeout, disconnect; - - var DISCONNECTDELAY = 1000; + var loaded = false; function load() { + if (loaded) return false; + loaded = true; + ui.insertCss(require("text!./error.css"), options.staticPrefix, plugin); } - function initDisconnectEvents(vfs){ - var timer; - - vfs.once("connect", function(){ - vfs.connection.on("reconnectDelay", function(e){ - clearInterval(timer); - - var delay = e.delay; - if (delay > 999) { - timer = setInterval(function(){ - if (vfs.connected) - return clearInterval(timer); - - delay -= 1000; - showDisconnect({ delay: delay }); - - if (delay <= 0) - clearInterval(timer); - }, 1000); - } - - showDisconnect(e); - }); - }); - vfs.on("connect", function(){ - hideDisconnect(); - }); - vfs.on("disconnect", function(){ - // setTimeout(function(){ - // showDisconnect(); - // }, DISCONNECTDELAY); - }); - vfs.on("connecting", function(){ - showDisconnect({ connecting: true }); - }); - plugin.on("retryConnect", function(){ - vfs.connection.reconnect(0); - }); - } - /***** Methods *****/ - function getCenterX(){ - var bartools = document.querySelector(".bartools"); - if (!bartools) return 0; // For testing - - var b1 = bartools.getBoundingClientRect(); - var b2 = bartools.nextSibling.getBoundingClientRect(); - - return b1.left + b1.width + ((b2.left - b1.left - b1.width)/2); - } - function show(message, timeout) { // Error message container if (!error) { @@ -113,21 +63,18 @@ define(function(require, exports, module) { error.innerHTML = "
" + messageString + "
"; - error.style.opacity = 0; error.style.display = "block"; - error.style.top = (offset - (error.offsetHeight - 10 + topPx)) + "px"; - error.firstChild.style.marginLeft = Math.max(0, (getCenterX() - (error.firstChild.offsetWidth / 2))) + "px"; + error.style.top = (-1 * error.offsetHeight - 10 + topPx) + "px"; // Start anim setTimeout(function() { - error.className = "errorlabel anim " + (offset > 0 ? "fade-in" : ""); - error.style.top = (offset + topPx) + "px"; - error.style.opacity = 1; + error.className = "errorlabel anim"; + error.style.top = topPx + "px"; }, 10); clearTimeout(hideTimeout); if (!(timeout < 0)) - hideTimeout = setTimeout(hide, timeout || 15000); + setTimeout(hide, timeout || 15000); }); return ++lastCookie; @@ -142,96 +89,19 @@ define(function(require, exports, module) { if (!error || error.style.display === "none") return callback && callback(); - error.className = "errorlabel anim " + (offset > 0 ? "fade-in" : ""); - if (offset > 0) - error.style.opacity = 0; - else - error.style.top = (-1 * error.offsetHeight - 10 + topPx) + "px"; - + error.className = "errorlabel anim"; + error.style.top = (-1 * error.offsetHeight - 10 + topPx) + "px"; setTimeout(function() { error.style.display = "none"; callback && callback(); }, 220); } - function showDisconnect(options){ - // Error message container - if (!disconnect) { - disconnect = document.body.appendChild(document.createElement("div")); - disconnect.className = "disconnectlabel"; - disconnect.addEventListener("mouseup", function(e) { - if (e.target.tagName == "U") - emit("retryConnect"); - }); - } - - var message; - if (!options || options.delay < 1000 || options.connecting) - message = "Reconnecting..."; - else if (options.delay) - message = "Reconnecting in " + Math.ceil(options.delay/1000) - + " seconds." - + (options.delay < 2001 ? "" : " Retry Now."); - else - message = "Reconnecting..."; - - disconnect.innerHTML = "
" + message + "
"; - disconnect.firstChild.style.marginLeft - = Math.max(0, (getCenterX() - 150)) + "px"; - - if (disconnect.style.display == "block") - return; - - disconnect.style.display = "block"; - disconnect.style.top = (-1 * disconnect.offsetHeight - 10 + topPx) + "px"; - - // Start anim - setTimeout(function() { - disconnect.className = "disconnectlabel anim"; - disconnect.style.top = (topPx) + "px"; - }, 10); - - offset = 28; - - // document.querySelector(".c9-offline").addEventListener("click", function(){ - // alert("Offline Notication", "You are currently offline.", - // "This indicator notifies you that Cloud9 is unable to reach " - // + "the server. This usually happens because you are offline. " - // + "Some features will be disabled until the " - // + "network connection becomes available again. " - // + "This notication could also show when the server is " - // + "unreachable due to other reasons. Sometimes a refresh of " - // + "the tab will fix an issue. Please e-mail " - // + "support@c9.io for further problem resolution."); - // }, false); - } - - function hideDisconnect(cookie, callback) { - if (!disconnect || disconnect.style.display === "none") - return callback && callback(); - - disconnect.className = "disconnectlabel anim"; - disconnect.style.top = (-1 * disconnect.offsetHeight - 10 + topPx) + "px"; - setTimeout(function() { - disconnect.style.display = "none"; - callback && callback(); - }, 220); - - offset = 0; - } - /***** Lifecycle *****/ plugin.on("load", function() { load(); }); - plugin.on("unload", function() { - topPx = 0; - lastCookie = 0; - offset = 0; - error = null; - hideTimeout = null; - }); /***** Register and define API *****/ @@ -246,19 +116,6 @@ define(function(require, exports, module) { get top(){ return topPx; }, set top(value){ topPx = value; }, - get vfs(){ throw new Error("Permission Denied"); }, - set vfs(v){ initDisconnectEvents(v); }, - - /** - * - */ - showDisconnect: showDisconnect, - - /** - * - */ - hideDisconnect: hideDisconnect, - /** * Displays an error message in the main error reporting UI. * @param {String} message The message to display. diff --git a/plugins/c9.ide.layout.classic/layout.js b/plugins/c9.ide.layout.classic/layout.js index 5d3aee91..c3124ceb 100644 --- a/plugins/c9.ide.layout.classic/layout.js +++ b/plugins/c9.ide.layout.classic/layout.js @@ -8,11 +8,11 @@ define(function(require, exports, module) { function main(options, imports, register) { var c9 = imports.c9; + var alert = imports["dialog.alert"].show; var Plugin = imports.Plugin; + var question = imports["dialog.question"]; var settings = imports.settings; var commands = imports.commands; - var alert = imports["dialog.alert"].show; - var question = imports["dialog.question"]; var preload = imports["layout.preload"]; var anims = imports.anims; var ui = imports.ui; @@ -126,6 +126,33 @@ define(function(require, exports, module) { img.src = options.staticPrefix + "/images/" + p; }); + var hideOffline; + c9.on("stateChange", function(e) { + // Online + if (e.state & c9.NETWORK && e.state & c9.STORAGE) { + hideOffline && hideOffline(); + } + // Offline + else if (!hideOffline || hideOffline.hasClosed()) { + hideOffline = notify("
No internet " + + "connection detected. Cloud9 will automatically try to " + + "reconnect when it detects an internet connection." + + "
", true, 1000); + + document.querySelector(".c9-offline").addEventListener("click", function(){ + alert("Offline Notication", "You are currently offline.", + "This indicator notifies you that Cloud9 is unable to reach " + + "the server. This usually happens because you are offline. " + + "Some features will be disabled until the " + + "network connection becomes available again. " + + "This notication could also show when the server is " + + "unreachable due to other reasons. Sometimes a refresh of " + + "the tab will fix an issue. Please e-mail " + + "support@c9.io for further problem resolution."); + }, false); + } + }); + window.addEventListener("resize", resize, false); window.addEventListener("focus", resize, false); @@ -515,21 +542,6 @@ define(function(require, exports, module) { window.removeEventListener("resize", resize); if (removeTheme) removeTheme(); - - logobar = null; - removeTheme = null; - theme = null; - c9console = null; - menus = null; - tabManager = null; - panels = null; - userLayout = null; - ignoreTheme = null; - notify = null; - hideFlagUpdate = null; - activeFindArea = null; - defaultFindArea = null; - activating = null; }); /***** Register and define API *****/ diff --git a/plugins/c9.ide.layout.classic/themes/default-dark-gray.less b/plugins/c9.ide.layout.classic/themes/default-dark-gray.less index f78fd8a0..6c78b067 100644 --- a/plugins/c9.ide.layout.classic/themes/default-dark-gray.less +++ b/plugins/c9.ide.layout.classic/themes/default-dark-gray.less @@ -632,12 +632,6 @@ @error-close-hover-position: -14px -14px; @error-close-active-position: -28px -14px; -// Disconnect Dialog -@disconnect-background: #D8B112; -@disconnect-color: @error-color; -@disconnect-padding: @error-padding; -@disconnect-box-shadow: @error-box-shadow; - // Offline Dialog @offline-gradient: linear-gradient(top, rgb(60, 112, 153) 0%, rgb(61, 97, 126) 100%); @offline-border-bottom: 1px solid rgba(0, 0, 0, 0.61); diff --git a/plugins/c9.ide.layout.classic/themes/default-dark.less b/plugins/c9.ide.layout.classic/themes/default-dark.less index 26707588..fd62d0f3 100644 --- a/plugins/c9.ide.layout.classic/themes/default-dark.less +++ b/plugins/c9.ide.layout.classic/themes/default-dark.less @@ -632,12 +632,6 @@ @error-close-hover-position: -14px -14px; @error-close-active-position: -28px -14px; -// Disconnect Dialog -@disconnect-background: #D8B112; -@disconnect-color: @error-color; -@disconnect-padding: @error-padding; -@disconnect-box-shadow: @error-box-shadow; - // Offline Dialog @offline-gradient: linear-gradient(top, rgb(60, 112, 153) 0%, rgb(61, 97, 126) 100%); @offline-border-bottom: 1px solid rgba(0, 0, 0, 0.61); diff --git a/plugins/c9.ide.layout.classic/themes/default-flat-light.less b/plugins/c9.ide.layout.classic/themes/default-flat-light.less index 6425061b..b23ca74b 100644 --- a/plugins/c9.ide.layout.classic/themes/default-flat-light.less +++ b/plugins/c9.ide.layout.classic/themes/default-flat-light.less @@ -632,12 +632,6 @@ @error-close-hover-position: -14px -14px; @error-close-active-position: -28px -14px; -// Disconnect Dialog -@disconnect-background: #D8B112; -@disconnect-color: @error-color; -@disconnect-padding: @error-padding; -@disconnect-box-shadow: @error-box-shadow; - // Offline Dialog @offline-gradient: linear-gradient(top, #3d9ac4 0%, #3d9ac4 100%); @offline-border-bottom: 0; diff --git a/plugins/c9.ide.layout.classic/themes/default-light-gray.less b/plugins/c9.ide.layout.classic/themes/default-light-gray.less index ebf4895d..39472337 100644 --- a/plugins/c9.ide.layout.classic/themes/default-light-gray.less +++ b/plugins/c9.ide.layout.classic/themes/default-light-gray.less @@ -632,12 +632,6 @@ @error-close-hover-position: -14px -14px; @error-close-active-position: -28px -14px; -// Disconnect Dialog -@disconnect-background: #D8B112; -@disconnect-color: @error-color; -@disconnect-padding: @error-padding; -@disconnect-box-shadow: @error-box-shadow; - // Offline Dialog @offline-gradient: linear-gradient(top, rgb(60, 112, 153) 0%, rgb(61, 97, 126) 100%); @offline-border-bottom: 1px solid rgba(0, 0, 0, 0.61); diff --git a/plugins/c9.ide.layout.classic/themes/default-light.less b/plugins/c9.ide.layout.classic/themes/default-light.less index 982b7177..48928aee 100644 --- a/plugins/c9.ide.layout.classic/themes/default-light.less +++ b/plugins/c9.ide.layout.classic/themes/default-light.less @@ -632,12 +632,6 @@ @error-close-hover-position: -14px -14px; @error-close-active-position: -28px -14px; -// Disconnect Dialog -@disconnect-background: #D8B112; -@disconnect-color: @error-color; -@disconnect-padding: @error-padding; -@disconnect-box-shadow: @error-box-shadow; - // Offline Dialog @offline-gradient: linear-gradient(top, rgb(60, 112, 153) 0%, rgb(61, 97, 126) 100%); @offline-border-bottom: 1px solid rgba(0, 0, 0, 0.61); diff --git a/plugins/c9.vfs.client/vfs_client.js b/plugins/c9.vfs.client/vfs_client.js index 266974e7..22a5916f 100644 --- a/plugins/c9.vfs.client/vfs_client.js +++ b/plugins/c9.vfs.client/vfs_client.js @@ -30,9 +30,8 @@ define(function(require, exports, module) { var Plugin = imports.Plugin; var auth = imports.auth; var vfsEndpoint = imports["vfs.endpoint"]; - var errorDialog = imports["dialog.error"]; - var showError = errorDialog.show; - var hideError = errorDialog.hide; + var showError = imports["dialog.error"].show; + var hideError = imports["dialog.error"].hide; var showAlert = imports["dialog.alert"].show; var eio = require("engine.io"); @@ -50,9 +49,6 @@ define(function(require, exports, module) { var plugin = new Plugin("Ajax.org", main.consumes); var emit = plugin.getEmitter(); - // Give reference to vfs to plugin - errorDialog.vfs = plugin; - var buffer = []; var installChecked = false; var withInstall = options.withInstall; @@ -334,22 +330,6 @@ define(function(require, exports, module) { }); plugin.on("unload", function(){ loaded = false; - - id = null; - buffer = []; - installChecked = false; - region = null; - vfsBaseUrl = null; - homeUrl = null; - projectUrl = null; - pingUrl = null; - serviceUrl = null; - eioOptions = null; - consumer = null; - vfs = null; - showErrorTimer = null; - showErrorTimerMessage = null; - lastError = null; }); /***** Register and define API *****/ From 2587c41e804e1603452b0f3b558faeed93f98c8f Mon Sep 17 00:00:00 2001 From: Nikolai Onken Date: Wed, 11 Feb 2015 16:21:08 +0100 Subject: [PATCH 8/9] Revert "Revert "Created new offline indicator loosely based on slack"" --- node_modules/kaefer/lib/client.js | 26 +-- plugins/c9.core/c9.js | 4 +- plugins/c9.ide.dialog.common/error.css | 37 +++- plugins/c9.ide.dialog.common/error.js | 165 ++++++++++++++++-- plugins/c9.ide.layout.classic/layout.js | 46 ++--- .../themes/default-dark-gray.less | 6 + .../themes/default-dark.less | 6 + .../themes/default-flat-light.less | 6 + .../themes/default-light-gray.less | 6 + .../themes/default-light.less | 6 + plugins/c9.vfs.client/vfs_client.js | 24 ++- 11 files changed, 272 insertions(+), 60 deletions(-) diff --git a/node_modules/kaefer/lib/client.js b/node_modules/kaefer/lib/client.js index 5586f63d..3f6bd7f0 100644 --- a/node_modules/kaefer/lib/client.js +++ b/node_modules/kaefer/lib/client.js @@ -86,27 +86,29 @@ var connectClient = module.exports = function(connectEio, options) { }); } - function reconnect() { - if (isReconnecting) + var timer; + function reconnect(delay) { + if (isReconnecting && typeof delay !== "number") return; reconnectSocket.setSocket(null); connectAttempts += 1; - var delay = 250; - if (connectAttempts > 10) { - delay = 10 * 1000; - } - else if (connectAttempts > 5) { - delay = 5 * 1000; - } - else if (connectAttempts > 3) { - delay = 1 * 1000; + if (typeof delay !== "number") { + if (connectAttempts < 10) { + delay = 250; + } + else { + delay = Math.min(60000, 250 * Math.pow(2, connectAttempts - 10)); + } } isReconnecting = true; console.log("Schedule re-connect in: " + delay); - setTimeout(function() { + socket.emit("reconnectDelay", { delay: delay }); + + clearTimeout(timer); + timer = setTimeout(function() { isReconnecting = false; connect(); }, delay); diff --git a/plugins/c9.core/c9.js b/plugins/c9.core/c9.js index 7f0947d2..6e7f9b1c 100644 --- a/plugins/c9.core/c9.js +++ b/plugins/c9.core/c9.js @@ -57,7 +57,7 @@ define(function(require, module, exports) { }, plugin); vfs.on("disconnect", function(reason) { - setStatus(status & ~STORAGE & ~PROCESS & ~NETWORK); + setStatus(state & ~STORAGE & ~PROCESS & ~NETWORK); emit("disconnect"); }, plugin); @@ -67,7 +67,7 @@ define(function(require, module, exports) { }, plugin); vfs.on("error", function(message) { - setStatus(status & ~STORAGE & ~PROCESS); + setStatus(state & ~STORAGE & ~PROCESS); // TODO: Don't display all errors? if (emit("showerrormessage", message) !== false) { console.error( diff --git a/plugins/c9.ide.dialog.common/error.css b/plugins/c9.ide.dialog.common/error.css index f3d14fb7..96f0a115 100644 --- a/plugins/c9.ide.dialog.common/error.css +++ b/plugins/c9.ide.dialog.common/error.css @@ -1,18 +1,23 @@ -.errorlabel{ +.errorlabel, .disconnectlabel{ position: absolute; left: 0; right: 0; top: 0; z-index: 10000000; - text-align: center; + /*text-align: center;*/ pointer-events: none; .font-smoothing(@error-font-smoothing); } -.errorlabel.anim{ +.errorlabel.anim, .disconnectlabel.anim{ transition: top 0.2s; -moz-transition: top 0.2s; /* Gecko */ -webkit-transition: top 0.2s; /* Safari */ } +.errorlabel.fade-in{ + transition: opacity 0.2s; + -moz-transition: opacity 0.2s; /* Gecko */ + -webkit-transition: opacity 0.2s; /* Safari */ +} .errorlabel div{ background: @error-background; padding: @error-padding; @@ -26,6 +31,9 @@ max-width: 100%; pointer-events: auto; } +.errorlabel.fade-in div{ + border-radius: 3px; +} .errorlabel u.close{ .image-2x("@{image-path}/@{error-close-image}", 42px, 28px); background-position: @error-close-idle-position; @@ -33,7 +41,7 @@ height: 14px; position: absolute; right: 8px; - top: 8px; + top: 6px; cursor: pointer; } .errorlabel u.close:hover{ @@ -45,4 +53,25 @@ .errorlabel div span{ border-bottom: 1px dotted rgb(255, 174, 174); cursor: help; +} + +.disconnectlabel{ + z-index: 10000001; +} +.disconnectlabel div{ + background: @disconnect-background; + padding: @disconnect-padding; + color: @disconnect-color; + border-radius: 0 0 3px 3px; + box-shadow: @disconnect-box-shadow; + line-height: 1.4; + display: inline-block; + position: relative; + word-wrap: break-word; + text-align: center; + width: 300px; + pointer-events: auto; +} +.disconnectlabel u{ + cursor: pointer; } \ No newline at end of file diff --git a/plugins/c9.ide.dialog.common/error.js b/plugins/c9.ide.dialog.common/error.js index 3642818a..3d28bb20 100644 --- a/plugins/c9.ide.dialog.common/error.js +++ b/plugins/c9.ide.dialog.common/error.js @@ -12,22 +12,72 @@ define(function(require, exports, module) { /***** Initialization *****/ var plugin = new Plugin("Ajax.org", main.consumes); + var emit = plugin.getEmitter(); var topPx = 0; - var error, hideTimeout; var lastCookie = 0; + var offset = 0; + var error, hideTimeout, disconnect; + + var DISCONNECTDELAY = 1000; - var loaded = false; function load() { - if (loaded) return false; - loaded = true; - ui.insertCss(require("text!./error.css"), options.staticPrefix, plugin); } + function initDisconnectEvents(vfs){ + var timer; + + vfs.once("connect", function(){ + vfs.connection.on("reconnectDelay", function(e){ + clearInterval(timer); + + var delay = e.delay; + if (delay > 999) { + timer = setInterval(function(){ + if (vfs.connected) + return clearInterval(timer); + + delay -= 1000; + showDisconnect({ delay: delay }); + + if (delay <= 0) + clearInterval(timer); + }, 1000); + } + + showDisconnect(e); + }); + }); + vfs.on("connect", function(){ + hideDisconnect(); + }); + vfs.on("disconnect", function(){ + // setTimeout(function(){ + // showDisconnect(); + // }, DISCONNECTDELAY); + }); + vfs.on("connecting", function(){ + showDisconnect({ connecting: true }); + }); + plugin.on("retryConnect", function(){ + vfs.connection.reconnect(0); + }); + } + /***** Methods *****/ + function getCenterX(){ + var bartools = document.querySelector(".bartools"); + if (!bartools) return 0; // For testing + + var b1 = bartools.getBoundingClientRect(); + var b2 = bartools.nextSibling.getBoundingClientRect(); + + return b1.left + b1.width + ((b2.left - b1.left - b1.width)/2); + } + function show(message, timeout) { // Error message container if (!error) { @@ -63,18 +113,21 @@ define(function(require, exports, module) { error.innerHTML = "
" + messageString + "
"; + error.style.opacity = 0; error.style.display = "block"; - error.style.top = (-1 * error.offsetHeight - 10 + topPx) + "px"; + error.style.top = (offset - (error.offsetHeight - 10 + topPx)) + "px"; + error.firstChild.style.marginLeft = Math.max(0, (getCenterX() - (error.firstChild.offsetWidth / 2))) + "px"; // Start anim setTimeout(function() { - error.className = "errorlabel anim"; - error.style.top = topPx + "px"; + error.className = "errorlabel anim " + (offset > 0 ? "fade-in" : ""); + error.style.top = (offset + topPx) + "px"; + error.style.opacity = 1; }, 10); clearTimeout(hideTimeout); if (!(timeout < 0)) - setTimeout(hide, timeout || 15000); + hideTimeout = setTimeout(hide, timeout || 15000); }); return ++lastCookie; @@ -89,19 +142,96 @@ define(function(require, exports, module) { if (!error || error.style.display === "none") return callback && callback(); - error.className = "errorlabel anim"; - error.style.top = (-1 * error.offsetHeight - 10 + topPx) + "px"; + error.className = "errorlabel anim " + (offset > 0 ? "fade-in" : ""); + if (offset > 0) + error.style.opacity = 0; + else + error.style.top = (-1 * error.offsetHeight - 10 + topPx) + "px"; + setTimeout(function() { error.style.display = "none"; callback && callback(); }, 220); } + function showDisconnect(options){ + // Error message container + if (!disconnect) { + disconnect = document.body.appendChild(document.createElement("div")); + disconnect.className = "disconnectlabel"; + disconnect.addEventListener("mouseup", function(e) { + if (e.target.tagName == "U") + emit("retryConnect"); + }); + } + + var message; + if (!options || options.delay < 1000 || options.connecting) + message = "Reconnecting..."; + else if (options.delay) + message = "Reconnecting in " + Math.ceil(options.delay/1000) + + " seconds." + + (options.delay < 2001 ? "" : " Retry Now."); + else + message = "Reconnecting..."; + + disconnect.innerHTML = "
" + message + "
"; + disconnect.firstChild.style.marginLeft + = Math.max(0, (getCenterX() - 150)) + "px"; + + if (disconnect.style.display == "block") + return; + + disconnect.style.display = "block"; + disconnect.style.top = (-1 * disconnect.offsetHeight - 10 + topPx) + "px"; + + // Start anim + setTimeout(function() { + disconnect.className = "disconnectlabel anim"; + disconnect.style.top = (topPx) + "px"; + }, 10); + + offset = 28; + + // document.querySelector(".c9-offline").addEventListener("click", function(){ + // alert("Offline Notication", "You are currently offline.", + // "This indicator notifies you that Cloud9 is unable to reach " + // + "the server. This usually happens because you are offline. " + // + "Some features will be disabled until the " + // + "network connection becomes available again. " + // + "This notication could also show when the server is " + // + "unreachable due to other reasons. Sometimes a refresh of " + // + "the tab will fix an issue. Please e-mail " + // + "support@c9.io for further problem resolution."); + // }, false); + } + + function hideDisconnect(cookie, callback) { + if (!disconnect || disconnect.style.display === "none") + return callback && callback(); + + disconnect.className = "disconnectlabel anim"; + disconnect.style.top = (-1 * disconnect.offsetHeight - 10 + topPx) + "px"; + setTimeout(function() { + disconnect.style.display = "none"; + callback && callback(); + }, 220); + + offset = 0; + } + /***** Lifecycle *****/ plugin.on("load", function() { load(); }); + plugin.on("unload", function() { + topPx = 0; + lastCookie = 0; + offset = 0; + error = null; + hideTimeout = null; + }); /***** Register and define API *****/ @@ -116,6 +246,19 @@ define(function(require, exports, module) { get top(){ return topPx; }, set top(value){ topPx = value; }, + get vfs(){ throw new Error("Permission Denied"); }, + set vfs(v){ initDisconnectEvents(v); }, + + /** + * + */ + showDisconnect: showDisconnect, + + /** + * + */ + hideDisconnect: hideDisconnect, + /** * Displays an error message in the main error reporting UI. * @param {String} message The message to display. diff --git a/plugins/c9.ide.layout.classic/layout.js b/plugins/c9.ide.layout.classic/layout.js index c3124ceb..5d3aee91 100644 --- a/plugins/c9.ide.layout.classic/layout.js +++ b/plugins/c9.ide.layout.classic/layout.js @@ -8,11 +8,11 @@ define(function(require, exports, module) { function main(options, imports, register) { var c9 = imports.c9; - var alert = imports["dialog.alert"].show; var Plugin = imports.Plugin; - var question = imports["dialog.question"]; var settings = imports.settings; var commands = imports.commands; + var alert = imports["dialog.alert"].show; + var question = imports["dialog.question"]; var preload = imports["layout.preload"]; var anims = imports.anims; var ui = imports.ui; @@ -126,33 +126,6 @@ define(function(require, exports, module) { img.src = options.staticPrefix + "/images/" + p; }); - var hideOffline; - c9.on("stateChange", function(e) { - // Online - if (e.state & c9.NETWORK && e.state & c9.STORAGE) { - hideOffline && hideOffline(); - } - // Offline - else if (!hideOffline || hideOffline.hasClosed()) { - hideOffline = notify("
No internet " - + "connection detected. Cloud9 will automatically try to " - + "reconnect when it detects an internet connection." - + "
", true, 1000); - - document.querySelector(".c9-offline").addEventListener("click", function(){ - alert("Offline Notication", "You are currently offline.", - "This indicator notifies you that Cloud9 is unable to reach " - + "the server. This usually happens because you are offline. " - + "Some features will be disabled until the " - + "network connection becomes available again. " - + "This notication could also show when the server is " - + "unreachable due to other reasons. Sometimes a refresh of " - + "the tab will fix an issue. Please e-mail " - + "support@c9.io for further problem resolution."); - }, false); - } - }); - window.addEventListener("resize", resize, false); window.addEventListener("focus", resize, false); @@ -542,6 +515,21 @@ define(function(require, exports, module) { window.removeEventListener("resize", resize); if (removeTheme) removeTheme(); + + logobar = null; + removeTheme = null; + theme = null; + c9console = null; + menus = null; + tabManager = null; + panels = null; + userLayout = null; + ignoreTheme = null; + notify = null; + hideFlagUpdate = null; + activeFindArea = null; + defaultFindArea = null; + activating = null; }); /***** Register and define API *****/ diff --git a/plugins/c9.ide.layout.classic/themes/default-dark-gray.less b/plugins/c9.ide.layout.classic/themes/default-dark-gray.less index 6c78b067..f78fd8a0 100644 --- a/plugins/c9.ide.layout.classic/themes/default-dark-gray.less +++ b/plugins/c9.ide.layout.classic/themes/default-dark-gray.less @@ -632,6 +632,12 @@ @error-close-hover-position: -14px -14px; @error-close-active-position: -28px -14px; +// Disconnect Dialog +@disconnect-background: #D8B112; +@disconnect-color: @error-color; +@disconnect-padding: @error-padding; +@disconnect-box-shadow: @error-box-shadow; + // Offline Dialog @offline-gradient: linear-gradient(top, rgb(60, 112, 153) 0%, rgb(61, 97, 126) 100%); @offline-border-bottom: 1px solid rgba(0, 0, 0, 0.61); diff --git a/plugins/c9.ide.layout.classic/themes/default-dark.less b/plugins/c9.ide.layout.classic/themes/default-dark.less index fd62d0f3..26707588 100644 --- a/plugins/c9.ide.layout.classic/themes/default-dark.less +++ b/plugins/c9.ide.layout.classic/themes/default-dark.less @@ -632,6 +632,12 @@ @error-close-hover-position: -14px -14px; @error-close-active-position: -28px -14px; +// Disconnect Dialog +@disconnect-background: #D8B112; +@disconnect-color: @error-color; +@disconnect-padding: @error-padding; +@disconnect-box-shadow: @error-box-shadow; + // Offline Dialog @offline-gradient: linear-gradient(top, rgb(60, 112, 153) 0%, rgb(61, 97, 126) 100%); @offline-border-bottom: 1px solid rgba(0, 0, 0, 0.61); diff --git a/plugins/c9.ide.layout.classic/themes/default-flat-light.less b/plugins/c9.ide.layout.classic/themes/default-flat-light.less index b23ca74b..6425061b 100644 --- a/plugins/c9.ide.layout.classic/themes/default-flat-light.less +++ b/plugins/c9.ide.layout.classic/themes/default-flat-light.less @@ -632,6 +632,12 @@ @error-close-hover-position: -14px -14px; @error-close-active-position: -28px -14px; +// Disconnect Dialog +@disconnect-background: #D8B112; +@disconnect-color: @error-color; +@disconnect-padding: @error-padding; +@disconnect-box-shadow: @error-box-shadow; + // Offline Dialog @offline-gradient: linear-gradient(top, #3d9ac4 0%, #3d9ac4 100%); @offline-border-bottom: 0; diff --git a/plugins/c9.ide.layout.classic/themes/default-light-gray.less b/plugins/c9.ide.layout.classic/themes/default-light-gray.less index 39472337..ebf4895d 100644 --- a/plugins/c9.ide.layout.classic/themes/default-light-gray.less +++ b/plugins/c9.ide.layout.classic/themes/default-light-gray.less @@ -632,6 +632,12 @@ @error-close-hover-position: -14px -14px; @error-close-active-position: -28px -14px; +// Disconnect Dialog +@disconnect-background: #D8B112; +@disconnect-color: @error-color; +@disconnect-padding: @error-padding; +@disconnect-box-shadow: @error-box-shadow; + // Offline Dialog @offline-gradient: linear-gradient(top, rgb(60, 112, 153) 0%, rgb(61, 97, 126) 100%); @offline-border-bottom: 1px solid rgba(0, 0, 0, 0.61); diff --git a/plugins/c9.ide.layout.classic/themes/default-light.less b/plugins/c9.ide.layout.classic/themes/default-light.less index 48928aee..982b7177 100644 --- a/plugins/c9.ide.layout.classic/themes/default-light.less +++ b/plugins/c9.ide.layout.classic/themes/default-light.less @@ -632,6 +632,12 @@ @error-close-hover-position: -14px -14px; @error-close-active-position: -28px -14px; +// Disconnect Dialog +@disconnect-background: #D8B112; +@disconnect-color: @error-color; +@disconnect-padding: @error-padding; +@disconnect-box-shadow: @error-box-shadow; + // Offline Dialog @offline-gradient: linear-gradient(top, rgb(60, 112, 153) 0%, rgb(61, 97, 126) 100%); @offline-border-bottom: 1px solid rgba(0, 0, 0, 0.61); diff --git a/plugins/c9.vfs.client/vfs_client.js b/plugins/c9.vfs.client/vfs_client.js index 22a5916f..266974e7 100644 --- a/plugins/c9.vfs.client/vfs_client.js +++ b/plugins/c9.vfs.client/vfs_client.js @@ -30,8 +30,9 @@ define(function(require, exports, module) { var Plugin = imports.Plugin; var auth = imports.auth; var vfsEndpoint = imports["vfs.endpoint"]; - var showError = imports["dialog.error"].show; - var hideError = imports["dialog.error"].hide; + var errorDialog = imports["dialog.error"]; + var showError = errorDialog.show; + var hideError = errorDialog.hide; var showAlert = imports["dialog.alert"].show; var eio = require("engine.io"); @@ -49,6 +50,9 @@ define(function(require, exports, module) { var plugin = new Plugin("Ajax.org", main.consumes); var emit = plugin.getEmitter(); + // Give reference to vfs to plugin + errorDialog.vfs = plugin; + var buffer = []; var installChecked = false; var withInstall = options.withInstall; @@ -330,6 +334,22 @@ define(function(require, exports, module) { }); plugin.on("unload", function(){ loaded = false; + + id = null; + buffer = []; + installChecked = false; + region = null; + vfsBaseUrl = null; + homeUrl = null; + projectUrl = null; + pingUrl = null; + serviceUrl = null; + eioOptions = null; + consumer = null; + vfs = null; + showErrorTimer = null; + showErrorTimerMessage = null; + lastError = null; }); /***** Register and define API *****/ From 591e5d841e81f03c3a0e88ba81be32e8191d6a25 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Wed, 11 Feb 2015 17:00:19 +0000 Subject: [PATCH 9/9] Fixes reconnect ui not going away --- plugins/c9.fs/proc.js | 2 +- plugins/c9.ide.dialog.common/error.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/c9.fs/proc.js b/plugins/c9.fs/proc.js index 3a738a29..2ce7ece1 100644 --- a/plugins/c9.fs/proc.js +++ b/plugins/c9.fs/proc.js @@ -357,7 +357,7 @@ define(function(require, exports, module) { }, /** - * Spawns a child process in a TMUX and returns a stream object. + * Spawns a child process in a TMUX session and returns a stream object. * Use this method if the process you wish to start requires a * terminal (for instance VI). * diff --git a/plugins/c9.ide.dialog.common/error.js b/plugins/c9.ide.dialog.common/error.js index 3d28bb20..6b82c801 100644 --- a/plugins/c9.ide.dialog.common/error.js +++ b/plugins/c9.ide.dialog.common/error.js @@ -50,6 +50,11 @@ define(function(require, exports, module) { showDisconnect(e); }); }); + vfs.on("away", function(){ + }); + vfs.on("back", function(){ + hideDisconnect(); + }); vfs.on("connect", function(){ hideDisconnect(); });