Skip to content

Commit 4cfeb3e

Browse files
authored
feat(settings): the organisation sync card shows its schedule and last run (#2401)
Board SkSettingsData (admin-settings-tabs 2.1, Data tab): the organisation sync card shows first its schedule, last run, next run and the last run's result line from GET /api/sync/status; the status grid, the time window and the voorzieningen sync sit behind a fold. REQ-FE-312. Assisted-by: ClaudeCode:claude-opus-5-5
1 parent e204f87 commit 4cfeb3e

11 files changed

Lines changed: 539 additions & 7 deletions

File tree

‎l10n/en.json‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2625,6 +2625,16 @@
26252625
"_%n element was lost._::_%n elements were lost._": [
26262626
"%n element was lost.",
26272627
"%n elements were lost."
2628-
]
2628+
],
2629+
"Organisation synchronisation": "Organisation synchronisation",
2630+
"Organisations, contact persons and users from the national catalogue": "Organisations, contact persons and users from the national catalogue",
2631+
"Sync details and tools": "Sync details and tools",
2632+
"The synchronisation status could not be read": "The synchronisation status could not be read",
2633+
"{seconds} s": "{seconds} s",
2634+
"{minutes} min": "{minutes} min",
2635+
"{organisations} organisations, {contacts} contact persons": "{organisations} organisations, {contacts} contact persons",
2636+
"At the next cron run": "At the next cron run",
2637+
"Last run completed: {created} new, {updated} updated, {errors} errors": "Last run completed: {created} new, {updated} updated, {errors} errors",
2638+
"Next run": "Next run"
26292639
}
26302640
}

‎l10n/nl.js‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2629,7 +2629,17 @@ OC.L10N.register(
26292629
"%n element was lost.": "%n element viel weg.",
26302630
"%n elements were lost.": "%n elementen vielen weg.",
26312631
"The last check could not be read": "De laatste controle kon niet worden gelezen",
2632-
"_%n element was lost._::_%n elements were lost._": ["%n element viel weg.","%n elementen vielen weg."]
2632+
"_%n element was lost._::_%n elements were lost._": ["%n element viel weg.","%n elementen vielen weg."],
2633+
"Organisation synchronisation": "Organisatiesynchronisatie",
2634+
"Organisations, contact persons and users from the national catalogue": "Organisaties, contactpersonen en gebruikers uit de landelijke catalogus",
2635+
"Sync details and tools": "Synchronisatiedetails en hulpmiddelen",
2636+
"The synchronisation status could not be read": "De synchronisatiestatus kon niet worden gelezen",
2637+
"{seconds} s": "{seconds} s",
2638+
"{minutes} min": "{minutes} min",
2639+
"{organisations} organisations, {contacts} contact persons": "{organisations} organisaties, {contacts} contactpersonen",
2640+
"At the next cron run": "Bij de volgende cronrun",
2641+
"Last run completed: {created} new, {updated} updated, {errors} errors": "Laatste run voltooid: {created} nieuw, {updated} bijgewerkt, {errors} fouten",
2642+
"Next run": "Volgende run"
26332643
},
26342644
"nplurals=2; plural=(n != 1);"
26352645
)

‎l10n/nl.json‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2688,6 +2688,16 @@
26882688
"_%n element was lost._::_%n elements were lost._": [
26892689
"%n element viel weg.",
26902690
"%n elementen vielen weg."
2691-
]
2691+
],
2692+
"Organisation synchronisation": "Organisatiesynchronisatie",
2693+
"Organisations, contact persons and users from the national catalogue": "Organisaties, contactpersonen en gebruikers uit de landelijke catalogus",
2694+
"Sync details and tools": "Synchronisatiedetails en hulpmiddelen",
2695+
"The synchronisation status could not be read": "De synchronisatiestatus kon niet worden gelezen",
2696+
"{seconds} s": "{seconds} s",
2697+
"{minutes} min": "{minutes} min",
2698+
"{organisations} organisations, {contacts} contact persons": "{organisations} organisaties, {contacts} contactpersonen",
2699+
"At the next cron run": "Bij de volgende cronrun",
2700+
"Last run completed: {created} new, {updated} updated, {errors} errors": "Laatste run voltooid: {created} nieuw, {updated} bijgewerkt, {errors} fouten",
2701+
"Next run": "Volgende run"
26922702
}
26932703
}

