|
|
@ -1,30 +1,30 @@
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
|
|
|
* Copyright (c) 2015-2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
|
|
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
|
|
|
* Version 2.0 (the "License"); you may not use this file except
|
|
|
|
* Version 2.0 (the "License"); you may not use this file except
|
|
|
|
* in compliance with the License.
|
|
|
|
* in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing,
|
|
|
|
* Unless required by applicable law or agreed to in writing,
|
|
|
|
* software distributed under the License is distributed on an
|
|
|
|
* software distributed under the License is distributed on an
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
|
|
|
* KIND, either express or implied. See the License for the
|
|
|
|
* either express or implied. See the License for the
|
|
|
|
* specific language governing permissions and limitations
|
|
|
|
* specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
* under the License.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/* sorting function */
|
|
|
|
/* sorting function */
|
|
|
|
var sortUpdateBtn = "#sortUpdateBtn";
|
|
|
|
var sortUpdateBtn = "#sortUpdateBtn";
|
|
|
|
var sortedIDs;
|
|
|
|
// var sortedIDs;
|
|
|
|
var dataTableSelection = '.DTTT_selected';
|
|
|
|
// var dataTableSelection = ".DTTT_selected";
|
|
|
|
var settings = {
|
|
|
|
var settings = {
|
|
|
|
"sorting": false
|
|
|
|
"sorting": false
|
|
|
|
};
|
|
|
|
};
|
|
|
|
$('#policy-grid').datatables_extended(settings);
|
|
|
|
$('#policy-grid').datatables_extended(settings);
|
|
|
|
$(".icon .text").res_text(0.2);
|
|
|
|
// $(".icon .text").res_text(0.2);
|
|
|
|
|
|
|
|
|
|
|
|
var saveNewPrioritiesButton = "#save-new-priorities-button";
|
|
|
|
var saveNewPrioritiesButton = "#save-new-priorities-button";
|
|
|
|
var saveNewPrioritiesButtonEnabled = Boolean($(saveNewPrioritiesButton).data("enabled"));
|
|
|
|
var saveNewPrioritiesButtonEnabled = Boolean($(saveNewPrioritiesButton).data("enabled"));
|
|
|
@ -41,25 +41,6 @@ function InitiateViewOption() {
|
|
|
|
$(location).attr('href', $(this).data("url"));
|
|
|
|
$(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.
|
|
|
|
* Modal related stuff are as follows.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -129,31 +110,29 @@ function getSelectedPolicies() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
|
$(document).ready(function () {
|
|
|
|
sortElements();
|
|
|
|
|
|
|
|
$("#loading-content").remove();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var policyRoles = $("#policy-roles").text();
|
|
|
|
/**
|
|
|
|
var policyUsers = $("#policy-users").text();
|
|
|
|
* ********************************************
|
|
|
|
|
|
|
|
* Click functions related to Policy Listing
|
|
|
|
|
|
|
|
* ********************************************
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
if (!policyRoles) {
|
|
|
|
// [1] logic for running apply-changes-for-devices use-case
|
|
|
|
$("#policy-roles").hide();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!policyUsers) {
|
|
|
|
|
|
|
|
$("#policy-users").hide();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($("#policy-listing-status-msg").text()) {
|
|
|
|
var applyChangesButtonId = "#appbar-btn-apply-changes";
|
|
|
|
$("#policy-listing-status").removeClass("hidden");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Click functions related to Policy Listing
|
|
|
|
var isUpdated = $("#is-updated").val();
|
|
|
|
var isUpdated = $('#is-updated').val();
|
|
|
|
|
|
|
|
if (!isUpdated) {
|
|
|
|
if (!isUpdated) {
|
|
|
|
$('#appbar-btn-apply-changes').addClass('hidden');
|
|
|
|
// 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");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$("#appbar-btn-apply-changes").click(function () {
|
|
|
|
// click-event function for applyChangesButton
|
|
|
|
var applyPolicyChangesAPI = "/devicemgt_admin/policies/apply-changes";
|
|
|
|
$(applyChangesButtonId).click(function () {
|
|
|
|
|
|
|
|
var serviceURL = "/api/device-mgt/v1.0/policies/apply-changes";
|
|
|
|
modalDialog.header('Do you really want to apply changes to all policies?');
|
|
|
|
modalDialog.header('Do you really want to apply changes to all policies?');
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="#" id="change-policy-yes-link" class="btn-operations">Yes' +
|
|
|
|
modalDialog.footer('<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 btn-default">No</a></div>');
|
|
|
|
'</a><a href="#" id="change-policy-cancel-link" class="btn-operations btn-default">No</a></div>');
|
|
|
@ -161,20 +140,23 @@ $(document).ready(function () {
|
|
|
|
|
|
|
|
|
|
|
|
$("a#change-policy-yes-link").click(function () {
|
|
|
|
$("a#change-policy-yes-link").click(function () {
|
|
|
|
invokerUtil.put(
|
|
|
|
invokerUtil.put(
|
|
|
|
applyPolicyChangesAPI,
|
|
|
|
serviceURL,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
// on success
|
|
|
|
// on success
|
|
|
|
function () {
|
|
|
|
function (data, textStatus, jqXHR) {
|
|
|
|
modalDialog.header('Done. Changes applied successfully.');
|
|
|
|
if (jqXHR.status == 200) {
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="#" id="change-policy-success-link" ' +
|
|
|
|
modalDialog.header('Done. Changes applied successfully.');
|
|
|
|
'class="btn-operations">Ok</a></div>');
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="#" id="change-policy-success-link" ' +
|
|
|
|
$("a#change-policy-success-link").click(function () {
|
|
|
|
'class="btn-operations">Ok</a></div>');
|
|
|
|
modalDialog.hide();
|
|
|
|
$("a#change-policy-success-link").click(function () {
|
|
|
|
location.reload();
|
|
|
|
modalDialog.hide();
|
|
|
|
});
|
|
|
|
location.reload();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// on error
|
|
|
|
// on error
|
|
|
|
function () {
|
|
|
|
function (jqXHR) {
|
|
|
|
|
|
|
|
console.log(stringify(jqXHR.data));
|
|
|
|
modalDialog.header('An unexpected error occurred. Please try again later.');
|
|
|
|
modalDialog.header('An unexpected error occurred. Please try again later.');
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="#" id="change-policy-error-link" ' +
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="#" id="change-policy-error-link" ' +
|
|
|
|
'class="btn-operations">Ok</a></div>');
|
|
|
|
'class="btn-operations">Ok</a></div>');
|
|
|
@ -191,61 +173,26 @@ $(document).ready(function () {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$(sortUpdateBtn).click(function () {
|
|
|
|
// [2] logic for un-publishing a selected set of Active, Active/Updated policies
|
|
|
|
$(sortUpdateBtn).prop("disabled", true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var newPolicyPriorityList = [];
|
|
|
|
|
|
|
|
var policy;
|
|
|
|
|
|
|
|
var i;
|
|
|
|
|
|
|
|
for (i = 0; i < sortedIDs.length; i++) {
|
|
|
|
|
|
|
|
policy = {};
|
|
|
|
|
|
|
|
policy.id = parseInt(sortedIDs[i]);
|
|
|
|
|
|
|
|
policy.priority = i + 1;
|
|
|
|
|
|
|
|
newPolicyPriorityList.push(policy);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var updatePolicyAPI = "/devicemgt_admin/policies/priorities";
|
|
|
|
|
|
|
|
invokerUtil.put(
|
|
|
|
|
|
|
|
updatePolicyAPI,
|
|
|
|
|
|
|
|
newPolicyPriorityList,
|
|
|
|
|
|
|
|
function () {
|
|
|
|
|
|
|
|
modalDialog.header('Done. New Policy priorities were successfully updated.');
|
|
|
|
|
|
|
|
modalDialog.footer('<a href="#" id="save-policy-priorities-success-link" class="btn-operations">Ok' +
|
|
|
|
|
|
|
|
'</a>');
|
|
|
|
|
|
|
|
modalDialog.show();
|
|
|
|
|
|
|
|
$("a#save-policy-priorities-success-link").click(function () {
|
|
|
|
|
|
|
|
modalDialog.hide();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
function () {
|
|
|
|
|
|
|
|
modalDialog.header('An unexpected error occurred. Please try again later.');
|
|
|
|
|
|
|
|
modalDialog.content(html("Message From Server : " + data["statusText"]));
|
|
|
|
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="#" id="save-policy-priorities-error-link" ' +
|
|
|
|
|
|
|
|
'class="btn-operations">Ok</a></div>');
|
|
|
|
|
|
|
|
modalDialog.showAsError();
|
|
|
|
|
|
|
|
$("a#save-policy-priorities-error-link").click(function () {
|
|
|
|
|
|
|
|
modalDialog.hide();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(".policy-unpublish-link").click(function () {
|
|
|
|
$(".policy-unpublish-link").click(function () {
|
|
|
|
var policyList = getSelectedPolicies();
|
|
|
|
var policyList = getSelectedPolicies();
|
|
|
|
var statusList = getSelectedPolicyStates();
|
|
|
|
var statusList = getSelectedPolicyStates();
|
|
|
|
if (($.inArray('Inactive/Updated', statusList) > -1) || ($.inArray('Inactive', statusList) > -1)) {
|
|
|
|
if (($.inArray("Inactive/Updated", statusList) > -1) || ($.inArray("Inactive", statusList) > -1)) {
|
|
|
|
modalDialog.header('Operation cannot be performed !');
|
|
|
|
// if policies found in Inactive or Inactive/Updated states with in the selection,
|
|
|
|
modalDialog.content('You cannot select already inactive policies. Please deselect inactive policies and ' +
|
|
|
|
// pop-up an error saying
|
|
|
|
'try again.');
|
|
|
|
// "You cannot select already inactive policies. Please deselect inactive policies and try again."
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="javascript:modalDialog.hide()" ' +
|
|
|
|
modalDialog.header('Action cannot be performed !');
|
|
|
|
'class="btn-operations">Ok</a></div>');
|
|
|
|
modalDialog.content('You cannot select already inactive policies to be unpublished. Please deselect ' +
|
|
|
|
|
|
|
|
'inactive policies and try again.');
|
|
|
|
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="javascript:modalDialog.hide()" class="btn-operations">Ok</a>' +
|
|
|
|
|
|
|
|
'</div>');
|
|
|
|
modalDialog.showAsAWarning();
|
|
|
|
modalDialog.showAsAWarning();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
var serviceURL = "/devicemgt_admin/policies/inactivate";
|
|
|
|
var serviceURL = "/api/device-mgt/v1.0/policies/deactivate-policy";
|
|
|
|
if (policyList == 0) {
|
|
|
|
if (policyList.length == 0) {
|
|
|
|
modalDialog.header('Operation cannot be performed !');
|
|
|
|
modalDialog.header('Action cannot be performed !');
|
|
|
|
modalDialog.content('Please select a policy or a list of policies to unpublish.');
|
|
|
|
modalDialog.content('Please select a policy or a list of policies to un-publish.');
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="javascript:modalDialog.hide()" ' +
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="javascript:modalDialog.hide()" ' +
|
|
|
|
'class="btn-operations">Ok</a></div>');
|
|
|
|
'class="btn-operations">Ok</a></div>');
|
|
|
|
modalDialog.showAsAWarning();
|
|
|
|
modalDialog.showAsAWarning();
|
|
|
@ -257,22 +204,26 @@ $(document).ready(function () {
|
|
|
|
modalDialog.show();
|
|
|
|
modalDialog.show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// on-click function for policy un-publishing "yes" button
|
|
|
|
$("a#unpublish-policy-yes-link").click(function () {
|
|
|
|
$("a#unpublish-policy-yes-link").click(function () {
|
|
|
|
invokerUtil.put(
|
|
|
|
invokerUtil.post(
|
|
|
|
serviceURL,
|
|
|
|
serviceURL,
|
|
|
|
policyList,
|
|
|
|
policyList,
|
|
|
|
// on success
|
|
|
|
// on success
|
|
|
|
function () {
|
|
|
|
function (data, textStatus, jqXHR) {
|
|
|
|
modalDialog.header('Done. Selected policy was successfully unpublished.');
|
|
|
|
if (jqXHR.status == 200 && data) {
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="#" id="unpublish-policy-success-link" ' +
|
|
|
|
modalDialog.header('Done. Selected policy was successfully unpublished.');
|
|
|
|
'class="btn-operations">Ok</a></div>');
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="#" id="unpublish-policy-success-link" ' +
|
|
|
|
$("a#unpublish-policy-success-link").click(function () {
|
|
|
|
'class="btn-operations">Ok</a></div>');
|
|
|
|
modalDialog.hide();
|
|
|
|
$("a#unpublish-policy-success-link").click(function () {
|
|
|
|
location.reload();
|
|
|
|
modalDialog.hide();
|
|
|
|
});
|
|
|
|
location.reload();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// on error
|
|
|
|
// on error
|
|
|
|
function () {
|
|
|
|
function (jqXHR) {
|
|
|
|
|
|
|
|
console.log(stringify(jqXHR.data));
|
|
|
|
modalDialog.header('An unexpected error occurred. Please try again later.');
|
|
|
|
modalDialog.header('An unexpected error occurred. Please try again later.');
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="#" id="unpublish-policy-error-link" ' +
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="#" id="unpublish-policy-error-link" ' +
|
|
|
|
'class="btn-operations">Ok</a></div>');
|
|
|
|
'class="btn-operations">Ok</a></div>');
|
|
|
@ -284,30 +235,35 @@ $(document).ready(function () {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// on-click function for policy un-publishing "cancel" button
|
|
|
|
$("a#unpublish-policy-cancel-link").click(function () {
|
|
|
|
$("a#unpublish-policy-cancel-link").click(function () {
|
|
|
|
modalDialog.hide();
|
|
|
|
modalDialog.hide();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// [3] logic for publishing a selected set of Inactive, Inactive/Updated policies
|
|
|
|
|
|
|
|
|
|
|
|
$(".policy-publish-link").click(function () {
|
|
|
|
$(".policy-publish-link").click(function () {
|
|
|
|
var policyList = getSelectedPolicies();
|
|
|
|
var policyList = getSelectedPolicies();
|
|
|
|
var statusList = getSelectedPolicyStates();
|
|
|
|
var statusList = getSelectedPolicyStates();
|
|
|
|
if (($.inArray('Active/Updated', statusList) > -1) || ($.inArray('Active', statusList) > -1)) {
|
|
|
|
if (($.inArray("Active/Updated", statusList) > -1) || ($.inArray("Active", statusList) > -1)) {
|
|
|
|
modalDialog.header('Operation cannot be performed !');
|
|
|
|
// 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."
|
|
|
|
|
|
|
|
modalDialog.header('Action cannot be performed !');
|
|
|
|
modalDialog.content('You cannot select already active policies. Please deselect active policies and try ' +
|
|
|
|
modalDialog.content('You cannot select already active policies. Please deselect active policies and try ' +
|
|
|
|
'again.');
|
|
|
|
'again.');
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="javascript:modalDialog.hide()" class="btn-operations">' +
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="javascript:modalDialog.hide()" class="btn-operations">' +
|
|
|
|
'Ok</a></div>');
|
|
|
|
'Ok</a></div>');
|
|
|
|
modalDialog.showAsAWarning();
|
|
|
|
modalDialog.showAsAWarning();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
var serviceURL = "/devicemgt_admin/policies/activate";
|
|
|
|
var serviceURL = "/api/device-mgt/v1.0/policies/activate-policy";
|
|
|
|
if (policyList == 0) {
|
|
|
|
if (policyList.length == 0) {
|
|
|
|
modalDialog.header('Operation cannot be performed !');
|
|
|
|
modalDialog.header('Action cannot be performed !');
|
|
|
|
modalDialog.content('Please select a policy or a list of policies to publish.');
|
|
|
|
modalDialog.content('Please select a policy or a list of policies to publish.');
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="javascript:modalDialog.hide()" class="btn-operations">' +
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="javascript:modalDialog.hide()" ' +
|
|
|
|
'Ok</a></div>');
|
|
|
|
'class="btn-operations">Ok</a></div>');
|
|
|
|
modalDialog.showAsAWarning();
|
|
|
|
modalDialog.showAsAWarning();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
modalDialog.header('Do you really want to publish the selected policy(s)?');
|
|
|
|
modalDialog.header('Do you really want to publish the selected policy(s)?');
|
|
|
@ -316,23 +272,26 @@ $(document).ready(function () {
|
|
|
|
'class="btn-operations btn-default">No</a></div>');
|
|
|
|
'class="btn-operations btn-default">No</a></div>');
|
|
|
|
modalDialog.show();
|
|
|
|
modalDialog.show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// on-click function for policy removing "yes" button
|
|
|
|
$("a#publish-policy-yes-link").click(function () {
|
|
|
|
$("a#publish-policy-yes-link").click(function () {
|
|
|
|
invokerUtil.put(
|
|
|
|
invokerUtil.post(
|
|
|
|
serviceURL,
|
|
|
|
serviceURL,
|
|
|
|
policyList,
|
|
|
|
policyList,
|
|
|
|
// on success
|
|
|
|
// on success
|
|
|
|
function () {
|
|
|
|
function (data, textStatus, jqXHR) {
|
|
|
|
modalDialog.header('Done. Selected policy was successfully published.');
|
|
|
|
if (jqXHR.status == 200 && data) {
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="#" id="publish-policy-success-link" ' +
|
|
|
|
modalDialog.header('Done. Selected policy was successfully published.');
|
|
|
|
'class="btn-operations">Ok</a></div>');
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="#" id="publish-policy-success-link" ' +
|
|
|
|
$("a#publish-policy-success-link").click(function () {
|
|
|
|
'class="btn-operations">Ok</a></div>');
|
|
|
|
modalDialog.hide();
|
|
|
|
$("a#publish-policy-success-link").click(function () {
|
|
|
|
location.reload();
|
|
|
|
modalDialog.hide();
|
|
|
|
});
|
|
|
|
location.reload();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// on error
|
|
|
|
// on error
|
|
|
|
function () {
|
|
|
|
function (jqXHR) {
|
|
|
|
|
|
|
|
console.log(stringify(jqXHR.data));
|
|
|
|
modalDialog.header('An unexpected error occurred. Please try again later.');
|
|
|
|
modalDialog.header('An unexpected error occurred. Please try again later.');
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="#" id="publish-policy-error-link" ' +
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="#" id="publish-policy-error-link" ' +
|
|
|
|
'class="btn-operations">Ok</a></div>');
|
|
|
|
'class="btn-operations">Ok</a></div>');
|
|
|
@ -344,66 +303,64 @@ $(document).ready(function () {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// on-click function for policy removing "cancel" button
|
|
|
|
$("a#publish-policy-cancel-link").click(function () {
|
|
|
|
$("a#publish-policy-cancel-link").click(function () {
|
|
|
|
modalDialog.hide();
|
|
|
|
modalDialog.hide();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// [4] logic for removing a selected set of policies
|
|
|
|
|
|
|
|
|
|
|
|
$(".policy-remove-link").click(function () {
|
|
|
|
$(".policy-remove-link").click(function () {
|
|
|
|
var policyList = getSelectedPolicies();
|
|
|
|
var policyList = getSelectedPolicies();
|
|
|
|
var deletePolicyAPI = "/devicemgt_admin/policies/bulk-remove";
|
|
|
|
var statusList = getSelectedPolicyStates();
|
|
|
|
if (policyList == 0) {
|
|
|
|
if (($.inArray("Active/Updated", statusList) > -1) || ($.inArray("Active", statusList) > -1)) {
|
|
|
|
modalDialog.header('Operation cannot be performed !');
|
|
|
|
// if policies found in Active or Active/Updated states with in the selection,
|
|
|
|
modalDialog.content('Please select a policy or a list of policies to remove.');
|
|
|
|
// pop-up an error saying
|
|
|
|
|
|
|
|
// "You cannot remove already active policies. Please deselect active policies and try again."
|
|
|
|
|
|
|
|
modalDialog.header('Action cannot be performed !');
|
|
|
|
|
|
|
|
modalDialog.content('You cannot select already active policies. Please deselect active policies and try ' +
|
|
|
|
|
|
|
|
'again.');
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="javascript:modalDialog.hide()" class="btn-operations">' +
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="javascript:modalDialog.hide()" class="btn-operations">' +
|
|
|
|
'Ok</a></div>');
|
|
|
|
'Ok</a></div>');
|
|
|
|
modalDialog.showAsAWarning();
|
|
|
|
modalDialog.showAsAWarning();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
modalDialog.header('Do you really want to remove the selected policy(s)?');
|
|
|
|
var serviceURL = "/api/device-mgt/v1.0/policies/remove-policy";
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="#" id="remove-policy-yes-link" class=' +
|
|
|
|
if (policyList.length == 0) {
|
|
|
|
'"btn-operations">Remove</a> <a href="#" id="remove-policy-cancel-link" ' +
|
|
|
|
modalDialog.header('Action cannot be performed !');
|
|
|
|
'class="btn-operations btn-default">Cancel</a></div>');
|
|
|
|
modalDialog.content('Please select a policy or a list of policies to remove.');
|
|
|
|
modalDialog.show();
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="javascript:modalDialog.hide()" ' +
|
|
|
|
}
|
|
|
|
'class="btn-operations">Ok</a></div>');
|
|
|
|
|
|
|
|
modalDialog.showAsAWarning();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
modalDialog.header('Do you really want to remove the selected policy(s)?');
|
|
|
|
|
|
|
|
modalDialog.footer('<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 btn-default">Cancel</a></div>');
|
|
|
|
|
|
|
|
modalDialog.show();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$("a#remove-policy-yes-link").click(function () {
|
|
|
|
// on-click function for policy removing "yes" button
|
|
|
|
invokerUtil.post(
|
|
|
|
$("a#remove-policy-yes-link").click(function () {
|
|
|
|
deletePolicyAPI,
|
|
|
|
invokerUtil.post(
|
|
|
|
policyList,
|
|
|
|
serviceURL,
|
|
|
|
// on success
|
|
|
|
policyList,
|
|
|
|
function (data) {
|
|
|
|
// on success
|
|
|
|
data = JSON.parse(data);
|
|
|
|
function (data, textStatus, jqXHR) {
|
|
|
|
if (data.errorMessage) {
|
|
|
|
if (jqXHR.status == 200 && data) {
|
|
|
|
modalDialog.header('Cannot Remove Policies.');
|
|
|
|
modalDialog.header('Done. Selected policy was successfully removed.');
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="#" id="remove-policy-error-devices" ' +
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="#" id="remove-policy-success-link" ' +
|
|
|
|
'class="btn-operations">Ok</a></div>');
|
|
|
|
'class="btn-operations">Ok</a></div>');
|
|
|
|
modalDialog.showAsError();
|
|
|
|
$("a#remove-policy-success-link").click(function () {
|
|
|
|
$("a#remove-policy-error-devices").click(function () {
|
|
|
|
modalDialog.hide();
|
|
|
|
modalDialog.hide();
|
|
|
|
location.reload();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
modalDialog.header('Done. Selected policy was successfully removed.');
|
|
|
|
},
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="#" id="remove-policy-success-link" ' +
|
|
|
|
// on error
|
|
|
|
'class="btn-operations">Ok</a></div>');
|
|
|
|
function (jqXHR) {
|
|
|
|
$("a#remove-policy-success-link").click(function () {
|
|
|
|
console.log(stringify(jqXHR.data));
|
|
|
|
var thisTable = $(".DTTT_selected").closest('.dataTables_wrapper').find('.dataTable').dataTable();
|
|
|
|
|
|
|
|
thisTable.api().rows('.DTTT_selected').remove().draw(false);
|
|
|
|
|
|
|
|
modalDialog.hide();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
// on error
|
|
|
|
|
|
|
|
function (data) {
|
|
|
|
|
|
|
|
if (JSON.parse(data.responseText).errorMessage) {
|
|
|
|
|
|
|
|
modalDialog.header('Cannot Remove Policies.');
|
|
|
|
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="#" id="remove-policy-error-devices" ' +
|
|
|
|
|
|
|
|
'class="btn-operations">Ok</a></div>');
|
|
|
|
|
|
|
|
modalDialog.showAsError();
|
|
|
|
|
|
|
|
$("a#remove-policy-error-devices").click(function () {
|
|
|
|
|
|
|
|
modalDialog.hide();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
modalDialog.header('An unexpected error occurred. Please try again later.');
|
|
|
|
modalDialog.header('An unexpected error occurred. Please try again later.');
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="#" id="remove-policy-error-link" ' +
|
|
|
|
modalDialog.footer('<div class="buttons"><a href="#" id="remove-policy-error-link" ' +
|
|
|
|
'class="btn-operations">Ok</a></div>');
|
|
|
|
'class="btn-operations">Ok</a></div>');
|
|
|
@ -412,15 +369,19 @@ $(document).ready(function () {
|
|
|
|
modalDialog.hide();
|
|
|
|
modalDialog.hide();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$("a#remove-policy-cancel-link").click(function () {
|
|
|
|
// on-click function for policy removing "cancel" button
|
|
|
|
modalDialog.hide();
|
|
|
|
$("a#remove-policy-cancel-link").click(function () {
|
|
|
|
});
|
|
|
|
modalDialog.hide();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$("#loading-content").remove();
|
|
|
|
$("#loading-content").remove();
|
|
|
|
|
|
|
|
if ($("#policy-listing-status-msg").text()) {
|
|
|
|
|
|
|
|
$("#policy-listing-status").removeClass("hidden");
|
|
|
|
|
|
|
|
}
|
|
|
|
$("#policy-grid").removeClass("hidden");
|
|
|
|
$("#policy-grid").removeClass("hidden");
|
|
|
|
$(".icon .text").res_text(0.2);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|