Skip to content

Commit

Permalink
Merge pull request #12 from Maker-Management-Platform/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
EduardoOliveira authored Dec 7, 2023
2 parents 9bd909c + 60f4f1f commit 22c0ee9
Show file tree
Hide file tree
Showing 20 changed files with 231 additions and 171 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ name: Docker
# documentation.

on:
schedule:
- cron: '35 11 * * *'
#schedule:
# - cron: '35 11 * * *'
push:
branches: [ "*" ]
# Publish semver tags as releases.
Expand Down
13 changes: 8 additions & 5 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ import '@mantine/core/styles/Flex.css';
import '@mantine/core/styles/AppShell.css';
import '@mantine/core/styles/Tabs.css';
import '@mantine/dropzone/styles.css';
import {createTheme, MantineProvider} from '@mantine/core';
import {createBrowserRouter, RouterProvider} from "react-router-dom";
import '@mantine/notifications/styles.css';
import { createTheme, MantineProvider } from '@mantine/core';
import { Notifications } from '@mantine/notifications';
import { createBrowserRouter, RouterProvider } from "react-router-dom";

import {routes as projectRoutes} from "./projects/routes.tsx";
import { routes as projectRoutes } from "./projects/routes.tsx";

const theme = createTheme({
/** Put your mantine theme override here */
Expand All @@ -32,7 +34,7 @@ const theme = createTheme({
const router = createBrowserRouter([
{
path: "/",
element: <App/>,
element: <App />,
children: [
{
path: "projects",
Expand All @@ -46,7 +48,8 @@ console.log(router);
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<MantineProvider theme={theme} defaultColorScheme="dark">
<RouterProvider router={router}/>
<Notifications limit={5}/>
<RouterProvider router={router} />
</MantineProvider>
</React.StrictMode>
)
81 changes: 81 additions & 0 deletions src/projects/components/parts/project-form/ProjectForm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { Button, Group, TagsInput, Textarea, TextInput } from "@mantine/core";
import { useForm } from "@mantine/form";
import { Project } from "../../../entities/Project.ts";
import useAxios from "axios-hooks";
import { useContext, useState } from "react";
import { SettingsContext } from "@/core/utils/settingsContext.ts";
import { notifications } from '@mantine/notifications';
type ProjectFormProps = {
project: Project;
onProjectChange: (p: Project) => void;
};

export function ProjectForm({ project, onProjectChange }: ProjectFormProps) {
const { local_backend } = useContext(SettingsContext);
const [{ data, loading, error }, executeSave] = useAxios(
{
method: 'POST'
},
{ manual: true }
)
const form = useForm({
initialValues: {
...project,
},
validate: {
name: (value) => (value.length < 2 ? 'Too short name' : null),
path: (value) => (value.length < 1 ? 'Too short path' : null),
},
});
const onSave = (project: Project) => {
executeSave({
url: `${local_backend}/projects/${project.uuid}`,
data: {
...project,
}
})
.then(({ data }) => {
onProjectChange(data)
notifications.show({
title: 'Great Success!',
message: 'Project updated',
color: 'indigo',
})
})
.catch(({ message }) => {
console.log(message)
notifications.show({
title: 'Ops... Error updating project!',
message,
color: 'red',
autoClose: false
})
});
};

return (
<>
<form onSubmit={form.onSubmit(onSave)}>
<TextInput
mb="sm"
label="Name"
{...form.getInputProps('name')}
/>
<Textarea
mb="sm"
label="Desciption"
{...form.getInputProps('description')}
/>
<TagsInput
mb="sm"
label="Tags"
maxDropdownHeight={200}
{...form.getInputProps('tags')}
/>
<Group justify="flex-end" mt="md">
<Button type="submit" loading={loading}>Submit</Button>
</Group>
</form>
</>
);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Badge, Overlay, Text, Title, TypographyStylesProvider, useMantineTheme} from '@mantine/core';
import classes from './ProjectHeader.module.css';
import {stringToNumber} from "../../../core/utils/color.ts";
import {stringToNumber} from "@/core/utils/color.ts";

type ProjectHeaderProps = {
name: string
Expand Down
86 changes: 0 additions & 86 deletions src/projects/components/project-form/ProjectForm.tsx

This file was deleted.

21 changes: 12 additions & 9 deletions src/projects/components/project-page3/ProjectPage3.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import {useParams} from "react-router-dom";
import { useParams } from "react-router-dom";
import useAxios from "axios-hooks";
import {Project} from "../../entities/Project.ts";
import {useContext, useEffect, useState} from "react";
import {ProjectPageBody} from "./parts/project-page-body/ProjectPageBody.tsx";
import {ProjectHeader} from "../project-header/ProjectHeader.tsx";
import { Project } from "../../entities/Project.ts";
import { useContext, useEffect, useState } from "react";
import { ProjectPageBody } from "./parts/project-page-body/ProjectPageBody.tsx";
import { ProjectHeader } from "@/projects/components/parts/project-header/ProjectHeader.tsx";
import { SettingsContext } from "../../../core/utils/settingsContext.ts";


export function ProjectPage3() {
const {local_backend} = useContext(SettingsContext);
const {id} = useParams();
const { local_backend } = useContext(SettingsContext);
const { id } = useParams();
const [project, setProject] = useState<Project>();

const [{data, loading, error}] = useAxios(
const [{ data, loading, error }] = useAxios(
`${local_backend}/projects/${id}`
);

Expand All @@ -30,7 +30,10 @@ export function ProjectPage3() {
/>
{error && <p>Error!</p>}
{loading && <p>Loading...</p>}
{id && <ProjectPageBody projectUuid={id} project={project}/>}
{id && <ProjectPageBody projectUuid={id} project={project} onProjectChange={(p)=>{
console.log("onProjectChange",p)
setProject(p)
}} />}
</>
)
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { useContext, useEffect, useState } from "react";
import { ModelDetailPane } from "@/assets/components/model/model-detail-pane/ModelDetailPane.tsx";
import { IconPhoto, IconSettings, IconFile3d, IconLayersIntersect, IconFile, IconFiles } from "@tabler/icons-react";
import { useNavigate, useSearchParams } from "react-router-dom";
import { AddAsset } from "../add-asset/AddAsset.tsx";
import { EditProject } from "../edit-project/EditProject.tsx";
import { AddAsset } from "./parts/add-asset/AddAsset.tsx";
import { EditProject } from "./parts/edit-project/EditProject.tsx";
import { Project } from "../../../../entities/Project.ts";
import { SettingsContext } from "@/core/utils/settingsContext.ts";
import { SliceDetailPane } from "@/assets/components/slice/slice-detail-pane/SliceDetailPane.tsx";
Expand All @@ -34,9 +34,10 @@ const assetTypeMap: Map<string, (props: AssetCardProps) => JSX.Element> = new Ma
type ProjectAssetsListProps = {
projectUuid: string;
project?: Project;
onProjectChange: (p: Project) => void;
}

export function ProjectPageBody({ projectUuid, project }: ProjectAssetsListProps) {
export function ProjectPageBody({ projectUuid, project, onProjectChange }: ProjectAssetsListProps) {
const { local_backend } = useContext(SettingsContext);
const navigate = useNavigate();
const [searchParams] = useSearchParams();
Expand Down Expand Up @@ -118,7 +119,7 @@ export function ProjectPageBody({ projectUuid, project }: ProjectAssetsListProps
<AddAsset projectUuid={projectUuid} />
</Tabs.Panel>
<Tabs.Panel value="settings" p={'xs'}>
{project && <EditProject project={project} />}
{project && <EditProject onProjectChange={onProjectChange} project={project} />}
</Tabs.Panel>
</Tabs>
<SimpleGrid cols={(selectedAsset || selectedModels.length > 0) ? 2 : 1} mt={'sm'}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Container, Group, rem, Text} from "@mantine/core";
import {IconPhoto, IconUpload, IconX} from "@tabler/icons-react";
import useAxios from "axios-hooks";
import { useContext } from "react";
import { SettingsContext } from "../../../../../core/utils/settingsContext";
import { SettingsContext } from "@/core/utils/settingsContext";


type AddAssetProps = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Container, Tabs } from "@mantine/core";
import { ProjectForm } from "@/projects/components/parts/project-form/ProjectForm.tsx";
import { Project } from "@/projects/entities/Project.ts";
import { ProjectOprations } from "./parts/project-operations/ProjectOperations";


type EditProjectProps = {
project: Project;
onProjectChange: (p: Project) => void;
}

export function EditProject({ project, onProjectChange }: EditProjectProps) {
return (
<>
<Tabs defaultValue="edit" orientation="vertical" placement="right">
<Tabs.List>
<Tabs.Tab value="edit">Edit</Tabs.Tab>
<Tabs.Tab value="operations">Operations</Tabs.Tab>
</Tabs.List>
<Tabs.Panel value="edit">
<Container>
<ProjectForm project={project} onProjectChange={onProjectChange} />
</Container>
</Tabs.Panel>
<Tabs.Panel value="operations">
<Container>
<ProjectOprations project={project} onProjectChange={onProjectChange} />
</Container>
</Tabs.Panel>
</Tabs>
</>
);
}
Loading

0 comments on commit 22c0ee9

Please sign in to comment.