Skip to content

Commit 3bdd165

Browse files
UI improvements (#58)
* Kern Table in refinery * Heuristic statistics * Updated heuristics statistics with tooltips * Submodules updated * Submodules updated * Submodules update * javascript * PR comments * Submodules merge --------- Co-authored-by: LennartSchmidtKern <[email protected]>
1 parent abc9295 commit 3bdd165

File tree

33 files changed

+199
-323
lines changed

33 files changed

+199
-323
lines changed

src/components/models-download/AddModelDownloadModal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ import { useDispatch, useSelector } from "react-redux";
77
import { useCallback, useEffect, useState } from "react";
88
import { dateAsUTCDate } from "@/submodules/javascript-functions/date-parser";
99
import { extentModelsDownloaded, selectModelsDownloaded } from "@/src/reduxStore/states/pages/models-downloaded";
10-
import { ModelsDownloaded, ModelsDownloadedStatus } from "@/src/types/components/models-downloaded/models-downloaded";
10+
import { ModelsDownloaded } from "@/src/types/components/models-downloaded/models-downloaded";
1111
import { CacheEnum, selectCachedValue } from "@/src/reduxStore/states/cachedValues";
1212
import KernDropdown from "@/submodules/react-components/components/KernDropdown";
1313
import { modelProviderDownloadModel } from "@/src/services/base/misc";
1414
import { PlatformType } from "@/src/types/components/projects/projectId/settings/embeddings";
15+
import { ModelsDownloadedStatus } from "@/submodules/javascript-functions/enums/enums";
1516

1617
const ACCEPT_BUTTON = { buttonCaption: 'Accept', useButton: true };
1718

src/components/models-download/ModelsDownload.tsx

Lines changed: 19 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { selectModelsDownloaded, setModelsDownloaded } from "@/src/reduxStore/states/pages/models-downloaded";
2-
import { ModelsDownloaded, ModelsDownloadedStatus } from "@/src/types/components/models-downloaded/models-downloaded";
32
import { Tooltip } from "@nextui-org/react";
43
import { IconAlertTriangleFilled, IconArrowLeft, IconCircleCheckFilled, IconExternalLink, IconLoader, IconPlus, IconTrash } from "@tabler/icons-react";
54
import { useRouter } from "next/router";
6-
import { useCallback, useEffect } from "react";
5+
import { useCallback, useEffect, useState } from "react";
76
import { useDispatch, useSelector } from "react-redux";
8-
import LoadingIcon from "../shared/loading/LoadingIcon";
7+
import LoadingIcon from "../../../submodules/react-components/components/LoadingIcon";
98
import { openModal, setModalStates } from "@/src/reduxStore/states/modal";
109
import { ModalEnum } from "@/src/types/shared/modal";
1110
import { selectIsAdmin, selectOrganizationId } from "@/src/reduxStore/states/general";
@@ -16,17 +15,30 @@ import DeleteModelDownloadModal from "./DeleteModelDownloadModal";
1615
import { useWebsocket } from "@/submodules/react-components/hooks/web-socket/useWebsocket";
1716
import { getModelProviderInfo } from "@/src/services/base/project";
1817
import { Application, CurrentPage } from "@/submodules/react-components/hooks/web-socket/constants";
18+
import { MODELS_DOWNLOAD_TABLE_COLUMNS, prepareTableBodyModelsDownload } from "@/src/util/table-preparations/models-download";
19+
import KernTable from "@/submodules/react-components/components/kern-table/KernTable";
1920

2021
export default function ModelsDownload() {
2122
const router = useRouter();
2223
const dispatch = useDispatch();
2324
const isAdmin = useSelector(selectIsAdmin);
2425
const modelsDownloaded = useSelector(selectModelsDownloaded);
2526

27+
const [preparedValues, setPreparedValues] = useState([]);
28+
2629
useEffect(() => {
2730
refetchModels();
2831
}, []);
2932

33+
useEffect(() => {
34+
if (!modelsDownloaded) return;
35+
setPreparedValues(prepareTableBodyModelsDownload(modelsDownloaded, openDeleteModal, isAdmin));
36+
}, [modelsDownloaded]);
37+
38+
function openDeleteModal(model) {
39+
dispatch(setModalStates(ModalEnum.DELETE_MODEL_DOWNLOAD, { modelName: model.name, open: true }));
40+
}
41+
3042
function refetchModels() {
3143
getModelProviderInfo((res) => {
3244
dispatch(setModelsDownloaded(res));
@@ -58,79 +70,10 @@ export default function ModelsDownload() {
5870
<div className="mt-1">
5971
<div className="inline-block min-w-full align-middle">
6072
<div className="overflow-hidden shadow ring-1 ring-black ring-opacity-5 md:rounded-lg">
61-
<table className="min-w-full divide-y divide-gray-300">
62-
<thead className="bg-gray-50">
63-
<tr>
64-
<th scope="col"
65-
className="px-3 py-2 text-center text-xs font-medium uppercase tracking-wide text-gray-500">
66-
Name</th>
67-
<th scope="col"
68-
className="px-3 py-2 text-center text-xs font-medium uppercase tracking-wide text-gray-500">
69-
Revision</th>
70-
<th scope="col"
71-
className="px-3 py-2 text-center text-xs font-medium uppercase tracking-wide text-gray-500">
72-
Link</th>
73-
<th scope="col"
74-
className="px-3 py-2 text-center text-xs font-medium uppercase tracking-wide text-gray-500">
75-
Download date</th>
76-
<th scope="col"
77-
className="px-3 py-2 text-center text-xs font-medium uppercase tracking-wide text-gray-500">
78-
Size</th>
79-
<th scope="col"
80-
className="px-3 py-2 text-center text-xs font-medium uppercase tracking-wide text-gray-500">
81-
Status</th>
82-
<th scope="col"
83-
className="px-3 py-2 text-center text-xs font-medium uppercase tracking-wide text-gray-500">
84-
</th>
85-
</tr>
86-
</thead>
87-
<tbody className="divide-y divide-gray-200">
88-
{modelsDownloaded && modelsDownloaded.map((model: ModelsDownloaded, index: number) => (
89-
<tr key={model.name} className={`${index % 2 != 0 ? 'bg-gray-50' : 'bg-white'}`}>
90-
<td className="text-center px-3 py-2 text-sm text-gray-500">
91-
<span className="inline-block mr-2">{model.name}</span>
92-
</td>
93-
<td className="text-center px-3 py-2 text-sm text-gray-500">
94-
{model.revision ? model.revision : '-'}
95-
</td>
96-
<td className="text-center px-3 py-2 text-sm text-gray-500">
97-
<div className="flex justify-center">
98-
{model.link && <a href={model.link} target="_blank">
99-
<IconExternalLink className="h-5 w-5" />
100-
</a>}
101-
</div>
102-
</td>
103-
<td className="whitespace-nowrap text-center px-3 py-2 text-sm text-gray-500">
104-
{model.date != '0' && (model.status === ModelsDownloadedStatus.FINISHED || model.status === ModelsDownloadedStatus.DOWNLOADING) ? model.parseDate : '-'}
105-
{model.status === ModelsDownloadedStatus.INITIALIZING && <>{model.date}</>}
106-
</td>
107-
<td className="whitespace-nowrap text-center px-3 py-2 text-sm text-gray-500">
108-
{model.status === ModelsDownloadedStatus.FINISHED ? model.sizeFormatted : '-'}
109-
</td>
110-
<td className="whitespace-nowrap text-center px-3 py-2 text-sm text-gray-500">
111-
<div className="flex justify-center">
112-
{model.status === ModelsDownloadedStatus.FINISHED && <Tooltip content={TOOLTIPS_DICT.GENERAL.SUCCESSFULLY_CREATED} color="invert" placement="top" className="cursor-auto">
113-
<IconCircleCheckFilled className="h-6 w-6 text-green-500" />
114-
</Tooltip>}
115-
{model.status === ModelsDownloadedStatus.FAILED && <Tooltip content={TOOLTIPS_DICT.GENERAL.ERROR} color="invert" placement="top" className="cursor-auto">
116-
<IconAlertTriangleFilled className="h-6 w-6 text-red-500" />
117-
</Tooltip>}
118-
{model.status === ModelsDownloadedStatus.DOWNLOADING && <Tooltip content={TOOLTIPS_DICT.GENERAL.DOWNLOADING} color="invert" placement="top" className="cursor-auto">
119-
<LoadingIcon />
120-
</Tooltip>}
121-
{model.status === ModelsDownloadedStatus.INITIALIZING && <Tooltip content={TOOLTIPS_DICT.GENERAL.INITIALIZING} color="invert" placement="top" className="cursor-auto">
122-
<IconLoader className="h-6 w-6 text-gray-500" />
123-
</Tooltip>}
124-
</div>
125-
</td>
126-
<td className="whitespace-nowrap text-center px-3 py-2 text-sm text-gray-500">
127-
{isAdmin && <IconTrash onClick={() => dispatch(setModalStates(ModalEnum.DELETE_MODEL_DOWNLOAD, { modelName: model.name, open: true }))}
128-
className="h-6 w-6 text-red-700 cursor-pointer" />}
129-
</td>
130-
</tr>
131-
))}
132-
</tbody>
133-
</table>
73+
<KernTable
74+
headers={MODELS_DOWNLOAD_TABLE_COLUMNS}
75+
values={preparedValues}
76+
/>
13477
</div>
13578
</div>
13679
</div>

src/components/projects/projectId/attributes/attributeId/AttributeCalculations.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { getPythonFunctionRegExMatch, toPythonFunctionName } from "@/submodules/
1818
import DangerZone from "@/src/components/shared/danger-zone/DangerZone";
1919
import { DangerZoneEnum } from "@/src/types/shared/danger-zone";
2020
import ContainerLogs from "@/src/components/shared/logs/ContainerLogs";
21-
import LoadingIcon from "@/src/components/shared/loading/LoadingIcon";
21+
import LoadingIcon from "@/submodules/react-components/components/LoadingIcon";
2222
import { debounceTime, distinctUntilChanged, fromEvent, timer } from "rxjs";
2323
import { TOOLTIPS_DICT } from "@/src/util/tooltip-constants";
2424
import { selectAllUsers, selectOrganizationId, setComments } from "@/src/reduxStore/states/general";

src/components/projects/projectId/attributes/attributeId/ExecutionContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import LoadingIcon from "@/src/components/shared/loading/LoadingIcon";
1+
import LoadingIcon from "@/submodules/react-components/components/LoadingIcon";
22
import { setModalStates } from "@/src/reduxStore/states/modal";
33
import { selectProjectId } from "@/src/reduxStore/states/project";
44
import { ExecutionContainerProps, SampleRecord } from "@/src/types/components/projects/projectId/settings/attribute-calculation";

src/components/projects/projectId/data-browser/DataBrowserRecords.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Slice } from '@/submodules/javascript-functions/enums/enums';
77
import { Tooltip } from '@nextui-org/react';
88
import { IconAdjustments, IconAlertTriangleFilled, IconChartCircles, IconFilter, IconFilterOff, IconTriangleFilled } from '@tabler/icons-react';
99
import { useDispatch, useSelector } from 'react-redux';
10-
import LoadingIcon from '@/src/components/shared/loading/LoadingIcon';
10+
import LoadingIcon from '@/submodules/react-components/components/LoadingIcon';
1111
import { selectVisibleAttributesHeuristics } from '@/src/reduxStore/states/pages/settings';
1212
import RecordList from './RecordList';
1313
import { useRouter } from 'next/router';

src/components/projects/projectId/edit-records/SyncRecordsModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import LoadingIcon from "@/src/components/shared/loading/LoadingIcon";
1+
import LoadingIcon from "@/submodules/react-components/components/LoadingIcon";
22
import Modal from "@/src/components/shared/modal/Modal";
33
import { selectModal, setModalStates } from "@/src/reduxStore/states/modal";
44
import { selectProjectId } from "@/src/reduxStore/states/project";

src/components/projects/projectId/heuristics/heuristicId/active-learning/ActiveLearning.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { CommentDataManager } from "@/src/util/classes/comments";
2727
import { InformationSourceCodeLookup, InformationSourceExamples } from "@/src/util/classes/heuristics";
2828
import { getInformationSourceTemplate } from "@/src/util/components/projects/projectId/heuristics/heuristics-helper";
2929
import KernDropdown from "@/submodules/react-components/components/KernDropdown";
30-
import LoadingIcon from "@/src/components/shared/loading/LoadingIcon";
30+
import LoadingIcon from "@/submodules/react-components/components/LoadingIcon";
3131
import { useWebsocket } from "@/submodules/react-components/hooks/web-socket/useWebsocket";
3232
import { getAllComments } from "@/src/services/base/comment";
3333
import { getLabelingTasksByProjectId } from "@/src/services/base/project";

src/components/projects/projectId/heuristics/heuristicId/labeling-function/CalculationProgress.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import LoadingIcon from "@/src/components/shared/loading/LoadingIcon";
1+
import LoadingIcon from "@/submodules/react-components/components/LoadingIcon";
22
import { selectHeuristic } from "@/src/reduxStore/states/pages/heuristics";
33
import { Status } from "@/src/types/shared/statuses";
44
import { TOOLTIPS_DICT } from "@/src/util/tooltip-constants";

src/components/projects/projectId/heuristics/heuristicId/labeling-function/LabelingFunction.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { InformationSourceCodeLookup, InformationSourceExamples } from "@/src/ut
2929
import { getInformationSourceTemplate } from "@/src/util/components/projects/projectId/heuristics/heuristics-helper";
3030
import KernDropdown from "@/submodules/react-components/components/KernDropdown";
3131
import { Attribute } from "@/src/types/components/projects/projectId/settings/data-schema";
32-
import LoadingIcon from "@/src/components/shared/loading/LoadingIcon";
32+
import LoadingIcon from "@/submodules/react-components/components/LoadingIcon";
3333
import { parseContainerLogsData } from "@/submodules/javascript-functions/logs-parser";
3434
import { useWebsocket } from "@/submodules/react-components/hooks/web-socket/useWebsocket";
3535
import { getAllComments } from "@/src/services/base/comment";

src/components/projects/projectId/heuristics/heuristicId/shared/HeuristicRunButtons.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import LoadingIcon from "@/src/components/shared/loading/LoadingIcon";
1+
import LoadingIcon from "@/submodules/react-components/components/LoadingIcon";
22
import { selectHeuristic } from "@/src/reduxStore/states/pages/heuristics";
33
import { selectProjectId } from "@/src/reduxStore/states/project";
44
import { createTask } from "@/src/services/base/heuristic";

0 commit comments

Comments
 (0)