revert-70aa11f8
hasuniea 8 years ago
commit ed5e954194

@ -374,7 +374,7 @@ public interface PolicyManagementService {
required = true) required = true)
List<Integer> policyIds); List<Integer> policyIds);
@POST @PUT
@Path("/deactivate-policy") @Path("/deactivate-policy")
@ApiOperation( @ApiOperation(
consumes = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON,

@ -15,7 +15,7 @@
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
}} }}
{{unit "cdmf.unit.ui.title" pageTitle="Policy Management"}} {{unit "cdmf.unit.ui.title" pageTitle="Policy Management | Policy Priorities"}}
{{#zone "breadcrumbs"}} {{#zone "breadcrumbs"}}
<li> <li>
@ -24,10 +24,17 @@
</a> </a>
</li> </li>
<li> <li>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/policies"> <a href="{{@app.context}}/policies">
Policies Policies
</a> </a>
</li> </li>
<li>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/policy/priority">
Priorities
</a>
</li>
{{/zone}} {{/zone}}
{{#zone "content"}} {{#zone "content"}}

@ -1,5 +1,5 @@
{ {
"version": "1.0.0", "version": "1.0.0",
"uri": "/policy/priority", "uri": "/policy/priority",
"layout": "cdmf.layout.default" "layout": "cdmf.layout.default"
} }

@ -15,20 +15,19 @@
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
}} }}
<div class="row wr-device-board"> <div class="row wr-device-board">
<div class="col-lg-12 wr-secondary-bar"> <div class="col-lg-12 wr-secondary-bar">
<span class="page-sub-title"> <span class="page-sub-title">
&nbsp;Policy List by priority order &nbsp;Policy List by priority order
</span> </span>
</div> </div>
</div> <div class="row">
<div class="row"> <div class="col-md-12">
<div class="col-md-12"> <span id="policy-listing-status-msg">{{policyListingStatusMsg}}</span>
<span id="policy-listing-status-msg">{{policyListingStatusMsg}}</span> <div class="wr-list-group wr-sortable policy-list">
{{#each policyListToView}}
<div class="wr-list-group wr-sortable policy-list"> <span class="list-group-item " place="place_{{id}}" id="{{id}}">
{{#each policyListToView}}
<span class="list-group-item " place="place_{{id}}" id="{{id}}">
<div class="row no-gutter"> <div class="row no-gutter">
<div class="col-xs-12 col-sm-4 col-md-4 col-lg-4 clearfix"> <div class="col-xs-12 col-sm-4 col-md-4 col-lg-4 clearfix">
<span class="wr-sortable-icon"><i class="fw fw-sort"></i></span> <span class="wr-sortable-icon"><i class="fw fw-sort"></i></span>
@ -40,15 +39,7 @@
</span> </span>
</span> </span>
<span class="wr-list-icon"> <span class="wr-list-icon">
{{#equal platform "android"}} <i class=" fw fw-{{platform}}"></i>
<i class=" fw fw-android"></i>
{{/equal}}
{{#equal platform "windows"}}
<i class=" fw fw-windows"></i>
{{/equal}}
{{#equal platform "ios"}}
<i class=" fw fw-apple"></i>
{{/equal}}
</span> </span>
<span class="wr-list-desc"> <span class="wr-list-desc">
<h3 class="wr-list-name">{{name}}</h3> <h3 class="wr-list-name">{{name}}</h3>
@ -62,19 +53,20 @@
<b>Ownership Type : </b> {{ownershipType}} <b>Ownership Type : </b> {{ownershipType}}
</div> </div>
</div> </div>
{{#if roles}} {{#equal roles "None"}}
<div class="wr-desc-list-configs highlight col-xs-12 col-sm-4 col-md-4 col-lg-4"> <div class="wr-desc-list-configs highlight col-xs-12 col-sm-4 col-md-4 col-lg-4">
<div> <div>
<b>Assigned Role(s) : </b> {{roles}} <b>Assigned User(s) : </b> {{users}}
</div> </div>
</div> </div>
{{else}} {{/equal}}
{{#equal users "None"}}
<div class="wr-desc-list-configs highlight col-xs-12 col-sm-4 col-md-4 col-lg-4"> <div class="wr-desc-list-configs highlight col-xs-12 col-sm-4 col-md-4 col-lg-4">
<div> <div>
<b>Assigned User(s) : </b> {{users}} <b>Assigned Role(s) : </b> {{roles}}
</div> </div>
</div> </div>
{{/if}} {{/equal}}
<div class="wr-desc-list-configs col-xs-12 col-sm-4 col-md-4 col-lg-4"> <div class="wr-desc-list-configs col-xs-12 col-sm-4 col-md-4 col-lg-4">
<div> <div>
<b>Compliance Type :</b> {{compliance}} <b>Compliance Type :</b> {{compliance}}
@ -84,120 +76,112 @@
</div> </div>
</div> </div>
</span> </span>
{{/each}} {{/each}}
</div>
{{#equal noPolicy false}}
<div id="save-new-priorities-button" class="wr-input-control wr-btn-grp">
<button class="wr-btn hide" id="sortUpdateBtn" data-policycount="{{policyCount}}"
data-enabled="{{saveNewPrioritiesButtonEnabled}}" disabled>Save New Priority
Order
</button>
<button class="wr-btn" id="applyChangesBtn">Apply Changes to Devices</button>
</div> </div>
{{/equal}} {{#equal noPolicy false}}
<div id="save-new-priorities-button" class="wr-input-control wr-btn-grp">
<button class="wr-btn hide" id="sortUpdateBtn" data-policycount="{{policyCount}}"
data-enabled="{{saveNewPrioritiesButtonEnabled}}" disabled>Save New Priority Order
</button>
<button class="wr-btn" id="applyChangesBtn">Apply Changes to Devices</button>
</div>
{{/equal}}
</div>
</div> </div>
</div>
<div id="change-policy-modal-content" class="hide"> <div id="apply-changes-modal-content" class="hide">
<div class="content"> <div class="content">
<div class="row"> <div class="row">
<div class="col-lg-5 col-md-6 col-centered"> <div class="col-lg-5 col-md-6 col-centered">
<h3>Do you really want to apply changes to all policies?</h3> <h3>Do you really want to apply changes to all policies?</h3>
<div class="buttons"> <div class="buttons">
<a href="javascript:void(0)" id="change-policy-yes-link" class="btn-operations"> <a href="javascript:void(0)" id="apply-changes-yes-link" class="btn-operations">
Yes Yes
</a> </a>
<a href="javascript:void(0)" id="change-policy-cancel-link" <a href="javascript:void(0)" id="apply-changes-cancel-link" class="btn-operations">
class="btn-operations"> No
No </a>
</a> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div>
<div id="change-policy-success-content" class="hide"> <div id="apply-changes-success-content" class="hide">
<div class="content"> <div class="content">
<div class="row"> <div class="row">
<div class="col-lg-5 col-md-6 col-centered"> <div class="col-lg-5 col-md-6 col-centered">
<h3>Done. Changes applied successfully.</h3> <h3>Done. Changes applied successfully.</h3>
<div class="buttons"> <div class="buttons">
<a href="javascript:void(0)" id="change-policy-success-link" <a href="javascript:void(0)" id="apply-changes-success-link" class="btn-operations">
class="btn-operations"> Ok
Ok </a>
</a> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div>
<div id="change-policy-error-content" class="hide"> <div id="apply-changes-error-content" class="hide">
<div class="content"> <div class="content">
<div class="row"> <div class="row">
<div class="col-lg-5 col-md-6 col-centered"> <div class="col-lg-5 col-md-6 col-centered">
<h3>An unexpected error occurred. Please try again later.</h3> <h3>An unexpected error occurred. Please try again later.</h3>
<div class="buttons"> <div class="buttons">
<a href="javascript:void(0)" id="change-policy-error-link" <a href="javascript:void(0)" id="apply-changes-error-link" class="btn-operations">
class="btn-operations"> Ok
Ok </a>
</a> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div>
<div id="remove-policy-error-content" class="hide"> <div id="remove-policy-error-content" class="hide">
<div class="content"> <div class="content">
<div class="row"> <div class="row">
<div class="col-lg-5 col-md-6 col-centered"> <div class="col-lg-5 col-md-6 col-centered">
<h3>An unexpected error occurred. Please try again later.</h3> <h3>An unexpected error occurred. Please try again later.</h3>
<div class="buttons"> <div class="buttons">
<a href="javascript:void(0)" id="remove-policy-error-link" <a href="javascript:void(0)" id="remove-policy-error-link" class="btn-operations">
class="btn-operations"> Ok
Ok </a>
</a> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div>
<div id="save-policy-priorities-success-content" class="hide"> <div id="save-policy-priorities-success-content" class="hide">
<div class="content"> <div class="content">
<div class="row"> <div class="row">
<div class="col-lg-5 col-md-6 col-centered"> <div class="col-lg-5 col-md-6 col-centered">
<h3>Done. New Policy priorities were successfully updated.</h3> <h3>Done. New Policy priorities were successfully updated.</h3>
<div class="buttons"> <div class="buttons">
<a href="javascript:void(0)" id="save-policy-priorities-success-link" <a href="javascript:void(0)" id="save-policy-priorities-success-link" class="btn-operations">
class="btn-operations"> Ok
Ok </a>
</a> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div>
<div id="save-policy-priorities-error-content" class="hide"> <div id="save-policy-priorities-error-content" class="hide">
<div class="content"> <div class="content">
<div class="row"> <div class="row">
<div class="col-lg-5 col-md-6 col-centered"> <div class="col-lg-5 col-md-6 col-centered">
<h3>An unexpected error occurred. Please try again later.</h3> <h3>An unexpected error occurred. Please try again later.</h3>
<h4 class="message-from-server"></h4> <div class="buttons">
<a href="javascript:void(0)" id="save-policy-priorities-error-link" class="btn-operations">
<div class="buttons"> Ok
<a href="javascript:void(0)" id="save-policy-priorities-error-link" </a>
class="btn-operations"> </div>
Ok
</a>
</div> </div>
</div> </div>
</div> </div>

@ -1,17 +1,17 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2015, 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.
*/ */
@ -27,8 +27,9 @@ function onRequest(context) {
return options.fn(this); return options.fn(this);
} }
}); });
var policyModule = require("/app/modules/business-controllers/group.js")["groupModule"]; var policyModule = require("/app/modules/business-controllers/policy.js")["policyModule"];
var response = policyModule.getAllPolicies(); var response = policyModule.getAllPolicies();
if (response["status"] == "success") { if (response["status"] == "success") {
var policyListToView = response["content"]; var policyListToView = response["content"];
context["policyListToView"] = policyListToView; context["policyListToView"] = policyListToView;
@ -38,7 +39,7 @@ function onRequest(context) {
context["saveNewPrioritiesButtonEnabled"] = false; context["saveNewPrioritiesButtonEnabled"] = false;
context["noPolicy"] = true; context["noPolicy"] = true;
} else if (policyCount == 1) { } else if (policyCount == 1) {
context["policyListingStatusMsg"] = "Add more policies to set up a priority order."; context["policyListingStatusMsg"] = "Two or more policies should be available to set up a priority order.";
context["saveNewPrioritiesButtonEnabled"] = false; context["saveNewPrioritiesButtonEnabled"] = false;
context["noPolicy"] = false; context["noPolicy"] = false;
} else { } else {
@ -47,9 +48,11 @@ function onRequest(context) {
context["noPolicy"] = false; context["noPolicy"] = false;
} }
} else { } else {
// here, response["status"] == "error"
context["policyListToView"] = []; context["policyListToView"] = [];
context["policyListingStatusMsg"] = response["content"]; context["policyListingStatusMsg"] = "Error in retrieving policies. Please try reloading the page.";
context["saveNewPrioritiesButtonEnabled"] = false; context["saveNewPrioritiesButtonEnabled"] = false;
} }
return context; return context;
} }

@ -1,17 +1,17 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2015, 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.
*/ */
@ -78,58 +78,66 @@ $(document).ready(function () {
newPolicyPriorityList.push(policy); newPolicyPriorityList.push(policy);
} }
var updatePolicyAPI = "/devicemgt_admin/policies/priorities"; var updatePolicyAPI = "/api/device-mgt/v1.0/policies/priorities";
invokerUtil.put( invokerUtil.put(
updatePolicyAPI, updatePolicyAPI,
newPolicyPriorityList, newPolicyPriorityList,
function () { // on success
$(modalPopupContent).html($('#save-policy-priorities-success-content').html()); function (data, textStatus, jqXHR) {
showPopup(); if (jqXHR.status == 200) {
$("a#save-policy-priorities-success-link").click(function () { $(modalPopupContent).html($('#save-policy-priorities-success-content').html());
hidePopup(); showPopup();
}); $("a#save-policy-priorities-success-link").click(function () {
hidePopup();
});
}
}, },
function () { // on error
$("#save-policy-priorities-error-content").find(".message-from-server").html( function (jqXHR) {
"Message From Server : " + data["statusText"]); if (jqXHR.status == 400 || jqXHR.status == 500) {
$(modalPopupContent).html($('#save-policy-priorities-error-content').html()); $(modalPopupContent).html($("#save-policy-priorities-error-content").html());
showPopup(); showPopup();
$("a#save-policy-priorities-error-link").click(function () { $("a#save-policy-priorities-error-link").click(function () {
hidePopup(); hidePopup();
}); });
}
} }
); );
}); });
$(applyChangesBtn).click(function () { $(applyChangesBtn).click(function () {
var applyPolicyChangesAPI = "/devicemgt_admin/policies/apply-changes"; var applyPolicyChangesAPI = "/api/device-mgt/v1.0/policies/apply-changes";
$(modalPopupContent).html($('#change-policy-modal-content').html()); $(modalPopupContent).html($("#apply-changes-modal-content").html());
showPopup(); showPopup();
$("a#change-policy-yes-link").click(function () { $("a#apply-changes-yes-link").click(function () {
invokerUtil.put( invokerUtil.put(
applyPolicyChangesAPI, applyPolicyChangesAPI,
null, null,
// on success // on success
function () { function (data, textStatus, jqXHR) {
$(modalPopupContent).html($('#change-policy-success-content').html()); if (jqXHR.status == 200) {
showPopup(); $(modalPopupContent).html($("#apply-changes-success-content").html());
$("a#change-policy-success-link").click(function () { showPopup();
hidePopup(); $("a#apply-changes-success-link").click(function () {
}); hidePopup();
});
}
}, },
// on error // on error
function () { function (jqXHR) {
$(modalPopupContent).html($('#change-policy-error-content').html()); if (jqXHR.status == 500) {
showPopup(); $(modalPopupContent).html($("#apply-changes-error-content").html());
$("a#change-policy-error-link").click(function () { showPopup();
hidePopup(); $("a#apply-changes-error-link").click(function () {
}); hidePopup();
});
}
} }
); );
}); });
$("a#change-policy-cancel-link").click(function () { $("a#apply-changes-cancel-link").click(function () {
hidePopup(); hidePopup();
}); });
}); });

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2015, 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
@ -47,7 +47,7 @@ var sortableListFunction = (function () {
} }
/** /**
* on input text field focus autocomplete bind function * on input text field focus auto-complete bind function
*/ */
$(sortableElem).on('focus', '.wr-sort-index input.index', function () { $(sortableElem).on('focus', '.wr-sort-index input.index', function () {
currentElemId = $(this).val(); currentElemId = $(this).val();

Loading…
Cancel
Save