diff --git a/.gitignore b/.gitignore index b1ff29ed7..e32571d6a 100644 --- a/.gitignore +++ b/.gitignore @@ -66,4 +66,5 @@ dist # hide the AWS and Rsync credentials file aws-credentials.json -rsync-credentials.json \ No newline at end of file +rsync-credentials.json +package-lock.json diff --git a/src/software/js-samples/importUsers.html b/src/software/js-samples/importUsers.html index 74cbefa42..fe4b73d07 100644 --- a/src/software/js-samples/importUsers.html +++ b/src/software/js-samples/importUsers.html @@ -17,15 +17,15 @@

Import users

Creates new users from a comma separated list

- - + +
-
-

This tool is provided as an example and is available on an As-Is basis. You must assume all the risks and costs associated with the use of the sample tool, including, without limitation, any damage to any equipment, software, information or data. In addition, we are not obligated to provide any maintenance, technical or other support for the sample tool. In order to improve our products, we may at any time, and without warning, change the design, presentation, or functionality of the software.

-
+
+

This tool is provided as an example and is available on an As-Is basis. You must assume all the risks and costs associated with the use of the sample tool, including, without limitation, any damage to any equipment, software, information or data. In addition, we are not obligated to provide any maintenance, technical or other support for the sample tool. In order to improve our products, we may at any time, and without warning, change the design, presentation, or functionality of the software.

+
@@ -42,516 +42,526 @@

Import users

- - -

+ + +

- + + + + + +

+ +

+

-

- +

+

-

- - -

-

- - - -

- -

- - - - - - - - +

+ + +

+

+ + + +

+ +

+ + + + + + + + - - -

- -

+ + +

+ +

-

-

+

+

-

-

-

- -
- - - -
-
-

-

-

- -
- - - -
-
-

-

-

- -
- - -
-
-

-

- +

+

+

+ +
+ + + +
+
+

+

+

+ +
+ + + +
+
+

+

+

+ +
+ + +
+
+

+

+ -

- - - -
+

+

+

+

-

- - -
-

-

-

- -
-
-

-

-

- -
-
-

- -

-      -

+
+ + +
+

+

+

+ +
+
+

+

+

+ +
+
+

+ +

+      +

@@ -577,9 +587,9 @@

Template

To make things easier, we've provided you with an excel template. Please follow the input requirements outlined in the Help menu.

Keep in mind that Time Zone is a required input and if a license plate is entered, it must be unique to the database. License state is required only if a license plate is provided. You may enter a state other than those provided.

NFC and Custom NFC keys must be unique to the database; no duplicates can exist.

If you want to import any reporting groups - the user groups cannot include the "CompanyGroupId", otherwise all reporting groups wiil be ignored.

-
-
Email1,FirstName,LastName,Password,GroupName1|GroupName2|...|GroupNameN,ReportingGroupName1|ReportingGroupName2|...|ReportingGroupNameN,SecurityClearanceId,NfcKey,CustomNfcKey,EmployeeNumber,FuelEconomyMeasurement,DistanceMeasurementSystem,FeaturePreview,TimeZone,AuthorityName,AuthorityAddress,CarrierNumber,HomeTerminal,HomeTerminalAddress,DriverLicenseNumber,LicenseState,Ruleset,YardMoveAllowed,PersonalConveyanceAllowed
Email2,FirstName,LastName,Password,GroupName1|GroupName2|...|GroupNameN,ReportingGroupName1|ReportingGroupName2|...|ReportingGroupNameN,SecurityClearanceId,NfcKey,,EmployeeNumber,,,,TimeZone,AuthorityName,AuthorityAddress,CarrierNumber,HomeTerminal,HomeTerminalAddress,DriverLicenseNumber,LicenseState,Ruleset,YardMoveAllowed,PersonalConveyanceAllowed
Email3,FirstName,LastName,Password,GroupName1|GroupName2|...|GroupNameN,ReportingGroupName1|ReportingGroupName2|...|ReportingGroupNameN,SecurityClearanceId,NfcKey,,,,,,,,,,,,,,Ruleset,,
-
+
+
Email1,FirstName,LastName,Password,GroupName1|GroupName2|...|GroupNameN,ReportingGroupName1|ReportingGroupName2|...|ReportingGroupNameN,SecurityClearanceId,NfcKey,CustomNfcKey,EmployeeNumber,FuelEconomyMeasurement,DistanceMeasurementSystem,FeaturePreview,TimeZone,AuthorityName,AuthorityAddress,CarrierNumber,HomeTerminal,HomeTerminalAddress,DriverLicenseNumber,LicenseState,Ruleset,YardMoveAllowed,PersonalConveyanceAllowed
Email2,FirstName,LastName,Password,GroupName1|GroupName2|...|GroupNameN,ReportingGroupName1|ReportingGroupName2|...|ReportingGroupNameN,SecurityClearanceId,NfcKey,,EmployeeNumber,,,,TimeZone,AuthorityName,AuthorityAddress,CarrierNumber,HomeTerminal,HomeTerminalAddress,DriverLicenseNumber,LicenseState,Ruleset,YardMoveAllowed,PersonalConveyanceAllowed
Email3,FirstName,LastName,Password,GroupName1|GroupName2|...|GroupNameN,ReportingGroupName1|ReportingGroupName2|...|ReportingGroupNameN,SecurityClearanceId,NfcKey,,,,,,,,,,,,,,Ruleset,,
+
@@ -588,166 +598,166 @@

