1
0
Fork 0
mirror of synced 2024-08-17 19:11:52 +12:00

fetching of users via new api in app assignment

This commit is contained in:
Peter Clement 2022-07-29 13:13:41 +01:00
parent 8a77aca540
commit 23dc9f6128
2 changed files with 29 additions and 12 deletions

View file

@ -29,7 +29,6 @@
let pageInfo = createPaginationStore() let pageInfo = createPaginationStore()
let fixedAppId let fixedAppId
$: page = $pageInfo.page $: page = $pageInfo.page
$: fetchUsers(page, search)
$: hasGroupsLicense = $auth.user?.license.features.includes( $: hasGroupsLicense = $auth.user?.license.features.includes(
Constants.Features.USER_GROUPS Constants.Features.USER_GROUPS
@ -37,12 +36,6 @@
$: fixedAppId = apps.getProdAppID(app.devId) $: fixedAppId = apps.getProdAppID(app.devId)
$: appUsers =
$users.data?.filter(x => {
return Object.keys(x.roles).find(y => {
return y === fixedAppId
})
}) || []
$: appGroups = $groups.filter(x => { $: appGroups = $groups.filter(x => {
return x.apps.includes(app.appId) return x.apps.includes(app.appId)
}) })
@ -130,6 +123,12 @@
pageInfo.loading() pageInfo.loading()
await users.search({ page, appId: fixedAppId }) await users.search({ page, appId: fixedAppId })
pageInfo.fetched($users.hasNextPage, $users.nextPage) pageInfo.fetched($users.hasNextPage, $users.nextPage)
appUsers =
$users.data?.filter(x => {
return Object.keys(x.roles).find(y => {
return y === fixedAppId
})
}) || []
} catch (error) { } catch (error) {
notifications.error("Error getting user list") notifications.error("Error getting user list")
} }
@ -137,6 +136,8 @@
onMount(async () => { onMount(async () => {
try { try {
await fetchUsers(page, search)
await groups.actions.init() await groups.actions.init()
await apps.load() await apps.load()
await roles.fetch() await roles.fetch()
@ -212,8 +213,14 @@
page={$pageInfo.pageNumber} page={$pageInfo.pageNumber}
hasPrevPage={$pageInfo.loading ? false : $pageInfo.hasPrevPage} hasPrevPage={$pageInfo.loading ? false : $pageInfo.hasPrevPage}
hasNextPage={$pageInfo.loading ? false : $pageInfo.hasNextPage} hasNextPage={$pageInfo.loading ? false : $pageInfo.hasNextPage}
goToPrevPage={pageInfo.prevPage} goToPrevPage={async () => {
goToNextPage={pageInfo.nextPage} await pageInfo.prevPage()
fetchUsers(page, search)
}}
goToNextPage={async () => {
await pageInfo.nextPage()
fetchUsers(page, search)
}}
/> />
</div> </div>
{/if} {/if}
@ -264,4 +271,11 @@
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
} }
.pagination {
display: flex;
flex-direction: row;
justify-content: flex-end;
margin-top: var(--spacing-xl);
}
</style> </style>

View file

@ -11,7 +11,7 @@
export let app export let app
export let deployments export let deployments
export let navigateTab export let navigateTab
let userCount
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
const unpublishApp = () => { const unpublishApp = () => {
@ -40,7 +40,9 @@
} }
onMount(async () => { onMount(async () => {
await users.search({ page: undefined, appId: "app_" + app.appId }) let resp = await users.getUserCountByApp({ appId: "app_" + app.appId })
userCount = resp.userCount
await users.search({ appId: "app_" + app.appId, limit: 4 })
}) })
</script> </script>
@ -155,7 +157,8 @@
</div> </div>
<div class="users-text"> <div class="users-text">
{$users?.data.length} users have access to this app {userCount}
{userCount > 1 ? `users have` : `user has`} access to this app
</div> </div>
</Layout> </Layout>
{:else} {:else}