Skip to content

Commit 71ceb1b

Browse files
committed
feat: add lifecycle filtering and pagination options to lifecycles and jobs tables, improve layout and styling across various components
1 parent 6a23c6d commit 71ceb1b

File tree

6 files changed

+147
-37
lines changed

6 files changed

+147
-37
lines changed

apps/api/src/management/lifecycle/lifecycle-crud.service.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,11 @@ export class LifecycleCrudService extends AbstractLifecycleService {
282282
*/
283283
public async getRecentChanges(
284284
options?: FilterOptions,
285+
lifecycle?: string,
285286
): Promise<[number, Query<Array<Lifecycle>, Lifecycle, any, Lifecycle>[]]> {
286-
const total = await this.count({})
287-
const result = await this.find<Lifecycle>({}, null, {
287+
const searchFilter = lifecycle ? { lifecycle } : {}
288+
const total = await this.count(searchFilter)
289+
const result = await this.find<Lifecycle>(searchFilter, null, {
288290
populate: 'refId',
289291
sort: {
290292
...options?.sort,

apps/api/src/management/lifecycle/lifecycle.controller.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
Get,
44
HttpStatus,
55
Param,
6+
Query,
67
Req,
78
Res,
89
UseInterceptors,
@@ -296,8 +297,9 @@ export class LifecycleController extends AbstractController {
296297
public async getRecentChanges(
297298
@SearchFilterOptions() searchFilterOptions: FilterOptions,
298299
@Res() res: Response,
300+
@Query('lifecycle') lifecycle?: string,
299301
): Promise<Response<Lifecycle[]>> {
300-
const [total, data] = await this._service.getRecentChanges(searchFilterOptions);
302+
const [total, data] = await this._service.getRecentChanges(searchFilterOptions, lifecycle);
301303
return res.status(HttpStatus.OK).json({
302304
statusCode: HttpStatus.OK,
303305
data,

apps/web/src/composables/useAuditsTable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function getAuditOperationLabel(op?: string): string {
4242
case 'insert':
4343
return 'Creation'
4444
case 'update':
45-
return 'Mise a jour'
45+
return 'Mise à jour'
4646
case 'delete':
4747
return 'Suppression'
4848
case 'replace':

apps/web/src/pages/audits/table.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template lang="pug">
2-
q-page.container.q-pa-md
2+
q-page.container.q-pa-sm
33
q-card(bordered square flat style='border-bottom: none;')
44
q-card-section.q-pa-none
55
q-toolbar(bordered dense style='height: 28px; line-height: 28px;')
@@ -48,6 +48,7 @@ q-page.container.q-pa-md
4848
v-model:pagination='pagination'
4949
:loading='loading'
5050
:filter='search'
51+
:rows-per-page-options='[16, 32, 64, 100]'
5152
:pagination-label='(firstRowIndex, endRowIndex, totalRowsNumber) => `${firstRowIndex}-${endRowIndex} sur ${totalRowsNumber} lignes`'
5253
@request='onRequest'
5354
)

apps/web/src/pages/jobs/table.vue

Lines changed: 74 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
<template lang="pug">
2-
q-page.container
3-
q-table(
4-
title="Journal des jobs"
5-
v-model:expanded="expanded"
6-
:rows="rows || []"
7-
:columns="columns"
8-
:rows-per-page-options="[18, 100, 0]"
9-
row-key="jobId"
10-
bordered
11-
dense
12-
flat
13-
)
14-
template(v-slot:top-right)
2+
q-page.container.q-pa-sm
3+
q-card(bordered square flat style='border-bottom: none;')
4+
q-card-section.q-pa-none
5+
q-toolbar(bordered dense style='height: 28px; line-height: 28px;')
6+
q-toolbar-title Journal des jobs
7+
q-btn(
8+
icon='mdi-refresh'
9+
color='primary'
10+
flat
11+
round
12+
dense
13+
:loading='pending'
14+
:disable='pending'
15+
@click='refreshJobs'
16+
)
17+
18+
q-separator
19+
q-toolbar(bordered dense style='height: 28px; line-height: 28px;')
20+
q-space
1521
q-select(
1622
v-model="stateFilter"
1723
:options="foptions"
@@ -23,8 +29,22 @@ q-page.container
2329
style="width: 150px"
2430
map-options
2531
)
26-
template(v-slot:append)
27-
q-icon(name="mdi-filter")
32+
q-table(
33+
flat
34+
bordered
35+
dense
36+
binary-state-sort
37+
v-model:pagination='pagination'
38+
v-model:expanded='expanded'
39+
:rows='rows || []'
40+
:columns='columns'
41+
:rows-per-page-options='[16, 32, 64, 100]'
42+
:loading='pending'
43+
:pagination-label='(firstRowIndex, endRowIndex, totalRowsNumber) => `${firstRowIndex}-${endRowIndex} sur ${totalRowsNumber} lignes`'
44+
row-key='jobId'
45+
@request='onRequest'
46+
)
47+
template(v-slot:top-right)
2848
template(v-slot:no-data)
2949
div.text-center.q-pa-md
3050
span Aucune donnée à afficher.
@@ -113,13 +133,23 @@ export default defineComponent({
113133
},
114134
async setup() {
115135
const { monacoOptions } = useDebug()
116-
const $route = useRoute()
136+
const route = useRoute()
137+
const router = useRouter()
138+
const pagination = ref({
139+
sortBy: 'date',
140+
descending: true,
141+
page: route.query.page ? parseInt(route.query.page as string, 10) : 1,
142+
rowsPerPage: route.query.limit ? parseInt(route.query.limit as string, 10) : 16,
143+
rowsNumber: 0,
144+
})
117145
const query = computed(() => {
146+
const { page, limit, skip, ...restQuery } = route.query
147+
118148
return {
119-
limit: 2000,
120-
skip: 0,
149+
limit: pagination.value.rowsPerPage,
150+
skip: (pagination.value.page - 1) * pagination.value.rowsPerPage,
121151
'sort[metadata.lastUpdatedAt]': 'desc',
122-
...$route.query,
152+
...restQuery,
123153
}
124154
})
125155
@@ -131,17 +161,18 @@ export default defineComponent({
131161
} = await useHttp<any>('/core/jobs', {
132162
method: 'GET',
133163
transform: (result) => {
134-
const data = result?.data?.map((enr) => {
135-
return enr
136-
})
137-
138-
return data || []
164+
return result?.data || []
165+
},
166+
onResponse({ response }) {
167+
pagination.value.rowsNumber = response?._data?.total || 0
139168
},
140169
query,
141170
})
142171
143172
return {
144173
monacoOptions,
174+
router,
175+
pagination,
145176
rows,
146177
pending,
147178
error,
@@ -181,16 +212,35 @@ export default defineComponent({
181212
},
182213
},
183214
methods: {
215+
async onRequest(props): Promise<void> {
216+
const { page, rowsPerPage } = props.pagination
217+
218+
this.pagination.page = page
219+
this.pagination.rowsPerPage = rowsPerPage
220+
221+
await this.router.replace({
222+
query: {
223+
...this.$route.query,
224+
page: `${page}`,
225+
limit: `${rowsPerPage}`,
226+
},
227+
})
228+
},
229+
async refreshJobs(): Promise<void> {
230+
await this.refresh()
231+
},
184232
updateStateFilter(selection: { value: string | null }): void {
185233
const query = {
186234
...this.$route.query,
235+
page: '1',
187236
}
188237
189238
if (!selection.value) {
190239
delete query['filters[:state]']
191240
} else {
192241
query['filters[:state]'] = selection.value
193242
}
243+
delete query.skip
194244
195245
this.$router.replace({
196246
query,

apps/web/src/pages/lifecycles/table.vue

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,51 @@
11
<template lang="pug">
2-
q-page.container
2+
q-page.container.q-pa-sm
3+
q-card(bordered square flat style='border-bottom: none;')
4+
q-card-section.q-pa-none
5+
q-toolbar(bordered dense style='height: 28px; line-height: 28px;')
6+
q-toolbar-title Derniers cycles déclenchés
7+
q-btn(
8+
icon='mdi-refresh'
9+
color='primary'
10+
flat
11+
round
12+
dense
13+
:loading='pending'
14+
:disable='pending'
15+
@click='refreshLifecycles'
16+
)
17+
q-separator
18+
q-toolbar(bordered dense style='height: 28px; line-height: 28px;')
19+
q-space
20+
q-select(
21+
v-model='selectedLifecycle'
22+
:options='lifecycleOptions'
23+
dense
24+
outlined
25+
clearable
26+
clear-icon='mdi-close'
27+
hide-dropdown-icon
28+
label='Filtrer par cycle'
29+
style='width: 210px'
30+
emit-value
31+
map-options
32+
option-label='label'
33+
option-value='value'
34+
)
335
q-table(
4-
flat bordered dense
5-
title="Derniers cycles déclenchés"
36+
flat
37+
bordered
38+
dense
39+
binary-state-sort
640
:rows="rows || []"
741
:columns="columns"
842
row-key="_id"
943
v-model:pagination="pagination"
1044
v-model:expanded="expanded"
45+
:rows-per-page-options='[16, 32, 64, 100]'
46+
:pagination-label='(firstRowIndex, endRowIndex, totalRowsNumber) => `${firstRowIndex}-${endRowIndex} sur ${totalRowsNumber} lignes`'
1147
:loading="pending"
1248
:filter="filter"
13-
binary-state-sort
1449
@request="onRequest"
1550
)
1651
template(#header="props")
@@ -85,7 +120,7 @@ export default defineComponent({
85120
const route = useRoute()
86121
const router = useRouter()
87122
88-
const { getLifecycleName, getLifecycleIcon, getLifecycleColor } = await useIdentityLifecycles()
123+
const { getLifecycleName, getLifecycleIcon, getLifecycleColor, stateList } = await useIdentityLifecycles()
89124
90125
const pagination = ref({
91126
sortBy: 'desc',
@@ -109,7 +144,7 @@ export default defineComponent({
109144
query,
110145
onRequest() {
111146
pagination.value.page = parseInt(route.query.page as string, 10) || 1
112-
pagination.value.rowsPerPage = parseInt(route.query.limit as string, 10) || 18
147+
pagination.value.rowsPerPage = parseInt(route.query.limit as string, 10) || 16
113148
},
114149
onResponse({ response }) {
115150
pagination.value.rowsNumber = response._data.total || 0
@@ -120,6 +155,10 @@ export default defineComponent({
120155
return {
121156
monacoOptions,
122157
pagination,
158+
lifecycleOptions: computed(() => stateList.value.map((state) => ({
159+
label: state?.label || state?.key || 'Inconnu',
160+
value: state?.key,
161+
}))),
123162
124163
getLifecycleName,
125164
getLifecycleIcon,
@@ -134,6 +173,21 @@ export default defineComponent({
134173
}
135174
},
136175
computed: {
176+
selectedLifecycle: {
177+
get(): string | undefined {
178+
const lifecycle = this.$route.query.lifecycle
179+
return lifecycle ? `${lifecycle}` : undefined
180+
},
181+
set(v: string | undefined): void {
182+
this.$router.replace({
183+
query: {
184+
...this.$route.query,
185+
lifecycle: v || undefined,
186+
page: '1',
187+
},
188+
})
189+
},
190+
},
137191
columns() {
138192
return [
139193
{
@@ -164,12 +218,13 @@ export default defineComponent({
164218
},
165219
},
166220
methods: {
221+
async refreshLifecycles() {
222+
await this.refresh()
223+
},
167224
async onRequest(props) {
168225
const { page, rowsPerPage: limit, sortBy, descending } = props.pagination
169226
const filter = props.filter
170227
171-
console.log('Requesting data with:', { page, limit, sortBy, descending, filter, props })
172-
173228
await this.router.replace({
174229
query: {
175230
...this.router.currentRoute.value.query,

0 commit comments

Comments
 (0)