Skip to content

Commit 9cd7bb3

Browse files
Elastic scale patch (#2056)
* fix results count in healthy endpoints and change look of results count * enable non-tracked endpoint to be deleted * Display only a single toaster * No need to await --------- Co-authored-by: John Simons <[email protected]>
1 parent 7e2130a commit 9cd7bb3

File tree

4 files changed

+42
-14
lines changed

4 files changed

+42
-14
lines changed

src/Frontend/src/components/NoData.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ const props = defineProps<{
1212
<div class="row box-header">
1313
<div class="col-sm-12">
1414
<p class="lead hard-wrap">{{ props.message }}</p>
15-
<p>&nbsp;</p>
15+
<slot>
16+
<p>&nbsp;</p>
17+
</slot>
1618
</div>
1719
</div>
1820
</div>

src/Frontend/src/components/ResultsCount.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ defineProps<{
1515
.format-showing-results {
1616
display: flex;
1717
align-items: flex-end;
18-
color: gray;
18+
font-style: italic;
1919
}
2020
</style>

src/Frontend/src/components/heartbeats/EndpointInstances.vue

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ enum Operation {
2626
}
2727
2828
const route = useRoute();
29+
const router = useRouter();
2930
const endpointName = route.params.endpointName.toString();
3031
const store = useHeartbeatInstancesStore();
3132
const { filteredInstances, sortedInstances, instanceFilterString, sortByInstances } = storeToRefs(store);
3233
const endpointSettings = ref<EndpointSettings[]>([endpointSettingsClient.defaultEndpointSettingsValue()]);
3334
const backLink = ref<string>(routeLinks.heartbeats.root);
34-
const filterInstances = (data: EndpointsView[]) =>
35+
const filterToValidInstances = (data: EndpointsView[]) =>
3536
data
3637
.filter((instance) => instance.name === endpointName)
3738
.filter((instance) => {
@@ -42,8 +43,8 @@ const filterInstances = (data: EndpointsView[]) =>
4243
4344
return true;
4445
});
45-
const instances = computed(() => filterInstances(filteredInstances.value));
46-
const totalInstances = computed(() => filterInstances(sortedInstances.value));
46+
const filteredValidInstances = computed(() => filterToValidInstances(filteredInstances.value));
47+
const totalValidInstances = computed(() => filterToValidInstances(sortedInstances.value));
4748
const showBulkWarningDialog = ref(false);
4849
const dialogWarningOperation = ref(Operation.Mute);
4950
@@ -68,7 +69,9 @@ async function proceedWarningDialog() {
6869
showBulkWarningDialog.value = false;
6970
7071
try {
71-
await store.toggleEndpointMonitor(instances.value.filter((instance) => (dialogWarningOperation.value === Operation.Unmute && !instance.monitor_heartbeat) || (dialogWarningOperation.value === Operation.Mute && instance.monitor_heartbeat)));
72+
await store.toggleEndpointMonitor(
73+
filteredValidInstances.value.filter((instance) => (dialogWarningOperation.value === Operation.Unmute && !instance.monitor_heartbeat) || (dialogWarningOperation.value === Operation.Mute && instance.monitor_heartbeat))
74+
);
7275
useShowToast(TYPE.SUCCESS, `All endpoint instances ${dialogWarningOperation.value}`, "", false, { timeout: 1000 });
7376
} catch {
7477
useShowToast(TYPE.ERROR, "Save failed", "", false, { timeout: 3000 });
@@ -84,6 +87,16 @@ async function deleteInstance(instance: EndpointsView) {
8487
}
8588
}
8689
90+
async function deleteAllInstances() {
91+
try {
92+
await Promise.all(sortedInstances.value.filter((instance) => instance.name === endpointName).map((instance) => store.deleteEndpointInstance(instance)));
93+
useShowToast(TYPE.SUCCESS, "Endpoint deleted", "", false, { timeout: 1000 });
94+
await router.replace(backLink.value);
95+
} catch {
96+
useShowToast(TYPE.ERROR, "Delete failed", "", false, { timeout: 3000 });
97+
}
98+
}
99+
87100
async function toggleAlerts(instance: EndpointsView) {
88101
try {
89102
await store.toggleEndpointMonitor([instance]);
@@ -99,7 +112,7 @@ async function toggleAlerts(instance: EndpointsView) {
99112
<ConfirmDialog
100113
v-if="showBulkWarningDialog"
101114
heading="Proceed with bulk operation"
102-
:body="`Are you sure you want to ${dialogWarningOperation} ${instances.length} endpoint instance(s)?`"
115+
:body="`Are you sure you want to ${dialogWarningOperation} ${filteredValidInstances.length} endpoint instance(s)?`"
103116
@cancel="cancelWarningDialog"
104117
@confirm="proceedWarningDialog"
105118
/>
@@ -119,19 +132,19 @@ async function toggleAlerts(instance: EndpointsView) {
119132
<div class="row filters">
120133
<div class="col-sm-12">
121134
<span class="buttonsContainer">
122-
<button type="button" class="btn btn-warning btn-sm" :disabled="instances.length === 0" @click="showBulkOperationWarningDialog(Operation.Mute)">
135+
<button type="button" class="btn btn-warning btn-sm" :disabled="filteredValidInstances.length === 0" @click="showBulkOperationWarningDialog(Operation.Mute)">
123136
<i
124137
:class="{
125-
'text-black': instances.length > 0,
138+
'text-black': filteredValidInstances.length > 0,
126139
}"
127140
class="fa fa-bell-slash"
128141
/>
129142
Mute Alerts on All
130143
</button>
131-
<button type="button" class="btn btn-default btn-sm" :disabled="instances.length === 0" @click="showBulkOperationWarningDialog(Operation.Unmute)">
144+
<button type="button" class="btn btn-default btn-sm" :disabled="filteredValidInstances.length === 0" @click="showBulkOperationWarningDialog(Operation.Unmute)">
132145
<i
133146
:class="{
134-
'text-black': instances.length > 0,
147+
'text-black': filteredValidInstances.length > 0,
135148
}"
136149
class="fa fa-bell"
137150
/>
@@ -141,7 +154,7 @@ async function toggleAlerts(instance: EndpointsView) {
141154
</div>
142155
</div>
143156
<div class="row">
144-
<ResultsCount :displayed="instances.length" :total="totalInstances.length" />
157+
<ResultsCount :displayed="filteredValidInstances.length" :total="totalValidInstances.length" />
145158
</div>
146159
<section role="table" aria-label="endpoint-instances">
147160
<!--Table headings-->
@@ -180,9 +193,15 @@ async function toggleAlerts(instance: EndpointsView) {
180193
</div>
181194
</div>
182195
</div>
183-
<no-data v-if="instances.length === 0" message="No endpoint instances found. For untracked endpoints, disconnected instances are automatically pruned."></no-data>
196+
<no-data v-if="filteredValidInstances.length === 0" message="No endpoint instances found. For untracked endpoints, disconnected instances are automatically pruned.">
197+
<div v-if="totalValidInstances.length === 0" class="delete-all">
198+
<span>You may</span>
199+
<button type="button" @click="deleteAllInstances()" class="btn btn-danger btn-sm"><i class="fa fa-trash text-white" /> Delete</button>
200+
<span>this endpoint</span>
201+
</div>
202+
</no-data>
184203
<!--Table rows-->
185-
<DataView :data="instances" :show-items-per-page="true" :items-per-page="20">
204+
<DataView :data="filteredValidInstances" :show-items-per-page="true" :items-per-page="20">
186205
<template #data="{ pageData }">
187206
<div role="rowgroup" aria-label="endpoints">
188207
<div role="row" :aria-label="instance.name" class="row grid-row" v-for="instance in pageData" :key="instance.id">
@@ -247,4 +266,10 @@ async function toggleAlerts(instance: EndpointsView) {
247266
border-radius: 3px;
248267
padding: 0.4em;
249268
}
269+
270+
.delete-all {
271+
display: flex;
272+
align-items: center;
273+
gap: 0.4em;
274+
}
250275
</style>

src/Frontend/src/components/heartbeats/HealthyEndpoints.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import NoData from "../NoData.vue";
33
import { ColumnNames, useHeartbeatsStore } from "@/stores/HeartbeatsStore";
44
import { storeToRefs } from "pinia";
55
import HeartbeatsList from "./HeartbeatsList.vue";
6+
import ResultsCount from "../ResultsCount.vue";
67
78
const store = useHeartbeatsStore();
89
const { healthyEndpoints, filteredHealthyEndpoints } = storeToRefs(store);

0 commit comments

Comments
 (0)