format all

This commit is contained in:
wh1te909
2020-07-12 07:11:21 +00:00
parent 4216b77199
commit 446f442fb8
13 changed files with 147 additions and 205 deletions

View File

@@ -59,11 +59,11 @@
<q-item-section>Edit</q-item-section>
</q-item>
<q-item
clickable
v-close-popup
@click="deleteTask(props.row.name, props.row.id)"
v-if="!props.row.managed_by_policy"
>
clickable
v-close-popup
@click="deleteTask(props.row.name, props.row.id)"
v-if="!props.row.managed_by_policy"
>
<q-item-section side>
<q-icon name="delete" />
</q-item-section>

View File

@@ -92,10 +92,10 @@
<!-- context menu -->
<q-menu context-menu>
<q-list dense style="min-width: 200px">
<q-item
clickable
v-close-popup
@click="showCheck('edit', props.row.check_type)"
<q-item
clickable
v-close-popup
@click="showCheck('edit', props.row.check_type)"
v-if="!props.row.managed_by_policy"
>
<q-item-section side>

View File

@@ -74,7 +74,6 @@
<template v-slot:header="props">
<q-tr :props="props">
<template v-for="col in props.cols">
<q-th v-if="col.name === 'active'" auto-width :key="col.name">
<q-icon name="power_settings_new" size="1.5em">
<q-tooltip>Enable Policy</q-tooltip>
@@ -87,19 +86,14 @@
</q-icon>
</q-th>
<q-th v-else :key="col.name" :props="props">
{{ col.label }}
</q-th>
<q-th v-else :key="col.name" :props="props">{{ col.label }}</q-th>
</template>
</q-tr>
</template>
</template>
<!-- No data Slot -->
<template v-slot:no-data >
<template v-slot:no-data>
<div class="full-width row flex-center q-gutter-sm">
<span v-if="policies.length === 0">
No Policies
</span>
<span v-if="policies.length === 0">No Policies</span>
</div>
</template>
<!-- body slots -->
@@ -108,9 +102,9 @@
<!-- context menu -->
<q-menu context-menu>
<q-list dense style="min-width: 200px">
<q-item
clickable
v-close-popup
<q-item
clickable
v-close-popup
@click="showEditPolicyModal(props.row.id)"
id="context-edit"
>
@@ -174,9 +168,7 @@
<span
style="cursor:pointer;color:blue;text-decoration:underline"
@click="showRelationsModal(props.row)"
>
{{ `Show Relations (${props.row.clients_count + props.row.sites_count + props.row.agents_count}+)` }}
</span>
>{{ `Show Relations (${props.row.clients_count + props.row.sites_count + props.row.agents_count}+)` }}</span>
</q-td>
</q-tr>
</template>
@@ -189,29 +181,17 @@
</q-card>
<!-- policy form modal -->
<q-dialog
v-model="showPolicyFormModal"
@hide="closePolicyFormModal"
>
<PolicyForm
:pk="editPolicyId"
@close="closePolicyFormModal"
/>
<q-dialog v-model="showPolicyFormModal" @hide="closePolicyFormModal">
<PolicyForm :pk="editPolicyId" @close="closePolicyFormModal" />
</q-dialog>
<!-- policy overview modal -->
<q-dialog
v-model="showPolicyOverviewModal"
@hide="clearRow"
>
<q-dialog v-model="showPolicyOverviewModal" @hide="clearRow">
<PolicyOverview />
</q-dialog>
<!-- policy relations modal -->
<q-dialog
v-model="showRelationsViewModal"
@hide="closeRelationsModal"
>
<q-dialog v-model="showRelationsViewModal" @hide="closeRelationsModal">
<RelationsView :policy="policy" />
</q-dialog>
</div>
@@ -251,18 +231,18 @@ export default {
name: "desc",
label: "Description",
field: "desc",
align: "left",
align: "left"
},
{
name: "actions",
label: "Actions",
field: "actions",
align: "left",
align: "left"
}
],
pagination: {
rowsPerPage: 9999
},
}
};
},
methods: {
@@ -323,26 +303,26 @@ export default {
this.showPolicyFormModal = true;
},
showPolicyOverview() {
this.showPolicyOverviewModal = true
this.showPolicyOverviewModal = true;
this.clearRow();
},
toggleCheckbox(policy, type) {
let text = "";
if (type === "Active") {
text = policy.active ? "Policy enabled successfully" : "Policy disabled successfully";
text = policy.active ? "Policy enabled successfully" : "Policy disabled successfully";
} else if (type === "Enforced") {
text = policy.enforced ? "Policy enforced successfully" : "Policy enforcement disabled";
text = policy.enforced ? "Policy enforced successfully" : "Policy enforcement disabled";
}
const data ={
const data = {
id: policy.id,
name: policy.name,
desc: policy.desc,
active: policy.active,
enforced: policy.enforced
}
};
this.$store
.dispatch("automation/editPolicy", data)
.then(response => {

View File

@@ -11,7 +11,7 @@
ref="add"
@click="showAddAutomatedTask = true"
/>
<q-btn
<q-btn
v-if="selectedPolicy !== null"
dense
flat
@@ -38,14 +38,10 @@
</q-th>
</template>
<!-- No data Slot -->
<template v-slot:no-data >
<template v-slot:no-data>
<div class="full-width row flex-center q-gutter-sm">
<span v-if="selectedPolicy === null">
Click on a policy to see the tasks
</span>
<span v-else>
There are no tasks added to this policy
</span>
<span v-if="selectedPolicy === null">Click on a policy to see the tasks</span>
<span v-else>There are no tasks added to this policy</span>
</div>
</template>
<!-- body slots -->
@@ -54,9 +50,9 @@
<!-- context menu -->
<q-menu context-menu>
<q-list dense style="min-width: 200px">
<q-item
clickable
v-close-popup
<q-item
clickable
v-close-popup
@click="runTask(props.row.id, props.row.enabled)"
id="context-runtask"
>
@@ -65,9 +61,9 @@
</q-item-section>
<q-item-section>Run task now</q-item-section>
</q-item>
<q-item
clickable
v-close-popup
<q-item
clickable
v-close-popup
@click="showEditAutomatedTask = true"
id="context-edit"
>
@@ -76,8 +72,8 @@
</q-item-section>
<q-item-section>Edit</q-item-section>
</q-item>
<q-item
clickable
<q-item
clickable
v-close-popup
@click="deleteTask(props.row.name, props.row.id)"
id="context-delete"
@@ -88,8 +84,8 @@
<q-item-section>Delete</q-item-section>
</q-item>
<q-separator />
<q-item
clickable
<q-item
clickable
v-close-popup
@click="showStatus(props.row)"
id="context-status"
@@ -122,9 +118,7 @@
style="cursor:pointer;color:blue;text-decoration:underline"
@click="showStatus(props.row)"
class="status-cell"
>
See Status
</span>
>See Status</span>
</q-td>
<q-td v-if="props.row.assigned_check">{{ props.row.assigned_check.name }}</q-td>
<q-td v-else></q-td>
@@ -135,16 +129,13 @@
</div>
<!-- modals -->
<q-dialog v-model="showAddAutomatedTask" position="top">
<AddAutomatedTask
:policypk="selectedPolicy"
@close="showAddAutomatedTask = false"
/>
<AddAutomatedTask :policypk="selectedPolicy" @close="showAddAutomatedTask = false" />
</q-dialog>
<!-- policy task status -->
<q-dialog v-model="showPolicyTaskStatus">
<PolicyStatus
type="task"
<PolicyStatus
type="task"
:item="statusTask"
:description="`${statusTask.name} Agent Status`"
/>
@@ -160,7 +151,7 @@ import PolicyStatus from "@/components/automation/modals/PolicyStatus";
export default {
name: "PolicyAutomatedTasksTab",
components: {
components: {
AddAutomatedTask,
PolicyStatus
},
@@ -242,7 +233,7 @@ export default {
persistent: true
})
.onOk(() => {
this.$store
this.$store
.dispatch("deleteAutoTask", pk)
.then(r => {
this.$store.dispatch("automation/loadPolicyAutomatedTasks", this.selectedPolicy);
@@ -256,7 +247,7 @@ export default {
...mapGetters({
tasks: "automation/tasks",
selectedPolicy: "automation/selectedPolicyPk"
}),
})
}
};
</script>

View File

@@ -57,14 +57,14 @@
</q-list>
</q-menu>
</q-btn>
<q-btn
v-if="selectedPolicy !== null"
dense
flat
<q-btn
v-if="selectedPolicy !== null"
dense
flat
push
@click="onRefresh(selectedPolicy)"
icon="refresh"
ref="refresh"
@click="onRefresh(selectedPolicy)"
icon="refresh"
ref="refresh"
/>
<template>
<q-table

View File

@@ -100,7 +100,6 @@ export default {
this.$store.dispatch("automation/loadPolicyChecks", this.selectedPolicy.id);
this.$store.commit("automation/setSelectedPolicy", this.selectedPolicy.id);
this.$store.dispatch("automation/loadPolicyAutomatedTasks", this.selectedPolicy.id);
},
processTreeDataFromApi(data) {
/* Structure
@@ -166,7 +165,7 @@ export default {
// Add any policies assigned to site
if (data[client].sites[site].policy !== null) {
site_temp["children"] = [];
// Indicate if the policy is active or not
let disabled = "";
if (!data[client].sites[site].policy.active) {
@@ -178,7 +177,6 @@ export default {
icon: "policy",
id: data[client].sites[site].policy.id
});
}
// Add Site to Client children array
@@ -194,6 +192,6 @@ export default {
},
mounted() {
this.getPolicyTree();
},
}
};
</script>

View File

@@ -1,39 +1,36 @@
<template>
<q-card style="width: 60vw" >
<q-card style="width: 60vw">
<q-card-section class="row items-center">
<div class="text-h6">Edit policy assigned to {{ type }}</div>
<q-space />
<q-btn icon="close" flat round dense v-close-popup />
</q-card-section>
<q-form @submit="submit" ref="form">
<q-card-section>
<q-select
v-model="selected"
:options="options"
filled
options-selected-class="text-green"
dense
clearable
>
<template v-slot:option="props">
<q-item
v-bind="props.itemProps"
v-on="props.itemEvents"
>
<q-item-section avatar>
<q-icon v-if="props.selected" name="check" />
</q-item-section>
<q-item-section>
<q-item-label v-html="props.opt.label" />
</q-item-section>
</q-item>
</template>
</q-select>
</q-card-section>
<q-card-section class="row items-center">
<q-btn label="Add Policy" color="primary" type="submit" />
</q-card-section>
</q-form>
<q-form @submit="submit" ref="form">
<q-card-section>
<q-select
v-model="selected"
:options="options"
filled
options-selected-class="text-green"
dense
clearable
>
<template v-slot:option="props">
<q-item v-bind="props.itemProps" v-on="props.itemEvents">
<q-item-section avatar>
<q-icon v-if="props.selected" name="check" />
</q-item-section>
<q-item-section>
<q-item-label v-html="props.opt.label" />
</q-item-section>
</q-item>
</template>
</q-select>
</q-card-section>
<q-card-section class="row items-center">
<q-btn label="Add Policy" color="primary" type="submit" />
</q-card-section>
</q-form>
</q-card>
</template>
@@ -48,17 +45,17 @@ export default {
type: {
required: true,
type: String,
validator: function (value) {
validator: function(value) {
// The value must match one of these strings
return ["agent", "site", "client"].includes(value);
}
}
}
},
data() {
return {
selected: null,
options: []
}
};
},
computed: {
...mapGetters({
@@ -70,8 +67,7 @@ export default {
this.$q.loading.show();
let data = {};
data.pk = this.pk,
data.type = this.type;
(data.pk = this.pk), (data.type = this.type);
data.policy = this.selected === null ? 0 : this.selected.value;
this.$store
@@ -83,7 +79,7 @@ export default {
})
.catch(e => {
this.$q.loading.hide();
this.$q.notify(notifyErrorConfig("Something went wrong!"))
this.$q.notify(notifyErrorConfig("Something went wrong!"));
});
},
getPolicies() {
@@ -93,23 +89,22 @@ export default {
this.options = this.policies.map(policy => ({
label: policy.name,
value: policy.id
}))
}));
})
.catch(e => {
this.$q.loading.hide();
this.$q.notify(notifyErrorConfig("Add error occured while loading"));
});;
});
},
getRelation(pk, type) {
this.$store
.dispatch("automation/getRelatedPolicies", {pk, type})
.dispatch("automation/getRelatedPolicies", { pk, type })
.then(r => {
if (r.data.id !== undefined) {
this.selected = {
label: r.data.name,
value: r.data.id
}
};
}
})
.catch(e => {
@@ -121,5 +116,5 @@ export default {
this.getPolicies();
this.getRelation(this.pk, this.type);
}
}
};
</script>

View File

@@ -61,17 +61,14 @@ export default {
getPolicy() {
this.$q.loading.show();
this.$store
.dispatch("automation/loadPolicy", this.pk)
.then(r => {
this.$store.dispatch("automation/loadPolicy", this.pk).then(r => {
this.$q.loading.hide();
this.$q.loading.hide();
this.name = r.data.name;
this.desc = r.data.desc;
this.active = r.data.active;
this.enforced = r.data.enforced;
});
this.name = r.data.name;
this.desc = r.data.desc;
this.active = r.data.active;
this.enforced = r.data.enforced;
});
},
submit() {
if (!this.name) {

View File

@@ -1,5 +1,5 @@
<template>
<q-card style="width: 90vw" >
<q-card style="width: 90vw">
<q-card-section class="row items-center">
<div class="text-h6">{{ this.title }}</div>
<q-space />
@@ -21,11 +21,9 @@
<q-th auto-width :props="props"></q-th>
</template>
<!-- No data Slot -->
<template v-slot:no-data >
<template v-slot:no-data>
<div class="full-width row flex-center q-gutter-sm">
<span>
There are no agents applied to this policy
</span>
<span>There are no agents applied to this policy</span>
</div>
</template>
<!-- body slots -->
@@ -44,9 +42,7 @@
<q-td v-else></q-td>
<!-- status text -->
<q-td v-if="props.row.status === 'pending'">Awaiting First Synchronization</q-td>
<q-td v-else-if="props.row.status === 'passing'">
</q-td>
<q-td v-else-if="props.row.status === 'passing'"></q-td>
<q-td v-else-if="props.row.status === 'failing'">
<q-badge color="negative">Failing</q-badge>
</q-td>
@@ -61,7 +57,9 @@
class="ping-cell"
>output</span>
</q-td>
<q-td v-else-if="props.row.check_type === 'script' || props.row.retcode || props.row.stdout || props.row.stderr">
<q-td
v-else-if="props.row.check_type === 'script' || props.row.retcode || props.row.stdout || props.row.stderr"
>
<span
style="cursor:pointer;color:blue;text-decoration:underline"
@click="scriptMoreInfo(props.row)"
@@ -91,10 +89,7 @@
<ScriptOutput @close="closeScriptOutput" :scriptInfo="scriptInfo" />
</q-dialog>
<q-dialog v-model="showEventLogOutput" @hide="closeEventLogOutput">
<EventLogCheckOutput
@close="closeEventLogOutput"
:evtlogdata="evtLogData"
/>
<EventLogCheckOutput @close="closeEventLogOutput" :evtlogdata="evtLogData" />
</q-dialog>
</q-card>
</template>
@@ -117,7 +112,7 @@ export default {
type: {
required: true,
type: String,
validator: function (value) {
validator: function(value) {
// The value must match one of these strings
return ["task", "check"].includes(value);
}
@@ -150,11 +145,11 @@ export default {
pagination: {
rowsPerPage: 9999
}
}
};
},
computed: {
title () {
return this.item.readable_desc ? this.item.readable_desc + " Status" : this.item.name + " Status"
title() {
return this.item.readable_desc ? this.item.readable_desc + " Status" : this.item.name + " Status";
}
},
methods: {
@@ -164,7 +159,7 @@ export default {
.dispatch("automation/loadCheckStatus", { checkpk: this.item.id })
.then(r => {
this.$q.loading.hide();
this.tableData = r.data
this.tableData = r.data;
})
.catch(e => {
this.$q.loading.hide();
@@ -177,20 +172,20 @@ export default {
.dispatch("automation/loadAutomatedTaskStatus", { taskpk: this.item.id })
.then(r => {
this.$q.loading.hide();
this.tableData = r.data
this.tableData = r.data;
})
.catch(e => {
this.$q.loading.hide();
// TODO: Return Error message from api and display
});;
});
},
closeEventLogOutput() {
this.showEventLogOutput = false;
this.showEventLogOutput = false;
this.evtLogdata = {};
},
closeScriptOutput() {
this.showScriptOutput = false;
this.scriptInfo = {}
this.showScriptOutput = false;
this.scriptInfo = {};
},
pingInfo(check) {
this.$q.dialog({
@@ -207,16 +202,14 @@ export default {
eventLogMoreInfo(check) {
this.evtLogData = check;
this.showEventLogOutput = true;
},
}
},
mounted() {
if (this.type === "task") {
this.getTaskData();
}
else {
} else {
this.getCheckData();
}
}
}
}
};
</script>

View File

@@ -51,7 +51,10 @@
<q-item :key="item.pk" v-for="item in related.agents">
<q-item-section>
<q-item-label>{{ item.hostname }}</q-item-label>
<q-item-label caption><b>{{ item.client }}</b> {{ item.site }}</q-item-label>
<q-item-label caption>
<b>{{ item.client }}</b>
{{ item.site }}
</q-item-label>
</q-item-section>
</q-item>
</q-list>
@@ -72,9 +75,9 @@ export default {
},
data() {
return {
tab: 'clients',
tab: "clients",
related: {}
}
};
},
mounted() {
this.$q.loading.show();
@@ -83,11 +86,11 @@ export default {
.dispatch("automation/getRelated", this.policy.id)
.then(r => {
this.$q.loading.hide();
this.related = r.data
this.related = r.data;
})
.catch(e => {
this.$q.loading.hide();
});
}
}
};
</script>

View File

@@ -148,32 +148,17 @@
<q-card-section class="row">
<div class="col-4">Username:</div>
<div class="col-2"></div>
<q-input
dense
filled
v-model="settings.mesh_username"
class="col-6"
/>
<q-input dense filled v-model="settings.mesh_username" class="col-6" />
</q-card-section>
<q-card-section class="row">
<div class="col-4">Mesh Site:</div>
<div class="col-2"></div>
<q-input
dense
filled
v-model="settings.mesh_site"
class="col-6"
/>
<q-input dense filled v-model="settings.mesh_site" class="col-6" />
</q-card-section>
<q-card-section class="row">
<div class="col-4">Mesh Token:</div>
<div class="col-2"></div>
<q-input
dense
filled
v-model="settings.mesh_token"
class="col-6"
/>
<q-input dense filled v-model="settings.mesh_token" class="col-6" />
</q-card-section>
</q-tab-panel>
</q-tab-panels>

View File

@@ -191,9 +191,9 @@ export default {
computed: {
...mapGetters(["selectedAgentPk", "scripts"]),
checks() {
return this.policypk ? this.$store.state.automation.checks : this.$store.state.agentChecks.filter(
check => check.managed_by_policy === false
);
return this.policypk
? this.$store.state.automation.checks
: this.$store.state.agentChecks.filter(check => check.managed_by_policy === false);
},
checksOptions() {
const r = [];

View File

@@ -2,17 +2,17 @@ export default {
methods: {
formatClients(clients) {
return clients.map(client => ({
label: client.client,
value: client.id
})
label: client.client,
value: client.id
})
);
},
formatSites(sites) {
return sites.map(site => ({
label: site.site,
value: site.id,
client: site.client_name
})
label: site.site,
value: site.id,
client: site.client_name
})
);
}
}