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

Feature/upload config and blob from UI #803

Merged
merged 72 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
7848576
add basic routing for upload config and blob and add basic configUplo…
postrowinski Apr 19, 2023
7f362a9
add full working with api config form TODO: try to refactor to react-…
postrowinski Apr 20, 2023
bd9303e
change layout for config and file upload
postrowinski Apr 20, 2023
4f14d5a
change native form states to react-hook-forms in UploadConfig
postrowinski Apr 21, 2023
07272c7
rewrite UploadFile to react-hook-forms and separate UploadDropzone an…
postrowinski Apr 21, 2023
ad34346
add upload blob form
postrowinski Apr 24, 2023
6a24951
Merge remote-tracking branch 'origin/master' into feature/upload-conf…
postrowinski Apr 24, 2023
9b7ceae
init commit to rewrite api to typescript
postrowinski May 2, 2023
ec5fc96
add some types to api
postrowinski May 2, 2023
3501921
add full types to api
postrowinski May 4, 2023
3bc6c20
uncomment include in tsconfig
postrowinski May 4, 2023
5faf4ce
init commit adding types to commons/ui
postrowinski May 5, 2023
e4bdc35
add some rewrite components in commons/ui
postrowinski May 5, 2023
9484233
add rest commons/ui components
postrowinski May 8, 2023
40051fd
Merge branch 'master' into feature/upload-config-and-blob-from-ui
postrowinski May 9, 2023
c541752
Merge branch 'master' into feature/add-types-to-common-ui
postrowinski May 9, 2023
f9bec86
add almost all type to commons folder (only without plugins)
postrowinski May 10, 2023
d5d6114
fix rest types in commons folder
postrowinski May 10, 2023
db245a1
fix import in jest write hooks test and type rest missing types in co…
postrowinski May 11, 2023
62b6884
Merge remote-tracking branch 'origin/master' into feature/add-types-t…
postrowinski May 11, 2023
d97dbaa
add types to react-select and fix conflicts after merge
postrowinski May 11, 2023
240bfa3
prettier fix
postrowinski May 11, 2023
fc739c4
init commit
postrowinski May 11, 2023
1c78a91
rewrite all components/Profile files
postrowinski May 12, 2023
0fa647e
Merge branch 'master' into feature/add-types-to-components-profile
postrowinski May 12, 2023
649cff8
fix conflicts
postrowinski May 12, 2023
dd1312a
Merge branch 'master' into feature/add-types-to-common-ui
postrowinski May 12, 2023
aa5dbe9
fix conflicts
postrowinski May 12, 2023
31c33e7
init commit to rewrite recent view
postrowinski May 12, 2023
55685dc
add types to RecentView
postrowinski May 15, 2023
8ac2ae3
add types to components/remotes
postrowinski May 15, 2023
9c62f4f
fix api context
postrowinski May 16, 2023
f1d0421
Merge remote-tracking branch 'origin/master' into feature/add-types-t…
postrowinski May 16, 2023
417563c
remove jsx file
postrowinski May 16, 2023
9ae0139
rewrite components/richAttributes to typescript
postrowinski May 16, 2023
d6f07c6
rewrite to tsx some components/settings views
postrowinski May 17, 2023
2fc5e12
rewrite some attribites component in components/setting
postrowinski May 18, 2023
7abc57e
add many new rewrited components in settings
postrowinski May 19, 2023
a17457f
add rest rewrited compoents/setting to tsx
postrowinski May 22, 2023
73f9572
fix GroupOutletContext
postrowinski May 22, 2023
7131656
Merge branch 'master' into feature/add-types-to-common-ui
postrowinski May 22, 2023
ffb0b58
fix conflicts
postrowinski May 22, 2023
0c3f19e
add tsc lint
postrowinski May 23, 2023
b750126
Merge branch 'feature/add-types-to-common-ui' into feature/add-types-…
postrowinski May 23, 2023
2c5a2e8
fix conflicts after merge with commons/ui
postrowinski May 23, 2023
f4fb2e9
Merge branch 'feature/add-types-to-components-profile' into feature/a…
postrowinski May 23, 2023
9a9299e
fix conflicts after merge with components/profile
postrowinski May 23, 2023
2590105
Merge branch 'feature/add-types-to-components-recent-view' into featu…
postrowinski May 23, 2023
b3172f4
Merge branch 'feature/add-types-to-components-remote' into feature/ad…
postrowinski May 23, 2023
0ff301e
Merge branch 'feature/add-types-to-components-rich-attribute' into fe…
postrowinski May 23, 2023
341f74d
fix conflits after merge with richAttributes
postrowinski May 23, 2023
b66fd6e
rewrite components/showobject/actions
postrowinski May 24, 2023
5b110de
rewrite most of components/showObject
postrowinski May 25, 2023
50aaf92
rewrite rest components/showobjects
postrowinski May 26, 2023
d3a129a
rewrite some components in components folder
postrowinski May 29, 2023
f049941
rewrite components/showobject/actions
postrowinski May 24, 2023
0f59c68
rewrite most of components/showObject
postrowinski May 25, 2023
ed3a68b
rewrite rest components/showobjects
postrowinski May 26, 2023
c9f834b
Fix imports in CommentBox.jsx
psrok1 May 30, 2023
8db6b23
rewrite all files in components folder
postrowinski Jun 1, 2023
878bbd7
fixes after review to components/showobject
postrowinski Jun 1, 2023
24b1231
fix conficts after merge showobject into component
postrowinski Jun 1, 2023
03aa9ca
prettier fix
postrowinski Jun 1, 2023
e485239
fix prettier and add format script
postrowinski Jun 1, 2023
08a9e8a
change rest default import and rewrite app file to tsx
postrowinski Jun 2, 2023
6e8df93
Merge branch 'feature/add-types-to-app-file-and-check-all-imports' in…
postrowinski Jun 2, 2023
9bb8789
rewrite components in config blob file to typescript
postrowinski Jun 5, 2023
8b25d17
Merge branch 'master' into feature/upload-config-and-blob-from-ui
postrowinski Jun 19, 2023
feb625c
fix errors after merge conflicts
postrowinski Jun 19, 2023
7808120
Merge branch 'master' into feature/upload-config-and-blob-from-ui
psrok1 Oct 10, 2023
6d1f929
fixes after review
postrowinski Oct 11, 2023
4ed8dbd
Merge branch 'master' into feature/upload-config-and-blob-from-ui
psrok1 Nov 2, 2023
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
45 changes: 33 additions & 12 deletions mwdb/web/src/commons/api/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,14 @@ import {
UpdateUserResponse,
UploadFileResponse,
UserRequestPasswordChangeResponse,
UploadFileRequest,
UploadConfigRequest,
UploadConfigResponse,
UploadBlobRequest,
UploadBlobResponse,
} from "@mwdb-web/types/api";
import {
Attribute,
Capability,
Comment,
CreateUser,
ObjectLegacyType,
ObjectType,
Expand Down Expand Up @@ -587,28 +590,44 @@ async function requestZipFileDownloadLink(id: string): Promise<string> {
return `${baseURL}/file/${id}/download/zip?token=${response.data.token}`;
}

function uploadFile(
file: File,
parent: string,
upload_as: string,
attributes: Attribute[],
fileUploadTimeout: number,
share3rdParty: boolean
): UploadFileResponse {
function uploadFile(body: UploadFileRequest): UploadFileResponse {
const {
file,
parent,
shareWith,
attributes,
fileUploadTimeout,
share3rdParty,
} = body;
let formData = new FormData();
formData.append("file", file);
formData.append("file", file!);
formData.append(
"options",
JSON.stringify({
parent: parent || null,
upload_as: upload_as,
upload_as: shareWith,
attributes: attributes,
share_3rd_party: share3rdParty,
})
);
return axios.post(`/file`, formData, { timeout: fileUploadTimeout });
}

function uploadBlob(body: UploadBlobRequest): UploadBlobResponse {
const { name, shareWith, parent, type } = body;
return axios.post(`/blob`, {
...body,
blob_name: name,
blob_type: type,
upload_as: shareWith,
parent: parent || null,
});
}

function uploadConfig(body: UploadConfigRequest): UploadConfigResponse {
return axios.post("/config", body);
}

function getRemoteNames(): GetRemoteNamesResponse {
return axios.get("/remote");
}
Expand Down Expand Up @@ -845,6 +864,8 @@ export const api = {
requestFileDownloadLink,
requestZipFileDownloadLink,
uploadFile,
uploadBlob,
uploadConfig,
getRemoteNames,
pushObjectRemote,
pullObjectRemote,
Expand Down
26 changes: 23 additions & 3 deletions mwdb/web/src/commons/navigation/AppRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import { RequiresAuth, RequiresCapability } from "../ui";
import { RecentSamplesView } from "@mwdb-web/components/File/Views/RecentSamplesView";
import { RecentConfigsView } from "@mwdb-web/components/Config/Views/RecentConfigsView";
import { RecentBlobsView } from "@mwdb-web/components/Blob/Views/RecentBlobsView";
import { SearchView } from "@mwdb-web/components/Views/SearchView";
import { UploadView } from "@mwdb-web/components/Views/UploadView";
import { ConfigStatsView } from "@mwdb-web/components/Config/Views/ConfigStatsView";
import { DocsView } from "@mwdb-web/components/Views/DocsView";
import { ShowSampleView } from "@mwdb-web/components/Views/ShowSampleView";
Expand Down Expand Up @@ -60,6 +58,10 @@ import { AttributeView } from "@mwdb-web/components/Settings/Views/AttributeView
import { AttributeDetailsView } from "@mwdb-web/components/Settings/Views/AttributeDetailsView";
import { AttributesPermissionsView } from "@mwdb-web/components/Settings/Views/AttributePermissionsView";
import { AttributeEditTemplateView } from "@mwdb-web/components/Settings/Views/AttributeEditTemplateView";
import { UploadConfigView } from "@mwdb-web/components/Upload/Views/UploadConfigView";
import { UploadBlobView } from "@mwdb-web/components/Upload/Views/UploadBlobView";
import { UploadFileView } from "@mwdb-web/components/Upload/Views/UploadFileView";
import { SearchView } from "@mwdb-web/components/Views/SearchView";

export function AppRoutes() {
return (
Expand All @@ -81,7 +83,25 @@ export function AppRoutes() {
path="upload"
element={
<RequiresCapability capability={Capability.addingFiles}>
<UploadView />
<UploadFileView />
</RequiresCapability>
}
/>
<Route
path="blob_upload"
element={
<RequiresCapability capability={Capability.addingBlobs}>
<UploadBlobView />
</RequiresCapability>
}
/>
<Route
path="config_upload"
element={
<RequiresCapability
capability={Capability.addingConfigs}
>
<UploadConfigView />
</RequiresCapability>
}
/>
Expand Down
4 changes: 3 additions & 1 deletion mwdb/web/src/commons/ui/Label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ type Props = {
required?: boolean;
htmlFor?: string;
className?: string;
children?: React.ReactNode;
};

export function Label(props: Props) {
const { label, required, htmlFor, className } = props;
const { label, required, htmlFor, className, children } = props;

const setClassName = useCallback(() => {
let result = "";
Expand All @@ -24,6 +25,7 @@ export function Label(props: Props) {
return (
<label className={setClassName()} htmlFor={htmlFor}>
{label}
{children}
</label>
);
}
12 changes: 4 additions & 8 deletions mwdb/web/src/commons/ui/NavDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,32 @@ type Props = {
export function NavDropdown(props: Props) {
if (!props.elements.length) return <div />;
return (
<li className="nav-item dropdown">
<div className="nav-item dropdown">
<a
className="nav-link dropdown-toggle"
href="#dropdown"
role="button"
data-toggle="dropdown"
>
{props.icon ? (
{props.icon && (
<FontAwesomeIcon
className="navbar-icon"
icon={props.icon}
/>
) : (
[]
)}
{props.title}
{props.badge ? (
{props.badge && (
<span
className="badge badge-pill badge-warning"
style={{ marginLeft: "8px" }}
>
{props.badge}
</span>
) : (
[]
)}
</a>
<div className="dropdown-menu" aria-labelledby="navbarDropdown">
{props.elements}
</div>
</li>
</div>
);
}
2 changes: 1 addition & 1 deletion mwdb/web/src/components/DagreD3Plot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function DagreD3Plot(props: Props) {
function NodeComponent() {
const Node = props.nodeComponent as any;
useEffect(() => {
resolve();
resolve(undefined);
}, []);
return <Node node={node} remotePath={remotePath} />;
}
Expand Down
5 changes: 2 additions & 3 deletions mwdb/web/src/components/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ import { ConfigContext } from "@mwdb-web/commons/config";
import { fromPlugins, Extendable } from "@mwdb-web/commons/plugins";
import { ConfirmationModal, NavDropdown } from "@mwdb-web/commons/ui";
import { useRemote, useRemotePath } from "@mwdb-web/commons/remotes";
import { Capability } from "@mwdb-web/types/types";

import logo from "../assets/logo.png";
import { AdminNav } from "./AdminNav";
import { RemoteDropdown } from "./RemoteDropdown";
import { UploadButton } from "./UploadButton";
import { Upload } from "./Upload/common/Upload";

export function Navigation() {
const auth = useContext(AuthContext);
Expand Down Expand Up @@ -60,7 +59,7 @@ export function Navigation() {
</Link>
</li>
<li className="nav-item">
<UploadButton />
<Upload />
</li>
</Extendable>
) : (
Expand Down
4 changes: 1 addition & 3 deletions mwdb/web/src/components/ShowObject/common/RelationsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import { useContext } from "react";
import { useSearchParams } from "react-router-dom";

import { faProjectDiagram, faSearch } from "@fortawesome/free-solid-svg-icons";

import { RelationsPlotView } from "../../Views/RelationsPlotView";

import { ObjectContext } from "@mwdb-web/commons/context";
import { ObjectAction, ObjectTab } from "@mwdb-web/commons/ui";
import { RelationsPlotView } from "@mwdb-web/components/Views/RelationsPlotView";

export function RelationsTab() {
const context = useContext(ObjectContext);
Expand Down
Loading