From 267c675425ea2491c1ad11e53bd0c2aeb67b0812 Mon Sep 17 00:00:00 2001 From: tabarra <1808295+tabarra@users.noreply.github.com> Date: Mon, 1 Apr 2024 01:03:07 -0300 Subject: [PATCH] chore: migrated old database to new history route prefix --- core/components/WebServer/router.ts | 2 +- core/webroutes/{databaseActions.ts => history/actions.ts} | 4 ++-- core/webroutes/index.js | 2 +- docs/dev_notes.md | 4 ++-- nui/src/components/PlayerModal/Tabs/DialogHistoryView.tsx | 2 +- panel/src/layout/ActionModal/ActionModifyTab.tsx | 2 +- web/main/playerList.ejs | 2 +- web/public/js/txadmin/main.js | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) rename core/webroutes/{databaseActions.ts => history/actions.ts} (98%) diff --git a/core/components/WebServer/router.ts b/core/components/WebServer/router.ts index 30f036d8e..c18e864da 100644 --- a/core/components/WebServer/router.ts +++ b/core/components/WebServer/router.ts @@ -113,7 +113,7 @@ export default (config: WebServerConfigType) => { router.get('/history/stats', apiAuthMw, webRoutes.history_stats); router.get('/history/search', apiAuthMw, webRoutes.history_search); router.get('/history/action', apiAuthMw, webRoutes.history_actionModal); - router.post('/database/:action', apiAuthMw, webRoutes.databaseActions); //FIXME: convert those to /history/:action + router.post('/history/:action', apiAuthMw, webRoutes.history_actions); //Player routes router.get('/player', apiAuthMw, webRoutes.player_modal); diff --git a/core/webroutes/databaseActions.ts b/core/webroutes/history/actions.ts similarity index 98% rename from core/webroutes/databaseActions.ts rename to core/webroutes/history/actions.ts index d0820da56..818358f83 100644 --- a/core/webroutes/databaseActions.ts +++ b/core/webroutes/history/actions.ts @@ -1,4 +1,4 @@ -const modulename = 'WebServer:DatabaseActions'; +const modulename = 'WebServer:HistoryActions'; import { GenericApiResp } from '@shared/genericApiTypes'; import { DatabaseActionType } from '@core/components/PlayerDatabase/databaseTypes'; import { calcExpirationFromDuration } from '@core/extras/helpers'; @@ -15,7 +15,7 @@ const anyUndefined = (...args: any) => { return [...args].some((x) => (typeof x /** * Endpoint to interact with the actions database. */ -export default async function DatabaseActions(ctx: AuthedCtx) { +export default async function HistoryActions(ctx: AuthedCtx) { //Sanity check if (!ctx.params?.action) { return ctx.utils.error(400, 'Invalid Request'); diff --git a/core/webroutes/index.js b/core/webroutes/index.js index 837607ed6..ae012b111 100644 --- a/core/webroutes/index.js +++ b/core/webroutes/index.js @@ -48,7 +48,7 @@ export { default as fxserver_schedule } from './fxserver/schedule'; export { default as history_stats } from './history/stats'; export { default as history_search } from './history/search'; export { default as history_actionModal } from './history/actionModal'; -export { default as databaseActions } from './databaseActions'; //FIXME: convert into history +export { default as history_actions } from './history/actions.js'; export { default as player_stats } from './player/stats'; export { default as player_search } from './player/search'; diff --git a/docs/dev_notes.md b/docs/dev_notes.md index e81cbf3be..1c3e46906 100644 --- a/docs/dev_notes.md +++ b/docs/dev_notes.md @@ -33,8 +33,8 @@ - [x] try to add player name to title - [x] fix modal padding (good enough) - [x] modify HistoryTab -> HistoryItem to open the action modal on item click, remove revoke/perms logic -- [ ] fix(console): fix extra line break on term.write -- [ ] Migrate `/database/` routes to `/history` (update panel, nui, web!) +- [x] fix(console): remove extra line break on term.write +- [x] Migrate `/database/` routes to `/history` (update panel, nui, web!) - [ ] Add StatisticsManager tracking for players/actions search duration (QuantileArray) - [ ] fix disallowed intents message diff --git a/nui/src/components/PlayerModal/Tabs/DialogHistoryView.tsx b/nui/src/components/PlayerModal/Tabs/DialogHistoryView.tsx index fcc6cda1a..1c42f1fd1 100644 --- a/nui/src/components/PlayerModal/Tabs/DialogHistoryView.tsx +++ b/nui/src/components/PlayerModal/Tabs/DialogHistoryView.tsx @@ -147,7 +147,7 @@ const DialogHistoryView: React.FC = () => { const handleRevoke = async (actionId: string) => { try { const result = await fetchWebPipe( - `/database/revoke_action`, + `/history/revoke_action`, { method: "POST", data: { actionId }, diff --git a/panel/src/layout/ActionModal/ActionModifyTab.tsx b/panel/src/layout/ActionModal/ActionModifyTab.tsx index 1efdb0a06..2a94d1309 100644 --- a/panel/src/layout/ActionModal/ActionModifyTab.tsx +++ b/panel/src/layout/ActionModal/ActionModifyTab.tsx @@ -17,7 +17,7 @@ export default function ActionModifyTab({ action, refreshModalData }: ActionModi const { hasPerm } = useAdminPerms(); const revokeActionApi = useBackendApi({ method: 'POST', - path: `/database/revoke_action`, + path: `/history/revoke_action`, }); const upperCasedType = action.type.charAt(0).toUpperCase() + action.type.slice(1); diff --git a/web/main/playerList.ejs b/web/main/playerList.ejs index 369644b9b..f5d815ff4 100644 --- a/web/main/playerList.ejs +++ b/web/main/playerList.ejs @@ -499,7 +499,7 @@ txAdminAPI({ type: "POST", - url: '/database/ban_ids', + url: '/history/ban_ids', timeout: REQ_TIMEOUT_LONG, data, success: function (data) { diff --git a/web/public/js/txadmin/main.js b/web/public/js/txadmin/main.js index e3fd65c6f..8bf170038 100644 --- a/web/public/js/txadmin/main.js +++ b/web/public/js/txadmin/main.js @@ -33,7 +33,7 @@ function revokeAction(actionId, isModal = false) { const notify = $.notify({ message: '

Revoking...

' }, {}); txAdminAPI({ type: "POST", - url: '/database/revoke_action', + url: '/history/revoke_action', timeout: REQ_TIMEOUT_LONG, data: { actionId }, success: function (data) {