Skip to content

Commit

Permalink
Add search on users and organizations (#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaudDauce authored Dec 18, 2024
1 parent ec082df commit ea2874e
Show file tree
Hide file tree
Showing 8 changed files with 250 additions and 147 deletions.
18 changes: 13 additions & 5 deletions components/Dataservices/AdminDataservicesPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,25 @@
</LoadingBlock>

<div
v-if="pageData && !pageData.total"
v-if="status != 'pending' && pageData && !pageData.total"
class="flex flex-col items-center"
>
<nuxt-img
src="/illustrations/dataservice.svg"
class="h-20"
/>
<p class="fr-text--bold fr-my-3v">
{{ t(`You haven't published a dataservice yet`) }}
</p>
<AdminPublishButton type="dataservice" />
<template v-if="q">
<p class="fr-text--bold fr-my-3v" >
{{ t(`No results for "{q}"`, { q }) }}
</p>
<BrandedButton color="primary" @click="q = qDebounced = ''">{{ $t('Reset filters') }}</BrandedButton>
</template>
<template v-else>
<p class="fr-text--bold fr-my-3v">
{{ t(`You haven't published a dataservice yet`) }}
</p>
<AdminPublishButton type="dataservice" />
</template>
</div>
</div>
</template>
Expand Down
3 changes: 3 additions & 0 deletions lang/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -760,5 +760,8 @@
"Create an harvester on": "Create an harvester on",
"Profile picture": "Profile picture",
"Pending transfer": "Pending transfer",
"No results for \"{q}\"": "No results for \"{q}\"",
"No users": "No users",
"No organizations": "No organizations",
"": ""
}
3 changes: 3 additions & 0 deletions lang/es-ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -753,5 +753,8 @@
"Create an harvester on": "Create an harvester on",
"Profile picture": "Profile picture",
"Pending transfer": "Pending transfer",
"No results for \"{q}\"": "No results for \"{q}\"",
"No users": "No users",
"No organizations": "No organizations",
"": ""
}
3 changes: 3 additions & 0 deletions lang/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -781,5 +781,8 @@
"You haven't published a harvester yet": "Vous n'avez pas encore publié de moissonneur",
"Create an harvester on": "Créer un moissoneur sur",
"Profile picture": "Image de profil",
"No results for \"{q}\"": "Pas de résultats pour « {q} »",
"No users": "Pas d'utilisateurs",
"No organizations": "Pas d'organizations",
"": ""
}
189 changes: 106 additions & 83 deletions pages/beta/admin/site/organizations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,97 +21,118 @@
<h1 class="fr-h3 fr-mb-5v">
{{ t("Organizations") }}
</h1>
<div class="fr-grid-row fr-grid-row--gutters fr-grid-row--middle">
<div v-if="pageData && pageData.total" class="fr-grid-row fr-grid-row--gutters fr-grid-row--middle">
<div class="fr-col">
<h2
v-if="status === 'success' && pageData.total"
class="subtitle subtitle--uppercase fr-m-0"
>
<h2 class="subtitle subtitle--uppercase fr-m-0">
{{ t('{n} organizations', pageData.total) }}
</h2>
</div>
<div class="fr-col-auto fr-grid-row fr-grid-row--middle">
<!-- Buttons -->
<AdminInput
v-model="q"
:icon="RiSearchLine"
:placeholder="$t('Search')"
/>
</div>
</div>
<AdminTable
v-if="status === 'pending' || (status === 'success' && pageData.total > 0)"
:loading="status === 'pending'"

