summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaciej Bendkowski <maciej.bendkowski@pl.ibm.com>2014-10-16 17:07:55 +0200
committerMaciej Bendkowski <maciej.bendkowski@pl.ibm.com>2014-10-17 12:26:46 +0200
commitdf571a91f492d125df738cc8341d5a3418f83df1 (patch)
treeffaab24f9cd28073567400a504dc49c734c6f9ea
parentdb8e7efdbdf8c49beba7a5d81114e5e96b0bc112 (diff)
downloadorg.eclipse.orion.client-origin/bug446669.zip
org.eclipse.orion.client-origin/bug446669.tar.gz
org.eclipse.orion.client-origin/bug446669.tar.bz2
Bug 446669 - Provide debug deployments for Node.js applicationsorigin/bug446669
Prompt user for password and url prefix
-rw-r--r--bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/common/debugPaneBuilder.js70
-rw-r--r--bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/common/deploymentLogic.js3
-rw-r--r--bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/nodeJSDeploymentWizardPlugin.html2
-rw-r--r--bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/nodejs/nodeJSDeploymentWizard.js45
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/webui/Wizard.js3
5 files changed, 91 insertions, 32 deletions
diff --git a/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/common/debugPaneBuilder.js b/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/common/debugPaneBuilder.js
index 34af260..b047886 100644
--- a/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/common/debugPaneBuilder.js
+++ b/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/common/debugPaneBuilder.js
@@ -32,9 +32,32 @@ define(['orion/webui/Wizard'], function(mWizard){
var self = this;
return new mWizard.WizardPage({
- template: '<div class="manifest formTable" id="debug"></div><div class="manifest formTable" id="manifest"></div>',
+ template: '<div class="manifest formTable" id="debug"></div>' +
+ '<table class="formTable">'+
+ '<tr>'+
+ '<td id="cfPasswordLabel" class="label"></td>'+
+ '<td id="cfPassword" class="selectCell"></td>'+
+ '</tr>'+
+ '<tr>'+
+ '<td id="cfUrlPrefixLabel" class="label"></td>'+
+ '<td id="cfUrlPrefix" class="selectCell"></td>'+
+ '</tr>'+
+ '</table>' +
+ '<div class="manifest formTable" id="manifest"></div>',
+
+ validate: function(callback){
+ var checkbox = self._debugCheckbox;
+ var debugEnabled = checkbox ? checkbox.checked : false;
+ if(!debugEnabled)
+ return callback(true);
+
+ var cfLauncherPassword = self._cfLauncherPassword.value;
+ return callback(cfLauncherPassword && cfLauncherPassword.length > 0);
+ },
+
render: function(){
+ var gandalfthewhite = this.wizard;
var manifestElement = document.getElementById("manifest");
var saveManifestCheckbox = document.createElement("input");
@@ -64,13 +87,54 @@ define(['orion/webui/Wizard'], function(mWizard){
var label = document.createElement("label");
label.className = "manifestLabel";
- label.innerHTML = "Debug with <a href=\"https://www.npmjs.org/package/cf-launcher\">cf-launcher</a>";
+ label.innerHTML = "Debug with <a href=\"https://www.npmjs.org/package/cf-launcher\">cf-launcher</a>:";
debugElement.appendChild(label);
+
+ var cfPasswordLabel = document.getElementById("cfPasswordLabel");
+ var passwordLabel = document.createTextNode("Password: ");
+ cfPasswordLabel.appendChild(passwordLabel);
+
+ var cfPassword = document.getElementById("cfPassword");
+ var passwordInput = document.createElement("input");
+ self._cfLauncherPassword = passwordInput;
+
+ passwordInput.type = "password";
+ passwordInput.disabled = true;
+ passwordInput.placeholder = "Required to prevent random access to cf-launcher";
+ cfPassword.appendChild(passwordInput);
+
+ var cfUrlPrefixLabel = document.getElementById("cfUrlPrefixLabel");
+ var urlLabel = document.createTextNode("URL Prefix: ");
+ cfUrlPrefixLabel.appendChild(urlLabel);
+
+ var cfUrlPrefix = document.getElementById("cfUrlPrefix");
+
+ var urlInput = document.createElement("input");
+ self._cfLauncherURLPrefix = urlInput;
+
+ urlInput.placeholder = "Leave blank for default /launcher";
+ urlInput.disabled = true;
+
+ cfUrlPrefix.appendChild(urlInput);
+
+ debugCheckbox.addEventListener("change", function(){
+ var enable = !debugCheckbox.checked;
+ passwordInput.disabled = enable;
+ urlInput.disabled = enable;
+
+ gandalfthewhite.validate();
+ });
+
+ passwordInput.addEventListener("keyup", function(){
+ gandalfthewhite.validate();
+ });
},
getResults: function(){
return {
- saveManifest : self._saveManifestCheckbox.checked
+ saveManifest : self._saveManifestCheckbox.checked,
+ cfLauncherPassword : self._cfLauncherPassword.value,
+ cfLauncherURLPrefix : self._cfLauncherURLPrefix.value
};
}
});
diff --git a/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/common/deploymentLogic.js b/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/common/deploymentLogic.js
index 764b4bb..79fa6c4 100644
--- a/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/common/deploymentLogic.js
+++ b/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/common/deploymentLogic.js
@@ -117,9 +117,6 @@ define(['orion/objects', 'cfui/cfUtil'], function(objects, mCfUtil){
var editLocation = new URL("../edit/edit.html#" + contentLocation, window.location.href);
cfService.pushApp(selection, null, decodeURIComponent(contentLocation + appPath), manifest, saveManifest, packager, instrumentation).then(function(result){
- if(options.successCallback)
- options.successCallback();
-
var launchConfigurationContent = mCfUtil.prepareLaunchConfigurationContent(result, appPath, editLocation);
postMsg(launchConfigurationContent);
diff --git a/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/nodeJSDeploymentWizardPlugin.html b/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/nodeJSDeploymentWizardPlugin.html
index 43944c8..581e3c6 100644
--- a/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/nodeJSDeploymentWizardPlugin.html
+++ b/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/nodeJSDeploymentWizardPlugin.html
@@ -33,7 +33,7 @@
return {
LocationTemplate : "{+OrionHome}/cfui/plugins/wizards/nodejs/nodeJSDeploymentWizard.html",
Width : "450px",
- Height : "350px"
+ Height : "430px"
};
}
};
diff --git a/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/nodejs/nodeJSDeploymentWizard.js b/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/nodejs/nodeJSDeploymentWizard.js
index 44e5937..fed5289 100644
--- a/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/nodejs/nodeJSDeploymentWizard.js
+++ b/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/wizards/nodejs/nodeJSDeploymentWizard.js
@@ -28,12 +28,6 @@ define(["orion/bootstrap", "orion/xhr", 'orion/webui/littlelib', 'orion/Deferred
var hideMessage = mWizardUtils.defaultHideMessage;
var showError = mWizardUtils.defaultShowError;
- /* generates a random cf-launcher authentication password */
- function getRandomPassword(length){
- length = length || 8;
- return Math.random().toString(36).slice(-length);
- }
-
mBootstrap.startup().then(function(core) {
/* set up initial message */
@@ -94,8 +88,12 @@ define(["orion/bootstrap", "orion/xhr", 'orion/webui/littlelib', 'orion/Deferred
});
}, function(error){
+
if(clouds.length === 0)
- return d.reject(error);
+ return d.reject({
+ error: error,
+ target: target
+ });
var dp = getDefaultNonEmptyTarget(clouds);
dp.then(d.resolve, d.reject);
@@ -198,13 +196,13 @@ define(["orion/bootstrap", "orion/xhr", 'orion/webui/littlelib', 'orion/Deferred
var message = "<p>Click <b>\"Deploy\"</b> to proceed or <b>\"Next\"</b> to change the deployment parameters.</p>";
- /*var message = i18nUtil.formatMessage(messageTemplate, manifestApplication.name,
- space.Name, org.Name, defaultTarget.Name || defaultTarget.Url || target.Name || target.Url);*/
-
var messageDiv = document.getElementById("confirmationMessage");
messageDiv.innerHTML = message;
}, function(err){
+
+ var error = err.error;
+ var target = err.target;
handleError(error, target, function(){ return page0.render(); });
});
},
@@ -265,9 +263,6 @@ define(["orion/bootstrap", "orion/xhr", 'orion/webui/littlelib', 'orion/Deferred
var page2 = servicesPageBuilder.build();
var page3 = additionalParamPageBuilder.build();
- /* shared instance of random cf-launcher password */
- var _cfLauncherPassword;
-
var wizard = new Wizard.Wizard({
parent: "wizard",
pages: [page0, page1, page2, page3],
@@ -285,6 +280,12 @@ define(["orion/bootstrap", "orion/xhr", 'orion/webui/littlelib', 'orion/Deferred
if(corePageBuilder._spacesDropdown)
corePageBuilder._spacesDropdown.disabled = true;
+
+ if(debugPaneBuilder._cfLauncherPassword)
+ debugPaneBuilder._cfLauncherPassword.disabled = true;
+
+ if(debugPaneBuilder._cfLauncherURLPrefix)
+ debugPaneBuilder._cfLauncherURLPrefix.disabled = true;
},
postMsg : postMsg,
@@ -323,21 +324,17 @@ define(["orion/bootstrap", "orion/xhr", 'orion/webui/littlelib', 'orion/Deferred
var instrumentation = {};
var app = manifest.applications[0];
- _cfLauncherPassword = getRandomPassword();
- var command = i18nUtil.formatMessage("node_modules/.bin/launcher --password ${0} -- ${1}", _cfLauncherPassword, app.command);
+ var password = debugPaneBuilder._cfLauncherPassword.value;
+ var userURLPrefix = debugPaneBuilder._cfLauncherURLPrefix.value;
+
+ var command = userURLPrefix ?
+ i18nUtil.formatMessage("node_modules/.bin/launcher --password ${0} --urlprefix ${1} -- ${2}", password, userURLPrefix, app.command)
+ : i18nUtil.formatMessage("node_modules/.bin/launcher --password ${0} -- ${1}", password, app.command);
+
instrumentation.command = command;
return instrumentation;
},
- successCallback : function(){
- var checkbox = debugPaneBuilder._debugCheckbox;
- var debugEnabled = checkbox ? checkbox.checked : false;
- if(!debugEnabled)
- return;
-
- alert(i18nUtil.formatMessage("Cf-launcher password: ${0}", _cfLauncherPassword));
- },
-
Manifest : plan.Manifest,
ContentLocation : resource.ContentLocation,
AppPath : resource.AppPath
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/webui/Wizard.js b/bundles/org.eclipse.orion.client.ui/web/orion/webui/Wizard.js
index ba4941a..50209f4 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/webui/Wizard.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/webui/Wizard.js
@@ -183,9 +183,10 @@ define(['orion/webui/littlelib', 'orion/objects'], function(lib, objects){
if(setValid) setValid(valid);
}.bind(this));
if(this.commonPane){
+ var self = this;
this.commonPane.validate(function(valid){
if(!valid){
- this._setButtonEnabled(this.okButton, false);
+ self._setButtonEnabled(self.okButton, false);
}
});
}