Adding emm policy listing UI

revert-dabc3590
dilanua 8 years ago
parent bd5ef4158b
commit ca4cb37d58

@ -0,0 +1,640 @@
{{!
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
WSO2 Inc. licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file except
in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
}}
{{unit "cdmf.unit.ui.title" pageTitle="Policy Management"}}
{{unit "cdmf.unit.data-tables-extended"}}
{{#zone "topCss"}}
<style>
.thumbnail.icon:before {
padding-top: 0;
}
</style>
{{/zone}}
{{#zone "breadcrumbs"}}
<li>
<a href="{{@app.context}}/">
<i class="icon fw fw-home"></i>
</a>
</li>
<li>
<a href="{{@app.context}}/policies">
Policies
</a>
</li>
{{/zone}}
{{#zone "navbarActions"}}
{{#if permissions.ADD_ADMIN_POLICY}}
<li>
<a href="{{@app.context}}/policy/add" class="cu-btn">
<span class="icon fw-stack">
<i class="fw fw-add fw-stack-1x"></i>
<i class="fw fw-ring fw-stack-2x"></i>
</span>
Add Policy
</a>
</li>
{{/if}}
{{#if permissions.CHANGE_POLICY_PRIORITY}}
{{#equal noPolicy false}}
<li>
<a href="{{@app.context}}/policy/priority" class="cu-btn">
<span class="icon fw-stack">
<i class="fw fw-throttling-policy fw-stack-1x"></i>
<i class="fw fw-ring fw-stack-2x"></i>
</span>
Policy Priority
</a>
</li>
{{/equal}}
{{/if}}
<li>
<a href="#" class="cu-btn" id="appbar-btn-apply-changes">
<span class="icon fw-stack">
<i class="fw fw-check fw-stack-1x"></i>
<i class="fw fw-ring fw-stack-2x"></i>
</span>
Apply Changes To Devices
</a>
</li>
{{/zone}}
{{#zone "content"}}
{{#equal noPolicy true}}
<div id="ast-container" class="ast-container list-view">
<div class="ctrl-info-panel col-centered text-center wr-login">
<h2>You don't have any policy at the moment.</h2>
<br/>
{{#if permissions.ADD_ADMIN_POLICY}}
<p class="text-center">
<a href="{{@app.context}}/policy/add" class="wr-btn">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-add fw-stack-1x"></i>
</span>
Add New Policy
</a>
</p>
{{/if}}
</div>
</div>
{{/equal}}
{{#equal noPolicy false}}
<div id="loading-content" class="col-centered">
<i class="fw fw-settings fw-spin fw-2x"></i>
Loading policies . . .
<br>
</div>
<table class="table table-striped table-hover list-table display responsive nowrap data-table grid-view hidden"
id="policy-grid">
<thead>
<tr class="sort-row">
<th class="no-sort"></th>
<th class="no-sort"></th>
<th>By Platform</th>
<th>By Ownership Type</th>
<th>By Role</th>
<th>By User</th>
<th>By Compliance Type</th>
<th>By Status</th>
<th class="no-sort"></th>
</tr>
<tr class="filter-row filter-box">
<th class="no-sort"></th>
<th class="no-sort"></th>
<th data-for="By Platform" class="select-filter"></th>
<th data-for="By Ownership Type" class="select-filter"></th>
<th data-for="By Role" class="text-filter"></th>
<th data-for="By User" class="text-filter"></th>
<th data-for="By Compliance Type" class="select-filter"></th>
<th data-for="By Status" class="select-filter"></th>
<th class="no-sort"></th>
</tr>
<tr class="bulk-action-row">
<th colspan="9">
<ul class="tiles">
{{#if removePermitted}}
<li class="square">
<a href="#" data-click-event="remove-form" class="btn square-element policy-remove-link"
data-toggle="modal" data-target="#modalDemo">
<span class="icon fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-delete fw-stack-1x"></i>
</span>
Remove
</a>
</li>
{{/if}}
<li class="square">
<a href="#" data-click-event="remove-form" class="btn square-element policy-publish-link"
data-toggle="modal" data-target="#modalDemo">
<span class="icon fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="glyphicon glyphicon-floppy-saved"></i>
</span>
Publish
</a>
</li>
<li class="square">
<a href="#" data-click-event="remove-form" class="btn square-element policy-unpublish-link"
data-toggle="modal" data-target="#modalDemo">
<span class="icon fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="glyphicon glyphicon-floppy-remove"></i>
</span>
Unpublish
</a>
</li>
</ul>
</th>
</tr>
</thead>
<tbody>
{{#each policyListToView}}
<tr data-type="selectable" data-id="{{id}}" data-status="{{status}}">
<td class="remove-padding icon-only content-fill viewEnabledIcon"
data-url="{{@app.context}}/policy/view?id={{id}}" data-id="{{id}}">
<div class="thumbnail icon">
<img src="{{icon}}"/>
</div>
</td>
<td class="fade-edge"
data-search="{{name}}"
data-display="{{name}}">
<h4>{{name}}</h4>
<div>({{platform}})</div>
{{#equal status "Active/Updated"}}
<span><i class="fw fw-warning icon-success"></i> Active/Updated</span>
{{/equal}}
{{#equal status "Active"}}
<span><i class="fw fw-ok icon-success"></i> Active</span>
{{/equal}}
{{#equal status "Inactive/Updated"}}
<span><i class="fw fw-warning icon-warning"></i> Inactive/Updated</span>
{{/equal}}
{{#equal status "Inactive"}}
<span><i class="fw fw-error icon-danger"></i> Inactive</span>
{{/equal}}
</td>
<td class="fade-edge remove-padding-top"
data-search="{{platform}}"
data-display="{{platform}}">
</td>
<td class="fade-edge remove-padding-top"
data-search="{{ownershipType}}"
data-display="{{ownershipType}}"
data-grid-label="Ownership">
{{ownershipType}}
</td>
<td id="policy-roles" class="fade-edge remove-padding-top"
data-search="{{roles}}"
data-display="{{roles}}"
data-grid-label="Role(s)">
{{roles}}
</td>
<td id="policy-users" class="fade-edge remove-padding-top"
data-search="{{users}}"
data-display="{{users}}"
data-grid-label="User(s)">
{{users}}
</td>
<td class="fade-edge remove-padding-top"
data-search="{{compliance}}"
data-display="{{compliance}}"
data-grid-label="Compliance">
{{compliance}}
</td>
<td id="policy-status" class="fade-edge remove-padding-top"
data-search="{{status}}"
data-display="{{status}}">
</td>
<td class="text-right content-fill text-left-on-grid-view no-wrap">
<a href="{{@app.context}}/policy/edit?id={{id}}"
data-id="{{id}}"
data-click-event="remove-form"
class="btn padding-reduce-on-grid-view policy-update-link">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-edit fw-stack-1x"></i>
</span>
<span class="hidden-xs hidden-on-grid-view">Re-Configure</span>
</a>
</td>
</tr>
{{/each}}
<br class="c-both"/>
</tbody>
</table>
{{/equal}}
<br class="c-both"/>
<div id="content-filter-types" style="display: none">
<div class="sort-title">Sort By</div>
<div class="sort-options">
<a href="#">By Platform<span class="ico-sort-asc"></span></a>
<a href="#">By Ownership Type</a>
<a href="#">By Role</a>
<a href="#">By User</a>
<a href="#">By Compliance Type</a>
<a href="#">By Status</a>
</div>
</div>
<div id="remove-policy-modal-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Do you really want to remove the selected policy(s)?</h3>
<div class="buttons">
<a href="#" id="remove-policy-yes-link" class="btn-operations">
Remove
</a>
<a href="#" id="remove-policy-cancel-link" class="btn-operations">
Cancel
</a>
</div>
</div>
</div>
</div>
</div>
<div id="remove-policy-success-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Done. Selected policy was successfully removed.</h3>
<div class="buttons">
<a href="#" id="remove-policy-success-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="remove-policy-error-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>An unexpected error occurred. Please try again later.</h3>
<div class="buttons">
<a href="#" id="remove-policy-error-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="remove-active-policy-error-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>
You cannot remove policies that have been already applied to devices.
Please deselect active policies from your selection and try again.
</h3>
<div class="buttons">
<a href="#" id="remove-active-policy-error-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="publish-policy-modal-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Do you really want to publish the selected policy(s)?</h3>
<div class="buttons">
<a href="#" id="publish-policy-yes-link" class="btn-operations">Yes</a>
<a href="#" id="publish-policy-cancel-link" class="btn-operations">No</a>
</div>
</div>
</div>
</div>
</div>
<div id="publish-policy-success-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Done. Selected policy was successfully published.</h3>
<div class="buttons">
<a href="#" id="publish-policy-success-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="publish-policy-error-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>An unexpected error occurred. Please try again later.</h3>
<div class="buttons">
<a href="#" id="publish-policy-error-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="unpublish-policy-modal-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Do you really want to unpublish the selected policy(s)?</h3>
<div class="buttons">
<a href="#" id="unpublish-policy-yes-link" class="btn-operations">
Yes
</a>
<a href="#" id="unpublish-policy-cancel-link" class="btn-operations">
No
</a>
</div>
</div>
</div>
</div>
</div>
<div id="unpublish-policy-success-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Done. Selected policy was successfully unpublished.</h3>
<div class="buttons">
<a href="#" id="unpublish-policy-success-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="unpublish-policy-error-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>An unexpected error occurred. Please try again later.</h3>
<div class="buttons">
<a href="#" id="unpublish-policy-error-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="save-policy-priorities-success-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Done. New Policy priorities were successfully updated.</h3>
<div class="buttons">
<a href="#" id="save-policy-priorities-success-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="save-policy-priorities-error-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>An unexpected error occurred. Please try again later.</h3>
<h4 class="message-from-server"></h4>
<div class="buttons">
<a href="#" id="save-policy-priorities-error-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="change-policy-modal-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Do you really want to apply changes to all policies?</h3>
<div class="buttons">
<a href="#" id="change-policy-yes-link" class="btn-operations">
Yes
</a>
<a href="#" id="change-policy-cancel-link" class="btn-operations">
No
</a>
</div>
</div>
</div>
</div>
</div>
<div id="change-policy-success-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Done. Changes applied successfully.</h3>
<div class="buttons">
<a href="#" id="change-policy-success-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="change-policy-error-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>An unexpected error occurred. Please try again later.</h3>
<div class="buttons">
<a href="#" id="change-policy-error-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="errorPolicyUnPublish" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-error fw-stack-1x"></i>
</span>
Action cannot be performed !
</h3>
<h4>
Please select a policy or a list of policies to un-publish.
</h4>
<div class="buttons">
<a href="javascript:hidePopup()" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="errorPolicyUnPublishSelection" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-error fw-stack-1x"></i>
</span>
Action cannot be performed !
</h3>
<h4>
You cannot select already inactive policies to be unpublished.
Please deselect inactive policies and try again.
</h4>
<div class="buttons">
<a href="javascript:hidePopup()" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="active-policy-selection-error" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-error fw-stack-1x"></i>
</span>
Action cannot be performed !
</h3>
<h4>
You cannot select already active policies. Please deselect active policies and try again.
</h4>
<div class="buttons">
<a href="javascript:hidePopup()" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="policy-publish-error" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-error fw-stack-1x"></i>
</span>
Action cannot be performed !
</h3>
<h4>
Please select a policy or a list of policies to publish.
</h4>
<div class="buttons">
<a href="javascript:hidePopup()" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="policy-remove-error" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-error fw-stack-1x"></i>
</span>
Action cannot be performed !
</h3>
<h4>
Please select a policy or a list of policies to remove.
</h4>
<div class="buttons">
<a href="javascript:hidePopup()" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
{{/zone}}
{{#zone "bottomJs"}}
{{js "js/policy-list.js"}}
{{/zone}}

@ -0,0 +1,59 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
function onRequest(context) {
context.handlebars.registerHelper('equal', function (lvalue, rvalue, options) {
if (arguments.length < 3) {
throw new Error("Handlebars Helper equal needs 2 parameters");
}
if (lvalue != rvalue) {
return options.inverse(this);
} else {
return options.fn(this);
}
});
var page = {};
var policyModule = require("/app/modules/business-controllers/policy.js")["policyModule"];
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var response = policyModule.getAllPolicies();
if (response["status"] == "success") {
var policyListToView = response["content"];
page["policyListToView"] = policyListToView;
var policyCount = policyListToView.length;
if (policyCount == 0) {
page["policyListingStatusMsg"] = "No policy is available to be displayed.";
page["noPolicy"] = true;
} else {
page["noPolicy"] = false;
page["isUpdated"] = response["updated"];
}
} else {
// here, response["status"] == "error"
page["policyListingStatusMsg"] = "An unexpected error occurred. Please try again later.";
page["noPolicy"] = true;
}
if (userModule.isAuthorized("/permission/admin/device-mgt/policies/remove")) {
page["removePermitted"] = true;
}
if (userModule.isAuthorized("/permission/admin/device-mgt/policies/update")) {
page["editPermitted"] = true;
}
page.permissions = userModule.getUIPermissions();
return page;
}

@ -0,0 +1,6 @@
{
"version": "1.0.0",
"uri": "/policies",
"extends": "cdmf.page.policies",
"layout": "cdmf.layout.default"
}

@ -0,0 +1,361 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/* sorting function */
var sortUpdateBtn = "#sortUpdateBtn";
// var sortedIDs;
// var dataTableSelection = ".DTTT_selected";
$('#policy-grid').datatables_extended();
// $(".icon .text").res_text(0.2);
var saveNewPrioritiesButton = "#save-new-priorities-button";
var saveNewPrioritiesButtonEnabled = Boolean($(saveNewPrioritiesButton).data("enabled"));
if (saveNewPrioritiesButtonEnabled) {
$(saveNewPrioritiesButton).removeClass("hide");
}
/**
* Following function would execute
* when a user clicks on the list item
* initial mode and with out select mode.
*/
function InitiateViewOption() {
$(location).attr('href', $(this).data("url"));
}
//var addSortableIndexNumbers = function () {
// $(".wr-sortable .list-group-item").not(".ui-sortable-placeholder").each(function (i) {
// $(".wr-sort-index", this).html(i + 1);
// });
//};
//var sortElements = function () {
// addSortableIndexNumbers();
// var sortableElem = ".wr-sortable";
// $(sortableElem).sortable({
// beforeStop: function () {
// sortedIDs = $(this).sortable("toArray");
// addSortableIndexNumbers();
// $(sortUpdateBtn).prop("disabled", false);
// }
// });
// $(sortableElem).disableSelection();
//};
/**
* Modal related stuff are as follows.
*/
var modalPopup = ".wr-modalpopup";
var modalPopupContainer = modalPopup + " .modalpopup-container";
var modalPopupContent = modalPopup + " .modalpopup-content";
var body = "body";
/*
* set popup maximum height function.
*/
function setPopupMaxHeight() {
var maxHeight = "max-height";
var marginTop = "margin-top";
var body = "body";
$(modalPopupContent).css(maxHeight, ($(body).height() - ($(body).height() / 100 * 30)));
$(modalPopupContainer).css(marginTop, (-($(modalPopupContainer).height() / 2)));
}
/*
* show popup function.
*/
function showPopup() {
$(modalPopup).show();
setPopupMaxHeight();
}
/*
* hide popup function.
*/
function hidePopup() {
$(modalPopupContent).html('');
$(modalPopup).hide();
}
/*
* Function to get selected policies.
*/
function getSelectedPolicyStates() {
var policyList = [];
var thisTable = $(".DTTT_selected").closest('.dataTables_wrapper').find('.dataTable').dataTable();
thisTable.api().rows().every(function () {
if ($(this.node()).hasClass('DTTT_selected')) {
policyList.push($(thisTable.api().row(this).node()).data('status'));
}
});
return policyList;
}
/*
* Function to get selected policies.
*/
function getSelectedPolicies() {
var policyList = [];
var thisTable = $(".DTTT_selected").closest('.dataTables_wrapper').find('.dataTable').dataTable();
thisTable.api().rows().every(function () {
if ($(this.node()).hasClass('DTTT_selected')) {
policyList.push($(thisTable.api().row(this).node()).data('id'));
}
});
return policyList;
}
$(document).ready(function () {
// sortElements();
// var policyRoles = $("#policy-roles").text();
// var policyUsers = $("#policy-users").text();
//
// if (!policyRoles) {
// $("#policy-roles").hide();
// }
// if (!policyUsers) {
// $("#policy-users").hide();
// }
/**
* ********************************************
* Click functions related to Policy Listing
* ********************************************
*/
// [1] logic for running apply-changes-for-devices use-case
var applyChangesButtonId = "#appbar-btn-apply-changes";
var isUpdated = $("#is-updated").val();
if (!isUpdated) {
// if no updated policies found, hide button from app bar
$(applyChangesButtonId).addClass("hidden");
} else {
// if updated policies found, show button from app bar
$(applyChangesButtonId).removeClass("hidden");
}
// click-event function for applyChangesButton
$(applyChangesButtonId).click(function () {
var serviceURL = "/api/device-mgt/v1.0/policies/apply-changes";
$(modalPopupContent).html($('#change-policy-modal-content').html());
showPopup();
$("a#change-policy-yes-link").click(function () {
invokerUtil.put(
serviceURL,
null,
// on success
function (data, textStatus, jqXHR) {
if (jqXHR.status == 200) {
$(modalPopupContent).html($('#change-policy-success-content').html());
showPopup();
$("a#change-policy-success-link").click(function () {
hidePopup();
location.reload();
});
}
},
// on error
function (jqXHR) {
console.log(stringify(jqXHR.data));
$(modalPopupContent).html($("#change-policy-error-content").html());
showPopup();
$("a#change-policy-error-link").click(function () {
hidePopup();
});
}
);
});
$("a#change-policy-cancel-link").click(function () {
hidePopup();
});
});
// [2] logic for un-publishing a selected set of Active, Active/Updated policies
$(".policy-unpublish-link").click(function () {
var policyList = getSelectedPolicies();
var statusList = getSelectedPolicyStates();
if (($.inArray("Inactive/Updated", statusList) > -1) || ($.inArray("Inactive", statusList) > -1)) {
// if policies found in Inactive or Inactive/Updated states with in the selection,
// pop-up an error saying
// "You cannot select already inactive policies. Please deselect inactive policies and try again."
$(modalPopupContent).html($("#errorPolicyUnPublishSelection").html());
showPopup();
} else {
var serviceURL = "/api/device-mgt/v1.0/policies/deactivate-policy";
if (policyList.length == 0) {
$(modalPopupContent).html($("#errorPolicyUnPublish").html());
} else {
$(modalPopupContent).html($("#unpublish-policy-modal-content").html());
}
showPopup();
// on-click function for policy un-publishing "yes" button
$("a#unpublish-policy-yes-link").click(function () {
invokerUtil.put(
serviceURL,
policyList,
// on success
function (data, textStatus, jqXHR) {
if (jqXHR.status == 200 && data) {
$(modalPopupContent).html($("#unpublish-policy-success-content").html());
$("a#unpublish-policy-success-link").click(function () {
hidePopup();
location.reload();
});
}
},
// on error
function (jqXHR) {
console.log(stringify(jqXHR.data));
$(modalPopupContent).html($("#unpublish-policy-error-content").html());
$("a#unpublish-policy-error-link").click(function () {
hidePopup();
});
}
);
});
// on-click function for policy un-publishing "cancel" button
$("a#unpublish-policy-cancel-link").click(function () {
hidePopup();
});
}
});
// [3] logic for publishing a selected set of Inactive, Inactive/Updated policies
$(".policy-publish-link").click(function () {
var policyList = getSelectedPolicies();
var statusList = getSelectedPolicyStates();
if (($.inArray("Active/Updated", statusList) > -1) || ($.inArray("Active", statusList) > -1)) {
// if policies found in Active or Active/Updated states with in the selection,
// pop-up an error saying
// "You cannot select already active policies. Please deselect active policies and try again."
$(modalPopupContent).html($("#active-policy-selection-error").html());
showPopup();
} else {
var serviceURL = "/api/device-mgt/v1.0/policies/activate-policy";
if (policyList.length == 0) {
$(modalPopupContent).html($("#policy-publish-error").html());
} else {
$(modalPopupContent).html($("#publish-policy-modal-content").html());
}
showPopup();
// on-click function for policy removing "yes" button
$("a#publish-policy-yes-link").click(function () {
invokerUtil.put(
serviceURL,
policyList,
// on success
function (data, textStatus, jqXHR) {
if (jqXHR.status == 200 && data) {
$(modalPopupContent).html($("#publish-policy-success-content").html());
$("a#publish-policy-success-link").click(function () {
hidePopup();
location.reload();
});
}
},
// on error
function (jqXHR) {
console.log(stringify(jqXHR.data));
$(modalPopupContent).html($("#publish-policy-error-content").html());
$("a#publish-policy-error-link").click(function () {
hidePopup();
});
}
);
});
// on-click function for policy removing "cancel" button
$("a#publish-policy-cancel-link").click(function () {
hidePopup();
});
}
});
// [4] logic for removing a selected set of policies
$(".policy-remove-link").click(function () {
var policyList = getSelectedPolicies();
var statusList = getSelectedPolicyStates();
if (($.inArray("Active/Updated", statusList) > -1) || ($.inArray("Active", statusList) > -1)) {
// if policies found in Active or Active/Updated states with in the selection,
// pop-up an error saying
// "You cannot remove already active policies. Please deselect active policies and try again."
$(modalPopupContent).html($("#active-policy-selection-error").html());
showPopup();
} else {
var serviceURL = "/api/device-mgt/v1.0/policies/remove-policy";
if (policyList.length == 0) {
$(modalPopupContent).html($("#policy-remove-error").html());
} else {
$(modalPopupContent).html($("#remove-policy-modal-content").html());
}
showPopup();
// on-click function for policy removing "yes" button
$("a#remove-policy-yes-link").click(function () {
invokerUtil.post(
serviceURL,
policyList,
// on success
function (data, textStatus, jqXHR) {
if (jqXHR.status == 200 && data) {
$(modalPopupContent).html($("#remove-policy-success-content").html());
$("a#remove-policy-success-link").click(function () {
hidePopup();
location.reload();
});
}
},
// on error
function (jqXHR) {
console.log(stringify(jqXHR.data));
$(modalPopupContent).html($("#remove-policy-error-content").html());
$("a#remove-policy-error-link").click(function () {
hidePopup();
});
}
);
});
// on-click function for policy removing "cancel" button
$("a#remove-policy-cancel-link").click(function () {
hidePopup();
});
}
});
$("#loading-content").remove();
if ($("#policy-listing-status-msg").text()) {
$("#policy-listing-status").removeClass("hidden");
}
$("#policy-grid").removeClass("hidden");
// $(".icon .text").res_text(0.2);
});
Loading…
Cancel
Save