Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion app/Helpers/InstitutionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static function checkSelfInst(Request $request)
}

// Returns the institution id and an error if any, as a tuple.
public static function GetInstitution(Request $request)
public static function GetInstitutionId(Request $request)
{
if ($request->user()->inst_id != null) {
return [$request->user()->inst_id, ''];
Expand All @@ -82,6 +82,40 @@ public static function GetInstitution(Request $request)
return [$inst, ''];
}

/** @return array<string, mixed>|null */
public static function GetInstitution(Request $request): ?array
{
if (! $request->user()) {
return null;
}
$instId = $request->attributes->get('inst_id');
if ($instId === null || $instId === '') {
$instId = self::GetInstitutionId($request)[0];
}
if ($instId === null || $instId === '') {
return null;
}
[$tok] = TokenHelper::GetToken($request);
if ($tok === '') {
return null;
}
$base = rtrim((string) env('BACKEND_URL'), '/');
$resp = Http::withHeaders([
'Authorization' => 'Bearer '.$tok,
'accept' => 'application/json',
'Cache-Control' => 'no-cache',
])->get($base.'/institutions/'.$instId);
if ($resp->getStatusCode() !== 200) {
return null;
}
$data = $resp->json();
if (! is_array($data)) {
return null;
}

return $data;
}

// Set the institution id for Datakinders, return an error if any.
public static function setDatakinderInst(string $access_type, string $inst)
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ public function viewUploadedData(Request $request)
public function appHomeRedirect(Request $request)
{
$hasBatches = false;
$inst_id = $request->attributes->get('inst_id') ?? \App\Helpers\InstitutionHelper::GetInstitution($request)[0];
$inst_id = $request->attributes->get('inst_id') ?? \App\Helpers\InstitutionHelper::GetInstitutionId($request)[0];
if ($request->user() && $inst_id) {
$request->attributes->set('inst_id', $inst_id);
$result = ApiController::constructInstRequest($request, '/input', 'GET', null);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/DataDictionaryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DataDictionaryController extends Controller
public function show(Request $request): InertiaResponse
{
$inst_id = $request->attributes->get('inst_id')
?? InstitutionHelper::GetInstitution($request)[0] ?? null;
?? InstitutionHelper::GetInstitutionId($request)[0] ?? null;

Log::info('DataDictionary: inst_id', ['inst_id' => $inst_id]);

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ModelResultsOverviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ModelResultsOverviewController extends Controller
public function show(Request $request, string $run_id, string $modelName): InertiaResponse|JsonResponse
{
$inst_id = $request->attributes->get('inst_id')
?? InstitutionHelper::GetInstitution($request)[0] ?? null;
?? InstitutionHelper::GetInstitutionId($request)[0] ?? null;

if (! $inst_id) {
return Inertia::render('ModelResultsOverview', [
Expand Down
8 changes: 7 additions & 1 deletion app/Http/Middleware/HandleInertiaRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,18 @@ public function share(Request $request): array
'success' => fn () => $request->session()->get('success'),
'error' => fn () => $request->session()->get('error'),
],
'institution' => function () use ($request) {
if (! $request->user()) {
return null;
}
return \App\Helpers\InstitutionHelper::GetInstitution($request);
},
'inst_id' => function () use ($request) {
if (! $request->user()) {
return null;
}
$inst = $request->attributes->get('inst_id')
?? \App\Helpers\InstitutionHelper::GetInstitution($request)[0];
?? \App\Helpers\InstitutionHelper::GetInstitutionId($request)[0];

return $inst ?: null;
},
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Middleware/RequireInstitution.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function handle(Request $request, Closure $next): Response
}

if ($request->user()->access_type !== 'DATAKINDER') {
[$inst, ] = InstitutionHelper::GetInstitution($request);
[$inst, ] = InstitutionHelper::GetInstitutionId($request);
if ($inst !== null && $inst !== '') {
$request->attributes->set('inst_id', $inst);
}
Expand All @@ -57,7 +57,7 @@ public function handle(Request $request, Closure $next): Response
}
}

[$inst, $instErr] = InstitutionHelper::GetInstitution($request);
[$inst, $instErr] = InstitutionHelper::GetInstitutionId($request);
if ($inst !== null && $inst !== '') {
$request->attributes->set('inst_id', $inst);

Expand Down
23 changes: 19 additions & 4 deletions resources/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,25 @@
url('https://storage.googleapis.com/staging-sst-01-staging-static/HelveticaNeueRoman.woff') format('woff');
font-weight: 400;
}

a {
color: theme('colors.link.DEFAULT');
text-decoration: none;
text-underline-offset: 2px;
transition: color 150ms cubic-bezier(0.4, 0, 0.2, 1);
}
a:hover {
color: theme('colors.secondary.DEFAULT');
}
a:focus-visible {
border-radius: 0.125rem;
outline: 2px solid theme('colors.input.focus');
outline-offset: 2px;
}
/* Avoid a line under image-only links (e.g. logo) */
a:has(> img:only-child) {
text-decoration-line: none;
}
}

[x-cloak] {
Expand Down Expand Up @@ -81,10 +100,6 @@ input[type='text'].mapboxgl-ctrl-geocoder--input[placeholder='Search'] {
@apply font-merriweather italic;
}

a {
@apply text-blue-700;
}

/* Rounded corners for Plotly tooltips */
.js-plotly-plot .hoverlayer .hovertext {
border-radius: 16px !important;
Expand Down
10 changes: 0 additions & 10 deletions resources/js/Components/ApplicationLogo.jsx

This file was deleted.

176 changes: 0 additions & 176 deletions resources/js/Components/Welcome.jsx

This file was deleted.

16 changes: 9 additions & 7 deletions resources/js/Layouts/AppLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const navigationBelowLine = [
// The title set in the page needs to match the name in the navigation map so that the highlighting works correctly.
export default function AppLayout({ title, renderHeader, children }) {
const { auth, jetstream } = useTypedPage().props;
const { inst_id } = usePage().props;
const { inst_id, institution } = usePage().props;
const user = auth.user;
const userIsDatakinder =
auth.user != null ? auth.user.access_type == 'DATAKINDER' : false;
Expand Down Expand Up @@ -407,18 +407,20 @@ export default function AppLayout({ title, renderHeader, children }) {
<header>
<nav className="auto w-1/8 bg-blue flex min-h-full flex-1 basis-2/12 flex-row gap-y-6 overflow-y-auto border-r border-gray-200 bg-white px-6 shadow-md">
<div className="flex flex-col justify-between">
<ul role="list" className="flex flex-1 flex-col gap-y-12">
<li
className="flex h-16 shrink-0 flex-col items-center pt-12"
key="logo"
>
<ul role="list" className="flex flex-1 flex-col">
<li className="my-10" key="logo">
<a href={route('home')}>
<img
className="w-full pb-12"
className="w-full"
src="https://storage.googleapis.com/staging-sst-01-staging-static/edvise-logo.svg"
alt="Edvise Logo"
/>
</a>
{userIsDatakinder && institution?.name && (
<a href={route('set-inst')} className="mt-3 block">
{institution.name}
</a>
)}
</li>
<li key="navigation">
<ul>
Expand Down
Loading