IOTS-296: Fixing issue with device type icon

This commit fixes an issue which is unable to load device type icons in the policy listing page.
revert-70aa11f8
Madawa Soysa 8 years ago
parent 0dfde40b7c
commit 7aada58472

@ -34,6 +34,7 @@
</a>
</li>
<li>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/policies">
Policies
</a>
@ -41,18 +42,24 @@
{{/zone}}
{{#zone "navbarActions"}}
{{#if managePermitted}}
<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 permissions.ADD_ADMIN_POLICY}}
{{#equal noPolicy false}}
<li>
<!--suppress HtmlUnknownTarget -->
<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 New Policy
</a>
</li>
{{/equal}}
{{/if}}
{{#if permissions.CHANGE_POLICY_PRIORITY}}
{{#equal noPolicy false}}
<li>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/policy/priority" class="cu-btn">
<span class="icon fw-stack">
<i class="fw fw-throttling-policy fw-stack-1x"></i>
@ -75,44 +82,37 @@
{{/zone}}
{{#zone "content"}}
{{#equal isUpdated true}}
<input type="hidden" id="is-updated" value="UPDATED">
{{/equal}}
{{#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 managePermitted}}
<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>
<h3 class="text-muted">
<i class="fw fw-policy fw-3x"></i>
</h3>
<h3 class="text-muted">You do not have any device policy at the moment</h3>
{{#if permissions.ADD_ADMIN_POLICY}}
<h3>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/policy/add" class="btn-operations btn-default">
<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>
</h3>
{{/if}}
</div>
</div>
{{/equal}}
{{#equal noPolicy false}}
{{#equal isUpdated true}}
<input type="hidden" id="is-updated" name="country" value="UPDATED">
{{/equal}}
<div id="loading-content" class="col-centered">
<i class="fw fw-settings fw-spin fw-2x"></i>
Loading policies . . .
<br>
</div>
<div id="policy-listing-status" class="raw hidden">
<ul style="list-style-type: none;">
<li class="message message-info">
<h4>
<i class="icon fw fw-info"></i>
<a id="policy-listing-status-msg">{{policyListingStatusMsg}}</a>
</h4>
</li>
</ul>
</div>
<table class="table table-striped table-hover list-table display responsive nowrap data-table grid-view hidden"
id="policy-grid">
<thead>
@ -141,10 +141,9 @@
<tr class="bulk-action-row">
<th colspan="9">
<ul class="tiles">
{{#if managePermitted}}
{{#if removePermitted}}
<li class="square">
<a href="#" data-click-event="remove-form"
class="btn square-element policy-remove-link"
<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>
@ -155,8 +154,7 @@
</li>
{{/if}}
<li class="square">
<a href="#" data-click-event="remove-form"
class="btn square-element policy-publish-link"
<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>
@ -166,8 +164,7 @@
</a>
</li>
<li class="square">
<a href="#" data-click-event="remove-form"
class="btn square-element policy-unpublish-link"
<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>
@ -185,56 +182,73 @@
{{#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}}&type={{platform}}"
data-id="{{id}}">
<div class="thumbnail icon">
<img src="{{icon}}"/>
data-url="{{@app.context}}/policy/view?id={{id}}" data-id="{{id}}">
<div class="thumbnail icon" style="padding-top: 30px; padding-bottom: 30px;">
<i class="fw fw-{{deviceTypeIcon}}" style="font-size: 59px"></i>
</div>
</td>
<td class="fade-edge" data-search="{{name}}" data-display="{{name}}">
<td class="fade-edge"
data-search="{{name}}"
data-display="{{name}}">
<h4>{{name}}</h4>
<div>({{platform}})</div>
{{#equal status "Active/Updated"}}
<i class="fw fw-warning icon-success"></i> Active/Updated</span>
<span><i class="fw fw-warning icon-success"></i> Active/Updated</span>
{{/equal}}
{{#equal status "Active"}}
<i class="fw fw-ok icon-success"></i> Active</span>
<span><i class="fw fw-ok icon-success"></i> Active</span>
{{/equal}}
{{#equal status "Inactive/Updated"}}
<i class="fw fw-warning icon-warning"></i> Inactive/Updated</span>
<span><i class="fw fw-warning icon-warning"></i> Inactive/Updated</span>
{{/equal}}
{{#equal status "Inactive"}}
<i class="fw fw-error icon-danger"></i> Inactive</span>
<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}}"
<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-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-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}}&type={{platform}}"
<!--suppress HtmlUnknownTarget -->
<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="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}}

@ -6,12 +6,12 @@
* in compliance with the License.
* 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,
* 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
* "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.
*/
@ -37,27 +37,23 @@ function onRequest(context) {
var policyCount = policyListToView.length;
if (policyCount == 0) {
page["policyListingStatusMsg"] = "No policy is available to be displayed.";
page["saveNewPrioritiesButtonEnabled"] = false;
page["noPolicy"] = true;
} else if (policyCount == 1) {
page["saveNewPrioritiesButtonEnabled"] = false;
page["noPolicy"] = false;
page["isUpdated"] = response["updated"];
} else {
page["saveNewPrioritiesButtonEnabled"] = true;
page["noPolicy"] = false;
page["isUpdated"] = response["updated"];
}
} else {
// here, response["status"] == "error"
page["policyListToView"] = [];
page["policyListingStatusMsg"] = "An unexpected error occurred @ backend. Please try again later.";
page["saveNewPrioritiesButtonEnabled"] = false;
page["policyListingStatusMsg"] = "An unexpected error occurred. Please try again later.";
page["noPolicy"] = true;
}
if (userModule.isAuthorized("/permission/admin/device-mgt/policies/manage")) {
page.managePermitted = 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;
}

@ -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,
* 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
* 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
* "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';
// var sortedIDs;
// var dataTableSelection = ".DTTT_selected";
var settings = {
"sorting": false
};
$('#policy-grid').datatables_extended(settings);
$(".icon .text").res_text(0.2);
// $(".icon .text").res_text(0.2);
var saveNewPrioritiesButton = "#save-new-priorities-button";
var saveNewPrioritiesButtonEnabled = Boolean($(saveNewPrioritiesButton).data("enabled"));
@ -41,25 +41,6 @@ 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.
*/
@ -129,31 +110,29 @@ function getSelectedPolicies() {
}
$(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) {
$("#policy-roles").hide();
}
if (!policyUsers) {
$("#policy-users").hide();
}
// [1] logic for running apply-changes-for-devices use-case
if ($("#policy-listing-status-msg").text()) {
$("#policy-listing-status").removeClass("hidden");
}
var applyChangesButtonId = "#appbar-btn-apply-changes";
// Click functions related to Policy Listing
var isUpdated = $('#is-updated').val();
var isUpdated = $("#is-updated").val();
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 () {
var applyPolicyChangesAPI = "/devicemgt_admin/policies/apply-changes";
// click-event function for applyChangesButton
$(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.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>');
@ -161,20 +140,23 @@ $(document).ready(function () {
$("a#change-policy-yes-link").click(function () {
invokerUtil.put(
applyPolicyChangesAPI,
serviceURL,
null,
// on success
function () {
modalDialog.header('Done. Changes applied successfully.');
modalDialog.footer('<div class="buttons"><a href="#" id="change-policy-success-link" ' +
'class="btn-operations">Ok</a></div>');
$("a#change-policy-success-link").click(function () {
modalDialog.hide();
location.reload();
});
function (data, textStatus, jqXHR) {
if (jqXHR.status == 200) {
modalDialog.header('Done. Changes applied successfully.');
modalDialog.footer('<div class="buttons"><a href="#" id="change-policy-success-link" ' +
'class="btn-operations">Ok</a></div>');
$("a#change-policy-success-link").click(function () {
modalDialog.hide();
location.reload();
});
}
},
// on error
function () {
function (jqXHR) {
console.log(stringify(jqXHR.data));
modalDialog.header('An unexpected error occurred. Please try again later.');
modalDialog.footer('<div class="buttons"><a href="#" id="change-policy-error-link" ' +
'class="btn-operations">Ok</a></div>');
@ -191,61 +173,26 @@ $(document).ready(function () {
});
});
$(sortUpdateBtn).click(function () {
$(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();
});
}
);
});
// [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)) {
modalDialog.header('Operation cannot be performed !');
modalDialog.content('You cannot select already inactive policies. Please deselect inactive policies and ' +
'try again.');
modalDialog.footer('<div class="buttons"><a href="javascript:modalDialog.hide()" ' +
'class="btn-operations">Ok</a></div>');
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."
modalDialog.header('Action cannot be performed !');
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();
} else {
var serviceURL = "/devicemgt_admin/policies/inactivate";
if (policyList == 0) {
modalDialog.header('Operation cannot be performed !');
modalDialog.content('Please select a policy or a list of policies to unpublish.');
var serviceURL = "/api/device-mgt/v1.0/policies/deactivate-policy";
if (policyList.length == 0) {
modalDialog.header('Action cannot be performed !');
modalDialog.content('Please select a policy or a list of policies to un-publish.');
modalDialog.footer('<div class="buttons"><a href="javascript:modalDialog.hide()" ' +
'class="btn-operations">Ok</a></div>');
modalDialog.showAsAWarning();
@ -257,22 +204,26 @@ $(document).ready(function () {
modalDialog.show();
}
// on-click function for policy un-publishing "yes" button
$("a#unpublish-policy-yes-link").click(function () {
invokerUtil.put(
invokerUtil.post(
serviceURL,
policyList,
// on success
function () {
modalDialog.header('Done. Selected policy was successfully unpublished.');
modalDialog.footer('<div class="buttons"><a href="#" id="unpublish-policy-success-link" ' +
'class="btn-operations">Ok</a></div>');
$("a#unpublish-policy-success-link").click(function () {
modalDialog.hide();
location.reload();
});
function (data, textStatus, jqXHR) {
if (jqXHR.status == 200 && data) {
modalDialog.header('Done. Selected policy was successfully unpublished.');
modalDialog.footer('<div class="buttons"><a href="#" id="unpublish-policy-success-link" ' +
'class="btn-operations">Ok</a></div>');
$("a#unpublish-policy-success-link").click(function () {
modalDialog.hide();
location.reload();
});
}
},
// on error
function () {
function (jqXHR) {
console.log(stringify(jqXHR.data));
modalDialog.header('An unexpected error occurred. Please try again later.');
modalDialog.footer('<div class="buttons"><a href="#" id="unpublish-policy-error-link" ' +
'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 () {
modalDialog.hide();
});
}
});
// [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)) {
modalDialog.header('Operation cannot be performed !');
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."
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">' +
'Ok</a></div>');
modalDialog.showAsAWarning();
} else {
var serviceURL = "/devicemgt_admin/policies/activate";
if (policyList == 0) {
modalDialog.header('Operation cannot be performed !');
var serviceURL = "/api/device-mgt/v1.0/policies/activate-policy";
if (policyList.length == 0) {
modalDialog.header('Action cannot be performed !');
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">' +
'Ok</a></div>');
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 publish the selected policy(s)?');
@ -316,23 +272,26 @@ $(document).ready(function () {
'class="btn-operations btn-default">No</a></div>');
modalDialog.show();
}
// on-click function for policy removing "yes" button
$("a#publish-policy-yes-link").click(function () {
invokerUtil.put(
invokerUtil.post(
serviceURL,
policyList,
// on success
function () {
modalDialog.header('Done. Selected policy was successfully published.');
modalDialog.footer('<div class="buttons"><a href="#" id="publish-policy-success-link" ' +
'class="btn-operations">Ok</a></div>');
$("a#publish-policy-success-link").click(function () {
modalDialog.hide();
location.reload();
});
function (data, textStatus, jqXHR) {
if (jqXHR.status == 200 && data) {
modalDialog.header('Done. Selected policy was successfully published.');
modalDialog.footer('<div class="buttons"><a href="#" id="publish-policy-success-link" ' +
'class="btn-operations">Ok</a></div>');
$("a#publish-policy-success-link").click(function () {
modalDialog.hide();
location.reload();
});
}
},
// on error
function () {
function (jqXHR) {
console.log(stringify(jqXHR.data));
modalDialog.header('An unexpected error occurred. Please try again later.');
modalDialog.footer('<div class="buttons"><a href="#" id="publish-policy-error-link" ' +
'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 () {
modalDialog.hide();
});
}
});
// [4] logic for removing a selected set of policies
$(".policy-remove-link").click(function () {
var policyList = getSelectedPolicies();
var deletePolicyAPI = "/devicemgt_admin/policies/bulk-remove";
if (policyList == 0) {
modalDialog.header('Operation cannot be performed !');
modalDialog.content('Please select a policy or a list of policies to remove.');
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."
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">' +
'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();
}
var serviceURL = "/api/device-mgt/v1.0/policies/remove-policy";
if (policyList.length == 0) {
modalDialog.header('Action cannot be performed !');
modalDialog.content('Please select a policy or a list of policies to remove.');
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 () {
invokerUtil.post(
deletePolicyAPI,
policyList,
// on success
function (data) {
data = JSON.parse(data);
if (data.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('Done. Selected policy was successfully removed.');
modalDialog.footer('<div class="buttons"><a href="#" id="remove-policy-success-link" ' +
'class="btn-operations">Ok</a></div>');
$("a#remove-policy-success-link").click(function () {
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 {
// 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) {
modalDialog.header('Done. Selected policy was successfully removed.');
modalDialog.footer('<div class="buttons"><a href="#" id="remove-policy-success-link" ' +
'class="btn-operations">Ok</a></div>');
$("a#remove-policy-success-link").click(function () {
modalDialog.hide();
location.reload();
});
}
},
// on error
function (jqXHR) {
console.log(stringify(jqXHR.data));
modalDialog.header('An unexpected error occurred. Please try again later.');
modalDialog.footer('<div class="buttons"><a href="#" id="remove-policy-error-link" ' +
'class="btn-operations">Ok</a></div>');
@ -412,15 +369,19 @@ $(document).ready(function () {
modalDialog.hide();
});
}
}
);
});
);
});
$("a#remove-policy-cancel-link").click(function () {
modalDialog.hide();
});
// on-click function for policy removing "cancel" button
$("a#remove-policy-cancel-link").click(function () {
modalDialog.hide();
});
}
});
$("#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