diff --git a/app/Helpers/InstitutionHelper.php b/app/Helpers/InstitutionHelper.php
index f0c0dde..89a4cf7 100644
--- a/app/Helpers/InstitutionHelper.php
+++ b/app/Helpers/InstitutionHelper.php
@@ -59,8 +59,10 @@ public static function GetInstitution(Request $request)
if ($inst !== '') {
$full = self::fetchInstitutionById($request, $inst);
session(['institution' => $full ?? ['inst_id' => $inst]]);
+
return [$inst, ''];
}
+
return ['', ''];
}
diff --git a/app/Http/Middleware/RequireInstitution.php b/app/Http/Middleware/RequireInstitution.php
index f624e72..9fb3fbd 100644
--- a/app/Http/Middleware/RequireInstitution.php
+++ b/app/Http/Middleware/RequireInstitution.php
@@ -62,7 +62,7 @@ public function handle(Request $request, Closure $next): Response
}
}
- [$inst, $instErr] = InstitutionHelper::GetInstitution($request);
+ [$inst] = InstitutionHelper::GetInstitution($request);
if ($inst !== null && $inst !== '') {
$institution = session('institution');
if (is_array($institution) && ! empty($institution['inst_id'] ?? '')) {
@@ -74,11 +74,10 @@ public function handle(Request $request, Closure $next): Response
return $next($request);
}
- $message = InstitutionHelper::SET_INST_REQUIRED_MESSAGE;
if ($request->expectsJson()) {
- return response()->json(['error' => $message], 401);
+ return response()->json(['error' => 'Institution required.'], 401);
}
- return redirect()->route('set-inst', ['message' => $message]);
+ return redirect()->route('set-inst');
}
}
diff --git a/resources/js/Components/Alert.jsx b/resources/js/Components/Alert.jsx
new file mode 100644
index 0000000..3957b41
--- /dev/null
+++ b/resources/js/Components/Alert.jsx
@@ -0,0 +1,97 @@
+import React from 'react';
+import classNames from 'classnames';
+import {
+ CheckCircleIcon,
+ ExclamationTriangleIcon,
+ InformationCircleIcon,
+ XCircleIcon,
+} from '@heroicons/react/24/solid';
+
+const VARIANTS = {
+ danger: {
+ Icon: XCircleIcon,
+ border: 'border-red',
+ surface: 'bg-red-50',
+ iconWrap: 'bg-red',
+ title: 'text-red-900',
+ item: 'text-red-800',
+ },
+ warning: {
+ Icon: ExclamationTriangleIcon,
+ border: 'border-amber-500',
+ surface: 'bg-amber-50',
+ iconWrap: 'bg-amber-500',
+ title: 'text-amber-900',
+ item: 'text-amber-800',
+ },
+ info: {
+ Icon: InformationCircleIcon,
+ border: 'border-sky-500',
+ surface: 'bg-sky-50',
+ iconWrap: 'bg-sky-500',
+ title: 'text-sky-900',
+ item: 'text-sky-800',
+ },
+ success: {
+ Icon: CheckCircleIcon,
+ border: 'border-green-600',
+ surface: 'bg-green-50',
+ iconWrap: 'bg-green-600',
+ title: 'text-green-900',
+ item: 'text-green-800',
+ },
+};
+
+export default function Alert({
+ variant = 'info',
+ mainMsg,
+ msgDict,
+ excludeValue,
+ className,
+}) {
+ if (mainMsg == undefined || mainMsg == '') {
+ return null;
+ }
+
+ const v = VARIANTS[variant] ?? VARIANTS.info;
+ const Icon = v.Icon;
+
+ return (
+
+
+
+
+
+
+ {mainMsg}
+
+
+ {msgDict !== undefined && Object.keys(msgDict).length !== 0
+ ? Object.entries(msgDict).map(([k, val]) =>
+ val !== excludeValue ? (
+ -
+ {k}: {val}
+
+ ) : null,
+ )
+ : null}
+
+
+
+ );
+}
diff --git a/resources/js/Components/ErrorAlert.jsx b/resources/js/Components/ErrorAlert.jsx
deleted file mode 100644
index eb54410..0000000
--- a/resources/js/Components/ErrorAlert.jsx
+++ /dev/null
@@ -1,67 +0,0 @@
-import React from 'react';
-import { XCircleIcon } from '@heroicons/react/24/solid';
-import classNames from 'classnames';
-
-export default function ErrorAlert({
- mainMsg,
- msgDict,
- excludeValue,
- className,
-}) {
- if (mainMsg == undefined || mainMsg == '') {
- return null;
- }
-
- return (
-
-
-
-
{mainMsg}
-
- {msgDict !== undefined && Object.keys(msgDict).length !== 0 ? (
- Object.entries(msgDict).map(([k, v]) =>
- v !== excludeValue ? (
- -
- {k}: {v}
-
- ) : (
- <>>
- ),
- )
- ) : (
- <>>
- )}
-
-
-
- );
-}
diff --git a/resources/js/Pages/Dashboard.jsx b/resources/js/Pages/Dashboard.jsx
index e387d6c..d9e0924 100644
--- a/resources/js/Pages/Dashboard.jsx
+++ b/resources/js/Pages/Dashboard.jsx
@@ -1,17 +1,11 @@
import axios from 'axios';
import React, { useEffect, useState } from 'react';
import { Chart } from 'react-google-charts';
-
import Spinner from '@/Components/Spinner';
import AppLayout from '@/Layouts/AppLayout';
import ModelRunHistory from '@/Components/ModelRunHistory';
-import HeaderLabel from '@/Components/HeaderLabel';
-import ErrorAlert from '@/Components/ErrorAlert';
-import classNames from 'classnames';
+import Alert from '@/Components/Alert';
import { formatModelName } from '@/utils/stringUtils';
-
-import { ChartBarIcon, ArrowUpTrayIcon } from '@heroicons/react/24/outline';
-import Button from '@/Components/Landing/Button';
import PageHeading from '@/Components/PageHeading';
const histogramOptions = {
@@ -212,10 +206,11 @@ export default function Dashboard({ modelname }) {
) : error != null &&
!(error.message == 'NO_MODELS' || error.message == 'NO_RUNS') ? (
-
+ />
) : (
{error != null &&
- (error.message == 'NO_MODELS' || error.message == 'NO_RUNS') ? (
+ (error.message == 'NO_MODELS' || error.message == 'NO_RUNS') ? (
<>
@@ -264,7 +259,10 @@ export default function Dashboard({ modelname }) {
)}
-
+
>
) : (
@@ -277,7 +275,7 @@ export default function Dashboard({ modelname }) {
Run Time:
{runDatesToJobDict == undefined ||
- Object.keys(runDatesToJobDict).length == 0 ? (
+ Object.keys(runDatesToJobDict).length == 0 ? (