|
153 | 153 | hint="Re-check uniquement si la dernière vérification est plus ancienne que ce délai" |
154 | 154 | dense |
155 | 155 | ) |
| 156 | + template(#append) |
| 157 | + q-chip(dense size="sm" color="grey-3" text-color="dark") |
| 158 | + span(v-text="pwnedRecheckMaxAgeHuman") |
156 | 159 | q-select.col-12.col-sm-6.col-md-5.col-lg-4( |
157 | 160 | :disable='!hasPermission("/settings/passwdadm", "update") || !payload.pwnedRecheckEnabled || !hibpKeyStatus.valid' |
158 | 161 | outlined |
|
201 | 204 | </template> |
202 | 205 |
|
203 | 206 | <script lang="ts"> |
204 | | -import { ref, watch } from 'vue' |
| 207 | +import { computed, ref, watch } from 'vue' |
205 | 208 |
|
206 | 209 | type PasswordPolicySettings = { |
207 | 210 | len: number |
@@ -260,6 +263,27 @@ export default defineComponent({ |
260 | 263 | const validations = ref({} as Record<string, any>) |
261 | 264 | const hibpKeyStatus = ref<{ valid: boolean; reason: string | null }>({ valid: true, reason: null }) |
262 | 265 |
|
| 266 | + const pwnedRecheckMaxAgeHuman = computed(() => { |
| 267 | + const secondsRaw = Number(payload.value.pwnedRecheckMaxAgeSeconds || 0) |
| 268 | + if (!Number.isFinite(secondsRaw) || secondsRaw <= 0) return '0 minute' |
| 269 | +
|
| 270 | + let seconds = Math.floor(secondsRaw) |
| 271 | + const days = Math.floor(seconds / 86400) |
| 272 | + seconds -= days * 86400 |
| 273 | + const hours = Math.floor(seconds / 3600) |
| 274 | + seconds -= hours * 3600 |
| 275 | + const minutes = Math.floor(seconds / 60) |
| 276 | + seconds -= minutes * 60 |
| 277 | + const secs = Math.floor(seconds) |
| 278 | +
|
| 279 | + const parts: string[] = [] |
| 280 | + if (days) parts.push(`${days} jour${days > 1 ? 's' : ''}`) |
| 281 | + if (hours) parts.push(`${hours} heure${hours > 1 ? 's' : ''}`) |
| 282 | + if (minutes || parts.length === 0) parts.push(`${minutes} minute${minutes > 1 ? 's' : ''}`) |
| 283 | + if (secs) parts.push(`${secs} seconde${secs > 1 ? 's' : ''}`) |
| 284 | + return parts.join(' ') |
| 285 | + }) |
| 286 | +
|
263 | 287 | const { |
264 | 288 | data: result, |
265 | 289 | pending, |
@@ -303,6 +327,7 @@ export default defineComponent({ |
303 | 327 | payload, |
304 | 328 | pwnedActions, |
305 | 329 | hibpKeyStatus, |
| 330 | + pwnedRecheckMaxAgeHuman, |
306 | 331 | handleError, |
307 | 332 | pending, |
308 | 333 | refresh, |
|
0 commit comments