@tekkare/romulus 0.1.303 → 0.1.305
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.json +1 -1
- package/dist/runtime/components/ShareDialog.vue +111 -9
- package/layer/app/components/layout/tool/adminTemplates.vue +86 -14
- package/layer/app/composables/useViewCardActions.ts +22 -4
- package/layer/app/utils/oipScopes.ts +2 -0
- package/layer/server/api/oip/es.post.ts +4 -1
- package/layer/server/utils/oipIndexUsage.ts +50 -0
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -14,6 +14,11 @@
|
|
|
14
14
|
des espaces au lieu des personnes. Une liste d'espaces vide vaut « tous »,
|
|
15
15
|
pour la meme raison que « tout l'espace » n'est pas deplie en noms.
|
|
16
16
|
|
|
17
|
+
Un modele peut aussi viser des personnes nommees, quel que soit leur espace.
|
|
18
|
+
Ce n'est pas la portee « des personnes choisies » : la vue reste un modele,
|
|
19
|
+
rangee dans le catalogue, pas dans leurs vues partagees. Espaces et
|
|
20
|
+
personnes se cumulent ; « tous » ne vaut que si les deux listes sont vides.
|
|
21
|
+
|
|
17
22
|
La liste des noms reste montee quand la portee change : on revient de
|
|
18
23
|
« tout l'espace » a « des personnes » sans avoir reperdu sa selection.
|
|
19
24
|
|
|
@@ -63,8 +68,13 @@ const props = withDefaults(
|
|
|
63
68
|
canTemplate?: boolean
|
|
64
69
|
/** La vue est deja publiee comme modele. */
|
|
65
70
|
isTemplate?: boolean
|
|
66
|
-
/** Espaces deja vises. Vide vaut « tous ». */
|
|
71
|
+
/** Espaces deja vises. Vide, sans personne visee, vaut « tous ». */
|
|
67
72
|
targetWorkspaces?: string[]
|
|
73
|
+
/**
|
|
74
|
+
* Personnes deja visees par le modele, avec leur nom : elles viennent
|
|
75
|
+
* souvent d'autres espaces, que la liste `members` ne connait pas.
|
|
76
|
+
*/
|
|
77
|
+
targetUsers?: RmShareMember[]
|
|
68
78
|
/** Espaces proposes. L'appelant les charge quand le dialogue s'ouvre. */
|
|
69
79
|
workspaces?: RmShareWorkspace[]
|
|
70
80
|
/**
|
|
@@ -88,6 +98,7 @@ const props = withDefaults(
|
|
|
88
98
|
canTemplate: false,
|
|
89
99
|
isTemplate: false,
|
|
90
100
|
targetWorkspaces: () => [],
|
|
101
|
+
targetUsers: () => [],
|
|
91
102
|
workspaces: () => [],
|
|
92
103
|
templateNote: '',
|
|
93
104
|
texts: () => ({}),
|
|
@@ -112,6 +123,7 @@ const emit = defineEmits<{
|
|
|
112
123
|
/** Absents quand l'appelant n'a pas le droit de publier. */
|
|
113
124
|
isTemplate?: boolean
|
|
114
125
|
targetWorkspaces?: string[]
|
|
126
|
+
targetUsers?: string[]
|
|
115
127
|
},
|
|
116
128
|
]
|
|
117
129
|
}>()
|
|
@@ -147,13 +159,32 @@ const T = computed(() => ({
|
|
|
147
159
|
: 'Offert comme point de depart sur cette page, sans etre partage.',
|
|
148
160
|
workspaceSearch: en.value ? 'Search for a workspace' : 'Chercher un espace',
|
|
149
161
|
noWorkspace: en.value ? 'No workspace to offer it to.' : 'Aucun espace a qui l\'offrir.',
|
|
162
|
+
templateWorkspaces: en.value ? 'Workspaces' : 'Espaces',
|
|
163
|
+
templatePeople: en.value ? 'People' : 'Personnes',
|
|
164
|
+
templatePeopleHint: en.value
|
|
165
|
+
? 'Offered to them whatever their workspace. It stays a template, not a shared view.'
|
|
166
|
+
: 'Offert quel que soit leur espace. Il reste un template, pas une vue partagee.',
|
|
167
|
+
templatePeopleSearch: en.value ? 'Search for a person by name or email' : 'Chercher une personne par nom ou adresse',
|
|
150
168
|
allWorkspaces: en.value
|
|
151
|
-
? 'No workspace picked: every workspace is offered the template.'
|
|
152
|
-
: 'Aucun espace
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
169
|
+
? 'No workspace or person picked: every workspace is offered the template.'
|
|
170
|
+
: 'Aucun espace ni personne retenus : le template est offert a tous les espaces.',
|
|
171
|
+
templateCount: (ws: number, people: number) => {
|
|
172
|
+
const parts = [
|
|
173
|
+
ws
|
|
174
|
+
? en.value
|
|
175
|
+
? `${ws} ${ws > 1 ? 'workspaces' : 'workspace'}`
|
|
176
|
+
: `${ws} espace${ws > 1 ? 's' : ''}`
|
|
177
|
+
: '',
|
|
178
|
+
people
|
|
179
|
+
? en.value
|
|
180
|
+
? `${people} ${people > 1 ? 'people' : 'person'}`
|
|
181
|
+
: `${people} personne${people > 1 ? 's' : ''}`
|
|
182
|
+
: '',
|
|
183
|
+
].filter(Boolean)
|
|
184
|
+
return en.value
|
|
185
|
+
? `Offered only to: ${parts.join(' and ')}.`
|
|
186
|
+
: `Offert uniquement a : ${parts.join(' et ')}.`
|
|
187
|
+
},
|
|
157
188
|
...props.texts,
|
|
158
189
|
}))
|
|
159
190
|
|
|
@@ -162,6 +193,9 @@ const picked = ref<string[]>([])
|
|
|
162
193
|
const search = ref('')
|
|
163
194
|
const pickedWorkspaces = ref<string[]>([])
|
|
164
195
|
const workspaceSearch = ref('')
|
|
196
|
+
/** Personnes visees par le modele, gardees avec leur nom pour les etiquettes. */
|
|
197
|
+
const pickedPeople = ref<RmShareMember[]>([])
|
|
198
|
+
const peopleSearch = ref('')
|
|
165
199
|
|
|
166
200
|
/**
|
|
167
201
|
* L'etat ouvert fait foi : le dialogue se recharge a chaque ouverture, jamais
|
|
@@ -173,6 +207,7 @@ watch(
|
|
|
173
207
|
if (!open) return
|
|
174
208
|
picked.value = [...props.sharedWith]
|
|
175
209
|
pickedWorkspaces.value = [...props.targetWorkspaces]
|
|
210
|
+
pickedPeople.value = [...props.targetUsers]
|
|
176
211
|
scope.value = props.isTemplate
|
|
177
212
|
? 'template'
|
|
178
213
|
: props.visibility === 'workspace'
|
|
@@ -182,11 +217,14 @@ watch(
|
|
|
182
217
|
: 'private'
|
|
183
218
|
search.value = ''
|
|
184
219
|
workspaceSearch.value = ''
|
|
220
|
+
peopleSearch.value = ''
|
|
185
221
|
},
|
|
186
222
|
{ immediate: true },
|
|
187
223
|
)
|
|
188
224
|
|
|
189
225
|
watch(search, value => emit('search', value.trim()))
|
|
226
|
+
// Meme recherche cote appelant : il complete `members` avec la plateforme.
|
|
227
|
+
watch(peopleSearch, value => emit('search', value.trim()))
|
|
190
228
|
|
|
191
229
|
const matches = computed(() => {
|
|
192
230
|
const q = search.value.trim().toLowerCase()
|
|
@@ -218,6 +256,27 @@ function toggleWorkspace(workspaceId: string) {
|
|
|
218
256
|
pickedWorkspaces.value = [...next]
|
|
219
257
|
}
|
|
220
258
|
|
|
259
|
+
/**
|
|
260
|
+
* Personnes proposees au modele : seulement quand on cherche. La liste des
|
|
261
|
+
* membres de l'espace de l'administrateur n'a rien a faire la par defaut, un
|
|
262
|
+
* modele vise surtout des gens d'espaces clients.
|
|
263
|
+
*/
|
|
264
|
+
const peopleMatches = computed(() => {
|
|
265
|
+
const q = peopleSearch.value.trim().toLowerCase()
|
|
266
|
+
if (!q) return []
|
|
267
|
+
return props.members.filter(
|
|
268
|
+
m =>
|
|
269
|
+
m.name.toLowerCase().includes(q) ||
|
|
270
|
+
(m.email ?? '').toLowerCase().includes(q),
|
|
271
|
+
)
|
|
272
|
+
})
|
|
273
|
+
|
|
274
|
+
function togglePerson(member: RmShareMember) {
|
|
275
|
+
pickedPeople.value = pickedPeople.value.some(p => p.userId === member.userId)
|
|
276
|
+
? pickedPeople.value.filter(p => p.userId !== member.userId)
|
|
277
|
+
: [...pickedPeople.value, member]
|
|
278
|
+
}
|
|
279
|
+
|
|
221
280
|
function close() {
|
|
222
281
|
emit('update:modelValue', false)
|
|
223
282
|
}
|
|
@@ -236,6 +295,7 @@ function save() {
|
|
|
236
295
|
...(props.canTemplate && {
|
|
237
296
|
isTemplate: scope.value === 'template',
|
|
238
297
|
targetWorkspaces: scope.value === 'template' ? pickedWorkspaces.value : [],
|
|
298
|
+
targetUsers: scope.value === 'template' ? pickedPeople.value.map(p => p.userId) : [],
|
|
239
299
|
}),
|
|
240
300
|
})
|
|
241
301
|
}
|
|
@@ -351,6 +411,8 @@ const scopes = computed<Array<{ key: RmShareScope; icon: string; label: string;
|
|
|
351
411
|
<div v-show="scope === 'template'" class="rm-share__people">
|
|
352
412
|
<p v-if="templateNote" class="rm-share__note">{{ templateNote }}</p>
|
|
353
413
|
|
|
414
|
+
<h3 class="rm-share__section">{{ T.templateWorkspaces }}</h3>
|
|
415
|
+
|
|
354
416
|
<label class="rm-share__search">
|
|
355
417
|
<RmIcon name="MagnifyingGlass" :size="16" />
|
|
356
418
|
<input
|
|
@@ -375,8 +437,48 @@ const scopes = computed<Array<{ key: RmShareScope; icon: string; label: string;
|
|
|
375
437
|
</li>
|
|
376
438
|
</ul>
|
|
377
439
|
|
|
440
|
+
<h3 class="rm-share__section">{{ T.templatePeople }}</h3>
|
|
441
|
+
<p class="rm-share__scope-hint">{{ T.templatePeopleHint }}</p>
|
|
442
|
+
|
|
443
|
+
<ul v-if="pickedPeople.length" class="rm-share__tags" :aria-label="T.templatePeople">
|
|
444
|
+
<li v-for="person in pickedPeople" :key="person.userId">
|
|
445
|
+
<RmTag variant="gray" closable @close="togglePerson(person)">
|
|
446
|
+
{{ person.name }}
|
|
447
|
+
</RmTag>
|
|
448
|
+
</li>
|
|
449
|
+
</ul>
|
|
450
|
+
|
|
451
|
+
<label class="rm-share__search">
|
|
452
|
+
<RmIcon name="MagnifyingGlass" :size="16" />
|
|
453
|
+
<input
|
|
454
|
+
v-model="peopleSearch"
|
|
455
|
+
type="search"
|
|
456
|
+
:placeholder="T.templatePeopleSearch"
|
|
457
|
+
:aria-label="T.templatePeopleSearch"
|
|
458
|
+
>
|
|
459
|
+
</label>
|
|
460
|
+
|
|
461
|
+
<p v-if="peopleSearch.trim() && !peopleMatches.length" class="rm-share__empty">
|
|
462
|
+
{{ T.noMatch }}
|
|
463
|
+
</p>
|
|
464
|
+
|
|
465
|
+
<ul v-else-if="peopleMatches.length" class="rm-share__list">
|
|
466
|
+
<li v-for="member in peopleMatches" :key="member.userId">
|
|
467
|
+
<RmCheckbox
|
|
468
|
+
:model-value="pickedPeople.some(p => p.userId === member.userId)"
|
|
469
|
+
:label="member.name"
|
|
470
|
+
:description="member.hint ? [member.email, member.hint].filter(Boolean).join(' · ') : member.email"
|
|
471
|
+
@update:model-value="togglePerson(member)"
|
|
472
|
+
/>
|
|
473
|
+
</li>
|
|
474
|
+
</ul>
|
|
475
|
+
|
|
378
476
|
<p class="rm-share__count">
|
|
379
|
-
{{
|
|
477
|
+
{{
|
|
478
|
+
pickedWorkspaces.length || pickedPeople.length
|
|
479
|
+
? T.templateCount(pickedWorkspaces.length, pickedPeople.length)
|
|
480
|
+
: T.allWorkspaces
|
|
481
|
+
}}
|
|
380
482
|
</p>
|
|
381
483
|
</div>
|
|
382
484
|
</div>
|
|
@@ -395,5 +497,5 @@ const scopes = computed<Array<{ key: RmShareScope; icon: string; label: string;
|
|
|
395
497
|
</template>
|
|
396
498
|
|
|
397
499
|
<style scoped>
|
|
398
|
-
.rm-share,.rm-share :where(*){box-sizing:border-box}.rm-share{display:flex;flex-direction:column;gap:var(--space-16)}.rm-share__note{background:var(--bg-surface-2);border:1px solid var(--border-soft);border-radius:var(--radius-md);color:var(--text-secondary);font-size:var(--font-12);padding:var(--space-8) var(--space-10)}.rm-share__head{display:flex;flex-direction:column;gap:var(--space-4)}.rm-share__title{color:var(--text-primary);font-size:var(--font-16);font-weight:var(--weight-bold)}.rm-share__subject{color:var(--text-secondary);font-size:var(--font-13)}.rm-share__scopes{display:flex;flex-direction:column;gap:var(--space-8);list-style:none;margin:0;padding:0}.rm-share__scope{align-items:flex-start;background:var(--bg-surface);border:1px solid var(--border-soft);border-radius:var(--radius-lg);color:var(--text-primary);cursor:pointer;display:flex;gap:var(--space-10);padding:var(--space-10) var(--space-12);text-align:left;width:100%}.rm-share__scope:hover{background:var(--bg-hover)}.rm-share__radio{border:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;clip:rect(0,0,0,0);white-space:nowrap}.rm-share__scope:has(.rm-share__radio:focus-visible){outline:2px solid var(--color-secondary);outline-offset:2px}.rm-share__scope.is-on{background:var(--bg-hover);border-color:var(--color-secondary)}.rm-share__scope-text{display:flex;flex:1;flex-direction:column;gap:2px}.rm-share__scope-label{font-size:var(--font-13);font-weight:var(--weight-medium)}.rm-share__scope-hint{color:var(--text-secondary);font-size:var(--font-12)}.rm-share__scope-mark{color:var(--color-secondary)}.rm-share__people{display:flex;flex-direction:column;gap:var(--space-8)}.rm-share__search{align-items:center;background:var(--bg-surface);border:1px solid var(--border-soft);border-radius:var(--radius-pill);color:var(--text-muted);display:flex;gap:var(--space-8);padding:var(--space-6) var(--space-10)}.rm-share__search input{background:none;border:none;color:var(--text-primary);flex:1;font-size:var(--font-13);outline:none}.rm-share__list{display:flex;flex-direction:column;gap:2px;list-style:none;margin:0;padding:0}.rm-share__count,.rm-share__empty{color:var(--text-secondary);font-size:var(--font-12)}.rm-share__foot{display:flex;gap:var(--space-8);justify-content:flex-end}
|
|
500
|
+
.rm-share,.rm-share :where(*){box-sizing:border-box}.rm-share{display:flex;flex-direction:column;gap:var(--space-16)}.rm-share__note{background:var(--bg-surface-2);border:1px solid var(--border-soft);border-radius:var(--radius-md);color:var(--text-secondary);font-size:var(--font-12);padding:var(--space-8) var(--space-10)}.rm-share__head{display:flex;flex-direction:column;gap:var(--space-4)}.rm-share__title{color:var(--text-primary);font-size:var(--font-16);font-weight:var(--weight-bold)}.rm-share__subject{color:var(--text-secondary);font-size:var(--font-13)}.rm-share__scopes{display:flex;flex-direction:column;gap:var(--space-8);list-style:none;margin:0;padding:0}.rm-share__scope{align-items:flex-start;background:var(--bg-surface);border:1px solid var(--border-soft);border-radius:var(--radius-lg);color:var(--text-primary);cursor:pointer;display:flex;gap:var(--space-10);padding:var(--space-10) var(--space-12);text-align:left;width:100%}.rm-share__scope:hover{background:var(--bg-hover)}.rm-share__radio{border:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;clip:rect(0,0,0,0);white-space:nowrap}.rm-share__scope:has(.rm-share__radio:focus-visible){outline:2px solid var(--color-secondary);outline-offset:2px}.rm-share__scope.is-on{background:var(--bg-hover);border-color:var(--color-secondary)}.rm-share__scope-text{display:flex;flex:1;flex-direction:column;gap:2px}.rm-share__scope-label{font-size:var(--font-13);font-weight:var(--weight-medium)}.rm-share__scope-hint{color:var(--text-secondary);font-size:var(--font-12)}.rm-share__scope-mark{color:var(--color-secondary)}.rm-share__people{display:flex;flex-direction:column;gap:var(--space-8)}.rm-share__search{align-items:center;background:var(--bg-surface);border:1px solid var(--border-soft);border-radius:var(--radius-pill);color:var(--text-muted);display:flex;gap:var(--space-8);padding:var(--space-6) var(--space-10)}.rm-share__search input{background:none;border:none;color:var(--text-primary);flex:1;font-size:var(--font-13);outline:none}.rm-share__list{display:flex;flex-direction:column;gap:2px;list-style:none;margin:0;padding:0}.rm-share__section{color:var(--text-primary);font-size:var(--font-12);font-weight:var(--weight-medium);margin:var(--space-8) 0 0}.rm-share__tags{display:flex;flex-wrap:wrap;gap:var(--space-6);list-style:none;margin:0;padding:0}.rm-share__count,.rm-share__empty{color:var(--text-secondary);font-size:var(--font-12)}.rm-share__foot{display:flex;gap:var(--space-8);justify-content:flex-end}
|
|
399
501
|
</style>
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
Tout template se gere ici, quel que soit qui l'a publie : changer les
|
|
10
10
|
espaces qui le recoivent, ou le retirer. Retirer ne supprime rien : la vue
|
|
11
|
-
revient dans « Mes vues » de son proprietaire. L'acces d'un template
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
revient dans « Mes vues » de son proprietaire. L'acces d'un template passe
|
|
12
|
+
par ses espaces cibles et par des personnes nommees (`targetUsers`), jamais
|
|
13
|
+
par le partage nominatif d'une vue, que l'API ignore sur un template.
|
|
14
14
|
-->
|
|
15
15
|
<script setup lang="ts">
|
|
16
16
|
import { useOipApi } from "#oip-app/api";
|
|
@@ -29,6 +29,17 @@ const { cardOf, start } = useViewTemplates(() => page.value);
|
|
|
29
29
|
|
|
30
30
|
type Row = Awaited<ReturnType<typeof elysia.admin.viewTemplates>>["data"][number];
|
|
31
31
|
|
|
32
|
+
/** Personne visee par un template, telle que l'inventaire la renvoie. */
|
|
33
|
+
type Person = { userId: string; name: string; email?: string };
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Lu hors du type de l'app : le client API de chaque app ne declare
|
|
37
|
+
* `targetUsers` qu'une fois remonte, et le layer ne doit pas casser avant.
|
|
38
|
+
*/
|
|
39
|
+
function peopleOf(row: Row | null | undefined): Person[] {
|
|
40
|
+
return (row as { targetUsers?: Person[] } | null | undefined)?.targetUsers ?? [];
|
|
41
|
+
}
|
|
42
|
+
|
|
32
43
|
const rows = ref<Row[]>([]);
|
|
33
44
|
const loading = ref(false);
|
|
34
45
|
|
|
@@ -68,7 +79,8 @@ function workspaceName(id: string) {
|
|
|
68
79
|
/** Qui a acces : tous les espaces quand aucune cible n'est posee. */
|
|
69
80
|
function accessRow(row: Row) {
|
|
70
81
|
const targets = row.targetWorkspaces ?? [];
|
|
71
|
-
|
|
82
|
+
const people = peopleOf(row);
|
|
83
|
+
if (!targets.length && !people.length) {
|
|
72
84
|
return {
|
|
73
85
|
icon: "Globe",
|
|
74
86
|
key: en.value ? "Access" : "Accès",
|
|
@@ -76,9 +88,12 @@ function accessRow(row: Row) {
|
|
|
76
88
|
};
|
|
77
89
|
}
|
|
78
90
|
return {
|
|
79
|
-
icon: "Buildings",
|
|
80
|
-
key: `${en.value ? "Access" : "Accès"} (${targets.length})`,
|
|
81
|
-
pills:
|
|
91
|
+
icon: targets.length ? "Buildings" : "UserPlus",
|
|
92
|
+
key: `${en.value ? "Access" : "Accès"} (${targets.length + people.length})`,
|
|
93
|
+
pills: [
|
|
94
|
+
...targets.map((id) => ({ k: en.value ? "Workspace" : "Espace", v: workspaceName(id) })),
|
|
95
|
+
...people.map((person) => ({ k: en.value ? "Person" : "Personne", v: person.name })),
|
|
96
|
+
],
|
|
82
97
|
};
|
|
83
98
|
}
|
|
84
99
|
|
|
@@ -147,7 +162,10 @@ function notify(text: string) {
|
|
|
147
162
|
]);
|
|
148
163
|
}
|
|
149
164
|
|
|
150
|
-
async function update(
|
|
165
|
+
async function update(
|
|
166
|
+
id: string,
|
|
167
|
+
body: { isTemplate?: boolean; targetWorkspaces?: string[]; targetUsers?: string[] },
|
|
168
|
+
) {
|
|
151
169
|
try {
|
|
152
170
|
await elysia.admin.updateViewTemplate(id, body);
|
|
153
171
|
return true;
|
|
@@ -160,6 +178,37 @@ async function update(id: string, body: { isTemplate?: boolean; targetWorkspaces
|
|
|
160
178
|
}
|
|
161
179
|
}
|
|
162
180
|
|
|
181
|
+
/**
|
|
182
|
+
* Personnes trouvees par la recherche du dialogue, sur toute la plateforme :
|
|
183
|
+
* un template vise surtout des gens d'espaces clients. Deux lettres au moins,
|
|
184
|
+
* une requete par pause de frappe, comme le partage depuis « Mes vues ».
|
|
185
|
+
*/
|
|
186
|
+
const people = ref<Person[]>([]);
|
|
187
|
+
let peopleSearch: ReturnType<typeof setTimeout> | null = null;
|
|
188
|
+
|
|
189
|
+
function onPeopleSearch(query: string) {
|
|
190
|
+
if (peopleSearch) clearTimeout(peopleSearch);
|
|
191
|
+
if (query.length < 2) {
|
|
192
|
+
people.value = [];
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
peopleSearch = setTimeout(async () => {
|
|
196
|
+
try {
|
|
197
|
+
const response = await elysia.admin.users({ search: query, limit: 20 });
|
|
198
|
+
people.value = (response.users ?? []).map((user) => ({
|
|
199
|
+
userId: user.userId,
|
|
200
|
+
name:
|
|
201
|
+
user.displayName ||
|
|
202
|
+
[user.firstName, user.lastName].filter(Boolean).join(" ") ||
|
|
203
|
+
user.email,
|
|
204
|
+
email: user.email,
|
|
205
|
+
}));
|
|
206
|
+
} catch (error) {
|
|
207
|
+
console.error("[adminTemplates] Recherche de personnes indisponible:", error);
|
|
208
|
+
}
|
|
209
|
+
}, 250);
|
|
210
|
+
}
|
|
211
|
+
|
|
163
212
|
/** Template dont on regle l'acces, ou null. */
|
|
164
213
|
const editingId = ref<string | null>(null);
|
|
165
214
|
const editing = computed(() => rows.value.find((row) => row.id === editingId.value) ?? null);
|
|
@@ -170,12 +219,18 @@ const dialogOpen = computed({
|
|
|
170
219
|
},
|
|
171
220
|
});
|
|
172
221
|
|
|
222
|
+
watch(editingId, () => (people.value = []));
|
|
223
|
+
|
|
173
224
|
/**
|
|
174
225
|
* Le dialogue rend toute la portee ; seuls le drapeau et les espaces comptent
|
|
175
226
|
* ici. Choisir autre chose que « template » revient a le retirer : la
|
|
176
227
|
* visibilite et les destinataires restent l'affaire du proprietaire.
|
|
177
228
|
*/
|
|
178
|
-
async function confirmAccess(share: {
|
|
229
|
+
async function confirmAccess(share: {
|
|
230
|
+
isTemplate?: boolean;
|
|
231
|
+
targetWorkspaces?: string[];
|
|
232
|
+
targetUsers?: string[];
|
|
233
|
+
}) {
|
|
179
234
|
const row = editing.value;
|
|
180
235
|
editingId.value = null;
|
|
181
236
|
if (!row) return;
|
|
@@ -186,12 +241,27 @@ async function confirmAccess(share: { isTemplate?: boolean; targetWorkspaces?: s
|
|
|
186
241
|
return;
|
|
187
242
|
}
|
|
188
243
|
const targets = share.targetWorkspaces ?? [];
|
|
189
|
-
|
|
190
|
-
|
|
244
|
+
const named = share.targetUsers ?? [];
|
|
245
|
+
if (await update(row.id, { targetWorkspaces: targets, targetUsers: named })) {
|
|
246
|
+
const audience = [
|
|
191
247
|
targets.length
|
|
192
248
|
? en.value
|
|
193
|
-
?
|
|
194
|
-
:
|
|
249
|
+
? `${targets.length} workspace${targets.length > 1 ? "s" : ""}`
|
|
250
|
+
: `${targets.length} espace${targets.length > 1 ? "s" : ""}`
|
|
251
|
+
: "",
|
|
252
|
+
named.length
|
|
253
|
+
? en.value
|
|
254
|
+
? `${named.length} ${named.length > 1 ? "people" : "person"}`
|
|
255
|
+
: `${named.length} personne${named.length > 1 ? "s" : ""}`
|
|
256
|
+
: "",
|
|
257
|
+
]
|
|
258
|
+
.filter(Boolean)
|
|
259
|
+
.join(en.value ? " and " : " et ");
|
|
260
|
+
notify(
|
|
261
|
+
audience
|
|
262
|
+
? en.value
|
|
263
|
+
? `Template offered to ${audience}.`
|
|
264
|
+
: `Template proposé à ${audience}.`
|
|
195
265
|
: en.value
|
|
196
266
|
? "Template offered to every workspace."
|
|
197
267
|
: "Template proposé à tous les espaces.",
|
|
@@ -242,12 +312,14 @@ async function onAction(key: string, id: string) {
|
|
|
242
312
|
<RmShareDialog
|
|
243
313
|
v-model="dialogOpen"
|
|
244
314
|
:title="editing?.title ?? ''"
|
|
245
|
-
:members="
|
|
315
|
+
:members="people"
|
|
246
316
|
can-template
|
|
247
317
|
is-template
|
|
248
318
|
:target-workspaces="editing?.targetWorkspaces ?? []"
|
|
319
|
+
:target-users="peopleOf(editing)"
|
|
249
320
|
:workspaces="workspaces"
|
|
250
321
|
:lang="en ? 'en' : 'fr'"
|
|
322
|
+
@search="onPeopleSearch"
|
|
251
323
|
@save="confirmAccess"
|
|
252
324
|
/>
|
|
253
325
|
</div>
|
|
@@ -322,17 +322,32 @@ function notify(text: string) {
|
|
|
322
322
|
function shareOutcome(
|
|
323
323
|
share: { visibility: string; sharedWith: string[]; isTemplate?: boolean },
|
|
324
324
|
targets: number,
|
|
325
|
+
people = 0,
|
|
325
326
|
): string {
|
|
326
327
|
const en = locale.value === "en";
|
|
327
328
|
if (share.isTemplate) {
|
|
328
|
-
if (targets === 0) {
|
|
329
|
+
if (targets === 0 && people === 0) {
|
|
329
330
|
return en
|
|
330
331
|
? "View published as a Tekkare template, offered to every workspace."
|
|
331
332
|
: "Vue publiée comme template Tekkare, offerte à tous les espaces.";
|
|
332
333
|
}
|
|
334
|
+
const audience = [
|
|
335
|
+
targets
|
|
336
|
+
? en
|
|
337
|
+
? `${targets} workspace${targets > 1 ? "s" : ""}`
|
|
338
|
+
: `${targets} espace${targets > 1 ? "s" : ""}`
|
|
339
|
+
: "",
|
|
340
|
+
people
|
|
341
|
+
? en
|
|
342
|
+
? `${people} ${people > 1 ? "people" : "person"}`
|
|
343
|
+
: `${people} personne${people > 1 ? "s" : ""}`
|
|
344
|
+
: "",
|
|
345
|
+
]
|
|
346
|
+
.filter(Boolean)
|
|
347
|
+
.join(en ? " and " : " et ");
|
|
333
348
|
return en
|
|
334
|
-
? `View published as a Tekkare template for ${
|
|
335
|
-
: `Vue publiée comme template Tekkare pour ${
|
|
349
|
+
? `View published as a Tekkare template for ${audience}.`
|
|
350
|
+
: `Vue publiée comme template Tekkare pour ${audience}.`;
|
|
336
351
|
}
|
|
337
352
|
if (share.visibility === "workspace") {
|
|
338
353
|
return en ? "View shared with the whole workspace." : "Vue partagée à tout l'espace.";
|
|
@@ -351,6 +366,7 @@ async function confirmShare(share: {
|
|
|
351
366
|
sharedWith: string[];
|
|
352
367
|
isTemplate?: boolean;
|
|
353
368
|
targetWorkspaces?: string[];
|
|
369
|
+
targetUsers?: string[];
|
|
354
370
|
}) {
|
|
355
371
|
const id = sharingId.value;
|
|
356
372
|
const target = shareTarget.value;
|
|
@@ -365,7 +381,9 @@ async function confirmShare(share: {
|
|
|
365
381
|
});
|
|
366
382
|
|
|
367
383
|
if (ok) {
|
|
368
|
-
notify(
|
|
384
|
+
notify(
|
|
385
|
+
shareOutcome(share, share.targetWorkspaces?.length ?? 0, share.targetUsers?.length ?? 0),
|
|
386
|
+
);
|
|
369
387
|
return;
|
|
370
388
|
}
|
|
371
389
|
|
|
@@ -280,6 +280,8 @@ export function createOipScopes(scopeStore: ReturnType<typeof defineOipScopeStor
|
|
|
280
280
|
*/
|
|
281
281
|
isTemplate?: boolean;
|
|
282
282
|
targetWorkspaces?: string[];
|
|
283
|
+
/** Personnes visees par le template, quel que soit leur espace. */
|
|
284
|
+
targetUsers?: string[];
|
|
283
285
|
templateCriteria?: any;
|
|
284
286
|
},
|
|
285
287
|
) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createError, defineEventHandler, getQuery, readBody } from "h3";
|
|
2
2
|
import { requireOipSession } from "../../utils/oipAuth";
|
|
3
3
|
import { findOipEsIndex, resolveOipEsIndex } from "../../utils/oipEsIndices";
|
|
4
|
+
import { oipReportIndexUsage } from "../../utils/oipIndexUsage";
|
|
4
5
|
import { oipResourceIndexes, type OipEsCluster } from "../../../app/utils/oipResources";
|
|
5
6
|
import { ES_INDEX } from "../../../app/oip-drugs/esIndices";
|
|
6
7
|
import { OIP_PATIENT_INDEXES } from "../../../app/oip-patients/indexes";
|
|
@@ -145,7 +146,9 @@ export default defineEventHandler(async (event) => {
|
|
|
145
146
|
throw createError({ status: 503, message: `Elasticsearch cluster not configured: ${cluster}` });
|
|
146
147
|
}
|
|
147
148
|
|
|
148
|
-
const
|
|
149
|
+
const physicalNames = await Promise.all(refs.map(physicalOf));
|
|
150
|
+
oipReportIndexUsage(event, physicalNames);
|
|
151
|
+
const physical = physicalNames.join(",");
|
|
149
152
|
const domain = target.domain.replace(/^https?:\/\//, "").replace(/\/+$/, "");
|
|
150
153
|
return await $fetch(`https://${domain}/${physical}/_search`, {
|
|
151
154
|
method: "POST",
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { H3Event } from "h3";
|
|
2
|
+
import { getOipAccessToken } from "./oipAuth";
|
|
3
|
+
import { oipAppUrls } from "./oipGuards";
|
|
4
|
+
|
|
5
|
+
// Releve « cette app lit cet index » pour la sonde hebdo de la Virtual Lab API
|
|
6
|
+
// (POST /index-health/usage). La sonde compare chaque lundi le mapping et les
|
|
7
|
+
// valeurs des champs keyword des index lus, et nomme dans son mail les apps
|
|
8
|
+
// touchees : un champ passe en nested vide les filtres sans aucune erreur.
|
|
9
|
+
// A appeler depuis tout proxy ES d'app, avec les noms physiques interroges.
|
|
10
|
+
|
|
11
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
12
|
+
|
|
13
|
+
/** Derniere declaration par index : une par jour et par instance suffit. */
|
|
14
|
+
const reported = new Map<string, number>();
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Declare les index lus, sans attendre ni jamais faire echouer la requete :
|
|
18
|
+
* une sonde muette vaut mieux qu'un filtre qui ne charge plus. Sans URL d'app
|
|
19
|
+
* (NUXT_OIP_APP_URL) ni jeton, rien ne part.
|
|
20
|
+
*/
|
|
21
|
+
export function oipReportIndexUsage(event: H3Event, physicalIndexes: string[]) {
|
|
22
|
+
const apiUrl = (useRuntimeConfig().oipVirtualLabApiUrl as string) || process.env.VIRTUAL_LAB_API_URL;
|
|
23
|
+
let app = "";
|
|
24
|
+
try {
|
|
25
|
+
const url = oipAppUrls()[0]!;
|
|
26
|
+
app = new URL(/^https?:\/\//.test(url) ? url : `https://${url}`).host;
|
|
27
|
+
} catch {
|
|
28
|
+
// App sans URL declaree : rien a signaler.
|
|
29
|
+
}
|
|
30
|
+
if (!apiUrl || !app) return;
|
|
31
|
+
|
|
32
|
+
const now = Date.now();
|
|
33
|
+
const due = physicalIndexes.filter((index) => now - (reported.get(index) ?? 0) > DAY_MS);
|
|
34
|
+
if (!due.length) return;
|
|
35
|
+
for (const index of due) reported.set(index, now);
|
|
36
|
+
|
|
37
|
+
void (async () => {
|
|
38
|
+
const token = await getOipAccessToken(event);
|
|
39
|
+
if (!token) throw new Error("no session");
|
|
40
|
+
await $fetch(`${apiUrl}/index-health/usage`, {
|
|
41
|
+
method: "POST",
|
|
42
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
43
|
+
body: { app, indexes: due },
|
|
44
|
+
});
|
|
45
|
+
})().catch((err: any) => {
|
|
46
|
+
// Reessaie a la prochaine requete plutot que dans un jour.
|
|
47
|
+
for (const index of due) reported.delete(index);
|
|
48
|
+
console.warn(`[oip/index-usage] report failed: ${err?.message ?? err}`);
|
|
49
|
+
});
|
|
50
|
+
}
|