Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 1 | /** |
| 2 | * Controller for date-time |
| 3 | * |
| 4 | * @module app/configuration |
| 5 | * @exports dateTimeController |
| 6 | * @name dateTimeController |
Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 7 | */ |
| 8 | |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 9 | window.angular && (function(angular) { |
| 10 | 'use strict'; |
Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 11 | |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 12 | angular.module('app.configuration').controller('dateTimeController', [ |
Gunnar Mills | 7de3866 | 2018-07-18 13:01:48 -0500 | [diff] [blame] | 13 | '$scope', '$window', 'APIUtils', |
| 14 | function($scope, $window, APIUtils) { |
| 15 | $scope.bmc_time = ''; |
Gunnar Mills | c74d434 | 2018-07-18 14:52:02 -0500 | [diff] [blame^] | 16 | $scope.time_mode = ''; |
| 17 | $scope.time_owner = ''; |
Gunnar Mills | 7de3866 | 2018-07-18 13:01:48 -0500 | [diff] [blame] | 18 | $scope.loading = true; |
| 19 | |
Gunnar Mills | c74d434 | 2018-07-18 14:52:02 -0500 | [diff] [blame^] | 20 | var getTimePromise = APIUtils.getTime().then( |
Gunnar Mills | 7de3866 | 2018-07-18 13:01:48 -0500 | [diff] [blame] | 21 | function(data) { |
Gunnar Mills | c74d434 | 2018-07-18 14:52:02 -0500 | [diff] [blame^] | 22 | $scope.bmc_time = |
| 23 | data.data['/xyz/openbmc_project/time/bmc'].Elapsed / 1000; |
| 24 | $scope.time_owner = data.data['/xyz/openbmc_project/time/owner'] |
| 25 | .TimeOwner.split('.') |
| 26 | .pop(); |
| 27 | $scope.time_mode = |
| 28 | data.data['/xyz/openbmc_project/time/sync_method'] |
| 29 | .TimeSyncMethod.split('.') |
| 30 | .pop(); |
Gunnar Mills | 7de3866 | 2018-07-18 13:01:48 -0500 | [diff] [blame] | 31 | }, |
| 32 | function(error) { |
| 33 | console.log(JSON.stringify(error)); |
| 34 | }); |
| 35 | |
Gunnar Mills | c74d434 | 2018-07-18 14:52:02 -0500 | [diff] [blame^] | 36 | getTimePromise.finally(function() { |
Gunnar Mills | 7de3866 | 2018-07-18 13:01:48 -0500 | [diff] [blame] | 37 | $scope.loading = false; |
| 38 | }); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 39 | } |
| 40 | ]); |
Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 41 | })(angular); |