<LoadingBlock :status>
<div v-if="pageData && pageData.total > 0">
<AdminTable>
<thead>
<tr>
<AdminTableTh scope="col">
{{ t("Name") }}
</AdminTableTh>
<AdminTableTh scope="col">
{{ t("Created at") }}
</AdminTableTh>
<AdminTableTh scope="col">
{{ t("Datasets") }}
</AdminTableTh>
<AdminTableTh scope="col">
{{ t("Dataservices") }}
</AdminTableTh>
<AdminTableTh scope="col">
{{ t("Reuses") }}
</AdminTableTh>
<AdminTableTh scope="col">
{{ t("Members") }}
</AdminTableTh>
</tr>
</thead>
<tbody>
<tr
v-for="organization in pageData.data"
:key="organization.id"
>
<td>
<div class="flex items-center space-x-2">
<Placeholder
type="organization"
:src="organization.logo_thumbnail"
:size="20"
/>
<AdminContentWithTooltip>
<TextClamp
:text="organization.name"
:auto-resize="true"
:max-lines="2"
/>
</AdminContentWithTooltip>
</div>
</td>
<td>{{ formatDate(organization.created_at) }}</td>
<td>
<NuxtLinkLocale :to="`/beta/admin/organizations/${organization.id}/datasets`">
{{ organization.metrics.datasets || 0 }}
</NuxtLinkLocale>
</td>
<td>
<NuxtLinkLocale :to="`/beta/admin/organizations/${organization.id}/dataservices`">
{{ organization.metrics.dataservices || 0 }}
</NuxtLinkLocale>
</td>
<td>
<NuxtLinkLocale :to="`/beta/admin/organizations/${organization.id}/reuses`">
{{ organization.metrics.reuses || 0 }}
</NuxtLinkLocale>
</td>
<td>
<NuxtLinkLocale :to="`/beta/admin/organizations/${organization.id}/members`">
{{ organization.metrics.members || 0 }}
</NuxtLinkLocale>
</td>
</tr>
</tbody>
</AdminTable>
<Pagination
:page="page"
:page-size="pageSize"
:total-results="pageData.total"
@change="(changedPage: number) => page = changedPage"
/>
</div>
</LoadingBlock>

<div
v-if="status != 'pending' && pageData && !pageData.total"
class="flex flex-col items-center"
>
<thead>
<tr>
<AdminTableTh scope="col">
{{ t("Name") }}
</AdminTableTh>
<AdminTableTh scope="col">
{{ t("Created at") }}
</AdminTableTh>
<AdminTableTh scope="col">
{{ t("Datasets") }}
</AdminTableTh>
<AdminTableTh scope="col">
{{ t("Dataservices") }}
</AdminTableTh>
<AdminTableTh scope="col">
{{ t("Reuses") }}
</AdminTableTh>
<AdminTableTh scope="col">
{{ t("Members") }}
</AdminTableTh>
</tr>
</thead>
<tbody v-if="pageData">
<tr
v-for="organization in pageData.data"
:key="organization.id"
>
<td>
<div class="flex items-center space-x-2">
<Placeholder
type="organization"
:src="organization.logo_thumbnail"
:size="20"
/>
<AdminContentWithTooltip>
<TextClamp
:text="organization.name"
:auto-resize="true"
:max-lines="2"
/>
</AdminContentWithTooltip>
</div>
</td>
<td>{{ formatDate(organization.created_at) }}</td>
<td>
<NuxtLinkLocale :to="`/beta/admin/organizations/${organization.id}/datasets`">
{{ organization.metrics.datasets || 0 }}
</NuxtLinkLocale>
</td>
<td>
<NuxtLinkLocale :to="`/beta/admin/organizations/${organization.id}/dataservices`">
{{ organization.metrics.dataservices || 0 }}
</NuxtLinkLocale>
</td>
<td>
<NuxtLinkLocale :to="`/beta/admin/organizations/${organization.id}/reuses`">
{{ organization.metrics.reuses || 0 }}
</NuxtLinkLocale>
</td>
<td>
<NuxtLinkLocale :to="`/beta/admin/organizations/${organization.id}/members`">
{{ organization.metrics.members || 0 }}
</NuxtLinkLocale>
</td>
</tr>
</tbody>
</AdminTable>
<Pagination
v-if="status === 'success' && pageData.total > pageSize"
:page="page"
:page-size="pageSize"
:total-results="pageData.total"
@change="(changedPage: number) => page = changedPage"
/>
<nuxt-img
src="/illustrations/organization.svg"
class="h-20"
/>
<template v-if="q">
<p class="fr-text--bold fr-my-3v" >
{{ t(`No results for "{q}"`, { q }) }}
</p>
<BrandedButton color="primary" @click="q = qDebounced = ''">{{ $t('Reset filters') }}</BrandedButton>
</template>
<p class="fr-text--bold fr-my-3v" v-else>
{{ t(`No organizations`) }}
</p>
</div>
</div>
</template>

Expand All @@ -125,6 +146,8 @@ import Breadcrumb from '~/components/Breadcrumb/Breadcrumb.vue'
import AdminTable from '~/components/AdminTable/Table/AdminTable.vue'
import AdminTableTh from '~/components/AdminTable/Table/AdminTableTh.vue'
import Placeholder from '~/components/Placeholder/Placeholder.vue'
import AdminInput from '~/components/AdminInput.vue'
import { RiSearchLine } from '@remixicon/vue'
const { t } = useI18n()
const config = useRuntimeConfig()
Expand Down
Loading

0 comments on commit ea2874e

Please sign in to comment.