forked from community/device-mgt-core
feature/appm-store/pbac
commit
36021014af
@ -0,0 +1,119 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (pvt) Ltd. 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import React from "react";
|
||||||
|
import CurrentUsersReview from "./CurrentUsersReview";
|
||||||
|
import {Col, Divider, Row, Typography} from "antd";
|
||||||
|
import DetailedRating from "../DetailedRating";
|
||||||
|
import Reviews from "./Reviews";
|
||||||
|
import axios from "axios";
|
||||||
|
import {handleApiError} from "../../../../js/Utils";
|
||||||
|
import {withConfigContext} from "../../../../context/ConfigContext";
|
||||||
|
|
||||||
|
const {Text} = Typography;
|
||||||
|
|
||||||
|
class ReviewContainer extends React.Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
currentUserReviews: [],
|
||||||
|
detailedRating: null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
this.fetchCurrentUserReviews();
|
||||||
|
this.fetchDetailedRating("app", this.props.uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchCurrentUserReviews = () => {
|
||||||
|
const {uuid} = this.props;
|
||||||
|
const config = this.props.context;
|
||||||
|
|
||||||
|
axios.get(
|
||||||
|
window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/reviews/app/user/" + uuid,
|
||||||
|
).then(res => {
|
||||||
|
if (res.status === 200) {
|
||||||
|
const currentUserReviews = res.data.data.data;
|
||||||
|
this.setState({currentUserReviews});
|
||||||
|
}
|
||||||
|
|
||||||
|
}).catch((error) => {
|
||||||
|
handleApiError(error, "Error occurred while trying to get your review.");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
deleteCurrentUserReviewCallback = () => {
|
||||||
|
this.setState({
|
||||||
|
currentUserReviews: []
|
||||||
|
});
|
||||||
|
this.fetchDetailedRating("app", this.props.uuid);
|
||||||
|
};
|
||||||
|
|
||||||
|
fetchDetailedRating = (type, uuid) => {
|
||||||
|
const config = this.props.context;
|
||||||
|
|
||||||
|
axios.get(
|
||||||
|
window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/reviews/" + uuid + "/" + type + "-rating",
|
||||||
|
).then(res => {
|
||||||
|
if (res.status === 200) {
|
||||||
|
let detailedRating = res.data.data;
|
||||||
|
this.setState({
|
||||||
|
detailedRating
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}).catch(function (error) {
|
||||||
|
handleApiError(error, "Error occurred while trying to load ratings.");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
onUpdateReview = () => {
|
||||||
|
this.fetchCurrentUserReviews();
|
||||||
|
this.fetchDetailedRating("app", this.props.uuid);
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const {uuid} = this.props;
|
||||||
|
const {currentUserReviews,detailedRating} = this.state;
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<CurrentUsersReview
|
||||||
|
uuid={uuid}
|
||||||
|
currentUserReviews={currentUserReviews}
|
||||||
|
onUpdateReview={this.onUpdateReview}
|
||||||
|
deleteCallback={this.deleteCurrentUserReviewCallback}/>
|
||||||
|
<Divider dashed={true}/>
|
||||||
|
<Text>REVIEWS</Text>
|
||||||
|
<Row>
|
||||||
|
<Col lg={18} md={24}>
|
||||||
|
<DetailedRating
|
||||||
|
type="app"
|
||||||
|
detailedRating={detailedRating}/>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
<Reviews
|
||||||
|
type="app"
|
||||||
|
uuid={uuid}
|
||||||
|
deleteCallback={this.onUpdateReview}/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default withConfigContext(ReviewContainer);
|
@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. 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.
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.common.policy.mgt;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@ApiModel(
|
||||||
|
value = "CorrectiveAction",
|
||||||
|
description = "This bean carries all information related corrective action which is required " +
|
||||||
|
"when a policy is violated."
|
||||||
|
)
|
||||||
|
public class CorrectiveAction implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -3414709449056070148L;
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
name = "action",
|
||||||
|
value = "Corrective action type (POLICY or OPERATION) to trigger when a policy is violated.",
|
||||||
|
example = "POLICY",
|
||||||
|
required = true
|
||||||
|
)
|
||||||
|
private String actionType;
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
name = "policyId",
|
||||||
|
value = "When corrective action is POLICY, the corrective policy ID to be applied when a policy " +
|
||||||
|
"is violated.",
|
||||||
|
example = "1"
|
||||||
|
)
|
||||||
|
private int policyId;
|
||||||
|
|
||||||
|
@ApiModelProperty(
|
||||||
|
name = "operations",
|
||||||
|
value = "When corrective action is OPERATION, the list of operations in features to be applied " +
|
||||||
|
"when a policy is violated."
|
||||||
|
)
|
||||||
|
private List<ProfileFeature> operations;
|
||||||
|
|
||||||
|
public String getActionType() {
|
||||||
|
return actionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActionType(String actionType) {
|
||||||
|
this.actionType = actionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPolicyId() {
|
||||||
|
return policyId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPolicyId(int policyId) {
|
||||||
|
this.policyId = policyId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ProfileFeature> getOperations() {
|
||||||
|
return operations;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOperations(List<ProfileFeature> operations) {
|
||||||
|
this.operations = operations;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"version" : "1.0.0"
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
|
||||||
|
$("select.select2").select2();
|
||||||
|
|
||||||
|
});
|
@ -0,0 +1,35 @@
|
|||||||
|
<!--Currently corrective action policy selection is supported only for android devices.
|
||||||
|
Once this is supported for other device type the below condition can be removed.-->
|
||||||
|
{{#equal deviceType "android"}}
|
||||||
|
<div id="corrective-policy-select-field" class="select-corrective-policy">
|
||||||
|
<div class="wr-input-control">
|
||||||
|
<div class="cus-col-50">
|
||||||
|
Select Corrective Policy
|
||||||
|
<span class="helper">
|
||||||
|
<i class="wr-help-tip glyphicon glyphicon-question-sign" title="Select the corrective policy to be applied when this general policy is violated"></i>
|
||||||
|
</span>
|
||||||
|
<!--suppress HtmlFormInputWithoutLabel -->
|
||||||
|
<select id="corrective-policy-input" class="form-control select2">
|
||||||
|
<option value="none">None</option>
|
||||||
|
{{#each correctivePolicies}}
|
||||||
|
{{#equal this.platform ../deviceType}}
|
||||||
|
<option value="{{this.id}}">{{this.name}}</option>
|
||||||
|
{{/equal}}
|
||||||
|
{{/each}}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<br class="c-both"/>
|
||||||
|
</div>
|
||||||
|
<div id="corrective-action-policy-id-missing-msg" class="hidden">
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
|
<span class="alert alert-info">
|
||||||
|
<strong>
|
||||||
|
<i class="icon fw fw-info"></i>
|
||||||
|
Corrective policy has been automatically changed to NONE since a previously selected corrective policy
|
||||||
|
has been updated to a GENERAL policy or it has been deleted.
|
||||||
|
</strong>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{/equal}}
|
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. 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.
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.policy.mgt.common;
|
||||||
|
|
||||||
|
public class PolicyTransformException extends Exception {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -4976670117832668628L;
|
||||||
|
|
||||||
|
public PolicyTransformException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PolicyTransformException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PolicyTransformException(String msg) {
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PolicyTransformException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue