-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathQueryCacheView.vue
More file actions
139 lines (133 loc) · 2.98 KB
/
Copy pathQueryCacheView.vue
File metadata and controls
139 lines (133 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<script setup lang="ts">
import { computed } from "vue";
import { useQueryStore } from "@/lib/query_cache/queryStore";
// i18n
import { i18n } from "@/lib/i18n";
const toggleKeyMode = () => {
const { locale } = i18n.global;
locale.value = locale.value === "keymode" ? "en_US" : "keymode";
};
import { PButton, PTag, PTable } from "@/ui";
// Grab the Pinia store
const queryStore = useQueryStore();
// Build a list of all cache entries
const entries = computed(() => {
return Object.entries(queryStore.cacheState).map(([key, state]) => ({
key,
state,
// Prettify JSON or show placeholder
jsonData:
state.data !== null
? JSON.stringify(state.data, null, 2)
: "null",
expireAt: state.expireTime
? state.timestamp + state.expireTime
: null,
}));
});
</script>
<template>
<div class="p-3 flex flex-col gap-6">
<div>
<h2 class="text-2xl pb-3">Translations</h2>
<div class="flex flex-row gap-3 items-center">
<PButton @click="toggleKeyMode">Toogle Key Mode</PButton>
<div>
To switch back to your selected language, please reload the
page.
</div>
</div>
</div>
<div>
<h2 class="text-2xl">Query Cache</h2>
</div>
<PTable striped>
<thead>
<tr>
<th>Key</th>
<th>Loading</th>
<th>Error</th>
<th>Timestamp</th>
<th>ExpireMs</th>
<th>ExpireAt</th>
<th>Refetch</th>
<th>Data</th>
<th></th>
</tr>
</thead>
<tbody>
<tr
v-for="entry in entries"
:key="`${entry.key}`"
class="child:text-nowrap">
<td class="!text-wrap break-all">
{{ entry.key }}
</td>
<td>
<PTag
v-if="entry.state.loading"
:bordered="false"
type="success">
yes
</PTag>
<PTag v-else :bordered="false">no</PTag>
</td>
<td>
<span v-if="entry.state.error">{{
entry.state.error.message
}}</span>
<span v-else>—</span>
</td>
<td>
<span v-if="entry.state.timestamp">
{{
new Date(entry.state.timestamp).toLocaleString()
}}
</span>
<span v-else>—</span>
</td>
<td>
<pre>{{ entry.state.expireTime }}</pre>
</td>
<td>
{{
entry.expireAt
? new Date(entry.expireAt).toLocaleString()
: "—"
}}
</td>
<td>
<PTag
v-if="entry.state.autoRefetch"
:bordered="false"
type="success">
yes
</PTag>
<PTag v-else :bordered="false" type="error"> no </PTag>
</td>
<td>
<pre>{{ entry.jsonData?.length }}</pre>
</td>
<td>
<PButton
size="sm"
type="error"
@click="
async () => {
await queryStore.invalidateKey(
JSON.parse(entry.key),
{ skipRefetch: true }
);
}
">
Invalidate
</PButton>
</td>
</tr>
<tr v-if="entries.length === 0">
<td colspan="9">No queries in cache.</td>
</tr>
</tbody>
</PTable>
</div>
</template>