diff --git a/core/src/handlers/users.rs b/core/src/handlers/users.rs index f3a94f93..f6fe68c2 100644 --- a/core/src/handlers/users.rs +++ b/core/src/handlers/users.rs @@ -207,7 +207,7 @@ pub async fn change_password( let requester = users_manager.try_auth_or_err(&token)?; - if requester.uid != config.uid || !requester.can_perform_action(&UserAction::ManageUser) { + if requester.uid != config.uid && !requester.can_perform_action(&UserAction::ManageUser) { return Err(Error { kind: ErrorKind::PermissionDenied, source: eyre!("You are not authorized to change other users password"), diff --git a/dashboard/src/components/Atoms/NotificationCard.tsx b/dashboard/src/components/Atoms/NotificationCard.tsx index a9482b1f..c29422b3 100644 --- a/dashboard/src/components/Atoms/NotificationCard.tsx +++ b/dashboard/src/components/Atoms/NotificationCard.tsx @@ -51,14 +51,14 @@ export default function NotificationCard({ >
-

+

{title}

-

+

{message}

- {!message && ( - + {!message && ( + {formatNotificationTime(timestamp)} )} diff --git a/dashboard/src/components/GameConsole.tsx b/dashboard/src/components/GameConsole.tsx index d33ae6d8..67f2f405 100644 --- a/dashboard/src/components/GameConsole.tsx +++ b/dashboard/src/components/GameConsole.tsx @@ -1,17 +1,19 @@ import { faCircle, faServer } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import axios from 'axios'; -import { useConsoleStream } from 'data/ConsoleStream'; +import { ConsoleEvent, useConsoleStream } from 'data/ConsoleStream'; import { InstanceContext } from 'data/InstanceContext'; import { CommandHistoryContext } from 'data/CommandHistoryContext'; import { useUserAuthorized } from 'data/UserInfo'; import Tooltip from 'rc-tooltip'; import { useContext, useEffect } from 'react'; import { useRef, useState } from 'react'; -import { usePrevious } from 'utils/hooks'; +import { useLocalStorageQueryParam, usePrevious } from 'utils/hooks'; import { DISABLE_AUTOFILL } from 'utils/util'; import ErrorGraphic from './ErrorGraphic'; import { useDocumentTitle } from 'usehooks-ts'; +import Button from './Atoms/Button'; +import Checkbox from './Atoms/Checkbox'; const autoScrollThreshold = 10; @@ -24,8 +26,15 @@ export default function GameConsole() { 'can_access_instance_console', uuid ); - const { consoleLog, consoleStatus } = useConsoleStream(uuid); + const defaultFilters = { + "PlayerMessage": true, + "SystemMessage": true, + "InstanceOutput": true + } + const { consoleLog, consoleStatus, clearConsoleLog } = useConsoleStream(uuid); const [command, setCommand] = useState(''); + const [filter, setFilter] = useState(''); + const [regex, setRegex] = useState(true); const { commandHistory, appendCommandHistory } = useContext( CommandHistoryContext ); @@ -128,75 +137,117 @@ export default function GameConsole() { } }; + const filterMessage = (line: ConsoleEvent) => { + if (filter == '') return true; + if (regex) { + try { + const filterRegex = new RegExp(filter, "i"); + if (line.message.match(filterRegex)) return true; + } catch (e) { + console.log("regex invalid!!!"); + } + } else { + if (line.message.toLowerCase().indexOf(filter.toLowerCase()) != -1) return true; + } + return false; + } + + const checkRegex = (checked: boolean) => { + setRegex(checked) + } + return ( -
- {consoleStatusMessage}} - placement="bottom" - showArrow={false} - trigger={['hover']} - mouseEnterDelay={0} - > - - - {!canAccessConsole || consoleStatus === 'no-permission' ? ( - + {/*
+
); } diff --git a/dashboard/src/components/UserBox.tsx b/dashboard/src/components/UserBox.tsx index 7a42bcc9..31f09997 100644 --- a/dashboard/src/components/UserBox.tsx +++ b/dashboard/src/components/UserBox.tsx @@ -65,12 +65,8 @@ export default function UserBox({

- Create a new user account + Change password

-

- This user will start with no permissions. You can grant them - permissions later. -

{isSelf ? ( setShowChangePassword(false)} diff --git a/dashboard/src/data/ConsoleStream.ts b/dashboard/src/data/ConsoleStream.ts index 36c123f1..469eff15 100644 --- a/dashboard/src/data/ConsoleStream.ts +++ b/dashboard/src/data/ConsoleStream.ts @@ -89,6 +89,11 @@ export const useConsoleStream = (uuid: string) => { uuid ); + const clearConsoleLog = () => { + const econsoleLog: ConsoleEvent[] = [] + setConsoleLog(econsoleLog) + } + const mergeConsoleLog = (newLog: ClientEvent[]) => { setConsoleLog((oldLog) => { const consoleEvents = newLog @@ -99,7 +104,6 @@ export const useConsoleStream = (uuid: string) => { ); }) .map(toConsoleEvent); - const mergedLog = [...oldLog, ...consoleEvents]; // this is slow ik return mergedLog.filter( @@ -135,6 +139,7 @@ export const useConsoleStream = (uuid: string) => { websocket.onclose = (event) => { setStatus(event.code === 1000 ? 'closed' : 'error'); + console.log("event: ", event) }; return () => { @@ -162,5 +167,6 @@ export const useConsoleStream = (uuid: string) => { return { consoleLog, consoleStatus: status, + clearConsoleLog }; }; diff --git a/dashboard/src/pages/InstanceTabs/InstanceTabs.tsx b/dashboard/src/pages/InstanceTabs/InstanceTabs.tsx index 43355700..2131ad9e 100644 --- a/dashboard/src/pages/InstanceTabs/InstanceTabs.tsx +++ b/dashboard/src/pages/InstanceTabs/InstanceTabs.tsx @@ -159,7 +159,7 @@ const InstanceTabs = () => { className="gutter-stable -mx-3 flex grow flex-row items-stretch overflow-y-auto pl-4 pr-2" key={`${instance.name}-${tab.title}`} > -
+
{tab.displayTitle && (
{tab.displayTitle} diff --git a/dashboard/src/pages/settings/UserSettings.tsx b/dashboard/src/pages/settings/UserSettings.tsx index 7b372db1..0d1f134d 100644 --- a/dashboard/src/pages/settings/UserSettings.tsx +++ b/dashboard/src/pages/settings/UserSettings.tsx @@ -204,7 +204,7 @@ export const UserSettings = () => { disabled: boolean ) => selectedUser && ( -
+
{permissionList.map((permission) => { const currentSettings = selectedUser.permissions[permission.permission]; @@ -245,6 +245,7 @@ export const UserSettings = () => { optionKey={(uuid) => uuid} onChange={(newSettings) => { // I hate typescript + // |- me too const newPermissions = { ...selectedUser.permissions, [permission.permission]: newSettings,