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", "name": "memories",
"version": "0.0.0", "version": "1.0.1",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "memories", "name": "memories",
"version": "0.0.0", "version": "1.0.1",
"license": "agpl", "license": "agpl",
"dependencies": { "dependencies": {
"@nextcloud/l10n": "^1.6.0", "@nextcloud/l10n": "^1.6.0",
"@nextcloud/vue": "^6.0.0-beta.6", "@nextcloud/vue": "^6.0.0-beta.6",
"path-posix": "^1.0.0", "path-posix": "^1.0.0",
"reflect-metadata": "^0.1.13",
"vue": "^2.7.10", "vue": "^2.7.10",
"vue-class-component": "^7.2.6",
"vue-property-decorator": "^9.1.2",
"vue-router": "^3.5.4", "vue-router": "^3.5.4",
"vue-virtual-scroller": "^1.0.10", "vue-virtual-scroller": "^1.0.10",
"webdav": "^4.11.0" "webdav": "^4.11.0"
@ -22,7 +25,10 @@
"@nextcloud/browserslist-config": "^2.3.0", "@nextcloud/browserslist-config": "^2.3.0",
"@nextcloud/eslint-config": "^8.1.2", "@nextcloud/eslint-config": "^8.1.2",
"@nextcloud/stylelint-config": "^2.2.0", "@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": { "engines": {
"node": ">=14.0.0", "node": ">=14.0.0",
@ -2583,6 +2589,12 @@
"@types/node": "*" "@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": { "node_modules/@types/ws": {
"version": "8.5.3", "version": "8.5.3",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.3.tgz", "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", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
"dev": true, "dev": true,
"peer": true,
"dependencies": { "dependencies": {
"fill-range": "^7.0.1" "fill-range": "^7.0.1"
}, },
@ -4706,7 +4717,6 @@
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.10.0.tgz", "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.10.0.tgz",
"integrity": "sha512-T0yTFjdpldGY8PmuXXR0PyQ1ufZpEGiHVrp7zHKB7jdR4qlmZHhONVM5AQOAWXuF/w3dnHbEQVrNptJgt7F+cQ==", "integrity": "sha512-T0yTFjdpldGY8PmuXXR0PyQ1ufZpEGiHVrp7zHKB7jdR4qlmZHhONVM5AQOAWXuF/w3dnHbEQVrNptJgt7F+cQ==",
"dev": true, "dev": true,
"peer": true,
"dependencies": { "dependencies": {
"graceful-fs": "^4.2.4", "graceful-fs": "^4.2.4",
"tapable": "^2.2.0" "tapable": "^2.2.0"
@ -5803,7 +5813,6 @@
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
"dev": true, "dev": true,
"peer": true,
"dependencies": { "dependencies": {
"to-regex-range": "^5.0.1" "to-regex-range": "^5.0.1"
}, },
@ -6283,8 +6292,7 @@
"version": "4.2.10", "version": "4.2.10",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz",
"integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==",
"dev": true, "dev": true
"peer": true
}, },
"node_modules/grapheme-splitter": { "node_modules/grapheme-splitter": {
"version": "1.0.4", "version": "1.0.4",
@ -7091,7 +7099,6 @@
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
"dev": true, "dev": true,
"peer": true,
"engines": { "engines": {
"node": ">=0.12.0" "node": ">=0.12.0"
} }
@ -7715,7 +7722,6 @@
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz",
"integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==",
"dev": true, "dev": true,
"peer": true,
"dependencies": { "dependencies": {
"braces": "^3.0.2", "braces": "^3.0.2",
"picomatch": "^2.3.1" "picomatch": "^2.3.1"
@ -8425,7 +8431,6 @@
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
"dev": true, "dev": true,
"peer": true,
"engines": { "engines": {
"node": ">=8.6" "node": ">=8.6"
}, },
@ -9110,6 +9115,11 @@
"node": ">=8" "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": { "node_modules/regenerate": {
"version": "1.4.2", "version": "1.4.2",
"resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz", "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", "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz",
"integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==",
"dev": true, "dev": true,
"peer": true,
"engines": { "engines": {
"node": ">=6" "node": ">=6"
} }
@ -10625,7 +10634,6 @@
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
"dev": true, "dev": true,
"peer": true,
"dependencies": { "dependencies": {
"is-number": "^7.0.0" "is-number": "^7.0.0"
}, },
@ -10663,6 +10671,110 @@
"node": ">=8" "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": { "node_modules/tsconfig-paths": {
"version": "3.14.1", "version": "3.14.1",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz",
@ -10741,6 +10853,19 @@
"node": ">= 0.6" "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": { "node_modules/unbox-primitive": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz",
@ -10973,6 +11098,14 @@
"csstype": "^3.1.0" "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": { "node_modules/vue-color": {
"version": "2.8.1", "version": "2.8.1",
"resolved": "https://registry.npmjs.org/vue-color/-/vue-color-2.8.1.tgz", "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", "resolved": "https://registry.npmjs.org/vue-observe-visibility/-/vue-observe-visibility-0.4.6.tgz",
"integrity": "sha512-xo0CEVdkjSjhJoDdLSvoZoQrw/H2BlzB5jrCBKGZNXN2zdZgMuZ9BKrxXDjNP2AxlcCoKc8OahI3F3r3JGLv2Q==" "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": { "node_modules/vue-resize": {
"version": "0.4.5", "version": "0.4.5",
"resolved": "https://registry.npmjs.org/vue-resize/-/vue-resize-0.4.5.tgz", "resolved": "https://registry.npmjs.org/vue-resize/-/vue-resize-0.4.5.tgz",
@ -13744,6 +13886,12 @@
"@types/node": "*" "@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": { "@types/ws": {
"version": "8.5.3", "version": "8.5.3",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.3.tgz", "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", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
"dev": true, "dev": true,
"peer": true,
"requires": { "requires": {
"fill-range": "^7.0.1" "fill-range": "^7.0.1"
} }
@ -15468,7 +15615,6 @@
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.10.0.tgz", "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.10.0.tgz",
"integrity": "sha512-T0yTFjdpldGY8PmuXXR0PyQ1ufZpEGiHVrp7zHKB7jdR4qlmZHhONVM5AQOAWXuF/w3dnHbEQVrNptJgt7F+cQ==", "integrity": "sha512-T0yTFjdpldGY8PmuXXR0PyQ1ufZpEGiHVrp7zHKB7jdR4qlmZHhONVM5AQOAWXuF/w3dnHbEQVrNptJgt7F+cQ==",
"dev": true, "dev": true,
"peer": true,
"requires": { "requires": {
"graceful-fs": "^4.2.4", "graceful-fs": "^4.2.4",
"tapable": "^2.2.0" "tapable": "^2.2.0"
@ -16299,7 +16445,6 @@
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
"dev": true, "dev": true,
"peer": true,
"requires": { "requires": {
"to-regex-range": "^5.0.1" "to-regex-range": "^5.0.1"
} }
@ -16666,8 +16811,7 @@
"version": "4.2.10", "version": "4.2.10",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz",
"integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==",
"dev": true, "dev": true
"peer": true
}, },
"grapheme-splitter": { "grapheme-splitter": {
"version": "1.0.4", "version": "1.0.4",
@ -17257,8 +17401,7 @@
"version": "7.0.0", "version": "7.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
"dev": true, "dev": true
"peer": true
}, },
"is-number-object": { "is-number-object": {
"version": "1.0.7", "version": "1.0.7",
@ -17739,7 +17882,6 @@
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz",
"integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==",
"dev": true, "dev": true,
"peer": true,
"requires": { "requires": {
"braces": "^3.0.2", "braces": "^3.0.2",
"picomatch": "^2.3.1" "picomatch": "^2.3.1"
@ -18293,8 +18435,7 @@
"version": "2.3.1", "version": "2.3.1",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
"dev": true, "dev": true
"peer": true
}, },
"pkg-dir": { "pkg-dir": {
"version": "4.2.0", "version": "4.2.0",
@ -18801,6 +18942,11 @@
"strip-indent": "^3.0.0" "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": { "regenerate": {
"version": "1.4.2", "version": "1.4.2",
"resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz", "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz",
@ -19883,8 +20029,7 @@
"version": "2.2.1", "version": "2.2.1",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz",
"integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==",
"dev": true, "dev": true
"peer": true
}, },
"terser": { "terser": {
"version": "5.14.2", "version": "5.14.2",
@ -19977,7 +20122,6 @@
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
"dev": true, "dev": true,
"peer": true,
"requires": { "requires": {
"is-number": "^7.0.0" "is-number": "^7.0.0"
} }
@ -20006,6 +20150,78 @@
"dev": true, "dev": true,
"peer": 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": { "tsconfig-paths": {
"version": "3.14.1", "version": "3.14.1",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz",
@ -20071,6 +20287,12 @@
"mime-types": "~2.1.24" "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": { "unbox-primitive": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz",
@ -20259,6 +20481,12 @@
"csstype": "^3.1.0" "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": { "vue-color": {
"version": "2.8.1", "version": "2.8.1",
"resolved": "https://registry.npmjs.org/vue-color/-/vue-color-2.8.1.tgz", "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", "resolved": "https://registry.npmjs.org/vue-observe-visibility/-/vue-observe-visibility-0.4.6.tgz",
"integrity": "sha512-xo0CEVdkjSjhJoDdLSvoZoQrw/H2BlzB5jrCBKGZNXN2zdZgMuZ9BKrxXDjNP2AxlcCoKc8OahI3F3r3JGLv2Q==" "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": { "vue-resize": {
"version": "0.4.5", "version": "0.4.5",
"resolved": "https://registry.npmjs.org/vue-resize/-/vue-resize-0.4.5.tgz", "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/l10n": "^1.6.0",
"@nextcloud/vue": "^6.0.0-beta.6", "@nextcloud/vue": "^6.0.0-beta.6",
"path-posix": "^1.0.0", "path-posix": "^1.0.0",
"reflect-metadata": "^0.1.13",
"vue": "^2.7.10", "vue": "^2.7.10",
"vue-class-component": "^7.2.6",
"vue-property-decorator": "^9.1.2",
"vue-router": "^3.5.4", "vue-router": "^3.5.4",
"vue-virtual-scroller": "^1.0.10", "vue-virtual-scroller": "^1.0.10",
"webdav": "^4.11.0" "webdav": "^4.11.0"
@ -52,6 +55,9 @@
"@nextcloud/browserslist-config": "^2.3.0", "@nextcloud/browserslist-config": "^2.3.0",
"@nextcloud/eslint-config": "^8.1.2", "@nextcloud/eslint-config": "^8.1.2",
"@nextcloud/stylelint-config": "^2.2.0", "@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> </style>
<script> <script lang="ts">
import { NcContent, NcAppContent, NcAppNavigation, NcAppNavigationItem, NcAppNavigationSettings} from '@nextcloud/vue' import { NcContent, NcAppContent, NcAppNavigation, NcAppNavigationItem, NcAppNavigationSettings} from '@nextcloud/vue'
import Timeline from './components/Timeline.vue' import Timeline from './components/Timeline.vue'

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -94,8 +94,8 @@
// finally sort by name // finally sort by name
return asc return asc
? 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(), OC.getLanguage()) || -1 : -fileInfo1[key]?.toString()?.localeCompare(fileInfo2[key].toString(), globalThis.OC.getLanguage()) || -1
} }
const genFileInfo = function(obj) { const genFileInfo = function(obj) {
@ -123,7 +123,7 @@
return fileInfo 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`); 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) { if (!num) {
return false return false
} }

View File

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