mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-12 08:47:40 -05:00
cleaned up admin
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import React, { useEffect, useState, } from "react";
|
||||
import { useGetSystemsQuery, useGetTalkgroupsQuery, useGetGroupsQuery, useUpdateGroupMutation, useCreateGroupMutation, useDeleteGroupMutation, useSaveGroupOrderMutation} from '../features/api/apiSlice'
|
||||
import { useGetTalkgroupsQuery, useGetGroupsQuery, useUpdateGroupMutation, useCreateGroupMutation} from '../features/api/apiSlice'
|
||||
|
||||
import {
|
||||
Grid,
|
||||
@@ -21,15 +21,15 @@ const GroupModal = (props) => {
|
||||
name: "",
|
||||
items: []
|
||||
}
|
||||
const [editGroup, setEditGroup] = useState(false);
|
||||
|
||||
const [groupName, setGroupName] = useState("");
|
||||
const [group, setGroup] = useState(emptyGroup)
|
||||
const [talkgroups, setTalkgroups] = useState(props.talkgroups ? props.talkgroups : [])
|
||||
|
||||
const { data: talkgroupsData, isSuccess: isTalkgroupsSuccess } = useGetTalkgroupsQuery(props.shortName);
|
||||
const { data: groupsData, isSuccess: isGroupsSuccess } = useGetGroupsQuery(props.shortName);
|
||||
const [ updateGroup,{ isLoading: isUpdating } ] = useUpdateGroupMutation();
|
||||
const [ createGroup,{ isLoading: isCreating } ] = useCreateGroupMutation();
|
||||
const { data: talkgroupsData} = useGetTalkgroupsQuery(props.shortName);
|
||||
const { data: groupsData} = useGetGroupsQuery(props.shortName);
|
||||
const [ updateGroup] = useUpdateGroupMutation();
|
||||
const [ createGroup] = useCreateGroupMutation();
|
||||
|
||||
useEffect(() => {
|
||||
if (talkgroupsData && groupsData && props.editGroupId) {
|
||||
@@ -66,7 +66,7 @@ const GroupModal = (props) => {
|
||||
if (!props.editGroupId && talkgroupsData) {
|
||||
setTalkgroups([...talkgroupsData]);
|
||||
}
|
||||
},[talkgroupsData]);
|
||||
},[talkgroupsData, props.editGroupId]);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
@@ -75,15 +75,9 @@ const GroupModal = (props) => {
|
||||
setGroup(emptyGroup);
|
||||
setTalkgroups( [...props.talkgroups]);
|
||||
}
|
||||
},[props.editGroupId]);
|
||||
},[props.editGroupId, props.talkgroups]);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const removeTalkgroup = (event, index) => {
|
||||
const removeTalkgroup = (index) => {
|
||||
const item = {
|
||||
num: group.items[index].num,
|
||||
description: group.items[index].description
|
||||
@@ -106,7 +100,7 @@ const GroupModal = (props) => {
|
||||
}
|
||||
|
||||
|
||||
const addTalkgroup = (event, index) => {
|
||||
const addTalkgroup = (index) => {
|
||||
const item = {
|
||||
num: talkgroupsData[index].num,
|
||||
description: talkgroupsData[index].description
|
||||
|
||||
@@ -1,15 +1,4 @@
|
||||
import React, { Component } from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import { Link } from 'react-router-dom'
|
||||
import {
|
||||
Container,
|
||||
Header,
|
||||
Form,
|
||||
Grid,
|
||||
Segment,
|
||||
Input,
|
||||
Button,
|
||||
Message,
|
||||
Icon,
|
||||
Table
|
||||
} from "semantic-ui-react";
|
||||
@@ -30,7 +19,7 @@ const ListGroups = (props) => {
|
||||
if (groups) {
|
||||
// if a group gets deleted, it will still be listed in the Order array for a little.
|
||||
for (const id of props.order) {
|
||||
const group = props.groups.find( group => group._id == id );
|
||||
const group = props.groups.find( group => group._id === id );
|
||||
if (group) {
|
||||
groupsDisplay.push(group)
|
||||
}
|
||||
@@ -58,13 +47,13 @@ const ListGroups = (props) => {
|
||||
onClick={e => props.editGroup(group._id)}
|
||||
/><Icon
|
||||
name="up arrow"
|
||||
link={i==0?false:true}
|
||||
disabled={i==0?true:false}
|
||||
link={i===0?false:true}
|
||||
disabled={i===0?true:false}
|
||||
onClick={e => props.reorderGroup(i, i-1)}
|
||||
/><Icon
|
||||
name="down arrow"
|
||||
link={i==groupsDisplay.length-1?false:true}
|
||||
disabled={i==groupsDisplay.length-1?true:false}
|
||||
link={i===groupsDisplay.length-1?false:true}
|
||||
disabled={i===groupsDisplay.length-1?true:false}
|
||||
onClick={e => props.reorderGroup(i, i+1)}
|
||||
/><Icon
|
||||
name="remove"
|
||||
|
||||
Reference in New Issue
Block a user