frontend to backend communication working, starting on locations page
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# go-api-template
|
# goInventorize
|
||||||
|
|
||||||
Template for go-fiber with react frontend.
|
Home Inventory app
|
||||||
|
|
||||||
## Developing
|
## Developing
|
||||||
|
|
||||||
|
@@ -7,6 +7,7 @@ env:
|
|||||||
RELEASE_MSG: "First official release of the project"
|
RELEASE_MSG: "First official release of the project"
|
||||||
GO_VERSION: 1.16.3
|
GO_VERSION: 1.16.3
|
||||||
GI_SERVER_PORT: 3500
|
GI_SERVER_PORT: 3500
|
||||||
|
GI_BASICAUTH: false
|
||||||
REACT_APP_BACKEND_PORT: 3500 #Frontend can't find backend port unless we specify it (for DEV only, does not work when built obv)
|
REACT_APP_BACKEND_PORT: 3500 #Frontend can't find backend port unless we specify it (for DEV only, does not work when built obv)
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
@@ -78,7 +79,7 @@ tasks:
|
|||||||
|
|
||||||
run-backend:
|
run-backend:
|
||||||
env:
|
env:
|
||||||
|
GI_BASIC_AUTH: false
|
||||||
GI_DEVELOPMENT: false
|
GI_DEVELOPMENT: false
|
||||||
# TZ: "America/New_York"
|
# TZ: "America/New_York"
|
||||||
cmds:
|
cmds:
|
||||||
|
@@ -8,7 +8,7 @@ Logger:
|
|||||||
loggingFile: "./app/log/goInventorize.log"
|
loggingFile: "./app/log/goInventorize.log"
|
||||||
|
|
||||||
Authentication:
|
Authentication:
|
||||||
BasicAuth: true
|
BasicAuth: false
|
||||||
UserName: "admin"
|
UserName: "admin"
|
||||||
Password: "password"
|
Password: "password"
|
||||||
|
|
||||||
|
@@ -70,3 +70,136 @@
|
|||||||
{"level":"info","time":"2021-11-13T22:11:01-05:00","message":"Configuration loaded successfully..."}
|
{"level":"info","time":"2021-11-13T22:11:01-05:00","message":"Configuration loaded successfully..."}
|
||||||
{"level":"debug","time":"2021-11-13T22:11:01-05:00","message":"{Timezone:America/New_York Server:{Port:3500 LocationPhotoDir:./app/photos/locations/} Logger:{Level:debug LoggingFile:./app/log/goInventorize.log} Authentication:{BasicAuth:true UserName:admin Password:password} Development:false}"}
|
{"level":"debug","time":"2021-11-13T22:11:01-05:00","message":"{Timezone:America/New_York Server:{Port:3500 LocationPhotoDir:./app/photos/locations/} Logger:{Level:debug LoggingFile:./app/log/goInventorize.log} Authentication:{BasicAuth:true UserName:admin Password:password} Development:false}"}
|
||||||
{"level":"info","time":"2021-11-13T22:11:01-05:00","message":"Database and Config loaded, starting webserver..."}
|
{"level":"info","time":"2021-11-13T22:11:01-05:00","message":"Database and Config loaded, starting webserver..."}
|
||||||
|
{"level":"info","time":"2021-11-14T14:26:43-05:00","message":"Configuration loaded successfully..."}
|
||||||
|
{"level":"debug","time":"2021-11-14T14:26:43-05:00","message":"{Timezone:America/New_York Server:{Port:3500 LocationPhotoDir:./app/photos/locations/} Logger:{Level:debug LoggingFile:./app/log/goInventorize.log} Authentication:{BasicAuth:true UserName:admin Password:password} Development:false}"}
|
||||||
|
{"level":"info","time":"2021-11-14T14:26:43-05:00","message":"Database and Config loaded, starting webserver..."}
|
||||||
|
{"level":"info","time":"2021-11-14T14:26:46-05:00","message":"Configuration loaded successfully..."}
|
||||||
|
{"level":"debug","time":"2021-11-14T14:26:46-05:00","message":"{Timezone:America/New_York Server:{Port:3500 LocationPhotoDir:./app/photos/locations/} Logger:{Level:debug LoggingFile:./app/log/goInventorize.log} Authentication:{BasicAuth:true UserName:admin Password:password} Development:false}"}
|
||||||
|
{"level":"info","time":"2021-11-14T14:26:46-05:00","message":"Database and Config loaded, starting webserver..."}
|
||||||
|
{"level":"info","time":"2021-11-14T18:43:36-05:00","message":"Configuration loaded successfully..."}
|
||||||
|
{"level":"debug","time":"2021-11-14T18:43:36-05:00","message":"{Timezone:America/New_York Server:{Port:3500 LocationPhotoDir:./app/photos/locations/} Logger:{Level:debug LoggingFile:./app/log/goInventorize.log} Authentication:{BasicAuth:true UserName:admin Password:password} Development:false}"}
|
||||||
|
{"level":"info","time":"2021-11-14T18:43:36-05:00","message":"Database and Config loaded, starting webserver..."}
|
||||||
|
{"level":"info","time":"2021-11-14T20:29:03-05:00","message":"Configuration loaded successfully..."}
|
||||||
|
{"level":"debug","time":"2021-11-14T20:29:03-05:00","message":"{Timezone:America/New_York Server:{Port:3500 LocationPhotoDir:./app/photos/locations/} Logger:{Level:debug LoggingFile:./app/log/goInventorize.log} Authentication:{BasicAuth:true UserName:admin Password:password} Development:false}"}
|
||||||
|
{"level":"info","time":"2021-11-14T20:29:03-05:00","message":"Database and Config loaded, starting webserver..."}
|
||||||
|
{"level":"info","time":"2021-11-14T20:32:07-05:00","message":"Configuration loaded successfully..."}
|
||||||
|
{"level":"debug","time":"2021-11-14T20:32:07-05:00","message":"{Timezone:America/New_York Server:{Port:3500 LocationPhotoDir:./app/photos/locations/} Logger:{Level:debug LoggingFile:./app/log/goInventorize.log} Authentication:{BasicAuth:true UserName:admin Password:password} Development:false}"}
|
||||||
|
{"level":"info","time":"2021-11-14T20:32:07-05:00","message":"Database and Config loaded, starting webserver..."}
|
||||||
|
{"logtype":"webserver", "pid":"30264", "requestid":"", "status":"200", "method":"GET", "path":"/config"}
|
||||||
|
{"logtype":"webserver", "pid":"30264", "requestid":"", "status":"200", "method":"GET", "path":"/config"}
|
||||||
|
{"logtype":"webserver", "pid":"30264", "requestid":"", "status":"200", "method":"GET", "path":"/config"}
|
||||||
|
{"logtype":"webserver", "pid":"30264", "requestid":"", "status":"200", "method":"GET", "path":"/config"}
|
||||||
|
{"logtype":"webserver", "pid":"30264", "requestid":"", "status":"200", "method":"GET", "path":"/config"}
|
||||||
|
{"logtype":"webserver", "pid":"30264", "requestid":"", "status":"200", "method":"GET", "path":"/config"}
|
||||||
|
{"logtype":"webserver", "pid":"30264", "requestid":"", "status":"200", "method":"GET", "path":"/config"}
|
||||||
|
{"logtype":"webserver", "pid":"30264", "requestid":"", "status":"200", "method":"GET", "path":"/config"}
|
||||||
|
{"logtype":"webserver", "pid":"30264", "requestid":"", "status":"200", "method":"GET", "path":"/config"}
|
||||||
|
{"level":"info","time":"2021-11-14T21:04:27-05:00","message":"Configuration loaded successfully..."}
|
||||||
|
{"level":"debug","time":"2021-11-14T21:04:27-05:00","message":"{Timezone:America/New_York Server:{Port:3500 LocationPhotoDir:./app/photos/locations/} Logger:{Level:debug LoggingFile:./app/log/goInventorize.log} Authentication:{BasicAuth:true UserName:admin Password:password} Development:false}"}
|
||||||
|
{"level":"info","time":"2021-11-14T21:04:27-05:00","message":"Database and Config loaded, starting webserver..."}
|
||||||
|
{"logtype":"webserver", "pid":"22768", "requestid":"", "status":"200", "method":"GET", "path":"/config"}
|
||||||
|
{"logtype":"webserver", "pid":"22768", "requestid":"", "status":"200", "method":"GET", "path":"/config"}
|
||||||
|
{"logtype":"webserver", "pid":"22768", "requestid":"", "status":"200", "method":"GET", "path":"/config"}
|
||||||
|
{"logtype":"webserver", "pid":"22768", "requestid":"", "status":"200", "method":"GET", "path":"/config"}
|
||||||
|
{"level":"info","time":"2021-11-14T21:25:49-05:00","message":"Configuration loaded successfully..."}
|
||||||
|
{"level":"debug","time":"2021-11-14T21:25:49-05:00","message":"{Timezone:America/New_York Server:{Port:3500 LocationPhotoDir:./app/photos/locations/} Logger:{Level:debug LoggingFile:./app/log/goInventorize.log} Authentication:{BasicAuth:true UserName:admin Password:password} Development:false}"}
|
||||||
|
{"level":"info","time":"2021-11-14T21:25:49-05:00","message":"Database and Config loaded, starting webserver..."}
|
||||||
|
{"level":"info","time":"2021-11-14T21:25:50-05:00","message":"Configuration loaded successfully..."}
|
||||||
|
{"level":"debug","time":"2021-11-14T21:25:50-05:00","message":"{Timezone:America/New_York Server:{Port:3500 LocationPhotoDir:./app/photos/locations/} Logger:{Level:debug LoggingFile:./app/log/goInventorize.log} Authentication:{BasicAuth:true UserName:admin Password:password} Development:false}"}
|
||||||
|
{"level":"info","time":"2021-11-14T21:25:50-05:00","message":"Database and Config loaded, starting webserver..."}
|
||||||
|
{"level":"info","time":"2021-12-08T21:33:50-05:00","message":"Configuration loaded successfully..."}
|
||||||
|
{"level":"debug","time":"2021-12-08T21:33:50-05:00","message":"{Timezone:America/New_York Server:{Port:3500 LocationPhotoDir:./app/photos/locations/} Logger:{Level:debug LoggingFile:./app/log/goInventorize.log} Authentication:{BasicAuth:true UserName:admin Password:password} Development:false}"}
|
||||||
|
{"level":"info","time":"2021-12-08T21:33:50-05:00","message":"Database and Config loaded, starting webserver..."}
|
||||||
|
{"level":"info","time":"2021-12-08T21:43:38-05:00","message":"Configuration loaded successfully..."}
|
||||||
|
{"level":"debug","time":"2021-12-08T21:43:38-05:00","message":"{Timezone:America/New_York Server:{Port:3500 LocationPhotoDir:./app/photos/locations/} Logger:{Level:debug LoggingFile:./app/log/goInventorize.log} Authentication:{BasicAuth:true UserName:admin Password:password} Development:false}"}
|
||||||
|
{"level":"info","time":"2021-12-08T21:43:38-05:00","message":"Database and Config loaded, starting webserver..."}
|
||||||
|
{"level":"info","time":"2021-12-08T22:23:34-05:00","message":"Configuration loaded successfully..."}
|
||||||
|
{"level":"debug","time":"2021-12-08T22:23:34-05: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":"2021-12-08T22:23:34-05:00","message":"Database and Config loaded, starting webserver..."}
|
||||||
|
{"level":"info","time":"2021-12-08T22:24:24-05:00","message":"Configuration loaded successfully..."}
|
||||||
|
{"level":"debug","time":"2021-12-08T22:24:24-05: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":"2021-12-08T22:24:24-05:00","message":"Database and Config loaded, starting webserver..."}
|
||||||
|
{"level":"info","time":"2021-12-08T22:25:14-05:00","message":"Configuration loaded successfully..."}
|
||||||
|
{"level":"debug","time":"2021-12-08T22:25:14-05: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":"2021-12-08T22:25:14-05:00","message":"Database and Config loaded, starting webserver..."}
|
||||||
|
{"level":"info","time":"2021-12-08T22:26:43-05:00","message":"Configuration loaded successfully..."}
|
||||||
|
{"level":"debug","time":"2021-12-08T22:26:43-05: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":"2021-12-08T22:26:43-05:00","message":"Database and Config loaded, starting webserver..."}
|
||||||
|
{"level":"info","time":"2021-12-08T22:28:59-05:00","message":"Configuration loaded successfully..."}
|
||||||
|
{"level":"debug","time":"2021-12-08T22:28:59-05: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":"2021-12-08T22:28:59-05:00","message":"Database and Config loaded, starting webserver..."}
|
||||||
|
{"level":"info","time":"2021-12-08T22:31:41-05:00","message":"Configuration loaded successfully..."}
|
||||||
|
{"level":"debug","time":"2021-12-08T22:31:41-05: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":"2021-12-08T22:31:41-05:00","message":"Database and Config loaded, starting webserver..."}
|
||||||
|
{"logtype":"webserver", "pid":"9108", "requestid":"", "status":"200", "method":"GET", "path":"/config"}
|
||||||
|
{"logtype":"webserver", "pid":"9108", "requestid":"", "status":"200", "method":"GET", "path":"/config"}
|
||||||
|
{"level":"debug","time":"2021-12-08T22:32:18-05:00","message":"Returning Locations: [{ID:1 Name:Location1 Description: CoverPhoto:./app/photos/locations/Location1/2020-05-23 11_08_43-Montage_Sword_LHL.png Photos:[./app/photos/locations/Location1/2020-05-22 22_47_24-ForlornOutcast - Unreal Editor.png ./app/photos/locations/Location1/2020-05-22 20_57_56-Wwise.png] Rooms:[] Notes:Notes for my location!}]"}
|
||||||
|
{"logtype":"webserver", "pid":"9108", "requestid":"", "status":"200", "method":"GET", "path":"/locations"}
|
||||||
|
{"level":"debug","time":"2021-12-08T22:34:40-05:00","message":"Returning Locations: [{ID:1 Name:Location1 Description: CoverPhoto:./app/photos/locations/Location1/2020-05-23 11_08_43-Montage_Sword_LHL.png Photos:[./app/photos/locations/Location1/2020-05-22 22_47_24-ForlornOutcast - Unreal Editor.png ./app/photos/locations/Location1/2020-05-22 20_57_56-Wwise.png] Rooms:[] Notes:Notes for my location!}]"}
|
||||||
|
{"logtype":"webserver", "pid":"9108", "requestid":"", "status":"200", "method":"GET", "path":"/locations"}
|
||||||
|
{"level":"debug","time":"2021-12-08T22:41:06-05:00","message":"Returning Locations: [{ID:1 Name:Location1 Description: CoverPhoto:./app/photos/locations/Location1/2020-05-23 11_08_43-Montage_Sword_LHL.png Photos:[./app/photos/locations/Location1/2020-05-22 22_47_24-ForlornOutcast - Unreal Editor.png ./app/photos/locations/Location1/2020-05-22 20_57_56-Wwise.png] Rooms:[] Notes:Notes for my location!}]"}
|
||||||
|
{"logtype":"webserver", "pid":"9108", "requestid":"", "status":"200", "method":"GET", "path":"/locations"}
|
||||||
|
{"level":"debug","time":"2021-12-08T22:41:32-05:00","message":"Returning Locations: [{ID:1 Name:Location1 Description: CoverPhoto:./app/photos/locations/Location1/2020-05-23 11_08_43-Montage_Sword_LHL.png Photos:[./app/photos/locations/Location1/2020-05-22 22_47_24-ForlornOutcast - Unreal Editor.png ./app/photos/locations/Location1/2020-05-22 20_57_56-Wwise.png] Rooms:[] Notes:Notes for my location!}]"}
|
||||||
|
{"logtype":"webserver", "pid":"9108", "requestid":"", "status":"200", "method":"GET", "path":"/locations"}
|
||||||
|
{"level":"debug","time":"2021-12-08T22:41:48-05:00","message":"Returning Locations: [{ID:1 Name:Location1 Description: CoverPhoto:./app/photos/locations/Location1/2020-05-23 11_08_43-Montage_Sword_LHL.png Photos:[./app/photos/locations/Location1/2020-05-22 22_47_24-ForlornOutcast - Unreal Editor.png ./app/photos/locations/Location1/2020-05-22 20_57_56-Wwise.png] Rooms:[] Notes:Notes for my location!}]"}
|
||||||
|
{"logtype":"webserver", "pid":"9108", "requestid":"", "status":"200", "method":"GET", "path":"/locations"}
|
||||||
|
{"level":"debug","time":"2021-12-08T22:50:22-05:00","message":"Returning Locations: [{ID:1 Name:Location1 Description: CoverPhoto:./app/photos/locations/Location1/2020-05-23 11_08_43-Montage_Sword_LHL.png Photos:[./app/photos/locations/Location1/2020-05-22 22_47_24-ForlornOutcast - Unreal Editor.png ./app/photos/locations/Location1/2020-05-22 20_57_56-Wwise.png] Rooms:[] Notes:Notes for my location!}]"}
|
||||||
|
{"logtype":"webserver", "pid":"9108", "requestid":"", "status":"200", "method":"GET", "path":"/locations"}
|
||||||
|
{"level":"debug","time":"2021-12-08T22:50:32-05:00","message":"Returning Locations: [{ID:1 Name:Location1 Description: CoverPhoto:./app/photos/locations/Location1/2020-05-23 11_08_43-Montage_Sword_LHL.png Photos:[./app/photos/locations/Location1/2020-05-22 22_47_24-ForlornOutcast - Unreal Editor.png ./app/photos/locations/Location1/2020-05-22 20_57_56-Wwise.png] Rooms:[] Notes:Notes for my location!}]"}
|
||||||
|
{"logtype":"webserver", "pid":"9108", "requestid":"", "status":"200", "method":"GET", "path":"/locations"}
|
||||||
|
{"level":"debug","time":"2021-12-08T22:50:51-05:00","message":"Returning Locations: [{ID:1 Name:Location1 Description: CoverPhoto:./app/photos/locations/Location1/2020-05-23 11_08_43-Montage_Sword_LHL.png Photos:[./app/photos/locations/Location1/2020-05-22 22_47_24-ForlornOutcast - Unreal Editor.png ./app/photos/locations/Location1/2020-05-22 20_57_56-Wwise.png] Rooms:[] Notes:Notes for my location!}]"}
|
||||||
|
{"logtype":"webserver", "pid":"9108", "requestid":"", "status":"200", "method":"GET", "path":"/locations"}
|
||||||
|
{"level":"debug","time":"2021-12-08T22:54:01-05:00","message":"Returning Locations: [{ID:1 Name:Location1 Description: CoverPhoto:./app/photos/locations/Location1/2020-05-23 11_08_43-Montage_Sword_LHL.png Photos:[./app/photos/locations/Location1/2020-05-22 22_47_24-ForlornOutcast - Unreal Editor.png ./app/photos/locations/Location1/2020-05-22 20_57_56-Wwise.png] Rooms:[] Notes:Notes for my location!}]"}
|
||||||
|
{"logtype":"webserver", "pid":"9108", "requestid":"", "status":"200", "method":"GET", "path":"/locations"}
|
||||||
|
{"logtype":"webserver", "pid":"9108", "requestid":"", "status":"404", "method":"GET", "path":"/photos/locations/Location1/testCover.png"}
|
||||||
|
{"logtype":"webserver", "pid":"9108", "requestid":"", "status":"200", "method":"GET", "path":"/favicon.ico"}
|
||||||
|
{"level":"info","time":"2021-12-08T22:54:57-05:00","message":"Configuration loaded successfully..."}
|
||||||
|
{"level":"debug","time":"2021-12-08T22:54:57-05: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":"2021-12-08T22:54:57-05:00","message":"Database and Config loaded, starting webserver..."}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"200", "method":"GET", "path":"/photos/locations/Location1/testCover.png"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"200", "method":"GET", "path":"/favicon.ico"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"200", "method":"GET", "path":"/config"}
|
||||||
|
{"level":"debug","time":"2021-12-08T22:55:08-05:00","message":"Returning Locations: [{ID:1 Name:Location1 Description: CoverPhoto:./app/photos/locations/Location1/2020-05-23 11_08_43-Montage_Sword_LHL.png Photos:[./app/photos/locations/Location1/2020-05-22 22_47_24-ForlornOutcast - Unreal Editor.png ./app/photos/locations/Location1/2020-05-22 20_57_56-Wwise.png] Rooms:[] Notes:Notes for my location!}]"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"200", "method":"GET", "path":"/locations"}
|
||||||
|
{"level":"debug","time":"2021-12-08T22:56:17-05:00","message":"Returning Locations: [{ID:1 Name:Location1 Description: CoverPhoto:./app/photos/locations/Location1/2020-05-23 11_08_43-Montage_Sword_LHL.png Photos:[./app/photos/locations/Location1/2020-05-22 22_47_24-ForlornOutcast - Unreal Editor.png ./app/photos/locations/Location1/2020-05-22 20_57_56-Wwise.png] Rooms:[] Notes:Notes for my location!}]"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"200", "method":"GET", "path":"/locations"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"200", "method":"GET", "path":"/config"}
|
||||||
|
{"level":"debug","time":"2021-12-08T22:56:23-05:00","message":"Returning Locations: [{ID:1 Name:Location1 Description: CoverPhoto:./app/photos/locations/Location1/2020-05-23 11_08_43-Montage_Sword_LHL.png Photos:[./app/photos/locations/Location1/2020-05-22 22_47_24-ForlornOutcast - Unreal Editor.png ./app/photos/locations/Location1/2020-05-22 20_57_56-Wwise.png] Rooms:[] Notes:Notes for my location!}]"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"200", "method":"GET", "path":"/locations"}
|
||||||
|
{"level":"debug","time":"2021-12-08T22:58:22-05:00","message":"Returning Locations: [{ID:1 Name:Location1 Description: CoverPhoto:./app/photos/locations/Location1/2020-05-23 11_08_43-Montage_Sword_LHL.png Photos:[./app/photos/locations/Location1/2020-05-22 22_47_24-ForlornOutcast - Unreal Editor.png ./app/photos/locations/Location1/2020-05-22 20_57_56-Wwise.png] Rooms:[] Notes:Notes for my location!}]"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"200", "method":"GET", "path":"/locations"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"200", "method":"GET", "path":"/config"}
|
||||||
|
{"level":"debug","time":"2021-12-08T22:58:26-05:00","message":"Returning Locations: [{ID:1 Name:Location1 Description: CoverPhoto:./app/photos/locations/Location1/2020-05-23 11_08_43-Montage_Sword_LHL.png Photos:[./app/photos/locations/Location1/2020-05-22 22_47_24-ForlornOutcast - Unreal Editor.png ./app/photos/locations/Location1/2020-05-22 20_57_56-Wwise.png] Rooms:[] Notes:Notes for my location!}]"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"200", "method":"GET", "path":"/locations"}
|
||||||
|
{"level":"debug","time":"2021-12-08T23:01:05-05:00","message":"Returning Locations: [{ID:1 Name:Location1 Description: CoverPhoto:./app/photos/locations/Location1/2020-05-23 11_08_43-Montage_Sword_LHL.png Photos:[./app/photos/locations/Location1/2020-05-22 22_47_24-ForlornOutcast - Unreal Editor.png ./app/photos/locations/Location1/2020-05-22 20_57_56-Wwise.png] Rooms:[] Notes:Notes for my location!}]"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"200", "method":"GET", "path":"/locations"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"200", "method":"GET", "path":"/config"}
|
||||||
|
{"level":"debug","time":"2021-12-08T23:01:39-05:00","message":"Returning Locations: [{ID:1 Name:Location1 Description: CoverPhoto:./app/photos/locations/Location1/2020-05-23 11_08_43-Montage_Sword_LHL.png Photos:[./app/photos/locations/Location1/2020-05-22 22_47_24-ForlornOutcast - Unreal Editor.png ./app/photos/locations/Location1/2020-05-22 20_57_56-Wwise.png] Rooms:[] Notes:Notes for my location!}]"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"200", "method":"GET", "path":"/locations"}
|
||||||
|
{"level":"debug","time":"2021-12-08T23:03:09-05:00","message":"Returning Locations: [{ID:1 Name:Location1 Description: CoverPhoto:./app/photos/locations/Location1/2020-05-23 11_08_43-Montage_Sword_LHL.png Photos:[./app/photos/locations/Location1/2020-05-22 22_47_24-ForlornOutcast - Unreal Editor.png ./app/photos/locations/Location1/2020-05-22 20_57_56-Wwise.png] Rooms:[] Notes:Notes for my location!}]"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"200", "method":"GET", "path":"/locations"}
|
||||||
|
{"level":"debug","time":"2021-12-08T23:04:22-05:00","message":"Returning Locations: [{ID:1 Name:Location1 Description: CoverPhoto:./app/photos/locations/Location1/2020-05-23 11_08_43-Montage_Sword_LHL.png Photos:[./app/photos/locations/Location1/2020-05-22 22_47_24-ForlornOutcast - Unreal Editor.png ./app/photos/locations/Location1/2020-05-22 20_57_56-Wwise.png] Rooms:[] Notes:Notes for my location!}]"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"200", "method":"GET", "path":"/locations"}
|
||||||
|
{"level":"debug","time":"2021-12-08T23:04:45-05:00","message":"Returning Locations: [{ID:1 Name:Location1 Description: CoverPhoto:./app/photos/locations/Location1/2020-05-23 11_08_43-Montage_Sword_LHL.png Photos:[./app/photos/locations/Location1/2020-05-22 22_47_24-ForlornOutcast - Unreal Editor.png ./app/photos/locations/Location1/2020-05-22 20_57_56-Wwise.png] Rooms:[] Notes:Notes for my location!}]"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"200", "method":"GET", "path":"/locations"}
|
||||||
|
{"level":"debug","time":"2021-12-08T23:06:26-05:00","message":"Returning Locations: [{ID:1 Name:Location1 Description: CoverPhoto:./app/photos/locations/Location1/2020-05-23 11_08_43-Montage_Sword_LHL.png Photos:[./app/photos/locations/Location1/2020-05-22 22_47_24-ForlornOutcast - Unreal Editor.png ./app/photos/locations/Location1/2020-05-22 20_57_56-Wwise.png] Rooms:[] Notes:Notes for my location!}]"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"200", "method":"GET", "path":"/locations"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"404", "method":"GET", "path":"/photos/locations/testName2/testString2"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"500", "method":"GET", "path":"/photos/locations//"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"304", "method":"GET", "path":"/photos/locations/Location1/testCover.png"}
|
||||||
|
{"level":"debug","time":"2021-12-08T23:07:31-05:00","message":"Returning Locations: [{ID:1 Name:Location1 Description: CoverPhoto:./app/photos/locations/Location1/2020-05-23 11_08_43-Montage_Sword_LHL.png Photos:[./app/photos/locations/Location1/2020-05-22 22_47_24-ForlornOutcast - Unreal Editor.png ./app/photos/locations/Location1/2020-05-22 20_57_56-Wwise.png] Rooms:[] Notes:Notes for my location!}]"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"200", "method":"GET", "path":"/locations"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"200", "method":"GET", "path":"/config"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"404", "method":"GET", "path":"/photos/locations/testName2/testString2"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"500", "method":"GET", "path":"/photos/locations//"}
|
||||||
|
{"level":"debug","time":"2021-12-08T23:07:55-05:00","message":"Returning Locations: [{ID:1 Name:Location1 Description: CoverPhoto:./app/photos/locations/Location1/2020-05-23 11_08_43-Montage_Sword_LHL.png Photos:[./app/photos/locations/Location1/2020-05-22 22_47_24-ForlornOutcast - Unreal Editor.png ./app/photos/locations/Location1/2020-05-22 20_57_56-Wwise.png] Rooms:[] Notes:Notes for my location!}]"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"200", "method":"GET", "path":"/locations"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"200", "method":"GET", "path":"/config"}
|
||||||
|
{"level":"debug","time":"2021-12-08T23:08:02-05:00","message":"Returning Locations: [{ID:1 Name:Location1 Description: CoverPhoto:./app/photos/locations/Location1/2020-05-23 11_08_43-Montage_Sword_LHL.png Photos:[./app/photos/locations/Location1/2020-05-22 22_47_24-ForlornOutcast - Unreal Editor.png ./app/photos/locations/Location1/2020-05-22 20_57_56-Wwise.png] Rooms:[] Notes:Notes for my location!}]"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"200", "method":"GET", "path":"/locations"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"200", "method":"GET", "path":"/config"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"200", "method":"GET", "path":"/config"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"200", "method":"GET", "path":"/config"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"200", "method":"GET", "path":"/config"}
|
||||||
|
{"level":"debug","time":"2021-12-08T23:10:33-05:00","message":"Returning Locations: [{ID:1 Name:Location1 Description: CoverPhoto:./app/photos/locations/Location1/2020-05-23 11_08_43-Montage_Sword_LHL.png Photos:[./app/photos/locations/Location1/2020-05-22 22_47_24-ForlornOutcast - Unreal Editor.png ./app/photos/locations/Location1/2020-05-22 20_57_56-Wwise.png] Rooms:[] Notes:Notes for my location!}]"}
|
||||||
|
{"logtype":"webserver", "pid":"67756", "requestid":"", "status":"200", "method":"GET", "path":"/locations"}
|
||||||
|
Before Width: | Height: | Size: 349 KiB After Width: | Height: | Size: 349 KiB |
21
frontend/apis/backend.js
Normal file
21
frontend/apis/backend.js
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import React, {useState, useEffect, useContext } from 'react';
|
||||||
|
import APIContext from '../../App';
|
||||||
|
import { Text } from '@mantine/core'
|
||||||
|
import useSwr from 'swr';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function BackendAPI() {
|
||||||
|
|
||||||
|
const serverConfig = useContext(APIContext);
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Text>This is the homepage!</Text>
|
||||||
|
</>
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default BackendAPI;
|
5
frontend/package-lock.json
generated
5
frontend/package-lock.json
generated
@@ -10672,11 +10672,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/klona/-/klona-2.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/klona/-/klona-2.0.4.tgz",
|
||||||
"integrity": "sha512-ZRbnvdg/NxqzC7L9Uyqzf4psi1OM4Cuc+sJAkQPjO6XkQIJTNbfK2Rsmbw8fx1p2mkZdp2FZYo2+LwXYY/uwIA=="
|
"integrity": "sha512-ZRbnvdg/NxqzC7L9Uyqzf4psi1OM4Cuc+sJAkQPjO6XkQIJTNbfK2Rsmbw8fx1p2mkZdp2FZYo2+LwXYY/uwIA=="
|
||||||
},
|
},
|
||||||
"ky": {
|
|
||||||
"version": "0.28.7",
|
|
||||||
"resolved": "https://registry.npmjs.org/ky/-/ky-0.28.7.tgz",
|
|
||||||
"integrity": "sha512-a23i6qSr/ep15vdtw/zyEQIDLoUaKDg9Jf04CYl/0ns/wXNYna26zJpI+MeIFaPeDvkrjLPrKtKOiiI3IE53RQ=="
|
|
||||||
},
|
|
||||||
"language-subtag-registry": {
|
"language-subtag-registry": {
|
||||||
"version": "0.3.21",
|
"version": "0.3.21",
|
||||||
"resolved": "https://registry.npmjs.org/language-subtag-registry/-/language-subtag-registry-0.3.21.tgz",
|
"resolved": "https://registry.npmjs.org/language-subtag-registry/-/language-subtag-registry-0.3.21.tgz",
|
||||||
|
@@ -13,7 +13,6 @@
|
|||||||
"@testing-library/user-event": "^13.5.0",
|
"@testing-library/user-event": "^13.5.0",
|
||||||
"base-64": "^1.0.0",
|
"base-64": "^1.0.0",
|
||||||
"dayjs": "^1.10.7",
|
"dayjs": "^1.10.7",
|
||||||
"ky": "^0.28.7",
|
|
||||||
"npm-check-updates": "^12.0.2",
|
"npm-check-updates": "^12.0.2",
|
||||||
"react": "^17.0.2",
|
"react": "^17.0.2",
|
||||||
"react-dom": "^17.0.2",
|
"react-dom": "^17.0.2",
|
||||||
|
@@ -1,112 +1,88 @@
|
|||||||
import React, {useState, useEffect, useContext, createContext} from 'react';
|
import React, {useState, useEffect, createContext} from 'react';
|
||||||
import base64 from 'base-64';
|
import HomePage from './components/pages/HomePage';
|
||||||
import Home from './components/pages/Home';
|
import Locations from './components/pages/Locations'
|
||||||
import { Modal, Button, Text, Group, TextInput, Loader, AppShell } from '@mantine/core';
|
import { Modal, Button, Text, Group, TextInput, Loader, AppShell } from '@mantine/core';
|
||||||
import { useDebouncedValue, useLocalStorageValue } from '@mantine/hooks';
|
import { useDebouncedValue, useLocalStorageValue } from '@mantine/hooks';
|
||||||
|
import { useNotifications } from '@mantine/notifications';
|
||||||
|
|
||||||
|
import { backendAPI } from './services/backend-api';
|
||||||
|
|
||||||
|
|
||||||
import SideBar from './components/SideBar';
|
import SideBar from './components/SideBar';
|
||||||
import AppHeader from './components/AppHeader';
|
import AppHeader from './components/AppHeader';
|
||||||
|
|
||||||
|
|
||||||
const defaultSettings = {"serverURL": window.location.href.slice(0, -1), "Timezone": "America/Detroit"}
|
|
||||||
|
|
||||||
|
|
||||||
const APIContext = createContext();
|
const APIContext = createContext();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
// Main nav/sidebar appshell openend
|
// Main nav/sidebar appshell openend
|
||||||
const [shellOpened, setShellOpened] = useState(false)
|
const [shellOpened, setShellOpened] = useState(false)
|
||||||
const [portModalOpen, setPortModalOpen] = useState(false)
|
|
||||||
const [authModalOpen, setAuthModalOpen] = useState(false)
|
|
||||||
const [isLoading, setIsLoading] = useState(true)
|
const [isLoading, setIsLoading] = useState(true)
|
||||||
|
const [currentPage, setCurrentPage] = useState("home")
|
||||||
|
|
||||||
// json.stringify({"serverURL": window.location.href.slice(0, -1), "Timezone": "America/Detroit"})
|
const [serverConfig, setServerConfig] = useState({})
|
||||||
const [serverConfigLS, setServerConfigLS] = useLocalStorageValue({key: 'serverConfig', defaultValue: JSON.stringify(defaultSettings)})
|
|
||||||
const [serverConfig, setServerConfig] = useState(defaultSettings)
|
|
||||||
|
|
||||||
const [fullServerURL] = useDebouncedValue(serverConfig["serverURL"], 800);
|
const notifications = useNotifications();
|
||||||
|
|
||||||
//headers.append("Authorization", "Basic " + base64.encode("user:password"));
|
|
||||||
const user = "admin"
|
|
||||||
const password = "password"
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
console.log("Checking local storage for server settings: ", JSON.parse(serverConfigLS))
|
|
||||||
if(JSON.parse(serverConfigLS)) {
|
|
||||||
setServerConfig(JSON.parse(serverConfigLS))
|
|
||||||
}
|
|
||||||
}, [serverConfigLS, setServerConfig])
|
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setPortModalOpen(false)
|
setIsLoading(true)
|
||||||
const lastChar = fullServerURL[fullServerURL.length - 1]
|
async function fetchSettings() {
|
||||||
let newURL = fullServerURL
|
backendAPI.get('/config').then(results => {
|
||||||
if (lastChar === "/") {
|
console.log("CONFIG: ", results.data)
|
||||||
newURL = fullServerURL.slice(0, -1)
|
results.data.baseURL = results.config.baseURL
|
||||||
}
|
console.log("CONFIG: ", results.data)
|
||||||
console.log("Auto-discover URL attempted: ", `${newURL}/config`)
|
setServerConfig(results.data)
|
||||||
fetch(`${newURL}/config`)
|
notifications.showNotification({
|
||||||
.then(response => {
|
title: 'Backend Notice',
|
||||||
console.log("RESPONSE: ", response)
|
message: 'Config fetched from backend!',
|
||||||
if (!response.ok) {
|
color: "green"
|
||||||
console.log("Server not responding as expected, this should not happen!")
|
})
|
||||||
setPortModalOpen(true)
|
setIsLoading(false)
|
||||||
} else {
|
|
||||||
response.json().then(data => {
|
|
||||||
console.log("Connected to Server! ", data)
|
|
||||||
setServerConfig({...serverConfig, "Timezone": data["Timezone"], "BasicAuth": data["BasicAuth"]})
|
|
||||||
setServerConfigLS(JSON.stringify({...serverConfig, "Timezone": data["Timezone"], "BasicAuth": data["BasicAuth"]}))
|
|
||||||
setPortModalOpen(false)
|
|
||||||
setIsLoading(false)
|
|
||||||
}).catch(err => {
|
|
||||||
console.log("Server URL is incorrect, please change! ", err)
|
|
||||||
setPortModalOpen(true)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.log("Server URL is incorrect, please change! ", err)
|
notifications.showNotification({
|
||||||
setPortModalOpen(true)
|
title: 'Backend Notice',
|
||||||
|
message: `Failed to connect to backend! ${err}`,
|
||||||
|
autoClose: false,
|
||||||
|
color: "red",
|
||||||
|
})
|
||||||
|
setIsLoading(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
}, [fullServerURL])
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
console.log("Loading Server Config: ", serverConfig)
|
|
||||||
if (serverConfig["BasicAuth"]) {
|
|
||||||
console.log("Looks like auth is required!")
|
|
||||||
//setAuthModalOpen(true)
|
|
||||||
}
|
}
|
||||||
}, [serverConfig])
|
fetchSettings();
|
||||||
|
|
||||||
|
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
|
||||||
|
function showPage() {
|
||||||
|
switch (currentPage) {
|
||||||
|
case "home":
|
||||||
|
return <HomePage />
|
||||||
|
case "locations":
|
||||||
|
return <Locations />
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<APIContext.Provider value={{...serverConfig}}>
|
<APIContext.Provider value={{...serverConfig}}>
|
||||||
<AppShell
|
<AppShell
|
||||||
navbarOffsetBreakpoint="sm" // navbarOffsetBreakpoint controls when navbar should no longer be offset with padding-left
|
navbarOffsetBreakpoint="sm" // navbarOffsetBreakpoint controls when navbar should no longer be offset with padding-left
|
||||||
fixed // fixed prop on AppShell will be automatically added to Header and Navbar
|
fixed // fixed prop on AppShell will be automatically added to Header and Navbar
|
||||||
navbar={<SideBar opened={shellOpened}/>}
|
navbar={<SideBar opened={shellOpened} setCurrentPage={setCurrentPage}/>}
|
||||||
header={<AppHeader opened={shellOpened} setOpened={setShellOpened}/>}
|
header={<AppHeader opened={shellOpened} setOpened={setShellOpened}/>}
|
||||||
>
|
>
|
||||||
<Text>Resize app to see responsive navbar in action</Text>
|
{showPage()}
|
||||||
</AppShell>
|
</AppShell>
|
||||||
<Modal
|
|
||||||
opened={portModalOpen}
|
|
||||||
onClose={() => setPortModalOpen(false)}
|
|
||||||
title="Communication Failed, server URL may not be what was expected!"
|
|
||||||
>
|
|
||||||
<Text>Guessed Server URL: {serverConfig["serverURL"]} does not appear to be correct, please enter correct url.</Text>
|
|
||||||
<TextInput label="Server URL" value={serverConfig["serverURL"]} onChange={(e) => setServerConfig({...serverConfig, "serverURL": e.currentTarget.value})} required></TextInput>
|
|
||||||
</Modal>
|
|
||||||
<Modal opened={authModalOpen} onClose={() => setAuthModalOpen(false)} title="Please Login!">
|
|
||||||
<TextInput label="UserName" value={serverConfig["serverURL"]} onChange={(e) => setServerConfig({"ServerURL": e.currentTarget.value})} required></TextInput>
|
|
||||||
<TextInput label="UserName" type="password" value={serverConfig["serverURL"]} onChange={(e) => setServerConfig({"ServerURL": e.currentTarget.value})} required></TextInput>
|
|
||||||
</Modal>
|
|
||||||
{isLoading ? <Group position="center"><Loader size="xl"></Loader></Group> : <div>Welcome to goInventorize!</div>}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</APIContext.Provider>
|
</APIContext.Provider>
|
||||||
|
|
||||||
);
|
);
|
||||||
|
@@ -21,7 +21,7 @@ function AppHeader(props) {
|
|||||||
/>
|
/>
|
||||||
</MediaQuery>
|
</MediaQuery>
|
||||||
<Group>
|
<Group>
|
||||||
<ThemeIcon size="xl"><BsHouseDoor /></ThemeIcon>
|
<BsHouseDoor size={30} />
|
||||||
<Title><Text inherit variant="gradient" gradient={{ from: 'indigo', to: 'cyan', deg: 45 }}>goInventorize</Text></Title>
|
<Title><Text inherit variant="gradient" gradient={{ from: 'indigo', to: 'cyan', deg: 45 }}>goInventorize</Text></Title>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
|
@@ -1,12 +1,26 @@
|
|||||||
import React, {useState } from 'react';
|
import React, {useState } from 'react';
|
||||||
import { Navbar, Text, Group, ThemeIcon, Button } from '@mantine/core';
|
import { Navbar, Text, Group, ThemeIcon, Button, UnstyledButton } from '@mantine/core';
|
||||||
|
import { createStyles } from '@mantine/styles';
|
||||||
import { BsMap } from 'react-icons/bs'
|
import { BsMap } from 'react-icons/bs'
|
||||||
import {BrowserRouter as Router, Routes, Route, Link} from 'react-router-dom'
|
|
||||||
|
|
||||||
|
|
||||||
|
const useStyles = createStyles((theme) => ({
|
||||||
|
button: {
|
||||||
|
display: 'block',
|
||||||
|
width: '100%',
|
||||||
|
padding: theme.spacing.xs,
|
||||||
|
borderRadius: theme.radius.sm,
|
||||||
|
color: theme.colorScheme === 'dark' ? theme.colors.dark[0] : theme.black,
|
||||||
|
backgroundColor: 'transparent',
|
||||||
|
|
||||||
|
'&:hover': {
|
||||||
|
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[6] : theme.colors.gray[0],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
function SideBar(props) {
|
function SideBar(props) {
|
||||||
|
const { classes } = useStyles();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Navbar
|
<Navbar
|
||||||
@@ -17,14 +31,13 @@ function SideBar(props) {
|
|||||||
hidden={!props.opened}
|
hidden={!props.opened}
|
||||||
width={{ base: 200, breakpoints: { sm: '100%', lg: 300 } }}
|
width={{ base: 200, breakpoints: { sm: '100%', lg: 300 } }}
|
||||||
>
|
>
|
||||||
<Router>
|
<UnstyledButton className={classes.button} onClick={() => props.setCurrentPage("locations")} >
|
||||||
<Routes>
|
<Group>
|
||||||
<Route path="/" element={<Home />} />
|
<BsMap />
|
||||||
</Routes>
|
<Text>Locations</Text>
|
||||||
<Button component={Link} to="/locations" leftIcon={<ThemeIcon><BsMap /></ThemeIcon>}>
|
</Group>
|
||||||
<Text>Locations</Text>
|
|
||||||
</Button>
|
</UnstyledButton>
|
||||||
</Router>
|
|
||||||
|
|
||||||
</Navbar>
|
</Navbar>
|
||||||
)
|
)
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
import React, {useState, useEffect, useContext, createContext} from 'react';
|
import React, {useState, useEffect, useContext, createContext} from 'react';
|
||||||
import APIContext from '../../App';
|
import APIContext from '../../App';
|
||||||
|
import { Text } from '@mantine/core'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function HomePage() {
|
||||||
function App() {
|
|
||||||
const [opened, setOpened] = useState(false);
|
const [opened, setOpened] = useState(false);
|
||||||
|
|
||||||
const serverConfig = useContext(APIContext);
|
const serverConfig = useContext(APIContext);
|
||||||
@@ -12,9 +12,10 @@ function App() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<Text>This is the homepage!</Text>
|
||||||
</>
|
</>
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default App;
|
export default HomePage;
|
@@ -0,0 +1,70 @@
|
|||||||
|
import React, {useState, useEffect, useContext, createContext} from 'react';
|
||||||
|
import APIContext from '../../App';
|
||||||
|
import { Text, Loader, Center, Card, Image, Badge, Button, SimpleGrid, Group } from '@mantine/core'
|
||||||
|
import { useNotifications } from '@mantine/notifications';
|
||||||
|
|
||||||
|
import { backendAPI } from '../../services/backend-api';
|
||||||
|
|
||||||
|
|
||||||
|
function LocationsPage() {
|
||||||
|
// const [opened, setOpened] = useState(false);
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
const [locations, setLocations] = useState([])
|
||||||
|
const [baseURL, setBaseURL] = useState("")
|
||||||
|
|
||||||
|
const serverConfig = useContext(APIContext);
|
||||||
|
|
||||||
|
const notifications = useNotifications();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setIsLoading(true)
|
||||||
|
async function fetchSettings() {
|
||||||
|
backendAPI.get('/locations').then(results => {
|
||||||
|
console.log("CONFIG: ", serverConfig)
|
||||||
|
//console.log("baseurl: ", results.config.baseURL)
|
||||||
|
setBaseURL(results.config.baseURL)
|
||||||
|
console.log("URL", `${results.data[0]}`)
|
||||||
|
setLocations(results.data)
|
||||||
|
setIsLoading(false)
|
||||||
|
}).catch(err => {
|
||||||
|
notifications.showNotification({
|
||||||
|
title: 'Backend Notice',
|
||||||
|
message: `Failed to fetch locations from backend! ${err}`,
|
||||||
|
autoClose: false,
|
||||||
|
color: "red",
|
||||||
|
})
|
||||||
|
setIsLoading(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
fetchSettings();
|
||||||
|
|
||||||
|
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Center>{ isLoading && <Loader size="xl" variant="bars" />}</Center>
|
||||||
|
<SimpleGrid cols={4} spacing="xl">
|
||||||
|
{ locations.map((location, idx) =>
|
||||||
|
<Card key={idx} shadow="sm" padding="md">
|
||||||
|
<Card.Section>
|
||||||
|
<Image src={`${serverConfig.baseURL}/photos/locations/${location.Name}/${location.CoverPhoto}`}></Image>
|
||||||
|
</Card.Section>
|
||||||
|
<Group position="apart">
|
||||||
|
<Text weight={500}>{location.Name}</Text>
|
||||||
|
<Badge color="pink" variant="light">
|
||||||
|
On Sale
|
||||||
|
</Badge>
|
||||||
|
</Group>
|
||||||
|
<Text size="sm">{location.Description}</Text>
|
||||||
|
</Card>
|
||||||
|
)}
|
||||||
|
</SimpleGrid>
|
||||||
|
</>
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default LocationsPage;
|
@@ -2,14 +2,17 @@ import React from 'react';
|
|||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import App from './App';
|
import App from './App';
|
||||||
import reportWebVitals from './reportWebVitals';
|
import reportWebVitals from './reportWebVitals';
|
||||||
|
import { NotificationsProvider } from '@mantine/notifications';
|
||||||
|
|
||||||
//setup api
|
//setup api
|
||||||
const backendPort = process.env.REACT_APP_BACKEND_PORT
|
//const backendPort = process.env.REACT_APP_BACKEND_PORT
|
||||||
console.log("BACKEND PORT: ", backendPort)
|
//console.log("BACKEND PORT: ", backendPort)
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
<App />
|
<NotificationsProvider>
|
||||||
|
<App />
|
||||||
|
</NotificationsProvider>
|
||||||
</React.StrictMode>,
|
</React.StrictMode>,
|
||||||
document.getElementById('root')
|
document.getElementById('root')
|
||||||
);
|
);
|
||||||
|
@@ -1,12 +1,13 @@
|
|||||||
import ky from 'ky';
|
import axios from 'axios';
|
||||||
|
|
||||||
const url = 'https://sindresorhus.com';
|
|
||||||
const backendPort = 3500
|
|
||||||
|
|
||||||
const backendAPI = ky.create({
|
let baseURL = ""
|
||||||
headers: {
|
|
||||||
rainbow: 'rainbow',
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
unicorn: 'unicorn'
|
baseURL = 'http://localhost:3500'
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
export const backendAPI = axios.create({
|
||||||
|
baseURL: baseURL
|
||||||
|
})
|
||||||
|
|
||||||
|
2
go.mod
2
go.mod
@@ -18,5 +18,5 @@ require (
|
|||||||
golang.org/x/sys v0.0.0-20210820121016-41cdb8703e55 // indirect
|
golang.org/x/sys v0.0.0-20210820121016-41cdb8703e55 // indirect
|
||||||
google.golang.org/appengine v1.6.7 // indirect
|
google.golang.org/appengine v1.6.7 // indirect
|
||||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
|
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
|
||||||
)
|
)
|
||||||
|
@@ -11,6 +11,7 @@ import (
|
|||||||
|
|
||||||
//Get Server Config
|
//Get Server Config
|
||||||
func (s *Server) GetServerConfig(c *fiber.Ctx) error {
|
func (s *Server) GetServerConfig(c *fiber.Ctx) error {
|
||||||
|
fmt.Println("SENDING CONFIG!")
|
||||||
return c.Status(fiber.StatusOK).JSON(fiber.Map{"BasicAuth": s.Config.Authentication.BasicAuth, "Timezone": s.Config.Timezone})
|
return c.Status(fiber.StatusOK).JSON(fiber.Map{"BasicAuth": s.Config.Authentication.BasicAuth, "Timezone": s.Config.Timezone})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,8 +91,8 @@ func (s *Server) GetAllLocationsHandler(c *fiber.Ctx) error {
|
|||||||
testLoc := Location{
|
testLoc := Location{
|
||||||
ID: 1,
|
ID: 1,
|
||||||
Description: "This is a description of the location",
|
Description: "This is a description of the location",
|
||||||
Name: "testName",
|
Name: "Location1",
|
||||||
CoverPhoto: "testString", // A "cover photo" for the location
|
CoverPhoto: "testCover.png", // A "cover photo" for the location
|
||||||
Notes: "Notes String",
|
Notes: "Notes String",
|
||||||
}
|
}
|
||||||
testLoc2 := Location{
|
testLoc2 := Location{
|
||||||
|
7
main.go
7
main.go
@@ -77,11 +77,14 @@ func main() {
|
|||||||
PathPrefix: "static",
|
PathPrefix: "static",
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
// Serve up our static images
|
||||||
|
server.WebServer.Static("/photos", "./app/photos")
|
||||||
|
|
||||||
// Load in our routes
|
// Load in our routes
|
||||||
server.WebServer.Get("/hello", func(c *fiber.Ctx) error { // Basic Hello Route
|
server.WebServer.Get("/hello", func(c *fiber.Ctx) error { // Basic Hello Route
|
||||||
return c.SendString("GoInventorize Backend Hello Route!")
|
return c.SendString("GoInventorize Backend Hello Route!")
|
||||||
})
|
})
|
||||||
// Location Routes
|
// Unauthenticated config route to fetch the config
|
||||||
server.WebServer.Get("/config", server.GetServerConfig)
|
server.WebServer.Get("/config", server.GetServerConfig)
|
||||||
// Setup our basic authentication if defined
|
// Setup our basic authentication if defined
|
||||||
if server.Config.Authentication.BasicAuth {
|
if server.Config.Authentication.BasicAuth {
|
||||||
@@ -91,7 +94,7 @@ func main() {
|
|||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
// Location Routes
|
||||||
server.WebServer.Get("/locations", server.GetAllLocationsHandler)
|
server.WebServer.Get("/locations", server.GetAllLocationsHandler)
|
||||||
server.WebServer.Post("/locations/new", server.AddNewLocationHandler)
|
server.WebServer.Post("/locations/new", server.AddNewLocationHandler)
|
||||||
server.WebServer.Delete("/locations/:locID", server.DeleteLocationHandler)
|
server.WebServer.Delete("/locations/:locID", server.DeleteLocationHandler)
|
||||||
|
Reference in New Issue
Block a user