summaryrefslogtreecommitdiffstats
path: root/app/common/directives/input.js
diff options
context:
space:
mode:
authorGunnar Mills <gmills@us.ibm.com>2018-07-18 13:01:48 -0500
committerGunnar Mills <gmills@us.ibm.com>2018-09-13 00:38:58 +0000
commitb7ea279015fd33574eeab24b114b19d0cdb22e3c (patch)
treed3d60c80e6d66e5074f805959575611116c0b871 /app/common/directives/input.js
parent264c5b8a131fbb554fa4804cc77095a741a0c7e7 (diff)
downloadphosphor-webui-b7ea279015fd33574eeab24b114b19d0cdb22e3c.tar.gz
phosphor-webui-b7ea279015fd33574eeab24b114b19d0cdb22e3c.zip
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>
Diffstat (limited to 'app/common/directives/input.js')
-rw-r--r--app/common/directives/input.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/common/directives/input.js b/app/common/directives/input.js
new file mode 100644
index 0000000..cb4d830
--- /dev/null
+++ b/app/common/directives/input.js
@@ -0,0 +1,19 @@
+window.angular && (function(angular) {
+ 'use strict';
+
+ angular.module('app.common.directives')
+ .directive('setFocusOnNewInput', function() {
+ return function(scope, element, attrs) {
+ var elem = window.document.getElementById(element[0].id);
+ // Focus on the newly created input.
+ // Since this directive is also called when initializing fields
+ // on a page load, need to determine if the call is from a page load
+ // or from the user pressing the "Add new" button. The easiest way to
+ // do this is to check if the field is empty, if it is we know this is
+ // a new field since all empty fields are removed from the array.
+ if (!scope[attrs.ngModel] && elem) {
+ elem.focus();
+ }
+ };
+ });
+})(window.angular);
OpenPOWER on IntegriCloud