Set time fields
Squashed 5 commits to set the date-time fields:
time mode, time owner, BMC time, and host time.
Also included is a commit to display the timezone.
Set time mode
Moved the selection of NTP vs Manual (time mode) to a radio
button.
Added code to allow the user set it.
Tested: Set the time mode on a Witherspoon.
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
Set time owner
The time owner is now a dropdown and is set when "Save settings"
is pressed.
Tested: Set the time owner on a Witherspoon
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
Set the BMC and Host time
The BMC and host have the same time except when time mode is split.
Only need to set BMC or host time when time mode is not split.
When time mode is split, set both. Use time owner to determine
which to set.
https://github.com/openbmc/phosphor-time-manager#time-settings
Have date and time as two separate inputs, this is due to Firefox
not supporting "datetime-local". The "date" and "time" input
fields are more widely supported.
https://caniuse.com/#feat=input-datetime
The idea for 2 separate input fields came from:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local
Must set the time mode and time owner before setting the time,
this is due to permissions of who can set the time.
Tested: Set the date and time on a Witherspoon.
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
Add NTP Servers
The user can now view and set NTP Servers.
Moved setFocusOnNewInput to a common directive since it is used
on the NTP Servers and the DNS Servers on the network page.
Even though NTPServers is a network interface specific path
(e.g. /xyz/openbmc_project/network/eth0/attr/NTPServers) it acts
like a global setting, openbmc/phosphor-time-manager#4.
Using eth0 for setting and getting the NTP Servers until
NTPServers is moved to a non-network interface specific path.
In Redfish, NTPServers is a non-network interface specific.
Tested: Set NTP Servers on a Witherspoon.
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
Add timezone
Added the timezone for the host and bmc date time.
The timezone looks like "GMT-0400 (EDT)" or "GMT-0500 (CDT)".
I got this from
https://stackoverflow.com/questions/1091372/getting-the-clients-timezone-in-javascript
and choose this formatting over something like "America/Chicago".
Tested: See the timezone on a Witherspoon
Change-Id: I59a4449d63f73a6ed14cb934f3d8577e46620c4e
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/app/configuration/controllers/date-time-controller.html b/app/configuration/controllers/date-time-controller.html
index a64a001..491ab56 100644
--- a/app/configuration/controllers/date-time-controller.html
+++ b/app/configuration/controllers/date-time-controller.html
@@ -1,31 +1,65 @@
<loader loading="loading"></loader>
<div id="configuration-date-time">
<div class="row column">
- <h1>Date time settings</h1>
+ <h1>Date and time settings</h1>
</div>
- <div class="page-header">
- <h2 class="bold h4">Time information</h2>
- </div>
- <fieldset>
- <div class="column large-8">
- <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="courier-bold">{{bmc_time | date:'medium'}}</p>
- </li>
- <li class="date-time__metadata-block" ng-if="time_owner == 'Split'">
- <p class="content-label">Host Time</p>
- <p class="courier-bold">{{host_time | date:'medium'}}</p>
- </li>
- <li class="date-time__metadata-block">
- <p class="content-label">Time Owner</p>
- <p class="courier-bold">{{time_owner}}</p>
- </li>
- <li class="date-time__metadata-block">
- <p class="content-label">Time Mode</p>
- <p class="courier-bold">{{time_mode}}</p>
- </li>
- </ul>
+ <form class="time__form" role="form" action="">
+ <div class="page-header">
+ <h2 class="bold h4">Date and time set to Network Time Protocol (NTP) or manually</h2>
</div>
- </fieldset>
+ <fieldset>
+ <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">
+ <span class="control__indicator control__indicator-on"></span>
+ </label>
+ </div>
+ <div class="row column date-time__ntp-servers-wrap">
+ <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}}</label>
+ <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/>
+ </fieldset>
+ <button type="button" class="btn-primary inline" ng-click="addNTPField()">Add new NTP server</button>
+ </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"/>
+ <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>
+ <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'" />
+ <p class="courier-bold">{{bmc.timezone}}</p>
+ </div>
+ </li>
+ <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.--->
+ <input type="date" ng-model="host.date" min="2018-01-01" max="2099-12-31"/>
+ <input type="time" ng-model="host.date"/>
+ <p class="courier-bold">{{host.timezone}}</p>
+ </div>
+ </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>
+ </li>
+ </ul>
+ </div>
+ </fieldset>
+ <div class="time__submit-wrapper">
+ <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>
+ </form>
</div>