Add policy type and corrective action UI for create policy

feature/appm-store/pbac
Saad Sahibjan 5 years ago
parent 62c01aa508
commit 1d2444f16f

@ -2,36 +2,44 @@
{{#if isAuthorized}} {{#if isAuthorized}}
<span id="logged-in-user" class="hidden" data-username="{{@user.username}}" data-domain="{{@user.domain}}" <span id="logged-in-user" class="hidden" data-username="{{@user.username}}" data-domain="{{@user.domain}}"
data-tenant-id="{{@user.tenantId}}" data-iscloud="{{isCloud}}" data-tenant-id="{{@user.tenantId}}" data-iscloud="{{isCloud}}"
data-isDeviceOwnerEnabled="{{isDeviceOwnerEnabled}}" data-storeapps="{{storeApps}}"> data-isDeviceOwnerEnabled="{{isDeviceOwnerEnabled}}" data-storeapps="{{storeApps}}"
data-corrective-policies="{{correctivePolicies}}">
</span> </span>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<div class="wr-steps hidden"> <div class="wr-steps hidden">
<div class="col-md-3 col-xs-3"> <div class="col-md-2 col-xs-2 col-md-offset-1">
<div class="itm-wiz itm-wiz-current" data-step="policy-platform"> <div class="itm-wiz itm-wiz-current" data-step="policy-platform">
<div class="wiz-no">1</div> <div class="wiz-no">1</div>
<div class="wiz-lbl hidden-xs"><span>Select a platform</span></div> <div class="wiz-lbl hidden-xs"><span>Select a platform</span></div>
</div> </div>
<br class="c-both"/> <br class="c-both"/>
</div> </div>
<div class="col-md-3 col-xs-3"> <div class="col-md-2 col-xs-2">
<div class="itm-wiz" data-step="policy-profile"> <div class="itm-wiz" data-step="policy-profile">
<div class="wiz-no">2</div> <div class="wiz-no">2</div>
<div class="wiz-lbl hidden-xs"><span>Configure profile</span></div> <div class="wiz-lbl hidden-xs"><span>Configure profile</span></div>
</div> </div>
<br class="c-both"/> <br class="c-both"/>
</div> </div>
<div class="col-md-3 col-xs-3"> <div class="col-md-2 col-xs-2">
<div class="itm-wiz" data-step="policy-criteria"> <div class="itm-wiz" data-step="policy-type">
<div class="wiz-no">3</div> <div class="wiz-no">3</div>
<div class="wiz-lbl hidden-xs"><span>Select policy type</span></div>
</div>
<br class="c-both"/>
</div>
<div class="col-md-2 col-xs-2">
<div class="itm-wiz" data-step="policy-criteria">
<div class="wiz-no">4</div>
<div class="wiz-lbl hidden-xs"><span>Assign to groups</span></div> <div class="wiz-lbl hidden-xs"><span>Assign to groups</span></div>
</div> </div>
<br class="c-both"/> <br class="c-both"/>
</div> </div>
<div class="col-md-3 col-xs-3"> <div class="col-md-2 col-xs-2">
<div class="itm-wiz" data-step="policy-naming"> <div class="itm-wiz" data-step="policy-naming">
<div class="wiz-no">4</div> <div class="wiz-no">5</div>
<div class="wiz-lbl hidden-xs"><span>Publish to devices</span></div> <div class="wiz-lbl hidden-xs"><span>Publish to devices</span></div>
</div> </div>
<br class="c-both"/> <br class="c-both"/>
@ -55,7 +63,7 @@
<hr> <hr>
<div class="row"> <div class="row">
<div class="col-lg-12"> <div class="col-lg-12">
<h4 class="hidden-xs">Step 4: Publish to devices</h4> <h4 class="hidden-xs">Step 5: Publish to devices</h4>
<br> <br>
<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>
@ -110,7 +118,7 @@
<hr> <hr>
<div class="row"> <div class="row">
<div class="col-lg-12"> <div class="col-lg-12">
<h4 class="hidden-xs">Step 3: Assign to groups</h4> <h4 class="hidden-xs">Step 4: Assign to groups</h4>
<br> <br>
<div id="policy-criteria-main-error-msg" class="alert alert-danger hidden" role="alert"> <div id="policy-criteria-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>
@ -201,7 +209,7 @@
</div> </div>
<div class="wr-input-control wr-btn-grp"> <div class="wr-input-control wr-btn-grp">
<a href="javascript:void(0)" class="wr-btn wizard-stepper" data-is-back-btn="true" <a href="javascript:void(0)" class="wr-btn wizard-stepper" data-is-back-btn="true"
data-current="policy-criteria" data-next="policy-profile">Back</a> data-current="policy-criteria" data-next="policy-type">Back</a>
<a href="javascript:void(0)" class="wr-btn wizard-stepper" <a href="javascript:void(0)" class="wr-btn wizard-stepper"
data-current="policy-criteria" data-next="policy-naming" data-validate="true">Continue</a> data-current="policy-criteria" data-next="policy-naming" data-validate="true">Continue</a>
</div> </div>
@ -209,7 +217,45 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-centered wr-content policy-type hidden">
<div class="wr-form">
<h1 id="policy-type-page-wizard-title" class="page-sub-title">ADD POLICY</h1>
<hr>
<div id="policy-type-wizard-steps" class="row wr-wizard"></div>
<hr>
<div class="row">
<div class="col-lg-12">
<h4 class="hidden-xs"> Step 3: Select policy type</h4>
<br>
<div id="policy-type-main-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span>
</div>
<div>
<div class="wr-input-control">
<label class="wr-input-control radio light">
<input type="radio" id="policy-type-general" name="policy-type-radio-btn"
value="GENERAL" checked/>
<span class="helper">General Policy</span>
</label>
<label class="wr-input-control radio light">
<input type="radio" id="policy-type-corrective" name="policy-type-radio-btn"
value="CORRECTIVE"/>
<span class="helper">Corrective Policy</span>
</label>
</div>
</div>
<div id="select-general-policy-type"></div>
<div class="wr-input-control wr-btn-grp">
<a href="javascript:void(0)" class="wr-btn wizard-stepper" data-is-back-btn="true"
data-current="policy-type" data-next="policy-profile">Back</a>
<a href="javascript:void(0)" class="wr-btn wizard-stepper"
data-current="policy-type"
data-next="policy-criteria" data-validate="false">Continue</a>
</div>
</div>
</div>
</div>
</div>
<div class="col-centered wr-content policy-profile hidden"> <div class="col-centered wr-content policy-profile hidden">
<div class="wr-form"> <div class="wr-form">
<h1 id="policy-profile-page-wizard-title" class="page-sub-title">ADD POLICY</h1> <h1 id="policy-profile-page-wizard-title" class="page-sub-title">ADD POLICY</h1>
@ -242,7 +288,7 @@
data-current="policy-profile" data-next="policy-platform">Back</a> data-current="policy-profile" data-next="policy-platform">Back</a>
<a href="javascript:void(0)" class="wr-btn wizard-stepper" <a href="javascript:void(0)" class="wr-btn wizard-stepper"
data-current="policy-profile" data-current="policy-profile"
data-next="policy-criteria" data-validate="true">Continue</a> data-next="policy-type" data-validate="true">Continue</a>
</div> </div>
</div> </div>
</div> </div>

@ -118,5 +118,7 @@ function onRequest(context) {
var enrollmentApps = policyModule.getStoreAppsForPolicy(); var enrollmentApps = policyModule.getStoreAppsForPolicy();
types["storeApps"] = JSON.stringify(enrollmentApps["content"]); types["storeApps"] = JSON.stringify(enrollmentApps["content"]);
types["correctivePolicies"] = JSON.stringify(policyModule.getAllPoliciesByType("CORRECTIVE")["content"]);
return types; return types;
} }

@ -39,6 +39,7 @@ var validateInline = {};
var clearInline = {}; var clearInline = {};
var validateStep = {}; var validateStep = {};
var hasPolicyProfileScript = false; var hasPolicyProfileScript = false;
var isCorrectiveActionProfileAdded = false;
var enableInlineError = function (inputField, errorMsg, errorSign) { var enableInlineError = function (inputField, errorMsg, errorSign) {
var fieldIdentifier = "#" + inputField; var fieldIdentifier = "#" + inputField;
@ -221,8 +222,36 @@ stepForwardFrom["policy-profile"] = function () {
*/ */
policy["profile"] = generatePolicyProfile(); policy["profile"] = generatePolicyProfile();
} }
// add policy correction action page
if (!isCorrectiveActionProfileAdded) {
var policyCorrectiveActionTemplateSrc =
"/public/cdmf.unit.policy.corrective-action/templates/policy-corrective-action.hbs";
var policyCorrectiveActionScriptSrc =
"/public/cdmf.unit.policy.corrective-action/js/policy-corrective-action.js";
var policyCorrectiveActionTemplateCacheKey = "policy-corrective-action";
$.template(policyCorrectiveActionTemplateCacheKey, context + policyCorrectiveActionTemplateSrc,
function (template) {
var content = template(
{
"deviceType": policy["platform"],
"correctivePolicies": $("#logged-in-user").data("corrective-policies")
}
);
$("#select-general-policy-type").html(content)
});
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = context + policyCorrectiveActionScriptSrc;
document.head.append(script);
isCorrectiveActionProfileAdded = true
}
// updating next-page wizard title with selected platform // updating next-page wizard title with selected platform
$("#policy-criteria-page-wizard-title").text("ADD " + policy["platform"] + " POLICY"); $("#policy-type-page-wizard-title").text("ADD " + policy["platform"] + " POLICY");
}; };
/** /**
@ -238,6 +267,28 @@ stepBackFrom["policy-profile"] = function () {
} }
}; };
/**
* Forward action of policy type page.
*/
stepForwardFrom["policy-type"] = function () {
policy["type"] = $("input[name=policy-type-radio-btn]:checked").val();
var correctiveActionList = [];
if (policy.type === "GENERAL") {
var selectedCorrectivePolicyId = $("#corrective-policy-input").val();
if (selectedCorrectivePolicyId !== "none") {
var correctiveAction = {
"actionType": "POLICY",
"policyId": selectedCorrectivePolicyId
};
correctiveActionList.push(correctiveAction);
}
}
policy["correctiveActionList"] = correctiveActionList;
//updating next-page wizard title with selected platform
$("#policy-criteria-page-wizard-title").text("ADD " + policy["platform"] + " POLICY");
};
/** /**
* Forward action of policy criteria page. * Forward action of policy criteria page.
*/ */
@ -438,6 +489,8 @@ var savePolicy = function (policy, isActive, serviceURL) {
"compliance": policy["selectedNonCompliantAction"], "compliance": policy["selectedNonCompliantAction"],
"ownershipType": null, "ownershipType": null,
"active": isActive, "active": isActive,
"policyType": policy["type"],
"correctiveActions": policy["correctiveActionList"],
"profile": { "profile": {
"profileName": policy["policyName"], "profileName": policy["policyName"],
"deviceType": policy["platform"], "deviceType": policy["platform"],
@ -458,8 +511,6 @@ var savePolicy = function (policy, isActive, serviceURL) {
payload["deviceGroups"] = policy["selectedGroups"]; payload["deviceGroups"] = policy["selectedGroups"];
} }
payload["policyType"] = "GENERAL";
invokerUtil.post( invokerUtil.post(
serviceURL, serviceURL,
payload, payload,
@ -594,6 +645,16 @@ $(document).ready(function () {
} }
}); });
isCorrectiveActionProfileAdded = false;
$('input[type=radio][name=policy-type-radio-btn]').change(function() {
if ($(this).val() === "CORRECTIVE") {
$("#select-general-policy-type").addClass("hidden");
} else {
$("#select-general-policy-type").removeClass("hidden");
}
});
//Policy wizard stepper //Policy wizard stepper
$(".wizard-stepper").click(function () { $(".wizard-stepper").click(function () {
// button clicked here can be either a continue button or a back button. // button clicked here can be either a continue button or a back button.

Loading…
Cancel
Save