fleet-contractor/Site/SystemSettings/SystemOptions.aspx
2024-03-26 15:56:31 +08:00

266 lines
12 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<%@ Page Title="" Language="C#" MasterPageFile="~/SystemSettings/SysSettingMasterPage.master" AutoEventWireup="true" CodeFile="SystemOptions.aspx.cs" Inherits="SystemOptions" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<style type="text/css">
.label {
min-width: 100px;
font-weight: bold;
padding-right: 10px;
text-align: right;
}
</style>
<script type="text/javascript">
function systemoptionsrequest(method, param, callback, error) {
_network.request("SystemSettings/SystemOptions.aspx", -1, method, param, callback, error || function (e) {
console.log(e);
showmaskbg(false, true);
showAlert(GetTextByKey('P_SET_QUERY', 'An unknown error occurred. Please refresh page.'), GetTextByKey('P_SET_QUERY', 'Query'));
});
}
function OnRefresh() {
showloading(true);
systemoptionsrequest("GetTimeZones", "", function (data) {
showloading(false);
showTimeZones(data);
}, function (err) {
showloading(false);
});
}
function showTimeZones(data) {
var sel = $("#selTimeZone");
sel.empty();
if (data && data.length > 0) {
for (var i = 0; i < data.length; i++) {
sel.append($("<option></option>").val(data[i].Key).text("(" + data[i].Value + ")" + data[i].Key).attr("offset", data[i].Tag1));
}
}
sel.val("UTC");
GetSystemOptions();
}
function GetSystemOptions() {
showloading(true);
systemoptionsrequest("GetSystemOptions", "", function (data) {
showloading(false);
if (data) {
$("#selTimeZone").val(data.TimeZone === "" ? "UTC" : data.TimeZone);
$('#accuracyfilter').val(data.AccuracyFilter);
$('#txtOdoUnit').val(data.UnitOfOdometer);
$('#sel_acknowledgealert').val(data.AcknowledgingAlerts);
$('#selAreaUnit').val(data.AreaUnits);
$('#selVolumeUnit').val(data.VolumeUnits);
$('#selWeightUnit').val(data.WeightUnits);
$('#sel_loginverifytype').val(data.LoginVerifyType);
$('#ipt_mfaremembermedays').val(data.MFARememberMeDays);
$('#sel_locdatasource').val(data.BreadcrumbLocationSource);
if (data.Connectors && data.Connectors.length > 0) {
var con = data.Connectors[0];
$('#ipt_connectorserver').val(con.Key);
$('#ipt_connectortoken').val(con.Value);
}
}
}, function (err) {
showloading(false);
});
}
var IsPositiveInteger = /^[0-9]\d*$/;
function OnSave() {
var offset = $('#selTimeZone').find("option:selected").attr("offset");
var connector = { 'Key': $('#ipt_connectorserver').val(), 'Value': $('#ipt_connectortoken').val() };
var item = {
'TimeZone': $('#selTimeZone').val(),
'Offset': offset,
'AccuracyFilter': $('#accuracyfilter').val(),
'UnitOfOdometer': $('#txtOdoUnit').val(),
'AcknowledgingAlerts': $('#sel_acknowledgealert').val(),
'AreaUnits': $('#selAreaUnit').val(),
'VolumeUnits': $('#selVolumeUnit').val(),
'WeightUnits': $('#selWeightUnit').val(),
'LoginVerifyType': $('#sel_loginverifytype').val(),
'MFARememberMeDays': $('#ipt_mfaremembermedays').val(),
'BreadcrumbLocationSource': $('#sel_locdatasource').val(),
'Connectors': [connector]
};
var alerttitle = GetTextByKey("P_SET_SAVESYSTEMOPTIONS", 'Save System Options');
if (item.AccuracyFilter !== "") {
if (isNaN(item.AccuracyFilter)) {
showAlert(GetTextByKey("P_SET_ACCURACYFILTERFORMATERROR", 'Accuracy Filter format error.'), alerttitle);
return;
}
else {
if (item.AccuracyFilter <= 0) {
showAlert(GetTextByKey("P_SET_ACCURACYFILTERMUSTBBEGREATERTHAN0", 'Accuracy Filter must be greater than 0.'), alerttitle);
return;
}
}
}
else
item.AccuracyFilter = 0;
if (item.MFARememberMeDays !== "") {
if (!IsPositiveInteger.test(item.MFARememberMeDays)) {
showAlert(GetTextByKey("P_SET_MFAREMEMBERMEDAYSFORMATERROR", 'MFA Remember Me Days format error.'), alerttitle);
return;
}
}
else
item.MFARememberMeDays = 0;
showloading(true);
var param = JSON.stringify(item);
systemoptionsrequest("SaveSystemOptions", param, function (data) {
if (data !== 'OK') {
showAlert(data, alerttitle);
} else {
showAlert(GetTextByKey("P_SET_SAVSUCCESSFULLY", "Saved Successfully."), alerttitle);
}
showloading(false);
}, function (err) {
showloading(false);
});
}
$(function () {
setPageTitle(GetTextByKey("P_SET_SYSTEMOPTIONS", 'System Options'), true);
OnRefresh();
});
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div style="padding: 0px; margin: 0px;">
<div class="page_title" data-lgid="P_SET_SYSTEMOPTIONS">System Options</div>
<div class="function_title">
<span class="sbutton iconsave" onclick="OnSave();" data-lgid="P_SET_SAVE">Save</span>
<span class="sbutton iconrefresh" onclick="OnRefresh();" data-lgid="P_SET_REFRESH">Refresh</span>
</div>
<div class="clear"></div>
<div class="content_main content_div" style="padding-top: 20px;">
<table style="line-height: 30px; width: 100%;">
<tr>
<td class="label" style="width: 300px;" data-lgid="P_SET_TIMEZON_COLON">Time Zone:</td>
<td>
<select id="selTimeZone" style="width: 304px;"></select></td>
<td></td>
</tr>
<tr>
<td class="label" data-lgid="P_SET_ACCURACYFILTER_COLON">Accuracy Filter:</td>
<td>
<input id="accuracyfilter" style="width: 100px;" maxlength="10" /><span style="color: gray;" data-lgid="P_SET_ACCURACYFILTERTIPS">
FI Tracker ignore location when accuracy greater than…</span>
</td>
<td></td>
</tr>
<tr>
<td class="label" data-lgid="P_SET_UNITOFODOMETER_COLON">Unit Of Odometer:</td>
<td>
<select id="txtOdoUnit" style="width: 304px;">
<option value="Mile" data-lgid="P_SET_MILE">Mile</option>
<option value="Kilometre" data-lgid="P_SET_KILOMETER">Kilometer</option>
</select></td>
<td></td>
</tr>
<tr>
<td class="label" data-lgid="P_SET_AREAUNITS_COLON">Unit Of Area:</td>
<td>
<select id="selAreaUnit" style="width: 304px;">
<option value="0" data-lgid="P_SET_SQUAREMETER">Square Meter</option>
<option value="1" data-lgid="P_SET_SQUAREKILOMETRE">Square Kilometre</option>
<option value="2" data-lgid="P_SET_HECTARE">Hectare</option>
<option value="3" data-lgid="P_SET_ACRE">Acre</option>
<option value="4" data-lgid="P_SET_SQUAREMILE">Square Mile</option>
</select></td>
<td></td>
</tr>
<tr>
<td class="label" data-lgid="P_SET_VOLUMEUNITS_COLON">Unit Of Volume:</td>
<td>
<select id="selVolumeUnit" style="width: 304px;">
<option value="0" data-lgid="P_SET_LITRE">Litre</option>
<option value="1" data-lgid="P_SET_GALLONUS">Gallon(U.S.)</option>
<option value="2" data-lgid="P_SET_GALLONENGLISH">Gallon (U.K.)</option>
</select></td>
<td></td>
</tr>
<tr>
<td class="label" data-lgid="P_SET_WEIGHTUNITS_COLON">Unit Of Weight:</td>
<td>
<select id="selWeightUnit" style="width: 304px;">
<option value="0" data-lgid="P_SET_KILOGRAM">Kilogram</option>
<option value="1" data-lgid="P_SET_TONNE">Tonne</option>
<option value="2" data-lgid="P_SET_POUND">Pound</option>
<option value="3" data-lgid="P_SET_SHORTTON">Ton (U.S.)</option>
</select></td>
<td></td>
</tr>
<tr>
<td class="label" data-lgid="P_SET_REQUIRECOMMENTWHENACKNOWLEDGINGALERTS_COLON">Require comment when acknowledging alerts:</td>
<td>
<select id="sel_acknowledgealert" style="width: 304px;">
<option value="No" data-lgid="P_SET_NO">No</option>
<option value="Yes" data-lgid="P_SET_YES">Yes</option>
</select></td>
<td></td>
</tr>
<tr>
<td class="label" data-lgid="P_SET_MULTIFACTOR_COLON">Multi-Factor Authentication Org. Preference:</td>
<td>
<select id="sel_loginverifytype" style="width: 304px;">
<option value=""></option>
<option value="Email" data-lgid="P_UM_EMAIL">Email</option>
<%--<option value="SMS">SMS</option>--%>
</select></td>
<td></td>
</tr>
<tr>
<td class="label" data-lgid="P_SET_MFAREMEMBERMEDAYS_COLON">MFA Remember Me Days:</td>
<td>
<input id="ipt_mfaremembermedays" style="width: 100px;" maxlength="10" /></td>
<td></td>
</tr>
<tr>
<td class="label" data-lgid="P_SET_DEFAULTBREADCRUMBLOCATIONSOURCES_COLON">Default Breadcrumb Location Source(s):</td>
<td>
<select id="sel_locdatasource" style="width: 304px;">
<option value="0" data-lgid="P_MV_PRIMARYONLY">Primary Only</option>
<option value="1" data-lgid="P_MV_THEFTMODEMULTIPLELINES">Theft Mode (Multiple Lines)</option>
<option value="2" data-lgid="P_MV_COMBINEDSINGLELINE">Combined (Single Line)</option>
</select></td>
<td></td>
</tr>
<tr>
<td colspan="3">
<div style="font-size: 18px; color: grey; margin: 20px 0px 0px 10px" data-lgid="P_SET_CONNECTOR">Connector</div>
<hr />
</td>
</tr>
<tr>
<td class="label" data-lgid="P_SET_SERVER_COLON">Server:</td>
<td>
<input id="ipt_connectorserver" style="width: 300px;" maxlength="200" /></td>
</tr>
<tr>
<td class="label" data-lgid="P_SET_TOKEN_COLON">Token:</td>
<td>
<input id="ipt_connectortoken" style="width: 300px;" maxlength="200" /></td>
<td></td>
</tr>
</table>
</div>
</div>
<div id="mask_bg" style="display: none;">
<div class="loading c-spin"></div>
</div>
</asp:Content>