From d09773183c56c3674b5032df6fa290539c01e9ba Mon Sep 17 00:00:00 2001 From: Florent BENOIT Date: Thu, 25 Feb 2016 10:44:26 +0100 Subject: [PATCH] CHE-602 allow to send to ide new parameters Change-Id: I0a10ca6a2ad403349a87ba80b124918eca7bff11 Signed-off-by: Florent BENOIT --- dashboard/src/app/ide/ide.controller.js | 40 +++++++++++++++++++++++-- dashboard/src/app/ide/ide.service.js | 12 ++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/dashboard/src/app/ide/ide.controller.js b/dashboard/src/app/ide/ide.controller.js index a66511219e..f485cd9b05 100644 --- a/dashboard/src/app/ide/ide.controller.js +++ b/dashboard/src/app/ide/ide.controller.js @@ -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(); diff --git a/dashboard/src/app/ide/ide.service.js b/dashboard/src/app/ide/ide.service.js index b05c11cbe1..1f1e1d91a0 100644 --- a/dashboard/src/app/ide/ide.service.js +++ b/dashboard/src/app/ide/ide.service.js @@ -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 {