From a002e434296d32d4d14d4fd628db11b52966524a Mon Sep 17 00:00:00 2001 From: j00302280 Date: Fri, 21 Oct 2016 18:43:03 +0800 Subject: Issue ID: GSO-37 Change-Id: I376471bf15f5c090d8e574e13524d736011a7a3e Signed-off-by: j00302280 --- .../src/main/webapp/lifecyclemgr/js/rest.js | 67 ++++++++++++++++++++-- 1 file changed, 63 insertions(+), 4 deletions(-) (limited to 'openo-portal/portal-lifecyclemgr') diff --git a/openo-portal/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/js/rest.js b/openo-portal/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/js/rest.js index 75d61ac3..ed860901 100644 --- a/openo-portal/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/js/rest.js +++ b/openo-portal/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/js/rest.js @@ -111,45 +111,104 @@ $(function () { } }); }); + //init the templates combo + $.when( + generateTemplatesComponent() + ).then( + function (templates) { + document.getElementById("svcTempl").innerHTML = templates; + } + ); }) +/** + * generate the templates Component + * @returns + */ +function generateTemplatesComponent(){ + var defer = $.Deferred(); + $.when( + queryTemplates() + ).then( + function (tmplatesResponse) { + var templatesInfo = translateToTemplatesInfo(tmplatesResponse); + defer.resolve(templatesInfo); + } + ) + return defer; +} + +/** + * query templates + * @returns + */ +function queryTemplates() { + var queryTemplatesUrl = '/openoapi/catalog/v1/servicetemplates'; + return $.ajax({ + type : "GET", + url : queryTemplatesUrl + }); +} + +/** + * generate templates html string + * @param templates + * @returns + */ +function translateToTemplatesInfo(templates) { + var options = ''; + var i; + for (i = 0; i < templates.length; i += 1) { + var option = ''; + options = options + option; + } + return options; +} + /*******************************************Get Service**********************************************/ function loadGetServiceData(){ - var requestUrl = url + "/openoapi/inventory/v1/services"; + var returnVal; + var requestUrl = "/openoapi/inventory/v1/services"; $ .ajax({ type : "POST", url : requestUrl, + async: false, contentType : "application/json", success : function(jsonobj) { // TODO return according to the json data received. - return jsonobj; + returnVal = jsonobj; }, error : function(xhr, ajaxOptions, thrownError) { alert("Error on getting link data : " + xhr.responseText); } }); + return returnVal; } /*********************************************Get Service Details********************************************/ function loadServiceDetails(serviceId){ // TODO re-confirm the latest url. - var requestUrl = url + "/openoapi/lifecyclemgr/v1/services/toposequence/" + serviceId; + var requestUrl ="/openoapi/gso/v1/services/toposequence/" + serviceId; + var returnObj; $ .ajax({ type : "GET", + async: false, url : requestUrl, contentType : "application/json", success : function(jsonobj) { // TODO return according to the json data received. - return jsonobj; + returnObj = jsonobj; }, error : function(xhr, ajaxOptions, thrownError) { alert("Error on getting link data : " + xhr.responseText); } }); + return returnObj; } function anchorClick(serviceId){ -- cgit 1.2.3-korg