-
Notifications
You must be signed in to change notification settings - Fork 26
Add activity filter for endpoint message types #2893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dvdstelt
wants to merge
2
commits into
master
Choose a base branch
from
feature/active-message-types-filter
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,34 +7,57 @@ import { storeToRefs } from "pinia"; | |||||||
| import NoData from "@/components/NoData.vue"; | ||||||||
| import SmallGraph from "./SmallGraph.vue"; | ||||||||
| import PaginationStrip from "@/components/PaginationStrip.vue"; | ||||||||
| import MessageTypeActivityFilter from "./MessageTypeActivityFilter.vue"; | ||||||||
| import { useMonitoringEndpointDetailsStore } from "@/stores/MonitoringEndpointDetailsStore"; | ||||||||
| import ColumnHeader from "@/components/ColumnHeader.vue"; | ||||||||
| import { CriticalTime, MessageType, ProcessingTime, ScheduledRetries, Throughput } from "@/resources/MonitoringResources"; | ||||||||
| import FAIcon from "@/components/FAIcon.vue"; | ||||||||
| import { faWarning } from "@fortawesome/free-solid-svg-icons"; | ||||||||
| import { useMonitoringHistoryPeriodStore } from "@/stores/MonitoringHistoryPeriodStore"; | ||||||||
|
|
||||||||
| const monitoringStore = useMonitoringEndpointDetailsStore(); | ||||||||
| const { endpointDetails: endpoint, messageTypes, messageTypesAvailable } = storeToRefs(monitoringStore); | ||||||||
| const { historyPeriod } = storeToRefs(useMonitoringHistoryPeriodStore()); | ||||||||
|
|
||||||||
| const route = useRoute(); | ||||||||
| const router = useRouter(); | ||||||||
| const messageTypesPage = ref(Number(route?.query?.pageNo ?? "1")); | ||||||||
| const activityFilter = ref(0); | ||||||||
|
|
||||||||
| watch(messageTypesPage, () => { | ||||||||
| router.replace({ query: { ...route.query, pageNo: messageTypesPage.value } }); | ||||||||
| }); | ||||||||
|
|
||||||||
| watch(activityFilter, () => { | ||||||||
| messageTypesPage.value = 1; | ||||||||
| }); | ||||||||
|
|
||||||||
| const props = defineProps({ | ||||||||
| perPage: { | ||||||||
| type: Number, | ||||||||
| default: 10, | ||||||||
| }, | ||||||||
| }); | ||||||||
|
|
||||||||
| const filteredMessageTypes = computed(() => { | ||||||||
| if (!messageTypes.value) return []; | ||||||||
| if (activityFilter.value === 0) return messageTypes.value.data; | ||||||||
|
|
||||||||
| return messageTypes.value.data.filter((mt) => { | ||||||||
| const points = mt.metrics.throughput.points; | ||||||||
| if (points.length === 0) return false; | ||||||||
|
|
||||||||
| const pVal = historyPeriod.value.pVal; | ||||||||
| const pointsToCheck = Math.min(points.length, Math.ceil((activityFilter.value / pVal) * points.length)); | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| const recentPoints = points.slice(-pointsToCheck); | ||||||||
| return recentPoints.some((p) => p > 0); | ||||||||
| }); | ||||||||
| }); | ||||||||
|
|
||||||||
| const paginatedMessageTypes = computed(() => { | ||||||||
| const pageStart = (messageTypesPage.value - 1) * props.perPage; | ||||||||
| const pageEnd = messageTypesPage.value * props.perPage; | ||||||||
| return messageTypes.value ? messageTypes.value.data.slice(pageStart, pageEnd) : []; | ||||||||
| return filteredMessageTypes.value.slice(pageStart, pageEnd); | ||||||||
| }); | ||||||||
| </script> | ||||||||
|
|
||||||||
|
|
@@ -46,6 +69,8 @@ const paginatedMessageTypes = computed(() => { | |||||||
| <a @click="monitoringStore.updateMessageTypes()" class="alink">Click here to reload the view</a> | ||||||||
| </div> | ||||||||
|
|
||||||||
| <MessageTypeActivityFilter v-model="activityFilter" :historyPeriod="historyPeriod.pVal" /> | ||||||||
|
|
||||||||
| <!-- Breakdown by message type--> | ||||||||
| <!--headers--> | ||||||||
| <div role="row" aria-label="message-type-column-headers" class="row box box-no-click table-head-row"> | ||||||||
|
|
@@ -65,6 +90,7 @@ const paginatedMessageTypes = computed(() => { | |||||||
| </div> | ||||||||
|
|
||||||||
| <no-data v-if="!endpoint?.messageTypes?.length" message="No messages processed in this period of time."></no-data> | ||||||||
| <no-data v-else-if="filteredMessageTypes.length === 0" message="No active message types found for the selected filter."></no-data> | ||||||||
|
|
||||||||
| <div role="rowgroup" aria-label="message-type-rows" class="row"> | ||||||||
| <div class="col-xs-12 no-side-padding"> | ||||||||
|
|
@@ -157,7 +183,7 @@ const paginatedMessageTypes = computed(() => { | |||||||
| </div> | ||||||||
| </div> | ||||||||
| </div> | ||||||||
| <PaginationStrip v-model="messageTypesPage" :itemsPerPage="perPage" :totalCount="messageTypes?.data?.length ?? 0" /> | ||||||||
| <PaginationStrip v-model="messageTypesPage" :itemsPerPage="perPage" :totalCount="filteredMessageTypes.length" /> | ||||||||
| </div> | ||||||||
| </div> | ||||||||
| </template> | ||||||||
|
|
||||||||
85 changes: 85 additions & 0 deletions
85
src/Frontend/src/components/monitoring/MessageTypeActivityFilter.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| <script setup lang="ts"> | ||
| import { computed, watch } from "vue"; | ||
|
|
||
| export interface ActivityFilterOption { | ||
| value: number; | ||
| text: string; | ||
| } | ||
|
|
||
| const allFilterOptions: ActivityFilterOption[] = [ | ||
| { value: 0, text: "All" }, | ||
| { value: 1, text: "1 min" }, | ||
| { value: 5, text: "5 min" }, | ||
| { value: 15, text: "15 min" }, | ||
| ]; | ||
|
|
||
| const props = defineProps<{ historyPeriod: number }>(); | ||
| const selected = defineModel<number>({ default: 0 }); | ||
|
|
||
| const filterOptions = computed(() => allFilterOptions.filter((o) => o.value === 0 || o.value <= props.historyPeriod)); | ||
|
|
||
| watch(filterOptions, () => { | ||
| if (!filterOptions.value.some((o) => o.value === selected.value)) { | ||
| selected.value = 0; | ||
| } | ||
| }); | ||
| </script> | ||
|
|
||
| <template> | ||
| <div class="activity-filter"> | ||
| <span class="activity-filter-label">Show active in the last:</span> | ||
| <ul aria-label="activity-filter-list" class="nav nav-pills activity-filter-pills"> | ||
| <li v-for="option in filterOptions" :key="option.value" :class="{ active: option.value === selected }" :aria-selected="option.value === selected"> | ||
| <a href="#" @click.prevent="selected = option.value">{{ option.text }}</a> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Anti-pattern - Consider using a |
||
| </li> | ||
| </ul> | ||
| </div> | ||
| </template> | ||
|
|
||
| <style scoped> | ||
| .activity-filter { | ||
| display: flex; | ||
| align-items: center; | ||
| gap: 8px; | ||
| margin: 16px 0 8px; | ||
| } | ||
|
|
||
| .activity-filter-label { | ||
| font-size: 13px; | ||
| color: #8c8c8c; | ||
| white-space: nowrap; | ||
| } | ||
|
|
||
| .nav-pills.activity-filter-pills > li > a { | ||
| border-radius: 0; | ||
| border-bottom: 3px solid transparent; | ||
| padding: 6px 8px; | ||
| font-size: 13px; | ||
| color: #00a3c4; | ||
| } | ||
|
|
||
| .nav-pills.activity-filter-pills > li > a:hover { | ||
| color: #00a3c4; | ||
| font-weight: normal; | ||
| background-color: initial; | ||
| border-bottom-color: #00a3c4; | ||
| text-decoration: none; | ||
| } | ||
|
|
||
| .nav-pills.activity-filter-pills > li.active > a, | ||
| .nav-pills.activity-filter-pills > li.active > a:hover, | ||
| .nav-pills.activity-filter-pills > li.active > a:focus { | ||
| color: #000; | ||
| font-weight: bold; | ||
| background-color: initial; | ||
| border-bottom-color: #000; | ||
| } | ||
|
|
||
| .nav li { | ||
| display: flex; | ||
| } | ||
|
|
||
| .nav-pills > li + li { | ||
| margin-left: 2px; | ||
| } | ||
| </style> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we also need to add a watcher for the
historyPeriod? i.e. user is on page 3 with "All" filter, switches history period -> stays on page 3 even if fewer results exist