mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge pull request #446 from madawas/IOTS-296
IOTS-296: Refactoring Policy create/edit units
This commit is contained in:
commit
2d0b0ed94b
@ -59,6 +59,11 @@ var disableInlineError = function (inputField, errorMsg, errorSign) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load all device groups.
|
||||||
|
*
|
||||||
|
* @param callback function to call on loading completion.
|
||||||
|
*/
|
||||||
function loadGroups(callback) {
|
function loadGroups(callback) {
|
||||||
invokerUtil.get(
|
invokerUtil.get(
|
||||||
"/api/device-mgt/v1.0/groups",
|
"/api/device-mgt/v1.0/groups",
|
||||||
@ -68,6 +73,12 @@ function loadGroups(callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates DeviceGroupWrapper object from selected groups.
|
||||||
|
*
|
||||||
|
* @param selectedGroups
|
||||||
|
* @returns {Array} DeviceGroupWrapper list.
|
||||||
|
*/
|
||||||
var createDeviceGroupWrapper = function (selectedGroups) {
|
var createDeviceGroupWrapper = function (selectedGroups) {
|
||||||
var groupObjects = [];
|
var groupObjects = [];
|
||||||
loadGroups(function (deviceGroups) {
|
loadGroups(function (deviceGroups) {
|
||||||
@ -136,7 +147,6 @@ stepForwardFrom["policy-platform"] = function (actionButton) {
|
|||||||
$.template(policyOperationsTemplateCacheKey, policyOperationsTemplateSrc, function (template) {
|
$.template(policyOperationsTemplateCacheKey, policyOperationsTemplateSrc, function (template) {
|
||||||
var content = template();
|
var content = template();
|
||||||
$("#device-type-policy-operations").html(content).removeClass("hidden");
|
$("#device-type-policy-operations").html(content).removeClass("hidden");
|
||||||
// $("#device-type-policy-operations").removeClass("hidden");
|
|
||||||
$(".policy-platform").addClass("hidden");
|
$(".policy-platform").addClass("hidden");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -63,7 +63,7 @@
|
|||||||
<div id="policy-naming-main-error-msg" class="alert alert-danger hidden" role="alert">
|
<div id="policy-naming-main-error-msg" class="alert alert-danger hidden" role="alert">
|
||||||
<i class="icon fw fw-error"></i><span></span>
|
<i class="icon fw fw-error"></i><span></span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="clearfix">
|
||||||
<label class="wr-input-label">
|
<label class="wr-input-label">
|
||||||
Set a name * to your policy<br>
|
Set a name * to your policy<br>
|
||||||
( should be 1-to-30 characters long )
|
( should be 1-to-30 characters long )
|
||||||
|
|||||||
@ -63,6 +63,11 @@ var disableInlineError = function (inputField, errorMsg, errorSign) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load all device groups.
|
||||||
|
*
|
||||||
|
* @param callback function to call on loading completion.
|
||||||
|
*/
|
||||||
function loadGroups(callback) {
|
function loadGroups(callback) {
|
||||||
invokerUtil.get(
|
invokerUtil.get(
|
||||||
"/api/device-mgt/v1.0/groups",
|
"/api/device-mgt/v1.0/groups",
|
||||||
@ -72,6 +77,12 @@ function loadGroups(callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates DeviceGroupWrapper object from selected groups.
|
||||||
|
*
|
||||||
|
* @param selectedGroups
|
||||||
|
* @returns {Array} DeviceGroupWrapper list.
|
||||||
|
*/
|
||||||
var createDeviceGroupWrapper = function (selectedGroups) {
|
var createDeviceGroupWrapper = function (selectedGroups) {
|
||||||
var groupObjects = [];
|
var groupObjects = [];
|
||||||
loadGroups(function (deviceGroups) {
|
loadGroups(function (deviceGroups) {
|
||||||
@ -132,7 +143,18 @@ skipStep["policy-platform"] = function (policyPayloadObj) {
|
|||||||
|
|
||||||
currentlyEffected["roles"] = policyPayloadObj.roles;
|
currentlyEffected["roles"] = policyPayloadObj.roles;
|
||||||
currentlyEffected["users"] = policyPayloadObj.users;
|
currentlyEffected["users"] = policyPayloadObj.users;
|
||||||
currentlyEffected["groups"] = policyPayloadObj.deviceGroups;
|
currentlyEffected["groups"] = [];
|
||||||
|
|
||||||
|
if (policyPayloadObj.deviceGroups) {
|
||||||
|
var deviceGroups = policyPayloadObj.deviceGroups;
|
||||||
|
for (var index in deviceGroups) {
|
||||||
|
if (deviceGroups.hasOwnProperty(index)) {
|
||||||
|
currentlyEffected["groups"].push(deviceGroups[index].name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
currentlyEffected["groups"].push("NONE");
|
||||||
|
}
|
||||||
|
|
||||||
if (currentlyEffected["roles"].length > 0) {
|
if (currentlyEffected["roles"].length > 0) {
|
||||||
$("#user-roles-radio-btn").prop("checked", true);
|
$("#user-roles-radio-btn").prop("checked", true);
|
||||||
@ -178,8 +200,8 @@ skipStep["policy-platform"] = function (policyPayloadObj) {
|
|||||||
script.type = 'text/javascript';
|
script.type = 'text/javascript';
|
||||||
script.src = policyOperationsScriptSrc;
|
script.src = policyOperationsScriptSrc;
|
||||||
$(".wr-advance-operations").prepend(script);
|
$(".wr-advance-operations").prepend(script);
|
||||||
var configuredOperations = operationModule.
|
var configuredOperations = operationModule.populateProfile(policy["platform"],
|
||||||
populateProfile(policy["platform"], policyPayloadObj["profile"]["profileFeaturesList"]);
|
policyPayloadObj["profile"]["profileFeaturesList"]);
|
||||||
polulateProfileOperations(configuredOperations);
|
polulateProfileOperations(configuredOperations);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -222,7 +244,7 @@ stepForwardFrom["policy-criteria"] = function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
policy["selectedGroups"] = $("#groups-input").val();
|
policy["selectedGroups"] = $("#groups-input").val();
|
||||||
if (policy["selectedGroups"].length > 1 || policy["selectedGroups"][0] !== "NONE") {
|
if (policy["selectedGroups"] && (policy["selectedGroups"].length > 1 || policy["selectedGroups"][0] !== "NONE")) {
|
||||||
policy["selectedGroups"] = createDeviceGroupWrapper(policy["selectedGroups"]);
|
policy["selectedGroups"] = createDeviceGroupWrapper(policy["selectedGroups"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user