diff options
author | j00302280 <j00101220@huawei.com> | 2016-10-21 18:38:31 +0800 |
---|---|---|
committer | j00302280 <j00101220@huawei.com> | 2016-10-21 18:38:31 +0800 |
commit | 3dbf095cd98c2f866b826540a05373be481402fe (patch) | |
tree | 2157b6e3fa1f374c03bf24bf04d33d28522d7f00 /openo-portal/portal-lifecyclemgr/src | |
parent | 7dec37dcd99fff5bc47b4e41a37f6f5eeb7c080d (diff) |
Issue ID: GSO-37
Change-Id: I04c4438a2f4efa20486362da98c1e37bdc7fda10
Signed-off-by: j00302280 <j00101220@huawei.com>
Diffstat (limited to 'openo-portal/portal-lifecyclemgr/src')
-rw-r--r-- | openo-portal/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/js/rest.js | 67 |
1 files changed, 63 insertions, 4 deletions
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 = '<option value="select">--select--</option>';
+ var i;
+ for (i = 0; i < templates.length; i += 1) {
+ var option = '<option value="' + templates[i].serviceTemplateId + '">' + templates[i].templateName
+ + '</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){
|