mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
ui-improvements
This commit is contained in:
parent
5aea03c66f
commit
d428901b22
@ -98,23 +98,23 @@
|
|||||||
<br/>
|
<br/>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
{{#each uiParams}}
|
{{#each uiParams}}
|
||||||
{{#equal this.type "bi-radio"}}
|
{{#equal this.type "select"}}
|
||||||
|
<div class="form-group">
|
||||||
|
<select class="form-control" id="{{this.id}}">
|
||||||
|
<option>{{this.valueOne}}</option>
|
||||||
|
<option>{{this.valueTwo}}</option>
|
||||||
|
<option>{{this.valueThree}}</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
{{/equal}}
|
||||||
|
{{#equal this.type "radio"}}
|
||||||
<input type="radio" id="{{this.id}}"
|
<input type="radio" id="{{this.id}}"
|
||||||
name="{{this.name}}"
|
name="{{this.name}}"
|
||||||
value="{{this.yesValue}}"
|
value="{{this.value}}"
|
||||||
|
class="radio"
|
||||||
checked="checked"
|
checked="checked"
|
||||||
class="radio"
|
|
||||||
onclick="changeLabel('yes')"
|
|
||||||
data-param-type="form"/>
|
data-param-type="form"/>
|
||||||
{{this.yesValue}}
|
{{this.value}}
|
||||||
<input type="radio" id="{{this.id}}"
|
|
||||||
name="{{this.name}}"
|
|
||||||
value="{{this.noValue}}"
|
|
||||||
class="radio"
|
|
||||||
onclick="changeLabel('no')"
|
|
||||||
data-param-type="form"/>
|
|
||||||
{{this.noValue}}
|
|
||||||
<br/> <br/>
|
|
||||||
{{/equal}}
|
{{/equal}}
|
||||||
{{#equal this.type "checkbox"}}
|
{{#equal this.type "checkbox"}}
|
||||||
<input type="{{this.type}}" id="{{this.id}}"
|
<input type="{{this.type}}" id="{{this.id}}"
|
||||||
@ -136,6 +136,13 @@
|
|||||||
data-param-type="form" value=""/>
|
data-param-type="form" value=""/>
|
||||||
<br/>
|
<br/>
|
||||||
{{/equal}}
|
{{/equal}}
|
||||||
|
{{#equal this.type "info"}}
|
||||||
|
<div class="form-group" id="{{this.id}}">
|
||||||
|
<span class="help-block">
|
||||||
|
+ {{this.value}}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
{{/equal}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
<button id="btnSend" type="button" onclick="submitForm('form-{{operation}}')"
|
<button id="btnSend" type="button" onclick="submitForm('form-{{operation}}')"
|
||||||
class="btn btn-default">Send
|
class="btn btn-default">Send
|
||||||
|
|||||||
@ -25,7 +25,7 @@ function operationSelect(selection) {
|
|||||||
$(modalPopupContent).html($(" .operation[data-operation-code=" + selection + "]").html());
|
$(modalPopupContent).html($(" .operation[data-operation-code=" + selection + "]").html());
|
||||||
$(modalPopupContent).data("operation-code", selection);
|
$(modalPopupContent).data("operation-code", selection);
|
||||||
if (selection === "FILE_TRANSFER") {
|
if (selection === "FILE_TRANSFER") {
|
||||||
fillUserName();
|
fileTransferSelection();
|
||||||
}
|
}
|
||||||
showPopup();
|
showPopup();
|
||||||
}
|
}
|
||||||
@ -35,6 +35,63 @@ var resetLoader = function () {
|
|||||||
$('#lbl-execution').addClass("hidden");
|
$('#lbl-execution').addClass("hidden");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function changes/hide/show field respective to the selection.
|
||||||
|
*/
|
||||||
|
function fileTransferSelection() {
|
||||||
|
var userName = document.getElementById('userName');
|
||||||
|
var password = document.getElementById('ftpPassword');
|
||||||
|
var infoTxt = document.getElementById('defaultFileLocation');
|
||||||
|
$(userName).hide();
|
||||||
|
$(password).hide();
|
||||||
|
$(infoTxt).hide();
|
||||||
|
fillUserName();
|
||||||
|
checkAuth();
|
||||||
|
changeLabels();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This changes the text box label when the operation is toggled between To device and From device
|
||||||
|
* and shows an info label for FILE UPLOAD regarding saving location.
|
||||||
|
*/
|
||||||
|
function changeLabels() {
|
||||||
|
var upload = document.getElementById('upload');
|
||||||
|
var download = document.getElementById('download');
|
||||||
|
var infoTxt = document.getElementById('defaultFileLocation');
|
||||||
|
console.log("info text " + infoTxt.value);
|
||||||
|
jQuery(upload).change(function () {
|
||||||
|
document.getElementById('fileURL').placeholder = "File URL";
|
||||||
|
document.getElementById('fileLocation').placeholder = "Location to save file in device";
|
||||||
|
$(infoTxt).show();
|
||||||
|
});
|
||||||
|
jQuery(download).change(function () {
|
||||||
|
document.getElementById('fileURL').placeholder = "URL to upload file from device";
|
||||||
|
document.getElementById('fileLocation').placeholder = "File location in the device";
|
||||||
|
$(infoTxt).hide();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function show/hide username and password text boxes when authentication is toggled.
|
||||||
|
*/
|
||||||
|
function checkAuth() {
|
||||||
|
var auth = document.getElementById('authentication');
|
||||||
|
var userName = document.getElementById('userName');
|
||||||
|
var password = document.getElementById('ftpPassword');
|
||||||
|
jQuery(auth).click(function () {
|
||||||
|
if (this.checked) {
|
||||||
|
$(userName).show();
|
||||||
|
$(password).show();
|
||||||
|
} else {
|
||||||
|
$(userName).hide();
|
||||||
|
$(password).hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function extracts the user name from the file url and fills it in the user name field.
|
||||||
|
*/
|
||||||
function fillUserName() {
|
function fillUserName() {
|
||||||
var inputBox = document.getElementById('fileURL');
|
var inputBox = document.getElementById('fileURL');
|
||||||
var regexp = ':\/\/[^\/]*@';
|
var regexp = ':\/\/[^\/]*@';
|
||||||
@ -53,26 +110,6 @@ function fillUserName() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This changes the text box label when the operation is toggled between FILE UPLOAD and FILE DOWNLOAD
|
|
||||||
* and shows an info label for FILE UPLOAD regarding saving location.
|
|
||||||
* @param type
|
|
||||||
*/
|
|
||||||
function changeLabel(type) {
|
|
||||||
$(".modal #operation-error-msg").addClass("hidden");
|
|
||||||
if (type == "no") {
|
|
||||||
$(".modal #operation-warn-msg span").text("File will be saved in default location if not specified.");
|
|
||||||
$(".modal #operation-warn-msg").removeClass("hidden");
|
|
||||||
document.getElementById('fileURL').placeholder = "File URL";
|
|
||||||
document.getElementById('fileLocation').placeholder = "Location to save file in device";
|
|
||||||
} else {
|
|
||||||
$(".modal #operation-warn-msg").addClass("hidden");
|
|
||||||
document.getElementById('fileURL').placeholder = "URL for file upload";
|
|
||||||
document.getElementById('fileLocation').placeholder = "File location in the device";
|
|
||||||
}
|
|
||||||
fillUserName();
|
|
||||||
}
|
|
||||||
|
|
||||||
function submitForm(formId) {
|
function submitForm(formId) {
|
||||||
$("#btnSend").addClass("hidden");
|
$("#btnSend").addClass("hidden");
|
||||||
$("#lbl-execution").removeClass("hidden");
|
$("#lbl-execution").removeClass("hidden");
|
||||||
@ -223,14 +260,7 @@ function validatePayload(operationCode, payload) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "FILE_TRANSFER":
|
case "FILE_TRANSFER":
|
||||||
if (payload.upload && !payload.fileURL) {
|
returnVal = validateFileTransferParameters(payload);
|
||||||
returnVal = "Please enter the URL of the file";
|
|
||||||
} else if (!payload.upload && !payload.fileURL) {
|
|
||||||
returnVal = "Please enter the FTP URL of the folder to upload file";
|
|
||||||
}
|
|
||||||
else if (!payload.upload && !payload.fileLocation) {
|
|
||||||
returnVal = "Please specify the file location in device";
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -239,6 +269,33 @@ function validatePayload(operationCode, payload) {
|
|||||||
return returnVal;
|
return returnVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function validates all the parameters that are entered related to the file transfer operation.
|
||||||
|
* @param payload
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
function validateFileTransferParameters(payload) {
|
||||||
|
var returnVal = "OK";
|
||||||
|
var auth = document.getElementById('authentication');
|
||||||
|
var protocol = $(document.getElementById('protocol')).find("option:selected").text();
|
||||||
|
if (payload.upload && !payload.fileURL) {
|
||||||
|
returnVal = "Please enter File URL";
|
||||||
|
} else if (!payload.upload && !payload.fileURL) {
|
||||||
|
returnVal = "Please enter the URL to upload file from device";
|
||||||
|
} else if (protocol === "HTTP" && !(payload.fileURL).startsWith("http:")) {
|
||||||
|
returnVal = "Please enter HTTP URL"
|
||||||
|
} else if (protocol === "FTP" && !(payload.fileURL).startsWith("ftp:")) {
|
||||||
|
returnVal = "Please enter FTP URL"
|
||||||
|
} else if (protocol === "SFTP" && !(payload.fileURL).startsWith("sftp:")) {
|
||||||
|
returnVal = "Please enter SFTP URL"
|
||||||
|
} else if (!payload.upload && !payload.fileLocation) {
|
||||||
|
returnVal = "Please specify the file location in device";
|
||||||
|
} else if (auth.checked && !payload.userName) {
|
||||||
|
returnVal = "Please enter the user name if authentication required"
|
||||||
|
}
|
||||||
|
return returnVal;
|
||||||
|
}
|
||||||
|
|
||||||
var generatePayload = function (operationCode, operationData, deviceList) {
|
var generatePayload = function (operationCode, operationData, deviceList) {
|
||||||
var payload;
|
var payload;
|
||||||
var operationType;
|
var operationType;
|
||||||
|
|||||||
@ -140,36 +140,64 @@
|
|||||||
"icon": "fw-save",
|
"icon": "fw-save",
|
||||||
"formParams": [
|
"formParams": [
|
||||||
{
|
{
|
||||||
"type": "bi-radio",
|
"type": "radio",
|
||||||
"name": "selection",
|
"name": "directionSelection",
|
||||||
"id": "upload",
|
"id": "upload",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"yesValue": "FILE DOWNLOAD",
|
"value": "To device"
|
||||||
"noValue": "FILE UPLOAD"
|
},
|
||||||
|
{
|
||||||
|
"type": "radio",
|
||||||
|
"name": "directionSelection",
|
||||||
|
"id": "download",
|
||||||
|
"optional": false,
|
||||||
|
"value": "From device"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "select",
|
||||||
|
"name": "protocolSelection",
|
||||||
|
"id": "protocol",
|
||||||
|
"optional": false,
|
||||||
|
"valueOne": "HTTP",
|
||||||
|
"valueTwo": "FTP",
|
||||||
|
"valueThree": "SFTP",
|
||||||
|
"label": "Protocol"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"id": "fileURL",
|
"id": "fileURL",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"label": "URL for file upload"
|
"label": "URL to upload file from device"
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "text",
|
|
||||||
"id": "userName",
|
|
||||||
"optional": false,
|
|
||||||
"label": "User Name (Ignore if you don't need authentication.)"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "password",
|
|
||||||
"id": "ftpPassword",
|
|
||||||
"optional": false,
|
|
||||||
"label": "Password (Ignore if you don't need authentication.)"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"id": "fileLocation",
|
"id": "fileLocation",
|
||||||
"optional": false,
|
"optional": false,
|
||||||
"label": "File location in the device"
|
"label": "File location in the device"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "info",
|
||||||
|
"id": "defaultFileLocation",
|
||||||
|
"optional": false,
|
||||||
|
"value": "File will be saved in Default download directory if not specified."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "checkbox",
|
||||||
|
"id": "authentication",
|
||||||
|
"optional": true,
|
||||||
|
"label": "Authentication required"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"id": "userName",
|
||||||
|
"optional": false,
|
||||||
|
"label": "User Name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "password",
|
||||||
|
"id": "ftpPassword",
|
||||||
|
"optional": false,
|
||||||
|
"label": "Password (Ignore if not needed)"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"permission": "/device-mgt/devices/owning-device/operations/android/file-transfer"
|
"permission": "/device-mgt/devices/owning-device/operations/android/file-transfer"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user