diff --git a/src/components/user/User.tsx b/src/components/user/User.tsx index 68fc63a..1298db2 100644 --- a/src/components/user/User.tsx +++ b/src/components/user/User.tsx @@ -1,6 +1,14 @@ import { createForm } from '@felte/solid'; -import { Component, Index, Match, onMount, Show, Switch } from 'solid-js'; -import { TextField, Button } from '@kobalte/core'; +import { + Component, + createSignal, + Index, + Match, + onMount, + Show, + Switch, +} from 'solid-js'; +import { TextField, Button, Progress } from '@kobalte/core'; import reporter from '@felte/reporter-tippy'; import './style.css'; import { useNavigate } from 'solid-start'; @@ -18,6 +26,8 @@ interface Props { const User: Component = (props) => { const navigate = useNavigate(); + const [progress, setProgress] = createSignal(-1); + const credentials = adminCredentials(); const { database } = credentials || { database: null }; @@ -37,6 +47,7 @@ const User: Component = (props) => { values, context, }); + setProgress(0); const id = getValues()?._id ?? userId(values.username, values.database); await put(id, values, isNew()); const couchUserId = `org.couchdb.user:${values.username}`; @@ -49,6 +60,8 @@ const User: Component = (props) => { }; await put(couchUserId, userDoc, isNew(), '_users'); + setProgress(1); + const subscriptions = !!props?.values ? props.values().subscriptions ?? [] : []; @@ -74,6 +87,8 @@ const User: Component = (props) => { } } + setProgress(2); + for (let i = 0; i < subscriptions.length; i++) { let subscription = subscriptions[i]; if (!isIn(subscription.username, updatedSubscriptions)) { @@ -83,10 +98,12 @@ const User: Component = (props) => { }); } } + setProgress(3); setInitialValues(values); setIsDirty(false); + setProgress(-1); navigate(`/user/${id}`); }; @@ -200,102 +217,125 @@ const User: Component = (props) => { return ( <> - -

{userId(data('username'), data('database'))}

+ = 0}> + + `${value} of ${max} tasks completed` + } + class='progress' + > +
+ + Processing... + + +
+ + + +
+
+ + +

{userId(data('username'), data('database'))}

+
+
+ + Mail address + + + Please provide a valid URL + + + + Database + + + + User name + + + + Password + + + + + + + + + + + + {(_, index) => ( + + + + + )} + + +
+ + User name
+ + + + + +
+ + + + Save + + Delete + + + + Create + + + + Back +
-
- - Mail address - - - Please provide a valid URL - - - - Database - - - - User name - - - - Password - - - - - - - - - - - - {(_, index) => ( - - - - - )} - - -
- - User name
- - - - - -
- - - - Save - - Delete - - - - Create - - - - Back -
); }; diff --git a/src/components/user/style.css b/src/components/user/style.css index 06d4773..e62a62b 100644 --- a/src/components/user/style.css +++ b/src/components/user/style.css @@ -142,3 +142,33 @@ form { transform: scale(0.96); } } + + +.progress { + display: flex; + flex-direction: column; + gap: 2px; + width: 300px; +} +.progress__label-container { + display: flex; + justify-content: space-between; +} +.progress__label, +.progress__value-label { + color: hsl(240 4% 16%); + font-size: 14px; +} +.progress__track { + height: 10px; + background-color: hsl(240 6% 90%); +} +.progress__fill { + background-color: hsl(200 98% 39%); + height: 100%; + width: var(--kb-progress-fill-width); + transition: width 250ms linear; +} +.progress__fill[data-progress="complete"] { + background-color: #16a34a; +} \ No newline at end of file