diff --git a/app/Http/Controllers/Admin/RolesController.php b/app/Http/Controllers/Api/Application/RoleController.php similarity index 92% rename from app/Http/Controllers/Admin/RolesController.php rename to app/Http/Controllers/Api/Application/RoleController.php index 085db3d1a..f74f35300 100644 --- a/app/Http/Controllers/Admin/RolesController.php +++ b/app/Http/Controllers/Api/Application/RoleController.php @@ -1,13 +1,12 @@ repository = $repository; } diff --git a/resources/scripts/api/admin/roles/getRoles.ts b/resources/scripts/api/admin/roles/getRoles.ts index cd2e51901..4a660927c 100644 --- a/resources/scripts/api/admin/roles/getRoles.ts +++ b/resources/scripts/api/admin/roles/getRoles.ts @@ -8,7 +8,7 @@ export interface Role { export default (): Promise => { return new Promise((resolve, reject) => { - http.get('/admin/roles') + http.get('/api/application/roles') .then(({ data }) => resolve(data || [])) .catch(reject); }); diff --git a/resources/scripts/components/App.tsx b/resources/scripts/components/App.tsx index daaec5c94..c951bbc2f 100644 --- a/resources/scripts/components/App.tsx +++ b/resources/scripts/components/App.tsx @@ -1,19 +1,19 @@ -// import React, { useEffect } from 'react'; -// import ReactGA from 'react-ga'; -import React, { Suspense, lazy } from 'react'; +import React, { lazy, useEffect, Suspense } from 'react'; +import ReactGA from 'react-ga'; import { hot } from 'react-hot-loader/root'; -import { BrowserRouter, Route, Switch } from 'react-router-dom'; +import { Route, Router, Switch, useLocation } from 'react-router-dom'; import { StoreProvider } from 'easy-peasy'; import { store } from '@/state'; import DashboardRouter from '@/routers/DashboardRouter'; import ServerRouter from '@/routers/ServerRouter'; import AuthenticationRouter from '@/routers/AuthenticationRouter'; -import { Provider } from 'react-redux'; import { SiteSettings } from '@/state/settings'; import ProgressBar from '@/components/elements/ProgressBar'; import NotFound from '@/components/screens/NotFound'; -import tw from 'twin.macro'; +import tw, { GlobalStyles as TailwindGlobalStyles } from 'twin.macro'; import GlobalStylesheet from '@/assets/css/GlobalStylesheet'; +import { createBrowserHistory } from 'history'; +import { setupInterceptors } from '@/api/interceptors'; const ChunkedAdminRouter = lazy(() => import(/* webpackChunkName: "admin" */'@/routers/AdminRouter')); @@ -33,6 +33,20 @@ interface ExtendedWindow extends Window { }; } +const history = createBrowserHistory({ basename: '/' }); + +setupInterceptors(history); + +const Pageview = () => { + const { pathname } = useLocation(); + + useEffect(() => { + ReactGA.pageview(pathname); + }, [ pathname ]); + + return null; +}; + const App = () => { const { PterodactylUser, SiteConfiguration } = (window as ExtendedWindow); if (PterodactylUser && !store.getState().user.data) { @@ -53,31 +67,32 @@ const App = () => { } useEffect(() => { - ReactGA.initialize(SiteConfiguration!.analytics); - ReactGA.pageview(location.pathname); + if (SiteConfiguration?.analytics) { + ReactGA.initialize(SiteConfiguration!.analytics); + } }, []); return ( <> + - - + -
- - Loading...
}> - - - - - - - - - - -
+
+ + Loading...
}> + {SiteConfiguration?.analytics && } + + + + + + + + + +
); diff --git a/resources/scripts/components/admin/roles/RolesContainer.tsx b/resources/scripts/components/admin/roles/RolesContainer.tsx index e5832d158..5ddf1fd28 100644 --- a/resources/scripts/components/admin/roles/RolesContainer.tsx +++ b/resources/scripts/components/admin/roles/RolesContainer.tsx @@ -61,15 +61,15 @@ export default () => { - ID + ID - Name + Name - Description + Description @@ -78,9 +78,9 @@ export default () => { { roles.map(role => ( - {role.id} - {role.name} - {role.description} + {role.id} + {role.name} + {role.description} )) } diff --git a/resources/scripts/routers/AdminRouter.tsx b/resources/scripts/routers/AdminRouter.tsx index be50a11a7..593d7ef1f 100644 --- a/resources/scripts/routers/AdminRouter.tsx +++ b/resources/scripts/routers/AdminRouter.tsx @@ -30,7 +30,7 @@ const Sidebar = styled.div<{ collapsed?: boolean }>` & > span { height: 18px; - ${tw`font-header font-medium text-xs text-neutral-300 whitespace-no-wrap uppercase ml-4 mb-1 select-none`}; + ${tw`font-header font-medium text-xs text-neutral-300 whitespace-nowrap uppercase ml-4 mb-1 select-none`}; ${props => props.collapsed && tw`opacity-0`}; &:not(:first-of-type) { @@ -47,7 +47,7 @@ const Sidebar = styled.div<{ collapsed?: boolean }>` } & > span { - ${props => props.collapsed ? tw`hidden` : tw`font-header font-medium text-lg whitespace-no-wrap leading-none ml-3`}; + ${props => props.collapsed ? tw`hidden` : tw`font-header font-medium text-lg whitespace-nowrap leading-none ml-3`}; } &:hover { @@ -83,7 +83,7 @@ export default ({ location, match }: RouteComponentProps) => {
{ setCollapsed(!collapsed); } }> { !collapsed ? -

{name}

+

{name}

: {'Pterodactyl } @@ -152,8 +152,8 @@ export default ({ location, match }: RouteComponentProps) => { Profile Picture
- Matthew Penner - Super Administrator + Matthew Penner + Super Administrator
diff --git a/resources/scripts/routers/AuthenticationRouter.tsx b/resources/scripts/routers/AuthenticationRouter.tsx index 57d1422ca..a7c687eef 100644 --- a/resources/scripts/routers/AuthenticationRouter.tsx +++ b/resources/scripts/routers/AuthenticationRouter.tsx @@ -1,5 +1,4 @@ -import React, { useEffect } from 'react'; -import ReactGA from 'react-ga'; +import React from 'react'; import { Route, RouteComponentProps, Switch } from 'react-router-dom'; import LoginContainer from '@/components/auth/LoginContainer'; import ForgotPasswordContainer from '@/components/auth/ForgotPasswordContainer'; @@ -7,23 +6,17 @@ import ResetPasswordContainer from '@/components/auth/ResetPasswordContainer'; import LoginCheckpointContainer from '@/components/auth/LoginCheckpointContainer'; import NotFound from '@/components/screens/NotFound'; -export default ({ location, history, match }: RouteComponentProps) => { - useEffect(() => { - ReactGA.pageview(location.pathname); - }, [ location.pathname ]); - - return ( -
- - - - - - - - history.push('/auth/login')} /> - - -
- ); -}; +export default ({ location, history, match }: RouteComponentProps) => ( +
+ + + + + + + + history.push('/auth/login')}/> + + +
+); diff --git a/resources/scripts/routers/DashboardRouter.tsx b/resources/scripts/routers/DashboardRouter.tsx index 7e57a10ca..1e5963996 100644 --- a/resources/scripts/routers/DashboardRouter.tsx +++ b/resources/scripts/routers/DashboardRouter.tsx @@ -1,5 +1,4 @@ -import React, { useEffect } from 'react'; -import ReactGA from 'react-ga'; +import React from 'react'; import { NavLink, Route, RouteComponentProps, Switch } from 'react-router-dom'; import AccountOverviewContainer from '@/components/dashboard/AccountOverviewContainer'; import NavigationBar from '@/components/NavigationBar'; @@ -9,30 +8,24 @@ import NotFound from '@/components/screens/NotFound'; import TransitionRouter from '@/TransitionRouter'; import SubNavigation from '@/components/elements/SubNavigation'; -export default ({ location }: RouteComponentProps) => { - useEffect(() => { - ReactGA.pageview(location.pathname); - }, [ location.pathname ]); - - return ( - <> - - {location.pathname.startsWith('/account') && - -
- Settings - API Credentials -
-
- } - - - - - - - - - - ); -}; +export default ({ location }: RouteComponentProps) => ( + <> + + {location.pathname.startsWith('/account') && + +
+ Settings + API Credentials +
+
+ } + + + + + + + + + +); diff --git a/routes/api-application.php b/routes/api-application.php index e32461717..d6eb1d83c 100644 --- a/routes/api-application.php +++ b/routes/api-application.php @@ -120,3 +120,20 @@ Route::group(['prefix' => '/nests'], function () { Route::get('/{egg}', 'Nests\EggController@view')->name('api.application.nests.eggs.view'); }); }); + +/* +|-------------------------------------------------------------------------- +| Role Controller Routes +|-------------------------------------------------------------------------- +| +| Endpoint: /api/application/roles +| +*/ + +Route::group(['prefix' => '/roles'], function () { + Route::get('/', 'RoleController@index')->name('api.application.roles'); + + Route::post('/', 'RoleController@create'); + + Route::delete('/{role}', 'RoleController@delete'); +});