added admin area manage for checking which categories are available

main
alex 2023-09-04 23:14:16 +02:00
parent 88e1734232
commit 93aba47966
8 changed files with 99 additions and 17 deletions

View File

@ -36,7 +36,8 @@
"menuCategory": "Adminbereich",
"roles": "Rollen",
"logs": "Logs",
"noScannerSelected": "Kein Scanner ausgewählt"
"noScannerSelected": "Kein Scanner ausgewählt",
"manage": "Verwalten"
},
"usersCount": {
"single": "Benutzer online",
@ -259,7 +260,14 @@
"save": { "tooltip": { "title": "Speichern" } },
"close": { "tooltip": { "title": "Schließen" } },
"edit": { "tooltip": { "title": "Bearbeiten" } },
"masterRoleRightsMessage": "Rechte können nicht bearbeitet werden, da diese Rolle der Master ist und alle Rechte besitzt."
"masterRoleRightsMessage": "Rechte können nicht bearbeitet werden, da diese Rolle der Master ist und alle Rechte besitzt.",
"manage": {
"groupTasksCard": {
"title": "Gruppenaufgaben Kategorien",
"description": "Die Suche nach Kategorieänderungen zwingt den Server, nach neuen Kategorien zu suchen oder alte aus dem Cache zu löschen.",
"buttonText": "Prüfen, welche Kategorien verfügbar sind"
}
}
},
"userProfile": {
"header": {

View File

@ -36,7 +36,8 @@
"menuCategory": "Admin Area",
"roles": "Roles",
"logs": "Logs",
"noScannerSelected": "No scanner selected"
"noScannerSelected": "No scanner selected",
"manage": "Manage"
},
"usersCount": {
"single": "User online",
@ -259,7 +260,14 @@
"save": { "tooltip": { "title": "Save" } },
"close": { "tooltip": { "title": "Close" } },
"edit": { "tooltip": { "title": "Edit" } },
"masterRoleRightsMessage": "Rights cannot be edited as this role is the master and has all rights."
"masterRoleRightsMessage": "Rights cannot be edited as this role is the master and has all rights.",
"manage": {
"groupTasksCard": {
"title": "Group Task Categories",
"description": "Searching for category changes forces the server to search for new categories or delete old ones from the cache.",
"buttonText": "Check which categories are available"
}
}
},
"userProfile": {
"header": {

View File

@ -11,6 +11,7 @@ const UserProfile = lazy(() => import("../../Pages/UserProfile"));
const Scanners = lazy(() => import("../../Pages/Scanners"));
const AdminAreaRoles = lazy(() => import("../../Pages/AdminArea/Roles"));
const AdminAreaLogs = lazy(() => import("../../Pages/AdminArea/Logs"));
const AdminAreaManage = lazy(() => import("../../Pages/AdminArea/Manage"));
const AllUsers = lazy(() => import("../../Pages/AllUsers"));
const GroupTasksHistory = lazy(() => import("../../Pages/GroupTasks/History"));
const PageNotFound = lazy(() => import("../../Pages/PageNotFound"));
@ -216,6 +217,20 @@ export default function AppRoutes() {
/>
)}
{hasPermission(
appContext.userPermissions,
Constants.PERMISSIONS.ADMIN_AREA.MANAGE
) && (
<Route
path={Constants.ROUTE_PATHS.ADMIN_AREA_MANAGE}
element={
<SuspenseFallback>
<AdminAreaManage />
</SuspenseFallback>
}
/>
)}
<Route
path="*"
element={

View File

@ -1,6 +1,7 @@
import {
AppstoreOutlined,
BookOutlined,
ControlOutlined,
FileTextOutlined,
HistoryOutlined,
LogoutOutlined,
@ -98,14 +99,6 @@ export default function SideMenu({
key: `/group-tasks/${categoryGroup}`,
});
});
/*
for (let i = 0; i < sideBarContext.availableCategoryGroups.length; i++) {
groupTasks.children.push({
label: sideBarContext.availableCategoryGroups[i],
icon: <SnippetsOutlined />,
key: `/group-tasks/${sideBarContext.availableCategoryGroups[i]}`,
});
} */
groupTasksGroup.children.push(groupTasks);
@ -132,7 +125,8 @@ export default function SideMenu({
Constants.PERMISSIONS.ADMIN_AREA.ROLES.UPDATE_ROLE,
Constants.PERMISSIONS.ADMIN_AREA.ROLES.DELETE_ROLE,
Constants.PERMISSIONS.ADMIN_AREA.ROLES.MOVE_ROLE_UP_DOWN,
Constants.PERMISSIONS.ADMIN_AREA.LOGS
Constants.PERMISSIONS.ADMIN_AREA.LOGS,
Constants.PERMISSIONS.ADMIN_AREA.MANAGE
)
) {
items.push({
@ -175,6 +169,19 @@ export default function SideMenu({
});
}
if (
hasPermission(
appContext.userPermissions,
Constants.PERMISSIONS.ADMIN_AREA.MANAGE
)
) {
adminArea.children.push({
label: t("sideMenu.adminArea.manage"),
icon: <ControlOutlined />,
key: Constants.ROUTE_PATHS.ADMIN_AREA_MANAGE,
});
}
items.push(adminArea);
}

View File

@ -74,6 +74,7 @@ export const SentMessagesCommands = {
SubscribeToTopic: 23,
DeleteAllNotifications: 24,
DeleteOneNotification: 25,
AdminAreaManageCheckWhichCategoriesAreAvailable: 26,
};
/*
@ -798,11 +799,13 @@ export function handleWebSocketMessage(
});
}
/*
TODO: handle this
if (
body["AddedCategoryGroups"] !== undefined ||
body["RemovedCategoryGroups"] !== undefined
) {
groupTasksContext.setCategoryGroups((arr) => {
groupTasksContext.setCategoryGroup((arr) => {
let newArr = [...arr];
if (body["RemovedCategoryGroups"] !== undefined) {
@ -827,7 +830,7 @@ export function handleWebSocketMessage(
return newArr;
});
}
} */
notificationApi["success"]({
message: `Category group changes reloaded`,

View File

@ -0,0 +1,36 @@
import { Button, Card } from "antd";
import { useTranslation } from "react-i18next";
import { useWebSocketContext } from "../../../Contexts/WebSocketContext";
import { SentMessagesCommands } from "../../../Handlers/WebSocketMessageHandler";
import { Constants, hasPermission } from "../../../utils";
import { useAppContext } from "../../../Contexts/AppContext";
export default function AdminAreaManage() {
const { t } = useTranslation();
const appContext = useAppContext();
const webSocketContext = useWebSocketContext();
return (
<>
{hasPermission(
appContext.userPermissions,
Constants.PERMISSIONS.ADMIN_AREA
.MANAGE_CHECK_WHICH_CATEGORIES_ARE_AVAILABLE
) && (
<Card title={t("adminArea.manage.groupTasksCard.title")}>
<p>{t("adminArea.manage.groupTasksCard.description")}</p>
<Button
onClick={() =>
webSocketContext.SendSocketMessage(
SentMessagesCommands.AdminAreaManageCheckWhichCategoriesAreAvailable,
{}
)
}
>
{t("adminArea.manage.groupTasksCard.buttonText")}
</Button>
</Card>
)}
</>
);
}

View File

@ -3,7 +3,7 @@ import { useEffect, useRef, useState } from "react";
import GroupTasksViewModal from "./GroupTasksViewModal";
import GroupTypeSelectionModal from "./GroupTypeSelectionModal";
import GroupTaskTableList from "./GroupTasksTableList";
import { Constants, hasPermission, myFetch } from "../../../utils";
import { AppStyle, Constants, hasPermission, myFetch } from "../../../utils";
import { useTranslation } from "react-i18next";
import { ReloadOutlined } from "@ant-design/icons";
import { useGroupTasksContext } from "../../../Contexts/GroupTasksContext";
@ -146,7 +146,7 @@ export default function GroupTasks({ isGroupTasksViewModalOpen }) {
style={{
display: "flex",
justifyContent: "center",
marginTop: 20,
marginTop: AppStyle.app.margin,
}}
>
<Popconfirm

View File

@ -47,6 +47,7 @@ export const Constants = {
ROUTE_PATHS: {
EQUIPMENT_DOCUMENTATION: "/equipment-documentation",
EQUIPMENT_DOCUMENTATION_VIEW: "/equipment-documentation/",
NO_GROUP_TASKS_AVAILABLE: "/group-tasks-no-available",
GROUP_TASKS: "/group-tasks/",
GROUP_TASKS_HISTORY: "/group-tasks-history",
USERS: "/users",
@ -54,6 +55,7 @@ export const Constants = {
USER_PROFILE: "/user-profile",
ADMIN_AREA_ROLES: "/admin-area/roles",
ADMIN_AREA_LOGS: "/admin-area/logs",
ADMIN_AREA_MANAGE: "/admin-area/manage",
},
GROUP_TASKS_STATUS: {
FINISHED: 1,
@ -129,6 +131,9 @@ export const Constants = {
MOVE_ROLE_UP_DOWN: "admin_area.roles.move_role_up_down",
},
LOGS: "admin_area.logs",
MANAGE: "admin_area.manage",
MANAGE_CHECK_WHICH_CATEGORIES_ARE_AVAILABLE:
"admin_area.manage.check_which_categories_are_available",
},
USER_PROFILE: {
API_KEYS: "user_profile.api_keys",