diff options
author | Iftekharul Islam <iffy.ryan@ibm.com> | 2017-11-02 13:23:08 -0500 |
---|---|---|
committer | Iftekharul Islam <iffy.ryan@ibm.com> | 2017-11-02 13:23:08 -0500 |
commit | 2a4895547294a5c32eeb2302739f5ce80626520a (patch) | |
tree | 3b35a8eb655a8c4500012a311a7cce210595c837 /app/common/services | |
parent | 1acb412d46571b39f01f058f0b7830b4cfa4877b (diff) | |
download | phosphor-webui-2a4895547294a5c32eeb2302739f5ce80626520a.tar.gz phosphor-webui-2a4895547294a5c32eeb2302739f5ce80626520a.zip |
Updating network settings
Adding display network settings info in network settings page
Change-Id: I5ab3b399445b8d2d6422f907dc4c5a477bfc794d
Signed-off-by: Iftekharul Islam <iffy.ryan@ibm.com>
Diffstat (limited to 'app/common/services')
-rw-r--r-- | app/common/services/api-utils.js | 105 | ||||
-rw-r--r-- | app/common/services/constants.js | 1 |
2 files changed, 100 insertions, 6 deletions
diff --git a/app/common/services/api-utils.js b/app/common/services/api-utils.js index c17577c..a7a6a58 100644 --- a/app/common/services/api-utils.js +++ b/app/common/services/api-utils.js @@ -72,6 +72,55 @@ window.angular && (function (angular) { var hostname = ""; var macAddress = ""; + function parseNetworkData(content){ + var data = { + interface_ids: [], + interfaces: { + } + }; + var interfaceId = '', keyParts = [], interfaceHash = '', interfaceType = ''; + for(var key in content.data){ + if(key.match(/network\/eth\d+$/ig)){ + interfaceId = key.split("/").pop(); + if(data.interface_ids.indexOf(interfaceId) == -1){ + data.interface_ids.push(interfaceId); + data.interfaces[interfaceId] = { + interfaceIname: '', + domainName:'', + MACAddress:'', + Nameservers: [], + DHCPEnabled: 0, + ipv4: + { + ids: [], + values: [] + }, + ipv6: + { + ids: [], + values: [] + } + }; + data.interfaces[interfaceId].MACAddress = content.data[key].MACAddress; + data.interfaces[interfaceId].DomainName = content.data[key].DomainName.join(" "); + data.interfaces[interfaceId].Nameservers = content.data[key].Nameservers; + data.interfaces[interfaceId].DHCPEnabled = content.data[key].DHCPEnabled; + } + }else if(key.match(/network\/eth\d+\/ipv[4|6]\/[a-z0-9]+$/ig)){ + keyParts = key.split("/"); + interfaceHash = keyParts.pop(); + interfaceType = keyParts.pop(); + interfaceId = keyParts.pop(); + + if(data.interfaces[interfaceId][interfaceType].ids.indexOf(interfaceHash) == -1){ + data.interfaces[interfaceId][interfaceType].ids.push(interfaceHash); + data.interfaces[interfaceId][interfaceType].values.push(content.data[key]); + } + } + } + return data; + } + if(content.data.hasOwnProperty('/xyz/openbmc_project/network/config') && content.data['/xyz/openbmc_project/network/config'].hasOwnProperty('HostName') ){ @@ -88,6 +137,7 @@ window.angular && (function (angular) { data: content.data, hostname: hostname, mac_address: macAddress, + formatted_data: parseNetworkData(content) }); }).error(function(error){ console.log(error); @@ -594,7 +644,7 @@ window.angular && (function (angular) { if(content.data.hasOwnProperty(key) && content.data[key].hasOwnProperty('Version')){ functional = (content.data[key].Priority == 0); - active = (/\.Active$/).test(content.data[key].Activation); + active = !functional && (/\.Active$/).test(content.data[key].Activation); ready = (/\.Ready$/).test(content.data[key].Activation); activationStatus = {functional: functional, active: active, ready: ready}; imageType = content.data[key].Purpose.split(".").pop(); @@ -644,8 +694,8 @@ window.angular && (function (angular) { method: 'PUT', url: DataService.getHost() + "/xyz/openbmc_project/software/" + imageId + "/attr/Priority", headers: { - 'Accept': 'application/octet-stream', - 'Content-Type': 'application/octet-stream' + 'Accept': 'application/json', + 'Content-Type': 'application/json' }, withCredentials: true, data: JSON.stringify({"data": priority}) @@ -660,15 +710,58 @@ window.angular && (function (angular) { return deferred.promise; }, - uploadImage: function(file){ + deleteImage: function(imageId){ + var deferred = $q.defer(); + $http({ + method: 'POST', + url: DataService.getHost() + "/xyz/openbmc_project/software/" + imageId + "/action/Delete", + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json' + }, + withCredentials: true, + data: JSON.stringify({"data": []}) + }).success(function(response){ + var json = JSON.stringify(response); + var content = JSON.parse(json); + deferred.resolve(content); + }).error(function(error){ + console.log(error); + deferred.reject(error); + }); + + return deferred.promise; + }, + activateImage: function(imageId){ var deferred = $q.defer(); $http({ method: 'PUT', + url: DataService.getHost() + "/xyz/openbmc_project/software/" + imageId + "/attr/RequestedActivation", + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json' + }, + withCredentials: true, + data: JSON.stringify({"data": Constants.FIRMWARE.ACTIVATE_FIRMWARE}) + }).success(function(response){ + var json = JSON.stringify(response); + var content = JSON.parse(json); + deferred.resolve(content); + }).error(function(error){ + console.log(error); + deferred.reject(error); + }); + + return deferred.promise; + }, + uploadImage: function(file){ + var deferred = $q.defer(); + $http({ + method: 'POST', timeout: 5 * 60 * 1000, url: DataService.getHost() + "/upload/image/", headers: { - 'Accept': 'application/octet-stream', - 'Content-Type': 'application/octet-stream' + 'Content-Type': 'application/octet-stream' }, withCredentials: true, data: file diff --git a/app/common/services/constants.js b/app/common/services/constants.js index 4852954..76bc590 100644 --- a/app/common/services/constants.js +++ b/app/common/services/constants.js @@ -111,6 +111,7 @@ window.angular && (function (angular) { ], SENSOR_SORT_ORDER_DEFAULT: 8, FIRMWARE: { + ACTIVATE_FIRMWARE: 'xyz.openbmc_project.Software.Activation.RequestedActivations.Active', FALLBACK_DOWNLOAD_FILENAME: 'firmware_download.tar', TYPES: { Functional: 'Functional', |