Skip to content

Commit 5787721

Browse files
committed
Add displaying of usage per month
1 parent 99c30b6 commit 5787721

File tree

5 files changed

+39
-5
lines changed

5 files changed

+39
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ async function toggleAlerts(instance: EndpointsView) {
167167
</div>
168168
<div role="columnheader" :aria-label="ColumnNames.MuteToggle" class="col-2 centre">
169169
<SortableColumn :sort-by="ColumnNames.MuteToggle" v-model="sortByInstances">Mute Alerts</SortableColumn>
170-
<tippy max-width="400px">
170+
<tippy max-width="400px" trigger="click">
171171
<i :style="{ fontSize: '1.1em', marginLeft: '0.25em' }" class="fa fa-info-circle text-primary" />
172172
<template #content>
173173
<span>Mute an instance when you are planning to take the instance offline to do maintenance or some other reason. This will prevent alerts on the dashboard.</span>

src/Frontend/src/resources/EndpointThroughputSummary.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ interface EndpointThroughputSummary {
33
is_known_endpoint: boolean;
44
user_indicator: string;
55
max_daily_throughput: number;
6+
max_monthly_throughput?: number;
67
}
78

89
export default EndpointThroughputSummary;

src/Frontend/src/views/throughputreport/endpoints/DetectedListView.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,15 @@ describe("DetectedListView tests", () => {
205205

206206
let throughput = 0;
207207
for (const row of within(table).getAllByRole("row").slice(1)) {
208-
expect(within(row).getByRole("cell", { name: "maximum daily throughput" }).textContent).toBe(`${throughput++}`);
208+
expect(within(row).getByRole("cell", { name: "maximum usage throughput" }).textContent).toBe(`${throughput++}`);
209209
}
210210

211211
await user.click(screen.getByRole("button", { name: /Sort by/i }));
212212
await user.click(screen.getByRole("link", { name: "throughput (Descending)" }));
213213

214214
throughput = dataLength - 1;
215215
for (const row of within(table).getAllByRole("row").slice(1)) {
216-
expect(within(row).getByRole("cell", { name: "maximum daily throughput" }).textContent).toBe(`${throughput--}`);
216+
expect(within(row).getByRole("cell", { name: "maximum usage throughput" }).textContent).toBe(`${throughput--}`);
217217
}
218218
});
219219

src/Frontend/src/views/throughputreport/endpoints/DetectedListView.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { userIndicatorMapper } from "./userIndicatorMapper";
1111
import ConfirmDialog from "@/components/ConfirmDialog.vue";
1212
import { useShowToast } from "@/composables/toast";
1313
import ResultsCount from "@/components/ResultsCount.vue";
14+
import { useHiddenFeature } from "./useHiddenFeature";
15+
import { license } from "@/composables/serviceLicense";
1416
1517
enum NameFilterType {
1618
beginsWith = "Begins with",
@@ -66,6 +68,9 @@ const filteredData = computed(() => {
6668
})
6769
.sort(sortItem?.comparer);
6870
});
71+
// We can remove this hidden toggle once we have new edition licenses.
72+
const hiddenFeatureToggle = useHiddenFeature(["ArrowUp", "ArrowUp", "ArrowDown", "ArrowDown"]);
73+
const showMonthly = computed(() => license.edition === "MonthlyUsage" || hiddenFeatureToggle.value);
6974
7075
onMounted(async () => {
7176
await loadData();
@@ -221,7 +226,8 @@ async function save() {
221226
<thead>
222227
<tr>
223228
<th scope="col">{{ props.columnTitle }}</th>
224-
<th scope="col" class="text-end formatThroughputColumn">Maximum daily throughput</th>
229+
<th v-if="showMonthly" scope="col" class="text-end formatThroughputColumn">Highest monthly throughput <i class="fa fa-info-circle text-primary" v-tippy="'In the last 12 months'" /></th>
230+
<th v-else scope="col" class="text-end formatThroughputColumn">Maximum daily throughput <i class="fa fa-info-circle text-primary" v-tippy="'In the last 12 months'" /></th>
225231
<th scope="col">Endpoint Type <i class="fa fa-info-circle text-primary" v-tippy="'Pick the most correct option'" /></th>
226232
</tr>
227233
</thead>
@@ -233,7 +239,8 @@ async function save() {
233239
<td class="col" aria-label="name">
234240
{{ row.name }}
235241
</td>
236-
<td class="col text-end formatThroughputColumn" style="width: 250px" aria-label="maximum daily throughput">{{ row.max_daily_throughput.toLocaleString() }}</td>
242+
<td v-if="showMonthly" class="col text-end formatThroughputColumn" style="width: 250px" aria-label="maximum usage throughput">{{ row.max_monthly_throughput ? row.max_monthly_throughput.toLocaleString() : "0" }}</td>
243+
<td v-else class="col text-end formatThroughputColumn" style="width: 250px" aria-label="maximum usage throughput">{{ row.max_daily_throughput.toLocaleString() }}</td>
237244
<td class="col" style="width: 350px" aria-label="endpoint type">
238245
<select class="form-select endpointType format-text" @change="(event) => updateIndicator(event, row.name)">
239246
<option v-if="props.showEndpointTypePlaceholder" value="">Pick the most appropriate option</option>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { ref, watchEffect } from "vue";
2+
3+
const keys = ref<string[]>([]);
4+
const hiddenFeatureEnabled = ref(false);
5+
const keyHandler = (event: KeyboardEvent) => {
6+
keys.value.push(event.key);
7+
};
8+
9+
watchEffect((onCleanup) => {
10+
if (keys.value.length > 0) {
11+
const timeout = window.setTimeout(() => keys.value.splice(0), 5000);
12+
onCleanup(() => clearTimeout(timeout));
13+
}
14+
});
15+
16+
window.document.addEventListener("keydown", keyHandler);
17+
18+
export function useHiddenFeature(keyCombo: string[]) {
19+
watchEffect(() => {
20+
if (keys.value.toString() === keyCombo.toString()) {
21+
hiddenFeatureEnabled.value = true;
22+
}
23+
});
24+
25+
return hiddenFeatureEnabled;
26+
}

0 commit comments

Comments
 (0)