TS migration WIP

pull/37/head
Varun Patil 2022-09-12 18:33:24 -07:00
parent 8d7b18ff1a
commit f13f68ff21
18 changed files with 1271 additions and 935 deletions

286
package-lock.json generated
View File

@ -1,18 +1,21 @@
{
"name": "memories",
"version": "0.0.0",
"version": "1.0.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "memories",
"version": "0.0.0",
"version": "1.0.1",
"license": "agpl",
"dependencies": {
"@nextcloud/l10n": "^1.6.0",
"@nextcloud/vue": "^6.0.0-beta.6",
"path-posix": "^1.0.0",
"reflect-metadata": "^0.1.13",
"vue": "^2.7.10",
"vue-class-component": "^7.2.6",
"vue-property-decorator": "^9.1.2",
"vue-router": "^3.5.4",
"vue-virtual-scroller": "^1.0.10",
"webdav": "^4.11.0"
@ -22,7 +25,10 @@
"@nextcloud/browserslist-config": "^2.3.0",
"@nextcloud/eslint-config": "^8.1.2",
"@nextcloud/stylelint-config": "^2.2.0",
"@nextcloud/webpack-vue-config": "^5.3.0"
"@nextcloud/webpack-vue-config": "^5.3.0",
"@types/url-parse": "^1.4.8",
"ts-loader": "^9.3.1",
"typescript": "^4.8.3"
},
"engines": {
"node": ">=14.0.0",
@ -2583,6 +2589,12 @@
"@types/node": "*"
}
},
"node_modules/@types/url-parse": {
"version": "1.4.8",
"resolved": "https://registry.npmjs.org/@types/url-parse/-/url-parse-1.4.8.tgz",
"integrity": "sha512-zqqcGKyNWgTLFBxmaexGUKQyWqeG7HjXj20EuQJSJWwXe54BjX0ihIo5cJB9yAQzH8dNugJ9GvkBYMjPXs/PJw==",
"dev": true
},
"node_modules/@types/ws": {
"version": "8.5.3",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.3.tgz",
@ -3450,7 +3462,6 @@
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
"dev": true,
"peer": true,
"dependencies": {
"fill-range": "^7.0.1"
},
@ -4706,7 +4717,6 @@
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.10.0.tgz",
"integrity": "sha512-T0yTFjdpldGY8PmuXXR0PyQ1ufZpEGiHVrp7zHKB7jdR4qlmZHhONVM5AQOAWXuF/w3dnHbEQVrNptJgt7F+cQ==",
"dev": true,
"peer": true,
"dependencies": {
"graceful-fs": "^4.2.4",
"tapable": "^2.2.0"
@ -5803,7 +5813,6 @@
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
"dev": true,
"peer": true,
"dependencies": {
"to-regex-range": "^5.0.1"
},
@ -6283,8 +6292,7 @@
"version": "4.2.10",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz",
"integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==",
"dev": true,
"peer": true
"dev": true
},
"node_modules/grapheme-splitter": {
"version": "1.0.4",
@ -7091,7 +7099,6 @@
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
"dev": true,
"peer": true,
"engines": {
"node": ">=0.12.0"
}
@ -7715,7 +7722,6 @@
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz",
"integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==",
"dev": true,
"peer": true,
"dependencies": {
"braces": "^3.0.2",
"picomatch": "^2.3.1"
@ -8425,7 +8431,6 @@
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
"dev": true,
"peer": true,
"engines": {
"node": ">=8.6"
},
@ -9110,6 +9115,11 @@
"node": ">=8"
}
},
"node_modules/reflect-metadata": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz",
"integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg=="
},
"node_modules/regenerate": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz",
@ -10490,7 +10500,6 @@
"resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz",
"integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==",
"dev": true,
"peer": true,
"engines": {
"node": ">=6"
}
@ -10625,7 +10634,6 @@
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
"dev": true,
"peer": true,
"dependencies": {
"is-number": "^7.0.0"
},
@ -10663,6 +10671,110 @@
"node": ">=8"
}
},
"node_modules/ts-loader": {
"version": "9.3.1",
"resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-9.3.1.tgz",
"integrity": "sha512-OkyShkcZTsTwyS3Kt7a4rsT/t2qvEVQuKCTg4LJmpj9fhFR7ukGdZwV6Qq3tRUkqcXtfGpPR7+hFKHCG/0d3Lw==",
"dev": true,
"dependencies": {
"chalk": "^4.1.0",
"enhanced-resolve": "^5.0.0",
"micromatch": "^4.0.0",
"semver": "^7.3.4"
},
"engines": {
"node": ">=12.0.0"
},
"peerDependencies": {
"typescript": "*",
"webpack": "^5.0.0"
}
},
"node_modules/ts-loader/node_modules/ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dev": true,
"dependencies": {
"color-convert": "^2.0.1"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/ts-loader/node_modules/chalk": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"dev": true,
"dependencies": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
"node_modules/ts-loader/node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dev": true,
"dependencies": {
"color-name": "~1.1.4"
},
"engines": {
"node": ">=7.0.0"
}
},
"node_modules/ts-loader/node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
},
"node_modules/ts-loader/node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true,
"engines": {
"node": ">=8"
}
},
"node_modules/ts-loader/node_modules/semver": {
"version": "7.3.7",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz",
"integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==",
"dev": true,
"dependencies": {
"lru-cache": "^6.0.0"
},
"bin": {
"semver": "bin/semver.js"
},
"engines": {
"node": ">=10"
}
},
"node_modules/ts-loader/node_modules/supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"dependencies": {
"has-flag": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/tsconfig-paths": {
"version": "3.14.1",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz",
@ -10741,6 +10853,19 @@
"node": ">= 0.6"
}
},
"node_modules/typescript": {
"version": "4.8.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz",
"integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=4.2.0"
}
},
"node_modules/unbox-primitive": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz",
@ -10973,6 +11098,14 @@
"csstype": "^3.1.0"
}
},
"node_modules/vue-class-component": {
"version": "7.2.6",
"resolved": "https://registry.npmjs.org/vue-class-component/-/vue-class-component-7.2.6.tgz",
"integrity": "sha512-+eaQXVrAm/LldalI272PpDe3+i4mPis0ORiMYxF6Ae4hyuCh15W8Idet7wPUEs4N4YptgFHGys4UrgNQOMyO6w==",
"peerDependencies": {
"vue": "^2.0.0"
}
},
"node_modules/vue-color": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/vue-color/-/vue-color-2.8.1.tgz",
@ -11139,6 +11272,15 @@
"resolved": "https://registry.npmjs.org/vue-observe-visibility/-/vue-observe-visibility-0.4.6.tgz",
"integrity": "sha512-xo0CEVdkjSjhJoDdLSvoZoQrw/H2BlzB5jrCBKGZNXN2zdZgMuZ9BKrxXDjNP2AxlcCoKc8OahI3F3r3JGLv2Q=="
},
"node_modules/vue-property-decorator": {
"version": "9.1.2",
"resolved": "https://registry.npmjs.org/vue-property-decorator/-/vue-property-decorator-9.1.2.tgz",
"integrity": "sha512-xYA8MkZynPBGd/w5QFJ2d/NM0z/YeegMqYTphy7NJQXbZcuU6FC6AOdUAcy4SXP+YnkerC6AfH+ldg7PDk9ESQ==",
"peerDependencies": {
"vue": "*",
"vue-class-component": "*"
}
},
"node_modules/vue-resize": {
"version": "0.4.5",
"resolved": "https://registry.npmjs.org/vue-resize/-/vue-resize-0.4.5.tgz",
@ -13744,6 +13886,12 @@
"@types/node": "*"
}
},
"@types/url-parse": {
"version": "1.4.8",
"resolved": "https://registry.npmjs.org/@types/url-parse/-/url-parse-1.4.8.tgz",
"integrity": "sha512-zqqcGKyNWgTLFBxmaexGUKQyWqeG7HjXj20EuQJSJWwXe54BjX0ihIo5cJB9yAQzH8dNugJ9GvkBYMjPXs/PJw==",
"dev": true
},
"@types/ws": {
"version": "8.5.3",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.3.tgz",
@ -14474,7 +14622,6 @@
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
"dev": true,
"peer": true,
"requires": {
"fill-range": "^7.0.1"
}
@ -15468,7 +15615,6 @@
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.10.0.tgz",
"integrity": "sha512-T0yTFjdpldGY8PmuXXR0PyQ1ufZpEGiHVrp7zHKB7jdR4qlmZHhONVM5AQOAWXuF/w3dnHbEQVrNptJgt7F+cQ==",
"dev": true,
"peer": true,
"requires": {
"graceful-fs": "^4.2.4",
"tapable": "^2.2.0"
@ -16299,7 +16445,6 @@
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
"dev": true,
"peer": true,
"requires": {
"to-regex-range": "^5.0.1"
}
@ -16666,8 +16811,7 @@
"version": "4.2.10",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz",
"integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==",
"dev": true,
"peer": true
"dev": true
},
"grapheme-splitter": {
"version": "1.0.4",
@ -17257,8 +17401,7 @@
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
"dev": true,
"peer": true
"dev": true
},
"is-number-object": {
"version": "1.0.7",
@ -17739,7 +17882,6 @@
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz",
"integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==",
"dev": true,
"peer": true,
"requires": {
"braces": "^3.0.2",
"picomatch": "^2.3.1"
@ -18293,8 +18435,7 @@
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
"dev": true,
"peer": true
"dev": true
},
"pkg-dir": {
"version": "4.2.0",
@ -18801,6 +18942,11 @@
"strip-indent": "^3.0.0"
}
},
"reflect-metadata": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz",
"integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg=="
},
"regenerate": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz",
@ -19883,8 +20029,7 @@
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz",
"integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==",
"dev": true,
"peer": true
"dev": true
},
"terser": {
"version": "5.14.2",
@ -19977,7 +20122,6 @@
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
"dev": true,
"peer": true,
"requires": {
"is-number": "^7.0.0"
}
@ -20006,6 +20150,78 @@
"dev": true,
"peer": true
},
"ts-loader": {
"version": "9.3.1",
"resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-9.3.1.tgz",
"integrity": "sha512-OkyShkcZTsTwyS3Kt7a4rsT/t2qvEVQuKCTg4LJmpj9fhFR7ukGdZwV6Qq3tRUkqcXtfGpPR7+hFKHCG/0d3Lw==",
"dev": true,
"requires": {
"chalk": "^4.1.0",
"enhanced-resolve": "^5.0.0",
"micromatch": "^4.0.0",
"semver": "^7.3.4"
},
"dependencies": {
"ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dev": true,
"requires": {
"color-convert": "^2.0.1"
}
},
"chalk": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"dev": true,
"requires": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
}
},
"color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dev": true,
"requires": {
"color-name": "~1.1.4"
}
},
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
},
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true
},
"semver": {
"version": "7.3.7",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz",
"integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==",
"dev": true,
"requires": {
"lru-cache": "^6.0.0"
}
},
"supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"requires": {
"has-flag": "^4.0.0"
}
}
}
},
"tsconfig-paths": {
"version": "3.14.1",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz",
@ -20071,6 +20287,12 @@
"mime-types": "~2.1.24"
}
},
"typescript": {
"version": "4.8.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz",
"integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==",
"dev": true
},
"unbox-primitive": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz",
@ -20259,6 +20481,12 @@
"csstype": "^3.1.0"
}
},
"vue-class-component": {
"version": "7.2.6",
"resolved": "https://registry.npmjs.org/vue-class-component/-/vue-class-component-7.2.6.tgz",
"integrity": "sha512-+eaQXVrAm/LldalI272PpDe3+i4mPis0ORiMYxF6Ae4hyuCh15W8Idet7wPUEs4N4YptgFHGys4UrgNQOMyO6w==",
"requires": {}
},
"vue-color": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/vue-color/-/vue-color-2.8.1.tgz",
@ -20383,6 +20611,12 @@
"resolved": "https://registry.npmjs.org/vue-observe-visibility/-/vue-observe-visibility-0.4.6.tgz",
"integrity": "sha512-xo0CEVdkjSjhJoDdLSvoZoQrw/H2BlzB5jrCBKGZNXN2zdZgMuZ9BKrxXDjNP2AxlcCoKc8OahI3F3r3JGLv2Q=="
},
"vue-property-decorator": {
"version": "9.1.2",
"resolved": "https://registry.npmjs.org/vue-property-decorator/-/vue-property-decorator-9.1.2.tgz",
"integrity": "sha512-xYA8MkZynPBGd/w5QFJ2d/NM0z/YeegMqYTphy7NJQXbZcuU6FC6AOdUAcy4SXP+YnkerC6AfH+ldg7PDk9ESQ==",
"requires": {}
},
"vue-resize": {
"version": "0.4.5",
"resolved": "https://registry.npmjs.org/vue-resize/-/vue-resize-0.4.5.tgz",

View File

@ -35,7 +35,10 @@
"@nextcloud/l10n": "^1.6.0",
"@nextcloud/vue": "^6.0.0-beta.6",
"path-posix": "^1.0.0",
"reflect-metadata": "^0.1.13",
"vue": "^2.7.10",
"vue-class-component": "^7.2.6",
"vue-property-decorator": "^9.1.2",
"vue-router": "^3.5.4",
"vue-virtual-scroller": "^1.0.10",
"webdav": "^4.11.0"
@ -52,6 +55,9 @@
"@nextcloud/browserslist-config": "^2.3.0",
"@nextcloud/eslint-config": "^8.1.2",
"@nextcloud/stylelint-config": "^2.2.0",
"@nextcloud/webpack-vue-config": "^5.3.0"
"@nextcloud/webpack-vue-config": "^5.3.0",
"@types/url-parse": "^1.4.8",
"ts-loader": "^9.3.1",
"typescript": "^4.8.3"
}
}

