diff --git a/app/log/goInventorize.log b/app/log/goInventorize.log index c2655b8..b7bb475 100644 --- a/app/log/goInventorize.log +++ b/app/log/goInventorize.log @@ -78,3 +78,37 @@ {"logtype":"webserver", "pid":"11448", "requestid":"", "status":"200", "method":"GET", "path":"/api/locations​"}​ {"level":"debug","time":"2022-04-02T23:14:39-04:00","message":"Returning Locations: [{ID:1 Name:Location4 Description: CoverPhoto:Location4_cover.png Photos:[Location4_0.png Location4_1.png] Rooms:[{ID:0 Name:Kitchen Description: CoverPhoto:Location4/Kitchen/Kitchen_cover.png Photos:[Location4/Kitchen/Kitchen_0.png] Paint: Notes:Notes For My Room! Cabinets:[] Items:[] SquareFeet:0 LocationID:1 LocationName:Location4}] Notes:Notes for my location! Address: SquareFeet:0 Latitude: Longitude: DatePurchased: PurchasePrice: CurrentValue:} {ID:2 Name:Location6 Description: CoverPhoto:Location6_cover.png Photos:[Location6_0.png Location6_1.png] Rooms:[] Notes:Notes for my location!6 Address: SquareFeet:0 Latitude: Longitude: DatePurchased: PurchasePrice: CurrentValue:} {ID:3 Name:Location10 Description: CoverPhoto:Location10_cover.png Photos:[] Rooms:[] Notes:Notes for my location!10 Address: SquareFeet:0 Latitude: Longitude: DatePurchased: PurchasePrice: CurrentValue:}]"} {"logtype":"webserver", "pid":"11448", "requestid":"", "status":"200", "method":"GET", "path":"/api/locations​"}​ +{"level":"info","time":"2022-04-03T16:13:11-04:00","message":"Configuration loaded successfully..."} +{"level":"debug","time":"2022-04-03T16:13:11-04:00","message":"{Timezone:America/New_York Server:{Port:3500 LocationPhotoDir:./app/photos/locations/} Logger:{Level:debug LoggingFile:./app/log/goInventorize.log} Authentication:{BasicAuth:false UserName:admin Password:password} Development:false}"} +{"level":"info","time":"2022-04-03T16:13:11-04:00","message":"Database and Config loaded, starting webserver..."} +{"logtype":"webserver", "pid":"8168", "requestid":"", "status":"200", "method":"GET", "path":"/api/config​"}​ +{"logtype":"webserver", "pid":"8168", "requestid":"", "status":"200", "method":"GET", "path":"/api/config​"}​ +{"level":"debug","time":"2022-04-03T16:17:29-04:00","message":"Returning Locations: [{ID:1 Name:Location4 Description: CoverPhoto:Location4_cover.png Photos:[Location4_0.png Location4_1.png] Rooms:[{ID:0 Name:Kitchen Description: CoverPhoto:Location4/Kitchen/Kitchen_cover.png Photos:[Location4/Kitchen/Kitchen_0.png] Paint: Notes:Notes For My Room! Cabinets:[] Items:[] SquareFeet:0 LocationID:1 LocationName:Location4}] Notes:Notes for my location! Address: SquareFeet:0 Latitude: Longitude: DatePurchased: PurchasePrice: CurrentValue:} {ID:2 Name:Location6 Description: CoverPhoto:Location6_cover.png Photos:[Location6_0.png Location6_1.png] Rooms:[] Notes:Notes for my location!6 Address: SquareFeet:0 Latitude: Longitude: DatePurchased: PurchasePrice: CurrentValue:} {ID:3 Name:Location10 Description: CoverPhoto:Location10_cover.png Photos:[] Rooms:[] Notes:Notes for my location!10 Address: SquareFeet:0 Latitude: Longitude: DatePurchased: PurchasePrice: CurrentValue:}]"} +{"logtype":"webserver", "pid":"8168", "requestid":"", "status":"200", "method":"GET", "path":"/api/locations​"}​ +{"logtype":"webserver", "pid":"8168", "requestid":"", "status":"304", "method":"GET", "path":"/photos/locations/Location6/Location6_cover.png​"}​ +{"logtype":"webserver", "pid":"8168", "requestid":"", "status":"304", "method":"GET", "path":"/photos/locations/Location10/Location10_cover.png​"}​ +{"level":"debug","time":"2022-04-03T16:17:44-04:00","message":"Returning Locations: [{ID:1 Name:Location4 Description: CoverPhoto:Location4_cover.png Photos:[Location4_0.png Location4_1.png] Rooms:[{ID:0 Name:Kitchen Description: CoverPhoto:Location4/Kitchen/Kitchen_cover.png Photos:[Location4/Kitchen/Kitchen_0.png] Paint: Notes:Notes For My Room! Cabinets:[] Items:[] SquareFeet:0 LocationID:1 LocationName:Location4}] Notes:Notes for my location! Address: SquareFeet:0 Latitude: Longitude: DatePurchased: PurchasePrice: CurrentValue:} {ID:2 Name:Location6 Description: CoverPhoto:Location6_cover.png Photos:[Location6_0.png Location6_1.png] Rooms:[] Notes:Notes for my location!6 Address: SquareFeet:0 Latitude: Longitude: DatePurchased: PurchasePrice: CurrentValue:} {ID:3 Name:Location10 Description: CoverPhoto:Location10_cover.png Photos:[] Rooms:[] Notes:Notes for my location!10 Address: SquareFeet:0 Latitude: Longitude: DatePurchased: PurchasePrice: CurrentValue:}]"} +{"logtype":"webserver", "pid":"8168", "requestid":"", "status":"200", "method":"GET", "path":"/api/locations​"}​ +{"level":"info","time":"2022-04-03T16:18:06-04:00","message":"Getting all Rooms"} +{"logtype":"webserver", "pid":"8168", "requestid":"", "status":"200", "method":"GET", "path":"/api/rooms​"}​ +{"logtype":"webserver", "pid":"8168", "requestid":"", "status":"304", "method":"GET", "path":"/photos/locations/Location4/Kitchen/Kitchen_cover.png​"}​ +{"level":"debug","time":"2022-04-03T16:18:08-04:00","message":"Returning Locations: [{ID:1 Name:Location4 Description: CoverPhoto:Location4_cover.png Photos:[Location4_0.png Location4_1.png] Rooms:[{ID:0 Name:Kitchen Description: CoverPhoto:Location4/Kitchen/Kitchen_cover.png Photos:[Location4/Kitchen/Kitchen_0.png] Paint: Notes:Notes For My Room! Cabinets:[] Items:[] SquareFeet:0 LocationID:1 LocationName:Location4}] Notes:Notes for my location! Address: SquareFeet:0 Latitude: Longitude: DatePurchased: PurchasePrice: CurrentValue:} {ID:2 Name:Location6 Description: CoverPhoto:Location6_cover.png Photos:[Location6_0.png Location6_1.png] Rooms:[] Notes:Notes for my location!6 Address: SquareFeet:0 Latitude: Longitude: DatePurchased: PurchasePrice: CurrentValue:} {ID:3 Name:Location10 Description: CoverPhoto:Location10_cover.png Photos:[] Rooms:[] Notes:Notes for my location!10 Address: SquareFeet:0 Latitude: Longitude: DatePurchased: PurchasePrice: CurrentValue:}]"} +{"logtype":"webserver", "pid":"8168", "requestid":"", "status":"200", "method":"GET", "path":"/api/locations​"}​ +{"logtype":"webserver", "pid":"8168", "requestid":"", "status":"200", "method":"GET", "path":"/api/config​"}​ +{"level":"info","time":"2022-04-03T20:46:19-04:00","message":"Configuration loaded successfully..."} +{"level":"debug","time":"2022-04-03T20:46:19-04:00","message":"{Timezone:America/New_York Server:{Port:3500 LocationPhotoDir:./app/photos/locations/} Logger:{Level:debug LoggingFile:./app/log/goInventorize.log} Authentication:{BasicAuth:false UserName:admin Password:password} Development:false}"} +{"level":"info","time":"2022-04-03T20:46:19-04:00","message":"Database and Config loaded, starting webserver..."} +{"level":"info","time":"2022-04-03T20:46:20-04:00","message":"Configuration loaded successfully..."} +{"level":"debug","time":"2022-04-03T20:46:20-04:00","message":"{Timezone:America/New_York Server:{Port:3500 LocationPhotoDir:./app/photos/locations/} Logger:{Level:debug LoggingFile:./app/log/goInventorize.log} Authentication:{BasicAuth:false UserName:admin Password:password} Development:false}"} +{"level":"info","time":"2022-04-03T20:46:20-04:00","message":"Database and Config loaded, starting webserver..."} +{"logtype":"webserver", "pid":"16808", "requestid":"", "status":"200", "method":"GET", "path":"/api/config​"}​ +{"level":"info","time":"2022-04-03T20:52:11-04:00","message":"Configuration loaded successfully..."} +{"level":"debug","time":"2022-04-03T20:52:11-04:00","message":"{Timezone:America/New_York Server:{Port:3500 LocationPhotoDir:./app/photos/locations/} Logger:{Level:debug LoggingFile:./app/log/goInventorize.log} Authentication:{BasicAuth:false UserName:admin Password:password} Development:false}"} +{"level":"info","time":"2022-04-03T20:52:11-04:00","message":"Database and Config loaded, starting webserver..."} +{"logtype":"webserver", "pid":"19608", "requestid":"", "status":"200", "method":"GET", "path":"/api/config​"}​ +{"logtype":"webserver", "pid":"19608", "requestid":"", "status":"200", "method":"GET", "path":"/api/config​"}​ +{"level":"info","time":"2022-04-03T21:44:35-04:00","message":"Configuration loaded successfully..."} +{"level":"debug","time":"2022-04-03T21:44:35-04:00","message":"{Timezone:America/New_York Server:{Port:3500 LocationPhotoDir:./app/photos/locations/} Logger:{Level:debug LoggingFile:./app/log/goInventorize.log} Authentication:{BasicAuth:false UserName:admin Password:password} Development:false}"} +{"level":"info","time":"2022-04-03T21:44:35-04:00","message":"Database and Config loaded, starting webserver..."} +{"logtype":"webserver", "pid":"1812", "requestid":"", "status":"200", "method":"GET", "path":"/api/config​"}​ +{"logtype":"webserver", "pid":"1812", "requestid":"", "status":"200", "method":"GET", "path":"/api/config​"}​ diff --git a/database_structs.go b/database_structs.go index a62b977..8504fc9 100644 --- a/database_structs.go +++ b/database_structs.go @@ -5,9 +5,6 @@ type Location struct { ID int `storm:"id,increment,index"` Name string `storm:"unique"` Description string - CoverPhoto string // A "cover photo" for the location - Photos []string // A list of additional photos for the location - Rooms []Room Notes string Address string SquareFeet int @@ -16,6 +13,10 @@ type Location struct { DatePurchased string PurchasePrice string CurrentValue string + CoverPhoto string // A "cover photo" for the location + Photos []string // A list of additional photos for the location + Files []string + Rooms []Room } // Room is a containerized area at a location @@ -23,13 +24,13 @@ type Room struct { ID int `storm:"id,increment,index"` Name string Description string + Paint string // Details about the paint + Notes string + SquareFeet int CoverPhoto string // A "cover photo" for the room Photos []string // A list of additional photos for the room - Paint string // Details about the paint - Notes string Cabinets []Cabinet Items []Item - SquareFeet int LocationID int //Which location room is assigned to LocationName string // Location name room belongs to diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 0399985..34ee514 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -2030,14 +2030,13 @@ } }, "@mantine/core": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/@mantine/core/-/core-4.1.1.tgz", - "integrity": "sha512-7eTv/vXKX863ri3c6zVbxozsAeA8B0iN31j3/dKs0K3y5Vd9+cgAy59WQk2RBGRlWdln7gtLnELePyQz+WlXLQ==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/@mantine/core/-/core-4.1.2.tgz", + "integrity": "sha512-7P3dhcTkA6zod7L9kSlIpEr4IcHX31LqFetbmoD/q8TqxBVBS2ckNYTwQaH5o446j2ORKrPZ0r28xBCI+lib8Q==", "requires": { - "@mantine/styles": "4.1.1", + "@mantine/styles": "4.1.2", "@popperjs/core": "^2.9.3", "@radix-ui/react-scroll-area": "^0.1.1", - "clsx": "^1.1.1", "react-popper": "^2.2.5", "react-textarea-autosize": "^8.3.2" } @@ -2053,9 +2052,9 @@ } }, "@mantine/dropzone": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@mantine/dropzone/-/dropzone-4.1.0.tgz", - "integrity": "sha512-ixu9VGg/dX5DO/BhyoSYH+9nwAmBTElBml7efClawMlvYaifhoOnNiEWykESwjGaGa6/tww0qxzd/ddsI9jEVQ==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/@mantine/dropzone/-/dropzone-4.1.2.tgz", + "integrity": "sha512-MhDx5Rez2f35gqISfAcMvdCyZJ1+d8q4U7/KFUFk4/mc3K1T+e9rFhNNO+dmTxX7tzypwzHPEDIWHsqD7kb5Fg==", "requires": { "react-dropzone": "^11.4.2" } @@ -2066,9 +2065,9 @@ "integrity": "sha512-Kh7lJ+JcLynCxpqUDmc5zpj/Jd/ZLpHCKnGM4TnfhV45lRlGhDQQtteKJ99XneYu2s23EhsLXfBIhD4RadHZ8g==" }, "@mantine/hooks": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/@mantine/hooks/-/hooks-4.1.1.tgz", - "integrity": "sha512-uVLVT1Qc7rt3kXy25efUVc509Uv3HPNPMyJaPEGM+o9RWy0k3Mo5Zp3meVfUL7PmjY179RlHmrGtxprdpiDZaA==" + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/@mantine/hooks/-/hooks-4.1.2.tgz", + "integrity": "sha512-ccTD4q7jViYisizjydRkCZdiMrtbC+uxEsZHHjyy/adcK8zOix178bag53OKn5TIFFMH6dXHZmto0IZsVCY1vw==" }, "@mantine/notifications": { "version": "4.1.0", @@ -2080,9 +2079,9 @@ } }, "@mantine/styles": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/@mantine/styles/-/styles-4.1.1.tgz", - "integrity": "sha512-ZTfjqugTrqAQatgmdA0R+smUCIwPZCHykxKA5HwQzuJZh6/9TwaPozdTP7yOKAVyjBDnnAQda2PPZ1Gz1PrXqg==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/@mantine/styles/-/styles-4.1.2.tgz", + "integrity": "sha512-HcBrmKzEV7jbBBxicnHUl/Ol/eS5hrZ4lt4hpoi/yD/VVx0BHolK4LkiHCvoh9vFHHN2o9gQo236LgHbqYMEGA==", "requires": { "@emotion/cache": "^11.7.1", "@emotion/react": "^11.7.1", diff --git a/frontend/package.json b/frontend/package.json index bbb88ad..b6936a7 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -3,11 +3,11 @@ "version": "0.1.0", "private": true, "dependencies": { - "@mantine/core": "^4.1.1", + "@mantine/core": "^4.1.2", "@mantine/dates": "^4.1.1", - "@mantine/dropzone": "^4.1.0", + "@mantine/dropzone": "^4.1.2", "@mantine/form": "^4.1.1", - "@mantine/hooks": "^4.1.1", + "@mantine/hooks": "^4.1.2", "@mantine/notifications": "^4.1.0", "@testing-library/jest-dom": "^5.16.3", "@testing-library/react": "^12.1.4", diff --git a/frontend/src/App.js b/frontend/src/App.js index ac2628e..e960708 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -3,6 +3,7 @@ import { useAtom } from 'jotai'; import HomePage from './components/pages/HomePage'; import Locations from './components/pages/Locations'; import RoomsPage from './components/pages/RoomsPage'; +import LocationForm from './components/forms/LocationForm' import { Routes, Route, useNavigate } from "react-router-dom"; import { Modal, Button, Text, Group, TextInput, Loader, AppShell, MediaQuery } from '@mantine/core'; import { useDebouncedValue, useLocalStorageValue } from '@mantine/hooks'; @@ -72,6 +73,7 @@ function App() { } /> } /> } /> + } /> diff --git a/frontend/src/components/SideBar.js b/frontend/src/components/SideBar.js index 1290a04..5028f9f 100644 --- a/frontend/src/components/SideBar.js +++ b/frontend/src/components/SideBar.js @@ -56,7 +56,7 @@ const useStyles = createStyles((theme) => ({ initiallyOpened: true, links: [ { label: 'View Locations', link: '/locations' }, - { label: 'Forecasts', link: '/' }, + { label: 'Add New Location', link: '/locations/new' }, { label: 'Outlook', link: '/' }, { label: 'Real time', link: '/' }, ], diff --git a/frontend/src/components/forms/LocationForm.js b/frontend/src/components/forms/LocationForm.js index 2d5930e..eb1bc9f 100644 --- a/frontend/src/components/forms/LocationForm.js +++ b/frontend/src/components/forms/LocationForm.js @@ -1,9 +1,12 @@ import React, {useState, useEffect} from 'react'; -import { Text, Title, TextInput, Button, NumberInput, } from '@mantine/core' +import { Text, Title, TextInput, Button, NumberInput, Textarea, Grid, Group, useMantineTheme, MantineTheme } from '@mantine/core' import { DatePicker } from '@mantine/dates'; import { useForm } from '@mantine/form'; import { useAtom } from 'jotai'; import { serverConfigAtom } from '../../state/main' +import { backendAPI } from '../../services/backend-api'; +import { BsCardImage, BsCloudUpload, BsXLg } from 'react-icons/bs' +import { Dropzone, DropzoneStatus, IMAGE_MIME_TYPE, PDF_MIME_TYPE } from '@mantine/dropzone'; @@ -11,13 +14,127 @@ function LocationForm(props) { const {location, modify: bool} = props const [opened, setOpened] = useState(false); const [serverConfig] = useAtom(serverConfigAtom) + const theme = useMantineTheme(); + const form = useForm({ + initialValues: { + Name: '', + Description: '', + Notes: '', + Address: '', + SquareFeet: 0, + Latitude: '', + Longitude: '', + DatePurchased: '', + PurchasePrice: '', + CurrentValue: '', + CoverPhoto: '', + AdditionalPhotos: [], + }, + + validate: { + + }, + }); + + // useEffect(() => { + // console.log("FORM", form) + // }, [form]) + + + const submitNewLocation = (values) => { + console.log("VALUES: ", values) + const formData = new FormData(values) + backendAPI.post("/locations/new", formData).then((result) => { + console.log("result: ", result.data) + }).catch(err => { + console.log("Error adding new location!", err) + }) + } + + function ImageUploadIcon({status, ...props}) { + if (status.accepted) { + return ; + } + + if (status.rejected) { + return ; + } + + return ; + } + + function getIconColor(status, theme) { + return status.accepted + ? theme.colors[theme.primaryColor][theme.colorScheme === 'dark' ? 4 : 6] + : status.rejected + ? theme.colors.red[theme.colorScheme === 'dark' ? 4 : 6] + : theme.colorScheme === 'dark' + ? theme.colors.dark[0] + : theme.colors.gray[7]; + } + + const dropzoneChildren = (status, theme, multiple) => ( + + + +
+ + Drag images here or click to select file{multiple ? "s" : ""} + + + Attach as many files as you like, each file should not exceed 5mb + +
+
+ ); + return ( <> - Location Form - This is the homepage! + Location Form +
submitNewLocation(values))}> + + + + + +