Help

This SDK example assists with importing users to your database using comma separated values (CSV).

- Use the form to add new users with optional NFC or GO driver keys. You can also use the text box to paste in users from another source. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + Use the form to add new users with optional NFC or GO driver keys. You can also use the text box to paste in users from another source. +
ValueExampleNotes
Emailjohn.smith@geotab.comCan be email or user name. Spaces are not allowed.
First nameJohnSpaces are not allowed.
Last nameSmith
PasswordMinimum of 6 characters.
GroupsDrivers|West|GarminNames of groups separated by the | character.
+ + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ValueExampleNotes
Reporting GroupsDrivers|West|GarminNames of reporting groups separated by the | character.
Security clearance IDb28A7 - Found in the URL when viewing a security clearance in MyGeotab.

- Example:
- my.geotab.com/DATABASE/#clearance,id:b28A7 -
NFC key numberT1234SOptional. Found on the NFC key fob.
Custom NFC key number12345678Optional. Found on the Custom NFC key fob.
Country CodeCAOptional. The user two symbols country ISO code (https://www.iso.org/iso-3166-country-codes.html)
Phone number+1 5555555555Optional. The user's phone number with space separated country phone code.
Phone number extension1234Optional. The user's phone number extension.
Designation""Optional. The user's designation
Employee number63-221-44Optional. The user's employee number.
Fuel economy measurementLitersPer100KmOptional. Choose how to display fuel economy. There are four different measurements: liters per 100 kilometers, kilometers per liter, miles per US gallon, or miles per imperial gallon. You may need to refresh your browser for the change to take effect.
Distance measurement systemMetric (true)Optional. Choose how to display speeds and distances. This can be Metric or US/Imperial. You may need to refresh your browser to see the change take effect.
Feature previewOn or Off (true or false)Optional. Toggle feature preview.
Time zoneAmerica/New_YorkThe time zone offset from UTC for your location. All data will be displayed in this time zone.
Authority nameNational ExpressOptional. The motor carrier that the driver works for.
Authority address5000 Explorer DriveOptional. The motor carrier's main office address.
Carrier number8Z88Optional. In the United States, this is the motor carrier's USDOT number. In Canada, this is the Canadian Carrier code.
Home terminalStark TowerOptional. The motor carrier's place of business where the driver ordinarily reports for work. This can include a temporary work site designated by the motor carrier.
Home terminal address200 Park AvenueOptional. The motor carrier's address where the driver ordinarily reports for work.
Driver license numberYEETOptional. Driver's license number and License state/province must be set at the same time.
License state/provinceOntario (ON)Optional. Selecting North America will show a dropdown menu; selecting Other will display a text box.
RulesetCalifornia Property Intrastate (HosRuleSetCaliforniaProperty)Optional. This is the ruleset the user will follow when using hours of service.
Yard move allowedOn or Off (true or false)Optional. Toggling this setting to ON allows the driver to apply the yard move exemption.
Personal conveyance allowedOn of Off (true or false)Optional. Toggling this setting to ON allows the driver to apply the personal conveyance exemption.
+ Email + john.smith@geotab.com + Can be email or user name. Spaces are not allowed. + + + First name + John + Spaces are not allowed. + + + Last name + Smith + + + + Password + + Minimum of 6 characters. + + + Groups + Drivers|West|Garmin + Names of groups separated by the | character. + + + Reporting Groups + Drivers|West|Garmin + Names of reporting groups separated by the | character. + + + Security clearance ID + b28A7 + + Found in the URL when viewing a security clearance in MyGeotab.

+ Example:
+ my.geotab.com/DATABASE/#clearance,id:b28A7 + + + + NFC key number + T1234S + Optional. Found on the NFC key fob. + + + Custom NFC key number + 12345678 + Optional. Found on the Custom NFC key fob. + + + + Country Code + CA + Optional. The user two symbols country ISO code (https://www.iso.org/iso-3166-country-codes.html) + + + + Phone number + +1 5555555555 + Optional. The user's phone number with space separated country phone code. + + + + Phone number extension + 1234 + Optional. The user's phone number extension. + + + + Designation + "" + Optional. The user's designation + + + Employee number + 63-221-44 + Optional. The user's employee number. + + + Fuel economy measurement + LitersPer100Km + Optional. Choose how to display fuel economy. There are four different measurements: liters per 100 kilometers, kilometers per liter, miles per US gallon, or miles per imperial gallon. You may need to refresh your browser for the change to take effect. + + + Distance measurement system + Metric (true) + Optional. Choose how to display speeds and distances. This can be Metric or US/Imperial. You may need to refresh your browser to see the change take effect. + + + Feature preview + On or Off (true or false) + Optional. Toggle feature preview. + + + Time zone + America/New_York + The time zone offset from UTC for your location. All data will be displayed in this time zone. + + + Authority name + National Express + Optional. The motor carrier that the driver works for. + + + Authority address + 5000 Explorer Drive + Optional. The motor carrier's main office address. + + + Carrier number + 8Z88 + Optional. In the United States, this is the motor carrier's USDOT number. In Canada, this is the Canadian Carrier code. + + + Home terminal + Stark Tower + Optional. The motor carrier's place of business where the driver ordinarily reports for work. This can include a temporary work site designated by the motor carrier. + + + Home terminal address + 200 Park Avenue + Optional. The motor carrier's address where the driver ordinarily reports for work. + + + Driver license number + YEET + Optional. Driver's license number and License state/province must be set at the same time. + + + License state/province + Ontario (ON) + Optional. Selecting North America will show a dropdown menu; selecting Other will display a text box. + + + Ruleset + California Property Intrastate (HosRuleSetCaliforniaProperty) + Optional. This is the ruleset the user will follow when using hours of service. + + + Yard move allowed + On or Off (true or false) + Optional. Toggling this setting to ON allows the driver to apply the yard move exemption. + + + Personal conveyance allowed + On of Off (true or false) + Optional. Toggling this setting to ON allows the driver to apply the personal conveyance exemption. + + +

@@ -760,139 +770,152 @@

Help

var groupCache = {}; var securityClearanceCache = {}; - var selectedGroups = []; + var selectedGroups = []; var selectedReportGroups = []; - var passwordResetCheckbox = document.getElementById("import-password-reset"); - var hosRulesetArray = []; - var moreCalls = []; + var passwordResetCheckbox = document.getElementById("import-password-reset"); + var hosRulesetArray = []; + var moreCalls = []; + var certificates = {}; - function toggleDocs(event) { + function toggleDocs(event) { - if (event.target && event.target.className == 'clickable-heading') { + if (event.target && event.target.className == 'clickable-heading') { - var next = event.target.nextElementSibling; + var next = event.target.nextElementSibling; - if (next.style.display == "none") { - next.style.display = "block"; + if (next.style.display == "none") { + next.style.display = "block"; - } else { - next.style.display = "none"; - } - } - } + } else { + next.style.display = "none"; + } + } + } - function yesnoCheck() { - if (document.getElementById('idLicenseStateNA').checked) { - document.getElementById('ifYes').style.display = 'block'; - document.getElementById('ifNo').style.display = 'none'; - } - else { - document.getElementById('ifYes').style.display = 'none'; - document.getElementById('ifNo').style.display = 'block'; - } - } + function yesnoCheck() { + if (document.getElementById('idLicenseStateNA').checked) { + document.getElementById('ifYes').style.display = 'block'; + document.getElementById('ifNo').style.display = 'none'; + } + else { + document.getElementById('ifYes').style.display = 'none'; + document.getElementById('ifNo').style.display = 'block'; + } + } - document.addEventListener('click', toggleDocs, true); + document.addEventListener('click', toggleDocs, true); + + document.getElementById('import-authType').addEventListener('change', function(event) { + + var select = document.getElementById('import-authType-certificate'); + + if (event.target.value === 'SAML'){ + select.style.display = ''; + } else { + select.style.display = 'none'; + } + + }); document.addEventListener("DOMContentLoaded", function() { groupCache = refreshGroupCache(null); - securityClearanceCache = refreshSecurityClearanceCache(null); - timeZoneCache = refreshTimeZoneCache(null); - - - document.getElementById("content").addEventListener("keyup", function(event) { - event.preventDefault(); - - document.getElementById("importUsers").disabled = (event.target.value === ""); - }); - - $("#import-groups").on("change", function(event, parameters) { - if (parameters.selected) { - selectedGroups.push(parameters.selected); - } else { - var index = selectedGroups.indexOf(parameters.deselected); - if (index > -1) { - selectedGroups.splice(index, 1); - } - } - }); + securityClearanceCache = refreshSecurityClearanceCache(null); + timeZoneCache = refreshTimeZoneCache(null); + getCertificates(null); + + document.getElementById("content").addEventListener("keyup", function(event) { + event.preventDefault(); + + document.getElementById("importUsers").disabled = (event.target.value === ""); + }); + + $("#import-groups").on("change", function(event, parameters) { + if (parameters.selected) { + selectedGroups.push(parameters.selected); + } else { + var index = selectedGroups.indexOf(parameters.deselected); + if (index > -1) { + selectedGroups.splice(index, 1); + } + } + }); $("#import-reporting-groups").on("change", function(event, parameters) { - if (parameters.selected) { - selectedReportGroups.push(parameters.selected); - } else { - var index = selectedReportGroups.indexOf(parameters.deselected); - if (index > -1) { - selectedReportGroups.splice(index, 1); - } - } - }); - - - document.getElementById("addUser").addEventListener("click", function(event) { - event.preventDefault(); - - var user = parseUserFromFields(); - - if (user.userName === "") { - alert("Email or user name is required"); - return; - } - if (user.userName.indexOf(" ") >= 0) { - alert("Email or user name cannot contain a space"); - return; - } - if (user.firstName === "") { - alert("First name is required"); - return; - } - if (user.lastName === "") { - alert("Last name is required"); - return; - } - if (!$(passwordResetCheckbox).is(":checked") && user.password === "") { - alert("Password is required"); - return; - } - if (user.groups.length <= 0) { - alert("User must belong to at least one group"); - return; - } - if (user.securityClearance === "") { - alert("Security clearance is required"); - return; - } - if (isNaN(user.customNfcKey) || user.customNfcKey < 0 || user.customNfcKey > 72057594037927940) { - alert("Custom NFC Key Serial Number must be between 0 and 72057594037927940"); - return; - } - if (user.phoneNumber !== "" && ( !(user.phoneNumber.indexOf(" ") >= 0) || user.phoneNumber.charAt(0) !== "+" )) { - alert("Invalid PhoneNumber. Phone number should start with '+' and the country phone code, followed by the phone number without formatting separated by a space. Example: +1 5555555555"); - return; - } - if ( user.phoneNumberExtension !== "" && (isNaN(user.phoneNumberExtension))) { - alert("Phone number extensions cannot exceed five characters and must contain only digits.") - return; - } - - var newContent = document.getElementById("content").value; - - if (newContent !== "") { - newContent += "\n"; - } - newContent += user.userName + ","; - newContent += user.firstName + ","; - newContent += user.lastName + ","; - newContent += user.password + ","; - for (var i = 0; i < user.groups.length; i++) { - if (i < user.groups.length - 1) { - newContent += user.groups[i] + "|"; - } else { - newContent += user.groups[i] + ","; - } - } + if (parameters.selected) { + selectedReportGroups.push(parameters.selected); + } else { + var index = selectedReportGroups.indexOf(parameters.deselected); + if (index > -1) { + selectedReportGroups.splice(index, 1); + } + } + }); + + + document.getElementById("addUser").addEventListener("click", function(event) { + event.preventDefault(); + + var user = parseUserFromFields(); + + if (user.userName === "") { + alert("Email or user name is required"); + return; + } + if (user.userName.indexOf(" ") >= 0) { + alert("Email or user name cannot contain a space"); + return; + } + if (user.firstName === "") { + alert("First name is required"); + return; + } + if (user.lastName === "") { + alert("Last name is required"); + return; + } + if (!$(passwordResetCheckbox).is(":checked") && user.password === "") { + alert("Password is required"); + return; + } + if (user.groups.length <= 0) { + alert("User must belong to at least one group"); + return; + } + if (user.securityClearance === "") { + alert("Security clearance is required"); + return; + } + if (isNaN(user.customNfcKey) || user.customNfcKey < 0 || user.customNfcKey > 72057594037927940) { + alert("Custom NFC Key Serial Number must be between 0 and 72057594037927940"); + return; + } + if (user.phoneNumber !== "" && ( !(user.phoneNumber.indexOf(" ") >= 0) || user.phoneNumber.charAt(0) !== "+" )) { + alert("Invalid PhoneNumber. Phone number should start with '+' and the country phone code, followed by the phone number without formatting separated by a space. Example: +1 5555555555"); + return; + } + if ( user.phoneNumberExtension !== "" && (isNaN(user.phoneNumberExtension))) { + alert("Phone number extensions cannot exceed five characters and must contain only digits.") + return; + } + + var newContent = document.getElementById("content").value; + + if (newContent !== "") { + newContent += "\n"; + } + newContent += user.userName + ","; + newContent += user.firstName + ","; + newContent += user.lastName + ","; + newContent += user.password + ","; + for (var i = 0; i < user.groups.length; i++) { + if (i < user.groups.length - 1) { + newContent += user.groups[i] + "|"; + } else { + newContent += user.groups[i] + ","; + } + } // Reporting groups, can be emtpy if (user.reportGroups.length !== 0){ for (var i = 0; i < user.reportGroups.length; i++) { @@ -906,18 +929,18 @@

Help

newContent += ','; } - newContent += user.securityClearance + ","; - newContent += user.nfcKey + ","; - newContent += user.customNfcKey + ","; - newContent += user.countryCode + ","; - newContent += user.phoneNumber + ","; - newContent += user.phoneNumberExtension + ","; - newContent += user.designation + ","; - newContent += user.employeeNo + ","; - newContent += user.fuelEconomyUnit + ","; - newContent += user.isMetric + ","; - newContent += user.isLabsEnabled + ","; - newContent += user.timeZoneId + ","; + newContent += user.securityClearance + ","; + newContent += user.nfcKey + ","; + newContent += user.customNfcKey + ","; + newContent += user.countryCode + ","; + newContent += user.phoneNumber + ","; + newContent += user.phoneNumberExtension + ","; + newContent += user.designation + ","; + newContent += user.employeeNo + ","; + newContent += user.fuelEconomyUnit + ","; //16 + newContent += user.isMetric + ","; + newContent += user.isLabsEnabled + ","; + newContent += user.timeZoneId + ","; // 19 newContent += user.authorityName + ","; newContent += user.authorityAddress + ","; newContent += user.carrierNumber + ","; @@ -926,12 +949,14 @@

Help

newContent += user.licenseNumber + ","; newContent += user.licenseProvince + ","; newContent += user.hosRuleSet + ","; - newContent += user.isYardMoveEnabled + ","; - newContent += user.isPersonalConveyanceEnabled; - - document.getElementById("content").value = newContent; - document.getElementById("importUsers").disabled = false; - }); + newContent += user.isYardMoveEnabled + ","; + newContent += user.isPersonalConveyanceEnabled + ","; + newContent += user.userAuthenticationType + ","; + newContent += user.userSelectedCertificate; + + document.getElementById("content").value = newContent; + document.getElementById("importUsers").disabled = false; + }); document.getElementById("importUsers").addEventListener("click", function(event) { event.preventDefault(); @@ -944,22 +969,22 @@

Help

alert("At least one user is required"); } else { var userRows = content.split("\n"); - - var users = []; - - for (var i = 0; i < userRows.length; i++) { - if (userRows[i].trim() !== "") { - users.push(userRows[i].trim()); - } - } - + + var users = []; + + for (var i = 0; i < userRows.length; i++) { + if (userRows[i].trim() !== "") { + users.push(userRows[i].trim()); + } + } + var calls = []; var userListAndRuleset = []; - + for (i = 0; i < users.length; i++) { var split = users[i].split(","); - - if (split.length !== 28) { + + if (split.length !== 30) { alert("Missing necessary information from user: " + users[i]); continue; } @@ -971,15 +996,15 @@

Help

var groups = parseGroups(split[4]); var reportGroups = parseReportingGroups(split[5]); var securityGroups = parseSecurityClearanceName(split[6]); - var keys = parseKeys(split[7], split[8]); - var countryCode = split[9].toLowerCase(); - var phoneNumber = split[10]; - var phoneNumberExtension = split[11]; - var designation = split[12]; - var employeeNo = split[13]; - var fuelEconomyUnit = split[14]; - var isMetric = split[15]; - var isLabsEnabled = split[16]; + var keys = parseKeys(split[7], split[8]); + var countryCode = split[9].toLowerCase(); + var phoneNumber = split[10]; + var phoneNumberExtension = split[11]; + var designation = split[12]; + var employeeNo = split[13]; + var fuelEconomyUnit = split[14]; + var isMetric = split[15]; + var isLabsEnabled = split[16]; var timeZoneId = split[17]; var authorityName = split[18]; var authorityAddress = split[19]; @@ -989,36 +1014,38 @@

Help

var licenseNumber = split[23]; var licenseProvince = split[24]; var hosRuleSet = split[25]; - var isYardMoveEnabled = split[26]; - var isPersonalConveyanceEnabled = split[27]; - - // when pasting in ',' seperated string make sure values aren't empty - if (isYardMoveEnabled === '') { - var isYardMoveEnabled = false; - } - if (isPersonalConveyanceEnabled === '') { - var isPersonalConveyanceEnabled = false; - } - - var newUser = { - name: userName, - firstName: firstName, - lastName: lastName, - password: password, - companyGroups: groups, + var isYardMoveEnabled = split[26]; + var isPersonalConveyanceEnabled = split[27]; + var userAuthenticationType = split[28]; + var userSelectedCertificate = split[29]; + + // when pasting in ',' seperated string make sure values aren't empty + if (isYardMoveEnabled === '') { + var isYardMoveEnabled = false; + } + if (isPersonalConveyanceEnabled === '') { + var isPersonalConveyanceEnabled = false; + } + + var newUser = { + name: userName, + firstName: firstName, + lastName: lastName, + password: password, + companyGroups: groups, reportGroups: reportGroups, - securityGroups: securityGroups, - userAuthenticationType: "BasicAuthentication", - activeFrom: new Date().toISOString(), - activeTo: "2050-01-01T00:00:00.000Z", - countryCode: countryCode, - phoneNumber: phoneNumber, - phoneNumberExtension: phoneNumberExtension, - designation: designation, - employeeNo: employeeNo, - fuelEconomyUnit: fuelEconomyUnit, - isMetric: isMetric, - isLabsEnabled: isLabsEnabled, + securityGroups: securityGroups, + userAuthenticationType: userAuthenticationType, + activeFrom: new Date().toISOString(), + activeTo: "2050-01-01T00:00:00.000Z", + countryCode: countryCode, + phoneNumber: phoneNumber, + phoneNumberExtension: phoneNumberExtension, + designation: designation, + employeeNo: employeeNo, + fuelEconomyUnit: fuelEconomyUnit, + isMetric: isMetric, + isLabsEnabled: isLabsEnabled, timeZoneId: timeZoneId, authorityName: authorityName, authorityAddress: authorityAddress, @@ -1027,139 +1054,148 @@

Help

companyAddress: companyAddress, licenseNumber: licenseNumber, licenseProvince: licenseProvince, - isYardMoveEnabled: isYardMoveEnabled, - isPersonalConveyanceEnabled: isPersonalConveyanceEnabled - }; - - if (keys.length > 0){ - newUser.driverGroups = groups; - newUser.viewDriversOwnDataOnly = false; - newUser.keys = keys; - newUser.isDriver = true; + isYardMoveEnabled: isYardMoveEnabled, + isPersonalConveyanceEnabled: isPersonalConveyanceEnabled + }; + + if (newUser.userAuthenticationType === 'SAML') { + + newUser.issuerCertificate = { + id: userSelectedCertificate, + isRoot: certificates[userSelectedCertificate].isRoot + }; + } + + if (keys.length > 0){ + newUser.driverGroups = groups; + newUser.viewDriversOwnDataOnly = false; + newUser.keys = keys; + newUser.isDriver = true; } if (licenseNumber.length > 0){ newUser.driverGroups = groups; - newUser.viewDriversOwnDataOnly = false; + newUser.viewDriversOwnDataOnly = false; newUser.isDriver = true; } - if ($(passwordResetCheckbox).is(":checked")) - { - newUser.changePassword = true; + if ($(passwordResetCheckbox).is(":checked")) + { + newUser.changePassword = true; } - hosRulesetArray.push(hosRuleSet); - - calls.push([ - "Add", { - typeName: "User", - entity: newUser - } - ]); + hosRulesetArray.push(hosRuleSet); + + calls.push([ + "Add", { + typeName: "User", + entity: newUser + } + ]); } - - api.multiCall(calls, function(results) { + + api.multiCall(calls, function(results) { var userIds = results; - pushRulesets(userIds); + pushRulesets(userIds); - api.multiCall(moreCalls, function(results) {moreCalls = [];}, function(error) {console.log(error); moreCalls = [];}); - - if (results !== undefined && results !== null && results.length > 0) { - alert("Imported " + results.length + " of " + users.length + " users"); - } - }, function(error) { - if (error !== undefined && error !== null) { - if (error.indexOf("checksum") > 0) { - alert("There was a problem importing users. Please check that the NFC driver keys are entered correctly."); - } else if (error.indexOf("Index was outside") > 0) { - alert("There was a problem importing users. Please check that the Custom NFC driver keys are entered correctly."); - } else if (error.indexOf("DuplicateUserException") > 0) { - alert("There was a problem importing users. You have attempted to import a user name which already exists on your database."); - } else if (error.indexOf("DuplicateException") > 0) { - alert("There was a problem importing users. You have attmepted to import a driver key which already exists on your database."); - } else { - console.error(error); - alert("There was a problem importing users. Please check that all fields are entered correctly, the groups and security clearances still exist on your account and that the email addresses or user names are not currently in use."); - } - } + api.multiCall(moreCalls, function(results) {moreCalls = [];}, function(error) {console.log(error); moreCalls = [];}); + + if (results !== undefined && results !== null && results.length > 0) { + alert("Imported " + results.length + " of " + users.length + " users"); + } + }, function(error) { + if (error !== undefined && error !== null) { + if (error.indexOf("checksum") > 0) { + alert("There was a problem importing users. Please check that the NFC driver keys are entered correctly."); + } else if (error.indexOf("Index was outside") > 0) { + alert("There was a problem importing users. Please check that the Custom NFC driver keys are entered correctly."); + } else if (error.indexOf("DuplicateUserException") > 0) { + alert("There was a problem importing users. You have attempted to import a user name which already exists on your database."); + } else if (error.indexOf("DuplicateException") > 0) { + alert("There was a problem importing users. You have attmepted to import a driver key which already exists on your database."); + } else { + console.error(error); + alert("There was a problem importing users. Please check that all fields are entered correctly, the groups and security clearances still exist on your account and that the email addresses or user names are not currently in use."); + } + } }); - var pushRulesets = function (userIds) { - for (i = 0; i < userIds.length; i++) { - - var anotherUser = { - dateTime: new Date().toISOString(), - hosRuleSet: {"id": hosRulesetArray[i]}, - user: {"id": userIds[i]} - }; - - //if no ruleset is selected, do not push one to user - if (hosRulesetArray[i] !== "") { - - moreCalls.push([ - "Add", { - typeName: "UserHosRuleSet", - entity: anotherUser - } - ]); - } - } - } + var pushRulesets = function (userIds) { + for (i = 0; i < userIds.length; i++) { + + var anotherUser = { + dateTime: new Date().toISOString(), + hosRuleSet: {"id": hosRulesetArray[i]}, + user: {"id": userIds[i]} + }; + + //if no ruleset is selected, do not push one to user + if (hosRulesetArray[i] !== "") { + + moreCalls.push([ + "Add", { + typeName: "UserHosRuleSet", + entity: anotherUser + } + ]); + } + } + } + } }); }); - - function parseUserFromFields() { - var groups = []; - - for (var i = 0; i < selectedGroups.length; i++) { - for (var key in groupCache) { - if (groupCache[key].id == selectedGroups[i]) { - groups.push(groupCache[key].name); - break; - } - } - } - + + function parseUserFromFields() { + var groups = []; + + for (var i = 0; i < selectedGroups.length; i++) { + for (var key in groupCache) { + if (groupCache[key].id == selectedGroups[i]) { + groups.push(groupCache[key].name); + break; + } + } + } + var reportGroups = []; for (var i = 0; i < selectedReportGroups.length; i++) { - for (var key in groupCache) { - if (groupCache[key].id == selectedReportGroups[i]) { - reportGroups.push(groupCache[key].name); - break; - } - } - } - - var securityClearanceSelect = document.getElementById("import-securityClearance"); - var securityClearanceId = securityClearanceSelect[securityClearanceSelect.selectedIndex].value; - - if (document.getElementById("Lper100km").checked) { - var fuelEconomySelect = document.getElementById("Lper100km").value; - } else if (document.getElementById("kmperL").checked) { - var fuelEconomySelect = document.getElementById("kmperL").value; - } else if (document.getElementById("mpgUS").checked) { - var fuelEconomySelect = document.getElementById("mpgUS").value; - } else if (document.getElementById("mpgImp").checked) { - var fuelEconomySelect = document.getElementById("mpgImp").value; - } else { - var fuelEconomySelect = ""; - } - - if (document.getElementById("metricUnit").checked) { - var isMetric = true; - } - else { - var isMetric = false; - } + for (var key in groupCache) { + if (groupCache[key].id == selectedReportGroups[i]) { + reportGroups.push(groupCache[key].name); + break; + } + } + } + + var securityClearanceSelect = document.getElementById("import-securityClearance"); + var securityClearanceId = securityClearanceSelect[securityClearanceSelect.selectedIndex].value; + + if (document.getElementById("Lper100km").checked) { + var fuelEconomySelect = document.getElementById("Lper100km").value; + } else if (document.getElementById("kmperL").checked) { + var fuelEconomySelect = document.getElementById("kmperL").value; + } else if (document.getElementById("mpgUS").checked) { + var fuelEconomySelect = document.getElementById("mpgUS").value; + } else if (document.getElementById("mpgImp").checked) { + var fuelEconomySelect = document.getElementById("mpgImp").value; + } else { + var fuelEconomySelect = ""; + } + + if (document.getElementById("metricUnit").checked) { + var isMetric = true; + } + else { + var isMetric = false; + } - if (document.getElementById("idFeaturePreviewOn").checked) { - var isLabsEnabled = true; - } else { - var isLabsEnabled = false; - } + if (document.getElementById("idFeaturePreviewOn").checked) { + var isLabsEnabled = true; + } else { + var isLabsEnabled = false; + } - var timeZoneId = document.getElementById("options_userTimeZoneOffset").value; + var timeZoneId = document.getElementById("options_userTimeZoneOffset").value; if (document.getElementById('idLicenseStateNA').checked) { var plateState = document.getElementById("options_licenseProvince").value; @@ -1167,38 +1203,46 @@

Help

var plateState = document.getElementById("options_LicenseStateOther").value; } else {var plateState = ""} - var selectedHosRuleset = document.getElementById("options_hosRuleSet").value; + var selectedHosRuleset = document.getElementById("options_hosRuleSet").value; - if (document.getElementById("idYardMoveOn").checked) { - var isYardMoveEnabled = true; - } else { - var isYardMoveEnabled = false; - } + if (document.getElementById("idYardMoveOn").checked) { + var isYardMoveEnabled = true; + } else { + var isYardMoveEnabled = false; + } + + if (document.getElementById("idPersonalConveyanceOn").checked) { + var isPersonalConveyanceEnabled = true; + } else { + var isPersonalConveyanceEnabled = false; + } - if (document.getElementById("idPersonalConveyanceOn").checked) { - var isPersonalConveyanceEnabled = true; - } else { - var isPersonalConveyanceEnabled = false; - } + var selectedAuthType = document.getElementById("import-authType").value; + if (selectedAuthType == 'SAML') { + var selectedCertificate = document.getElementById("import-authType-certificate").value; + } else { + var selectedCertificate = null; + } + return { - userName: document.getElementById("import-userName").value, - firstName: document.getElementById("import-firstName").value, - lastName: document.getElementById("import-lastName").value, - password: document.getElementById("import-password").value, - groups: groups, + userName: document.getElementById("import-userName").value, + firstName: document.getElementById("import-firstName").value, + lastName: document.getElementById("import-lastName").value, + password: document.getElementById("import-password").value, + groups: groups, reportGroups: reportGroups, - securityClearance: securityClearanceId, - nfcKey: document.getElementById("import-nfcKey").value, - customNfcKey: document.getElementById("import-customNFC").value, - countryCode: document.getElementById("import-countryCode").value, - phoneNumber: document.getElementById("import-phoneNumber").value, - phoneNumberExtension: document.getElementById("import-phoneNumberExtension").value, - designation: document.getElementById("import-designation").value, - employeeNo: document.getElementById("import-employeeNumber").value, - fuelEconomyUnit: fuelEconomySelect, - isMetric: isMetric, - isLabsEnabled: isLabsEnabled, + securityClearance: securityClearanceId, + nfcKey: document.getElementById("import-nfcKey").value, + customNfcKey: document.getElementById("import-customNFC").value, + countryCode: document.getElementById("import-countryCode").value, + phoneNumber: document.getElementById("import-phoneNumber").value, + phoneNumberExtension: document.getElementById("import-phoneNumberExtension").value, + designation: document.getElementById("import-designation").value, + employeeNo: document.getElementById("import-employeeNumber").value, + fuelEconomyUnit: fuelEconomySelect, + isMetric: isMetric, + isLabsEnabled: isLabsEnabled, timeZoneId: timeZoneId, authorityName: document.getElementById("options_AuthorityName").value, authorityAddress: document.getElementById("options_AuthorityAddress").value, @@ -1208,10 +1252,12 @@

Help

licenseNumber: document.getElementById("options_LicenseNumber").value, licenseProvince: plateState, hosRuleSet: document.getElementById("options_hosRuleSet").value, - isYardMoveEnabled: isYardMoveEnabled, - isPersonalConveyanceEnabled: isPersonalConveyanceEnabled - } - } + isYardMoveEnabled: isYardMoveEnabled, + isPersonalConveyanceEnabled: isPersonalConveyanceEnabled, + userAuthenticationType: selectedAuthType, + userSelectedCertificate: selectedCertificate + } + } function parseGroups(text) { var result = []; @@ -1268,37 +1314,77 @@

Help

driverKeyType: "CustomNfc", isImmobilizeOnly: true }); - } - else if (customNfcKey === "") { - // do nothing - } - else alert("Custom NFC Key Serial Number must be between 0 and 72057594037927940.") + } + else if (customNfcKey === "") { + // do nothing + } + else alert("Custom NFC Key Serial Number must be between 0 and 72057594037927940.") return keys; - } + } - function refreshTimeZoneCache(callback) { - var select = document.getElementById("options_userTimeZoneOffset"); - + function refreshTimeZoneCache(callback) { + var select = document.getElementById("options_userTimeZoneOffset"); + api.call("GetTimeZones", {}, function(result) { if (result !== undefined && result != null && result.length > 0) { timeZoneCache = {}; - result.sort(function(a, b) { - if (a.id.toLowerCase() < b.id.toLowerCase()) { - return -1; - } - if (a.id.toLowerCase() > b.id.toLowerCase()) { - return 1; - } - return 0; - }); - for (i = 0; i < result.length; i++) { - timeZoneCache[result[i].id] = result[i]; - var option = new Option(); - option.text = result[i].id; - option.value = result[i].id; - select.add(option); - } + result.sort(function(a, b) { + if (a.id.toLowerCase() < b.id.toLowerCase()) { + return -1; + } + if (a.id.toLowerCase() > b.id.toLowerCase()) { + return 1; + } + return 0; + }); + for (i = 0; i < result.length; i++) { + timeZoneCache[result[i].id] = result[i]; + var option = new Option(); + option.text = result[i].id; + option.value = result[i].id; + select.add(option); + } + } + if (callback) { + callback(); + } + }, function(error) { + console.log(error); + }); + } + + + function getCertificates(callback) { + var selectAuthType = document.getElementById("import-authType"); + var select = document.getElementById("import-authType-certificate"); + + api.call("Get", { + "typeName":"Certificate" + }, function(result) { + if (result !== undefined && result != null && result.length > 0) { + + for (i = 0; i < result.length; i++) { + + var option = new Option(); + option.text = result[i].issuer; + option.value = result[i].id; + select.add(option); + + certificates[result[i].id] = { + name: result[i].issuer, + id : result[i].id, + isRoot: result[i].isRoot + }; + } + + var option = new Option(); + option.text = "SAML"; + option.value = "SAML"; + selectAuthType.add(option); + + select.style.display = 'none'; + } if (callback) { callback(); @@ -1307,11 +1393,12 @@

Help

console.log(error); }); } + function refreshGroupCache(callback) { - var select = document.getElementById("import-groups"); + var select = document.getElementById("import-groups"); var selectR = document.getElementById("import-reporting-groups"); - + api.call("Get", { typeName: "Group" }, function(result) { @@ -1319,36 +1406,36 @@

Help

groupCache = {}; for (var i = 0; i < result.length; i++) { if (result[i].name === undefined) { - result[i].name = result[i].id; + result[i].name = result[i].id; } } - result.sort(function(a, b) { - if (a.name.toLowerCase() < b.name.toLowerCase()) { - return -1; - } - if (a.name.toLowerCase() > b.name.toLowerCase()) { - return 1; - } - return 0; - }); - for (i = 0; i < result.length; i++) { - groupCache[result[i].name] = result[i]; - var option = new Option(); - option.text = result[i].name; - option.value = result[i].id; - select.add(option); + result.sort(function(a, b) { + if (a.name.toLowerCase() < b.name.toLowerCase()) { + return -1; + } + if (a.name.toLowerCase() > b.name.toLowerCase()) { + return 1; + } + return 0; + }); + for (i = 0; i < result.length; i++) { + groupCache[result[i].name] = result[i]; + var option = new Option(); + option.text = result[i].name; + option.value = result[i].id; + select.add(option); var optionR = new Option(); - optionR.text = result[i].name; - optionR.value = result[i].id; + optionR.text = result[i].name; + optionR.value = result[i].id; selectR.add(optionR); - } + } } - $("#import-groups").chosen({ - search_contains: true - }); + $("#import-groups").chosen({ + search_contains: true + }); $("#import-reporting-groups").chosen({ - search_contains: true - }); + search_contains: true + }); if (callback) { callback(); } @@ -1358,8 +1445,8 @@

