Skip to content
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

Sessions order and filters fix #27

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 62 additions & 5 deletions src/pages/LogsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,61 @@
v-model="logViewerStore.logfileFilter"
@update:model-value="computedLogFileList()"
multiple
clearable
:options="logViewerStore.encounterOptions"
label="Filter encounters"
style="width: 256px"
/>
>
<template
v-if="logViewerStore.logfileFilter.length > 0"
v-slot:append
>
<q-icon
name="cancel"
@click.stop.prevent="
logViewerStore.logfileFilter = [];
computedLogFileList();
"
class="cursor-pointer q-field__focusable-action"
/>
</template>
</q-select>

<q-select
v-if="logViewerStore.viewerState === 'viewing-session'"
filled
v-model="logViewerStore.encounterFilter"
@update:model-value="calculateEncounterRows()"
multiple
clearable
:options="logViewerStore.encounterOptions"
label="Filter encounters"
style="width: 256px"
>
<template
v-if="logViewerStore.encounterFilter.length > 0"
v-slot:append
>
<q-icon
name="cancel"
@click.stop.prevent="
logViewerStore.encounterFilter = [];
calculateEncounterRows();
"
class="cursor-pointer q-field__focusable-action"
/>
</template>
</q-select>

<q-select
v-if="logViewerStore.viewerState === 'viewing-session'"
filled
v-model="logViewerStore.sessionsOrder"
@update:model-value="reOrderSessions()"
:options="[
{ label: 'Newest', value: 'desc' },
{ label: 'Oldest', value: 'asc' },
]"
label="Sessions Order"
style="width: 256px; margin-left: 10px"
/>

<q-space />
Expand Down Expand Up @@ -165,8 +204,8 @@
</q-timeline-entry>

<q-timeline-entry
v-for="encounter in encounterRows"
:key="encounter.encounterName"
v-for="(encounter, index) in encounterRows"
:key="`${index}-${encounter}`"
:title="
encounter.encounterName +
' | ' +
Expand Down Expand Up @@ -442,9 +481,27 @@ function calculateEncounterRows() {
return;
}
});

reOrderSessions();
}
/* End session table */

function reOrderSessions() {
if (encounterRows.value.length === 1) return;

const firstEncounter = encounterRows.value.at(0);
const lastEncounter = encounterRows.value.at(-1);

if (!firstEncounter || !lastEncounter) return;

const currentOrientation =
firstEncounter.startingMs < lastEncounter.startingMs ? "asc" : "desc";

if (currentOrientation === logViewerStore.sessionsOrder.value) return;

encounterRows.value.reverse();
}

/* Start encounter table */
const encounterRows: Ref<RowData[]> = ref([]);

Expand Down
3 changes: 3 additions & 0 deletions src/stores/log-viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type State = {
encounterOptions: string[];
encounterFilter: string[];
logfileFilter: string[];
sessionsOrder: { label: "Newest" | "Oldest"; value: "desc" | "asc" };
};

export const useLogViewerStore = defineStore("log-viewer", {
Expand All @@ -45,6 +46,7 @@ export const useLogViewerStore = defineStore("log-viewer", {
encounterOptions: [],
encounterFilter: [],
logfileFilter: [],
sessionsOrder: { label: "Newest", value: "desc" },
}),
actions: {
resetState() {
Expand All @@ -56,6 +58,7 @@ export const useLogViewerStore = defineStore("log-viewer", {
this.encounterOptions = [];
this.encounterFilter = [];
this.logfileFilter = [];
this.sessionsOrder = { label: "Newest", value: "desc" };
},
},
});