diff --git a/admin/server/controllers/systems.js b/admin/server/controllers/systems.js
index 4973fa5..190f1ca 100644
--- a/admin/server/controllers/systems.js
+++ b/admin/server/controllers/systems.js
@@ -3,6 +3,7 @@ const System = require("../models/system");
const SystemStat = require("../models/system_stat");
const Talkgroup = require("../models/talkgroup");
const Group = require("../models/group");
+const User = require("../models/user");
const crypto = require("crypto");
exports.isLoggedIn = function (req, res, next) {
@@ -12,6 +13,27 @@ exports.isLoggedIn = function (req, res, next) {
// -------------------------------------------
+exports.listUserSystems = async function (req,res,next) {
+ if (!req.user.admin) {
+ res.status(401);
+ res.json({ success: false, message: "Not Authorized" });
+ return;
+ }
+ const users = await User.find({}, "_id email firstName lastName lastLogin");
+ let list = [];
+ console.log(users);
+ for (let index = 0; index < users.length; index++) {
+ let user = users[index].toObject();
+ const userId = new mongoose.Types.ObjectId(user._id);
+ const systems = await System.find({ userId: userId }, "name shortName description systemType city state county country lastActive");
+
+ user["systems"] = systems;
+ list.push(user);
+ }
+ res.json(list);
+ return;
+}
+
exports.listAllSystems = async function (req, res, next) {
if (!req.user.admin) {
res.status(401);
diff --git a/admin/server/index.js b/admin/server/index.js
index 5473a93..d6ddb96 100644
--- a/admin/server/index.js
+++ b/admin/server/index.js
@@ -153,6 +153,7 @@ app.get("/groups/:shortName/:groupId?", isLoggedIn, groups.getGroups);
app.delete("/groups/:shortName/:groupId", isLoggedIn, groups.deleteGroup);
app.get("/systems", isLoggedIn, systems.listSystems)
app.get("/admin/systems", isAdmin, systems.listAllSystems)
+app.get("/admin/users", isAdmin, systems.listUserSystems)
app.delete("/systems/:shortName", isLoggedIn, systems.deleteSystem)
app.post("/systems/:shortName", [isLoggedIn, systems.ownSystem, systems.validateSystem, systems.updateSystem])
app.post("/systems", [isLoggedIn, systems.uniqueShortName, systems.validateSystem, systems.createSystem])
diff --git a/admin/src/AllSystems/AllSystems.js b/admin/src/AllSystems/AllSystems.js
index ec5df2a..fe593a2 100644
--- a/admin/src/AllSystems/AllSystems.js
+++ b/admin/src/AllSystems/AllSystems.js
@@ -1,19 +1,17 @@
import {
Container,
- Divider,
Header,
- Table
+ Table,
+ Icon
} from "semantic-ui-react";
import { useGetAllSystemsQuery, } from '../features/api/apiSlice'
+import SystemRow from "./SystemRow";
// ----------------------------------------------------
-const ListSystems = () => {
- const { data, isSuccess } = useGetAllSystemsQuery();
- let systems = false;
- if (isSuccess) {
- systems = data.systems;
- }
+const AllSystems = () => {
+ const { data: users, isSuccess } = useGetAllSystemsQuery();
+
//https://stackoverflow.com/questions/36559661/how-can-i-dispatch-from-child-components-in-react-redux
//https://stackoverflow.com/questions/42597602/react-onclick-pass-event-with-parameter
@@ -24,29 +22,36 @@ const ListSystems = () => {