add reset check status to check context menu. #388

This commit is contained in:
sadnub 2021-04-15 16:52:42 -04:00
parent 67a87ccf00
commit 26cfec7d80
2 changed files with 27 additions and 1 deletions

View File

@ -86,7 +86,10 @@ class GetUpdateDeleteCheck(APIView):
check = get_object_or_404(Check, pk=pk)
# remove fields that should not be changed when editing a check from the frontend
if "check_alert" not in request.data.keys():
if (
"check_alert" not in request.data.keys()
and "check_reset" not in request.data.keys()
):
[request.data.pop(i) for i in check.non_editable_fields]
# set event id to 0 if wildcard because it needs to be an integer field for db

View File

@ -124,6 +124,13 @@
<q-item-section>Delete</q-item-section>
</q-item>
<q-separator></q-separator>
<q-item clickable v-close-popup @click="resetCheck(props.row.id)">
<q-item-section side>
<q-icon name="info" />
</q-item-section>
<q-item-section>Reset Check Status</q-item-section>
</q-item>
<q-separator></q-separator>
<q-item clickable v-close-popup>
<q-item-section>Close</q-item-section>
</q-item>
@ -431,6 +438,22 @@ export default {
});
});
},
resetCheck(check) {
const data = {
check_reset: true,
status: "passing",
};
axios
.patch(`/checks/${check}/check/`, data)
.then(r => {
this.$store.dispatch("loadChecks", this.selectedAgentPk);
this.notifySuccess("The check was reset");
})
.catch(e => {
this.notifyError("There was an issue resetting the check");
});
},
onRefresh(id) {
this.$store.dispatch("loadChecks", id);
this.$store.dispatch("loadAutomatedTasks", id);