‎openspec/changes/admin-settings-tabs/specs/fe-settings-ui/spec.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,15 @@ The admin page SHALL be one `CnAdminSettingsShell` with the board look and an un
1515
- WHEN the admin picks Access
1616
- THEN the address MUST end in `#access`
1717
- AND Back MUST return to General
18+
19+
### Requirement: The organisation sync card shows its schedule and last run (REQ-FE-312)
20+
21+
The organisation synchronisation card on the Data tab SHALL follow board SkSettingsData: its title is Organisation synchronisation with the subtitle "Organisations, contact persons and users from the national catalogue", and it SHALL first show, from `GET /api/sync/status`, the schedule ("Every hour"), the last run (its end time, how long it took and how many organisations and contact persons it processed, or "The sync has not run yet."), the next run (the last run's end plus the interval, "Off" when the scheduled sync is switched off) and the last run's result ("Last run completed: <n> new, <n> updated, <n> errors"). Sync now stays in the card body and Save in the footer; a manual sync SHALL refresh the facts. The status grid, the incremental time window and the voorzieningen sync SHALL stay available behind "Sync details and tools".
22+
23+
#### Scenario: The card names the last run
24+
@e2e tests/e2e/spec-coverage/settings.spec.ts
25+
26+
- GIVEN the organisation sync ran and kept its last run record
27+
- WHEN an admin opens `/settings/admin/stackiq#data`
28+
- THEN the Organisation synchronisation card MUST show the schedule, the last run with its organisations and contact persons, the next run and the result line
29+
- AND the status grid MUST sit behind "Sync details and tools"

‎openspec/changes/admin-settings-tabs/tasks.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@
1616
- Pixel, Data tab, ArchiMate (30 Nov 2026, SkSettingsData): the card is the board's 'ArchiMate importeren en exporteren' with its Open Group subtitle; the drop zone and separate Import step are gone: Bestand importeren opens the picker and the import starts on the pick, a running import names its file ('<file> wordt geïmporteerd') above its phase and Import annuleren; Bestand importeren and Basis exporteren share one action row, and the organisation select with Organisatie exporteren is one row under a rule (the include switches stay under it once an organisation is chosen). Still different: the board's round-trip line (last check's date and result, Verslag bekijken) needs a stored last check; the round-trip check stays the per-file check under the card.
1717
- Pixel, Access tab (30 Nov 2026, SkAdminAccess, decision 30 Nov 07:41Z option a): the Access tab draws the board's Rollen en groepen (the role table with a May column saying what each role may do, the role group under the role's name, the multi-group select kept; no sub-tabs) and E-mailsjablonen (the template editor only). The generic, organisation admin and super user group lists and the mail transport (settings, types, testing) moved to General under their own cards; the integriq Email connection links to `#general`. Unit: `accessTabSplitSections.spec.js`, `adminSettingsTabs.spec.js`, `ConnectionsDeclarationTest`. Still open: the board amendment for the multi-group select and the General tab cards (design), the live pixel re-run, and Toegangsreview (a new change).
1818
- Pixel pass, live screenshots (30 Nov 2026, sandbox NC 34, 1440 px) against the three boards. Exchange: the federation card follows SkInstellingenUitwisseling (#2373, #2376, #2377, #2379), and Integrations beside Service desk exchange, then Webhooks, are in the board's order. Data: the Organization Synchronization card's buttons ran past its half-width column; its rows wrap now. Still different from SkSettingsData: ArchiMate import/export is the old upload, export and check layout, not the board's one card with import progress and the round-trip line; the organisation sync card still shows its statistics grid and the voorzieningen sync. Access, against SkBeheerToegang: User Groups Configuration with four sub-tabs instead of the board's Rollen en groepen table (role, what it may do, group select); the e-mail configuration (SMTP, types, testing) instead of the board's E-mailsjablonen card; no Toegangsreview card (the quarterly access review has no spec or endpoint yet, so it is a new change, not this one).
19+
- Pixel, Data tab, organisation sync (30 Nov 2026, SkSettingsData, REQ-FE-312 in this change's spec): the card is the board's Organisatiesynchronisatie with its subtitle, and shows first the facts from `GET /api/sync/status`: Schema (the interval), Laatste run (end time, duration, organisations and contact persons), Volgende run (end plus interval, Off when switched off) and 'Laatste run voltooid: N nieuw, N bijgewerkt, N fouten'; Sync now in the body, Save in the footer, the facts refresh after a manual sync. The status grid, the incremental time window and the voorzieningen sync sit behind 'Synchronisatiedetails en hulpmiddelen'. Unit: `organisationSyncFacts.spec.js`, `organizationSynchronizationMounted.spec.js`. Still different: the board's Schema is a select and it has Maximale looptijd per run; the interval is fixed (OrganizationContactSyncSchedule) and the sync has no run-time limit setting.
1920
- [ ] 2.2 Archive this change with its spec synced.

‎src/utils/organisationSyncFacts.js‎

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
/**
2+
* SPDX-FileCopyrightText: 2026 Conduction B.V. <info@conduction.nl>
3+
* SPDX-License-Identifier: EUPL-1.2
4+
*/
5+
/**
6+
* The facts of the organisation sync card on the Data tab (board
7+
* SkSettingsData): the schedule, the last run, the next run and the last
8+
* run's result, from what `GET /api/sync/status` answers.
9+
*
10+
* @spec openspec/changes/admin-settings-tabs/specs/fe-settings-ui/spec.md#requirement-the-organisation-sync-card-shows-its-schedule-and-last-run-req-fe-312
11+
*/
12+
13+
import axios from '@nextcloud/axios'
14+
import { getLanguage, translate as t } from '@nextcloud/l10n'
15+
import { generateUrl } from '@nextcloud/router'
16+
17+
/**
18+
* Read the organisation sync's schedule and last run.
19+
*
20+
* @return {Promise<{interval: number, enabled: boolean, lastRun: object|null}>}
21+
* @throws {Error} With the server's message when the request fails.
22+
*
23+
* @spec openspec/changes/admin-settings-tabs/specs/fe-settings-ui/spec.md#requirement-the-organisation-sync-card-shows-its-schedule-and-last-run-req-fe-312
24+
*/
25+
export async function fetchSyncFacts() {
26+
try {
27+
const response = await axios.get(generateUrl('/apps/stackiq/api/sync/status'))
28+
return response.data
29+
} catch (error) {
30+
throw new Error(error?.response?.data?.message || t('stackiq', 'The synchronisation status could not be read'), { cause: error })
31+
}
32+
}
33+
34+
/**
35+
* A server time (`Y-m-d H:i:s`, the server's clock) as a Date.
36+
*
37+
* @param {string} value The time.
38+
* @return {Date|null}
39+
*/
40+
function parseServerTime(value) {
41+
if (typeof value !== 'string' || value === '') {
42+
return null
43+
}
44+
const date = new Date(value.includes('T') ? value : value.replace(' ', 'T'))
45+
return Number.isNaN(date.getTime()) ? null : date
46+
}
47+
48+
/**
49+
* The interval as words: "Every hour", "Every 6 hours".
50+
*
51+
* @param {number} seconds The interval.
52+
* @return {string}
53+
*
54+
* @spec openspec/changes/admin-settings-tabs/specs/fe-settings-ui/spec.md#requirement-the-organisation-sync-card-shows-its-schedule-and-last-run-req-fe-312
55+
*/
56+
export function scheduleLabel(seconds) {
57+
const value = Number(seconds) || 0
58+
if (value <= 0) {
59+
return t('stackiq', 'Not scheduled')
60+
}
61+
if (value === 3600) {
62+
return t('stackiq', 'Every hour')
63+
}
64+
if (value % 3600 === 0) {
65+
return t('stackiq', 'Every {hours} hours', { hours: value / 3600 })
66+
}
67+
return t('stackiq', 'Every {minutes} minutes', { minutes: Math.round(value / 60) })
68+
}
69+
70+
/**
71+
* The last run as the board writes it: "30 Nov 2026, 10:00 · 2 minutes · 412 organisations, 1,034 contact persons".
72+
*
73+
* @param {object|null} lastRun The last run record.
74+
* @param {string} [locale] The locale for the time and the numbers.
75+
* @return {string}
76+
*
77+
* @spec openspec/changes/admin-settings-tabs/specs/fe-settings-ui/spec.md#requirement-the-organisation-sync-card-shows-its-schedule-and-last-run-req-fe-312
78+
*/
79+
export function lastRunLine(lastRun, locale = getLanguage()) {
80+
const finished = parseServerTime(lastRun?.finishedAt)
81+
if (finished === null) {
82+
return t('stackiq', 'The sync has not run yet.')
83+
}
84+
const parts = [finished.toLocaleString(locale, { dateStyle: 'medium', timeStyle: 'short' })]
85+
const started = parseServerTime(lastRun.startedAt)
86+
if (started !== null && finished >= started) {
87+
const seconds = Math.round((finished - started) / 1000)
88+
parts.push(seconds < 60
89+
? t('stackiq', '{seconds} s', { seconds })
90+
: t('stackiq', '{minutes} min', { minutes: Math.round(seconds / 60) }))
91+
}
92+
if (lastRun.organizationsProcessed !== undefined) {
93+
parts.push(t('stackiq', '{organisations} organisations, {contacts} contact persons', {
94+
organisations: Number(lastRun.organizationsProcessed || 0).toLocaleString(locale),
95+
contacts: Number(lastRun.contactPersonsProcessed || 0).toLocaleString(locale),
96+
}))
97+
}
98+
return parts.join(' · ')
99+
}
100+
101+
/**
102+
* When the next scheduled run is due: the last run's end plus the interval, or null when it is off or never ran.
103+
*
104+
* @param {object} facts What the status answered.
105+
* @param {string} [locale] The locale for the time.
106+
* @return {string}
107+
*
108+
* @spec openspec/changes/admin-settings-tabs/specs/fe-settings-ui/spec.md#requirement-the-organisation-sync-card-shows-its-schedule-and-last-run-req-fe-312
109+
*/
110+
export function nextRunLine(facts, locale = getLanguage()) {
111+
if (!facts?.enabled) {
112+
return t('stackiq', 'Off')
113+
}
114+
const finished = parseServerTime(facts.lastRun?.finishedAt)
115+
const interval = Number(facts.interval) || 0
116+
if (finished === null || interval <= 0) {
117+
return t('stackiq', 'At the next cron run')
118+
}
119+
return new Date(finished.getTime() + interval * 1000).toLocaleString(locale, { dateStyle: 'medium', timeStyle: 'short' })
120+
}
121+
122+
/**
123+
* The last run's result: "Last run completed: 3 new, 11 updated, 0 errors", or an empty string without a counted run.
124+
*
125+
* @param {object|null} lastRun The last run record.
126+
* @return {string}
127+
*
128+
* @spec openspec/changes/admin-settings-tabs/specs/fe-settings-ui/spec.md#requirement-the-organisation-sync-card-shows-its-schedule-and-last-run-req-fe-312
129+
*/
130+
export function resultLine(lastRun) {
131+
if (!lastRun || lastRun.entitiesCreated === undefined) {
132+
return ''
133+
}
134+
return t('stackiq', 'Last run completed: {created} new, {updated} updated, {errors} errors', {
135+
created: Number(lastRun.entitiesCreated || 0),
136+
updated: Number(lastRun.entitiesUpdated || 0),
137+
errors: Number(lastRun.errorCount || 0),
138+
})
139+
}
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
<!--
2+
- SPDX-FileCopyrightText: 2026 Conduction B.V. <info@conduction.nl>
3+
- SPDX-License-Identifier: EUPL-1.2
4+
-->
5+
<!--
6+
The organisation sync card's facts (board SkSettingsData): the schedule,
7+
the last run, the next run and the last run's result line.
8+
9+
@spec openspec/changes/admin-settings-tabs/specs/fe-settings-ui/spec.md#requirement-the-organisation-sync-card-shows-its-schedule-and-last-run-req-fe-312
10+
-->
11+
<template>
12+
<div class="org-sync-facts" data-testid="org-sync-facts">
13+
<NcNoteCard v-if="error" type="error">
14+
{{ error }}
15+
</NcNoteCard>
16+
<dl v-else class="org-sync-facts__list">
17+
<dt>{{ t('stackiq', 'Schedule') }}</dt>
18+
<dd data-fact="schedule">
19+
{{ loading ? '…' : schedule }}
20+
</dd>
21+
<dt>{{ t('stackiq', 'Last run') }}</dt>
22+
<dd data-fact="last-run">
23+
{{ loading ? '…' : lastRun }}
24+
</dd>
25+
<dt>{{ t('stackiq', 'Next run') }}</dt>
26+
<dd data-fact="next-run">
27+
{{ loading ? '…' : nextRun }}
28+
</dd>
29+
</dl>
30+
<p v-if="!loading && result" class="org-sync-facts__result" data-fact="result">
31+
{{ result }}
32+
</p>
33+
</div>
34+
</template>
35+
36+
<script>
37+
import { translate as t } from '@nextcloud/l10n'
38+
import { NcNoteCard } from '@nextcloud/vue'
39+
import {
40+
fetchSyncFacts,
41+
lastRunLine,
42+
nextRunLine,
43+
resultLine,
44+
scheduleLabel,
45+
} from '../../../utils/organisationSyncFacts.js'
46+
47+
export default {
48+
name: 'OrganizationSyncFacts',
49+
50+
components: {
51+
NcNoteCard,
52+
},
53+
54+
data() {
55+
return {
56+
facts: null,
57+
loading: true,
58+
error: null,
59+
}
60+
},
61+
62+
computed: {
63+
/**
64+
* The schedule as words.
65+
*
66+
* @return {string}
67+
* @spec openspec/changes/admin-settings-tabs/specs/fe-settings-ui/spec.md#requirement-the-organisation-sync-card-shows-its-schedule-and-last-run-req-fe-312
68+
*/
69+
schedule() {
70+
return scheduleLabel(this.facts?.interval)
71+
},
72+
73+
/**
74+
* The last run's line.
75+
*
76+
* @return {string}
77+
* @spec openspec/changes/admin-settings-tabs/specs/fe-settings-ui/spec.md#requirement-the-organisation-sync-card-shows-its-schedule-and-last-run-req-fe-312
78+
*/
79+
lastRun() {
80+
return lastRunLine(this.facts?.lastRun ?? null)
81+
},
82+
83+
/**
84+
* When the next run is due.
85+
*
86+
* @return {string}
87+
* @spec openspec/changes/admin-settings-tabs/specs/fe-settings-ui/spec.md#requirement-the-organisation-sync-card-shows-its-schedule-and-last-run-req-fe-312
88+
*/
89+
nextRun() {
90+
return nextRunLine(this.facts)
91+
},
92+
93+
/**
94+
* The last run's result line.
95+
*
96+
* @return {string}
97+
* @spec openspec/changes/admin-settings-tabs/specs/fe-settings-ui/spec.md#requirement-the-organisation-sync-card-shows-its-schedule-and-last-run-req-fe-312
98+
*/
99+
result() {
100+
return resultLine(this.facts?.lastRun ?? null)
101+
},
102+
},
103+
104+
mounted() {
105+
this.load()
106+
},
107+
108+
methods: {
109+
t,
110+
111+
/**
112+
* Read the facts again, after a manual sync too.
113+
*
114+
* @return {Promise<void>}
115+
* @spec openspec/changes/admin-settings-tabs/specs/fe-settings-ui/spec.md#requirement-the-organisation-sync-card-shows-its-schedule-and-last-run-req-fe-312
116+
*/
117+
async load() {
118+
this.loading = true
119+
this.error = null
120+
try {
121+
this.facts = await fetchSyncFacts()
122+
} catch (error) {
123+
this.error = error.message
124+
} finally {
125+
this.loading = false
126+
}
127+
},
128+
},
129+
}
130+
</script>
131+
132+
<style scoped>
133+
.org-sync-facts {
134+
display: flex;
135+
flex-direction: column;
136+
gap: 8px;
137+
margin-bottom: 16px;
138+
}
139+
140+
.org-sync-facts__list {
141+
display: grid;
142+
grid-template-columns: minmax(120px, max-content) 1fr;
143+
gap: 6px 24px;
144+
margin: 0;
145+
}
146+
147+
.org-sync-facts__list dt,
148+
.org-sync-facts__list dd {
149+
margin: 0;
150+
padding: 0;
151+
text-align: start;
152+
}
153+
154+
.org-sync-facts__list dt {
155+
color: var(--color-text-maxcontrast);
156+
}
157+
158+
.org-sync-facts__result {
159+
margin: 0;
160+
padding-top: 8px;
161+
border-top: 1px solid var(--color-border);
162+
}
163+
</style>

0 commit comments

Comments
 (0)