diff options
author | 2016-09-23 21:52:17 +0800 | |
---|---|---|
committer | 2016-09-23 21:52:17 +0800 | |
commit | 985b2108a6437173d4364238c13a98d13d1c7083 (patch) | |
tree | 6e0f3def4d538cc27bd622c0e165fd66548df1d0 /openo-portal/portal-resmgr/src/main/webapp/resmgr-nfv/js | |
parent | 540f0bf70e65f982bdae95d3fb3a95db5a66bbe7 (diff) |
formatting the code, removing unnecessary imports and URL patterns correction
Change-Id: I44ef8d3318e222cf6cdbccfb717f22b05dd6cb01
Signed-off-by: Seshu-Kumar-M <seshu.kumar.m@huawei.com>
Diffstat (limited to 'openo-portal/portal-resmgr/src/main/webapp/resmgr-nfv/js')
5 files changed, 515 insertions, 520 deletions
diff --git a/openo-portal/portal-resmgr/src/main/webapp/resmgr-nfv/js/SendMsg.js b/openo-portal/portal-resmgr/src/main/webapp/resmgr-nfv/js/SendMsg.js index b898d6ad..e42c0333 100644 --- a/openo-portal/portal-resmgr/src/main/webapp/resmgr-nfv/js/SendMsg.js +++ b/openo-portal/portal-resmgr/src/main/webapp/resmgr-nfv/js/SendMsg.js @@ -1,20 +1,20 @@ var sendMsg = { - get : "get", - post : "post" + get: "get", + post: "post" } function request(url, requestType, data, success, error, async) { - var setting = { - url : url, - async : async ? async : false, - type : requestType, - dataType : "json", - contentType : 'application/json;charset=UTF-8', - data : data, - success : success, - error : error - } + var setting = { + url: url, + async: async ? async : false, + type: requestType, + dataType: "json", + contentType: 'application/json;charset=UTF-8', + data: data, + success: success, + error: error + } - $.ajax(setting); + $.ajax(setting); }
\ No newline at end of file diff --git a/openo-portal/portal-resmgr/src/main/webapp/resmgr-nfv/js/datacenter.js b/openo-portal/portal-resmgr/src/main/webapp/resmgr-nfv/js/datacenter.js index 44b464e3..e3ff681a 100644 --- a/openo-portal/portal-resmgr/src/main/webapp/resmgr-nfv/js/datacenter.js +++ b/openo-portal/portal-resmgr/src/main/webapp/resmgr-nfv/js/datacenter.js @@ -1,247 +1,246 @@ -function hideFirstCol(){ +function hideFirstCol() { // $('table tr').find('th:eq(0)').hide(); // $('table tr').find('td:eq(0)').hide(); } function deleteDatacenter(objectId) { - var requestUrl = "/resmgr/rest/openoapi/resmgr/v1/datacenters/"+ objectId; - $.ajax({ - type : "DELETE", - url : requestUrl, - contentType : "application/json", - success : function(jsonobj) { - $('#Datacenter_table').bootstrapTable('remove', { - field : 'id', - values : [ objectId ] - }); - bootbox.alert("Delete successfull !!!"); - }, - error : function(xhr, ajaxOptions, thrownError) { - bootbox.alert("Error on deleting data: " + xhr.responseText); - } - }); + var requestUrl = "/resmgr/rest/openoapi/resmgr/v1/datacenters/" + objectId; + $.ajax({ + type: "DELETE", + url: requestUrl, + contentType: "application/json", + success: function (jsonobj) { + $('#Datacenter_table').bootstrapTable('remove', { + field: 'id', + values: [objectId] + }); + bootbox.alert("Delete successfull !!!"); + }, + error: function (xhr, ajaxOptions, thrownError) { + bootbox.alert("Error on deleting data: " + xhr.responseText); + } + }); } function loadDatacenterData() { - var requestUrl = "/resmgr/rest/openoapi/resmgr/v1/datacenters"; - $.ajax({ - type : "GET", - url : requestUrl, - contentType : "application/json", - success : function(jsonobj) { - $.each(jsonobj.datacenters,function(n,v){ - v.cpu= "used:"+v.usedCPU+"<br>total:"+v.totalCPU; - v.memory="used:"+v.usedMemory+"<br>total:"+v.totalMemory; - v.hardDisk="used:"+v.usedDisk+"<br>total:"+v.totalDisk; + var requestUrl = "/resmgr/rest/openoapi/resmgr/v1/datacenters"; + $.ajax({ + type: "GET", + url: requestUrl, + contentType: "application/json", + success: function (jsonobj) { + $.each(jsonobj.datacenters, function (n, v) { + v.cpu = "used:" + v.usedCPU + "<br>total:" + v.totalCPU; + v.memory = "used:" + v.usedMemory + "<br>total:" + v.totalMemory; + v.hardDisk = "used:" + v.usedDisk + "<br>total:" + v.totalDisk; + }); + $('#Datacenter_table').bootstrapTable({ + data: jsonobj.datacenters }); - $('#Datacenter_table').bootstrapTable({ - data : jsonobj.datacenters - }); - $('#Datacenter_table').bootstrapTable('refresh'); - hideFirstCol(); - }, - error : function(xhr, ajaxOptions, thrownError) { - bootbox.alert("Error on getting site data : " + xhr.responseText); - } - }); + $('#Datacenter_table').bootstrapTable('refresh'); + hideFirstCol(); + }, + error: function (xhr, ajaxOptions, thrownError) { + bootbox.alert("Error on getting site data : " + xhr.responseText); + } + }); } function loadNetWorkData() { - var requestUrl = "/resmgr/rest/openoapi/resmgr/v1/networks"; - $.ajax({ - type : "GET", - url : requestUrl, - contentType : "application/json", - success : function(jsonobj) { - $('#network_table').bootstrapTable({ - data : jsonobj.networks - }); - }, - error : function(xhr, ajaxOptions, thrownError) { - bootbox.alert("Error on getting site data : " + xhr.responseText); - } - }); + var requestUrl = "/resmgr/rest/openoapi/resmgr/v1/networks"; + $.ajax({ + type: "GET", + url: requestUrl, + contentType: "application/json", + success: function (jsonobj) { + $('#network_table').bootstrapTable({ + data: jsonobj.networks + }); + }, + error: function (xhr, ajaxOptions, thrownError) { + bootbox.alert("Error on getting site data : " + xhr.responseText); + } + }); } function loadPortData() { - var requestUrl = "/resmgr/rest/openoapi/resmgr/v1/ports"; - $.ajax({ - type : "GET", - url : requestUrl, - contentType : "application/json", - success : function(jsonobj) { - $('#port_table').bootstrapTable({ - data : jsonobj.ports - }); - }, - error : function(xhr, ajaxOptions, thrownError) { - bootbox.alert("Error on getting site data : " + xhr.responseText); - } - }); + var requestUrl = "/resmgr/rest/openoapi/resmgr/v1/ports"; + $.ajax({ + type: "GET", + url: requestUrl, + contentType: "application/json", + success: function (jsonobj) { + $('#port_table').bootstrapTable({ + data: jsonobj.ports + }); + }, + error: function (xhr, ajaxOptions, thrownError) { + bootbox.alert("Error on getting site data : " + xhr.responseText); + } + }); } function loadHostData() { - var requestUrl = "/resmgr/rest/openoapi/resmgr/v1/hosts"; - $.ajax({ - type : "GET", - url : requestUrl, - contentType : "application/json", - success : function(jsonobj) { - $('#host_table').bootstrapTable({ - data : jsonobj.hosts - }); - }, - error : function(xhr, ajaxOptions, thrownError) { - bootbox.alert("Error on getting site data : " + xhr.responseText); - } - }); + var requestUrl = "/resmgr/rest/openoapi/resmgr/v1/hosts"; + $.ajax({ + type: "GET", + url: requestUrl, + contentType: "application/json", + success: function (jsonobj) { + $('#host_table').bootstrapTable({ + data: jsonobj.hosts + }); + }, + error: function (xhr, ajaxOptions, thrownError) { + bootbox.alert("Error on getting site data : " + xhr.responseText); + } + }); } function fillCountryData() { - - var requestUrl = "/resmgr/rest/openoapi/resmgr/v1/locations/country"; - var htmlContent = ""; - $.ajax({ - type : "GET", - url : requestUrl, - contentType : "application/json", - success : function(jsonobj) { - var str = jsonobj.data.replace('[','').replace(']','').split(',') - $.each(str,function(n,v){ - htmlContent += "<option value='"+v+"'>"+v+"</option>"; - $("#country").html(htmlContent); - - }); - }, - error : function(xhr, ajaxOptions, thrownError) { - bootbox.alert("Error on getting country data : " + xhr.responseText); - } - }); + + var requestUrl = "/resmgr/rest/openoapi/resmgr/v1/locations/country"; + var htmlContent = ""; + $.ajax({ + type: "GET", + url: requestUrl, + contentType: "application/json", + success: function (jsonobj) { + var str = jsonobj.data.replace('[', '').replace(']', '').split(',') + $.each(str, function (n, v) { + htmlContent += "<option value='" + v + "'>" + v + "</option>"; + $("#country").html(htmlContent); + + }); + }, + error: function (xhr, ajaxOptions, thrownError) { + bootbox.alert("Error on getting country data : " + xhr.responseText); + } + }); } function fillVimNameData() { - - var requestUrl = "/resmgr/rest/openoapi/resmgr/v1/locations/cloudservice"; - var htmlContent = ""; - $.ajax({ - type : "GET", - url : requestUrl, - contentType : "application/json", - success : function(jsonobj) { - var str = jsonobj.data.replace('[','').replace(']','').split(',') - $.each(str,function(n,v){ - htmlContent += "<option value='"+v+"'>"+v+"</option>"; - $("#vimName").html(htmlContent); - + + var requestUrl = "/resmgr/rest/openoapi/resmgr/v1/locations/cloudservice"; + var htmlContent = ""; + $.ajax({ + type: "GET", + url: requestUrl, + contentType: "application/json", + success: function (jsonobj) { + var str = jsonobj.data.replace('[', '').replace(']', '').split(',') + $.each(str, function (n, v) { + htmlContent += "<option value='" + v + "'>" + v + "</option>"; + $("#vimName").html(htmlContent); + }); - }, - error : function(xhr, ajaxOptions, thrownError) { - bootbox.alert("Error on getting country data : " + xhr.responseText); - } - }); + }, + error: function (xhr, ajaxOptions, thrownError) { + bootbox.alert("Error on getting country data : " + xhr.responseText); + } + }); } -$(function() { - $("#vmAppForm").validate({ - rules: { - country: "required", - location: "required", - lantitude: "required", - longitude: "required" - } - }); - - $('.close,.button-previous').click(function() { - $('#vmAppDialog').removeClass('in').css('display', 'none'); - }); - $('.detail-top ul li').click(function() { - $(this).addClass('current').siblings().removeClass('current'); - }); - $('.basic').click(function() { - $('#flavorTab').css('display', 'none'); - }); - - $('.table tbody tr').click( - function() { - $(this).addClass('openoTable_row_selected').siblings() - .removeClass('openoTable_row_selected'); - }); - $('.table tr:odd').addClass('active'); - $('#false').click(function() { - $('#vmAppForm')[0].reset(); - $('#vmAppDialog').addClass('in').css({ - 'display' : 'block' - }); - }); - $('.close,.button-previous').click(function() { - $('#vmAppDialog').removeClass('in').css('display', 'none'); - }); - - $.fn.serializeObject = function() { - var o = {}; - var a = this.serializeArray(); - $.each(a, function() { - if (o[this.name] !== undefined) { - if (!o[this.name].push) { - o[this.name] = [ o[this.name] ]; - } - o[this.name].push(this.value || ''); - } else { - o[this.name] = this.value || ''; - } - }); - return o; - }; - $('#createDatacenter') - .click( - function() { - - - var formData = JSON.stringify($("#vmAppForm").serializeObject()); - var jsonobj = JSON.parse(formData); - var requestUrl = "/resmgr/rest/openoapi/resmgr/v1/datacenters"; - $.ajax({ - type : "POST", - url : requestUrl, - contentType : "application/json", - dataType : "json", - data : formData, - success : function(jsonResp) { - loadDatacenterData(); - bootbox.alert(jsonResp.msg); - $('#vmAppDialog').removeClass('in').css({ - 'display' : 'none' - }); - }, - error : function(xhr, ajaxOptions, thrownError) { - bootbox.alert("Error on page : " + xhr.responseText); - } - }); - }); - - $('#country').change(function(){ - var country = $(this).children('option:selected').val(); - var requestUrl = "/resmgr/rest/openoapi/resmgr/v1/locations/locationbycountry?country="+country; - - var htmlContent = "<option value=''>--select--</option>"; - $.ajax({ - type : "GET", - url : requestUrl, - contentType : "application/json", - success : function(jsonobj) { - $.each(jsonobj.data,function(n,v){ - htmlContent += "<option value='"+v+"'>"+v+"</option>"; - $("#location").html(htmlContent); - - }); - - }, - error : function(xhr, ajaxOptions, thrownError) { - bootbox.alert("Error on getting location data : " + xhr.responseText); - } - }); - - }) - - +$(function () { + $("#vmAppForm").validate({ + rules: { + country: "required", + location: "required", + lantitude: "required", + longitude: "required" + } + }); + + $('.close,.button-previous').click(function () { + $('#vmAppDialog').removeClass('in').css('display', 'none'); + }); + $('.detail-top ul li').click(function () { + $(this).addClass('current').siblings().removeClass('current'); + }); + $('.basic').click(function () { + $('#flavorTab').css('display', 'none'); + }); + + $('.table tbody tr').click( + function () { + $(this).addClass('openoTable_row_selected').siblings() + .removeClass('openoTable_row_selected'); + }); + $('.table tr:odd').addClass('active'); + $('#false').click(function () { + $('#vmAppForm')[0].reset(); + $('#vmAppDialog').addClass('in').css({ + 'display': 'block' + }); + }); + $('.close,.button-previous').click(function () { + $('#vmAppDialog').removeClass('in').css('display', 'none'); + }); + + $.fn.serializeObject = function () { + var o = {}; + var a = this.serializeArray(); + $.each(a, function () { + if (o[this.name] !== undefined) { + if (!o[this.name].push) { + o[this.name] = [o[this.name]]; + } + o[this.name].push(this.value || ''); + } else { + o[this.name] = this.value || ''; + } + }); + return o; + }; + $('#createDatacenter') + .click( + function () { + + + var formData = JSON.stringify($("#vmAppForm").serializeObject()); + var jsonobj = JSON.parse(formData); + var requestUrl = "/resmgr/rest/openoapi/resmgr/v1/datacenters"; + $.ajax({ + type: "POST", + url: requestUrl, + contentType: "application/json", + dataType: "json", + data: formData, + success: function (jsonResp) { + loadDatacenterData(); + bootbox.alert(jsonResp.msg); + $('#vmAppDialog').removeClass('in').css({ + 'display': 'none' + }); + }, + error: function (xhr, ajaxOptions, thrownError) { + bootbox.alert("Error on page : " + xhr.responseText); + } + }); + }); + + $('#country').change(function () { + var country = $(this).children('option:selected').val(); + var requestUrl = "/resmgr/rest/openoapi/resmgr/v1/locations/locationbycountry?country=" + country; + + var htmlContent = "<option value=''>--select--</option>"; + $.ajax({ + type: "GET", + url: requestUrl, + contentType: "application/json", + success: function (jsonobj) { + $.each(jsonobj.data, function (n, v) { + htmlContent += "<option value='" + v + "'>" + v + "</option>"; + $("#location").html(htmlContent); + + }); + + }, + error: function (xhr, ajaxOptions, thrownError) { + bootbox.alert("Error on getting location data : " + xhr.responseText); + } + }); + + }) + })
\ No newline at end of file diff --git a/openo-portal/portal-resmgr/src/main/webapp/resmgr-nfv/js/resmgr.js b/openo-portal/portal-resmgr/src/main/webapp/resmgr-nfv/js/resmgr.js index 24804131..a0ad9921 100644 --- a/openo-portal/portal-resmgr/src/main/webapp/resmgr-nfv/js/resmgr.js +++ b/openo-portal/portal-resmgr/src/main/webapp/resmgr-nfv/js/resmgr.js @@ -1,202 +1,198 @@ -function hideFirstCol(){ +function hideFirstCol() { // $('table tr').find('th:eq(0)').hide(); // $('table tr').find('td:eq(0)').hide(); } function deleteLocation(objectId) { - var requestUrl = "/resmgr/rest/openoapi/resmgr/v1/locations/"+ objectId; - $.ajax({ - type : "DELETE", - url : requestUrl, - contentType : "application/json", - success : function(jsonobj) { - $('#location_table').bootstrapTable('remove', { - field : 'id', - values : [ objectId ] - }); - bootbox.alert("Delete successfull !!!"); - }, - error : function(xhr, ajaxOptions, thrownError) { - bootbox.alert("Error on deleting data: " + xhr.responseText); - } - }); + var requestUrl = "/resmgr/rest/openoapi/resmgr/v1/locations/" + objectId; + $.ajax({ + type: "DELETE", + url: requestUrl, + contentType: "application/json", + success: function (jsonobj) { + $('#location_table').bootstrapTable('remove', { + field: 'id', + values: [objectId] + }); + bootbox.alert("Delete successfull !!!"); + }, + error: function (xhr, ajaxOptions, thrownError) { + bootbox.alert("Error on deleting data: " + xhr.responseText); + } + }); } function editLocation(row) { - $('#vmAppDialog').addClass('in').css({ - 'display' : 'block' - }); - $('#id').val(row.id); - $('#country').val(row.country); - $('#location').val(row.location); - $('#description').val(row.description); - $('#latitude').val(row.latitude); - $('#longitude').val(row.longitude); + $('#vmAppDialog').addClass('in').css({ + 'display': 'block' + }); + $('#id').val(row.id); + $('#country').val(row.country); + $('#location').val(row.location); + $('#description').val(row.description); + $('#latitude').val(row.latitude); + $('#longitude').val(row.longitude); } function loadLocationData() { - var requestUrl = "/resmgr/rest/openoapi/resmgr/v1/locations"; - $.ajax({ - type : "GET", - url : requestUrl, - contentType : "application/json", - success : function(jsonobj) { - $('#location_table').bootstrapTable({ - pageSize: 50, - striped: true, - data : jsonobj.locations - }); - $('#location_table').bootstrapTable('refresh'); - - }, - error : function(xhr, ajaxOptions, thrownError) { - bootbox.alert("Error on getting site data : " + xhr.responseText); - } - }); - + var requestUrl = "/resmgr/rest/openoapi/resmgr/v1/locations"; + $.ajax({ + type: "GET", + url: requestUrl, + contentType: "application/json", + success: function (jsonobj) { + $('#location_table').bootstrapTable({ + pageSize: 50, + striped: true, + data: jsonobj.locations + }); + $('#location_table').bootstrapTable('refresh'); + + }, + error: function (xhr, ajaxOptions, thrownError) { + bootbox.alert("Error on getting site data : " + xhr.responseText); + } + }); + } -$(function() { - $("#vmAppForm").validate({ - rules: { - country: "required", - location: "required", - latitude: { - required: true, - number: true - }, - longitude: { - required: true, - number: true - } - } - }); - - $('.close,.button-previous').click(function() { - $('#vmAppDialog').removeClass('in').css('display', 'none'); - }); - $('.detail-top ul li').click(function() { - $(this).addClass('current').siblings().removeClass('current'); - }); - $('.para').click(function() { - if ($('#serviceTemplateName').val() == '') { - alert('Please choose the service templet!'); - $('#flavorTab').css('display', 'none'); - } else { - $('#flavorTab').css('display', 'block'); - } - $('#basicTab').css('display', 'block'); - }); - $('.basic').click(function() { - $('#flavorTab').css('display', 'none'); - }); - - $('.table tbody tr').click( - function() { - $(this).addClass('openoTable_row_selected').siblings() - .removeClass('openoTable_row_selected'); - }); - $('.table tr:odd').addClass('active'); - $('#false').click(function() { - $('#vmAppForm')[0].reset(); - $('#vmAppDialog').addClass('in').css({ - 'display' : 'block' - }); - }); - $('.close,.button-previous').click(function() { - $('#vmAppDialog').removeClass('in').css('display', 'none'); - }); - $('#filterTpLogicalType').click( - function() { - $('#filterTpLogicalType_select_popupcontainer').toggleClass( - 'openo-hide'); - $('#filterTpLogicalType').toggleClass('openo-focus'); - var oLeft = $('#open_base_tpL_td6').offset().left; - var oTop = $('#open_base_tpL_td6').offset().top; - var oHeight = $('#open_base_tpL_td6').height(); - $('#filterTpLogicalType_select_popupcontainer').css({ - 'left' : oLeft, - 'top' : oTop + oHeight + 10 - }); - }); - $('div.openo-select-popup-container>div.openo-select-item>label').click( - function() { - var Lvalue = $(this).html(); - $('#filterTpLogicalType_select_input').attr('value', Lvalue); - $('#filterTpLogicalType_select_popupcontainer').addClass( - 'openo-hide'); - $('#filterTpLogicalType').removeClass('openo-focus'); - }); - $.fn.serializeObject = function() { - var o = {}; - var a = this.serializeArray(); - $.each(a, function() { - if (o[this.name] !== undefined) { - if (!o[this.name].push) { - o[this.name] = [ o[this.name] ]; - } - o[this.name].push(this.value || ''); - } else { - o[this.name] = this.value || ''; - } - }); - return o; - }; - $('#createLocation') - .click( - - function() { - var formData = JSON.stringify($("#vmAppForm").serializeObject()); - var jsonobj = JSON.parse(formData); - var requestUrl = "/resmgr/rest/openoapi/resmgr/v1/locations"; - var requestUrl_query = "/resmgr/rest/openoapi/resmgr/v1/locations"; - if($('#id').val().length === 0){//create - - - $.ajax({ - type : "POST", - url : requestUrl, - contentType : "application/json", - dataType : "json", - data : formData, - success : function(jsonResp) { - loadLocationData(); - bootbox.alert(jsonResp.msg); - $('#vmAppDialog').removeClass('in').css({ - 'display' : 'none' - }); - - }, - error : function(xhr, ajaxOptions, thrownError) { - bootbox.alert("Error on page : " + xhr.responseText); - } - }); - }else{//put - - - $.ajax({ - type : "PUT", - url : requestUrl, - contentType : "application/json", - dataType : "json", - data : formData, - success : function(jsonResp) { - loadLocationData(); - bootbox.alert(jsonResp.msg); - $('#vmAppDialog').removeClass('in').css({ - 'display' : 'none' - }); - - }, - error : function(xhr, ajaxOptions, thrownError) { - bootbox.alert("Error on page : " + xhr.responseText); - } - }); - } - - }); - - - - +$(function () { + $("#vmAppForm").validate({ + rules: { + country: "required", + location: "required", + latitude: { + required: true, + number: true + }, + longitude: { + required: true, + number: true + } + } + }); + + $('.close,.button-previous').click(function () { + $('#vmAppDialog').removeClass('in').css('display', 'none'); + }); + $('.detail-top ul li').click(function () { + $(this).addClass('current').siblings().removeClass('current'); + }); + $('.para').click(function () { + if ($('#serviceTemplateName').val() == '') { + alert('Please choose the service templet!'); + $('#flavorTab').css('display', 'none'); + } else { + $('#flavorTab').css('display', 'block'); + } + $('#basicTab').css('display', 'block'); + }); + $('.basic').click(function () { + $('#flavorTab').css('display', 'none'); + }); + + $('.table tbody tr').click( + function () { + $(this).addClass('openoTable_row_selected').siblings() + .removeClass('openoTable_row_selected'); + }); + $('.table tr:odd').addClass('active'); + $('#false').click(function () { + $('#vmAppForm')[0].reset(); + $('#vmAppDialog').addClass('in').css({ + 'display': 'block' + }); + }); + $('.close,.button-previous').click(function () { + $('#vmAppDialog').removeClass('in').css('display', 'none'); + }); + $('#filterTpLogicalType').click( + function () { + $('#filterTpLogicalType_select_popupcontainer').toggleClass( + 'openo-hide'); + $('#filterTpLogicalType').toggleClass('openo-focus'); + var oLeft = $('#open_base_tpL_td6').offset().left; + var oTop = $('#open_base_tpL_td6').offset().top; + var oHeight = $('#open_base_tpL_td6').height(); + $('#filterTpLogicalType_select_popupcontainer').css({ + 'left': oLeft, + 'top': oTop + oHeight + 10 + }); + }); + $('div.openo-select-popup-container>div.openo-select-item>label').click( + function () { + var Lvalue = $(this).html(); + $('#filterTpLogicalType_select_input').attr('value', Lvalue); + $('#filterTpLogicalType_select_popupcontainer').addClass( + 'openo-hide'); + $('#filterTpLogicalType').removeClass('openo-focus'); + }); + $.fn.serializeObject = function () { + var o = {}; + var a = this.serializeArray(); + $.each(a, function () { + if (o[this.name] !== undefined) { + if (!o[this.name].push) { + o[this.name] = [o[this.name]]; + } + o[this.name].push(this.value || ''); + } else { + o[this.name] = this.value || ''; + } + }); + return o; + }; + $('#createLocation') + .click( + function () { + var formData = JSON.stringify($("#vmAppForm").serializeObject()); + var jsonobj = JSON.parse(formData); + var requestUrl = "/resmgr/rest/openoapi/resmgr/v1/locations"; + var requestUrl_query = "/resmgr/rest/openoapi/resmgr/v1/locations"; + if ($('#id').val().length === 0) {//create + + + $.ajax({ + type: "POST", + url: requestUrl, + contentType: "application/json", + dataType: "json", + data: formData, + success: function (jsonResp) { + loadLocationData(); + bootbox.alert(jsonResp.msg); + $('#vmAppDialog').removeClass('in').css({ + 'display': 'none' + }); + + }, + error: function (xhr, ajaxOptions, thrownError) { + bootbox.alert("Error on page : " + xhr.responseText); + } + }); + } else {//put + + + $.ajax({ + type: "PUT", + url: requestUrl, + contentType: "application/json", + dataType: "json", + data: formData, + success: function (jsonResp) { + loadLocationData(); + bootbox.alert(jsonResp.msg); + $('#vmAppDialog').removeClass('in').css({ + 'display': 'none' + }); + + }, + error: function (xhr, ajaxOptions, thrownError) { + bootbox.alert("Error on page : " + xhr.responseText); + } + }); + } + + }); + })
\ No newline at end of file diff --git a/openo-portal/portal-resmgr/src/main/webapp/resmgr-nfv/js/validateset.js b/openo-portal/portal-resmgr/src/main/webapp/resmgr-nfv/js/validateset.js index 5b44be87..d6e47d27 100644 --- a/openo-portal/portal-resmgr/src/main/webapp/resmgr-nfv/js/validateset.js +++ b/openo-portal/portal-resmgr/src/main/webapp/resmgr-nfv/js/validateset.js @@ -1,28 +1,28 @@ -$(function(){ - $.validator.setDefaults({ - onkeyup: null, - success: function(label){ - label.text('').addClass('valid'); - }, - onfocusin: function( element ) { - this.lastActive = element; - this.addWrapper(this.errorsFor(element)).hide(); - var tip = $(element).attr('tip'); - if(tip && $(element).parent().children(".tip").length === 0){ - $(element).parent().append("<label class='tip'>" + tip + "</label>"); - } - $(element).addClass('highlight'); - if ( this.settings.focusCleanup ) { - if ( this.settings.unhighlight ) { - this.settings.unhighlight.call( this, element, this.settings.errorClass, this.settings.validClass ); - } - this.hideThese( this.errorsFor( element ) ); - } - }, - onfocusout: function( element ) { - $(element).parent().children(".tip").remove(); - $(element).removeClass('highlight'); - this.element( element ); - } - }); +$(function () { + $.validator.setDefaults({ + onkeyup: null, + success: function (label) { + label.text('').addClass('valid'); + }, + onfocusin: function (element) { + this.lastActive = element; + this.addWrapper(this.errorsFor(element)).hide(); + var tip = $(element).attr('tip'); + if (tip && $(element).parent().children(".tip").length === 0) { + $(element).parent().append("<label class='tip'>" + tip + "</label>"); + } + $(element).addClass('highlight'); + if (this.settings.focusCleanup) { + if (this.settings.unhighlight) { + this.settings.unhighlight.call(this, element, this.settings.errorClass, this.settings.validClass); + } + this.hideThese(this.errorsFor(element)); + } + }, + onfocusout: function (element) { + $(element).parent().children(".tip").remove(); + $(element).removeClass('highlight'); + this.element(element); + } + }); });
\ No newline at end of file diff --git a/openo-portal/portal-resmgr/src/main/webapp/resmgr-nfv/js/vim.js b/openo-portal/portal-resmgr/src/main/webapp/resmgr-nfv/js/vim.js index 1a406f9c..6de43718 100644 --- a/openo-portal/portal-resmgr/src/main/webapp/resmgr-nfv/js/vim.js +++ b/openo-portal/portal-resmgr/src/main/webapp/resmgr-nfv/js/vim.js @@ -1,79 +1,79 @@ function loadVimData() { - var requestUrl = "/resmgr/rest/v1/resmanage/vim/vimInfo"; - $.ajax({ - type : "GET", - url : requestUrl, - contentType : "application/json", - success : function(jsonobj) { - printCharts(jsonobj.data[0].used.cpu, - jsonobj.data[0].total.cpu,jsonobj.data[0].used.memory,jsonobj.data[0].total.memory,jsonobj.data[0].used.disk,jsonobj.data[0].total.disk); + var requestUrl = "/resmgr/rest/v1/resmanage/vim/vimInfo"; + $.ajax({ + type: "GET", + url: requestUrl, + contentType: "application/json", + success: function (jsonobj) { + printCharts(jsonobj.data[0].used.cpu, + jsonobj.data[0].total.cpu, jsonobj.data[0].used.memory, jsonobj.data[0].total.memory, jsonobj.data[0].used.disk, jsonobj.data[0].total.disk); - }, - error : function(xhr, ajaxOptions, thrownError) { - bootbox.alert("Error on getting data (here display the test data) : " + xhr.responseText); - printCharts(11,12,21,22,31,32); - } - }); + }, + error: function (xhr, ajaxOptions, thrownError) { + bootbox.alert("Error on getting data (here display the test data) : " + xhr.responseText); + printCharts(11, 12, 21, 22, 31, 32); + } + }); } -function printCharts(v11,v12,v21,v22,v31,v32){ - var cpuChart = new Chart($("#cpuChart"), { - type : 'doughnut', - data : { - labels : ["used", "available" ], - datasets : [ { - data : [v11,v12], - backgroundColor : ["#FFCE56","#36A2EB"], - hoverBackgroundColor : ["#FFCE56","#36A2EB"] - } ] - }, - options : { - animation:{ - animateScale:true, - animateRotate:true - - } - } - }); - var memoryChart = new Chart($("#memoryChart"), { - type : 'doughnut', - data : { - labels : [ "used", "available"], - datasets : [ { - data : [v21,v22], - backgroundColor : [ "#FF6384", "#36A2EB"], - hoverBackgroundColor : [ "#FF6384", "#36A2EB"] - } ] - }, - options : { - - animation:{ - animateScale:true, - animateRotate:true - - } - } - }); - var diskChart = new Chart($("#diskChart"), { - type : 'doughnut', - data : { - labels : [ "used", "available"], - datasets : [ { - data : [v31,v32], - backgroundColor : [ "#FF6384", "green" ], - hoverBackgroundColor : [ "#FF6384", "green" ] - } ] - }, - options : { - animation:{ - animateScale:true, - animateRotate:true - - } - } - }); +function printCharts(v11, v12, v21, v22, v31, v32) { + var cpuChart = new Chart($("#cpuChart"), { + type: 'doughnut', + data: { + labels: ["used", "available"], + datasets: [{ + data: [v11, v12], + backgroundColor: ["#FFCE56", "#36A2EB"], + hoverBackgroundColor: ["#FFCE56", "#36A2EB"] + }] + }, + options: { + animation: { + animateScale: true, + animateRotate: true + + } + } + }); + var memoryChart = new Chart($("#memoryChart"), { + type: 'doughnut', + data: { + labels: ["used", "available"], + datasets: [{ + data: [v21, v22], + backgroundColor: ["#FF6384", "#36A2EB"], + hoverBackgroundColor: ["#FF6384", "#36A2EB"] + }] + }, + options: { + + animation: { + animateScale: true, + animateRotate: true + + } + } + }); + var diskChart = new Chart($("#diskChart"), { + type: 'doughnut', + data: { + labels: ["used", "available"], + datasets: [{ + data: [v31, v32], + backgroundColor: ["#FF6384", "green"], + hoverBackgroundColor: ["#FF6384", "green"] + }] + }, + options: { + animation: { + animateScale: true, + animateRotate: true + + } + } + }); } -$(function() { - loadVimData(); - +$(function () { + loadVimData(); + })
\ No newline at end of file |