View File

@ -45,7 +45,7 @@
}
</style>
<script>
<script lang="ts">
import { NcContent, NcAppContent, NcAppNavigation, NcAppNavigationItem, NcAppNavigationSettings} from '@nextcloud/vue'
import Timeline from './components/Timeline.vue'

View File

@ -36,35 +36,24 @@
</div>
</template>
<script>
<script lang="ts">
import { Component, Vue, Prop } from 'vue-property-decorator';
import { IDay, IPhoto } from "../types";
import * as dav from "../services/DavRequests";
import constants from "../mixins/constants"
import errorsvg from "../assets/error.svg";
import { getPreviewUrl } from "../services/FileUtils";
export default {
name: 'Photo',
data() {
return {
touchTimer: 0,
c: constants,
}
},
props: {
data: {
type: Object,
required: true
},
rowHeight: {
type: Number,
required: true,
},
day: {
type: Object,
required: true,
},
},
methods: {
@Component({})
export default class Photo extends Vue {
private touchTimer = 0;
private readonly c = constants;
@Prop() data: IPhoto;
@Prop() rowHeight: number;
@Prop() day: IDay;
/** Get URL for image to show */
getUrl() {
if (this.data.flag & constants.FLAG_PLACEHOLDER) {
@ -77,17 +66,17 @@ export default {
} else {
return getPreviewUrl(this.data.fileid, this.data.etag);
}
},
}
/** Error in loading image */
error(e) {
error(e: any) {
this.data.flag |= (constants.FLAG_LOADED | constants.FLAG_LOAD_FAIL);
},
}
/** Pass to parent */
click() {
this.$emit('clickImg', this);
},
}
/** Open viewer */
async openFile() {
@ -101,12 +90,9 @@ export default {
if (!fileInfos) {
const ids = this.day.detail.map(p => p.fileid);
try {
this.loading = true;
fileInfos = await dav.getFiles(ids);
} catch (e) {
console.error('Failed to load fileInfos', e);
} finally {
this.loading = false;
}
if (fileInfos.length === 0) {
return;
@ -123,7 +109,7 @@ export default {
// Store in day with a original copy
this.day.fileInfos = fileInfos;
this.day.fiOrigIds = new Set(fileInfos.map(f => f.fileid));
this.day.origFileIds = new Set(fileInfos.map(f => f.fileid));
}
// Get this photo in the fileInfos
@ -137,17 +123,17 @@ export default {
const SIDEBAR_KEY = 'memories:sidebar-open';
// Open viewer
OCA.Viewer.open({
globalThis.OCA.Viewer.open({
path: photo.filename, // path
list: fileInfos, // file list
canLoop: false, // don't loop
onClose: () => { // on viewer close
if (OCA.Files.Sidebar.file) {
if (globalThis.OCA.Files.Sidebar.file) {
localStorage.setItem(SIDEBAR_KEY, '1');
} else {
localStorage.removeItem(SIDEBAR_KEY);
}
OCA.Files.Sidebar.close();
globalThis.OCA.Files.Sidebar.close();
// Check for any deleted files and remove them from the main view
this.processDeleted();
@ -156,9 +142,9 @@ export default {
// Restore sidebar state
if (localStorage.getItem(SIDEBAR_KEY) === '1') {
OCA.Files.Sidebar.open(photo.filename);
globalThis.OCA.Files.Sidebar.open(photo.filename);
}
}
},
/** Remove deleted files from main view */
processDeleted() {
@ -167,43 +153,42 @@ export default {
// Compare new and old list of ids
const newIds = new Set(this.day.fileInfos.map(f => f.fileid));
const remIds = new Set([...this.day.fiOrigIds].filter(x => !newIds.has(x)));
const remIds = new Set([...this.day.origFileIds].filter(x => !newIds.has(x)));
// Exit if nothing to do
if (remIds.size === 0) {
return;
}
this.day.fiOrigIds = newIds;
this.day.origFileIds = newIds;
// Remove deleted files from details
this.$emit('reprocess', remIds, new Set([this.day]));
},
}
toggleSelect() {
if (this.data.flag & constants.FLAG_PLACEHOLDER) {
return;
}
this.$emit('select', this.data);
},
}
touchstart() {
this.touchTimer = setTimeout(() => {
this.touchTimer = window.setTimeout(() => {
this.toggleSelect();
this.touchTimer = 0;
}, 600);
},
}
contextmenu(e) {
contextmenu(e: Event) {
e.preventDefault();
e.stopPropagation();
},
}
touchend() {
if (this.touchTimer) {
clearTimeout(this.touchTimer);
this.touchTimer = 0;
}
},
}
}
</script>

View File

@ -91,15 +91,18 @@
</div>
</template>
<script>
<script lang="ts">
import { Component, Watch, Vue } from 'vue-property-decorator';
import { IDay, IPhoto, IRow, ITick } from "../types";
import { NcActions, NcActionButton, NcButton } from '@nextcloud/vue';
import { generateUrl } from '@nextcloud/router'
import * as dav from "../services/DavRequests";
import * as utils from "../services/Utils";
import axios from '@nextcloud/axios'
import Folder from "./Folder";
import Photo from "./Photo";
import Folder from "./Folder.vue";
import Photo from "./Photo.vue";
import constants from "../mixins/constants";
import { generateUrl } from '@nextcloud/router'
import { NcActions, NcActionButton, NcButton } from '@nextcloud/vue'
const SCROLL_LOAD_DELAY = 100; // Delay in loading data when scrolling
const MAX_PHOTO_WIDTH = 175; // Max width of a photo
@ -117,93 +120,89 @@ for (const [key, value] of Object.entries(API_ROUTES)) {
API_ROUTES[key] = '/apps/memories/api/' + value;
}
export default {
@Component({
components: {
Folder,
Photo,
NcActions,
NcActionButton,
NcButton
},
data() {
return {
}
})
export default class Timeline extends Vue {
/** Loading days response */
loading: true,
private loading = true;
/** Main list of rows */
list: [],
private list: IRow[] = [];
/** Counter of rows */
numRows: 0,
private numRows = 0;
/** Computed number of columns */
numCols: 5,
private numCols = 5;
/** Header rows for dayId key */
heads: {},
private heads: { [dayid: number]: IRow } = {};
/** Original days response */
days: [],
private days: IDay[] = [];
/** Computed row height */
rowHeight: 100,
private rowHeight = 100;
/** Total height of recycler */
viewHeight: 1000,
private viewHeight = 1000;
/** Total height of timeline */
timelineHeight: 100,
private timelineHeight = 100;
/** Computed timeline ticks */
timelineTicks: [],
private timelineTicks: ITick[] = [];
/** Computed timeline cursor top */
timelineCursorY: 0,
private timelineCursorY = 0;
/** Timeline hover cursor top */
timelineHoverCursorY: -5,
private timelineHoverCursorY = -5;
/** Timeline hover cursor text */
timelineHoverCursorText: "",
private timelineHoverCursorText = "";
/** Current start index */
currentStart: 0,
private currentStart = 0;
/** Current end index */
currentEnd: 0,
private currentEnd = 0;
/** Scrolling currently */
scrolling: false,
private scrolling = false;
/** Scrolling timer */
scrollTimer: null,
private scrollTimer = null as number | null;
/** Resizing timer */
resizeTimer: null,
private resizeTimer = null as number | null;
/** View size reflow timer */
reflowTimelineTimer: null,
private reflowTimelineTimer = null as number | null;
/** Is mobile layout */
isMobile: false,
private isMobile = false;
/** Set of dayIds for which images loaded */
loadedDays: new Set(),
private loadedDays = new Set<number>();
/** Set of selected file ids */
selection: new Set(),
private selection = new Set<IPhoto>();
/** State for request cancellations */
state: Math.random(),
private state = Math.random();
/** Constants for HTML template */
c: constants,
}
},
private readonly c = constants;
mounted() {
this.handleResize();
this.fetchDays();
// Timeline recycler init
this.$refs.recycler.$el.addEventListener('scroll', this.scrollPositionChange, false);
(this.$refs.recycler as any).$el.addEventListener('scroll', this.scrollPositionChange, false);
this.scrollPositionChange();
},
}
watch: {
$route(from, to) {
@Watch('route')
routeChange(from, to) {
this.resetState();
this.fetchDays();
},
},
};
beforeDestroy() {
this.resetState();
},
}
methods: {
/** Reset all state */
resetState() {
this.clearSelection();
@ -217,25 +216,28 @@ export default {
this.timelineTicks = [];
this.state = Math.random();
this.loadedDays.clear();
},
}
/** Do resize after some time */
handleResizeWithDelay() {
if (this.resizeTimer) {
clearTimeout(this.resizeTimer);
}
this.resizeTimer = setTimeout(() => {
this.resizeTimer = window.setTimeout(() => {
this.handleResize();
this.resizeTimer = null;
}, 300);
},
}
/** Handle window resize and initialization */
handleResize() {
let height = this.$refs.container.clientHeight;
let width = this.$refs.container.clientWidth;
this.timelineHeight = this.$refs.timelineScroll.clientHeight;
this.$refs.recycler.$el.style.height = (height - 4) + 'px';
const e = this.$refs.container as Element;
let height = e.clientHeight;
let width = e.clientWidth;
this.timelineHeight = e.clientHeight;
const recycler = this.$refs.recycler as any;
recycler.$el.style.height = (height - 4) + 'px';
// Mobile devices
if (window.innerWidth <= 768) {
@ -258,31 +260,31 @@ export default {
row.size = this.rowHeight;
});
this.reflowTimeline();
},
}
/**
* Triggered when position of scroll change.
* This does NOT indicate the items have changed, only that
* the pixel position of the recycler has changed.
*/
scrollPositionChange(event) {
scrollPositionChange(event?: any) {
if (event) {
this.timelineCursorY = event.target.scrollTop * this.timelineHeight / this.viewHeight;
this.timelineMoveHoverCursor(this.timelineCursorY);
}
if (this.scrollTimer) {
clearTimeout(this.scrollTimer);
window.clearTimeout(this.scrollTimer);
}
this.scrolling = true;
this.scrollTimer = setTimeout(() => {
this.scrollTimer = window.setTimeout(() => {
this.scrolling = false;
this.scrollTimer = null;
}, 1500);
},
}
/** Trigger when recycler view changes */
scrollChange(startIndex, endIndex) {
scrollChange(startIndex: number, endIndex: number) {
if (startIndex === this.currentStart && endIndex === this.currentEnd) {
return;
}
@ -300,7 +302,7 @@ export default {
for (let j = 0; j < row.pct; j++) {
row.photos[j] = {
flag: constants.FLAG_PLACEHOLDER,
fileid: `${row.dayId}-${i}-${j}`,
fileid: row.dayId * 10000 + i * 1000 + j,
};
}
delete row.pct;
@ -330,10 +332,10 @@ export default {
this.loadScrollChanges(start, end);
}
}, SCROLL_LOAD_DELAY);
},
}
/** Load image data for given view */
loadScrollChanges(startIndex, endIndex) {
loadScrollChanges(startIndex: number, endIndex: number) {
// Make sure start and end valid
startIndex = Math.max(0, startIndex);
endIndex = Math.min(this.list.length - 1, endIndex);
@ -348,15 +350,15 @@ export default {
this.loadedDays.add(item.dayId);
this.fetchDay(item.dayId);
}
},
}
/** Get query string for API calls */
appendQuery(url) {
appendQuery(url: string) {
const query = new URLSearchParams();
// Favorites
if (this.$route.name === 'favorites') {
query.set('fav', 1);
query.set('fav', '1');
}
// Create query string and append to URL
@ -365,10 +367,10 @@ export default {
url += '?' + queryStr;
}
return url;
},
}
/** Get name of header */
getHeadName(head) {
getHeadName(head: IRow) {
// Check cache
if (head.name) {
return head.name;
@ -393,12 +395,12 @@ export default {
// Cache and return
head.name = name;
return head.name;
},
}
/** Fetch timeline main call */
async fetchDays() {
let url = API_ROUTES.DAYS;
let params = {};
let params: any = {};
if (this.$route.name === 'folders') {
url = API_ROUTES.FOLDER_DAYS;
@ -406,16 +408,16 @@ export default {
}
const startState = this.state;
const res = await axios.get(generateUrl(this.appendQuery(url), params));
const res = await axios.get<IDay[]>(generateUrl(this.appendQuery(url), params));
const data = res.data;
if (this.state !== startState) return;
this.processDays(data);
},
}
/** Process the data for days call including folders */
processDays(data) {
const list = [];
const heads = {};
processDays(data: IDay[]) {
const list: IRow[] = [];
const heads: {[dayId: number]: IRow} = {};
for (const day of data) {
day.count = Number(day.count);
@ -466,12 +468,12 @@ export default {
// Fix view height variable
this.reflowTimeline();
this.loading = false;
},
}
/** Fetch image data for one dayId */
async fetchDay(dayId) {
async fetchDay(dayId: number) {
let url = API_ROUTES.DAY;
const params = { dayId };
const params: any = { dayId };
if (this.$route.name === 'folders') {
url = API_ROUTES.FOLDER_DAY;
@ -483,7 +485,7 @@ export default {
try {
const startState = this.state;
const res = await axios.get(generateUrl(this.appendQuery(url), params));
const res = await axios.get<IPhoto[]>(generateUrl(this.appendQuery(url), params));
const data = res.data;
if (this.state !== startState) return;
@ -494,7 +496,7 @@ export default {
} catch (e) {
console.error(e);
}
},
}
/** Re-create timeline tick data in the next frame */
reflowTimeline() {
@ -502,11 +504,11 @@ export default {
return;
}
this.reflowTimelineTimer = setTimeout(() => {
this.reflowTimelineTimer = window.setTimeout(() => {
this.reflowTimelineTimer = null;
this.reflowTimelineNow();
}, 0);
},
}
/** Re-create timeline tick data */
reflowTimelineNow() {
@ -549,7 +551,8 @@ export default {
currTopRow += day.rows.size;
}
this.viewHeight = this.$refs.recycler.$refs.wrapper.clientHeight;
const recycler: any = this.$refs.recycler;
this.viewHeight = recycler.$refs.wrapper.clientHeight;
// Compute timeline tick positions
for (const tick of this.timelineTicks) {
@ -559,7 +562,8 @@ export default {
// Do another pass to figure out which timeline points are visible
// This is not as bad as it looks, it's actually 12*O(n)
// because there are only 12 months in a year
const minGap = parseFloat(getComputedStyle(this.$refs.cursorSt).fontSize) + (this.isMobile ? 5 : 2);
const fontSizePx = parseFloat(getComputedStyle(this.$refs.cursorSt as any).fontSize);
const minGap = fontSizePx + (this.isMobile ? 5 : 2);
let prevShow = -9999;
for (const [idx, tick] of this.timelineTicks.entries()) {
// You can't see these anyway, why bother?
@ -604,15 +608,15 @@ export default {
tick.s = true;
prevShow = tick.topC;
}
},
}
/**
* Process items from day response.
* Do not auto reflow if you plan to cal the reflow function later.
*
* @param {any} day Day object
* @param day Day object
*/
processDay(day) {
processDay(day: IDay) {
const dayId = day.dayid;
const data = day.detail;
@ -665,7 +669,7 @@ export default {
}
if (photo.isfavorite) {
photo.flag |= constants.FLAG_IS_FAVORITE;
delete photo.favorite;
delete photo.isfavorite;
}
this.list[rowIdx].photos.push(photo);
@ -697,10 +701,10 @@ export default {
if (addedRow || spliceCount > 0) {
this.reflowTimeline();
}
},
}
/** Get a new blank row */
getBlankRow(day) {
getBlankRow(day: IDay): IRow {
return {
id: ++this.numRows,
photos: [],
@ -708,9 +712,9 @@ export default {
dayId: day.dayid,
day: day,
};
},
}
timelineMoveHoverCursor(y) {
timelineMoveHoverCursor(y: number) {
this.timelineHoverCursorY = y;
// Get index of previous tick
@ -725,53 +729,55 @@ export default {
const date = utils.dayIdToDate(this.timelineTicks[idx].dayId);
this.timelineHoverCursorText = `${utils.getMonthName(date)} ${date.getUTCFullYear()}`;
},
}
/** Handle mouse hover on right timeline */
timelineHover(event) {
timelineHover(event: MouseEvent) {
if (event.buttons) {
this.timelineClick(event);
}
this.timelineMoveHoverCursor(event.offsetY);
},
}
/** Handle mouse leave on right timeline */
timelineLeave() {
this.timelineMoveHoverCursor(this.timelineCursorY);
},
}
/** Handle mouse click on right timeline */
timelineClick(event) {
this.$refs.recycler.scrollToPosition(this.getTimelinePosition(event.offsetY));
},
timelineClick(event: MouseEvent) {
const recycler: any = this.$refs.recycler;
recycler.scrollToPosition(this.getTimelinePosition(event.offsetY));
}
/** Handle touch on right timeline */
timelineTouch(event) {
timelineTouch(event: any) {
const rect = event.target.getBoundingClientRect();
const y = event.targetTouches[0].pageY - rect.top;
this.$refs.recycler.scrollToPosition(this.getTimelinePosition(y));
const recycler: any = this.$refs.recycler;
recycler.scrollToPosition(this.getTimelinePosition(y));
event.preventDefault();
event.stopPropagation();
},
}
/** Get recycler equivalent position from event */
getTimelinePosition(y) {
getTimelinePosition(y: number) {
const tH = this.viewHeight;
const maxH = this.timelineHeight;
return y * tH / maxH;
},
}
/** Clicking on photo */
clickPhoto(photoComponent) {
clickPhoto(photoComponent: any) {
if (this.selection.size > 0) { // selection mode
photoComponent.toggleSelect();
} else {
photoComponent.openFile();
}
},
}
/** Add a photo to selection list */
selectPhoto(photo) {
selectPhoto(photo: IPhoto) {
const nval = !this.selection.has(photo);
if (nval) {
photo.flag |= constants.FLAG_SELECTED;
@ -781,7 +787,7 @@ export default {
this.selection.delete(photo);
}
this.$forceUpdate();
},
}
/** Clear all selected photos */
clearSelection() {
@ -790,14 +796,14 @@ export default {
}
this.selection.clear();
this.$forceUpdate();
},
}
/**
* Download the currently selected files
*/
async downloadSelection() {
await dav.downloadFilesByIds([...this.selection].map(p => p.fileid));
},
}
/**
* Delete the currently selected photos
@ -810,7 +816,7 @@ export default {
const updatedDays = new Set(list.filter(f => delIds.has(f.fileid)).map(f => f.d));
await this.deleteFromViewWithAnimation(delIds, updatedDays);
},
}
/**
* Delete elements from main view with some animation
@ -870,7 +876,7 @@ export default {
}
// Enter from right all photos that exited left
exitedLeft.forEach((photo) => {
exitedLeft.forEach((photo: any) => {
photo.flag &= ~constants.FLAG_EXIT_LEFT;
photo.flag |= constants.FLAG_ENTER_RIGHT;
});
@ -882,14 +888,13 @@ export default {
await new Promise(resolve => setTimeout(resolve, 200));
// Clear enter right flags
exitedLeft.forEach((photo) => {
exitedLeft.forEach((photo: any) => {
photo.flag &= ~constants.FLAG_ENTER_RIGHT;
});
// Reflow timeline
this.reflowTimeline();
},
},
}
}
</script>

View File

@ -19,12 +19,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import 'reflect-metadata'
import Vue from 'vue'
import VueVirtualScroller from 'vue-virtual-scroller'
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css'
import { translate as t, translatePlural as n } from '@nextcloud/l10n'
import App from './App'
import App from './App.vue'
import router from './router'
// Adding translations to the whole app
@ -42,11 +43,11 @@ Vue.use(VueVirtualScroller)
// original scripts are loaded from
// https://github.com/nextcloud/server/blob/5bf3d1bb384da56adbf205752be8f840aac3b0c5/lib/private/legacy/template.php#L120-L122
window.addEventListener('DOMContentLoaded', () => {
if (!window.OCA.Files) {
window.OCA.Files = {}
if (!globalThis.OCA.Files) {
globalThis.OCA.Files = {}
}
// register unused client for the sidebar to have access to its parser methods
Object.assign(window.OCA.Files, { App: { fileList: { filesClient: OC.Files.getClient() } } }, window.OCA.Files)
Object.assign(globalThis.OCA.Files, { App: { fileList: { filesClient: globalThis.OC.Files.getClient() } } }, globalThis.OCA.Files)
})
export default new Vue({

View File

@ -21,10 +21,10 @@
*/
import { generateUrl } from '@nextcloud/router'
import { translate as t, translatePlural as n } from '@nextcloud/l10n'
import Router from 'vue-router'
import Vue from 'vue'
const Timeline = () => import('./components/Timeline')
import Timeline from './components/Timeline.vue';
Vue.use(Router)
@ -43,7 +43,7 @@
mode: 'history',
// if index.php is in the url AND we got this far, then it's working:
// let's keep using index.php in the url
base: generateUrl('/apps/memories', ''),
base: generateUrl('/apps/memories'),
linkActiveClass: 'active',
routes: [
{

View File

@ -27,8 +27,8 @@
// Monkey business
import * as rq from 'webdav/dist/node/request';
rq.prepareRequestOptionsOld = rq.prepareRequestOptions.bind(rq);
rq.prepareRequestOptions = (function(requestOptions, context, userOptions) {
(<any>rq).prepareRequestOptionsOld = rq.prepareRequestOptions.bind(rq);
(<any>rq).prepareRequestOptions = (function(requestOptions, context, userOptions) {
requestOptions.method = userOptions.method || requestOptions.method;
return this.prepareRequestOptionsOld(requestOptions, context, userOptions);
}).bind(rq);

View File

@ -2,6 +2,7 @@ import { getCurrentUser } from '@nextcloud/auth'
import { generateUrl } from '@nextcloud/router'
import { genFileInfo } from './FileUtils'
import client from './DavClient';
import { IFileInfo } from '../types';
const props = `
<oc:fileid />
@ -23,11 +24,11 @@ const IMAGE_MIME_TYPES = [
/**
* Get file infos for list of files given Ids
* @param {number[]} fileIds list of file ids
* @returns {Promise<any[]>} list of file infos
* @param fileIds list of file ids
* @returns list of file infos
*/
export async function getFiles(fileIds) {
const prefixPath = `/files/${getCurrentUser().uid}`;
export async function getFiles(fileIds: number[]): Promise<IFileInfo[]> {
const prefixPath = `/files/${getCurrentUser()!.uid}`;
// IMPORTANT: if this isn't there, then a blank
// returns EVERYTHING on the server!
@ -79,20 +80,19 @@ export async function getFiles(fileIds) {
responseType: 'text',
};
let response = await client.getDirectoryContents('', options);
let response: any = await client.getDirectoryContents('', options);
return response.data
.map(data => genFileInfo(data))
.map(data => Object.assign({}, data, { filename: data.filename.replace(prefixPath, '') }));
.map((data: any) => genFileInfo(data))
.map((data: any) => Object.assign({}, data, { filename: data.filename.replace(prefixPath, '') }));
}
/**
* Get file infos for files in folder path
* @param {string} folderPath Path to folder
* @param {number} limit Max number of files to return
* @returns {Promise<any[]>} list of file infos
* @param folderPath Path to folder
* @param limit Max number of files to return
*/
export async function getFolderPreviewFileIds(folderPath, limit) {
const prefixPath = `/files/${getCurrentUser().uid}`;
export async function getFolderPreviewFileIds(folderPath: string, limit: number): Promise<IFileInfo[]> {
const prefixPath = `/files/${getCurrentUser()!.uid}`;
const filter = IMAGE_MIME_TYPES.map(mime => `
<d:like>
@ -141,10 +141,10 @@ export async function getFolderPreviewFileIds(folderPath, limit) {
responseType: 'text',
};
let response = await client.getDirectoryContents('', options);
let response:any = await client.getDirectoryContents('', options);
return response.data
.map(data => genFileInfo(data))
.map(data => Object.assign({}, data, {
.map((data: any) => genFileInfo(data))
.map((data: any) => Object.assign({}, data, {
filename: data.filename.replace(prefixPath, ''),
etag: data.etag.replace(/&quot;/g, ''), // remove quotes
}));
@ -153,22 +153,21 @@ export async function getFolderPreviewFileIds(folderPath, limit) {
/**
* Delete a single file
*
* @param {string} path path to the file
* @returns {Promise<void>}
* @param path path to the file
*/
export async function deleteFile(path) {
const prefixPath = `/files/${getCurrentUser().uid}`;
export async function deleteFile(path: string) {
const prefixPath = `/files/${getCurrentUser()!.uid}`;
return await client.deleteFile(`${prefixPath}${path}`);
}
/**
* Delete all files in a given list of Ids
*
* @param {number[]} fileIds list of file ids
* @returns {Promise<Set<number>>} list of file ids that were deleted
* @param fileIds list of file ids
* @returns list of file ids that were deleted
*/
export async function deleteFilesByIds(fileIds) {
const delIds = new Set();
export async function deleteFilesByIds(fileIds: number[]) {
const delIds = new Set<number>();
const fileIdsSet = new Set(fileIds);
if (fileIds.length === 0) {
@ -176,7 +175,7 @@ export async function deleteFilesByIds(fileIds) {
}
// Get files data
let fileInfos = [];
let fileInfos: any[] = [];
try {
fileInfos = await getFiles(fileIds.filter(f => f));
} catch (e) {
@ -185,7 +184,7 @@ export async function deleteFilesByIds(fileIds) {
}
// Run all promises together
const promises = [];
const promises: Promise<void>[] = [];
// Delete each file
for (const fileInfo of fileInfos) {
@ -212,10 +211,9 @@ export async function deleteFilesByIds(fileIds) {
/**
* Download a file
*
* @param {string[]} fileNames - The file's names
* @returns {Promise<void>}
* @param fileNames - The file's names
*/
export async function downloadFiles(fileNames) {
export async function downloadFiles(fileNames: string[]): Promise<boolean> {
const randomToken = Math.random().toString(36).substring(2)
const params = new URLSearchParams()
@ -224,7 +222,7 @@ export async function deleteFilesByIds(fileIds) {
const downloadURL = generateUrl(`/apps/files/ajax/download.php?${params}`)
window.location = `${downloadURL}downloadStartSecret=${randomToken}`
window.location.href = `${downloadURL}downloadStartSecret=${randomToken}`
return new Promise((resolve) => {
const waitForCookieInterval = setInterval(
@ -246,10 +244,9 @@ export async function deleteFilesByIds(fileIds) {
/**
* Download the files given by the fileIds
* @param {number[]} fileIds
* @returns {Promise<void>}
* @param fileIds list of file ids
*/
export async function downloadFilesByIds(fileIds) {
export async function downloadFilesByIds(fileIds: number[]) {
if (fileIds.length === 0) {
return;
}

View File

@ -94,8 +94,8 @@
// finally sort by name
return asc
? fileInfo1[key]?.toString()?.localeCompare(fileInfo2[key].toString(), OC.getLanguage()) || 1
: -fileInfo1[key]?.toString()?.localeCompare(fileInfo2[key].toString(), OC.getLanguage()) || -1
? fileInfo1[key]?.toString()?.localeCompare(fileInfo2[key].toString(), globalThis.OC.getLanguage()) || 1
: -fileInfo1[key]?.toString()?.localeCompare(fileInfo2[key].toString(), globalThis.OC.getLanguage()) || -1
}
const genFileInfo = function(obj) {
@ -123,7 +123,7 @@
return fileInfo
}
const getPreviewUrl = function(fileid, etag) {
const getPreviewUrl = function(fileid: number, etag: string): string {
return generateUrl(`/core/preview?fileId=${fileid}&c=${etag}&x=250&y=250&forceIcon=0&a=0`);
}

View File

@ -20,7 +20,7 @@
*
*/
const isNumber = function(num) {
const isNumber = function(num: any) {
if (!num) {
return false
}

View File

@ -1,10 +1,10 @@
/** Get JS date object from dayId */
export function dayIdToDate(dayId){
return new Date(Number(dayId)*86400*1000);
export function dayIdToDate(dayId: number){
return new Date(dayId*86400*1000);
}
/** Get month name from number */
export function getMonthName(date) {
export function getMonthName(date: Date) {
const dateTimeFormat = new Intl.DateTimeFormat('en-US', {
month: 'short',
timeZone: 'UTC',

69
src/types.ts 100644
View File

@ -0,0 +1,69 @@
export type IFileInfo = {
fileid: number;
filename: string;
etag: string;
}
export type IDay = {
/** Day ID */
dayid: number;
/** Number of photos in this day */
count: number;
/** Set of rows in the day */
rows?: Set<IRow>;
/** List of photos for this day */
detail?: IPhoto[];
/** WebDAV fileInfos, fetched before viewer open */
fileInfos?: IFileInfo[];
/** Original fileIds from fileInfos */
origFileIds?: Set<number>;
}
export type IPhoto = {
/** Nextcloud ID of file */
fileid: number;
/** Etag from server */
etag?: string;
/** Bit flags */
flag: number;
/** Reference to day object */
d?: IDay;
/** Video flag from server */
isvideo?: boolean;
/** Favorite flag from server */
isfavorite?: boolean;
}
export type IRow = {
/** Vue Recycler identifier */
id?: number;
/** Day ID */
dayId: number;
/** Refrence to day object */
day: IDay;
/** Whether this is a head row */
head?: boolean;
/** [Head only] Title of the header */
name?: string;
/** Main list of photo items */
photos?: IPhoto[];
/** Height in px of the row */
size?: number;
/** Count of placeholders to create */
pct?: number;
}
export type ITick = {
/** Day ID */
dayId: number;
/** Top row at this */
top: number;
/** Static distance from top (for headers) */
topS: number;
/** Count row distance from top (dynamic) */
topC: number;
/** Text if any (e.g. year) */
text?: string | number;
/** Whether this tick should be shown */
s?: boolean;
}

10
src/vue-shims.d.ts vendored 100644
View File

@ -0,0 +1,10 @@
declare module "*.vue" {
import Vue from "vue"
export default Vue
}
declare module '*.svg' {
import Vue, {VueConstructor} from 'vue';
const content: VueConstructor<Vue>;
export default content;
}

13
tsconfig.json 100644
View File

@ -0,0 +1,13 @@
{
"compilerOptions": {
"lib": ["dom", "es2017"],
"target": "ESNext",
"module": "es2015",
"moduleResolution": "node",
"sourceMap": true,
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"jsx": "preserve"
}
}

View File

@ -1,3 +1,19 @@
const webpackConfig = require('@nextcloud/webpack-vue-config')
const path = require('path')
webpackConfig.module.rules.push({
test: /\.ts?$/,
loader: 'ts-loader',
exclude: /node_modules/,
options: {
appendTsSuffixTo: [/\.vue$/],
},
});
webpackConfig.resolve.extensions.push('.ts');
webpackConfig.resolve.alias = {
'vue$': 'vue/dist/vue.esm.js',
}
webpackConfig.entry.main = path.resolve(path.join('src', 'main'));
delete webpackConfig.optimization.splitChunks;
module.exports = webpackConfig