Compare commits
95 Commits
Author | SHA1 | Date | |
---|---|---|---|
d0366bbd2a | |||
205bbd08d1 | |||
a71279b223 | |||
664e9b087f | |||
e04314217b | |||
17060fb068 | |||
a818b7f203 | |||
d4c69f2723 | |||
f92162bca9 | |||
3bc11ce05f | |||
7eab070c6a | |||
d5cd5c9a97 | |||
68ec2e34e1 | |||
6a0a73a890 | |||
c259220e3a | |||
5bfa89f283 | |||
aa70878324 | |||
f7bce68f68 | |||
074f9492a9 | |||
b6f57384d0 | |||
01ff1bf0df | |||
01a5031895 | |||
4d287c3d1a | |||
5688f0dab6 | |||
357ef79e11 | |||
397d1070c8 | |||
8abd89d0d1 | |||
a7df098167 | |||
2b721c483e | |||
ada12fd4db | |||
4814ef4c22 | |||
b0d866873b | |||
06364a06bf | |||
795b166d7f | |||
adb4bb7f75 | |||
958902631f | |||
b0347a9d06 | |||
384354fbac | |||
ed2e8ef446 | |||
fa16814f91 | |||
735279bc47 | |||
204bf5b01d | |||
cb0e86a66a | |||
5b375f888e | |||
7365749113 | |||
2cf66ab6cb | |||
4377fc56c8 | |||
6584b3c7c7 | |||
a3c379a813 | |||
092762011d | |||
ea6bd074a1 | |||
59a411bab5 | |||
3a82caad95 | |||
19e08bc52c | |||
515370eac7 | |||
0c629e2416 | |||
c5c8514bab | |||
cc5cb2782f | |||
a50a28622a | |||
5329c4e121 | |||
912e0b70a2 | |||
7da22287ff | |||
5f81f55987 | |||
8bcab4661b | |||
f2ec82762e | |||
0327bdc7a0 | |||
b3b6731c09 | |||
36de0a3eb3 | |||
839c658075 | |||
12aa8eeb3e | |||
b655ff2372 | |||
58adc6511a | |||
29c4b0013a | |||
8ed16adeff | |||
09219ff798 | |||
d9cd552c89 | |||
2b82f8798c | |||
d9715139cf | |||
c731323b0b | |||
0d8db9f41f | |||
6706c9b0d1 | |||
0dc6fe6704 | |||
5f82c5bef8 | |||
47f7583659 | |||
0819dc7b5d | |||
2010cc3260 | |||
8c1a2d319b | |||
b57aa535de | |||
84ab757e11 | |||
cd3508dcb6 | |||
4f5b7f38fb | |||
c34f45ca6f | |||
b160ab04b8 | |||
c5874e16c6 | |||
d9134f6de2 |
146
CHANGELOG.md
146
CHANGELOG.md
|
@ -2,8 +2,154 @@
|
|||
|
||||
All notable changes to this project will be documented in this file. Dates are displayed in UTC.
|
||||
|
||||
#### [0.4.5](https://git.odit.services/kauft.es/linkylinky-dashboard/compare/0.4.4...0.4.5)
|
||||
|
||||
- Added missing text styling to button [`b0d8668`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/b0d866873b7871118f664d5955212913aabbb414)
|
||||
- Fixed image src for deployment [`06364a0`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/06364a06bfd625e8f255569404892104a3192014)
|
||||
|
||||
#### [0.4.4](https://git.odit.services/kauft.es/linkylinky-dashboard/compare/0.4.3...0.4.4)
|
||||
|
||||
> 21 August 2021
|
||||
|
||||
- 🚀RELEASE 0.4.4 [`795b166`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/795b166d7f733907662047f1f6eb01bf5ce2eab4)
|
||||
- Added logo to sidebar [`adb4bb7`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/adb4bb7f7523e7fd739e93a74837c32eb9b266fa)
|
||||
|
||||
#### [0.4.3](https://git.odit.services/kauft.es/linkylinky-dashboard/compare/0.4.2...0.4.3)
|
||||
|
||||
> 21 August 2021
|
||||
|
||||
- 🚀RELEASE 0.4.3 [`9589026`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/958902631fe282b378048be8728cb9ec10c97cc4)
|
||||
- Added provider to detail vist table [`b0347a9`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/b0347a9d06a21578b4e5263daabf11e5de45ef5c)
|
||||
|
||||
#### [0.4.2](https://git.odit.services/kauft.es/linkylinky-dashboard/compare/0.4.1...0.4.2)
|
||||
|
||||
> 21 August 2021
|
||||
|
||||
- 🚀RELEASE 0.4.2 [`384354f`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/384354fbac3b58a7e4480a0788d9b079827938b7)
|
||||
- Commented search away from sidebar [`ed2e8ef`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/ed2e8ef44650f1c63d38258d7bef84c9e9222364)
|
||||
|
||||
#### [0.4.1](https://git.odit.services/kauft.es/linkylinky-dashboard/compare/0.4.0...0.4.1)
|
||||
|
||||
> 21 August 2021
|
||||
|
||||
- 🚀RELEASE 0.4.1 [`fa16814`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/fa16814f9165c89caaacfa9d6e042aa9aa77aebb)
|
||||
- Applied new sidebar styles to logout button [`735279b`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/735279bc47ef547549e57f6d137c95541e8bdd16)
|
||||
|
||||
#### [0.4.0](https://git.odit.services/kauft.es/linkylinky-dashboard/compare/0.3.2...0.4.0)
|
||||
|
||||
> 21 August 2021
|
||||
|
||||
- Migrated all sidebar items to the new component [`7365749`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/7365749113afc8f51e6b4aff78babcf361992f0a)
|
||||
- Removed unused commented template stuff [`5b375f8`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/5b375f888e729bea0a82938d9af7bc016c6bd74e)
|
||||
- Extracted a bunch of duplicate stylechecks into own component [`4377fc5`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/4377fc56c8f8d0f63a7579d21bcef95c0db45be8)
|
||||
- Refactoring: Rename [`cb0e86a`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/cb0e86a66af04c6f88b989ee8e1490aad689d1db)
|
||||
- Sidebar activestates [`a3c379a`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/a3c379a813be4349879e90ad07d9977a4e334e0d)
|
||||
- 🚀RELEASE 0.4.0 [`204bf5b`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/204bf5b01d61f4ab96aaa891225377fe5f7792cf)
|
||||
- Added hoverstates [`2cf66ab`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/2cf66ab6cbf661330a7767896157c62d958a651e)
|
||||
- Removed console log [`6584b3c`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/6584b3c7c7c0d5496d52522e8130f615145d1b03)
|
||||
|
||||
#### [0.3.2](https://git.odit.services/kauft.es/linkylinky-dashboard/compare/0.3.1...0.3.2)
|
||||
|
||||
> 21 August 2021
|
||||
|
||||
- Added code to createurl component [`59a411b`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/59a411bab5462710109767dfccb90a0f0459b2dd)
|
||||
- More basics for the shorturl creation module [`515370e`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/515370eac7ff5f018cae5ec790ccc8e90c025718)
|
||||
- added display logic for the basic elements [`cc5cb27`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/cc5cb2782f20c4a7ab480132217463a0f4a9a956)
|
||||
- Added basics for error handling on url creation [`c5c8514`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/c5c8514bab9615c90de8b5fb1f9a5925f752b28b)
|
||||
- Basics for the new url creation component [`5329c4e`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/5329c4e1219a1cd3c8f1b5c0bdf02cb22330fd72)
|
||||
- Added adding url functionality to apiclient [`0c629e2`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/0c629e241668e1809d9616e9f7cb6ba804ad4c53)
|
||||
- 🚀RELEASE 0.3.2 [`0927620`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/092762011dbaf5270b482e838cf29059af9d24eb)
|
||||
- Tmp removed the createurl component from index until it works [`ea6bd07`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/ea6bd074a12ed4a43d30b1e9bacbe12bc6f97356)
|
||||
- Now only using odit registry hosted images to speed up the build [`3a82caa`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/3a82caad95eb99dac71e01dc02e3fdafe17ef6da)
|
||||
- Switched to our own brotli nginx build [`19e08bc`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/19e08bc52cc6a9c73e4b2d42d612d3ea7401f108)
|
||||
- Added url creation component to dashboard [`a50a286`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/a50a28622ac4904e611a0bdaa3f2997192bf75ca)
|
||||
|
||||
#### [0.3.1](https://git.odit.services/kauft.es/linkylinky-dashboard/compare/0.3.0...0.3.1)
|
||||
|
||||
> 21 August 2021
|
||||
|
||||
- 🚀RELEASE 0.3.1 [`912e0b7`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/912e0b70a2bcf5100901d3d6faf9806238ed317f)
|
||||
- Removed length check [`7da2228`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/7da22287ff00b9403d2458b486c5289e7b389415)
|
||||
|
||||
#### [0.3.0](https://git.odit.services/kauft.es/linkylinky-dashboard/compare/0.2.4...0.3.0)
|
||||
|
||||
> 21 August 2021
|
||||
|
||||
- Added new "visits" page [`b655ff2`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/b655ff2372655d1fb7fa6cea8a10b193805f315c)
|
||||
- Added visits overview to sidebar [`36de0a3`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/36de0a3eb305317c829bace18a9661308c8cf0f3)
|
||||
- 🚀RELEASE 0.3.0 [`5f81f55`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/5f81f559876328f57b947e7c19d236e45fbf25c0)
|
||||
- Added apiclient method [`839c658`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/839c65807524646c1c6a677f10042988fb2bccdf)
|
||||
- Added safeguard for random updates [`8bcab46`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/8bcab4661bec3c748cc65078e5187d936be9cdf9)
|
||||
- Fixed link to details [`f2ec827`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/f2ec82762e9bc107f29952709555bc3d893def49)
|
||||
- Enabled y scrolling (whyever that was disabled...) [`0327bdc`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/0327bdc7a0cefda343168c911faa51cd42271673)
|
||||
- Fixed typo in visits query [`b3b6731`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/b3b6731c09d47fff9df96903c75914e7042e28c5)
|
||||
- Missing copy-paste :D [`12aa8ee`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/12aa8eeb3e345ccee10bdb6abca93c5fd84a071a)
|
||||
|
||||
#### [0.2.4](https://git.odit.services/kauft.es/linkylinky-dashboard/compare/0.2.3...0.2.4)
|
||||
|
||||
> 21 August 2021
|
||||
|
||||
- 🚀RELEASE 0.2.4 [`58adc65`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/58adc6511aa1ee573abcf21a176131bf10354747)
|
||||
- Fixed logout redirect [`29c4b00`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/29c4b0013abb0466f59239ae3717f60216cecc1f)
|
||||
- Fixed details link [`8ed16ad`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/8ed16adeffed9e1368615caf6022d8a376337b8a)
|
||||
|
||||
#### [0.2.3](https://git.odit.services/kauft.es/linkylinky-dashboard/compare/0.2.2...0.2.3)
|
||||
|
||||
> 21 August 2021
|
||||
|
||||
- 🚀RELEASE 0.2.3 [`09219ff`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/09219ff7987e6088245d8a871e3a5aaca3f855fd)
|
||||
- Updated login text color [`d9cd552`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/d9cd552c89415625c22c1adcb892c5a789823ce9)
|
||||
- Fixed login replace [`2b82f87`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/2b82f8798cd23f15dc48a5375dc1f5ad1a3abbfd)
|
||||
|
||||
#### [0.2.2](https://git.odit.services/kauft.es/linkylinky-dashboard/compare/0.2.1...0.2.2)
|
||||
|
||||
> 21 August 2021
|
||||
|
||||
- 🚀RELEASE 0.2.2 [`d971513`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/d9715139cf0c5583cb1db43953c34e3293345f68)
|
||||
- Fixxed routing links [`c731323`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/c731323b0bd1b757297b601e7bbc3f5034c04e9c)
|
||||
|
||||
#### [0.2.1](https://git.odit.services/kauft.es/linkylinky-dashboard/compare/0.2.0...0.2.1)
|
||||
|
||||
> 21 August 2021
|
||||
|
||||
- 🚀RELEASE 0.2.1 [`0d8db9f`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/0d8db9f41f84ccaba3211d61e6521d57f43e1b88)
|
||||
- Static links (yay) [`6706c9b`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/6706c9b0d1e396b0c6df6bb9b05d2d25c2a45cba)
|
||||
|
||||
#### [0.2.0](https://git.odit.services/kauft.es/linkylinky-dashboard/compare/0.1.3...0.2.0)
|
||||
|
||||
> 21 August 2021
|
||||
|
||||
- Added comments to fix [`#1`](https://git.odit.services/kauft.es/linkylinky-dashboard/issues/1)
|
||||
- More userstore fixes [`84ab757`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/84ab757e1159eac3cd160aac158873deaf51bb3f)
|
||||
- Added comments to apiclient [`47f7583`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/47f75836597ff13a32660e03d61629ddd173f86c)
|
||||
- No longer showing logged out users the profile pic thingy [`2010cc3`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/2010cc326019085ca37fcdc8b8dab8445006b6fa)
|
||||
- Weired fucking fix for the userstore data not being instantly loaded.... [`cd3508d`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/cd3508dcb61f165a7c83d6f0f9332f799677cb9f)
|
||||
- 🚀RELEASE 0.2.0 [`0dc6fe6`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/0dc6fe670498b6d1022a1ef6c4e5c4b3fcd7e352)
|
||||
- First mitigations for localforage error stuff [`4f5b7f3`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/4f5b7f38fb625e4da0ea3f432df958029ee8d25c)
|
||||
- Now ignoring status on logout [`8c1a2d3`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/8c1a2d319b9fb6e63c3e27163392bad1becba8dd)
|
||||
- Removed unused function [`b57aa53`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/b57aa535de94e22f19754b729cc6b63166a07a9d)
|
||||
- Removed useless console log [`5f82c5b`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/5f82c5bef8011bd7cee853bde76433585d93b88b)
|
||||
|
||||
#### [0.1.3](https://git.odit.services/kauft.es/linkylinky-dashboard/compare/0.1.2...0.1.3)
|
||||
|
||||
> 18 August 2021
|
||||
|
||||
- Tmp fix for the build fail, for more info see: https://github.com/sveltejs/kit/issues/2230 [`b160ab0`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/b160ab04b8324daa6389c947356bc58c865059aa)
|
||||
- 🚀RELEASE 0.1.3 [`c34f45c`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/c34f45ca6f8a7fe955e8d82f0f2c10b3cdfd54ce)
|
||||
|
||||
#### [0.1.2](https://git.odit.services/kauft.es/linkylinky-dashboard/compare/0.1.1...0.1.2)
|
||||
|
||||
> 18 August 2021
|
||||
|
||||
- 🚀RELEASE 0.1.2 [`c5874e1`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/c5874e16c60030361aedf8b7f8437a4410276f38)
|
||||
- Added fix for custom basepath [`d9134f6`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/d9134f6de2f5587a57f69ad06e828d184c3480a2)
|
||||
|
||||
#### [0.1.1](https://git.odit.services/kauft.es/linkylinky-dashboard/compare/0.1.0...0.1.1)
|
||||
|
||||
> 18 August 2021
|
||||
|
||||
- 🚀RELEASE 0.1.1 [`db5c530`](https://git.odit.services/kauft.es/linkylinky-dashboard/commit/db5c530477f9584c77d087c3dea3c3f9156b4773)
|
||||
|
||||
#### 0.1.0
|
||||
|
||||
> 18 August 2021
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
FROM library/node:16-alpine
|
||||
FROM registry.odit.services/hub/library/node:18-alpine
|
||||
WORKDIR /app
|
||||
COPY package.json ./
|
||||
RUN yarn
|
||||
COPY ./ ./
|
||||
RUN yarn build
|
||||
|
||||
FROM fholzer/nginx-brotli:v1.19.1
|
||||
FROM registry.odit.services/library/nginx-brotli:3.15
|
||||
COPY --from=0 /app/build /usr/share/nginx/html
|
||||
COPY ./nginx.conf /etc/nginx/nginx.conf
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"extends": "./.svelte-kit/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
|
|
16
package.json
16
package.json
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@odit/linkylinky-dashboard",
|
||||
"version": "0.1.1",
|
||||
"version": "0.4.5",
|
||||
"scripts": {
|
||||
"dev": "svelte-kit dev",
|
||||
"build": "svelte-kit build",
|
||||
|
@ -10,25 +10,25 @@
|
|||
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/kit": "next",
|
||||
"@sveltejs/kit": "1.0.0-next.324",
|
||||
"autoprefixer": "^10.3.1",
|
||||
"cssnano": "^5.0.6",
|
||||
"eslint": "^7.22.0",
|
||||
"eslint": "^8.0.0",
|
||||
"eslint-config-prettier": "^8.1.0",
|
||||
"eslint-plugin-svelte3": "^3.2.0",
|
||||
"eslint-plugin-svelte3": "^4.0.0",
|
||||
"postcss": "^8.3.5",
|
||||
"postcss-load-config": "^3.1.0",
|
||||
"prettier": "~2.2.1",
|
||||
"prettier": "~2.6.0",
|
||||
"prettier-plugin-svelte": "^2.2.0",
|
||||
"release-it": "^14.11.5",
|
||||
"release-it": "^15.0.0",
|
||||
"svelte": "^3.34.0",
|
||||
"svelte-preprocess": "^4.7.4",
|
||||
"tailwindcss": "^2.2.4"
|
||||
"tailwindcss": "^3.0.0"
|
||||
},
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@sveltejs/adapter-static": "^1.0.0-next.16",
|
||||
"axios": "^0.21.1",
|
||||
"axios": "^0.27.0",
|
||||
"localforage": "^1.9.0"
|
||||
},
|
||||
"release-it": {
|
||||
|
|
4293
pnpm-lock.yaml
Normal file
4293
pnpm-lock.yaml
Normal file
File diff suppressed because it is too large
Load Diff
16
renovate.json
Normal file
16
renovate.json
Normal file
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"dependencyDashboard": true,
|
||||
"baseBranches": [
|
||||
"main"
|
||||
],
|
||||
"addLabels": [
|
||||
"status:review_needed",
|
||||
"enhancement",
|
||||
"priority:medium"
|
||||
],
|
||||
"reviewers": [
|
||||
"niggl",
|
||||
"philipp"
|
||||
]
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
import { data } from 'autoprefixer';
|
||||
import axios from 'axios';
|
||||
import UserStore from './UserStore';
|
||||
|
||||
|
@ -11,12 +12,21 @@ axios.interceptors.response.use(response => {
|
|||
});
|
||||
|
||||
export default class Apiclient {
|
||||
|
||||
/**
|
||||
* API-Getter for the linkylinky api stats endpoint
|
||||
* @returns Current linkylinky stats (url count, total visits)
|
||||
*/
|
||||
static async getStats() {
|
||||
return (
|
||||
await axios.get('https://kauft.es/api/stats')
|
||||
).data;
|
||||
}
|
||||
|
||||
/**
|
||||
* API-Getter for the linkylinky api all urls endpoint (needs auth)
|
||||
* @returns All urls with shortcode, target, full url and visits in an array of objects
|
||||
*/
|
||||
static async getUrls() {
|
||||
return (
|
||||
await axios.get('https://kauft.es/api?showVisits=true', {
|
||||
|
@ -25,7 +35,13 @@ export default class Apiclient {
|
|||
).data;
|
||||
}
|
||||
|
||||
/**
|
||||
* API-Getter for the linkylinky api url details endpoint (needs auth)
|
||||
* @param {*} shortcode The shortcode of your favourite url
|
||||
* @returns Url shortcode, target, full url and visit count in an object
|
||||
*/
|
||||
static async getUrlDetails(shortcode) {
|
||||
//TODO: Handle 404
|
||||
return (
|
||||
await axios.get(`https://kauft.es/api/${shortcode}`, {
|
||||
headers: { Authorization: `Bearer ${UserStore.state.token}` }
|
||||
|
@ -33,7 +49,13 @@ export default class Apiclient {
|
|||
).data;
|
||||
}
|
||||
|
||||
/**
|
||||
* API-Getter for the linkylinky api url vists endpoint (needs auth)
|
||||
* @param {*} shortcode The shortcode of your favourite url
|
||||
* @returns Url visit details as an object for each visits (r/n they only contain timestamps)
|
||||
*/
|
||||
static async getUrlVisits(shortcode) {
|
||||
//TODO: Handle 404
|
||||
return (
|
||||
await axios.get(`https://kauft.es/api/${shortcode}/visits`, {
|
||||
headers: { Authorization: `Bearer ${UserStore.state.token}` }
|
||||
|
@ -41,6 +63,44 @@ export default class Apiclient {
|
|||
).data;
|
||||
}
|
||||
|
||||
/**
|
||||
* API-Getter for the linkylinky api all vists endpoint (needs auth)
|
||||
* @returns Url visit details for each visit in an array of objects.
|
||||
*/
|
||||
static async getVisits() {
|
||||
return (
|
||||
await axios.get(`https://kauft.es/api/visits`, {
|
||||
headers: { Authorization: `Bearer ${UserStore.state.token}` }
|
||||
})
|
||||
).data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new shorturl via the api
|
||||
* @param {*} target The target (rediction) url for the new shorturl.
|
||||
* @param {*} shortcode A custom shortcode (if needed)
|
||||
* @returns The response data/error
|
||||
*/
|
||||
static async createUrl(target, shortcode) {
|
||||
const res = (
|
||||
await axios.post(`https://kauft.es/api`, {
|
||||
target,
|
||||
shortcode
|
||||
}, {
|
||||
validateStatus: null
|
||||
})
|
||||
);
|
||||
return {
|
||||
status: res.status,
|
||||
data: res.data
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* API-Delet for the linkylinky api url deletion endpoint (needs auth)
|
||||
* @param {*} shortcode The shortcode of your most hated url
|
||||
* @returns Just a 204 (no matter if the url got deleted or didn't exist in the first place)
|
||||
*/
|
||||
static async deleteUrl(shortcode) {
|
||||
return (
|
||||
await axios.delete(`https://kauft.es/api/${shortcode}`, {
|
||||
|
@ -49,6 +109,12 @@ export default class Apiclient {
|
|||
).status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Login and receive a JWT for future auth.
|
||||
* @param {*} username Your username (cleartext)
|
||||
* @param {*} password Your password (cleartext)
|
||||
* @returns A user login object containing your jwt
|
||||
*/
|
||||
static async login(username, password) {
|
||||
return (
|
||||
await axios.post(`https://kauft.es/api/auth/login`, {}, {
|
||||
|
@ -59,10 +125,16 @@ export default class Apiclient {
|
|||
).data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log yourself out -> Invalidates your current (and past) JWTs
|
||||
* @returns Done!
|
||||
*/
|
||||
static async logout() {
|
||||
return (
|
||||
await axios.post(`https://kauft.es/api/auth/logout`, {}, {
|
||||
headers: { Authorization: `Bearer ${UserStore.state.token}` }
|
||||
headers: { Authorization: `Bearer ${UserStore.state.token}`,
|
||||
validateStatus: null
|
||||
}
|
||||
})
|
||||
).data;
|
||||
}
|
||||
|
|
123
src/lib/CreateUrl.svelte
Normal file
123
src/lib/CreateUrl.svelte
Normal file
|
@ -0,0 +1,123 @@
|
|||
<script>
|
||||
import Apiclient from './Apiclient';
|
||||
|
||||
$: targetUrl = '';
|
||||
$: customShortcode = '';
|
||||
$: shortcode = '';
|
||||
$: error = '';
|
||||
|
||||
function createUrl() {
|
||||
console.log('here');
|
||||
Apiclient.createUrl(targetUrl, shortcode).then((res) => {
|
||||
console.log(res);
|
||||
if (res.status != 200) {
|
||||
error = res.data;
|
||||
} else {
|
||||
shortcode = res.data.shortcode;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function resetInput() {
|
||||
error = '';
|
||||
shortcode = '';
|
||||
customShortcode = '';
|
||||
targetUrl = '';
|
||||
}
|
||||
</script>
|
||||
|
||||
<h2 class="text-center text-2xl font-bold text-gray-800 dark:text-gray-100 pb-3">Create new url</h2>
|
||||
{#if error != ''}
|
||||
<div class="rounded-md bg-red-100 p-4 hidden" id="error_container">
|
||||
<div class="flex">
|
||||
<div class="flex-shrink-0">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="h-5 w-5 text-red-600"
|
||||
viewBox="0 0 20 20"
|
||||
fill="currentColor"
|
||||
>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z"
|
||||
clip-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="ml-3">
|
||||
<p class="text-sm font-medium text-red-800" id="error_text">
|
||||
{error}
|
||||
</p>
|
||||
</div>
|
||||
<div class="ml-auto pl-3">
|
||||
<div class="-mx-1.5 -my-1.5">
|
||||
<button
|
||||
on:click={() => {
|
||||
error = '';
|
||||
}}
|
||||
class="inline-flex bg-red-100 rounded-md p-1.5 text-red-500 hover:bg-red-100 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-red-50 focus:ring-red-600"
|
||||
>
|
||||
<span class="sr-only">Dismiss</span>
|
||||
<svg
|
||||
class="h-5 w-5"
|
||||
x-description="Heroicon name: x"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 20 20"
|
||||
fill="currentColor"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
|
||||
clip-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{#if shortcode == ''}
|
||||
<div>
|
||||
<div class="mx-auto lg:w-1/3 w-full mt-1 flex rounded-md shadow-sm">
|
||||
<input
|
||||
type="url"
|
||||
required
|
||||
class="flex-1 min-w-0 block border rounded-lg px-3 py-2 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm border-gray-300 bg-gray-50 dark:bg-gray-800 dark:text-gray-200 dark:border-gray-600"
|
||||
placeholder="https://target.url"
|
||||
/>
|
||||
</div>
|
||||
<div class="mt-1 flex rounded-md shadow-sm mx-auto lg:w-1/3 w-full">
|
||||
<span
|
||||
class="inline-flex items-center px-3 rounded-l-md border border-r-0 border-gray-300 bg-gray-50 dark:bg-gray-900 dark:text-gray-300 text-gray-500 sm:text-sm dark:border-gray-600"
|
||||
>
|
||||
https://kauf.es/
|
||||
</span>
|
||||
<input
|
||||
type="text"
|
||||
class="flex-1 min-w-0 block w-full px-3 py-2 border-t border-b border-r rounded-none rounded-r-md focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm border-gray-300 dark:bg-gray-800 dark:text-gray-200 dark:border-gray-600"
|
||||
placeholder="custom_code"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<!-- TODO: -->
|
||||
{/if}
|
||||
<div class="mt-3 mx-auto text-center lg:w-1/3 w-full">
|
||||
{#if shortcode == ''}
|
||||
<button
|
||||
on:click={createUrl}
|
||||
class="px-4 py-2 font-medium tracking-wide text-white capitalize transition-colors duration-200 transform bg-blue-600 rounded-md dark:bg-gray-900 hover:bg-blue-500 dark:hover:bg-gray-700 focus:outline-none focus:bg-blue-500 dark:focus:bg-gray-700"
|
||||
>
|
||||
Create shorturl
|
||||
</button>
|
||||
{:else}
|
||||
<button
|
||||
on:click={resetInput}
|
||||
class="px-4 py-2 font-medium tracking-wide text-white capitalize transition-colors duration-200 transform bg-blue-600 rounded-md dark:bg-gray-900 hover:bg-blue-500 dark:hover:bg-gray-700 focus:outline-none focus:bg-blue-500 dark:focus:bg-gray-700"
|
||||
>
|
||||
Add another url
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
|
@ -1,21 +1,12 @@
|
|||
<script>
|
||||
import UserStore from '$lib/UserStore';
|
||||
import { onDestroy, onMount } from 'svelte';
|
||||
import * as localForage from 'localforage';
|
||||
import { onDestroy } from 'svelte';
|
||||
import Apiclient from './Apiclient';
|
||||
import { page } from '$app/stores';
|
||||
import SidebarEntry from './SidebarEntry.svelte';
|
||||
|
||||
$: logged_in = false;
|
||||
|
||||
UserStore.init();
|
||||
onMount(() => {
|
||||
localForage.getItem('userdata', (err, value) => {
|
||||
if (value) {
|
||||
if (value.token) {
|
||||
UserStore.login(value);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
$: currentPage = $page.url.pathname;
|
||||
|
||||
const unsubscribe = UserStore.subscribe((value) => {
|
||||
logged_in = value.isLoggedIn;
|
||||
|
@ -24,7 +15,7 @@
|
|||
onDestroy(unsubscribe);
|
||||
|
||||
async function logout() {
|
||||
await Apiclient.logout().catch((e)=>{});
|
||||
await Apiclient.logout().catch((e) => {});
|
||||
UserStore.logout();
|
||||
}
|
||||
</script>
|
||||
|
@ -32,9 +23,9 @@
|
|||
<div
|
||||
class="flex flex-col w-64 h-screen px-4 py-8 bg-white border-r dark:bg-gray-800 dark:border-gray-600"
|
||||
>
|
||||
<img class="h-36 w-36" src="/icon_128.png" alt="LinkyLinky Logo (White kauft.es K on red background)">
|
||||
<h2 class="text-3xl font-semibold text-gray-800 dark:text-white">LinkyLinky</h2>
|
||||
|
||||
<div class="relative mt-6">
|
||||
<!-- <div class="relative mt-6">
|
||||
<span class="absolute inset-y-0 left-0 flex items-center pl-3">
|
||||
<svg class="w-5 h-5 text-gray-400" viewBox="0 0 24 24" fill="none">
|
||||
<path
|
||||
|
@ -52,14 +43,11 @@
|
|||
class="w-full py-3 pl-10 pr-4 text-gray-700 bg-white border border-gray-300 rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 focus:border-blue-500 dark:focus:border-blue-500 focus:outline-none focus:ring"
|
||||
placeholder="Search"
|
||||
/>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="flex flex-col justify-between flex-1 mt-6">
|
||||
<nav>
|
||||
<a
|
||||
class="flex items-center px-4 py-2 text-gray-700 bg-gray-200 rounded-md dark:bg-gray-700 dark:text-gray-200"
|
||||
href="/"
|
||||
>
|
||||
<SidebarEntry title="Dashboard" href="" pageUrl="/" bind:currentPage>
|
||||
<svg class="w-5 h-5" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
d="M19 11H5M19 11C20.1046 11 21 11.8954 21 13V19C21 20.1046 20.1046 21 19 21H5C3.89543 21 3 20.1046 3 19V13C3 11.8954 3.89543 11 5 11M19 11V9C19 7.89543 18.1046 7 17 7M5 11V9C5 7.89543 5.89543 7 7 7M7 7V5C7 3.89543 7.89543 3 9 3H15C16.1046 3 17 3.89543 17 5V7M7 7H17"
|
||||
|
@ -69,17 +57,12 @@
|
|||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
|
||||
<span class="mx-4 font-medium">Dashboard</span>
|
||||
</a>
|
||||
</SidebarEntry>
|
||||
|
||||
<hr class="my-6 dark:border-gray-600" />
|
||||
|
||||
{#if logged_in}
|
||||
<a
|
||||
class="flex items-center px-4 py-2 mt-5 text-gray-600 transition-colors duration-200 transform rounded-md dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700 dark:hover:text-gray-200 hover:text-gray-700"
|
||||
href="/links"
|
||||
>
|
||||
<SidebarEntry title="Manage Links" href="/links" pageUrl="/links" bind:currentPage>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="h-5 w-5"
|
||||
|
@ -94,35 +77,31 @@
|
|||
d="M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"
|
||||
/>
|
||||
</svg>
|
||||
|
||||
<span class="mx-4 font-medium">Manage Links</span>
|
||||
</a>
|
||||
|
||||
<!-- <a
|
||||
class="flex items-center px-4 py-2 mt-5 text-gray-600 transition-colors duration-200 transform rounded-md dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700 dark:hover:text-gray-200 hover:text-gray-700"
|
||||
href="#"
|
||||
>
|
||||
<svg class="w-5 h-5" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
</SidebarEntry>
|
||||
<SidebarEntry title="All visits" href="/visits" pageUrl="/visits" bind:currentPage>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="h-5 w-5"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke="currentColor"
|
||||
>
|
||||
<path
|
||||
d="M10.3246 4.31731C10.751 2.5609 13.249 2.5609 13.6754 4.31731C13.9508 5.45193 15.2507 5.99038 16.2478 5.38285C17.7913 4.44239 19.5576 6.2087 18.6172 7.75218C18.0096 8.74925 18.5481 10.0492 19.6827 10.3246C21.4391 10.751 21.4391 13.249 19.6827 13.6754C18.5481 13.9508 18.0096 15.2507 18.6172 16.2478C19.5576 17.7913 17.7913 19.5576 16.2478 18.6172C15.2507 18.0096 13.9508 18.5481 13.6754 19.6827C13.249 21.4391 10.751 21.4391 10.3246 19.6827C10.0492 18.5481 8.74926 18.0096 7.75219 18.6172C6.2087 19.5576 4.44239 17.7913 5.38285 16.2478C5.99038 15.2507 5.45193 13.9508 4.31731 13.6754C2.5609 13.249 2.5609 10.751 4.31731 10.3246C5.45193 10.0492 5.99037 8.74926 5.38285 7.75218C4.44239 6.2087 6.2087 4.44239 7.75219 5.38285C8.74926 5.99037 10.0492 5.45193 10.3246 4.31731Z"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"
|
||||
/>
|
||||
<path
|
||||
d="M15 12C15 13.6569 13.6569 15 12 15C10.3431 15 9 13.6569 9 12C9 10.3431 10.3431 9 12 9C13.6569 9 15 10.3431 15 12Z"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"
|
||||
/>
|
||||
</svg>
|
||||
|
||||
<span class="mx-4 font-medium">Settings</span>
|
||||
</a> -->
|
||||
</SidebarEntry>
|
||||
<button
|
||||
class="flex items-center px-4 py-2 mt-5 text-gray-600 transition-colors duration-200 transform rounded-md dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700 dark:hover:text-gray-200 hover:text-gray-700"
|
||||
class="flex items-center px-4 py-2 mt-5 transition-colors duration-200 transform rounded-md hover:bg-gray-200 dark:hover:bg-gray-700 dark:hover:text-gray-200 hover:text-gray-700 text-gray-600 dark:text-gray-400"
|
||||
on:click={logout}
|
||||
>
|
||||
<svg
|
||||
|
@ -143,10 +122,7 @@
|
|||
<span class="mx-4 font-medium">Logout</span>
|
||||
</button>
|
||||
{:else}
|
||||
<a
|
||||
class="flex items-center px-4 py-2 mt-5 text-gray-600 transition-colors duration-200 transform rounded-md dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700 dark:hover:text-gray-200 hover:text-gray-700"
|
||||
href="/login"
|
||||
>
|
||||
<SidebarEntry title="Login" href="/login" pageUrl="/login" bind:currentPage>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="h-5 w-5"
|
||||
|
@ -161,19 +137,21 @@
|
|||
d="M11 16l-4-4m0 0l4-4m-4 4h14m-5 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h7a3 3 0 013 3v1"
|
||||
/>
|
||||
</svg>
|
||||
|
||||
<span class="mx-4 font-medium">Login</span>
|
||||
</a>
|
||||
</SidebarEntry>
|
||||
{/if}
|
||||
</nav>
|
||||
|
||||
<div class="flex items-center px-4 -mx-2">
|
||||
<img
|
||||
class="object-cover mx-2 rounded-full h-9 w-9"
|
||||
src="https://images.unsplash.com/photo-1531427186611-ecfd6d936c79?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=634&q=80"
|
||||
alt="avatar"
|
||||
/>
|
||||
<h4 class="mx-2 font-medium text-gray-800 dark:text-gray-200 hover:underline">John Doe</h4>
|
||||
</div>
|
||||
{#if logged_in}
|
||||
<div class="flex items-center px-4 -mx-2">
|
||||
<img
|
||||
class="object-cover mx-2 rounded-full h-9 w-9"
|
||||
src="https://images.unsplash.com/photo-1531427186611-ecfd6d936c79?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=634&q=80"
|
||||
alt="avatar"
|
||||
/>
|
||||
<h4 class="mx-2 font-medium text-gray-800 dark:text-gray-200 hover:underline">
|
||||
Username here
|
||||
</h4>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
|
21
src/lib/SidebarEntry.svelte
Normal file
21
src/lib/SidebarEntry.svelte
Normal file
|
@ -0,0 +1,21 @@
|
|||
<script>
|
||||
export let currentPage;
|
||||
export let title = 'null';
|
||||
export let href = './null';
|
||||
export let pageUrl = '/null';
|
||||
</script>
|
||||
|
||||
<a
|
||||
class="flex items-center px-4 py-2 mt-5 transition-colors duration-200 transform rounded-md hover:bg-gray-200 dark:hover:bg-gray-700 dark:hover:text-gray-200 hover:text-gray-700"
|
||||
class:dark:bg-gray-700={currentPage == pageUrl}
|
||||
class:bg-gray-200={currentPage == pageUrl}
|
||||
class:dark:text-gray-200={currentPage == pageUrl}
|
||||
class:text-gray-700={currentPage == pageUrl}
|
||||
class:dark:text-gray-400={!(currentPage == pageUrl)}
|
||||
class:text-gray-600={!(currentPage == pageUrl)}
|
||||
{href}
|
||||
>
|
||||
<slot />
|
||||
|
||||
<span class="mx-4 font-medium">{title}</span>
|
||||
</a>
|
|
@ -46,7 +46,7 @@ const userStore = () => {
|
|||
//
|
||||
return state;
|
||||
});
|
||||
location.replace("/");
|
||||
location.replace("./");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,12 +1,31 @@
|
|||
<script>
|
||||
import '../app.postcss';
|
||||
import Sidebar from '$lib/Sidebar.svelte';
|
||||
import UserStore from '$lib/UserStore';
|
||||
import { onMount } from 'svelte';
|
||||
import * as localForage from 'localforage';
|
||||
|
||||
/**
|
||||
* Master init for all things userstore, b/c async stuff somethimes does weired shit.
|
||||
* Yes i know this isn't the best way to implement this, but linkylinky dashboard is just a oneshot sideproject r/n.
|
||||
*/
|
||||
onMount(() => {
|
||||
UserStore.init();
|
||||
localForage.getItem('userdata', (err, value) => {
|
||||
if (value) {
|
||||
if (value.token) {
|
||||
UserStore.login(value);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<div style="min-height: 640px;" class="bg-white dark:bg-gray-800">
|
||||
<div class="h-screen flex overflow-hidden">
|
||||
<Sidebar/>
|
||||
<div class="px-4 py-8 flex flex-col w-0 flex-1 overflow-hidden">
|
||||
<Sidebar />
|
||||
<div class="px-4 py-8 flex flex-col w-0 flex-1 overflow-y-scroll">
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<script>
|
||||
import { page } from '$app/stores';
|
||||
import Apiclient from '$lib/Apiclient';
|
||||
import UserStore from '$lib/UserStore';
|
||||
import { onDestroy, onMount } from 'svelte';
|
||||
|
||||
let shortcode = $page.query.get('shortcode');
|
||||
$: urlDetails = {
|
||||
shortcode: 'Loading...',
|
||||
url: 'Loading...',
|
||||
|
@ -10,12 +10,27 @@
|
|||
visits: 'Loading...'
|
||||
};
|
||||
$: urlVisists = [];
|
||||
let visitQuery;
|
||||
let shortcode;
|
||||
|
||||
Apiclient.getUrlDetails(shortcode).then((res) => {
|
||||
urlDetails = res;
|
||||
});
|
||||
let visitQuery = Apiclient.getUrlVisits(shortcode).then((res) => {
|
||||
urlVisists = res;
|
||||
onMount(async () => {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
let shortcode = params.get('shortcode');
|
||||
|
||||
// Yes i know this isn't the best way to implement this, but linkylinky dashboard is just a oneshot sideproject r/n.
|
||||
const unsubscribe = UserStore.subscribe((value) => {
|
||||
if (value.isLoggedIn) {
|
||||
Apiclient.getUrlDetails(shortcode).then((res) => {
|
||||
urlDetails = res;
|
||||
unsubscribe();
|
||||
});
|
||||
visitQuery = Apiclient.getUrlVisits(shortcode).then((res) => {
|
||||
urlVisists = res;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
onDestroy(unsubscribe);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
@ -39,6 +54,9 @@
|
|||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider">
|
||||
Timestamp
|
||||
</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider">
|
||||
Provider
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="bg-white dark:bg-gray-700 divide-y divide-gray-200 dark:text-gray-100" x-max="1">
|
||||
|
@ -49,6 +67,7 @@
|
|||
>
|
||||
Loading data...
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm"> Loading data... </td>
|
||||
</tr>
|
||||
{:then}
|
||||
{#each urlVisists as visit}
|
||||
|
@ -58,6 +77,7 @@
|
|||
>
|
||||
{visit.timestamp}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm"> {visit.provider} </td>
|
||||
</tr>
|
||||
{/each}
|
||||
{/await}
|
||||
|
|
|
@ -45,4 +45,4 @@
|
|||
/>
|
||||
</svg>
|
||||
</Statscard>
|
||||
</div>
|
||||
</div>
|
|
@ -1,10 +1,22 @@
|
|||
<script>
|
||||
import Apiclient from '$lib/Apiclient';
|
||||
import UserStore from '$lib/UserStore';
|
||||
import { onDestroy } from 'svelte';
|
||||
|
||||
$: urls = [];
|
||||
let urlQuery = Apiclient.getUrls().then((res) => {
|
||||
urls = res;
|
||||
let urlQuery;
|
||||
|
||||
// Yes i know this isn't the best way to implement this, but linkylinky dashboard is just a oneshot sideproject r/n.
|
||||
const unsubscribe = UserStore.subscribe((value) => {
|
||||
if (value.isLoggedIn) {
|
||||
urlQuery = Apiclient.getUrls().then((res) => {
|
||||
urls = res;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
onDestroy(unsubscribe);
|
||||
|
||||
function deleteUrl(shortcode) {
|
||||
Apiclient.deleteUrl(shortcode).then(() => {
|
||||
urls = urls.filter((url) => url.shortcode != shortcode);
|
||||
|
@ -40,7 +52,7 @@
|
|||
Loading data...
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm">
|
||||
<a href="#">Loading data...</a>
|
||||
<p href="#">Loading data...</p>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm"> Loading data... </td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
|
||||
|
@ -70,7 +82,7 @@
|
|||
Delete
|
||||
</button>
|
||||
<a
|
||||
href={`/details?shortcode=${url.shortcode}`}
|
||||
href={`./details?shortcode=${url.shortcode}`}
|
||||
class="px-4 py-2 font-medium tracking-wide text-white capitalize transition-colors duration-200 transform bg-blue-600 rounded-md hover:bg-blue-700 focus:outline-none focus:bg-blue-700"
|
||||
>
|
||||
Details
|
||||
|
|
|
@ -7,16 +7,21 @@ import Apiclient from '$lib/Apiclient';
|
|||
$: password = "";
|
||||
$: error = "";
|
||||
|
||||
UserStore.init();
|
||||
async function login() {
|
||||
try {
|
||||
const login = await Apiclient.login(username, password);
|
||||
UserStore.login(login);
|
||||
location.replace("/");
|
||||
location.replace("./");
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function handleKeydown(e) {
|
||||
if (e.keyCode === 13) {
|
||||
login();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="w-full max-w-sm mx-auto overflow-hidden bg-white rounded-lg shadow-md dark:bg-gray-800">
|
||||
|
@ -31,21 +36,23 @@ import Apiclient from '$lib/Apiclient';
|
|||
|
||||
<div class="w-full mt-4">
|
||||
<input
|
||||
class="block w-full px-4 py-2 mt-2 text-gray-700 placeholder-gray-500 bg-white border border-gray-300 rounded-md dark:bg-gray-800 dark:border-gray-600 dark:placeholder-gray-400 focus:border-blue-500 dark:focus:border-blue-500 focus:outline-none focus:ring"
|
||||
class="block w-full px-4 py-2 mt-2 text-gray-700 dark:text-gray-200 placeholder-gray-500 bg-white border border-gray-300 rounded-md dark:bg-gray-800 dark:border-gray-600 dark:placeholder-gray-400 focus:border-blue-500 dark:focus:border-blue-500 focus:outline-none focus:ring"
|
||||
type="text"
|
||||
placeholder="Username"
|
||||
aria-label="Username"
|
||||
bind:value={username}
|
||||
on:keydown={handleKeydown}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="w-full mt-4">
|
||||
<input
|
||||
class="block w-full px-4 py-2 mt-2 text-gray-700 placeholder-gray-500 bg-white border border-gray-300 rounded-md dark:bg-gray-800 dark:border-gray-600 dark:placeholder-gray-400 focus:border-blue-500 dark:focus:border-blue-500 focus:outline-none focus:ring"
|
||||
class="block w-full px-4 py-2 mt-2 text-gray-700 dark:text-gray-200 placeholder-gray-500 bg-white border border-gray-300 rounded-md dark:bg-gray-800 dark:border-gray-600 dark:placeholder-gray-400 focus:border-blue-500 dark:focus:border-blue-500 focus:outline-none focus:ring"
|
||||
type="password"
|
||||
placeholder="Password"
|
||||
aria-label="Password"
|
||||
bind:value={password}
|
||||
on:keydown={handleKeydown}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
|
68
src/routes/visits.svelte
Normal file
68
src/routes/visits.svelte
Normal file
|
@ -0,0 +1,68 @@
|
|||
<script>
|
||||
import Apiclient from '$lib/Apiclient';
|
||||
import UserStore from '$lib/UserStore';
|
||||
import { onDestroy } from 'svelte';
|
||||
|
||||
$: visits = [];
|
||||
let visitQuery;
|
||||
|
||||
// Yes i know this isn't the best way to implement this, but linkylinky dashboard is just a oneshot sideproject r/n.
|
||||
const unsubscribe = UserStore.subscribe((value) => {
|
||||
if (value.isLoggedIn) {
|
||||
visitQuery = Apiclient.getVisits().then((res) => {
|
||||
visits = res;
|
||||
unsubscribe();
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<h2 class="text-3xl font-bold text-gray-800 dark:text-gray-100 pb-6">View all visits</h2>
|
||||
<div class="rounded-xl">
|
||||
<table class="min-w-full divide-y divide-gray-200">
|
||||
<thead class="bg-gray-50 dark:bg-gray-900 text-gray-800 dark:text-gray-100">
|
||||
<tr>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider">
|
||||
Shortcode
|
||||
</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider">
|
||||
Provider
|
||||
</th>
|
||||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider">
|
||||
Timestamp
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="bg-white dark:bg-gray-700 divide-y divide-gray-200 dark:text-gray-100" x-max="1">
|
||||
{#await visitQuery}
|
||||
<tr>
|
||||
<td
|
||||
class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900 dark:text-gray-200"
|
||||
>
|
||||
Loading data...
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm"> Loading data... </td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm"> Loading data... </td>
|
||||
</tr>
|
||||
{:then}
|
||||
{#each visits as visit}
|
||||
<tr>
|
||||
<td
|
||||
class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900 dark:text-gray-200"
|
||||
>
|
||||
{#if visit.provider == "native"}
|
||||
<a href={`./details?shortcode=${visit.shortcode}`}>{visit.shortcode}</a>
|
||||
{:else}
|
||||
{visit.shortcode}
|
||||
{/if}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm">
|
||||
{visit.provider}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm"> {visit.timestamp} </td>
|
||||
</tr>
|
||||
{/each}
|
||||
{/await}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
|
@ -1,22 +1,29 @@
|
|||
import preprocess from 'svelte-preprocess';
|
||||
import staticAdapter from '@sveltejs/adapter-static';
|
||||
|
||||
/** @type {import('@sveltejs/kit').Config} */
|
||||
import preprocess from "svelte-preprocess";
|
||||
import adapterStatic from '@sveltejs/adapter-static';
|
||||
|
||||
const config = {
|
||||
kit: {
|
||||
// hydrate the <div id="svelte"> element in src/app.html
|
||||
target: '#svelte',
|
||||
adapter: staticAdapter(),
|
||||
adapter: adapterStatic({
|
||||
// default options are shown
|
||||
pages: 'build',
|
||||
assets: 'build',
|
||||
fallback: null,
|
||||
precompress: false
|
||||
}),
|
||||
prerender: {
|
||||
// This can be false if you're using a fallback (i.e. SPA mode)
|
||||
default: true
|
||||
},
|
||||
files: {
|
||||
assets: 'static'
|
||||
}
|
||||
},
|
||||
|
||||
preprocess: [
|
||||
preprocess({
|
||||
postcss: true
|
||||
})
|
||||
]
|
||||
],
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
const config = {
|
||||
mode: 'jit',
|
||||
darkMode: 'media',
|
||||
purge: ['./src/**/*.{html,js,svelte,ts}'],
|
||||
mode: "jit",
|
||||
content: [
|
||||
"./src/**/*.{html,js,svelte,ts}",
|
||||
],
|
||||
theme: {
|
||||
extend: {}
|
||||
extend: {},
|
||||
},
|
||||
plugins: []
|
||||
plugins: [],
|
||||
};
|
||||
|
||||
module.exports = config;
|
||||
|
|
Loading…
Reference in New Issue
Block a user