Get the BMC time
Get the BMC time from xyz/openbmc_project/time/bmc.
This time is in epoch time so convert.
Before the time and date hardcoded.
From https://docs.angularjs.org/api/ng/filter/date:
"'medium': equivalent to 'MMM d, y h:mm:ss a' for en_US locale
(e.g. Sep 3, 2010 12:05:08 PM)"
This is a similar format as to what was present on the GUI
before for en_US.
Letting the browser choose the format, is important.
Displayed in user's timezone.
Resolves openbmc/openbmc#3116
Tested: Now see correct date and time, "4/19/2018, 20:31:18 UTC"
Change-Id: Ie30c65b038b58afc8c4c77ca5b70667e80e76cc6
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/app/common/services/api-utils.js b/app/common/services/api-utils.js
index 12377c5..fcd873c 100644
--- a/app/common/services/api-utils.js
+++ b/app/common/services/api-utils.js
@@ -897,6 +897,19 @@
return response.data;
});
},
+ getBMCTime: function(){
+ return $http({
+ method: 'GET',
+ url: DataService.getHost() + "/xyz/openbmc_project/time/bmc",
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json'
+ },
+ withCredentials: true
+ }).then(function(response){
+ return response.data;
+ });
+ },
getHardwares: function(callback){
$http({
method: 'GET',
diff --git a/app/overview/controllers/system-overview-controller.html b/app/overview/controllers/system-overview-controller.html
index d7069ad..295aac6 100644
--- a/app/overview/controllers/system-overview-controller.html
+++ b/app/overview/controllers/system-overview-controller.html
@@ -86,7 +86,7 @@
</a>
<div class="quick-links__item no-icon">
<p class="inline quick-links__label">BMC time</p>
- <p class="inline courier-bold float-right">3:20:12 5/22/2017 UTC</p>
+ <p class="inline courier-bold float-right">{{bmc_time | date:'medium'}}</p>
</div>
<div class="quick-links__item no-icon">
<p class="inline quick-links__label">Turn <span ng-if="dataService.LED_state == 'off'">on</span><span ng-if="dataService.LED_state == 'on'">off</span> server LED</p>
diff --git a/app/overview/controllers/system-overview-controller.js b/app/overview/controllers/system-overview-controller.js
index 6698962..87fcf4e 100644
--- a/app/overview/controllers/system-overview-controller.js
+++ b/app/overview/controllers/system-overview-controller.js
@@ -26,6 +26,7 @@
$scope.bmc_info = {};
$scope.server_info = {};
$scope.bmc_firmware = "";
+ $scope.bmc_time = "";
$scope.server_firmware = "";
$scope.power_consumption = "";
$scope.power_cap = "";
@@ -40,6 +41,7 @@
led: APIUtils.getLEDState(),
ethernet: APIUtils.getBMCEthernetInfo(),
bmc_info: APIUtils.getBMCInfo(),
+ bmc_time: APIUtils.getBMCTime(),
server_info: APIUtils.getServerInfo(),
power_consumption: APIUtils.getPowerConsumption(),
power_cap: APIUtils.getPowerCap(),
@@ -57,6 +59,7 @@
data.bmc_info,
data.firmware.bmcActiveVersion
);
+ $scope.displayBMCTime(data.bmc_time);
$scope.displayPowerConsumption(data.power_consumption);
$scope.displayPowerCap(data.power_cap);
})
@@ -73,6 +76,10 @@
$scope.bmc_firmware = bmcActiveVersion;
}
+ $scope.displayBMCTime = function(data){
+ $scope.bmc_time = data.data.Elapsed / 1000;
+ }
+
$scope.displayLogs = function(data){
$scope.logs = data.filter(function(log){
return log.severity_flags.high == true;