adds user management
This commit is contained in:
31
db/pb_migrations/1706901300_updated_users.js
Normal file
31
db/pb_migrations/1706901300_updated_users.js
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("_pb_users_auth_")
|
||||||
|
|
||||||
|
// remove
|
||||||
|
collection.schema.removeField("users_name")
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
}, (db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("_pb_users_auth_")
|
||||||
|
|
||||||
|
// add
|
||||||
|
collection.schema.addField(new SchemaField({
|
||||||
|
"system": false,
|
||||||
|
"id": "users_name",
|
||||||
|
"name": "name",
|
||||||
|
"type": "text",
|
||||||
|
"required": false,
|
||||||
|
"presentable": false,
|
||||||
|
"unique": false,
|
||||||
|
"options": {
|
||||||
|
"min": null,
|
||||||
|
"max": null,
|
||||||
|
"pattern": ""
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
})
|
||||||
27
db/pb_migrations/1706905108_updated_trails.js
Normal file
27
db/pb_migrations/1706905108_updated_trails.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||||
|
|
||||||
|
// add
|
||||||
|
collection.schema.addField(new SchemaField({
|
||||||
|
"system": false,
|
||||||
|
"id": "ehrmydva",
|
||||||
|
"name": "public",
|
||||||
|
"type": "bool",
|
||||||
|
"required": false,
|
||||||
|
"presentable": false,
|
||||||
|
"unique": false,
|
||||||
|
"options": {}
|
||||||
|
}))
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
}, (db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||||
|
|
||||||
|
// remove
|
||||||
|
collection.schema.removeField("ehrmydva")
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
})
|
||||||
48
db/pb_migrations/1706905430_updated_trails.js
Normal file
48
db/pb_migrations/1706905430_updated_trails.js
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||||
|
|
||||||
|
// update
|
||||||
|
collection.schema.addField(new SchemaField({
|
||||||
|
"system": false,
|
||||||
|
"id": "1utgul91",
|
||||||
|
"name": "author",
|
||||||
|
"type": "relation",
|
||||||
|
"required": true,
|
||||||
|
"presentable": false,
|
||||||
|
"unique": false,
|
||||||
|
"options": {
|
||||||
|
"collectionId": "_pb_users_auth_",
|
||||||
|
"cascadeDelete": true,
|
||||||
|
"minSelect": null,
|
||||||
|
"maxSelect": 1,
|
||||||
|
"displayFields": null
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
}, (db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||||
|
|
||||||
|
// update
|
||||||
|
collection.schema.addField(new SchemaField({
|
||||||
|
"system": false,
|
||||||
|
"id": "1utgul91",
|
||||||
|
"name": "author",
|
||||||
|
"type": "relation",
|
||||||
|
"required": false,
|
||||||
|
"presentable": false,
|
||||||
|
"unique": false,
|
||||||
|
"options": {
|
||||||
|
"collectionId": "_pb_users_auth_",
|
||||||
|
"cascadeDelete": false,
|
||||||
|
"minSelect": null,
|
||||||
|
"maxSelect": 1,
|
||||||
|
"displayFields": null
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
})
|
||||||
24
db/pb_migrations/1706907701_updated_trails.js
Normal file
24
db/pb_migrations/1706907701_updated_trails.js
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||||
|
|
||||||
|
collection.listRule = "author = @request.auth.id || public = true"
|
||||||
|
collection.viewRule = "author = @request.auth.id || public = true"
|
||||||
|
collection.createRule = "@request.auth.id != \"\" && (@request.data.author = @request.auth.id)"
|
||||||
|
collection.updateRule = "author = @request.auth.id "
|
||||||
|
collection.deleteRule = "author = @request.auth.id "
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
}, (db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||||
|
|
||||||
|
collection.listRule = ""
|
||||||
|
collection.viewRule = ""
|
||||||
|
collection.createRule = ""
|
||||||
|
collection.updateRule = ""
|
||||||
|
collection.deleteRule = ""
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
})
|
||||||
24
db/pb_migrations/1706907926_updated_waypoints.js
Normal file
24
db/pb_migrations/1706907926_updated_waypoints.js
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
collection.createRule = "@request.auth.id != \"\""
|
||||||
|
collection.updateRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id)"
|
||||||
|
collection.deleteRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id)"
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
}, (db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.listRule = ""
|
||||||
|
collection.viewRule = ""
|
||||||
|
collection.createRule = ""
|
||||||
|
collection.updateRule = ""
|
||||||
|
collection.deleteRule = ""
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
})
|
||||||
24
db/pb_migrations/1706907953_updated_summit_logs.js
Normal file
24
db/pb_migrations/1706907953_updated_summit_logs.js
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
|
|
||||||
|
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
collection.createRule = "@request.auth.id != \"\""
|
||||||
|
collection.updateRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id)"
|
||||||
|
collection.deleteRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id)"
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
}, (db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
|
|
||||||
|
collection.listRule = ""
|
||||||
|
collection.viewRule = ""
|
||||||
|
collection.createRule = ""
|
||||||
|
collection.updateRule = ""
|
||||||
|
collection.deleteRule = ""
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
})
|
||||||
22
db/pb_migrations/1706908030_updated_summit_logs.js
Normal file
22
db/pb_migrations/1706908030_updated_summit_logs.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
|
|
||||||
|
collection.listRule = "@request.auth.id != \"\" && @collection.trails.summit_logs ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.summit_logs ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
collection.updateRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id)"
|
||||||
|
collection.deleteRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id)"
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
}, (db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
|
|
||||||
|
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
collection.updateRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id)"
|
||||||
|
collection.deleteRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id)"
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
})
|
||||||
22
db/pb_migrations/1706908043_updated_waypoints.js
Normal file
22
db/pb_migrations/1706908043_updated_waypoints.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
collection.updateRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id)"
|
||||||
|
collection.deleteRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id)"
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
}, (db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
collection.updateRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id)"
|
||||||
|
collection.deleteRule = "@request.auth.id != \"\" && @collection.trails.waypoints = id && (@collection.trails.author = @request.auth.id)"
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
})
|
||||||
16
db/pb_migrations/1706908165_updated_waypoints.js
Normal file
16
db/pb_migrations/1706908165_updated_waypoints.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.listRule = "@request.auth.id != \"\""
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
}, (db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
})
|
||||||
18
db/pb_migrations/1706908193_updated_waypoints.js
Normal file
18
db/pb_migrations/1706908193_updated_waypoints.js
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
collection.viewRule = "@request.auth.id != \"\" "
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
}, (db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.listRule = "@request.auth.id != \"\""
|
||||||
|
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
})
|
||||||
16
db/pb_migrations/1706908206_updated_waypoints.js
Normal file
16
db/pb_migrations/1706908206_updated_waypoints.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.viewRule = ""
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
}, (db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.viewRule = "@request.auth.id != \"\" "
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
})
|
||||||
16
db/pb_migrations/1706908221_updated_waypoints.js
Normal file
16
db/pb_migrations/1706908221_updated_waypoints.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
}, (db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.viewRule = ""
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
})
|
||||||
16
db/pb_migrations/1706908229_updated_summit_logs.js
Normal file
16
db/pb_migrations/1706908229_updated_summit_logs.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
|
|
||||||
|
collection.viewRule = ""
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
}, (db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
|
|
||||||
|
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.summit_logs ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
})
|
||||||
16
db/pb_migrations/1706908236_updated_waypoints.js
Normal file
16
db/pb_migrations/1706908236_updated_waypoints.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.viewRule = ""
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
}, (db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
})
|
||||||
16
db/pb_migrations/1706908260_updated_summit_logs.js
Normal file
16
db/pb_migrations/1706908260_updated_summit_logs.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
|
|
||||||
|
collection.listRule = ""
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
}, (db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
|
|
||||||
|
collection.listRule = "@request.auth.id != \"\" && @collection.trails.summit_logs ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
})
|
||||||
16
db/pb_migrations/1706908281_updated_waypoints.js
Normal file
16
db/pb_migrations/1706908281_updated_waypoints.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
}, (db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.viewRule = ""
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
})
|
||||||
16
db/pb_migrations/1706908311_updated_waypoints.js
Normal file
16
db/pb_migrations/1706908311_updated_waypoints.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id "
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
}, (db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
})
|
||||||
16
db/pb_migrations/1706908342_updated_waypoints.js
Normal file
16
db/pb_migrations/1706908342_updated_waypoints.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.viewRule = ""
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
}, (db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id "
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
})
|
||||||
16
db/pb_migrations/1706908372_updated_waypoints.js
Normal file
16
db/pb_migrations/1706908372_updated_waypoints.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.listRule = ""
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
}, (db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
})
|
||||||
18
db/pb_migrations/1706908432_updated_waypoints.js
Normal file
18
db/pb_migrations/1706908432_updated_waypoints.js
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
}, (db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.listRule = ""
|
||||||
|
collection.viewRule = ""
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
})
|
||||||
16
db/pb_migrations/1706908739_updated_trails.js
Normal file
16
db/pb_migrations/1706908739_updated_trails.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||||
|
|
||||||
|
collection.viewRule = ""
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
}, (db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||||
|
|
||||||
|
collection.viewRule = "author = @request.auth.id || public = true"
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
})
|
||||||
16
db/pb_migrations/1706908748_updated_trails.js
Normal file
16
db/pb_migrations/1706908748_updated_trails.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||||
|
|
||||||
|
collection.viewRule = "author = @request.auth.id || public = true"
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
}, (db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("e864strfxo14pm4")
|
||||||
|
|
||||||
|
collection.viewRule = ""
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
})
|
||||||
16
db/pb_migrations/1706908846_updated_waypoints.js
Normal file
16
db/pb_migrations/1706908846_updated_waypoints.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.viewRule = "@request.auth.id != \"\" && (@collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true))"
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
}, (db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
})
|
||||||
16
db/pb_migrations/1706908854_updated_waypoints.js
Normal file
16
db/pb_migrations/1706908854_updated_waypoints.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.listRule = "@request.auth.id != \"\" && (@collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true))"
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
}, (db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
})
|
||||||
18
db/pb_migrations/1706908926_updated_waypoints.js
Normal file
18
db/pb_migrations/1706908926_updated_waypoints.js
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id "
|
||||||
|
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id "
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
}, (db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.listRule = "@request.auth.id != \"\" && (@collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true))"
|
||||||
|
collection.viewRule = "@request.auth.id != \"\" && (@collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true))"
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
})
|
||||||
18
db/pb_migrations/1706908971_updated_waypoints.js
Normal file
18
db/pb_migrations/1706908971_updated_waypoints.js
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id "
|
||||||
|
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id "
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
}, (db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id "
|
||||||
|
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id "
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
})
|
||||||
18
db/pb_migrations/1706909005_updated_waypoints.js
Normal file
18
db/pb_migrations/1706909005_updated_waypoints.js
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
}, (db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("goeo2ubp103rzp9")
|
||||||
|
|
||||||
|
collection.listRule = "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id "
|
||||||
|
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.waypoints.id ?= id "
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
})
|
||||||
22
db/pb_migrations/1706909055_updated_summit_logs.js
Normal file
22
db/pb_migrations/1706909055_updated_summit_logs.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/// <reference path="../pb_data/types.d.ts" />
|
||||||
|
migrate((db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
|
|
||||||
|
collection.listRule = "@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
collection.viewRule = "@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id || @collection.trails.public = true)"
|
||||||
|
collection.updateRule = "@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id)"
|
||||||
|
collection.deleteRule = "@request.auth.id != \"\" && @collection.trails.summit_logs.id ?= id && (@collection.trails.author = @request.auth.id)"
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
}, (db) => {
|
||||||
|
const dao = new Dao(db)
|
||||||
|
const collection = dao.findCollectionByNameOrId("dd2l9a4vxpy2ni8")
|
||||||
|
|
||||||
|
collection.listRule = ""
|
||||||
|
collection.viewRule = ""
|
||||||
|
collection.updateRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id)"
|
||||||
|
collection.deleteRule = "@request.auth.id != \"\" && @collection.trails.waypoints ?= id && (@collection.trails.author = @request.auth.id)"
|
||||||
|
|
||||||
|
return dao.saveCollection(collection)
|
||||||
|
})
|
||||||
1
web/src/app.d.ts
vendored
1
web/src/app.d.ts
vendored
@@ -12,6 +12,7 @@ declare global {
|
|||||||
// interface Platform {}
|
// interface Platform {}
|
||||||
interface Locals {
|
interface Locals {
|
||||||
pb: PocketBase
|
pb: PocketBase
|
||||||
|
user: AuthModel | null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
8
web/src/hooks.client.ts
Normal file
8
web/src/hooks.client.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import { pb } from '$lib/pocketbase'
|
||||||
|
import { currentUser } from '$lib/stores/user_store'
|
||||||
|
|
||||||
|
pb.authStore.loadFromCookie(document.cookie)
|
||||||
|
pb.authStore.onChange(() => {
|
||||||
|
currentUser.set(pb.authStore.model)
|
||||||
|
document.cookie = pb.authStore.exportToCookie({ httpOnly: false })
|
||||||
|
}, true)
|
||||||
@@ -1,23 +1,31 @@
|
|||||||
import PocketBase from 'pocketbase';
|
import { createInstance } from '$lib/pocketbase'
|
||||||
|
import type { Handle } from '@sveltejs/kit'
|
||||||
|
|
||||||
export async function handle({ event, resolve }) {
|
export const handle: Handle = async ({ event, resolve }) => {
|
||||||
event.locals.pb = new PocketBase('http://127.0.0.1:8090');
|
const pb = createInstance()
|
||||||
|
|
||||||
// load the store data from the request cookie string
|
// load the store data from the request cookie string
|
||||||
event.locals.pb.authStore.loadFromCookie(event.request.headers.get('cookie') || '');
|
pb.authStore.loadFromCookie(event.request.headers.get('cookie') || '')
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// get an up-to-date auth store state by verifying and refreshing the loaded auth model (if any)
|
// get an up-to-date auth store state by verifying and refreshing the loaded auth model (if any)
|
||||||
event.locals.pb.authStore.isValid && await event.locals.pb.collection('users').authRefresh();
|
if (pb.authStore.isValid) {
|
||||||
|
await pb.collection('users').authRefresh()
|
||||||
|
}
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
// clear the auth store on failed refresh
|
// clear the auth store on failed refresh
|
||||||
event.locals.pb.authStore.clear();
|
pb.authStore.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await resolve(event);
|
event.locals.pb = pb
|
||||||
|
event.locals.user = pb.authStore.model
|
||||||
|
|
||||||
|
const response = await resolve(event)
|
||||||
|
|
||||||
// send back the default 'pb_auth' cookie to the client with the latest store state
|
// send back the default 'pb_auth' cookie to the client with the latest store state
|
||||||
response.headers.append('set-cookie', event.locals.pb.authStore.exportToCookie());
|
response.headers.set(
|
||||||
|
'set-cookie',
|
||||||
|
pb.authStore.exportToCookie({ httpOnly: false })
|
||||||
|
)
|
||||||
|
|
||||||
return response;
|
return response
|
||||||
}
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
<menu class="rounded-full border w-12 h-12"></menu>
|
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { createEventDispatcher } from "svelte";
|
import { createEventDispatcher } from "svelte";
|
||||||
|
|
||||||
export let items: { text: string; value: any }[] = [];
|
export let items: { text: string; value: any; icon?: string }[] = [];
|
||||||
|
export let size: string = "regular";
|
||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
@@ -26,28 +27,31 @@
|
|||||||
<svelte:window on:mouseup={() => (isOpen = false)} />
|
<svelte:window on:mouseup={() => (isOpen = false)} />
|
||||||
|
|
||||||
<div class="dropdown relative">
|
<div class="dropdown relative">
|
||||||
<button
|
<button class="flex items-center justify-center" on:click={toggleMenu} type="button">
|
||||||
class="hover:bg-gray-100 w-8 h-8 rounded-full"
|
<slot>
|
||||||
on:click={toggleMenu}
|
<i
|
||||||
type="button"
|
class="fa fa-ellipsis-vertical text-{size} hover:bg-gray-300 px-[14px] py-2 rounded-full hover:bg-opacity-50"
|
||||||
>
|
></i>
|
||||||
<i class="fa fa-ellipsis-vertical"></i>
|
</slot>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{#if isOpen}
|
{#if isOpen}
|
||||||
<ul
|
<ul
|
||||||
class="menu absolute bg-white border rounded-l-xl rounded-b-xl shadow-md z-10 right-0 overflow-hidden"
|
class="menu absolute bg-white border rounded-l-xl rounded-b-xl shadow-md right-0 overflow-hidden text-black"
|
||||||
class:none={isOpen}
|
class:none={isOpen}
|
||||||
|
style="z-index: 1001"
|
||||||
>
|
>
|
||||||
{#each items as item}
|
{#each items as item}
|
||||||
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
|
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
|
||||||
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
||||||
<li
|
<li
|
||||||
class="menu-item p-4 cursor-pointer hover:bg-gray-100 focus:bg-gray-200 transition-colors"
|
class="menu-item flex items-center p-4 cursor-pointer hover:bg-gray-100 focus:bg-gray-200 transition-colors"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
on:mouseup|stopPropagation={() => handleItemClick(item)}
|
on:mouseup|stopPropagation={() => handleItemClick(item)}
|
||||||
on:keydown|stopPropagation={() => handleItemClick(item)}
|
on:keydown|stopPropagation={() => handleItemClick(item)}
|
||||||
>
|
>
|
||||||
|
{#if item.icon}
|
||||||
|
<i class="fa fa-{item.icon} mr-6"></i>
|
||||||
|
{/if}
|
||||||
{item.text}
|
{item.text}
|
||||||
</li>
|
</li>
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
@@ -7,9 +7,9 @@
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
{#if label.length}
|
{#if label.length}
|
||||||
<p class="text-sm font-medium pb-1">
|
<label for={name} class="text-sm font-medium pb-1">
|
||||||
{label}
|
{label}
|
||||||
</p>
|
</label>
|
||||||
{/if}
|
{/if}
|
||||||
<select
|
<select
|
||||||
{name}
|
{name}
|
||||||
|
|||||||
@@ -5,13 +5,19 @@
|
|||||||
export let label: string = "";
|
export let label: string = "";
|
||||||
export let error: string = "";
|
export let error: string = "";
|
||||||
export let icon: string = "";
|
export let icon: string = "";
|
||||||
|
export let extraClasses: string = "";
|
||||||
|
export let type: "text" | "password" = "text";
|
||||||
|
|
||||||
|
function typeAction(node: HTMLInputElement) {
|
||||||
|
node.type = type;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
{#if label.length}
|
{#if label.length}
|
||||||
<p class="text-sm font-medium pb-1">
|
<label for={name} class="text-sm font-medium pb-1">
|
||||||
{label}
|
{label}
|
||||||
</p>
|
</label>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
{#if icon.length > 0}
|
{#if icon.length > 0}
|
||||||
@@ -19,10 +25,10 @@
|
|||||||
{/if}
|
{/if}
|
||||||
<input
|
<input
|
||||||
{name}
|
{name}
|
||||||
class="bg-gray-50 border rounded-md p-3 transition-colors focus:border-primary focus:outline-none focus:ring-0 w-full"
|
class="bg-gray-50 border rounded-md p-3 transition-colors focus:border-primary focus:outline-none focus:ring-0 w-full {extraClasses}"
|
||||||
class:border-red-400={error.length > 0}
|
class:border-red-400={error.length > 0}
|
||||||
class:bg-red-50={error.length > 0}
|
class:bg-red-50={error.length > 0}
|
||||||
type="text"
|
use:typeAction
|
||||||
bind:value
|
bind:value
|
||||||
on:change
|
on:change
|
||||||
{placeholder}
|
{placeholder}
|
||||||
|
|||||||
@@ -1,27 +1,44 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { toast } from "$lib/stores/toast_store";
|
import { toast } from "$lib/stores/toast_store";
|
||||||
|
import { fade } from "svelte/transition";
|
||||||
|
|
||||||
$: getBackgroundColor = () => {
|
function closeToast() {
|
||||||
if ($toast && $toast.type == "success") {
|
toast.set(null);
|
||||||
return "green-200";
|
|
||||||
}
|
}
|
||||||
return "";
|
|
||||||
};
|
|
||||||
|
|
||||||
$: getBorderColor = () => {
|
|
||||||
if ($toast && $toast.type == "success") {
|
|
||||||
return "green-500";
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if $toast}
|
{#if $toast}
|
||||||
<div
|
<div
|
||||||
class="fixed px-8 py-4 shadow-xl rounded-xl border bottom-4 right-4 bg-{getBackgroundColor()} border-{getBorderColor()}"
|
class="fixed px-4 py-3 shadow-xl rounded-xl border bottom-4 right-4 bg-white text-gray-500 flex items-center"
|
||||||
style="z-index: 1000;"
|
style="z-index: 1001;"
|
||||||
|
in:fade={{ duration: 250 }}
|
||||||
|
out:fade={{ duration: 250 }}
|
||||||
>
|
>
|
||||||
<i class="fa fa-{$toast.icon} mr-2"></i>
|
<span>
|
||||||
<span>{$toast.text}</span>
|
<i
|
||||||
|
class="fa fa-{$toast.icon} p-3 mr-2 rounded-lg"
|
||||||
|
class:success-toast={$toast.type == "success"}
|
||||||
|
class:error-toast={$toast.type == "error"}
|
||||||
|
></i>{$toast.text}</span
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 ms-auto inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white ml-6"
|
||||||
|
on:click={closeToast}
|
||||||
|
>
|
||||||
|
<i class="fa fa-close"></i>
|
||||||
|
<span class="sr-only">Close modal</span>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.success-toast {
|
||||||
|
color: #10b981;
|
||||||
|
background-color: #a7f3d0;
|
||||||
|
}
|
||||||
|
.error-toast {
|
||||||
|
color: #ef4444;
|
||||||
|
background-color: #fecaca;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
18
web/src/lib/components/base/toggle.svelte
Normal file
18
web/src/lib/components/base/toggle.svelte
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
export let name: string = "";
|
||||||
|
export let value: boolean = false;
|
||||||
|
export let label: string = "";
|
||||||
|
export let error: string = "";
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<label class="relative my-2 inline-flex items-center cursor-pointer">
|
||||||
|
<input {name} bind:checked={value} type="checkbox" class="sr-only peer" value="1"/>
|
||||||
|
<div
|
||||||
|
class="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-gray-400 rounded-full peer peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-primary"
|
||||||
|
></div>
|
||||||
|
<span class="ms-3 text-sm font-medium">{label}</span>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<span class="toggle-error text-xs text-red-400">
|
||||||
|
{error}
|
||||||
|
</span>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
import LogoTextLight from "./logo_text_light.svelte";
|
import LogoTextLight from "./logo/logo_text_light.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<footer class="bg-primary text-white w-full grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-y-8 p-12 mt-12 rounded-t-3xl">
|
<footer class="bg-primary text-white w-full grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-y-8 p-12 mt-12 rounded-t-3xl">
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
33
web/src/lib/components/logo/logo_text_two_line.svelte
Normal file
33
web/src/lib/components/logo/logo_text_two_line.svelte
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 11 KiB |
@@ -1,10 +1,25 @@
|
|||||||
<script>
|
<script lang="ts">
|
||||||
import Avatar from "./avatar.svelte";
|
import { goto } from "$app/navigation";
|
||||||
import LogoText from "./logo_text.svelte";
|
import LogoText from "$lib/components/logo/logo_text.svelte";
|
||||||
|
import { logout, currentUser } from "$lib/stores/user_store";
|
||||||
|
import Dropdown from "./base/dropdown.svelte";
|
||||||
|
|
||||||
|
const dropdownItems = [
|
||||||
|
{ text: "Profile", value: "profile", icon: "user" },
|
||||||
|
{ text: "Logout", value: "logout", icon: "right-from-bracket" },
|
||||||
|
];
|
||||||
|
|
||||||
|
function handleDropdownClick(item: { text: string; value: any }) {
|
||||||
|
if (item.value == "logout") {
|
||||||
|
logout();
|
||||||
|
goto("/login");
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<nav class="flex justify-between items-center p-6">
|
<nav class="flex justify-between items-center p-6">
|
||||||
<a href="/"><LogoText></LogoText></a>
|
<a href="/"><LogoText></LogoText></a>
|
||||||
|
{#if $currentUser}
|
||||||
<menu class="flex gap-8">
|
<menu class="flex gap-8">
|
||||||
<a class="font-semibold" href="">Trails</a>
|
<a class="font-semibold" href="">Trails</a>
|
||||||
<a class="font-semibold" href="">Map</a>
|
<a class="font-semibold" href="">Map</a>
|
||||||
@@ -12,7 +27,21 @@
|
|||||||
<a class="font-semibold" href="">Favorites</a>
|
<a class="font-semibold" href="">Favorites</a>
|
||||||
</menu>
|
</menu>
|
||||||
<div class="flex gap-6 items-center">
|
<div class="flex gap-6 items-center">
|
||||||
<a class="btn-primary btn-large" href="/trail/edit/new"><i class="fa fa-plus mr-2"></i>New Trail</a>
|
<a class="btn-primary btn-large" href="/trail/edit/new"
|
||||||
<Avatar></Avatar>
|
><i class="fa fa-plus mr-2"></i>New Trail</a
|
||||||
|
>
|
||||||
|
<Dropdown
|
||||||
|
items={dropdownItems}
|
||||||
|
on:change={(e) => handleDropdownClick(e.detail)}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
class="w-12 h-h12 rounded-full"
|
||||||
|
src="https://api.dicebear.com/7.x/initials/svg?seed={$currentUser.username}&backgroundType=gradientLinear"
|
||||||
|
alt=""
|
||||||
|
/>
|
||||||
|
</Dropdown>
|
||||||
</div>
|
</div>
|
||||||
|
{:else}
|
||||||
|
<a class="btn-primary btn-large" href="/login">Login</a>
|
||||||
|
{/if}
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
import PocketBase from 'pocketbase';
|
|
||||||
import { env } from "$env/dynamic/public";
|
|
||||||
|
|
||||||
const pb = new PocketBase(env.PUBLIC_DB_HOST);
|
|
||||||
|
|
||||||
export { pb }
|
|
||||||
@@ -7,6 +7,7 @@ class Trail {
|
|||||||
id?: string;
|
id?: string;
|
||||||
name: string;
|
name: string;
|
||||||
location?: string;
|
location?: string;
|
||||||
|
public: boolean;
|
||||||
distance?: number;
|
distance?: number;
|
||||||
elevation_gain?: number;
|
elevation_gain?: number;
|
||||||
duration?: number;
|
duration?: number;
|
||||||
@@ -28,6 +29,7 @@ class Trail {
|
|||||||
params?: {
|
params?: {
|
||||||
id?: string,
|
id?: string,
|
||||||
location?: string,
|
location?: string,
|
||||||
|
public?: boolean,
|
||||||
distance?: number,
|
distance?: number,
|
||||||
elevation_gain?: number,
|
elevation_gain?: number,
|
||||||
duration?: number,
|
duration?: number,
|
||||||
@@ -45,6 +47,7 @@ class Trail {
|
|||||||
this.id = params?.id;
|
this.id = params?.id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.location = params?.location;
|
this.location = params?.location;
|
||||||
|
this.public = params?.public ?? false
|
||||||
this.distance = params?.distance;
|
this.distance = params?.distance;
|
||||||
this.elevation_gain = params?.elevation_gain;
|
this.elevation_gain = params?.elevation_gain;
|
||||||
this.duration = params?.duration;
|
this.duration = params?.duration;
|
||||||
|
|||||||
8
web/src/lib/pocketbase.ts
Normal file
8
web/src/lib/pocketbase.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import { PUBLIC_POCKETBASE_URL } from '$env/static/public'
|
||||||
|
import PocketBase from 'pocketbase'
|
||||||
|
|
||||||
|
export function createInstance() {
|
||||||
|
return new PocketBase(PUBLIC_POCKETBASE_URL)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const pb = createInstance()
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { pb } from "$lib/constants";
|
import { pb } from "$lib/pocketbase";
|
||||||
import type { Category } from "$lib/models/category";
|
import type { Category } from "$lib/models/category";
|
||||||
import { writable, type Writable } from "svelte/store";
|
import { writable, type Writable } from "svelte/store";
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { pb } from "$lib/constants";
|
import { pb } from "$lib/pocketbase";
|
||||||
import { SummitLog } from "$lib/models/summit_log";
|
import { SummitLog } from "$lib/models/summit_log";
|
||||||
import { writable, type Writable } from "svelte/store";
|
import { writable, type Writable } from "svelte/store";
|
||||||
|
|
||||||
@@ -12,9 +12,17 @@ export async function summit_logs_create(bodyParams?: { [key: string]: any; } |
|
|||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function summit_logs_update(updatedSummitLog: SummitLog) {
|
||||||
|
const model = await pb
|
||||||
|
.collection("summit_logs")
|
||||||
|
.update(updatedSummitLog.id!, updatedSummitLog);
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
export async function summit_logs_delete(id: string) {
|
export async function summit_logs_delete(id: string) {
|
||||||
const success = await pb
|
const success = await pb
|
||||||
.collection("summit_logs_delete")
|
.collection("summit_logs")
|
||||||
.delete(id);
|
.delete(id);
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
|
|||||||
@@ -7,4 +7,11 @@ export type Toast = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const toast: Writable<Toast> = writable();
|
export const toast: Writable<Toast | null> = writable();
|
||||||
|
|
||||||
|
|
||||||
|
export function show_toast(newToast: Toast, duration: number = 3000) {
|
||||||
|
toast.set(newToast);
|
||||||
|
|
||||||
|
setTimeout(() => toast.set(null), duration);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import { pb } from "$lib/constants";
|
|
||||||
import { Trail } from "$lib/models/trail";
|
|
||||||
import { getFileURL } from "$lib/util/file_util";
|
|
||||||
import { writable, type Writable } from "svelte/store";
|
|
||||||
import { waypoints_create, waypoints_delete } from "./waypoint_store";
|
|
||||||
import { summit_logs_create, summit_logs_delete } from "./summit_log_store";
|
|
||||||
import type { Waypoint } from "$lib/models/waypoint";
|
|
||||||
import type { SummitLog } from "$lib/models/summit_log";
|
import type { SummitLog } from "$lib/models/summit_log";
|
||||||
|
import { Trail } from "$lib/models/trail";
|
||||||
|
import type { Waypoint } from "$lib/models/waypoint";
|
||||||
|
import { pb } from "$lib/pocketbase";
|
||||||
|
import { getFileURL } from "$lib/util/file_util";
|
||||||
|
import { util } from "$lib/vendor/svelte-form-lib/util";
|
||||||
|
import { writable, type Writable } from "svelte/store";
|
||||||
|
import { summit_logs_create, summit_logs_delete, summit_logs_update } from "./summit_log_store";
|
||||||
|
import { waypoints_create, waypoints_delete, waypoints_update } from "./waypoint_store";
|
||||||
|
|
||||||
export const trails: Writable<Trail[]> = writable([])
|
export const trails: Writable<Trail[]> = writable([])
|
||||||
export const trail: Writable<Trail> = writable(new Trail(""));
|
export const trail: Writable<Trail> = writable(new Trail(""));
|
||||||
@@ -45,6 +46,11 @@ export async function trails_show(id: string, loadGPX?: boolean) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function trails_create(trail: Trail, formData: { [key: string]: any; } | FormData) {
|
export async function trails_create(trail: Trail, formData: { [key: string]: any; } | FormData) {
|
||||||
|
|
||||||
|
if (!pb.authStore.model) {
|
||||||
|
throw new Error("Unauthenticated");
|
||||||
|
;
|
||||||
|
}
|
||||||
formData.set("category", trail.expand.category!.id);
|
formData.set("category", trail.expand.category!.id);
|
||||||
|
|
||||||
for (const file of trail._photoFiles) {
|
for (const file of trail._photoFiles) {
|
||||||
@@ -62,6 +68,13 @@ export async function trails_create(trail: Trail, formData: { [key: string]: any
|
|||||||
const model = await summit_logs_create(summitLog);
|
const model = await summit_logs_create(summitLog);
|
||||||
formData.append("summit_logs", model.id!);
|
formData.append("summit_logs", model.id!);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!formData.get("public")) {
|
||||||
|
formData.set("public", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
formData.append("author", pb.authStore.model!.id);
|
||||||
|
|
||||||
let model = await pb
|
let model = await pb
|
||||||
.collection("trails")
|
.collection("trails")
|
||||||
.create<Trail>(formData);
|
.create<Trail>(formData);
|
||||||
@@ -93,6 +106,13 @@ export async function trails_update(oldTrail: Trail, newTrail: Trail, formData:
|
|||||||
formData.append("waypoints+", model.id!);
|
formData.append("waypoints+", model.id!);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const updatedWaypoint of waypointUpdates.updated) {
|
||||||
|
const model = await waypoints_update({
|
||||||
|
...updatedWaypoint,
|
||||||
|
marker: undefined,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
for (const deletedWaypoint of waypointUpdates.deleted) {
|
for (const deletedWaypoint of waypointUpdates.deleted) {
|
||||||
const success = await waypoints_delete(deletedWaypoint.id!);
|
const success = await waypoints_delete(deletedWaypoint.id!);
|
||||||
}
|
}
|
||||||
@@ -104,6 +124,10 @@ export async function trails_update(oldTrail: Trail, newTrail: Trail, formData:
|
|||||||
formData.append("summit_logs+", model.id!);
|
formData.append("summit_logs+", model.id!);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const updatedSummitLog of summitLogUpdates.updated) {
|
||||||
|
const model = await summit_logs_update(updatedSummitLog);
|
||||||
|
}
|
||||||
|
|
||||||
for (const deletedSummitLog of summitLogUpdates.deleted) {
|
for (const deletedSummitLog of summitLogUpdates.deleted) {
|
||||||
const success = await summit_logs_delete(deletedSummitLog.id!);
|
const success = await summit_logs_delete(deletedSummitLog.id!);
|
||||||
}
|
}
|
||||||
@@ -122,6 +146,10 @@ export async function trails_update(oldTrail: Trail, newTrail: Trail, formData:
|
|||||||
formData.delete("gpx");
|
formData.delete("gpx");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!formData.get("public")) {
|
||||||
|
formData.set("public", 0);
|
||||||
|
}
|
||||||
|
|
||||||
const thumbnailIndex = newTrail.photos.findIndex(
|
const thumbnailIndex = newTrail.photos.findIndex(
|
||||||
(p) => p == newTrail.thumbnail,
|
(p) => p == newTrail.thumbnail,
|
||||||
);
|
);
|
||||||
@@ -137,7 +165,7 @@ export async function trails_update(oldTrail: Trail, newTrail: Trail, formData:
|
|||||||
|
|
||||||
model = await pb
|
model = await pb
|
||||||
.collection("trails")
|
.collection("trails")
|
||||||
.update<Trail>(model.id!, { thumbnail: thumbnail });
|
.update<Trail>(model.id!, { thumbnail: thumbnail }, { expand: "category,waypoints,summit_logs" });
|
||||||
|
|
||||||
trail.set(model);
|
trail.set(model);
|
||||||
|
|
||||||
@@ -145,10 +173,21 @@ export async function trails_update(oldTrail: Trail, newTrail: Trail, formData:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export async function trails_delete(id: string) {
|
export async function trails_delete(trail: Trail) {
|
||||||
|
if (trail.expand.waypoints) {
|
||||||
|
for (const waypoint of trail.expand.waypoints) {
|
||||||
|
waypoints_delete(waypoint.id!);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (trail.expand.summit_logs) {
|
||||||
|
for (const summit_log of trail.expand.summit_logs) {
|
||||||
|
summit_logs_delete(summit_log.id!);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const success = await pb
|
const success = await pb
|
||||||
.collection("trails")
|
.collection("trails")
|
||||||
.delete(id);
|
.delete(trail.id!);
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
@@ -173,12 +212,22 @@ function setFileURLs(trail: Trail) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function compareObjectArrays<T extends { id?: string }>(oldArray: T[], newArray: T[]) {
|
function compareObjectArrays<T extends { id?: string }>(oldArray: T[], newArray: T[]) {
|
||||||
const newObjects = newArray.filter(newObj => !oldArray.find(oldObj => oldObj.id === newObj.id));
|
const newObjects = [];
|
||||||
|
const updatedObjects = [];
|
||||||
|
for (const newObj of newArray) {
|
||||||
|
const oldObj = oldArray.find(oldObj => oldObj.id === newObj.id)
|
||||||
|
if (!oldObj) {
|
||||||
|
newObjects.push(newObj);
|
||||||
|
} else if (!util.deepEqual(newObj, oldObj)) {
|
||||||
|
updatedObjects.push(newObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
const deletedObjects = oldArray.filter(oldObj => !newArray.find(newObj => newObj.id === oldObj.id));
|
const deletedObjects = oldArray.filter(oldObj => !newArray.find(newObj => newObj.id === oldObj.id));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
added: newObjects,
|
added: newObjects,
|
||||||
deleted: deletedObjects
|
deleted: deletedObjects,
|
||||||
|
updated: updatedObjects
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
25
web/src/lib/stores/user_store.ts
Normal file
25
web/src/lib/stores/user_store.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { pb } from "$lib/pocketbase";
|
||||||
|
import { type AuthModel } from 'pocketbase';
|
||||||
|
import { writable, type Writable } from "svelte/store";
|
||||||
|
|
||||||
|
export type User = {
|
||||||
|
username?: string,
|
||||||
|
email?: string,
|
||||||
|
password: string,
|
||||||
|
}
|
||||||
|
|
||||||
|
export const currentUser: Writable<AuthModel | null> = writable<AuthModel | null>()
|
||||||
|
|
||||||
|
export async function users_create(user: User) {
|
||||||
|
const model = await pb.collection('users').create({ ...user, passwordConfirm: user.password });
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function login(user: User) {
|
||||||
|
const authData = await pb.collection('users').authWithPassword(user.email ?? user.username!, user.password);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function logout() {
|
||||||
|
pb.authStore.clear();
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { pb } from "$lib/constants";
|
import { pb } from "$lib/pocketbase";
|
||||||
import { Waypoint } from "$lib/models/waypoint";
|
import { Waypoint } from "$lib/models/waypoint";
|
||||||
import { writable, type Writable } from "svelte/store";
|
import { writable, type Writable } from "svelte/store";
|
||||||
|
|
||||||
@@ -13,6 +13,14 @@ export async function waypoints_create(bodyParams?: { [key: string]: any; } | Fo
|
|||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function waypoints_update(updatedWaypoint: Waypoint) {
|
||||||
|
const model = await pb
|
||||||
|
.collection("waypoints")
|
||||||
|
.update(updatedWaypoint.id!, updatedWaypoint);
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
export async function waypoints_delete(id: string) {
|
export async function waypoints_delete(id: string) {
|
||||||
const success = await pb
|
const success = await pb
|
||||||
.collection("waypoints")
|
.collection("waypoints")
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { pb } from "$lib/constants";
|
import { pb } from "$lib/pocketbase";
|
||||||
import type { FileOptions } from "pocketbase";
|
import type { FileOptions } from "pocketbase";
|
||||||
|
|
||||||
export function getFileURL(record: { [key: string]: any; }, filename?: string, options?: FileOptions) {
|
export function getFileURL(record: { [key: string]: any; }, filename?: string, options?: FileOptions) {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
trails_delete,
|
trails_delete,
|
||||||
trails_index,
|
trails_index,
|
||||||
} from "$lib/stores/trail_store";
|
} from "$lib/stores/trail_store";
|
||||||
|
import { currentUser } from "$lib/stores/user_store";
|
||||||
import { waypoints_delete } from "$lib/stores/waypoint_store";
|
import { waypoints_delete } from "$lib/stores/waypoint_store";
|
||||||
|
|
||||||
async function handleDropdownClick(
|
async function handleDropdownClick(
|
||||||
@@ -19,18 +20,7 @@
|
|||||||
if (item.value == "edit") {
|
if (item.value == "edit") {
|
||||||
goto(`/trail/edit/${currentTrail.id}`);
|
goto(`/trail/edit/${currentTrail.id}`);
|
||||||
} else if (item.value == "delete") {
|
} else if (item.value == "delete") {
|
||||||
if (currentTrail.expand.waypoints) {
|
await trails_delete(currentTrail);
|
||||||
for (const waypoint of currentTrail.expand.waypoints) {
|
|
||||||
waypoints_delete(waypoint.id!);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (currentTrail.expand.summit_logs) {
|
|
||||||
for (const summit_log of currentTrail.expand.summit_logs) {
|
|
||||||
summit_logs_delete(summit_log.id!);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await trails_delete(currentTrail.id!);
|
|
||||||
await trails_index();
|
await trails_index();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,7 +41,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section class="max-w-7xl mx-auto mt-8 px-8 xl:px-0">
|
<section class="max-w-7xl mx-auto mt-8 px-8 xl:px-0">
|
||||||
<h2 class="text-5xl md:text-6xl font-bold text-primary">Your trails</h2>
|
<h2 class="text-5xl md:text-6xl font-bold text-primary">{$currentUser ? 'Your' : 'Explore'} trails</h2>
|
||||||
<div
|
<div
|
||||||
id="trails"
|
id="trails"
|
||||||
class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 justify-items-center gap-8 py-8"
|
class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 justify-items-center gap-8 py-8"
|
||||||
|
|||||||
88
web/src/routes/login/+page.svelte
Normal file
88
web/src/routes/login/+page.svelte
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { goto } from "$app/navigation";
|
||||||
|
import Button from "$lib/components/base/button.svelte";
|
||||||
|
import TextField from "$lib/components/base/text_field.svelte";
|
||||||
|
import LogoTextTwoLine from "$lib/components/logo/logo_text_two_line.svelte";
|
||||||
|
import { show_toast } from "$lib/stores/toast_store";
|
||||||
|
import { login, type User } from "$lib/stores/user_store";
|
||||||
|
import { createForm } from "$lib/vendor/svelte-form-lib";
|
||||||
|
import { ClientResponseError } from "pocketbase";
|
||||||
|
import { object, string } from "yup";
|
||||||
|
|
||||||
|
let loading: boolean = false;
|
||||||
|
const { form, errors, handleChange, handleSubmit } = createForm<User>({
|
||||||
|
initialValues: {
|
||||||
|
username: "",
|
||||||
|
password: "",
|
||||||
|
},
|
||||||
|
validationSchema: object<User>({
|
||||||
|
username: string().required("Required"),
|
||||||
|
password: string().required("Required"),
|
||||||
|
}),
|
||||||
|
onSubmit: async (newUser) => {
|
||||||
|
loading = true;
|
||||||
|
try {
|
||||||
|
await login(newUser);
|
||||||
|
goto(`/`);
|
||||||
|
} catch (e) {
|
||||||
|
if (
|
||||||
|
e instanceof ClientResponseError &&
|
||||||
|
e.message == "Failed to authenticate."
|
||||||
|
) {
|
||||||
|
show_toast({
|
||||||
|
icon: "close",
|
||||||
|
type: "error",
|
||||||
|
text: "Wrong username or password.",
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
show_toast({
|
||||||
|
icon: "close",
|
||||||
|
type: "error",
|
||||||
|
text: "Error during login.",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
loading = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<main class="flex justify-center">
|
||||||
|
<form
|
||||||
|
class="login-panel max-w-md shadow-lg rounded-xl p-8 flex flex-col justify-center items-center gap-8 w-[28rem] mt-8"
|
||||||
|
on:submit={handleSubmit}
|
||||||
|
>
|
||||||
|
<LogoTextTwoLine></LogoTextTwoLine>
|
||||||
|
<h4 class="text-xl font-semibold">Save your adventures!</h4>
|
||||||
|
<div class="space-y-6 w-80">
|
||||||
|
<TextField
|
||||||
|
name="username"
|
||||||
|
label="Username/Email"
|
||||||
|
bind:value={$form.username}
|
||||||
|
on:change={handleChange}
|
||||||
|
error={$errors.username}
|
||||||
|
></TextField>
|
||||||
|
<TextField
|
||||||
|
name="password"
|
||||||
|
label="Password"
|
||||||
|
type="password"
|
||||||
|
bind:value={$form.password}
|
||||||
|
on:change={handleChange}
|
||||||
|
error={$errors.password}
|
||||||
|
></TextField>
|
||||||
|
<Button
|
||||||
|
primary={true}
|
||||||
|
extraClasses={"min-w-full"}
|
||||||
|
type="submit"
|
||||||
|
{loading}>Login</Button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<span
|
||||||
|
>Don't have an account? <a
|
||||||
|
class="text-blue-500 underline"
|
||||||
|
href="/register">Make one!</a
|
||||||
|
></span
|
||||||
|
>
|
||||||
|
</form>
|
||||||
|
</main>
|
||||||
98
web/src/routes/register/+page.svelte
Normal file
98
web/src/routes/register/+page.svelte
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { goto } from "$app/navigation";
|
||||||
|
import Button from "$lib/components/base/button.svelte";
|
||||||
|
import TextField from "$lib/components/base/text_field.svelte";
|
||||||
|
import LogoTextTwoLine from "$lib/components/logo/logo_text_two_line.svelte";
|
||||||
|
import { show_toast } from "$lib/stores/toast_store";
|
||||||
|
import { users_create, type User, login } from "$lib/stores/user_store";
|
||||||
|
import { createForm } from "$lib/vendor/svelte-form-lib";
|
||||||
|
import { object, string } from "yup";
|
||||||
|
|
||||||
|
let loading: boolean = false;
|
||||||
|
const { form, errors, handleChange, handleSubmit } = createForm<User>({
|
||||||
|
initialValues: {
|
||||||
|
username: "",
|
||||||
|
email: "",
|
||||||
|
password: "",
|
||||||
|
},
|
||||||
|
validationSchema: object<User>({
|
||||||
|
username: string().required("Required"),
|
||||||
|
email: string().email().required("Required"),
|
||||||
|
password: string()
|
||||||
|
.min(8, "Must be at least 8 characters long")
|
||||||
|
.required("Required"),
|
||||||
|
}),
|
||||||
|
onSubmit: async (newUser) => {
|
||||||
|
loading = true;
|
||||||
|
try {
|
||||||
|
await users_create(newUser);
|
||||||
|
} catch (e) {
|
||||||
|
show_toast({
|
||||||
|
icon: "close",
|
||||||
|
type: "error",
|
||||||
|
text: "Error creating user.",
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
loading = false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await login(newUser);
|
||||||
|
goto(`/`);
|
||||||
|
} catch (e) {
|
||||||
|
show_toast({
|
||||||
|
icon: "close",
|
||||||
|
type: "error",
|
||||||
|
text: "Error during login.",
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
loading = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<main class="flex justify-center">
|
||||||
|
<form
|
||||||
|
class="login-panel max-w-md shadow-lg rounded-xl p-8 flex flex-col justify-center items-center gap-8 w-[28rem] mt-8"
|
||||||
|
on:submit={handleSubmit}
|
||||||
|
>
|
||||||
|
<LogoTextTwoLine></LogoTextTwoLine>
|
||||||
|
<h4 class="text-xl font-semibold">Save your adventures!</h4>
|
||||||
|
<div class="space-y-6 w-80">
|
||||||
|
<TextField
|
||||||
|
name="username"
|
||||||
|
label="Username"
|
||||||
|
bind:value={$form.username}
|
||||||
|
on:change={handleChange}
|
||||||
|
error={$errors.username}
|
||||||
|
></TextField>
|
||||||
|
<TextField
|
||||||
|
name="email"
|
||||||
|
label="Email"
|
||||||
|
bind:value={$form.email}
|
||||||
|
on:change={handleChange}
|
||||||
|
error={$errors.email}
|
||||||
|
></TextField>
|
||||||
|
<TextField
|
||||||
|
name="password"
|
||||||
|
label="Password"
|
||||||
|
type="password"
|
||||||
|
bind:value={$form.password}
|
||||||
|
on:change={handleChange}
|
||||||
|
error={$errors.password}
|
||||||
|
></TextField>
|
||||||
|
<Button
|
||||||
|
primary={true}
|
||||||
|
extraClasses={"min-w-full"}
|
||||||
|
type="submit"
|
||||||
|
{loading}>Register</Button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<span
|
||||||
|
>Already have an account? <a
|
||||||
|
class="text-blue-500 underline"
|
||||||
|
href="/login">Login!</a
|
||||||
|
></span
|
||||||
|
>
|
||||||
|
</form>
|
||||||
|
</main>
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
import Select from "$lib/components/base/select.svelte";
|
import Select from "$lib/components/base/select.svelte";
|
||||||
import TextField from "$lib/components/base/text_field.svelte";
|
import TextField from "$lib/components/base/text_field.svelte";
|
||||||
import Textarea from "$lib/components/base/textarea.svelte";
|
import Textarea from "$lib/components/base/textarea.svelte";
|
||||||
|
import Toggle from "$lib/components/base/toggle.svelte";
|
||||||
import PhotoCard from "$lib/components/photo_card.svelte";
|
import PhotoCard from "$lib/components/photo_card.svelte";
|
||||||
import SummitLogCard from "$lib/components/summit_log/summit_log_card.svelte";
|
import SummitLogCard from "$lib/components/summit_log/summit_log_card.svelte";
|
||||||
import SummitLogModal from "$lib/components/summit_log/summit_log_modal.svelte";
|
import SummitLogModal from "$lib/components/summit_log/summit_log_modal.svelte";
|
||||||
@@ -13,7 +14,7 @@
|
|||||||
import { Waypoint } from "$lib/models/waypoint";
|
import { Waypoint } from "$lib/models/waypoint";
|
||||||
import { categories } from "$lib/stores/category_store";
|
import { categories } from "$lib/stores/category_store";
|
||||||
import { summitLog } from "$lib/stores/summit_log_store";
|
import { summitLog } from "$lib/stores/summit_log_store";
|
||||||
import { toast } from "$lib/stores/toast_store";
|
import { show_toast } from "$lib/stores/toast_store";
|
||||||
import {
|
import {
|
||||||
trail,
|
trail,
|
||||||
trails_create,
|
trails_create,
|
||||||
@@ -84,9 +85,19 @@
|
|||||||
await trails_update($trail, submittedTrail, formData);
|
await trails_update($trail, submittedTrail, formData);
|
||||||
}
|
}
|
||||||
|
|
||||||
toast.set({type: "success", "icon": "check", "text": "Trail saved successfully!"})
|
show_toast({
|
||||||
|
type: "success",
|
||||||
|
icon: "check",
|
||||||
|
text: "Trail saved successfully.",
|
||||||
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
|
||||||
|
show_toast({
|
||||||
|
type: "error",
|
||||||
|
icon: "close",
|
||||||
|
text: "Error saving trail.",
|
||||||
|
});
|
||||||
} finally {
|
} finally {
|
||||||
loading = false;
|
loading = false;
|
||||||
}
|
}
|
||||||
@@ -304,6 +315,7 @@
|
|||||||
e: CustomEvent<{ text: string; value: string }>,
|
e: CustomEvent<{ text: string; value: string }>,
|
||||||
) {
|
) {
|
||||||
if (e.detail.value === "edit") {
|
if (e.detail.value === "edit") {
|
||||||
|
currentSummitLog.date = format(currentSummitLog.date, "yyyy-MM-dd");
|
||||||
summitLog.set(currentSummitLog);
|
summitLog.set(currentSummitLog);
|
||||||
openSummitLogModal();
|
openSummitLogModal();
|
||||||
} else if (e.detail.value === "delete") {
|
} else if (e.detail.value === "delete") {
|
||||||
@@ -375,12 +387,15 @@
|
|||||||
label="Describe your trail"
|
label="Describe your trail"
|
||||||
bind:value={$form.description}
|
bind:value={$form.description}
|
||||||
></Textarea>
|
></Textarea>
|
||||||
|
{#if $form.expand.category}
|
||||||
<Select
|
<Select
|
||||||
name="category"
|
name="category"
|
||||||
label="Category"
|
label="Category"
|
||||||
bind:value={$form.expand.category}
|
bind:value={$form.expand.category.id}
|
||||||
items={$categories.map((c) => ({ text: c.name, value: c }))}
|
items={$categories.map((c) => ({ text: c.name, value: c.id }))}
|
||||||
></Select>
|
></Select>
|
||||||
|
{/if}
|
||||||
|
<Toggle name="public" label="Public" bind:value={$form.public}></Toggle>
|
||||||
<hr />
|
<hr />
|
||||||
<h3 class="text-xl font-semibold">Waypoints</h3>
|
<h3 class="text-xl font-semibold">Waypoints</h3>
|
||||||
<ul>
|
<ul>
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { goto } from "$app/navigation";
|
||||||
|
import Dropdown from "$lib/components/base/dropdown.svelte";
|
||||||
import SummitLogCard from "$lib/components/summit_log/summit_log_card.svelte";
|
import SummitLogCard from "$lib/components/summit_log/summit_log_card.svelte";
|
||||||
import Tabs from "$lib/components/tabs.svelte";
|
import Tabs from "$lib/components/tabs.svelte";
|
||||||
import WaypointCard from "$lib/components/waypoint/waypoint_card.svelte";
|
import WaypointCard from "$lib/components/waypoint/waypoint_card.svelte";
|
||||||
import { trail } from "$lib/stores/trail_store";
|
import {
|
||||||
|
trail,
|
||||||
|
trails_delete,
|
||||||
|
trails_index,
|
||||||
|
} from "$lib/stores/trail_store";
|
||||||
import { formatMeters, formatTimeHHMM } from "$lib/util/format_util";
|
import { formatMeters, formatTimeHHMM } from "$lib/util/format_util";
|
||||||
import { createMarkerFromWaypoint } from "$lib/util/leaflet_util";
|
import { createMarkerFromWaypoint } from "$lib/util/leaflet_util";
|
||||||
import type { Icon, Marker } from "leaflet";
|
import type { Icon, Marker } from "leaflet";
|
||||||
@@ -12,6 +18,7 @@
|
|||||||
import PhotoSwipeLightbox from "photoswipe/lightbox";
|
import PhotoSwipeLightbox from "photoswipe/lightbox";
|
||||||
import "photoswipe/style.css";
|
import "photoswipe/style.css";
|
||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
|
import { fade } from "svelte/transition";
|
||||||
|
|
||||||
const tabs = ["Description", "Waypoints", "Photos", "Summit book"];
|
const tabs = ["Description", "Waypoints", "Photos", "Summit book"];
|
||||||
|
|
||||||
@@ -22,6 +29,11 @@
|
|||||||
let lightbox: PhotoSwipeLightbox;
|
let lightbox: PhotoSwipeLightbox;
|
||||||
let lightboxDataSource: DataSource;
|
let lightboxDataSource: DataSource;
|
||||||
|
|
||||||
|
const dropdownItems = [
|
||||||
|
{ text: "Edit", value: "edit" },
|
||||||
|
{ text: "Delete", value: "delete" },
|
||||||
|
];
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
const L = (await import("leaflet")).default;
|
const L = (await import("leaflet")).default;
|
||||||
await import("leaflet-gpx");
|
await import("leaflet-gpx");
|
||||||
@@ -109,17 +121,23 @@
|
|||||||
function openGallery(idx: number) {
|
function openGallery(idx: number) {
|
||||||
lightbox?.loadAndOpen(idx, lightboxDataSource);
|
lightbox?.loadAndOpen(idx, lightboxDataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function handleDropdownClick(item: { text: string; value: any }) {
|
||||||
|
if (item.value == "edit") {
|
||||||
|
goto(`/trail/edit/${$trail.id}`);
|
||||||
|
} else if (item.value == "delete") {
|
||||||
|
await trails_delete($trail);
|
||||||
|
await trails_index();
|
||||||
|
goto(`/`);
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="trail-panel max-w-5xl mx-auto shadow-2xl rounded-3xl overflow-hidden"
|
class="trail-panel max-w-5xl mx-auto shadow-2xl rounded-3xl overflow-hidden"
|
||||||
>
|
>
|
||||||
<section class="relative h-80">
|
<section class="relative h-80">
|
||||||
<img
|
<img class="w-full h-80" src={$trail.thumbnail} alt="" />
|
||||||
class="w-full h-80"
|
|
||||||
src={$trail.thumbnail}
|
|
||||||
alt=""
|
|
||||||
/>
|
|
||||||
<div
|
<div
|
||||||
class="absolute bottom-0 w-full h-1/2 bg-gradient-to-b from-transparent to-black opacity-50"
|
class="absolute bottom-0 w-full h-1/2 bg-gradient-to-b from-transparent to-black opacity-50"
|
||||||
></div>
|
></div>
|
||||||
@@ -132,6 +150,13 @@
|
|||||||
{$trail.location}
|
{$trail.location}
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="absolute text-white bottom-8 right-8">
|
||||||
|
<Dropdown
|
||||||
|
size="2xl"
|
||||||
|
items={dropdownItems}
|
||||||
|
on:change={(e) => handleDropdownClick(e.detail)}
|
||||||
|
></Dropdown>
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section
|
<section
|
||||||
class="grid grid-cols-2 sm:grid-cols-4 gap-y-4 justify-around py-8"
|
class="grid grid-cols-2 sm:grid-cols-4 gap-y-4 justify-around py-8"
|
||||||
@@ -154,12 +179,14 @@
|
|||||||
>{formatTimeHHMM($trail.duration)}</span
|
>{formatTimeHHMM($trail.duration)}</span
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
{#if $trail.expand.category}
|
||||||
<div class="flex flex-col items-center">
|
<div class="flex flex-col items-center">
|
||||||
<span>Category</span>
|
<span>Category</span>
|
||||||
<span class="font-semibold text-lg"
|
<span class="font-semibold text-lg"
|
||||||
>{$trail.expand.category.name}</span
|
>{$trail.expand.category.name}</span
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
</section>
|
</section>
|
||||||
{#if $trail.tags && $trail.tags.length > 0}
|
{#if $trail.tags && $trail.tags.length > 0}
|
||||||
<hr />
|
<hr />
|
||||||
@@ -206,9 +233,11 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{#if activeTab == 3}
|
{#if activeTab == 3}
|
||||||
|
<ul>
|
||||||
{#each $trail.expand.summit_logs ?? [] as log}
|
{#each $trail.expand.summit_logs ?? [] as log}
|
||||||
<SummitLogCard {log}></SummitLogCard>
|
<li><SummitLogCard {log}></SummitLogCard></li>
|
||||||
{/each}
|
{/each}
|
||||||
|
</ul>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -2,5 +2,9 @@ import { trails_show } from "$lib/stores/trail_store";
|
|||||||
import type { Load } from "@sveltejs/kit";
|
import type { Load } from "@sveltejs/kit";
|
||||||
|
|
||||||
export const load: Load = async ({ params }) => {
|
export const load: Load = async ({ params }) => {
|
||||||
|
try {
|
||||||
await trails_show(params.id!, true)
|
await trails_show(params.id!, true)
|
||||||
|
}catch(e) {
|
||||||
|
|
||||||
|
}
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user