Skip to content

Commit

Permalink
Feature/react migration (#1095)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgershman authored Jul 11, 2024
1 parent 898e914 commit ca80569
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 46 deletions.
15 changes: 15 additions & 0 deletions src/app/Http/Controllers/AdminV2Controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class AdminV2Controller extends Controller
{
public function index(Request $request)
{
return view('admin')
->with('baseUrl', sprintf("%s/adminv2", $request->getBaseUrl()))
->with('rootUrl', $request->getBaseUrl());
}
}
2 changes: 1 addition & 1 deletion src/app/Services/SettingsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class SettingsService
{
private string $version = "4.3.5";
private string $version = "4.4.0";
private array $allowlist = [
'announce_servicebody_volunteer_routing' => ['description' => '/helpline/announce_servicebody_volunteer_routing' , 'default' => false, 'overridable' => true, 'hidden' => false],
'blocklist' => ['description' => '/general/blocklist' , 'default' => '', 'overridable' => true, 'hidden' => false],
Expand Down
34 changes: 17 additions & 17 deletions src/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 35 additions & 27 deletions src/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 49 additions & 1 deletion src/resources/js/pages/Users.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,54 @@
import React, {useEffect, useState} from "react";
import {Button, Card, Table, TableBody, TableCell, TableContainer, TableHead, TableRow} from "@mui/material";

function Users() {
const [loading, setLoading] = useState(false);
const [list, setList] = useState([]);

const getUsers = async() => {
setLoading(true)
let response = await fetch(`${rootUrl}/api/v1/users`)
let responseData = await response.json()
setList(responseData)
setLoading(false)
}

useEffect(() => {
getUsers()
}, [])

return (
<h1>Users</h1>
!loading && list.length > 0 ?
<TableContainer>
<Table sx={{ minWidth: 650 }} size="small" aria-label="a dense table">
<TableHead>
<TableRow>
<TableCell>Username</TableCell>
<TableCell>Name</TableCell>
<TableCell>Service Bodies</TableCell>
<TableCell>Permissions</TableCell>
<TableCell>Admin</TableCell>
<TableCell>Date Created</TableCell>
</TableRow>
</TableHead>
<TableBody>
{list.map((item) => (
<TableRow
key={item.username}
sx={{ '&:last-child td, &:last-child th': { border: 0 } }}>
<TableCell component="th" scope="row">
{item.username}
</TableCell>
<TableCell>{item.name}</TableCell>
<TableCell>{item.service_bodies}</TableCell>
<TableCell>{item.permissions}</TableCell>
<TableCell>{item.is_admin}</TableCell>
<TableCell>{item.created_on}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</TableContainer> : "Loading..."
)
}

Expand Down
14 changes: 14 additions & 0 deletions src/resources/views/admin.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<html lang="{{ app()->getLocale() }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ env('APP_NAME') }}</title>
</head>
<body>
<div id="root"></div>
<script>const rootUrl = "{{ $rootUrl }}";const baseUrl = "{{ $baseUrl }}";</script>
<script src="{{ url('public' . mix('js/index.js')) }}"></script>
</body>
</html>
3 changes: 3 additions & 0 deletions src/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
Route::post("/admin/login", 'App\Http\Controllers\AdminController@login');
Route::get("/admin/{page}", 'App\Http\Controllers\AdminController@index')
->middleware("authForAdminPortal");
Route::get("/adminv2{page}", 'App\Http\Controllers\AdminV2Controller@index')
->where('page', '.*');
Route::get("/bots/getMeetings", 'App\Http\Controllers\BotController@getMeetings');
Route::get("/bots/getServiceBodyCoverage", 'App\Http\Controllers\BotController@getServiceBodyCoverage');
Route::get("/msr/{latitude}/{longitude}", ['uses' => 'App\Http\Controllers\MeetingResultsController@index'])
Expand Down Expand Up @@ -90,3 +92,4 @@
->where('ext', $ext);
Route::match(array('GET', 'POST'), "/helpline-dialer{ext}", 'App\Http\Controllers\HelplineController@dial')
->where('ext', $ext);
Route::get("/callWidget", 'App\Http\Controllers\CallWidgetController@index');

0 comments on commit ca80569

Please sign in to comment.