Help

} function refreshSecurityClearanceCache(callback) { - var select = document.getElementById("import-securityClearance"); - + var select = document.getElementById("import-securityClearance"); + api.call("Get", { typeName: "Group", search: { @@ -1370,25 +1457,25 @@

Help

securityClearanceCache = {}; for (var i = 0; i < result.length; i++) { if (result[i].name === undefined) { - result[i].name = result[i].id; + result[i].name = result[i].id; + } + } + result.sort(function(a, b) { + if (a.name.toLowerCase() < b.name.toLowerCase()) { + return -1; } + if (a.name.toLowerCase() > b.name.toLowerCase()) { + return 1; + } + return 0; + }); + for (i = 0; i < result.length; i++) { + securityClearanceCache[result[i].id] = result[i]; + var option = new Option(); + option.text = result[i].name; + option.value = result[i].id; + select.add(option); } - result.sort(function(a, b) { - if (a.name.toLowerCase() < b.name.toLowerCase()) { - return -1; - } - if (a.name.toLowerCase() > b.name.toLowerCase()) { - return 1; - } - return 0; - }); - for (i = 0; i < result.length; i++) { - securityClearanceCache[result[i].id] = result[i]; - var option = new Option(); - option.text = result[i].name; - option.value = result[i].id; - select.add(option); - } } if (callback) { callback(); @@ -1398,10 +1485,10 @@

Help

}); } - function ClearFields() { + function ClearFields() { - document.getElementById("content").value = ""; - } + document.getElementById("content").value = ""; + } diff --git a/src/software/js-samples/templates/import-users-template.xlsx b/src/software/js-samples/templates/import-users-template.xlsx index d6beddfd5..472925a7c 100644 Binary files a/src/software/js-samples/templates/import-users-template.xlsx and b/src/software/js-samples/templates/import-users-template.xlsx differ