fixed a bunch of group/team permission stuff on the devices page
This commit is contained in:
parent
988ab1c683
commit
afdbe3426e
7 changed files with 59 additions and 33 deletions
|
|
@ -141,7 +141,6 @@ export default function Devices() {
|
|||
};
|
||||
|
||||
const removeGroupCallback = useCallback(() => {
|
||||
console.log("Remove callback");
|
||||
let newGroups = [...groups];
|
||||
newGroups.splice(parseInt(tab), 1);
|
||||
setGroups(newGroups);
|
||||
|
|
@ -149,6 +148,16 @@ export default function Devices() {
|
|||
setGroupSettingsIsOpen(false);
|
||||
}, [groups, tab]); // Include dependencies
|
||||
|
||||
const addGroupCallback = useCallback((groupSettings: pond.GroupSettings) => {
|
||||
let newGroups = [...groups];
|
||||
let group = pond.Group.create({
|
||||
settings: groupSettings
|
||||
})
|
||||
newGroups.push(Group.create(group))
|
||||
setGroups(newGroups);
|
||||
// setTab(groups.length.toString())
|
||||
}, [groups, tab]); // Include dependencies
|
||||
|
||||
const openGroupSettings = (
|
||||
group: Group | undefined,
|
||||
mode: "add" | "update" | "remove" | undefined
|
||||
|
|
@ -162,7 +171,6 @@ export default function Devices() {
|
|||
setGroupSettingsIsOpen(false);
|
||||
setGroupSettingsMode(undefined);
|
||||
setSelectedGroup(undefined);
|
||||
console.log("close callback")
|
||||
};
|
||||
|
||||
const getKeys = () => {
|
||||
|
|
@ -197,7 +205,9 @@ export default function Devices() {
|
|||
orderGroup,
|
||||
orderGroupBy,
|
||||
searchGroup,
|
||||
undefined
|
||||
undefined,
|
||||
getKeys(),
|
||||
getTypes(),
|
||||
).then(resp => {
|
||||
let newGroups: Group[] = []
|
||||
resp.data.groups?.forEach((group: pond.Group) => {
|
||||
|
|
@ -210,7 +220,6 @@ export default function Devices() {
|
|||
}
|
||||
|
||||
const loadDevices = () => {
|
||||
console.log("load callback")
|
||||
setDevicesLoading(true)
|
||||
deviceAPI.list(
|
||||
limit,
|
||||
|
|
@ -499,6 +508,18 @@ export default function Devices() {
|
|||
refreshCallback={loadDevices}
|
||||
closeDialogCallback={closeProvisionDialog}
|
||||
/>
|
||||
{/* This GroupSettings is used for adding */}
|
||||
<GroupSettings
|
||||
initialGroup={selectedGroup}
|
||||
mode={groupSettingsMode}
|
||||
isDialogOpen={groupSettingsIsOpen}
|
||||
closeDialogCallback={closeGroupSettings}
|
||||
refreshCallback={() => {}}
|
||||
canEdit={true}
|
||||
groupDevices={devices}
|
||||
removeGroupCallback={removeGroupCallback}
|
||||
addGroupCallback={addGroupCallback}
|
||||
/>
|
||||
</PageContainer>
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue