Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chores: UI Fixes and add default role #161

Merged
merged 6 commits into from
Oct 31, 2023
Merged
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
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="/manifest.json" />

<link rel="stylesheet" href="/fonts/inter.css">

</head>
<body>
<div id="root"></div>
Expand Down
Binary file added public/fonts/Inter-Black.woff
Binary file not shown.
Binary file added public/fonts/Inter-Black.woff2
Binary file not shown.
Binary file added public/fonts/Inter-BlackItalic.woff
Binary file not shown.
Binary file added public/fonts/Inter-BlackItalic.woff2
Binary file not shown.
Binary file added public/fonts/Inter-Bold.woff
Binary file not shown.
Binary file added public/fonts/Inter-Bold.woff2
Binary file not shown.
Binary file added public/fonts/Inter-BoldItalic.woff
Binary file not shown.
Binary file added public/fonts/Inter-BoldItalic.woff2
Binary file not shown.
Binary file added public/fonts/Inter-ExtraBold.woff
Binary file not shown.
Binary file added public/fonts/Inter-ExtraBold.woff2
Binary file not shown.
Binary file added public/fonts/Inter-ExtraBoldItalic.woff
Binary file not shown.
Binary file added public/fonts/Inter-ExtraBoldItalic.woff2
Binary file not shown.
Binary file added public/fonts/Inter-ExtraLight.woff
Binary file not shown.
Binary file added public/fonts/Inter-ExtraLight.woff2
Binary file not shown.
Binary file added public/fonts/Inter-ExtraLightItalic.woff
Binary file not shown.
Binary file added public/fonts/Inter-ExtraLightItalic.woff2
Binary file not shown.
Binary file added public/fonts/Inter-Italic.woff
Binary file not shown.
Binary file added public/fonts/Inter-Italic.woff2
Binary file not shown.
Binary file added public/fonts/Inter-Light.woff
Binary file not shown.
Binary file added public/fonts/Inter-Light.woff2
Binary file not shown.
Binary file added public/fonts/Inter-LightItalic.woff
Binary file not shown.
Binary file added public/fonts/Inter-LightItalic.woff2
Binary file not shown.
Binary file added public/fonts/Inter-Medium.woff
Binary file not shown.
Binary file added public/fonts/Inter-Medium.woff2
Binary file not shown.
Binary file added public/fonts/Inter-MediumItalic.woff
Binary file not shown.
Binary file added public/fonts/Inter-MediumItalic.woff2
Binary file not shown.
Binary file added public/fonts/Inter-Regular.woff
Binary file not shown.
Binary file added public/fonts/Inter-Regular.woff2
Binary file not shown.
Binary file added public/fonts/Inter-SemiBold.woff
Binary file not shown.
Binary file added public/fonts/Inter-SemiBold.woff2
Binary file not shown.
Binary file added public/fonts/Inter-SemiBoldItalic.woff
Binary file not shown.
Binary file added public/fonts/Inter-SemiBoldItalic.woff2
Binary file not shown.
Binary file added public/fonts/Inter-Thin.woff
Binary file not shown.
Binary file added public/fonts/Inter-Thin.woff2
Binary file not shown.
Binary file added public/fonts/Inter-ThinItalic.woff
Binary file not shown.
Binary file added public/fonts/Inter-ThinItalic.woff2
Binary file not shown.
Binary file added public/fonts/Inter-italic.var.woff2
Binary file not shown.
Binary file added public/fonts/Inter-roman.var.woff2
Binary file not shown.
Binary file added public/fonts/Inter.var.woff2
Binary file not shown.
200 changes: 200 additions & 0 deletions public/fonts/inter.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
@font-face {
font-family: 'Inter';
font-style: normal;
font-weight: 100;
font-display: swap;
src: url("Inter-Thin.woff2?v=3.19") format("woff2"),
url("Inter-Thin.woff?v=3.19") format("woff");
}
@font-face {
font-family: 'Inter';
font-style: italic;
font-weight: 100;
font-display: swap;
src: url("Inter-ThinItalic.woff2?v=3.19") format("woff2"),
url("Inter-ThinItalic.woff?v=3.19") format("woff");
}

@font-face {
font-family: 'Inter';
font-style: normal;
font-weight: 200;
font-display: swap;
src: url("Inter-ExtraLight.woff2?v=3.19") format("woff2"),
url("Inter-ExtraLight.woff?v=3.19") format("woff");
}
@font-face {
font-family: 'Inter';
font-style: italic;
font-weight: 200;
font-display: swap;
src: url("Inter-ExtraLightItalic.woff2?v=3.19") format("woff2"),
url("Inter-ExtraLightItalic.woff?v=3.19") format("woff");
}

@font-face {
font-family: 'Inter';
font-style: normal;
font-weight: 300;
font-display: swap;
src: url("Inter-Light.woff2?v=3.19") format("woff2"),
url("Inter-Light.woff?v=3.19") format("woff");
}
@font-face {
font-family: 'Inter';
font-style: italic;
font-weight: 300;
font-display: swap;
src: url("Inter-LightItalic.woff2?v=3.19") format("woff2"),
url("Inter-LightItalic.woff?v=3.19") format("woff");
}

@font-face {
font-family: 'Inter';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url("Inter-Regular.woff2?v=3.19") format("woff2"),
url("Inter-Regular.woff?v=3.19") format("woff");
}
@font-face {
font-family: 'Inter';
font-style: italic;
font-weight: 400;
font-display: swap;
src: url("Inter-Italic.woff2?v=3.19") format("woff2"),
url("Inter-Italic.woff?v=3.19") format("woff");
}

@font-face {
font-family: 'Inter';
font-style: normal;
font-weight: 500;
font-display: swap;
src: url("Inter-Medium.woff2?v=3.19") format("woff2"),
url("Inter-Medium.woff?v=3.19") format("woff");
}
@font-face {
font-family: 'Inter';
font-style: italic;
font-weight: 500;
font-display: swap;
src: url("Inter-MediumItalic.woff2?v=3.19") format("woff2"),
url("Inter-MediumItalic.woff?v=3.19") format("woff");
}

@font-face {
font-family: 'Inter';
font-style: normal;
font-weight: 600;
font-display: swap;
src: url("Inter-SemiBold.woff2?v=3.19") format("woff2"),
url("Inter-SemiBold.woff?v=3.19") format("woff");
}
@font-face {
font-family: 'Inter';
font-style: italic;
font-weight: 600;
font-display: swap;
src: url("Inter-SemiBoldItalic.woff2?v=3.19") format("woff2"),
url("Inter-SemiBoldItalic.woff?v=3.19") format("woff");
}

@font-face {
font-family: 'Inter';
font-style: normal;
font-weight: 700;
font-display: swap;
src: url("Inter-Bold.woff2?v=3.19") format("woff2"),
url("Inter-Bold.woff?v=3.19") format("woff");
}
@font-face {
font-family: 'Inter';
font-style: italic;
font-weight: 700;
font-display: swap;
src: url("Inter-BoldItalic.woff2?v=3.19") format("woff2"),
url("Inter-BoldItalic.woff?v=3.19") format("woff");
}

@font-face {
font-family: 'Inter';
font-style: normal;
font-weight: 800;
font-display: swap;
src: url("Inter-ExtraBold.woff2?v=3.19") format("woff2"),
url("Inter-ExtraBold.woff?v=3.19") format("woff");
}
@font-face {
font-family: 'Inter';
font-style: italic;
font-weight: 800;
font-display: swap;
src: url("Inter-ExtraBoldItalic.woff2?v=3.19") format("woff2"),
url("Inter-ExtraBoldItalic.woff?v=3.19") format("woff");
}

