Skip to content

Commit 281572a

Browse files
committed
chore: Add yaml package as a dependency
1 parent efe44e3 commit 281572a

File tree

7 files changed

+191
-94
lines changed

7 files changed

+191
-94
lines changed

config/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.yml

nuxt.config.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { resolve } from 'path'
2-
import { writeFileSync } from 'fs'
2+
import { readFileSync, writeFileSync } from 'fs'
33
import pugPlugin from 'vite-plugin-pug'
44
import openapiTS from 'openapi-typescript'
55
import { defineNuxtConfig } from 'nuxt/config'
6+
import { parse } from 'yaml'
67

78
const SESAME_APP_API_URL = process.env.SESAME_APP_API_URL || 'http://localhost:4002'
89

@@ -148,7 +149,21 @@ export default defineNuxtConfig({
148149
storesDirs: ['~/stores'],
149150
},
150151
hooks: {
151-
ready: async () => {
152+
ready: async (nuxt) => {
153+
try {
154+
const menus = parse(readFileSync('./config/menus.yml', 'utf8') || '{}')
155+
nuxt.options.appConfig.menus = { ...menus || {} }
156+
} catch (error) {
157+
console.debug('[Nuxt] Error while reading menus.yml', error)
158+
}
159+
160+
try {
161+
const identitiesColumns = parse(readFileSync('./config/identities-columns.yml', 'utf8') || '{}')
162+
nuxt.options.appConfig.identitiesColumns = { ...identitiesColumns || {} }
163+
} catch (error) {
164+
console.debug('[Nuxt] Error while reading identities-columns.yml', error)
165+
}
166+
152167
console.log('[OpenapiTS] Generating .nuxt/types/service-api.d.ts...')
153168
try {
154169
const fileData = await openapiTS(`${SESAME_APP_API_URL}/swagger/json`)

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"quasar": "^2.15.4",
3030
"radash": "^12.1.0",
3131
"sass": "^1.70.0",
32-
"vue-eslint-parser": "^9.4.2"
32+
"vue-eslint-parser": "^9.4.2",
33+
"yaml": "^2.4.2"
3334
},
3435
"devDependencies": {
3536
"@nuxt/devtools": "^1.1.5",
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
import type { QTableProps } from 'quasar'
2+
import type { components } from '#build/types/service-api'
3+
4+
type Identity = components['schemas']['IdentitiesDto']
5+
6+
interface ColumnConfig {
7+
name: string;
8+
label: string;
9+
field: string | ((row: any) => any);
10+
required?: boolean;
11+
align?: "left" | "right" | "center";
12+
sortable?: boolean;
13+
sort?: (a: any, b: any, rowA: any, rowB: any) => number;
14+
rawSort?: (a: any, b: any, rowA: any, rowB: any) => number;
15+
sortOrder?: "ad" | "da";
16+
format?: (val: any, row: any) => any;
17+
style?: string | ((row: any) => string);
18+
classes?: string | ((row: any) => string);
19+
headerStyle?: string;
20+
headerClasses?: string;
21+
}
22+
23+
const config = useAppConfig()
24+
const daysjs = useDayjs()
25+
26+
function processFieldValue(row: any, field: any) {
27+
if (field.type === 'function') {
28+
return eval(field.value);
29+
}
30+
return row[field];
31+
}
32+
33+
function processFormat(value: any, format: any) {
34+
if (format && format.type === 'function') {
35+
return eval(format.value);
36+
}
37+
return value;
38+
}
39+
40+
export function useColumnsIdentites() {
41+
const columns = ref<QTableProps['columns']>(
42+
[
43+
{
44+
name: 'states',
45+
label: 'Etats',
46+
field: 'states',
47+
align: 'left',
48+
},
49+
...config?.identitiesColumns?.entries || [],
50+
{
51+
name: 'metadata.lastUpdatedAt',
52+
label: 'Date de modification',
53+
field: (row: Identity) => row?.metadata?.lastUpdatedAt,
54+
format: (val: string) => daysjs(val).format('DD/MM/YYYY HH:mm'),
55+
align: 'left',
56+
sortable: true,
57+
},
58+
{
59+
name: 'metadata.createdAt',
60+
label: 'Date de création',
61+
field: (row: Identity) => row?.metadata?.createdAt,
62+
format: (val: string) => daysjs(val).format('DD/MM/YYYY HH:mm'),
63+
align: 'left',
64+
sortable: true,
65+
},
66+
{
67+
name: 'actions',
68+
label: 'Actions',
69+
field: 'actions',
70+
align: 'left',
71+
},
72+
].map((col: any) => ({
73+
...col,
74+
field: typeof col.field === 'function' ? col.field : (row: Identity) => processFieldValue(row, col.field),
75+
format: typeof col.format === 'function' ? col.format : (val: any) => processFormat(val, col.format),
76+
})) as ColumnConfig[]
77+
);
78+
79+
// const columns = ref<QTableProps['columns']>([
80+
// {
81+
// name: 'inetOrgPerson.uid',
82+
// label: 'ID',
83+
// field: (row: Identity) => row?.inetOrgPerson?.uid,
84+
// align: 'left',
85+
// sortable: true,
86+
// },
87+
// {
88+
// name: 'inetOrgPerson.employeeNumber',
89+
// label: 'EmployeeNumber',
90+
// field: (row: Identity) => row?.inetOrgPerson?.employeeNumber,
91+
// align: 'left',
92+
// sortable: true,
93+
// },
94+
// {
95+
// name: 'additionalFields.attributes.supannPerson.supannTypeEntiteAffectation',
96+
// label: 'Affectation',
97+
// field: (row: Identity) => row.additionalFields?.attributes?.supannPerson?.supannTypeEntiteAffectation,
98+
// align: 'left',
99+
// sortable: true,
100+
// },
101+
// {
102+
// name: 'inetOrgPerson.cn',
103+
// label: 'Nom',
104+
// field: (row: Identity) => row?.inetOrgPerson?.cn,
105+
// align: 'left',
106+
// sortable: true,
107+
// },
108+
// {
109+
// name: 'inetOrgPerson.givenName',
110+
// label: 'Prénom',
111+
// field: (row: Identity) => row?.inetOrgPerson?.givenName,
112+
// align: 'left',
113+
// sortable: false,
114+
// },
115+
// {
116+
// name: 'metadata.lastUpdatedAt',
117+
// label: 'Date de modification',
118+
// field: (row: Identity) => row?.metadata?.lastUpdatedAt,
119+
// format: (val: string) => daysjs(val).format('DD/MM/YYYY HH:mm'),
120+
// align: 'left',
121+
// sortable: true,
122+
// },
123+
// {
124+
// name: 'metadata.createdAt',
125+
// label: 'Date de création',
126+
// field: (row: Identity) => row?.metadata?.createdAt,
127+
// format: (val: string) => daysjs(val).format('DD/MM/YYYY HH:mm'),
128+
// align: 'left',
129+
// sortable: true,
130+
// },
131+
// {
132+
// name: 'actions',
133+
// label: 'Actions',
134+
// field: 'actions',
135+
// align: 'left',
136+
// },
137+
// ])
138+
139+
return {
140+
columns,
141+
}
142+
}

src/composables/useMenu.ts

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { IdentityState, useIdentityStates } from "./useIdentityStates"
33
import { useIdentityStateStore } from "~/stores/identityState"
44

55
const { getStateInfos } = useIdentityStates()
6+
const config = useAppConfig()
67

78
type Badge = {
89
name: string
@@ -77,30 +78,31 @@ function useMenu(identityStateStore, identityAffectationStore) {
7778
part: 'Etats',
7879
badgeValue: 'SYNCED',
7980
},
80-
{
81-
icon: 'mdi-account-off',
82-
label: 'Etudiants',
83-
path: '/identities?sort[metadata.lastUpdatedAt]=desc&skip=0&limit=10&filters[^additionalFields.attributes.supannPerson.supannTypeEntiteAffectation]=/etd/i',
84-
color: 'primary',
85-
part: 'Affectations',
86-
badgeValue: 'ETD',
87-
},
88-
{
89-
icon: 'mdi-account-tie',
90-
label: 'Administratifs',
91-
path: '/identities?sort[metadata.lastUpdatedAt]=desc&skip=0&limit=10&filters[^additionalFields.attributes.supannPerson.supannTypeEntiteAffectation]=/adm/i',
92-
color: 'primary',
93-
part: 'Affectations',
94-
badgeValue: 'ADM',
95-
},
96-
{
97-
icon: 'mdi-account-group',
98-
label: 'Enseignants',
99-
path: '/identities?sort[metadata.lastUpdatedAt]=desc&skip=0&limit=10&filters[^additionalFields.attributes.supannPerson.supannTypeEntiteAffectation]=/esn/i',
100-
color: 'primary',
101-
part: 'Affectations',
102-
badgeValue: 'ESN',
103-
},
81+
...config?.menus?.entries || [],
82+
// {
83+
// icon: 'mdi-account-off',
84+
// label: 'Etudiants',
85+
// path: '/identities?sort[metadata.lastUpdatedAt]=desc&skip=0&limit=10&filters[^additionalFields.attributes.supannPerson.supannTypeEntiteAffectation]=/etd/i',
86+
// color: 'primary',
87+
// part: 'Affectations',
88+
// badgeValue: 'ETD',
89+
// },
90+
// {
91+
// icon: 'mdi-account-tie',
92+
// label: 'Administratifs',
93+
// path: '/identities?sort[metadata.lastUpdatedAt]=desc&skip=0&limit=10&filters[^additionalFields.attributes.supannPerson.supannTypeEntiteAffectation]=/adm/i',
94+
// color: 'primary',
95+
// part: 'Affectations',
96+
// badgeValue: 'ADM',
97+
// },
98+
// {
99+
// icon: 'mdi-account-group',
100+
// label: 'Enseignants',
101+
// path: '/identities?sort[metadata.lastUpdatedAt]=desc&skip=0&limit=10&filters[^additionalFields.attributes.supannPerson.supannTypeEntiteAffectation]=/esn/i',
102+
// color: 'primary',
103+
// part: 'Affectations',
104+
// badgeValue: 'ESN',
105+
// },
104106
{
105107
icon: 'mdi-account-remove',
106108
label: 'En erreur',

src/pages/identities/index.vue

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ defineOptions({
7777
})
7878
7979
const twopan = ref<any>(null)
80-
const daysjs = useDayjs()
8180
const route = useRoute()
8281
const router = useRouter()
8382
const $q = useQuasar()
@@ -118,71 +117,7 @@ if (error.value) {
118117
})
119118
}
120119
121-
const columns = ref<QTableProps['columns']>([
122-
{
123-
name: 'states',
124-
label: 'Etats',
125-
field: 'states',
126-
align: 'left',
127-
},
128-
{
129-
name: 'inetOrgPerson.uid',
130-
label: 'ID',
131-
field: (row: Identity) => row?.inetOrgPerson?.uid,
132-
align: 'left',
133-
sortable: true,
134-
},
135-
{
136-
name: 'inetOrgPerson.employeeNumber',
137-
label: 'EmployeeNumber',
138-
field: (row: Identity) => row?.inetOrgPerson?.employeeNumber,
139-
align: 'left',
140-
sortable: true,
141-
},
142-
{
143-
name: 'additionalFields.attributes.supannPerson.supannTypeEntiteAffectation',
144-
label: 'Affectation',
145-
field: (row: Identity) => row.additionalFields?.attributes?.supannPerson?.supannTypeEntiteAffectation,
146-
align: 'left',
147-
sortable: true,
148-
},
149-
{
150-
name: 'inetOrgPerson.cn',
151-
label: 'Nom',
152-
field: (row: Identity) => row?.inetOrgPerson?.cn,
153-
align: 'left',
154-
sortable: true,
155-
},
156-
{
157-
name: 'inetOrgPerson.givenName',
158-
label: 'Prénom',
159-
field: (row: Identity) => row?.inetOrgPerson?.givenName,
160-
align: 'left',
161-
sortable: false,
162-
},
163-
{
164-
name: 'metadata.lastUpdatedAt',
165-
label: 'Date de modification',
166-
field: (row: Identity) => row?.metadata?.lastUpdatedAt,
167-
format: (val: string) => daysjs(val).format('DD/MM/YYYY HH:mm'),
168-
align: 'left',
169-
sortable: true,
170-
},
171-
{
172-
name: 'metadata.createdAt',
173-
label: 'Date de création',
174-
field: (row: Identity) => row?.metadata?.createdAt,
175-
format: (val: string) => daysjs(val).format('DD/MM/YYYY HH:mm'),
176-
align: 'left',
177-
sortable: true,
178-
},
179-
{
180-
name: 'actions',
181-
label: 'Actions',
182-
field: 'actions',
183-
align: 'left',
184-
},
185-
])
120+
const { columns } = useColumnsIdentites()
186121
const visibleColumns = ref<QTableProps['visibleColumns']>([
187122
'inetOrgPerson.uid',
188123
'inetOrgPerson.employeeNumber',

yarn.lock

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7290,6 +7290,7 @@ word-wrap@^1.2.5:
72907290
integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==
72917291

72927292
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
7293+
name wrap-ansi-cjs
72937294
version "7.0.0"
72947295
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
72957296
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
@@ -7337,7 +7338,7 @@ yallist@^4.0.0:
73377338
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
73387339
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==
73397340

7340-
yaml@^2.3.2:
7341+
yaml@^2.3.2, yaml@^2.4.2:
73417342
version "2.4.2"
73427343
resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.4.2.tgz#7a2b30f2243a5fc299e1f14ca58d475ed4bc5362"
73437344
integrity sha512-B3VqDZ+JAg1nZpaEmWtTXUlBneoGx6CPM9b0TENK6aoSu5t73dItudwdgmi6tHlIZZId4dZ9skcAQ2UbcyAeVA==

0 commit comments

Comments
 (0)