diff options
| author | Gunnar Mills <gmills@us.ibm.com> | 2018-10-13 16:56:10 -0500 |
|---|---|---|
| committer | Gunnar Mills <gmills@us.ibm.com> | 2018-10-19 19:54:25 +0000 |
| commit | 2f955bd86bfd9d9eb55f4bd125acc177cd1a1dcf (patch) | |
| tree | 3026770eeb30ee767484dde403a97b2f09c987b6 /app/configuration | |
| parent | 335ac3449f2ca22332ff1d5498add061f4bdc182 (diff) | |
| download | phosphor-webui-2f955bd86bfd9d9eb55f4bd125acc177cd1a1dcf.tar.gz phosphor-webui-2f955bd86bfd9d9eb55f4bd125acc177cd1a1dcf.zip | |
Date-time: Use lowerCamelCase for vars
Following https://google.github.io/styleguide/jsguide.html.
Also, added a comment to clarify a variable.
Change-Id: I27dd8c0af6187ccd3f8093b88ebe2674fd42747b
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
Diffstat (limited to 'app/configuration')
| -rw-r--r-- | app/configuration/controllers/date-time-controller.html | 22 | ||||
| -rw-r--r-- | app/configuration/controllers/date-time-controller.js | 61 |
2 files changed, 42 insertions, 41 deletions
diff --git a/app/configuration/controllers/date-time-controller.html b/app/configuration/controllers/date-time-controller.html index 8ead4c8..23a93d2 100644 --- a/app/configuration/controllers/date-time-controller.html +++ b/app/configuration/controllers/date-time-controller.html @@ -11,7 +11,7 @@ <div class="column large-8"> <div class="row column"> <label class="control-radio" for="ntp-time">Obtain Automatically from a Network Time Protocol (NTP) Server - <input type="radio" id="ntp-time" ng-model="time_mode" value="NTP"> + <input type="radio" id="ntp-time" ng-model="time.mode" value="NTP"> <span class="control__indicator control__indicator-on"></span> </label> </div> @@ -19,7 +19,7 @@ <fieldset class="date-time__ntp-servers" ng-repeat="server in ntp.servers track by $index"> <label for="ntp-server{{$index+1}}">NTP Server Address {{$index+1}} <span ng-if="$first">(Primary)</span></label> <div class="inline"> - <input id="ntp-server{{$index+1}}" type="text" ng-readonly="time_mode != 'NTP'" ng-model="server" ng-blur="ntp.servers[$index] = server" set-focus-on-new-input/> + <input id="ntp-server{{$index+1}}" type="text" ng-readonly="time.mode != 'NTP'" ng-model="server" ng-blur="ntp.servers[$index] = server" set-focus-on-new-input/> </div> <button class="date-time__dns-remove inline" ng-click="removeNTPField($index)">Remove</button> </fieldset> @@ -29,20 +29,20 @@ </div> <div class="row column"> <label class="control-radio" for="manual-time">Manually set date and time - <input type="radio" id="manual-time" ng-model="time_mode" value="Manual"/> + <input type="radio" id="manual-time" ng-model="time.mode" value="Manual"/> <span class="control__indicator control__indicator-on"></span> </label> </div> <ul class="date-time__metadata-wrapper"> <li class="date-time__metadata-block"> - <p class="content-label">BMC <span ng-if="time_owner != 'Split'">and Host</span> Time</p> + <p class="content-label">BMC <span ng-if="time.owner != 'Split'">and Host</span> Time</p> <div class="inline"> - <input type="date" ng-model="bmc.date" ng-readonly="time_mode == 'NTP'" min="2018-01-01" max="2099-12-31"/> - <input type="time" ng-model="bmc.date" ng-readonly="time_mode == 'NTP'" /> + <input type="date" ng-model="bmc.date" ng-readonly="time.mode == 'NTP'" min="2018-01-01" max="2099-12-31"/> + <input type="time" ng-model="bmc.date" ng-readonly="time.mode == 'NTP'" /> <p class="courier-bold">{{bmc.timezone}}</p> </div> </li> - <li class="date-time__metadata-block" ng-if="time_owner == 'Split'"> + <li class="date-time__metadata-block" ng-if="time.owner == 'Split'"> <p class="content-label">Host Time</p> <div class="inline"> <!--- Ideally, would just use one input, datetime-local, but datetime-local is not supported on Firefox.---> @@ -53,8 +53,8 @@ </li> <li class="date-time__metadata-block"> <label class="content-label">Time Owner</label> - <select ng-model="time_owner" class="date-time__owner-dropdown"> - <option class="courier-bold" ng-repeat="owner in time_owners">{{owner}}</option> + <select ng-model="time.owner" class="date-time__owner-dropdown"> + <option class="courier-bold" ng-repeat="owner in timeOwners">{{owner}}</option> </select> </li> </ul> @@ -64,7 +64,7 @@ <button type="button" class="btn-primary inline" ng-click="setTime()">Save settings</button> <button type="button" class="btn-secondary inline" ng-click="refresh()">Cancel</button> </div> - <p class="success-msg" ng-show="set_time_success" role="alert">Success! Time changed!</p> - <p class="set_time_error error-msg" ng-show="set_time_error" role="alert">Error setting time!</p> + <p class="success-msg" ng-show="success" role="alert">Success! Time changed!</p> + <p class="set_time_error error-msg" ng-show="error" role="alert">Error setting time!</p> </form> </div> diff --git a/app/configuration/controllers/date-time-controller.js b/app/configuration/controllers/date-time-controller.js index 0f6ecf9..aca4c4c 100644 --- a/app/configuration/controllers/date-time-controller.js +++ b/app/configuration/controllers/date-time-controller.js @@ -16,22 +16,23 @@ window.angular && (function(angular) { // Only used when the owner is "Split" $scope.host = {}; $scope.ntp = {servers: []}; - $scope.time_mode = ''; - $scope.time_owner = ''; - $scope.time_owners = ['BMC', 'Host', 'Both', 'Split']; - $scope.set_time_error = false; - $scope.set_time_success = false; + $scope.time = {mode: '', owner: ''}; + // Possible time owners + // https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/xyz/openbmc_project/Time/Owner.interface.yaml#L13 + $scope.timeOwners = ['BMC', 'Host', 'Both', 'Split']; + $scope.error = false; + $scope.success = false; $scope.loading = true; - var time_path = '/xyz/openbmc_project/time/'; + var timePath = '/xyz/openbmc_project/time/'; var getTimePromise = APIUtils.getTime().then( function(data) { // The time is returned as Epoch microseconds convert to // milliseconds. - if (data.data[time_path + 'bmc'] && - data.data[time_path + 'bmc'].hasOwnProperty('Elapsed')) { + if (data.data[timePath + 'bmc'] && + data.data[timePath + 'bmc'].hasOwnProperty('Elapsed')) { $scope.bmc.date = - new Date(data.data[time_path + 'bmc'].Elapsed / 1000); + new Date(data.data[timePath + 'bmc'].Elapsed / 1000); // Don't care about milliseconds and don't want them displayed $scope.bmc.date.setMilliseconds(0); // https://stackoverflow.com/questions/1091372/getting-the-clients-timezone-in-javascript @@ -39,23 +40,23 @@ window.angular && (function(angular) { $scope.bmc.timezone = $scope.bmc.date.toString().match(/([A-Z]+[\+-][0-9]+.*)/)[1]; } - if (data.data[time_path + 'host'] && - data.data[time_path + 'host'].hasOwnProperty('Elapsed')) { + if (data.data[timePath + 'host'] && + data.data[timePath + 'host'].hasOwnProperty('Elapsed')) { $scope.host.date = - new Date(data.data[time_path + 'host'].Elapsed / 1000); + new Date(data.data[timePath + 'host'].Elapsed / 1000); $scope.host.date.setMilliseconds(0); $scope.host.timezone = $scope.host.date.toString().match(/([A-Z]+[\+-][0-9]+.*)/)[1]; } - if (data.data[time_path + 'owner'] && - data.data[time_path + 'owner'].hasOwnProperty('TimeOwner')) { - $scope.time_owner = - data.data[time_path + 'owner'].TimeOwner.split('.').pop(); + if (data.data[timePath + 'owner'] && + data.data[timePath + 'owner'].hasOwnProperty('TimeOwner')) { + $scope.time.owner = + data.data[timePath + 'owner'].TimeOwner.split('.').pop(); } - if (data.data[time_path + 'sync_method'] && - data.data[time_path + 'sync_method'].hasOwnProperty( + if (data.data[timePath + 'sync_method'] && + data.data[timePath + 'sync_method'].hasOwnProperty( 'TimeSyncMethod')) { - $scope.time_mode = data.data[time_path + 'sync_method'] + $scope.time.mode = data.data[timePath + 'sync_method'] .TimeSyncMethod.split('.') .pop(); } @@ -82,8 +83,8 @@ window.angular && (function(angular) { }); $scope.setTime = function() { - $scope.set_time_error = false; - $scope.set_time_success = false; + $scope.error = false; + $scope.success = false; $scope.loading = true; var promises = [setTimeMode(), setTimeOwner(), setNTPServers()]; @@ -93,26 +94,26 @@ window.angular && (function(angular) { // insufficient permissions if the time mode or time owner had // changed. var manual_promises = []; - if ($scope.time_mode == 'Manual') { + if ($scope.time.mode == 'Manual') { // If owner is 'Split' set both. // If owner is 'Host' set only it. // Else set BMC only. See: // https://github.com/openbmc/phosphor-time-manager/blob/master/README.md - if ($scope.time_owner != 'Host') { + if ($scope.time.owner != 'Host') { manual_promises.push( setBMCTime($scope.bmc.date.getTime() * 1000)); } // Even though we are setting Host time, we are setting from // the BMC date and time fields labeled "BMC and Host Time" // currently. - if ($scope.time_owner == 'Host') { + if ($scope.time.owner == 'Host') { manual_promises.push( setHostTime($scope.bmc.date.getTime() * 1000)); } } // Set the Host if Split even if NTP. In split mode, the host has // its own date and time field. Set from it. - if ($scope.time_owner == 'Split') { + if ($scope.time.owner == 'Split') { manual_promises.push( setHostTime($scope.host.date.getTime() * 1000)); } @@ -120,11 +121,11 @@ window.angular && (function(angular) { $q.all(manual_promises) .then( function() { - $scope.set_time_success = true; + $scope.success = true; }, function(errors) { console.log(JSON.stringify(errors)); - $scope.set_time_error = true; + $scope.error = true; }) .finally(function() { $scope.loading = false; @@ -132,7 +133,7 @@ window.angular && (function(angular) { }, function(errors) { console.log(JSON.stringify(errors)); - $scope.set_time_error = true; + $scope.error = true; $scope.loading = false; }); }; @@ -164,12 +165,12 @@ window.angular && (function(angular) { function setTimeMode() { return APIUtils.setTimeMode( 'xyz.openbmc_project.Time.Synchronization.Method.' + - $scope.time_mode); + $scope.time.mode); } function setTimeOwner() { return APIUtils.setTimeOwner( - 'xyz.openbmc_project.Time.Owner.Owners.' + $scope.time_owner); + 'xyz.openbmc_project.Time.Owner.Owners.' + $scope.time.owner); } function setBMCTime(time) { |

