Add pending actions to agent table and filter
This commit is contained in:
parent
e6aa2c3b78
commit
c28c1efbb1
|
@ -36,12 +36,16 @@ class AgentSerializer(serializers.ModelSerializer):
|
|||
|
||||
class AgentTableSerializer(serializers.ModelSerializer):
|
||||
patches_pending = serializers.ReadOnlyField(source="has_patches_pending")
|
||||
pending_actions = serializers.SerializerMethodField()
|
||||
status = serializers.ReadOnlyField()
|
||||
checks = serializers.ReadOnlyField()
|
||||
last_seen = serializers.SerializerMethodField()
|
||||
client_name = serializers.ReadOnlyField(source="client.name")
|
||||
site_name = serializers.ReadOnlyField(source="site.name")
|
||||
|
||||
def get_pending_actions(self, obj):
|
||||
return obj.pendingactions.filter(status="pending").count()
|
||||
|
||||
def get_last_seen(self, obj):
|
||||
if obj.time_zone is not None:
|
||||
agent_tz = pytz.timezone(obj.time_zone)
|
||||
|
@ -62,6 +66,7 @@ class AgentTableSerializer(serializers.ModelSerializer):
|
|||
"description",
|
||||
"needs_reboot",
|
||||
"patches_pending",
|
||||
"pending_actions",
|
||||
"status",
|
||||
"overdue_text_alert",
|
||||
"overdue_email_alert",
|
||||
|
|
|
@ -12,12 +12,11 @@ class Command(BaseCommand):
|
|||
|
||||
async def websocket_call(self, mesh_settings):
|
||||
|
||||
token = get_auth_token(
|
||||
mesh_settings.mesh_username, mesh_settings.mesh_token
|
||||
)
|
||||
token = get_auth_token(mesh_settings.mesh_username, mesh_settings.mesh_token)
|
||||
|
||||
if settings.MESH_WS_URL:
|
||||
uri = f"{settings.MESH_WS_URL}/control.ashx?auth={token}"
|
||||
if settings.DOCKER_BUILD:
|
||||
site = mesh_settings.mesh_site.replace("https", "ws")
|
||||
uri = f"{site}:443/control.ashx?auth={token}"
|
||||
else:
|
||||
site = mesh_settings.mesh_site.replace("https", "wss")
|
||||
uri = f"{site}/control.ashx?auth={token}"
|
||||
|
@ -52,11 +51,17 @@ class Command(BaseCommand):
|
|||
|
||||
try:
|
||||
# Check for Mesh Username
|
||||
if not mesh_settings.mesh_username or settings.MESH_USERNAME != mesh_settings.mesh_username:
|
||||
if (
|
||||
not mesh_settings.mesh_username
|
||||
or settings.MESH_USERNAME != mesh_settings.mesh_username
|
||||
):
|
||||
mesh_settings.mesh_username = settings.MESH_USERNAME
|
||||
|
||||
# Check for Mesh Site
|
||||
if not mesh_settings.mesh_site or settings.MESH_SITE != mesh_settings.mesh_site:
|
||||
if (
|
||||
not mesh_settings.mesh_site
|
||||
or settings.MESH_SITE != mesh_settings.mesh_site
|
||||
):
|
||||
mesh_settings.mesh_site = settings.MESH_SITE
|
||||
|
||||
# Check for Mesh Token
|
||||
|
@ -75,7 +80,9 @@ class Command(BaseCommand):
|
|||
return
|
||||
|
||||
try:
|
||||
asyncio.get_event_loop().run_until_complete(self.websocket_call(mesh_settings))
|
||||
asyncio.get_event_loop().run_until_complete(
|
||||
self.websocket_call(mesh_settings)
|
||||
)
|
||||
self.stdout.write("Initial Mesh Central setup complete")
|
||||
except websockets.exceptions.ConnectionClosedError:
|
||||
self.stdout.write(
|
||||
|
|
|
@ -101,7 +101,9 @@ services:
|
|||
MONGODB_USER: ${MONGODB_USER}
|
||||
MONGODB_PASSWORD: ${MONGODB_PASSWORD}
|
||||
networks:
|
||||
- proxy
|
||||
proxy:
|
||||
aliases:
|
||||
- ${MESH_HOST}
|
||||
- mesh-db
|
||||
volumes:
|
||||
- tactical_data:/opt/tactical
|
||||
|
|
|
@ -46,6 +46,13 @@
|
|||
</q-icon>
|
||||
</q-th>
|
||||
</template>
|
||||
<template v-slot:header-cell-pendingactions="props">
|
||||
<q-th auto-width :props="props">
|
||||
<q-icon name="far fa-clock" size="1.5em">
|
||||
<q-tooltip>Pending Actions</q-tooltip>
|
||||
</q-icon>
|
||||
</q-th>
|
||||
</template>
|
||||
<!--
|
||||
<template v-slot:header-cell-antivirus="props">
|
||||
<q-th auto-width :props="props">
|
||||
|
@ -274,6 +281,11 @@
|
|||
<q-tooltip>Patches Pending</q-tooltip>
|
||||
</q-icon>
|
||||
</q-td>
|
||||
<q-td :props="props" key="pendingactions">
|
||||
<q-icon @click="showPendingActionsModal(props.row.id)" name="far fa-clock" size="1.4em" color="warning">
|
||||
<q-tooltip>Pending Action Count: {{ props.row.pending_actions }}</q-tooltip>
|
||||
</q-icon>
|
||||
</q-td>
|
||||
<q-td key="agentstatus">
|
||||
<q-icon v-if="props.row.status === 'overdue'" name="fas fa-signal" size="1.2em" color="negative">
|
||||
<q-tooltip>Agent overdue</q-tooltip>
|
||||
|
@ -384,6 +396,7 @@ export default {
|
|||
let availability = null;
|
||||
let checks = false;
|
||||
let patches = false;
|
||||
let actions = false;
|
||||
let reboot = false;
|
||||
let search = "";
|
||||
|
||||
|
@ -394,6 +407,7 @@ export default {
|
|||
advancedFilter = true;
|
||||
let filter = param.split(":")[1];
|
||||
if (filter === "patchespending") patches = true;
|
||||
if (filter === "actionspending") actions = true;
|
||||
else if (filter === "checksfailing") checks = true;
|
||||
else if (filter === "rebootneeded") reboot = true;
|
||||
else if (filter === "online" || filter === "offline" || filter === "expired") availability = filter;
|
||||
|
@ -406,6 +420,7 @@ export default {
|
|||
if (advancedFilter) {
|
||||
if (checks && !row.checks.has_failing_checks) return false;
|
||||
if (patches && !row.patches_pending) return false;
|
||||
if (actions && row.pending_actions > 0) return false;
|
||||
if (reboot && !row.needs_reboot) return false;
|
||||
if (availability === "online" && row.status !== "online") return false;
|
||||
else if (availability === "offline" && row.status !== "overdue") return false;
|
||||
|
|
|
@ -217,6 +217,16 @@
|
|||
</q-item-section>
|
||||
</q-item>
|
||||
|
||||
<q-item>
|
||||
<q-item-section side>
|
||||
<q-checkbox v-model="filterActionsPending" />
|
||||
</q-item-section>
|
||||
|
||||
<q-item-section>
|
||||
<q-item-label>Actions Pending</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
|
||||
<q-item>
|
||||
<q-item-section side>
|
||||
<q-checkbox v-model="filterRebootNeeded" />
|
||||
|
@ -379,6 +389,7 @@ export default {
|
|||
filterTextLength: 0,
|
||||
filterAvailability: "all",
|
||||
filterPatchesPending: false,
|
||||
filterActionsPending: false,
|
||||
filterChecksFailing: false,
|
||||
filterRebootNeeded: false,
|
||||
currentTRMMVersion: null,
|
||||
|
@ -446,6 +457,12 @@ export default {
|
|||
align: "left",
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
name: "pendingactions",
|
||||
field: "pending_actions",
|
||||
align: "left",
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
name: "agentstatus",
|
||||
field: "status",
|
||||
|
@ -483,6 +500,7 @@ export default {
|
|||
"description",
|
||||
"user",
|
||||
"patchespending",
|
||||
"pendingactions",
|
||||
"agentstatus",
|
||||
"needsreboot",
|
||||
"lastseen",
|
||||
|
@ -655,6 +673,7 @@ export default {
|
|||
this.filterPatchesPending = false;
|
||||
this.filterRebootNeeded = false;
|
||||
this.filterChecksFailing = false;
|
||||
this.filterActionsPending = false;
|
||||
this.filterAvailability = "all";
|
||||
this.search = "";
|
||||
},
|
||||
|
@ -675,6 +694,10 @@ export default {
|
|||
filterText += "is:patchespending ";
|
||||
}
|
||||
|
||||
if (this.filterActionsPending) {
|
||||
filterText += "is:actionspending ";
|
||||
}
|
||||
|
||||
if (this.filterChecksFailing) {
|
||||
filterText += "is:checksfailing ";
|
||||
}
|
||||
|
@ -723,6 +746,7 @@ export default {
|
|||
isFilteringTable() {
|
||||
return (
|
||||
this.filterPatchesPending ||
|
||||
this.filterActionsPending ||
|
||||
this.filterChecksFailing ||
|
||||
this.filterRebootNeeded ||
|
||||
this.filterAvailability !== "all"
|
||||
|
|
Loading…
Reference in New Issue