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 Locals {
|
||||
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 }) {
|
||||
event.locals.pb = new PocketBase('http://127.0.0.1:8090');
|
||||
export const handle: Handle = async ({ event, resolve }) => {
|
||||
const pb = createInstance()
|
||||
|
||||
// load the store data from the request cookie string
|
||||
event.locals.pb.authStore.loadFromCookie(event.request.headers.get('cookie') || '');
|
||||
|
||||
try {
|
||||
// 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();
|
||||
} catch (_) {
|
||||
// clear the auth store on failed refresh
|
||||
event.locals.pb.authStore.clear();
|
||||
// load the store data from the request cookie string
|
||||
pb.authStore.loadFromCookie(event.request.headers.get('cookie') || '')
|
||||
try {
|
||||
// get an up-to-date auth store state by verifying and refreshing the loaded auth model (if any)
|
||||
if (pb.authStore.isValid) {
|
||||
await pb.collection('users').authRefresh()
|
||||
}
|
||||
} catch (_) {
|
||||
// clear the auth store on failed refresh
|
||||
pb.authStore.clear()
|
||||
}
|
||||
|
||||
const response = await resolve(event);
|
||||
event.locals.pb = pb
|
||||
event.locals.user = pb.authStore.model
|
||||
|
||||
// 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());
|
||||
const response = await resolve(event)
|
||||
|
||||
return response;
|
||||
// send back the default 'pb_auth' cookie to the client with the latest store state
|
||||
response.headers.set(
|
||||
'set-cookie',
|
||||
pb.authStore.exportToCookie({ httpOnly: false })
|
||||
)
|
||||
|
||||
return response
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
<menu class="rounded-full border w-12 h-12"></menu>
|
||||
@@ -1,7 +1,8 @@
|
||||
<script lang="ts">
|
||||
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();
|
||||
|
||||
@@ -26,28 +27,31 @@
|
||||
<svelte:window on:mouseup={() => (isOpen = false)} />
|
||||
|
||||
<div class="dropdown relative">
|
||||
<button
|
||||
class="hover:bg-gray-100 w-8 h-8 rounded-full"
|
||||
on:click={toggleMenu}
|
||||
type="button"
|
||||
>
|
||||
<i class="fa fa-ellipsis-vertical"></i>
|
||||
<button class="flex items-center justify-center" on:click={toggleMenu} type="button">
|
||||
<slot>
|
||||
<i
|
||||
class="fa fa-ellipsis-vertical text-{size} hover:bg-gray-300 px-[14px] py-2 rounded-full hover:bg-opacity-50"
|
||||
></i>
|
||||
</slot>
|
||||
</button>
|
||||
|
||||
{#if isOpen}
|
||||
<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}
|
||||
style="z-index: 1001"
|
||||
>
|
||||
{#each items as item}
|
||||
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
|
||||
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
||||
<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"
|
||||
on:mouseup|stopPropagation={() => handleItemClick(item)}
|
||||
on:keydown|stopPropagation={() => handleItemClick(item)}
|
||||
>
|
||||
{#if item.icon}
|
||||
<i class="fa fa-{item.icon} mr-6"></i>
|
||||
{/if}
|
||||
{item.text}
|
||||
</li>
|
||||
{/each}
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
|
||||
<div>
|
||||
{#if label.length}
|
||||
<p class="text-sm font-medium pb-1">
|
||||
<label for={name} class="text-sm font-medium pb-1">
|
||||
{label}
|
||||
</p>
|
||||
</label>
|
||||
{/if}
|
||||
<select
|
||||
{name}
|
||||
|
||||
@@ -5,13 +5,19 @@
|
||||
export let label: string = "";
|
||||
export let error: string = "";
|
||||
export let icon: string = "";
|
||||
export let extraClasses: string = "";
|
||||
export let type: "text" | "password" = "text";
|
||||
|
||||
function typeAction(node: HTMLInputElement) {
|
||||
node.type = type;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div>
|
||||
{#if label.length}
|
||||
<p class="text-sm font-medium pb-1">
|
||||
<label for={name} class="text-sm font-medium pb-1">
|
||||
{label}
|
||||
</p>
|
||||
</label>
|
||||
{/if}
|
||||
<div class="flex items-center gap-2">
|
||||
{#if icon.length > 0}
|
||||
@@ -19,10 +25,10 @@
|
||||
{/if}
|
||||
<input
|
||||
{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:bg-red-50={error.length > 0}
|
||||
type="text"
|
||||
use:typeAction
|
||||
bind:value
|
||||
on:change
|
||||
{placeholder}
|
||||
|
||||
@@ -1,27 +1,44 @@
|
||||
<script lang="ts">
|
||||
import { toast } from "$lib/stores/toast_store";
|
||||
import { fade } from "svelte/transition";
|
||||
|
||||
$: getBackgroundColor = () => {
|
||||
if ($toast && $toast.type == "success") {
|
||||
return "green-200";
|
||||
}
|
||||
return "";
|
||||
};
|
||||
|
||||
$: getBorderColor = () => {
|
||||
if ($toast && $toast.type == "success") {
|
||||
return "green-500";
|
||||
}
|
||||
return "";
|
||||
};
|
||||
function closeToast() {
|
||||
toast.set(null);
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if $toast}
|
||||
<div
|
||||
class="fixed px-8 py-4 shadow-xl rounded-xl border bottom-4 right-4 bg-{getBackgroundColor()} border-{getBorderColor()}"
|
||||
style="z-index: 1000;"
|
||||
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: 1001;"
|
||||
in:fade={{ duration: 250 }}
|
||||
out:fade={{ duration: 250 }}
|
||||
>
|
||||
<i class="fa fa-{$toast.icon} mr-2"></i>
|
||||
<span>{$toast.text}</span>
|
||||
<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>
|
||||
{/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>
|
||||
import LogoTextLight from "./logo_text_light.svelte";
|
||||
import LogoTextLight from "./logo/logo_text_light.svelte";
|
||||
</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">
|
||||
|
||||
|
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,18 +1,47 @@
|
||||
<script>
|
||||
import Avatar from "./avatar.svelte";
|
||||
import LogoText from "./logo_text.svelte";
|
||||
<script lang="ts">
|
||||
import { goto } from "$app/navigation";
|
||||
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>
|
||||
|
||||
<nav class="flex justify-between items-center p-6">
|
||||
<a href="/"><LogoText></LogoText></a>
|
||||
<menu class="flex gap-8">
|
||||
<a class="font-semibold" href="">Trails</a>
|
||||
<a class="font-semibold" href="">Map</a>
|
||||
<a class="font-semibold" href="">Categories</a>
|
||||
<a class="font-semibold" href="">Favorites</a>
|
||||
</menu>
|
||||
<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>
|
||||
<Avatar></Avatar>
|
||||
</div>
|
||||
{#if $currentUser}
|
||||
<menu class="flex gap-8">
|
||||
<a class="font-semibold" href="">Trails</a>
|
||||
<a class="font-semibold" href="">Map</a>
|
||||
<a class="font-semibold" href="">Categories</a>
|
||||
<a class="font-semibold" href="">Favorites</a>
|
||||
</menu>
|
||||
<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
|
||||
>
|
||||
<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>
|
||||
{:else}
|
||||
<a class="btn-primary btn-large" href="/login">Login</a>
|
||||
{/if}
|
||||
</nav>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
closeModal!();
|
||||
},
|
||||
});
|
||||
$: form.set(util.cloneDeep($summitLog));
|
||||
$: form.set(util.cloneDeep($summitLog));
|
||||
</script>
|
||||
|
||||
<Modal
|
||||
|
||||
@@ -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;
|
||||
name: string;
|
||||
location?: string;
|
||||
public: boolean;
|
||||
distance?: number;
|
||||
elevation_gain?: number;
|
||||
duration?: number;
|
||||
@@ -28,6 +29,7 @@ class Trail {
|
||||
params?: {
|
||||
id?: string,
|
||||
location?: string,
|
||||
public?: boolean,
|
||||
distance?: number,
|
||||
elevation_gain?: number,
|
||||
duration?: number,
|
||||
@@ -45,6 +47,7 @@ class Trail {
|
||||
this.id = params?.id;
|
||||
this.name = name;
|
||||
this.location = params?.location;
|
||||
this.public = params?.public ?? false
|
||||
this.distance = params?.distance;
|
||||
this.elevation_gain = params?.elevation_gain;
|
||||
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 { 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 { writable, type Writable } from "svelte/store";
|
||||
|
||||
@@ -12,9 +12,17 @@ export async function summit_logs_create(bodyParams?: { [key: string]: any; } |
|
||||
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) {
|
||||
const success = await pb
|
||||
.collection("summit_logs_delete")
|
||||
.collection("summit_logs")
|
||||
.delete(id);
|
||||
|
||||
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 { 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 trail: Writable<Trail> = writable(new Trail(""));
|
||||
@@ -25,7 +26,7 @@ export async function trails_index() {
|
||||
}
|
||||
|
||||
export async function trails_show(id: string, loadGPX?: boolean) {
|
||||
const response: Trail = await pb.collection('trails').getOne<Trail>(id, { expand: "category,waypoints,summit_logs" })
|
||||
const response: Trail = await pb.collection('trails').getOne<Trail>(id, { expand: "category,waypoints,summit_logs" })
|
||||
|
||||
if (loadGPX) {
|
||||
const gpxData: string = await fetchGPX(response);
|
||||
@@ -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) {
|
||||
|
||||
if (!pb.authStore.model) {
|
||||
throw new Error("Unauthenticated");
|
||||
;
|
||||
}
|
||||
formData.set("category", trail.expand.category!.id);
|
||||
|
||||
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);
|
||||
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
|
||||
.collection("trails")
|
||||
.create<Trail>(formData);
|
||||
@@ -93,6 +106,13 @@ export async function trails_update(oldTrail: Trail, newTrail: Trail, formData:
|
||||
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) {
|
||||
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!);
|
||||
}
|
||||
|
||||
for (const updatedSummitLog of summitLogUpdates.updated) {
|
||||
const model = await summit_logs_update(updatedSummitLog);
|
||||
}
|
||||
|
||||
for (const deletedSummitLog of summitLogUpdates.deleted) {
|
||||
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");
|
||||
}
|
||||
|
||||
if (!formData.get("public")) {
|
||||
formData.set("public", 0);
|
||||
}
|
||||
|
||||
const thumbnailIndex = newTrail.photos.findIndex(
|
||||
(p) => p == newTrail.thumbnail,
|
||||
);
|
||||
@@ -137,7 +165,7 @@ export async function trails_update(oldTrail: Trail, newTrail: Trail, formData:
|
||||
|
||||
model = await pb
|
||||
.collection("trails")
|
||||
.update<Trail>(model.id!, { thumbnail: thumbnail });
|
||||
.update<Trail>(model.id!, { thumbnail: thumbnail }, { expand: "category,waypoints,summit_logs" });
|
||||
|
||||
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
|
||||
.collection("trails")
|
||||
.delete(id);
|
||||
.delete(trail.id!);
|
||||
|
||||
return success;
|
||||
}
|
||||
@@ -173,12 +212,22 @@ function setFileURLs(trail: Trail) {
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
return {
|
||||
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 { writable, type Writable } from "svelte/store";
|
||||
|
||||
@@ -13,6 +13,14 @@ export async function waypoints_create(bodyParams?: { [key: string]: any; } | Fo
|
||||
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) {
|
||||
const success = await pb
|
||||
.collection("waypoints")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { pb } from "$lib/constants";
|
||||
import { pb } from "$lib/pocketbase";
|
||||
import type { FileOptions } from "pocketbase";
|
||||
|
||||
export function getFileURL(record: { [key: string]: any; }, filename?: string, options?: FileOptions) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script>
|
||||
import Toast from "$lib/components/base/toast.svelte";
|
||||
import Footer from "$lib/components/footer.svelte";
|
||||
import NavBar from "$lib/components/nav_bar.svelte";
|
||||
import NavBar from "$lib/components/nav_bar.svelte";
|
||||
import "../app.css";
|
||||
import "../components.css"
|
||||
import '@fortawesome/fontawesome-free/css/all.min.css'
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
trails_delete,
|
||||
trails_index,
|
||||
} from "$lib/stores/trail_store";
|
||||
import { currentUser } from "$lib/stores/user_store";
|
||||
import { waypoints_delete } from "$lib/stores/waypoint_store";
|
||||
|
||||
async function handleDropdownClick(
|
||||
@@ -19,18 +20,7 @@
|
||||
if (item.value == "edit") {
|
||||
goto(`/trail/edit/${currentTrail.id}`);
|
||||
} else if (item.value == "delete") {
|
||||
if (currentTrail.expand.waypoints) {
|
||||
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_delete(currentTrail);
|
||||
await trails_index();
|
||||
}
|
||||
}
|
||||
@@ -51,7 +41,7 @@
|
||||
</div>
|
||||
</section>
|
||||
<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
|
||||
id="trails"
|
||||
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 TextField from "$lib/components/base/text_field.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 SummitLogCard from "$lib/components/summit_log/summit_log_card.svelte";
|
||||
import SummitLogModal from "$lib/components/summit_log/summit_log_modal.svelte";
|
||||
@@ -13,7 +14,7 @@
|
||||
import { Waypoint } from "$lib/models/waypoint";
|
||||
import { categories } from "$lib/stores/category_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 {
|
||||
trail,
|
||||
trails_create,
|
||||
@@ -84,9 +85,19 @@
|
||||
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) {
|
||||
console.error(e);
|
||||
|
||||
show_toast({
|
||||
type: "error",
|
||||
icon: "close",
|
||||
text: "Error saving trail.",
|
||||
});
|
||||
} finally {
|
||||
loading = false;
|
||||
}
|
||||
@@ -304,6 +315,7 @@
|
||||
e: CustomEvent<{ text: string; value: string }>,
|
||||
) {
|
||||
if (e.detail.value === "edit") {
|
||||
currentSummitLog.date = format(currentSummitLog.date, "yyyy-MM-dd");
|
||||
summitLog.set(currentSummitLog);
|
||||
openSummitLogModal();
|
||||
} else if (e.detail.value === "delete") {
|
||||
@@ -375,12 +387,15 @@
|
||||
label="Describe your trail"
|
||||
bind:value={$form.description}
|
||||
></Textarea>
|
||||
<Select
|
||||
name="category"
|
||||
label="Category"
|
||||
bind:value={$form.expand.category}
|
||||
items={$categories.map((c) => ({ text: c.name, value: c }))}
|
||||
></Select>
|
||||
{#if $form.expand.category}
|
||||
<Select
|
||||
name="category"
|
||||
label="Category"
|
||||
bind:value={$form.expand.category.id}
|
||||
items={$categories.map((c) => ({ text: c.name, value: c.id }))}
|
||||
></Select>
|
||||
{/if}
|
||||
<Toggle name="public" label="Public" bind:value={$form.public}></Toggle>
|
||||
<hr />
|
||||
<h3 class="text-xl font-semibold">Waypoints</h3>
|
||||
<ul>
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
<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 Tabs from "$lib/components/tabs.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 { createMarkerFromWaypoint } from "$lib/util/leaflet_util";
|
||||
import type { Icon, Marker } from "leaflet";
|
||||
@@ -12,6 +18,7 @@
|
||||
import PhotoSwipeLightbox from "photoswipe/lightbox";
|
||||
import "photoswipe/style.css";
|
||||
import { onMount } from "svelte";
|
||||
import { fade } from "svelte/transition";
|
||||
|
||||
const tabs = ["Description", "Waypoints", "Photos", "Summit book"];
|
||||
|
||||
@@ -22,6 +29,11 @@
|
||||
let lightbox: PhotoSwipeLightbox;
|
||||
let lightboxDataSource: DataSource;
|
||||
|
||||
const dropdownItems = [
|
||||
{ text: "Edit", value: "edit" },
|
||||
{ text: "Delete", value: "delete" },
|
||||
];
|
||||
|
||||
onMount(async () => {
|
||||
const L = (await import("leaflet")).default;
|
||||
await import("leaflet-gpx");
|
||||
@@ -109,17 +121,23 @@
|
||||
function openGallery(idx: number) {
|
||||
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>
|
||||
|
||||
<div
|
||||
class="trail-panel max-w-5xl mx-auto shadow-2xl rounded-3xl overflow-hidden"
|
||||
>
|
||||
<section class="relative h-80">
|
||||
<img
|
||||
class="w-full h-80"
|
||||
src={$trail.thumbnail}
|
||||
alt=""
|
||||
/>
|
||||
<img class="w-full h-80" src={$trail.thumbnail} alt="" />
|
||||
<div
|
||||
class="absolute bottom-0 w-full h-1/2 bg-gradient-to-b from-transparent to-black opacity-50"
|
||||
></div>
|
||||
@@ -132,6 +150,13 @@
|
||||
{$trail.location}
|
||||
</h3>
|
||||
</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
|
||||
class="grid grid-cols-2 sm:grid-cols-4 gap-y-4 justify-around py-8"
|
||||
@@ -154,12 +179,14 @@
|
||||
>{formatTimeHHMM($trail.duration)}</span
|
||||
>
|
||||
</div>
|
||||
<div class="flex flex-col items-center">
|
||||
<span>Category</span>
|
||||
<span class="font-semibold text-lg"
|
||||
>{$trail.expand.category.name}</span
|
||||
>
|
||||
</div>
|
||||
{#if $trail.expand.category}
|
||||
<div class="flex flex-col items-center">
|
||||
<span>Category</span>
|
||||
<span class="font-semibold text-lg"
|
||||
>{$trail.expand.category.name}</span
|
||||
>
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
{#if $trail.tags && $trail.tags.length > 0}
|
||||
<hr />
|
||||
@@ -206,9 +233,11 @@
|
||||
</div>
|
||||
{/if}
|
||||
{#if activeTab == 3}
|
||||
{#each $trail.expand.summit_logs ?? [] as log}
|
||||
<SummitLogCard {log}></SummitLogCard>
|
||||
{/each}
|
||||
<ul>
|
||||
{#each $trail.expand.summit_logs ?? [] as log}
|
||||
<li><SummitLogCard {log}></SummitLogCard></li>
|
||||
{/each}
|
||||
</ul>
|
||||
{/if}
|
||||
</div>
|
||||
<div
|
||||
|
||||
@@ -2,5 +2,9 @@ import { trails_show } from "$lib/stores/trail_store";
|
||||
import type { Load } from "@sveltejs/kit";
|
||||
|
||||
export const load: Load = async ({ params }) => {
|
||||
await trails_show(params.id!, true)
|
||||
try {
|
||||
await trails_show(params.id!, true)
|
||||
}catch(e) {
|
||||
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user