diff --git a/README.md b/README.md index d957c20..1f9a563 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# go-api-template +# goInventorize -Template for go-fiber with react frontend. +Home Inventory app ## Developing diff --git a/Taskfile.yml b/Taskfile.yml index dc3bb1d..f1441ff 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -7,6 +7,7 @@ env: RELEASE_MSG: "First official release of the project" GO_VERSION: 1.16.3 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) tasks: @@ -78,7 +79,7 @@ tasks: run-backend: env: - + GI_BASIC_AUTH: false GI_DEVELOPMENT: false # TZ: "America/New_York" cmds: diff --git a/app/config/config.yaml b/app/config/config.yaml index f0eed44..c4b99b0 100644 --- a/app/config/config.yaml +++ b/app/config/config.yaml @@ -8,7 +8,7 @@ Logger: loggingFile: "./app/log/goInventorize.log" Authentication: - BasicAuth: true + BasicAuth: false UserName: "admin" Password: "password" diff --git a/app/log/goInventorize.log b/app/log/goInventorize.log index 400529f..d2c5024 100644 --- a/app/log/goInventorize.log +++ b/app/log/goInventorize.log @@ -70,3 +70,136 @@ {"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":"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​"}​ diff --git a/app/photos/locations/Location1/2020-05-22 20_57_56-Wwise.png b/app/photos/locations/Location1/testCover.png similarity index 100% rename from app/photos/locations/Location1/2020-05-22 20_57_56-Wwise.png rename to app/photos/locations/Location1/testCover.png diff --git a/frontend/apis/backend.js b/frontend/apis/backend.js new file mode 100644 index 0000000..fa6e991 --- /dev/null +++ b/frontend/apis/backend.js @@ -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 ( + <> + This is the homepage! + + + ); +} + +export default BackendAPI; \ No newline at end of file diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 859a9e5..045a74c 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -10672,11 +10672,6 @@ "resolved": "https://registry.npmjs.org/klona/-/klona-2.0.4.tgz", "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": { "version": "0.3.21", "resolved": "https://registry.npmjs.org/language-subtag-registry/-/language-subtag-registry-0.3.21.tgz", diff --git a/frontend/package.json b/frontend/package.json index bc5f00f..4596f28 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -13,7 +13,6 @@ "@testing-library/user-event": "^13.5.0", "base-64": "^1.0.0", "dayjs": "^1.10.7", - "ky": "^0.28.7", "npm-check-updates": "^12.0.2", "react": "^17.0.2", "react-dom": "^17.0.2", diff --git a/frontend/src/App.js b/frontend/src/App.js index 9b1b392..3102de8 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -1,112 +1,88 @@ -import React, {useState, useEffect, useContext, createContext} from 'react'; -import base64 from 'base-64'; -import Home from './components/pages/Home'; +import React, {useState, useEffect, createContext} from 'react'; +import HomePage from './components/pages/HomePage'; +import Locations from './components/pages/Locations' import { Modal, Button, Text, Group, TextInput, Loader, AppShell } from '@mantine/core'; import { useDebouncedValue, useLocalStorageValue } from '@mantine/hooks'; +import { useNotifications } from '@mantine/notifications'; + +import { backendAPI } from './services/backend-api'; import SideBar from './components/SideBar'; import AppHeader from './components/AppHeader'; -const defaultSettings = {"serverURL": window.location.href.slice(0, -1), "Timezone": "America/Detroit"} - - const APIContext = createContext(); + + + function App() { // Main nav/sidebar appshell openend const [shellOpened, setShellOpened] = useState(false) - const [portModalOpen, setPortModalOpen] = useState(false) - const [authModalOpen, setAuthModalOpen] = useState(false) const [isLoading, setIsLoading] = useState(true) + const [currentPage, setCurrentPage] = useState("home") - // json.stringify({"serverURL": window.location.href.slice(0, -1), "Timezone": "America/Detroit"}) - const [serverConfigLS, setServerConfigLS] = useLocalStorageValue({key: 'serverConfig', defaultValue: JSON.stringify(defaultSettings)}) - const [serverConfig, setServerConfig] = useState(defaultSettings) + const [serverConfig, setServerConfig] = useState({}) - 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(() => { - setPortModalOpen(false) - const lastChar = fullServerURL[fullServerURL.length - 1] - let newURL = fullServerURL - if (lastChar === "/") { - newURL = fullServerURL.slice(0, -1) - } - console.log("Auto-discover URL attempted: ", `${newURL}/config`) - fetch(`${newURL}/config`) - .then(response => { - console.log("RESPONSE: ", response) - if (!response.ok) { - console.log("Server not responding as expected, this should not happen!") - setPortModalOpen(true) - } 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) - }) - } + setIsLoading(true) + async function fetchSettings() { + backendAPI.get('/config').then(results => { + console.log("CONFIG: ", results.data) + results.data.baseURL = results.config.baseURL + console.log("CONFIG: ", results.data) + setServerConfig(results.data) + notifications.showNotification({ + title: 'Backend Notice', + message: 'Config fetched from backend!', + color: "green" + }) + setIsLoading(false) }).catch(err => { - console.log("Server URL is incorrect, please change! ", err) - setPortModalOpen(true) + notifications.showNotification({ + 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 + case "locations": + return + + default: + break; + } + } return ( - } - header={} - > - Resize app to see responsive navbar in action - - setPortModalOpen(false)} - title="Communication Failed, server URL may not be what was expected!" - > - Guessed Server URL: {serverConfig["serverURL"]} does not appear to be correct, please enter correct url. - setServerConfig({...serverConfig, "serverURL": e.currentTarget.value})} required> - - setAuthModalOpen(false)} title="Please Login!"> - setServerConfig({"ServerURL": e.currentTarget.value})} required> - setServerConfig({"ServerURL": e.currentTarget.value})} required> - - {isLoading ? :
Welcome to goInventorize!
} - - - + } + header={} + > + {showPage()} +
); diff --git a/frontend/src/components/AppHeader.js b/frontend/src/components/AppHeader.js index 8299e6e..8b6dbbe 100644 --- a/frontend/src/components/AppHeader.js +++ b/frontend/src/components/AppHeader.js @@ -21,7 +21,7 @@ function AppHeader(props) { /> - + <Text inherit variant="gradient" gradient={{ from: 'indigo', to: 'cyan', deg: 45 }}>goInventorize</Text> diff --git a/frontend/src/components/SideBar.js b/frontend/src/components/SideBar.js index 06726c3..20c1bf4 100644 --- a/frontend/src/components/SideBar.js +++ b/frontend/src/components/SideBar.js @@ -1,12 +1,26 @@ 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 {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) { - + const { classes } = useStyles(); return ( ) diff --git a/frontend/src/components/pages/Home.js b/frontend/src/components/pages/HomePage.js similarity index 64% rename from frontend/src/components/pages/Home.js rename to frontend/src/components/pages/HomePage.js index dda022d..5785277 100644 --- a/frontend/src/components/pages/Home.js +++ b/frontend/src/components/pages/HomePage.js @@ -1,10 +1,10 @@ import React, {useState, useEffect, useContext, createContext} from 'react'; import APIContext from '../../App'; +import { Text } from '@mantine/core' - -function App() { +function HomePage() { const [opened, setOpened] = useState(false); const serverConfig = useContext(APIContext); @@ -12,9 +12,10 @@ function App() { return ( <> + This is the homepage! ); } -export default App; +export default HomePage; diff --git a/frontend/src/components/pages/Locations.js b/frontend/src/components/pages/Locations.js index e69de29..2706874 100644 --- a/frontend/src/components/pages/Locations.js +++ b/frontend/src/components/pages/Locations.js @@ -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 ( + <> +
{ isLoading && }
+ + { locations.map((location, idx) => + + + + + + {location.Name} + + On Sale + + + {location.Description} + + )} + + + + ); +} + +export default LocationsPage; \ No newline at end of file diff --git a/frontend/src/index.js b/frontend/src/index.js index d5e5808..0143100 100644 --- a/frontend/src/index.js +++ b/frontend/src/index.js @@ -2,14 +2,17 @@ import React from 'react'; import ReactDOM from 'react-dom'; import App from './App'; import reportWebVitals from './reportWebVitals'; +import { NotificationsProvider } from '@mantine/notifications'; //setup api -const backendPort = process.env.REACT_APP_BACKEND_PORT -console.log("BACKEND PORT: ", backendPort) +//const backendPort = process.env.REACT_APP_BACKEND_PORT +//console.log("BACKEND PORT: ", backendPort) ReactDOM.render( - - + + + + , document.getElementById('root') ); diff --git a/frontend/src/services/backend-api.js b/frontend/src/services/backend-api.js index 60cfe2d..cbcb1df 100644 --- a/frontend/src/services/backend-api.js +++ b/frontend/src/services/backend-api.js @@ -1,12 +1,13 @@ -import ky from 'ky'; +import axios from 'axios'; -const url = 'https://sindresorhus.com'; -const backendPort = 3500 -const backendAPI = ky.create({ - headers: { - rainbow: 'rainbow', - unicorn: 'unicorn' - } -}); +let baseURL = "" + +if (process.env.NODE_ENV !== 'production') { + baseURL = 'http://localhost:3500' +} + +export const backendAPI = axios.create({ + baseURL: baseURL + }) diff --git a/go.mod b/go.mod index 626c4b8..f92d711 100644 --- a/go.mod +++ b/go.mod @@ -18,5 +18,5 @@ require ( golang.org/x/sys v0.0.0-20210820121016-41cdb8703e55 // indirect google.golang.org/appengine v1.6.7 // 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 ) diff --git a/handlers.go b/handlers.go index 5e29b08..7a1bc10 100644 --- a/handlers.go +++ b/handlers.go @@ -11,6 +11,7 @@ import ( //Get Server Config 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}) } @@ -90,8 +91,8 @@ func (s *Server) GetAllLocationsHandler(c *fiber.Ctx) error { testLoc := Location{ ID: 1, Description: "This is a description of the location", - Name: "testName", - CoverPhoto: "testString", // A "cover photo" for the location + Name: "Location1", + CoverPhoto: "testCover.png", // A "cover photo" for the location Notes: "Notes String", } testLoc2 := Location{ diff --git a/main.go b/main.go index 4295c78..422220a 100644 --- a/main.go +++ b/main.go @@ -77,11 +77,14 @@ func main() { PathPrefix: "static", })) + // Serve up our static images + server.WebServer.Static("/photos", "./app/photos") + // Load in our routes server.WebServer.Get("/hello", func(c *fiber.Ctx) error { // Basic Hello Route return c.SendString("GoInventorize Backend Hello Route!") }) - // Location Routes + // Unauthenticated config route to fetch the config server.WebServer.Get("/config", server.GetServerConfig) // Setup our basic authentication if defined if server.Config.Authentication.BasicAuth { @@ -91,7 +94,7 @@ func main() { }, })) } - + // Location Routes server.WebServer.Get("/locations", server.GetAllLocationsHandler) server.WebServer.Post("/locations/new", server.AddNewLocationHandler) server.WebServer.Delete("/locations/:locID", server.DeleteLocationHandler)