Skip to content

Commit

Permalink
UI improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
wardviaene committed Aug 19, 2024
1 parent e4a970f commit b2e926f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
6 changes: 3 additions & 3 deletions webapp/src/Routes/Setup/Setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { useAuthContext } from "../../Auth/Auth";
import { useForm } from '@mantine/form';
import axios, { AxiosError } from "axios";


type SetupRequest = {
hostname: string;
enableTLS: boolean;
Expand Down Expand Up @@ -130,13 +129,14 @@ export function Setup() {
</div>
</UnstyledButton>
<Space h="md" />
<UnstyledButton className={classes.button} onClick={() => form.setFieldValue("redirectToHttps", !form.getValues().redirectToHttps )}>
<UnstyledButton className={classes.button} onClick={() => window.location.protocol === "https:" ? form.setFieldValue("redirectToHttps", !form.getValues().redirectToHttps) : null }>
<Checkbox
tabIndex={-1}
size="md"
mr="xl"
styles={{ input: { cursor: 'pointer' } }}
aria-hidden
disabled={ window.location.protocol === "https:" ? false : true }
key={form.key('redirectToHttps')}
{...form.getInputProps('redirectToHttps', { type: 'checkbox' })}
/>
Expand All @@ -147,7 +147,7 @@ export function Setup() {
<Text fz="sm" c="dimmed">
Redirect http requests to https.
Not needed when terminating TLS on an external LoadBalancer.
Recommended once TLS is activated and working.
Can only be enabled once this page is requested through https.
</Text>
</div>
</UnstyledButton>
Expand Down
26 changes: 18 additions & 8 deletions webapp/src/Routes/Users/ListUsers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ type UserIDAndPassword = {
password: string;
}

type Status = {
status: string;
color: string;
}

export function ListUsers({localAuthDisabled}:Props) {
const [opened, { open, close }] = useDisclosure(false);
const [newPassword, setNewPassword] = useState<string>();
Expand Down Expand Up @@ -89,12 +94,7 @@ export function ListUsers({localAuthDisabled}:Props) {
saml: 'teal',
provisioned: 'grape',
};
const userStatus: Record<string, string> = {
active: 'green',
suspended: 'red',
tokenExpired: 'amber',
localAuthDisabled: 'yellow'
};

const rolesData = ["user", "admin"];

const openPasswordModal = (id:string) => {
Expand All @@ -106,6 +106,16 @@ export function ListUsers({localAuthDisabled}:Props) {
const date = new Date(dateInput)
return date.getFullYear() + "-" + (date.getMonth()+1).toString().padStart(2, '0') + "-" + date.getDate().toString().padStart(2, '0') + " " + date.getHours().toString().padStart(2, '0') + ":" + date.getMinutes().toString().padStart(2, '0') + ":" + date.getSeconds().toString().padStart(2, '0')
}

const getStatus = (item:User) : Status => {
if(item.suspended) {
return {status: "Suspended", color: "red"}
}
if (localAuthDisabled && item.oidcID == "" && !item.provisioned) {
return {status: "Local Auth Disabled", color: "yellow"}
}
return {status: "Active", color: "green"}
}

const rows = data.map((item:User) => (
<Table.Tr key={item.id}>
Expand Down Expand Up @@ -148,8 +158,8 @@ export function ListUsers({localAuthDisabled}:Props) {
: null}
</Table.Td>
<Table.Td>
<Badge color={userStatus[item.suspended ? "suspended" : localAuthDisabled && item.oidcID == "" ? "localAuthDisabled" : "active"]} variant="light">
{item.suspended ? "Suspended" : localAuthDisabled && item.oidcID == "" ? "Local Auth Disabled" : "Active"}
<Badge color={getStatus(item).color} variant="light">
{getStatus(item).status}
</Badge>
</Table.Td>
<Table.Td>
Expand Down

0 comments on commit b2e926f

Please sign in to comment.