access tab refreshing correctly
This commit is contained in:
parent
8489ae36a4
commit
93f11584df
|
@ -127,7 +127,10 @@
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
await organisation.init()
|
await organisation.init()
|
||||||
|
await roles.fetch()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
|
||||||
notifications.error("Error getting org config")
|
notifications.error("Error getting org config")
|
||||||
}
|
}
|
||||||
loaded = true
|
loaded = true
|
||||||
|
|
|
@ -219,6 +219,7 @@
|
||||||
try {
|
try {
|
||||||
await organisation.init()
|
await organisation.init()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.log("hello1")
|
||||||
notifications.error("Error getting org config")
|
notifications.error("Error getting org config")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,10 +26,11 @@
|
||||||
let selectedUsers = []
|
let selectedUsers = []
|
||||||
let prevSearch = undefined,
|
let prevSearch = undefined,
|
||||||
search = undefined
|
search = undefined
|
||||||
|
let pageInfo = createPaginationStore()
|
||||||
|
|
||||||
$: page = $pageInfo.page
|
$: page = $pageInfo.page
|
||||||
$: fetchUsers(page, search)
|
$: fetchUsers(page, search)
|
||||||
$: group = $groups.find(x => x._id === groupId)
|
$: group = $groups.find(x => x._id === groupId)
|
||||||
let pageInfo = createPaginationStore()
|
|
||||||
|
|
||||||
async function addAll() {
|
async function addAll() {
|
||||||
group.users = selectedUsers
|
group.users = selectedUsers
|
||||||
|
|
|
@ -76,34 +76,29 @@
|
||||||
$: fetchUsers(page, search)
|
$: fetchUsers(page, search)
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
if ($users.data) {
|
enrichedUsers = $users.data?.map(user => {
|
||||||
enrichedUsers = $users.data.map(user => {
|
let userGroups = []
|
||||||
let userGroups = []
|
let userApps = []
|
||||||
let userApps = []
|
$groups.forEach(group => {
|
||||||
$groups.forEach(group => {
|
console.log(group)
|
||||||
console.log(group)
|
if (group.users) {
|
||||||
if (group.users) {
|
group.users?.forEach(y => {
|
||||||
group.users?.forEach(y => {
|
if (y._id === user._id) {
|
||||||
if (y._id === user._id) {
|
console.log("hello")
|
||||||
console.log("hello")
|
userGroups.push(group)
|
||||||
userGroups.push(group)
|
userApps = group.apps
|
||||||
userApps = group.apps
|
}
|
||||||
}
|
})
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return {
|
|
||||||
...user,
|
|
||||||
name: user.firstName ? user.firstName + " " + user.lastName : "",
|
|
||||||
userGroups,
|
|
||||||
apps: [...new Set(Object.keys(user.roles))],
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
return {
|
||||||
enrichedUsers = []
|
...user,
|
||||||
}
|
name: user.firstName ? user.firstName + " " + user.lastName : "",
|
||||||
|
userGroups,
|
||||||
|
apps: [...new Set(Object.keys(user.roles))],
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
$: console.log(enrichedUsers)
|
|
||||||
function showOnboardingTypeModal() {
|
function showOnboardingTypeModal() {
|
||||||
onboardingTypeModal.show()
|
onboardingTypeModal.show()
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,18 +14,27 @@
|
||||||
import RoleSelect from "components/common/RoleSelect.svelte"
|
import RoleSelect from "components/common/RoleSelect.svelte"
|
||||||
import { users, groups, apps } from "stores/portal"
|
import { users, groups, apps } from "stores/portal"
|
||||||
import AssignmentModal from "./AssignmentModal.svelte"
|
import AssignmentModal from "./AssignmentModal.svelte"
|
||||||
|
import { createPaginationStore } from "helpers/pagination"
|
||||||
|
|
||||||
export let app
|
export let app
|
||||||
|
|
||||||
let assignmentModal
|
let assignmentModal
|
||||||
let appGroups = []
|
let appGroups = []
|
||||||
let appUsers = []
|
let appUsers = []
|
||||||
|
let pageInfo = createPaginationStore()
|
||||||
|
let prevSearch = undefined,
|
||||||
|
search = undefined
|
||||||
|
|
||||||
|
$: page = $pageInfo.page
|
||||||
|
$: fetchUsers(page, search)
|
||||||
|
|
||||||
|
$: appUsers =
|
||||||
|
$users.data?.filter(x => {
|
||||||
|
return Object.keys(x.roles).find(y => {
|
||||||
|
return extractAppId(y) === extractAppId(app.appId)
|
||||||
|
})
|
||||||
|
}) || []
|
||||||
|
|
||||||
$: appUsers = $users.filter(x => {
|
|
||||||
return Object.keys(x.roles).find(y => {
|
|
||||||
return extractAppId(y) === extractAppId(app.appId)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
$: appGroups = $groups.filter(x => {
|
$: appGroups = $groups.filter(x => {
|
||||||
return x.apps.find(y => {
|
return x.apps.find(y => {
|
||||||
return y.appId === app.appId
|
return y.appId === app.appId
|
||||||
|
@ -48,7 +57,7 @@
|
||||||
|
|
||||||
groups.actions.save(matchedGroup)
|
groups.actions.save(matchedGroup)
|
||||||
} else if (data.id.startsWith(us_prefix)) {
|
} else if (data.id.startsWith(us_prefix)) {
|
||||||
let matchedUser = $users.find(user => {
|
let matchedUser = $users.data.find(user => {
|
||||||
return user._id === data.id
|
return user._id === data.id
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -60,10 +69,30 @@
|
||||||
await users.save(newUser)
|
await users.save(newUser)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
await pageInfo.reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function fetchUsers(page, search) {
|
||||||
|
if ($pageInfo.loading) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// need to remove the page if they've started searching
|
||||||
|
if (search && !prevSearch) {
|
||||||
|
pageInfo.reset()
|
||||||
|
page = undefined
|
||||||
|
}
|
||||||
|
prevSearch = search
|
||||||
|
try {
|
||||||
|
pageInfo.loading()
|
||||||
|
await users.search({ page, search })
|
||||||
|
pageInfo.fetched($users.hasNextPage, $users.nextPage)
|
||||||
|
} catch (error) {
|
||||||
|
notifications.error("Error getting user list")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
try {
|
try {
|
||||||
await users.init()
|
|
||||||
await groups.actions.init()
|
await groups.actions.init()
|
||||||
await apps.load()
|
await apps.load()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -115,7 +144,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Modal bind:this={assignmentModal}>
|
<Modal bind:this={assignmentModal}>
|
||||||
<AssignmentModal {addData} />
|
<AssignmentModal userData={$users.data} {addData} />
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
import { RoleUtils } from "@budibase/frontend-core"
|
import { RoleUtils } from "@budibase/frontend-core"
|
||||||
|
|
||||||
export let addData
|
export let addData
|
||||||
|
export let userData = []
|
||||||
$: optionSections = {
|
$: optionSections = {
|
||||||
groups: {
|
groups: {
|
||||||
data: $groups,
|
data: $groups,
|
||||||
|
@ -14,7 +15,7 @@
|
||||||
getColour: group => group.color,
|
getColour: group => group.color,
|
||||||
},
|
},
|
||||||
users: {
|
users: {
|
||||||
data: $users,
|
data: userData,
|
||||||
getLabel: user => user.email,
|
getLabel: user => user.email,
|
||||||
getValue: user => user._id,
|
getValue: user => user._id,
|
||||||
getIcon: user => user.icon,
|
getIcon: user => user.icon,
|
||||||
|
@ -27,8 +28,6 @@
|
||||||
function addNewInput() {
|
function addNewInput() {
|
||||||
appData = [...appData, { id: "", role: "" }]
|
appData = [...appData, { id: "", role: "" }]
|
||||||
}
|
}
|
||||||
|
|
||||||
$: console.log(appData)
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ModalContent
|
<ModalContent
|
||||||
|
|
|
@ -7,6 +7,7 @@ export function createRolesStore() {
|
||||||
const actions = {
|
const actions = {
|
||||||
fetch: async () => {
|
fetch: async () => {
|
||||||
const roles = await API.getRoles()
|
const roles = await API.getRoles()
|
||||||
|
console.log(roles)
|
||||||
set(roles)
|
set(roles)
|
||||||
},
|
},
|
||||||
delete: async role => {
|
delete: async role => {
|
||||||
|
|
Loading…
Reference in New Issue