@font-face {
font-family: 'Inter';
font-style: normal;
font-weight: 900;
font-display: swap;
src: url("Inter-Black.woff2?v=3.19") format("woff2"),
url("Inter-Black.woff?v=3.19") format("woff");
}
@font-face {
font-family: 'Inter';
font-style: italic;
font-weight: 900;
font-display: swap;
src: url("Inter-BlackItalic.woff2?v=3.19") format("woff2"),
url("Inter-BlackItalic.woff?v=3.19") format("woff");
}

/* -------------------------------------------------------
Variable font.
Usage:

html { font-family: 'Inter', sans-serif; }
@supports (font-variation-settings: normal) {
html { font-family: 'Inter var', sans-serif; }
}
*/
@font-face {
font-family: 'Inter var';
font-weight: 100 900;
font-display: swap;
font-style: normal;
font-named-instance: 'Regular';
src: url("Inter-roman.var.woff2?v=3.19") format("woff2");
}
@font-face {
font-family: 'Inter var';
font-weight: 100 900;
font-display: swap;
font-style: italic;
font-named-instance: 'Italic';
src: url("Inter-italic.var.woff2?v=3.19") format("woff2");
}


/* --------------------------------------------------------------------------
[EXPERIMENTAL] Multi-axis, single variable font.

Slant axis is not yet widely supported (as of February 2019) and thus this
multi-axis single variable font is opt-in rather than the default.

When using this, you will probably need to set font-variation-settings
explicitly, e.g.

* { font-variation-settings: "slnt" 0deg }
.italic { font-variation-settings: "slnt" 10deg }

*/
@font-face {
font-family: 'Inter var experimental';
font-weight: 100 900;
font-display: swap;
font-style: oblique 0deg 10deg;
src: url("Inter.var.woff2?v=3.19") format("woff2");
}
2 changes: 2 additions & 0 deletions src/@types/parseable/api/about.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ export type AboutData = {
llmActive: boolean;
llmProvider: string;
uiVersion: string;
grpcPort: number;
oidcActive: boolean;
};
1 change: 1 addition & 0 deletions src/api/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const USERS_LIST_URL = `${API_V1}/user`;
export const USER_URL = (username: string) => `${USERS_LIST_URL}/${username}`;
export const USER_ROLES_URL = (username: string) => `${USER_URL(username)}/role`;
export const USER_PASSWORD_URL = (username: string) => `${USER_URL(username)}/generate-new-password`;
export const DEFAULT_ROLE_URL = `${API_V1}/role/default`;

// Roles Management
export const ROLES_LIST_URL = `${API_V1}/role`;
Expand Down
28 changes: 18 additions & 10 deletions src/api/roles.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
import { Axios } from "./axios";
import { ROLE_URL, ROLES_LIST_URL } from "./constants";
import { Axios } from './axios';
import { DEFAULT_ROLE_URL, ROLE_URL, ROLES_LIST_URL } from './constants';

export const getRoles = () => {
return Axios().get(ROLES_LIST_URL);
}
return Axios().get(ROLES_LIST_URL);
};

export const deleteRole = (roleName: string) => {
return Axios().delete(ROLE_URL(roleName));
}
return Axios().delete(ROLE_URL(roleName));
};

export const putRole = (roleName: string, privilege: object[]) => {
return Axios().put(ROLE_URL(roleName), privilege);
}
return Axios().put(ROLE_URL(roleName), privilege);
};

export const getRole = (roleName: string) => {
return Axios().get(ROLE_URL(roleName));
}
return Axios().get(ROLE_URL(roleName));
};

export const putDeafultRole = (roleName: string) => {
return Axios().put(DEFAULT_ROLE_URL, roleName, { headers: { 'Content-Type': 'application/json' } });
};

