diff --git a/src/App.svelte b/src/App.svelte index 13f9d517..c5548087 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -49,6 +49,7 @@ import UserDetail from "./components/UserDetail.svelte"; OpenAPI.BASE = config.baseurl; import { register as registerSW } from "./swmodule"; + import TeamDetail from "./components/TeamDetail.svelte"; store.init(); // registerSW(); @@ -85,8 +86,13 @@ - - + + + + + + + diff --git a/src/components/AddTeamModal.svelte b/src/components/AddTeamModal.svelte new file mode 100644 index 00000000..68f54be0 --- /dev/null +++ b/src/components/AddTeamModal.svelte @@ -0,0 +1,181 @@ + + +{#if modal_open} + { + modal_open = false; + }}> + + + + + + + + + + + + + + Create a new team + + + + Please provide the required information to add a new team. + + + + + {$_('team-name')} + + {#if !isTeamNameValid} + + team name is required + + {/if} + + + {$_('organization')} + + {#each orgs as t} + {t.name} + {/each} + + + + + + + + + {$_('create')} + + { + modal_open = false; + }} + type="button" + class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm"> + {$_('cancel')} + + + + + +{/if} diff --git a/src/components/ConfirmOrgDeletion.svelte b/src/components/ConfirmOrgDeletion.svelte new file mode 100644 index 00000000..9f2d4831 --- /dev/null +++ b/src/components/ConfirmOrgDeletion.svelte @@ -0,0 +1,100 @@ + + +{#if modal_open} + + + + + + + + + + + + + + + Attention! + + + + Do you want to delete the organization + {delete_org.name}?All associated teams and runners will + be deleted too! + + + + + + + + Confirm, delete organization and associated teams+runners. + + + Cancel, keep organization + + + + + +{/if} diff --git a/src/components/OrgDetail.svelte b/src/components/OrgDetail.svelte index 42b68879..c1e69614 100644 --- a/src/components/OrgDetail.svelte +++ b/src/components/OrgDetail.svelte @@ -3,6 +3,7 @@ import { _ } from "svelte-i18n"; import Toastify from "toastify-js"; import store from "../store"; + import ConfirmOrgDeletion from "./ConfirmOrgDeletion.svelte"; import PromiseError from "./PromiseError.svelte"; $: delete_triggered = false; $: save_enabled = !data_changed; @@ -18,15 +19,25 @@ orgdata = Object.assign(orgdata, value); original = Object.assign(original, value); }); + let modal_open = false; + let delete_org = {}; function deleteOrganisation() { - RunnerOrganisationService.runnerOrganisationControllerRemove( - original.id, - true - ) - .then((resp) => { - location.replace("./"); - }) - .catch((err) => {}); + // RunnerOrganisationService.runnerOrganisationControllerRemove( + // original.id, + // false + // ) + // .then((resp) => { + // Toastify({ + // text: "Organization deleted", + // duration: 500, + // backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)", + // }).showToast(); + // location.replace("./"); + // }) + // .catch((err) => { + modal_open = true; + delete_org = original; + // }); } function submit() { if (data_loaded === true && save_enabled) { @@ -55,6 +66,7 @@ } + {#if data_loaded} diff --git a/src/components/OrgOverview.svelte b/src/components/OrgOverview.svelte index f22ddb3a..5b4a7ff3 100644 --- a/src/components/OrgOverview.svelte +++ b/src/components/OrgOverview.svelte @@ -1,9 +1,13 @@ + { + modal_open = false; + active_deletes[event.detail.id] = false; + }} + bind:modal_open + bind:delete_org /> {#if store.state.jwtinfo.userdetails.permissions.includes('ORGANISATION:GET')} {#await promise} { - RunnerOrganisationService.runnerOrganisationControllerRemove(o.id, true) + RunnerOrganisationService.runnerOrganisationControllerRemove(o.id, false) .then((resp) => { current_organizations = current_organizations.filter((obj) => obj.id !== o.id); + Toastify({ + text: 'Organization deleted', + duration: 500, + backgroundColor: + 'linear-gradient(to right, #00b09b, #96c93d)', + }).showToast(); }) .catch((err) => { - // error deleting user + modal_open = true; + delete_org = o; }); }} tabindex="0" diff --git a/src/components/TeamDetail.svelte b/src/components/TeamDetail.svelte new file mode 100644 index 00000000..7ae6fe8f --- /dev/null +++ b/src/components/TeamDetail.svelte @@ -0,0 +1,210 @@ + + +{#if data_loaded} + + + {original.name} + + {#if store.state.jwtinfo.userdetails.permissions.includes('TEAM:DELETE')} + {#if delete_triggered} + {$_('confirm-delete')} + { + delete_triggered = !delete_triggered; + }} + class="w-full justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-400 text-base font-medium text-white sm:w-auto sm:text-sm">{$_('cancel')} + {/if} + {#if !delete_triggered} + { + delete_triggered = true; + }} + type="button" + class="w-full justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-red-600 text-base font-medium text-white hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 sm:ml-3 sm:w-auto sm:text-sm">{$_('delete-team')} + {/if} + {/if} + {#if !delete_triggered} + {$_('save-changes')} + {/if} + + + + + + + + + + + + Home + + + + + + + Teams + + + + Team-Details #{params.teamid} + + + + + + + Name + + + + {$_('contact')} + + + + {#each orgs as o} + {o.name} + {/each} + + +{:else} + {#await promise} + team detail is being loaded... + {:catch error} + + {/await} +{/if} diff --git a/src/components/Teams.svelte b/src/components/Teams.svelte index 7bcfd325..75ad7411 100644 --- a/src/components/Teams.svelte +++ b/src/components/Teams.svelte @@ -1,10 +1,31 @@ {$_('teams')} + {#if store.state.jwtinfo.userdetails.permissions.includes('USER:CREATE')} + { + modal_open = true; + }} + type="button" + class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-600 text-base font-medium text-white hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:ml-3 sm:w-auto sm:text-sm"> + Create Team + + {/if} everything is more fun together 🏃♂️🏃♀️🏃♂️ + + +{#if store.state.jwtinfo.userdetails.permissions.includes('USER:CREATE')} + +{/if} diff --git a/src/components/TeamsEmptyState.svelte b/src/components/TeamsEmptyState.svelte new file mode 100644 index 00000000..05b4936e --- /dev/null +++ b/src/components/TeamsEmptyState.svelte @@ -0,0 +1,15 @@ + + + + + There are no teams added yet. + Add your first team + + + + diff --git a/src/components/TeamsOverview.svelte b/src/components/TeamsOverview.svelte new file mode 100644 index 00000000..d8400b8d --- /dev/null +++ b/src/components/TeamsOverview.svelte @@ -0,0 +1,160 @@ + + +{#if store.state.jwtinfo.userdetails.permissions.includes('TEAM:GET')} + {#await teams_promise} + + teams are being loaded... + {$_('this-might-take-a-moment')} + + {:then} + {#if current_teams.length === 0} + + {:else} + + + + + + + Name + + + {$_('organization')} + + + Contact + + + Action + + + + + {#each current_teams as t} + {#if Object.values(t) + .toString() + .toLowerCase() + .includes(searchvalue)} + + + + + + {t.name} + + + + + + + + + {#if t.parentGroup} + {t.parentGroup.name} + {:else}no organization specified{/if} + + + + + + + + + {#if t.contact} + {JSON.stringify(t.contact)} + {:else}no contact specified{/if} + + + + + {#if active_deletes[t.id] === true} + + { + active_deletes[t.id] = false; + }} + tabindex="0" + class="ml-4 text-indigo-600 hover:text-indigo-900 cursor-pointer">Cancel + Delete + { + RunnerTeamService.runnerTeamControllerRemove(t.id, true) + .then((resp) => { + current_teams = current_teams.filter((obj) => obj.id !== t.id); + }) + .catch((err) => { + // error deleting user + }); + }} + tabindex="0" + class="ml-4 text-red-600 hover:text-red-900 cursor-pointer">Confirm + Delete + + {:else} + + Edit + {#if store.state.jwtinfo.userdetails.permissions.includes('TEAM:DELETE')} + { + active_deletes[t.id] = true; + }} + tabindex="0" + class="ml-4 text-red-600 hover:text-red-900 cursor-pointer">Delete + {/if} + + {/if} + + {/if} + {/each} + + + + {/if} + {:catch error} + + + {$_('general_promise_error')} + {error} + + + {/await} +{/if} diff --git a/src/components/UsersOverview.svelte b/src/components/UsersOverview.svelte index c6844137..28603c25 100644 --- a/src/components/UsersOverview.svelte +++ b/src/components/UsersOverview.svelte @@ -10,7 +10,6 @@ export let current_users=[]; $: advanced_search = false; usersstore.subscribe((val) => { - userscache = val; current_users=val; }); users_promise.then((data) => { diff --git a/src/locales/en.json b/src/locales/en.json index 6923ebd0..53fe708e 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -40,6 +40,7 @@ "an_error_happened_while_fetching_the_data": "An error happened while fetching the data" }, "delete-organization": "Delete Organization", + "delete-team": "Delete Team", "delete-user": "Delete User", "dependency_name": "Name", "dont-have-your-email-connected": "Don't have your email connected?", @@ -94,6 +95,7 @@ "minimum-lap-time-in-s": "minimum lap time in s", "no-license-text-could-be-found": "No license text could be found 😢", "no-tracks-added-yet": "there are no tracks added yet.", + "organization": "Organization", "organizations": "Organizations", "orgs": "Orgs", "oss_credit_description": "We use a lot of open source software on these projects, and would like to thank the following projects and contributors who help make open source great!", @@ -111,6 +113,7 @@ "settings": "Settings", "signout": "Sign out", "stats-are-being-loaded": "stats are being loaded...", + "team-name": "Team name", "teams": "Teams", "this-might-take-a-moment": "This might take a moment 👀", "total-distance": "total distance",
+ Please provide the required information to add a new team. +
+ Do you want to delete the organization + {delete_org.name}?All associated teams and runners will + be deleted too! +
everything is more fun together 🏃♂️🏃♀️🏃♂️
+ There are no teams added yet. + Add your first team +
teams are being loaded...
{$_('this-might-take-a-moment')}