CHE-602 allow to send to ide new parameters

Change-Id: I0a10ca6a2ad403349a87ba80b124918eca7bff11
Signed-off-by: Florent BENOIT <fbenoit@codenvy.com>
6.19.x
Florent BENOIT 2016-02-25 10:44:26 +01:00
parent 6aad4e3549
commit d09773183c
2 changed files with 50 additions and 2 deletions

View File

@ -42,6 +42,7 @@ class IdeCtrl {
}
let ideAction = $routeParams.action;
let ideParams = $routeParams.ideParams;
if (ideAction) {
// send action
this.ideSvc.setIDEAction(ideAction);
@ -52,9 +53,30 @@ class IdeCtrl {
// remove action from path
$location.url('/ide/' + this.selectedWorkspaceName, false);
} else {
// no action, keep current flow
} else if (ideParams) {
let params = new Map();
let isArray = Array.isArray(ideParams);
if (isArray) {
ideParams.forEach((param) => {
let argParam = this.getParams(param);
params.set(argParam.key, argParam.value);
});
} else {
let argParam = this.getParams(ideParams);
params.set(argParam.key, argParam.value);
}
for (var [key, val] of params) {
this.ideSvc.setLoadingParameter(key, val);
}
// pop current route as we will redirect
routeHistory.popCurrentPath();
// remove action from path
$location.url('/ide/' + this.selectedWorkspaceName, false);
} else {
this.ideIFrameSvc.addIFrame();
let promise = cheWorkspace.fetchWorkspaces();
@ -69,6 +91,20 @@ class IdeCtrl {
}
/**
* Transform colon separator value into key/value
* @param arg
* @returns object with key and value
*/
getParams(arg) {
let array = arg.split(':');
var obj = {};
obj.key = array[0];
obj.value = array[1];
return obj;
}
displayIDE() {
this.ideSvc.displayIDE();

View File

@ -34,6 +34,7 @@ class IdeSvc {
this.$location = $location;
this.routeHistory = routeHistory;
this.ideParams = new Map();
this.currentStep = 0;
this.selectedWorkspace = null;
@ -216,6 +217,10 @@ class IdeSvc {
});
}
setLoadingParameter(paramName, paramValue) {
this.ideParams.set(paramName, paramValue);
}
setIDEAction(ideAction) {
this.ideAction = ideAction;
}
@ -248,6 +253,13 @@ class IdeSvc {
this.ideAction = null;
}
if (this.ideParams) {
for (var [key, val] of this.ideParams) {
appendUrl = appendUrl + '&' + key + '=' + val;
}
this.ideParams.clear();
}
if (inDevMode) {
this.$rootScope.ideIframeLink = this.$sce.trustAsResourceUrl(this.proxySettings + contextPath + this.selectedWorkspace.config.name + appendUrl);
} else {