http://git-wip-us.apache.org/repos/asf/stratos/blob/c6a485f9/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag b/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag new file mode 100644 index 0000000..549b52c --- /dev/null +++ b/components/org.apache.stratos.manager.console/console/controllers/rest/rest_calls.jag @@ -0,0 +1,374 @@ +<% +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +RESTCalls = new function(){ + var log = new Log('RESTCalls'); + + this.getAvailableSingleTenantCartridges = function(){ + return this.sendReceive("GET","/cartridge/list",{}); + }; + + this.getAvailableMultiTenantCartridges = function(){ + return this.sendReceive("GET","/cartridge/tenanted/list",{}); + }; + + this.getSubscribedCartridges = function(){ + return this.sendReceive("GET","/cartridge/list/subscribed",{}); + } + + this.getTenants = function(){ + return this.sendReceive("GET","/tenant/list",{}); + }; + + this.getServices = function(){ + return this.sendReceive("GET","/service",{}); + }; + + this.deployCartridgeDefinition = function(cartridgeDefinition){ + return this.send("POST","/cartridge/definition",cartridgeDefinition); + }; + + this.deployServiceDefinition = function(serviceDefinition){ + return this.send("POST","/service/definition",serviceDefinition); + }; + + this.deployLbDefinition = function(lbDefinition){ + return this.send("POST","/cartridge/definition",lbDefinition); + }; + + this.activateTenant = function(tenantDomain){ + return this.send("POST","/tenant/activate/" + tenantDomain,{}); + }; + + this.deactivateTenant = function(tenantDomain){ + return this.send("POST","/tenant/deactivate/" + tenantDomain,{}); + }; + + this.deleteTenant = function(tenantDomain){ + return this.send("DELETE","/tenant/" + tenantDomain,{}); + }; + + this.checkAvailability = function(tenantDomain){ + return this.send("POST","/tenant/availability/" + tenantDomain,{}); + }; + + this.deployPartitionDefinition = function(partitionDefinition){ + return this.send("POST","/policy/deployment/partition",partitionDefinition); + }; + + this.deployDeploymentPolicyDefinition = function(policyDefinition){ + return this.send("POST","/policy/deployment",policyDefinition); + }; + + this.deployAutoscalePolicyDefinition = function(policyDefinition){ + return this.send("POST","/policy/autoscale",policyDefinition); + }; + + this.deployKubernetesGroupDefinition = function(groupDefinition){ + return this.send("POST","/kubernetes/deploy/group",groupDefinition); + }; + + this.deployGroupDefinition = function(groupDefinition){ + return this.send("POST","/group/definition", groupDefinition); + }; + + this.deployApplicationDefinition = function(applicationDefinition){ + return this.send("POST","/application/definition", applicationDefinition); + }; + + this.subscribeToCartridge = function(cartridgeBeanInfo){ + return this.sendReceive("POST","/cartridge/subscribe", cartridgeBeanInfo); + }; + + this.addTenant = function(tenantInfoBean){ + return this.sendReceive("POST","/tenant",tenantInfoBean); + }; + + + this.addUser = function(userInfoBean){ + return this.sendReceive("POST","/user", userInfoBean); + }; + + this.syncRepo = function(alias){ + return this.send("POST","/cartridge/sync",alias); + }; + + this.getAutoScalePolicies = function(){ + return this.sendReceive("GET","/policy/autoscale",{}); + }; + + this.getDeploymentPolicies = function(){ + return this.sendReceive("GET","/policy/deployment",{}); + }; + + this.getKubernetesGroups = function(){ + return this.sendReceive("GET","/kubernetes/group",{}); + }; + + this.getApplicableDeploymentPolicies = function(cartridgeType){ + return this.sendReceive("GET","/" + cartridgeType + "/policy/deployment/",{}); + }; + + this.getPartitions = function(){ + return this.sendReceive("GET","/partition",{}); + }; + + this.getSingleTenantCartridgeInfo = function(cartridgeType){ + return this.sendReceive("GET","/cartridge/available/info/" + cartridgeType,{}); + }; + + this.getServiceInfo = function(cartridgeType){ + return this.sendReceive("GET","/service/" + cartridgeType,{}); + }; + + this.getPolicyAutoScale = function(){ + return this.sendReceive("GET","/policy/autoscale",{}); + }; + + this.getPolicyDeployment = function(){ + return this.sendReceive("GET","/policy/deployment",{}); + }; + this.unsubscribeCartridge = function(alias){ + return this.send("POST","/cartridge/unsubscribe",alias); + }; + this.getCartridges = function(){ + return this.sendReceive("GET","/cartridge/available/list",{}); + }; + + this.getLbCartridges = function(){ + return this.sendReceive("GET","/cartridge/lb",{}); + }; + + this.getApplications = function(){ + return this.sendReceive("GET","/application",{}); + }; + + this.getClusterInfo = function(clusterId){ + return this.sendReceive("GET","/cluster/clusterId/" + clusterId,{}); + }; + + this.getLBClusterInfo = function(){ + return this.sendReceive("GET","/cluster/lb",{}); + }; + + this.getClusterInfoWithAlias = function(cartridgeType, alias){ + return this.sendReceive("GET","/cluster/" + cartridgeType + "/" + alias,{}); + }; + this.getCartridgeInfo = function(alias){ + return this.sendReceive("GET","/cartridge/info/"+alias,{}); + }; + this.getCartridgeServiceGroup = function(serviceGroup){ + return this.sendReceive("GET","/cartridge/list/subscribed/group/"+serviceGroup,{}); + }; + this.validateCaptcha = function(captchaText){ + return this.sendReceive("POST","/captcha",captchaText); + }; + this.getCaptcha = function(){ + return this.sendReceiveImage("Get","/simpleImg",{}); + }; + this.undeployCartridge = function(cartridgeType){ + return this.sendReceive("DELETE","/cartridge/definition/"+cartridgeType,{}); + }; + this.getUserList = function(){ + return this.sendReceive("GET", "/user/list", {}); + } + this.getConfigStatus = function(){ + var configStatus = {}; + var error; + var par_res = this.sendReceive("GET","/policy/autoscale",{}); + var get_status = session.get("get-status"); + if(par_res.Error != undefined){ + error = par_res.Error; + configStatus.first_use = true; + }else{ + if(get_status.status == "success") { + if(par_res.autoscalePolicy.length == 0){ + configStatus.first_use = true; + }else{ + var car_res = this.sendReceive("GET","/cartridge/available/list",{}); + if(car_res.Error != undefined){ + error=car_res.Error; + configStatus.first_use = false; + configStatus.not_complete = true; + }else{ + get_status = session.get("get-status"); + if(get_status.status == "success") { + if(car_res.cartridge.length == 0){ + configStatus.first_use = false; + configStatus.not_complete = true; + }else{ + + configStatus.not_complete = false; + configStatus.first_use = false; + } + } + } + } + } + } + + + return configStatus; + }; + + this.getRequestHeaders = function(ssoEnabled){ + var requestHeaders; + if(ssoEnabled){ + var accessToken = this.getAccessTokenFromSession(); + requestHeaders = { + "Authorization": "Bearer "+accessToken, + "Content-Type": "application/json" + }; + }else{ + requestHeaders = { + "Content-Type": "application/json", + "Cookie": "JSESSIONID="+session.get("JSESSIONID") + }; + } + return requestHeaders; + }; + + // refactor sendRecive and send method. duplicate code... + this.sendReceive = function(httpMethod,urlPostFix,data){ + var config = require('/config/console.js').config(); + var backendServerURL = config.backendServerConfiguration.url; + // getting the access token from the session. + var endpoint = backendServerURL + urlPostFix; + var headers = this.getRequestHeaders(false); //NEED TO FIX THIS + var response; + switch (httpMethod){ + case "GET": + response = get(endpoint,{},headers); + break; + case "POST": + response = post(endpoint,stringify(data),headers); + break; + case "PUT": + response = put(endpoint,stringify(data),headers); + break; + case "DELETE": + response = del(endpoint,stringify(data),headers); + break; + default : + log.error("Error in the programme flow."); + } + if (response.xhr.status >= 200 && response.xhr.status < 300) { //if success + + session.put("get-status", { "message": "success" , "status": "success" }); + } else if (response.xhr.status >= 300 && response.xhr.status < 400) { //if redirects + if(response.data != null && response.data != undefined) { + session.put("get-status", { "message": parse(response.data).Error.errorMessage , "status": "warning" } ); + } + } else if (response.xhr.status >= 400 && response.xhr.status < 500) { //if client error + if(response.data != null && response.data != undefined) { + session.put("get-status",{ "message": parse(response.data).Error.errorMessage, "status": "warning" } ); + } + } else if (response.xhr.status >= 500 && response.xhr.status < 600) { //if server error + if(response.data != null && response.data != undefined) { + session.put("get-status", { "message": parse(response.data).Error.errorMessage, "status": "warning" } ); + } + } else { + session.put("get-status", "Unknown response!"); + } + + log.debug("sent is: " + stringify(response)); + + if (response.data != null && response.data != undefined) { + return parse(response.data); + } else { + return response.data; + } + }; + + + this.send = function(httpMethod,urlPostFix,data){ + var config = require('/config/console.js').config(); + var backendServerURL = config.backendServerConfiguration.url; + // getting the access token from the session. + var endpoint = backendServerURL + urlPostFix; + var headers = this.getRequestHeaders(false); //NEED TO FIX THIS + var response; + switch (httpMethod){ + case "GET": + response = get(endpoint,{},headers); + break; + case "POST": + response = post(endpoint,data,headers); + break; + case "PUT": + response = put(endpoint,data,headers); + break; + case "DELETE": + response = del(endpoint,data,headers); + break; + default : + log.error("Error in the programme flow."); + } + + if (response.xhr.status >= 200 && response.xhr.status < 300) { //if success + session.put("deploy-status", { "message": "success" , "status": "success" }); + } else if (response.xhr.status >= 300 && response.xhr.status < 400) { //if redirects + if(response.data != null && response.data != undefined) { + session.put("deploy-status",{ "message": parse(response.data).Error.errorMessage, "status": "warning" } ); + } + } else if (response.xhr.status >= 400 && response.xhr.status < 500) { //if client error + if(response.data != null && response.data != undefined) { + session.put("deploy-status", { "message": parse(response.data).Error.errorMessage, "status": "error"}); + } + } else if (response.xhr.status >= 500 && response.xhr.status < 600) { //if server error + if(response.data != null && response.data != undefined) { + session.put("deploy-status", { "message": parse(response.data).Error.errorMessage, "status": "error"}); + } + } else { + session.put("deploy-status", "Unknown response!"); + } + + if (response.data != null && response.data != undefined) { + return parse(response.data); + } else { + return response.data; + } + }; + + + this.getSession = function(userName, password){ + var config = require('/config/console.js').config(); + var backendServerURL = config.backendServerConfiguration.url; + var endpoint = backendServerURL + "/session"; + var sso = require("sso"); //TODO: get rid of this... + var basicAuthToken = sso.client.b64encode(userName + ":" + password); + var headers = { + "Authorization": "Basic "+basicAuthToken, + "Content-Type": "application/json" + }; + var response = get(endpoint,{},headers,"json"); + return response; + }; + + this.getAccessTokenFromSession = function(){ + return session.get("access_token"); + }; + + + +}; +%> \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/c6a485f9/components/org.apache.stratos.manager.console/console/controllers/users/users_requests.jag ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.manager.console/console/controllers/users/users_requests.jag b/components/org.apache.stratos.manager.console/console/controllers/users/users_requests.jag new file mode 100644 index 0000000..b5c6c9e --- /dev/null +++ b/components/org.apache.stratos.manager.console/console/controllers/users/users_requests.jag @@ -0,0 +1,45 @@ +<% +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +var log = new Log("apachestratos.users_request"), + util = require('/controllers/rest/rest_calls.jag'), + formPayload = request.getParameter('formPayload'), + formtype = request.getParameter('formtype'), + formSubmit; + +//add login validator for pages +include('/controllers/login/validator.jag'); + +try { + if(formtype == 'users'){ + formSubmit = util.RESTCalls.addUser(JSON.parse(formPayload)); + + }else if(formtype == 'tenants'){ + formSubmit = util.RESTCalls.addTenant(JSON.parse(formPayload)); + } + +}catch(e){ + log.info(e); +} + + +print(session.get("get-status")); +%> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/c6a485f9/components/org.apache.stratos.manager.console/console/controllers/wizard/wizard_requests.jag ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.manager.console/console/controllers/wizard/wizard_requests.jag b/components/org.apache.stratos.manager.console/console/controllers/wizard/wizard_requests.jag new file mode 100644 index 0000000..decbdf5 --- /dev/null +++ b/components/org.apache.stratos.manager.console/console/controllers/wizard/wizard_requests.jag @@ -0,0 +1,53 @@ +<% +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +var log = new Log("apachestratos.configure_request"), + util = require('/controllers/rest/rest_calls.jag'), + formPayload = request.getParameter('formPayload'), + formtype = request.getParameter('formtype'), + formSubmit; + +//add login validator for pages +include('/controllers/login/validator.jag'); + +try { + if(formtype == 'partitions'){ + formSubmit = util.RESTCalls.deployPartitionDefinition(formPayload); + }else if(formtype == 'autoscalingpolicies'){ + formSubmit = util.RESTCalls.deployAutoscalePolicyDefinition(formPayload); + }else if(formtype == 'deployments'){ + formSubmit = util.RESTCalls.deployDeploymentPolicyDefinition(formPayload); + }else if(formtype == 'loadbalancer'){ + formSubmit = util.RESTCalls.deployLbDefinition(formPayload); + }else if(formtype == 'cartridges'){ + formSubmit = util.RESTCalls.deployCartridgeDefinition(formPayload); + }else if(formtype == 'multitenant'){ + formSubmit = util.RESTCalls.deployServiceDefinition(formPayload); + } + + //print(session.get("deploy-status")); +}catch(e){ + log.info(e); +} + + +print(session.get("deploy-status")); +%> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/c6a485f9/components/org.apache.stratos.manager.console/console/errorhtml/error-404.html ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.manager.console/console/errorhtml/error-404.html b/components/org.apache.stratos.manager.console/console/errorhtml/error-404.html new file mode 100644 index 0000000..7b44ec3 --- /dev/null +++ b/components/org.apache.stratos.manager.console/console/errorhtml/error-404.html @@ -0,0 +1 @@ +Error 404 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/c6a485f9/components/org.apache.stratos.manager.console/console/errorhtml/error.html ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.manager.console/console/errorhtml/error.html b/components/org.apache.stratos.manager.console/console/errorhtml/error.html new file mode 100644 index 0000000..d2f9f22 --- /dev/null +++ b/components/org.apache.stratos.manager.console/console/errorhtml/error.html @@ -0,0 +1 @@ +Error page 500 Internal Server \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/c6a485f9/components/org.apache.stratos.manager.console/console/index.jag ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.manager.console/console/index.jag b/components/org.apache.stratos.manager.console/console/index.jag new file mode 100644 index 0000000..f6aa87c --- /dev/null +++ b/components/org.apache.stratos.manager.console/console/index.jag @@ -0,0 +1,43 @@ +<% +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +include('/controllers/login/validator.jag'); +include('/controllers/menu/menu_generator.jag'); + +var log = new Log("apacheStratos.index"); +var error = []; +var caramel = require('caramel'), + context = caramel.configs().context, + menuJson = require('/controllers/menu/menu.json'), + userPermissions = session.get('PERMISSIONS'); + +//create left menu +var leftMenu = menuGenerator(context, menuJson.menu, userPermissions); +//create metro block +var metroMenu = metroGenerator('/', menuJson.menu, userPermissions); + +caramel.render({ + metro_menu: metroMenu, + left_menu: leftMenu, + error: error +}); + +%> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/c6a485f9/components/org.apache.stratos.manager.console/console/jaggery.conf ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.manager.console/console/jaggery.conf b/components/org.apache.stratos.manager.console/console/jaggery.conf new file mode 100644 index 0000000..9936c4e --- /dev/null +++ b/components/org.apache.stratos.manager.console/console/jaggery.conf @@ -0,0 +1,60 @@ +{ + "initScripts": ["app.js"], + "logLevel": "info", + "urlMappings": [ + { + "url":"/login/", + "path":"/login.jag" + }, + { + "url": "/controllers/", + "path": "/controllers/*" + }, + { + "url": "/", + "path": "/index.jag" + }, + { + "url": "/configure/", + "path": "/configure.jag" + }, + { + "url": "/configure/*", + "path": "/configure_form.jag" + }, + { + "url": "/users/", + "path": "/users.jag" + }, + { + "url": "/users/*", + "path": "/users_form.jag" + }, + { + "url": "/applications/", + "path": "/applications.jag" + }, + { + "url": "/applications/*", + "path": "/applications_form.jag" + }, + { + "url": "/mycartridges/", + "path": "/my_cartridges.jag" + }, + { + "url": "/mycartridges/*", + "path": "/my_cartridges_info.jag" + }, + { + "url": "/wizard/*", + "path": "/wizard.jag" + } + ], + "errorPages": + { + "500":"/errorhtml/error.html", + "404":"/errorhtml/error-404.html" + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/c6a485f9/components/org.apache.stratos.manager.console/console/login.jag ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.manager.console/console/login.jag b/components/org.apache.stratos.manager.console/console/login.jag new file mode 100644 index 0000000..b4c2f7d --- /dev/null +++ b/components/org.apache.stratos.manager.console/console/login.jag @@ -0,0 +1,36 @@ +<% +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +var log = new Log("apachestratos.login"); +var error = session.get("error"), + caramel = require('caramel'); + +if (error == null) { + error = ""; +} + +session.remove("error"); + +caramel.render({ + error: error +}); +%> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/c6a485f9/components/org.apache.stratos.manager.console/console/modules/pinch.min.js ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.manager.console/console/modules/pinch.min.js b/components/org.apache.stratos.manager.console/console/modules/pinch.min.js new file mode 100644 index 0000000..7a6c14e --- /dev/null +++ b/components/org.apache.stratos.manager.console/console/modules/pinch.min.js @@ -0,0 +1,25 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +(function(){var k=function(a,c){return a.length!==c.length?!1:a.every(function(a,b){return c[b]===a})},j=function(a,c,d){var b,e;if("[object Array]"===Object.prototype.toString.call(a)){b=0;for(e=a.length;b<e;b++)c.apply(d,[b,a[b],a])}else for(b in a)a.hasOwnProperty(b)&&c.apply(d,[b,a[b],a])},h=function(a){for(var c=[],d=!1,b=0,e=a.length,f="",g=function(){f&&(c.push(f),f="")};b<e;b++)a[b].match(/\[|\]/)?(g(),d="]"===a[b]?!1:!0):'"'!==a[b]&&"'"!==a[b]&&("."===a[b]&&!d?g():f+=a[b]),b===e-1&&g();return c}, + g=function(a,c,d){var b=-1!==["string","object"].indexOf(typeof a),e="string"===typeof c||c&&c.test&&c.exec,f=-1!==["string","object","function"].indexOf(typeof d);b&&e&&f&&("string"===typeof a?(this.instance=JSON.parse(a),this.json=!0):this.instance=a,this.pattern="string"===typeof c?c.replace(/'/g,'"'):c,this.replacement=d,this.createIndex(this.instance))};g.prototype.createIndex=function(a,c){var d=this;this.index=this.index||[];c=c||"";j(a,function(a,e){var f,a=a+"";f=a.match(/^[a-zA-Z]+$/)?c? + c+"."+a:a:a.match(/\d+/)?c+"["+a+"]":c+'["'+a+'"]';d.index.push(f);"object"===typeof e&&d.createIndex(e,f)})};g.prototype.replace=function(){var a=this;j(this.index,function(c,d){if(a.pattern&&a.pattern.test&&a.pattern.exec&&d.match(a.pattern))return a.replaceValue(d);if("string"===typeof a.pattern){var b=h(d),e=h(a.pattern);if(k(b,e))return a.replaceValue(d)}});return this.json?JSON.stringify(this.instance):this.instance};g.prototype.replaceValue=function(a){var c=this,d=h(a);d.reduce(function(b, + e,f){if(f===d.length-1)f="function"===typeof c.replacement?c.replacement(a,e,b[e]):c.replacement,b[e]=f;else return b[e]},this.instance)};var i=function(a,c,d,b){a=(new g(a,c,d)).replace();return"function"===typeof b?b(null,a):a};"undefined"!==typeof module&&module.exports?module.exports=i:"undefined"!==typeof define?define(function(){return i}):this.pinch=i})(); http://git-wip-us.apache.org/repos/asf/stratos/blob/c6a485f9/components/org.apache.stratos.manager.console/console/my_cartridges.jag ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.manager.console/console/my_cartridges.jag b/components/org.apache.stratos.manager.console/console/my_cartridges.jag new file mode 100644 index 0000000..4341c08 --- /dev/null +++ b/components/org.apache.stratos.manager.console/console/my_cartridges.jag @@ -0,0 +1,71 @@ +<% +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +//add login validator for pages +include('/controllers/login/validator.jag'); +include('/controllers/menu/menu_generator.jag'); + +var log = new Log("apacheStratos.mycartridges"); +var error = [], + caramel = require('caramel'), + context = caramel.configs().context, + menuJson = require('/controllers/menu/menu.json'), + userPermissions = session.get('PERMISSIONS'), + uriMatcher = new URIMatcher(request.getRequestURI()), + util = require('/controllers/rest/rest_calls.jag'); + +var myCartridges, cartridgeAlias, myCartridgeInfo, myCartridgeInfoStatus; +//create left menu +var leftMenu = menuGenerator(context, menuJson.menu, userPermissions); + +try { + myCartridges = util.RESTCalls.getSubscribedCartridges(); +} catch (e) { + log.warn(e); +} + + +elements = uriMatcher.match('/{context}/mycartridges/{formtype}/{aliasType}') + +if (elements != null) { + cartridgeAlias = elements.aliasType; + myCartridgeInfoStatus = true; + try { + myCartridgeInfo = util.RESTCalls.getCartridgeInfo(cartridgeAlias); + } catch (e) { + log.warn(e); + } +} else { + myCartridgeInfoStatus = false; +} + +log.info(myCartridgeInfoStatus); + +caramel.render({ + error: error, + breadcrumbPathLevelOne: 'mycartridges', + left_menu: leftMenu, + myCartridgeInfoStatus: myCartridgeInfoStatus, + myCartridgeInfo: myCartridgeInfo, + myCartridges: myCartridges.cartridge +}); + +%> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/c6a485f9/components/org.apache.stratos.manager.console/console/my_cartridges_info.jag ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.manager.console/console/my_cartridges_info.jag b/components/org.apache.stratos.manager.console/console/my_cartridges_info.jag new file mode 100644 index 0000000..b999e10 --- /dev/null +++ b/components/org.apache.stratos.manager.console/console/my_cartridges_info.jag @@ -0,0 +1,65 @@ +<% +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +//add login validator for pages +include('/controllers/login/validator.jag'); +include('/controllers/menu/menu_generator.jag'); + +var log = new Log("apacheStratos.mycartridges"); +var error = [], + caramel = require('caramel'), + context = caramel.configs().context, + menuJson = require('/controllers/menu/menu.json'), + userPermissions = session.get('PERMISSIONS'), + uriMatcher = new URIMatcher(request.getRequestURI()), + cartridgeHtml = '', + util = require('/controllers/rest/rest_calls.jag'); +var myCartridgeInfo, myCartridgeInfoStatus; + +//create left menu +var leftMenu = menuGenerator(context, menuJson.menu, userPermissions); + +elements = uriMatcher.match('/{context}/mycartridges/{formtype}/{aliasType}') + +if (elements != null) { + cartridgeAlias = elements.aliasType; + myCartridgeInfoStatus = true; + try { + myCartridgeInfo = util.RESTCalls.getCartridgeInfo(cartridgeAlias); + for (specNumber in myCartridgeInfo.cartridge) { + log.info(myCartridgeInfo.cartridge[specNumber]) + cartridgeHtml +='<tr><td>' + specNumber +' </td><td>'+ myCartridgeInfo.cartridge[specNumber] + '</td></tr>'; + } + } catch (e) { + + } +} else { + myCartridgeInfoStatus = false; +} + +caramel.render({ + error: error, + breadcrumbPathLevelOne: 'mycartridges', + left_menu: leftMenu, + myCartridgeInfo: cartridgeHtml +}); + +%> \ No newline at end of file