export const getDefaultRole = () => {
return Axios().get(DEFAULT_ROLE_URL);
};
4 changes: 2 additions & 2 deletions src/components/Navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import { NAVBAR_WIDTH } from '@/constants/theme';
const baseURL = import.meta.env.VITE_PARSEABLE_URL ?? '/';

const links = [
{ icon: IconZoomCode, label: 'Query', pathname: '/query', requiredAccess: ['Query', 'GetSchema'] },
{ icon: IconTableShortcut, label: 'Logs', pathname: '/logs', requiredAccess: ['Query', 'GetSchema'] },
{ icon: IconZoomCode, label: 'SQL', pathname: '/query', requiredAccess: ['Query', 'GetSchema'] },
{ icon: IconTableShortcut, label: 'Explore', pathname: '/logs', requiredAccess: ['Query', 'GetSchema'] },
{ icon: IconReportAnalytics, label: 'Stats', pathname: '/stats', requiredAccess: ['GetStats'] },
{ icon: IconSettings, label: 'Config', pathname: '/config', requiredAccess: ['PutAlert'] },
];
Expand Down
6 changes: 3 additions & 3 deletions src/components/Navbar/infoModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type InfoModalProps = {
const InfoModal: FC<InfoModalProps> = (props) => {
const { opened, close } = props;
const {
state: { subLLMActive },
state: { subInstanceConfig },
} = useHeaderContext();

const { data, loading, error, getAbout, resetData } = useGetAbout();
Expand All @@ -83,9 +83,9 @@ const InfoModal: FC<InfoModalProps> = (props) => {

useEffect(() => {
if (data) {
subLLMActive.set(data.llmActive);
subInstanceConfig.set(data);
}
}, [data?.llmActive]);
}, [data]);

const { classes } = useInfoModalStyles();
const {
Expand Down
57 changes: 57 additions & 0 deletions src/hooks/useGetDefaultRole.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { StatusCodes } from 'http-status-codes';
import useMountedState from './useMountedState';
import { getDefaultRole } from '@/api/roles';
import { notifications } from '@mantine/notifications';
import { IconFileAlert } from '@tabler/icons-react';

export const useGetDefaultRole = () => {
const [data, setData] = useMountedState<string | null>(null);
const [error, setError] = useMountedState<string | null>(null);
const [loading, setLoading] = useMountedState<boolean>(false);

const getDefaultOidc = async () => {
try {
setLoading(true);
setError(null);
const res = await getDefaultRole();

switch (res.status) {
case StatusCodes.OK: {
const streams = res.data;

setData(streams);
break;
}
default: {
setError('Failed to get default role');
notifications.show({
id: 'get-default-role',
color: 'red',
title: 'Error occurred',
message: 'Failed to get default role',
icon: <IconFileAlert size="1rem" />,
autoClose: 2000,
});
}
}
} catch {
setError('Failed to get default role');
notifications.show({
id: 'get-default-role',
color: 'red',
title: 'Error occurred',
message: 'Failed to get default role',
icon: <IconFileAlert size="1rem" />,
autoClose: 2000,
});
} finally {
setLoading(false);
}
};

const resetData = () => {
setData(null);
};

return { data, error, loading, getDefaultOidc, resetData };
};
14 changes: 12 additions & 2 deletions src/hooks/useGetLogStreamList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,17 @@ export const useGetLogStreamList = () => {

switch (res.status) {
case StatusCodes.OK: {
const streams = res.data;
const streams = res.data.sort((a, b) => {
const nameA = a.name.toUpperCase();
const nameB = b.name.toUpperCase();
if (nameA < nameB) {
return -1;
}
if (nameA > nameB) {
return 1;
}
return 0;
});

setData(streams);
if (streams && Boolean(streams.length)) {
Expand Down Expand Up @@ -65,7 +75,7 @@ export const useGetLogStreamList = () => {
setError('Unauthorized');
Cookies.remove('session');
Cookies.remove('username');

notifications.update({
id: 'load-data',
color: 'red',
Expand Down
Loading