From 7ac91b4d5dece0b07a0d8d32a5fcf351643a618a Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Wed, 27 Jul 2022 11:32:10 +0200 Subject: [PATCH 01/34] feat(gui-v2): add `useApi` composable # What's changed? * useApi provides a loading, error and response ref * also provides event cb for error and response --- packages/nc-gui-v2/package-lock.json | 312 +-------------------------- 1 file changed, 4 insertions(+), 308 deletions(-) diff --git a/packages/nc-gui-v2/package-lock.json b/packages/nc-gui-v2/package-lock.json index 88dbdc82a9..175cbbbb88 100644 --- a/packages/nc-gui-v2/package-lock.json +++ b/packages/nc-gui-v2/package-lock.json @@ -9,32 +9,25 @@ "@vueuse/integrations": "^8.9.1", "ant-design-vue": "^3.1.0-rc.6", "dayjs": "^1.11.3", - "file-saver": "^2.0.5", "jwt-decode": "^3.1.2", "monaco-editor": "^0.33.0", "nocodb-sdk": "file:../nocodb-sdk", - "papaparse": "^5.3.2", "socket.io-client": "^4.5.1", "sortablejs": "^1.15.0", "unique-names-generator": "^4.7.1", "vue-i18n": "^9.1.10", "vue-toastification": "^2.0.0-rc.5", - "vuedraggable": "^4.1.0", - "vuetify": "^3.0.0-alpha.13", - "xlsx": "^0.17.3" + "vuetify": "^3.0.0-alpha.13" }, "devDependencies": { "@antfu/eslint-config": "^0.25.2", "@iconify-json/clarity": "^1.1.4", - "@iconify-json/eva": "^1.1.2", "@iconify-json/ic": "^1.1.7", - "@iconify-json/lucide": "^1.1.36", "@iconify-json/material-symbols": "^1.1.8", "@iconify-json/mdi": "^1.1.25", "@iconify-json/ri": "^1.1.3", "@intlify/vite-plugin-vue-i18n": "^4.0.0", "@types/axios": "^0.14.0", - "@types/papaparse": "^5.3.2", "@types/sortablejs": "^1.13.0", "@vitejs/plugin-vue": "^2.3.3", "@vitest/ui": "^0.18.0", @@ -978,15 +971,6 @@ "@iconify/types": "*" } }, - "node_modules/@iconify-json/eva": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@iconify-json/eva/-/eva-1.1.2.tgz", - "integrity": "sha512-4n3sAzXYH4vX2ehi2+kMPP7VHM1TTZ2AKJyUrAogAdbEKWhHr891huFhOSZPRJ9F2/4D4Us8SjRxBHYyUvX80w==", - "dev": true, - "dependencies": { - "@iconify/types": "*" - } - }, "node_modules/@iconify-json/ic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/@iconify-json/ic/-/ic-1.1.7.tgz", @@ -996,15 +980,6 @@ "@iconify/types": "*" } }, - "node_modules/@iconify-json/lucide": { - "version": "1.1.38", - "resolved": "https://registry.npmjs.org/@iconify-json/lucide/-/lucide-1.1.38.tgz", - "integrity": "sha512-0sDKnWign8yc3ndWczI4QliSMUi/AUngwlufprDJlR7feXILzpEfp5yyYlfPRE7gQrup6ey8dMX1vDaT8bet/g==", - "dev": true, - "dependencies": { - "@iconify/types": "*" - } - }, "node_modules/@iconify-json/material-symbols": { "version": "1.1.8", "resolved": "https://registry.npmjs.org/@iconify-json/material-symbols/-/material-symbols-1.1.8.tgz", @@ -2300,15 +2275,6 @@ "integrity": "sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==", "dev": true }, - "node_modules/@types/papaparse": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/@types/papaparse/-/papaparse-5.3.3.tgz", - "integrity": "sha512-i7fV8u843vb7nIGpcwdCsG3WjfBONeytRHK1mQL9d5KQAvFeAK2rRisDHicreYpoQ0MXocUDEqunKHTeXdvibg==", - "dev": true, - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/parse5": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/@types/parse5/-/parse5-6.0.3.tgz", @@ -3408,21 +3374,6 @@ "node": ">=0.4.0" } }, - "node_modules/adler-32": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/adler-32/-/adler-32-1.2.0.tgz", - "integrity": "sha512-/vUqU/UY4MVeFsg+SsK6c+/05RZXIHZMGJA+PX5JyWI0ZRcBpupnRuPLU/NXXoFwMYCPCoxIfElM2eS+DUXCqQ==", - "dependencies": { - "exit-on-epipe": "~1.0.1", - "printj": "~1.1.0" - }, - "bin": { - "adler32": "bin/adler32.njs" - }, - "engines": { - "node": ">=0.8" - } - }, "node_modules/agent-base": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", @@ -4096,26 +4047,6 @@ "integrity": "sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==", "dev": true }, - "node_modules/cfb": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/cfb/-/cfb-1.2.2.tgz", - "integrity": "sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==", - "dependencies": { - "adler-32": "~1.3.0", - "crc-32": "~1.2.0" - }, - "engines": { - "node": ">=0.8" - } - }, - "node_modules/cfb/node_modules/adler-32": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/adler-32/-/adler-32-1.3.1.tgz", - "integrity": "sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A==", - "engines": { - "node": ">=0.8" - } - }, "node_modules/chai": { "version": "4.3.6", "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.6.tgz", @@ -4524,14 +4455,6 @@ "node": ">=0.10.0" } }, - "node_modules/codepage": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/codepage/-/codepage-1.15.0.tgz", - "integrity": "sha512-3g6NUTPd/YtuuGrhMnOMRjFc+LJw/bnMp3+0r/Wcz3IXUuCosKRJvMphm5+Q+bvTVGcJJuRvVLuYba+WojaFaA==", - "engines": { - "node": ">=0.8" - } - }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -4752,6 +4675,7 @@ "version": "1.2.2", "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==", + "dev": true, "bin": { "crc32": "bin/crc32.njs" }, @@ -6884,14 +6808,6 @@ "url": "https://github.com/sindresorhus/execa?sponsor=1" } }, - "node_modules/exit-on-epipe": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/exit-on-epipe/-/exit-on-epipe-1.0.1.tgz", - "integrity": "sha512-h2z5mrROTxce56S+pnvAV890uu7ls7f1kEvVGJbw1OlFH3/mlJ5bkXu0KRyW94v37zzHPiUd55iLn3DA7TjWpw==", - "engines": { - "node": ">=0.8" - } - }, "node_modules/external-editor": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", @@ -7029,11 +6945,6 @@ "node": "^10.12.0 || >=12.0.0" } }, - "node_modules/file-saver": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/file-saver/-/file-saver-2.0.5.tgz", - "integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA==" - }, "node_modules/file-uri-to-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", @@ -7221,14 +7132,6 @@ "node": ">=12.20.0" } }, - "node_modules/frac": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/frac/-/frac-1.1.2.tgz", - "integrity": "sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA==", - "engines": { - "node": ">=0.8" - } - }, "node_modules/fraction.js": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.2.0.tgz", @@ -10334,11 +10237,6 @@ "node": ">=4" } }, - "node_modules/papaparse": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/papaparse/-/papaparse-5.3.2.tgz", - "integrity": "sha512-6dNZu0Ki+gyV0eBsFKJhYr+MdQYAzFUGlBMNj3GNrmHxmz1lfRa24CjFObPXtjcetlOv5Ad299MhIK0znp3afw==" - }, "node_modules/parse-cache-control": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parse-cache-control/-/parse-cache-control-1.0.1.tgz", @@ -11273,17 +11171,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/printj": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/printj/-/printj-1.1.2.tgz", - "integrity": "sha512-zA2SmoLaxZyArQTOPj5LXecR+RagfPSU5Kw1qP+jkWeNlrq+eJZyY2oS68SU1Z/7/myXM4lo9716laOFAVStCQ==", - "bin": { - "printj": "bin/printj.njs" - }, - "engines": { - "node": ">=0.8" - } - }, "node_modules/process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", @@ -12322,17 +12209,6 @@ "node": ">=6" } }, - "node_modules/ssf": { - "version": "0.11.2", - "resolved": "https://registry.npmjs.org/ssf/-/ssf-0.11.2.tgz", - "integrity": "sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g==", - "dependencies": { - "frac": "~1.1.2" - }, - "engines": { - "node": ">=0.8" - } - }, "node_modules/stable": { "version": "0.1.8", "resolved": "https://registry.npmjs.org/stable/-/stable-0.1.8.tgz", @@ -13868,22 +13744,6 @@ "vue": "^3.0.0" } }, - "node_modules/vuedraggable": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/vuedraggable/-/vuedraggable-4.1.0.tgz", - "integrity": "sha512-FU5HCWBmsf20GpP3eudURW3WdWTKIbEIQxh9/8GE806hydR9qZqRRxRE3RjqX7PkuLuMQG/A7n3cfj9rCEchww==", - "dependencies": { - "sortablejs": "1.14.0" - }, - "peerDependencies": { - "vue": "^3.0.1" - } - }, - "node_modules/vuedraggable/node_modules/sortablejs": { - "version": "1.14.0", - "resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.14.0.tgz", - "integrity": "sha512-pBXvQCs5/33fdN1/39pPL0NZF20LeRbLQ5jtnheIPN9JQAaufGjKdWduZn4U7wCtVuzKhmRkI0DFYHYRbB2H1w==" - }, "node_modules/vuetify": { "version": "3.0.0-beta.5", "resolved": "https://registry.npmjs.org/vuetify/-/vuetify-3.0.0-beta.5.tgz", @@ -14214,22 +14074,6 @@ "integrity": "sha512-sTitTPYnn23esFR3RlqYBWn4c45WGeLcsKzQiUpXJAyfcWkolvlYpV8FLo7JishK946oQwMFUCHXQ9AjGPKExw==", "dev": true }, - "node_modules/wmf": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wmf/-/wmf-1.0.2.tgz", - "integrity": "sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw==", - "engines": { - "node": ">=0.8" - } - }, - "node_modules/word": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/word/-/word-0.3.0.tgz", - "integrity": "sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA==", - "engines": { - "node": ">=0.8" - } - }, "node_modules/word-wrap": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", @@ -14284,26 +14128,6 @@ } } }, - "node_modules/xlsx": { - "version": "0.17.5", - "resolved": "https://registry.npmjs.org/xlsx/-/xlsx-0.17.5.tgz", - "integrity": "sha512-lXNU0TuYsvElzvtI6O7WIVb9Zar1XYw7Xb3VAx2wn8N/n0whBYrCnHMxtFyIiUU1Wjf09WzmLALDfBO5PqTb1g==", - "dependencies": { - "adler-32": "~1.2.0", - "cfb": "^1.1.4", - "codepage": "~1.15.0", - "crc-32": "~1.2.0", - "ssf": "~0.11.2", - "wmf": "~1.0.1", - "word": "~0.3.0" - }, - "bin": { - "xlsx": "bin/xlsx.njs" - }, - "engines": { - "node": ">=0.8" - } - }, "node_modules/xml-name-validator": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-4.0.0.tgz", @@ -15116,15 +14940,6 @@ "@iconify/types": "*" } }, - "@iconify-json/eva": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@iconify-json/eva/-/eva-1.1.2.tgz", - "integrity": "sha512-4n3sAzXYH4vX2ehi2+kMPP7VHM1TTZ2AKJyUrAogAdbEKWhHr891huFhOSZPRJ9F2/4D4Us8SjRxBHYyUvX80w==", - "dev": true, - "requires": { - "@iconify/types": "*" - } - }, "@iconify-json/ic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/@iconify-json/ic/-/ic-1.1.7.tgz", @@ -15134,15 +14949,6 @@ "@iconify/types": "*" } }, - "@iconify-json/lucide": { - "version": "1.1.38", - "resolved": "https://registry.npmjs.org/@iconify-json/lucide/-/lucide-1.1.38.tgz", - "integrity": "sha512-0sDKnWign8yc3ndWczI4QliSMUi/AUngwlufprDJlR7feXILzpEfp5yyYlfPRE7gQrup6ey8dMX1vDaT8bet/g==", - "dev": true, - "requires": { - "@iconify/types": "*" - } - }, "@iconify-json/material-symbols": { "version": "1.1.8", "resolved": "https://registry.npmjs.org/@iconify-json/material-symbols/-/material-symbols-1.1.8.tgz", @@ -16179,15 +15985,6 @@ "integrity": "sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==", "dev": true }, - "@types/papaparse": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/@types/papaparse/-/papaparse-5.3.3.tgz", - "integrity": "sha512-i7fV8u843vb7nIGpcwdCsG3WjfBONeytRHK1mQL9d5KQAvFeAK2rRisDHicreYpoQ0MXocUDEqunKHTeXdvibg==", - "dev": true, - "requires": { - "@types/node": "*" - } - }, "@types/parse5": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/@types/parse5/-/parse5-6.0.3.tgz", @@ -16979,15 +16776,6 @@ "optional": true, "peer": true }, - "adler-32": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/adler-32/-/adler-32-1.2.0.tgz", - "integrity": "sha512-/vUqU/UY4MVeFsg+SsK6c+/05RZXIHZMGJA+PX5JyWI0ZRcBpupnRuPLU/NXXoFwMYCPCoxIfElM2eS+DUXCqQ==", - "requires": { - "exit-on-epipe": "~1.0.1", - "printj": "~1.1.0" - } - }, "agent-base": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", @@ -17474,22 +17262,6 @@ "integrity": "sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==", "dev": true }, - "cfb": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/cfb/-/cfb-1.2.2.tgz", - "integrity": "sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==", - "requires": { - "adler-32": "~1.3.0", - "crc-32": "~1.2.0" - }, - "dependencies": { - "adler-32": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/adler-32/-/adler-32-1.3.1.tgz", - "integrity": "sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A==" - } - } - }, "chai": { "version": "4.3.6", "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.6.tgz", @@ -17781,11 +17553,6 @@ "integrity": "sha512-2Nii8p3RwAPiFwsnZvukotvow2rIHM+yQ6ZcBXGHdniadkYGZYiGmkHJIbZPIV9nfv7m/U1IPMVVcAhoWFeklw==", "dev": true }, - "codepage": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/codepage/-/codepage-1.15.0.tgz", - "integrity": "sha512-3g6NUTPd/YtuuGrhMnOMRjFc+LJw/bnMp3+0r/Wcz3IXUuCosKRJvMphm5+Q+bvTVGcJJuRvVLuYba+WojaFaA==" - }, "color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -17980,7 +17747,8 @@ "crc-32": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", - "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==" + "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==", + "dev": true }, "crc32-stream": { "version": "4.0.2", @@ -19476,11 +19244,6 @@ "strip-final-newline": "^2.0.0" } }, - "exit-on-epipe": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/exit-on-epipe/-/exit-on-epipe-1.0.1.tgz", - "integrity": "sha512-h2z5mrROTxce56S+pnvAV890uu7ls7f1kEvVGJbw1OlFH3/mlJ5bkXu0KRyW94v37zzHPiUd55iLn3DA7TjWpw==" - }, "external-editor": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", @@ -19589,11 +19352,6 @@ "flat-cache": "^3.0.4" } }, - "file-saver": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/file-saver/-/file-saver-2.0.5.tgz", - "integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA==" - }, "file-uri-to-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", @@ -19733,11 +19491,6 @@ "fetch-blob": "^3.1.2" } }, - "frac": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/frac/-/frac-1.1.2.tgz", - "integrity": "sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA==" - }, "fraction.js": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.2.0.tgz", @@ -22126,11 +21879,6 @@ "integrity": "sha512-U1etNYuMJoIz3ZXSrrySFjsXQTWOx2/jdi86L+2pRvph/qMKL6sbcCYdH23fqsbm8TH2Gn0OybpT4eSFlCVHww==", "dev": true }, - "papaparse": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/papaparse/-/papaparse-5.3.2.tgz", - "integrity": "sha512-6dNZu0Ki+gyV0eBsFKJhYr+MdQYAzFUGlBMNj3GNrmHxmz1lfRa24CjFObPXtjcetlOv5Ad299MhIK0znp3afw==" - }, "parse-cache-control": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parse-cache-control/-/parse-cache-control-1.0.1.tgz", @@ -22769,11 +22517,6 @@ "integrity": "sha512-6UqkYefdogmzqAZWzJ7laYeJnaXDy2/J+ZqiiMtS7t7OfpXWTlaeGMwX8U6EFvPV/YWWEKRkS8hKS4k60WHTOg==", "dev": true }, - "printj": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/printj/-/printj-1.1.2.tgz", - "integrity": "sha512-zA2SmoLaxZyArQTOPj5LXecR+RagfPSU5Kw1qP+jkWeNlrq+eJZyY2oS68SU1Z/7/myXM4lo9716laOFAVStCQ==" - }, "process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", @@ -23583,14 +23326,6 @@ "integrity": "sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==", "dev": true }, - "ssf": { - "version": "0.11.2", - "resolved": "https://registry.npmjs.org/ssf/-/ssf-0.11.2.tgz", - "integrity": "sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g==", - "requires": { - "frac": "~1.1.2" - } - }, "stable": { "version": "0.1.8", "resolved": "https://registry.npmjs.org/stable/-/stable-0.1.8.tgz", @@ -24683,21 +24418,6 @@ "is-plain-object": "3.0.1" } }, - "vuedraggable": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/vuedraggable/-/vuedraggable-4.1.0.tgz", - "integrity": "sha512-FU5HCWBmsf20GpP3eudURW3WdWTKIbEIQxh9/8GE806hydR9qZqRRxRE3RjqX7PkuLuMQG/A7n3cfj9rCEchww==", - "requires": { - "sortablejs": "1.14.0" - }, - "dependencies": { - "sortablejs": { - "version": "1.14.0", - "resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.14.0.tgz", - "integrity": "sha512-pBXvQCs5/33fdN1/39pPL0NZF20LeRbLQ5jtnheIPN9JQAaufGjKdWduZn4U7wCtVuzKhmRkI0DFYHYRbB2H1w==" - } - } - }, "vuetify": { "version": "3.0.0-beta.5", "resolved": "https://registry.npmjs.org/vuetify/-/vuetify-3.0.0-beta.5.tgz", @@ -24944,16 +24664,6 @@ } } }, - "wmf": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wmf/-/wmf-1.0.2.tgz", - "integrity": "sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw==" - }, - "word": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/word/-/word-0.3.0.tgz", - "integrity": "sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA==" - }, "word-wrap": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", @@ -24985,20 +24695,6 @@ "dev": true, "requires": {} }, - "xlsx": { - "version": "0.17.5", - "resolved": "https://registry.npmjs.org/xlsx/-/xlsx-0.17.5.tgz", - "integrity": "sha512-lXNU0TuYsvElzvtI6O7WIVb9Zar1XYw7Xb3VAx2wn8N/n0whBYrCnHMxtFyIiUU1Wjf09WzmLALDfBO5PqTb1g==", - "requires": { - "adler-32": "~1.2.0", - "cfb": "^1.1.4", - "codepage": "~1.15.0", - "crc-32": "~1.2.0", - "ssf": "~0.11.2", - "wmf": "~1.0.1", - "word": "~0.3.0" - } - }, "xml-name-validator": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-4.0.0.tgz", From 045cf53e3cf75d80c87fb973df7e819b69858302 Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Sun, 31 Jul 2022 17:25:55 +0200 Subject: [PATCH 02/34] chore(gui-v2,deps): remove vuedraggable --- packages/nc-gui-v2/package-lock.json | 242 ++++++++++++++++++++++++++- packages/nc-gui-v2/package.json | 1 - 2 files changed, 238 insertions(+), 5 deletions(-) diff --git a/packages/nc-gui-v2/package-lock.json b/packages/nc-gui-v2/package-lock.json index 175cbbbb88..614967704f 100644 --- a/packages/nc-gui-v2/package-lock.json +++ b/packages/nc-gui-v2/package-lock.json @@ -9,15 +9,18 @@ "@vueuse/integrations": "^8.9.1", "ant-design-vue": "^3.1.0-rc.6", "dayjs": "^1.11.3", + "file-saver": "^2.0.5", "jwt-decode": "^3.1.2", "monaco-editor": "^0.33.0", "nocodb-sdk": "file:../nocodb-sdk", + "papaparse": "^5.3.2", "socket.io-client": "^4.5.1", "sortablejs": "^1.15.0", "unique-names-generator": "^4.7.1", "vue-i18n": "^9.1.10", "vue-toastification": "^2.0.0-rc.5", - "vuetify": "^3.0.0-alpha.13" + "vuetify": "^3.0.0-alpha.13", + "xlsx": "^0.17.3" }, "devDependencies": { "@antfu/eslint-config": "^0.25.2", @@ -28,6 +31,7 @@ "@iconify-json/ri": "^1.1.3", "@intlify/vite-plugin-vue-i18n": "^4.0.0", "@types/axios": "^0.14.0", + "@types/papaparse": "^5.3.2", "@types/sortablejs": "^1.13.0", "@vitejs/plugin-vue": "^2.3.3", "@vitest/ui": "^0.18.0", @@ -2275,6 +2279,15 @@ "integrity": "sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==", "dev": true }, + "node_modules/@types/papaparse": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/@types/papaparse/-/papaparse-5.3.2.tgz", + "integrity": "sha512-BNbCHJkTE4RwmAFkCxEalET4mDvGr/1ld7ZtQ4i/laWI/iiVt+GL07stdvufle4KfywyvloqqpIiJscXNCrKxA==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/parse5": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/@types/parse5/-/parse5-6.0.3.tgz", @@ -3374,6 +3387,21 @@ "node": ">=0.4.0" } }, + "node_modules/adler-32": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/adler-32/-/adler-32-1.2.0.tgz", + "integrity": "sha512-/vUqU/UY4MVeFsg+SsK6c+/05RZXIHZMGJA+PX5JyWI0ZRcBpupnRuPLU/NXXoFwMYCPCoxIfElM2eS+DUXCqQ==", + "dependencies": { + "exit-on-epipe": "~1.0.1", + "printj": "~1.1.0" + }, + "bin": { + "adler32": "bin/adler32.njs" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/agent-base": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", @@ -4047,6 +4075,26 @@ "integrity": "sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==", "dev": true }, + "node_modules/cfb": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cfb/-/cfb-1.2.2.tgz", + "integrity": "sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==", + "dependencies": { + "adler-32": "~1.3.0", + "crc-32": "~1.2.0" + }, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/cfb/node_modules/adler-32": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/adler-32/-/adler-32-1.3.1.tgz", + "integrity": "sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A==", + "engines": { + "node": ">=0.8" + } + }, "node_modules/chai": { "version": "4.3.6", "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.6.tgz", @@ -4455,6 +4503,14 @@ "node": ">=0.10.0" } }, + "node_modules/codepage": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/codepage/-/codepage-1.15.0.tgz", + "integrity": "sha512-3g6NUTPd/YtuuGrhMnOMRjFc+LJw/bnMp3+0r/Wcz3IXUuCosKRJvMphm5+Q+bvTVGcJJuRvVLuYba+WojaFaA==", + "engines": { + "node": ">=0.8" + } + }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -4675,7 +4731,6 @@ "version": "1.2.2", "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==", - "dev": true, "bin": { "crc32": "bin/crc32.njs" }, @@ -6808,6 +6863,14 @@ "url": "https://github.com/sindresorhus/execa?sponsor=1" } }, + "node_modules/exit-on-epipe": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/exit-on-epipe/-/exit-on-epipe-1.0.1.tgz", + "integrity": "sha512-h2z5mrROTxce56S+pnvAV890uu7ls7f1kEvVGJbw1OlFH3/mlJ5bkXu0KRyW94v37zzHPiUd55iLn3DA7TjWpw==", + "engines": { + "node": ">=0.8" + } + }, "node_modules/external-editor": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", @@ -6945,6 +7008,11 @@ "node": "^10.12.0 || >=12.0.0" } }, + "node_modules/file-saver": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/file-saver/-/file-saver-2.0.5.tgz", + "integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA==" + }, "node_modules/file-uri-to-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", @@ -7132,6 +7200,14 @@ "node": ">=12.20.0" } }, + "node_modules/frac": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/frac/-/frac-1.1.2.tgz", + "integrity": "sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA==", + "engines": { + "node": ">=0.8" + } + }, "node_modules/fraction.js": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.2.0.tgz", @@ -10237,6 +10313,11 @@ "node": ">=4" } }, + "node_modules/papaparse": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/papaparse/-/papaparse-5.3.2.tgz", + "integrity": "sha512-6dNZu0Ki+gyV0eBsFKJhYr+MdQYAzFUGlBMNj3GNrmHxmz1lfRa24CjFObPXtjcetlOv5Ad299MhIK0znp3afw==" + }, "node_modules/parse-cache-control": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parse-cache-control/-/parse-cache-control-1.0.1.tgz", @@ -11171,6 +11252,17 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/printj": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/printj/-/printj-1.1.2.tgz", + "integrity": "sha512-zA2SmoLaxZyArQTOPj5LXecR+RagfPSU5Kw1qP+jkWeNlrq+eJZyY2oS68SU1Z/7/myXM4lo9716laOFAVStCQ==", + "bin": { + "printj": "bin/printj.njs" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", @@ -12209,6 +12301,17 @@ "node": ">=6" } }, + "node_modules/ssf": { + "version": "0.11.2", + "resolved": "https://registry.npmjs.org/ssf/-/ssf-0.11.2.tgz", + "integrity": "sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g==", + "dependencies": { + "frac": "~1.1.2" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/stable": { "version": "0.1.8", "resolved": "https://registry.npmjs.org/stable/-/stable-0.1.8.tgz", @@ -14074,6 +14177,22 @@ "integrity": "sha512-sTitTPYnn23esFR3RlqYBWn4c45WGeLcsKzQiUpXJAyfcWkolvlYpV8FLo7JishK946oQwMFUCHXQ9AjGPKExw==", "dev": true }, + "node_modules/wmf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wmf/-/wmf-1.0.2.tgz", + "integrity": "sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw==", + "engines": { + "node": ">=0.8" + } + }, + "node_modules/word": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/word/-/word-0.3.0.tgz", + "integrity": "sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA==", + "engines": { + "node": ">=0.8" + } + }, "node_modules/word-wrap": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", @@ -14128,6 +14247,26 @@ } } }, + "node_modules/xlsx": { + "version": "0.17.5", + "resolved": "https://registry.npmjs.org/xlsx/-/xlsx-0.17.5.tgz", + "integrity": "sha512-lXNU0TuYsvElzvtI6O7WIVb9Zar1XYw7Xb3VAx2wn8N/n0whBYrCnHMxtFyIiUU1Wjf09WzmLALDfBO5PqTb1g==", + "dependencies": { + "adler-32": "~1.2.0", + "cfb": "^1.1.4", + "codepage": "~1.15.0", + "crc-32": "~1.2.0", + "ssf": "~0.11.2", + "wmf": "~1.0.1", + "word": "~0.3.0" + }, + "bin": { + "xlsx": "bin/xlsx.njs" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/xml-name-validator": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-4.0.0.tgz", @@ -15985,6 +16124,15 @@ "integrity": "sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==", "dev": true }, + "@types/papaparse": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/@types/papaparse/-/papaparse-5.3.2.tgz", + "integrity": "sha512-BNbCHJkTE4RwmAFkCxEalET4mDvGr/1ld7ZtQ4i/laWI/iiVt+GL07stdvufle4KfywyvloqqpIiJscXNCrKxA==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, "@types/parse5": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/@types/parse5/-/parse5-6.0.3.tgz", @@ -16776,6 +16924,15 @@ "optional": true, "peer": true }, + "adler-32": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/adler-32/-/adler-32-1.2.0.tgz", + "integrity": "sha512-/vUqU/UY4MVeFsg+SsK6c+/05RZXIHZMGJA+PX5JyWI0ZRcBpupnRuPLU/NXXoFwMYCPCoxIfElM2eS+DUXCqQ==", + "requires": { + "exit-on-epipe": "~1.0.1", + "printj": "~1.1.0" + } + }, "agent-base": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", @@ -17262,6 +17419,22 @@ "integrity": "sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==", "dev": true }, + "cfb": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cfb/-/cfb-1.2.2.tgz", + "integrity": "sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==", + "requires": { + "adler-32": "~1.3.0", + "crc-32": "~1.2.0" + }, + "dependencies": { + "adler-32": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/adler-32/-/adler-32-1.3.1.tgz", + "integrity": "sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A==" + } + } + }, "chai": { "version": "4.3.6", "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.6.tgz", @@ -17553,6 +17726,11 @@ "integrity": "sha512-2Nii8p3RwAPiFwsnZvukotvow2rIHM+yQ6ZcBXGHdniadkYGZYiGmkHJIbZPIV9nfv7m/U1IPMVVcAhoWFeklw==", "dev": true }, + "codepage": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/codepage/-/codepage-1.15.0.tgz", + "integrity": "sha512-3g6NUTPd/YtuuGrhMnOMRjFc+LJw/bnMp3+0r/Wcz3IXUuCosKRJvMphm5+Q+bvTVGcJJuRvVLuYba+WojaFaA==" + }, "color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -17747,8 +17925,7 @@ "crc-32": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", - "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==", - "dev": true + "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==" }, "crc32-stream": { "version": "4.0.2", @@ -19244,6 +19421,11 @@ "strip-final-newline": "^2.0.0" } }, + "exit-on-epipe": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/exit-on-epipe/-/exit-on-epipe-1.0.1.tgz", + "integrity": "sha512-h2z5mrROTxce56S+pnvAV890uu7ls7f1kEvVGJbw1OlFH3/mlJ5bkXu0KRyW94v37zzHPiUd55iLn3DA7TjWpw==" + }, "external-editor": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", @@ -19352,6 +19534,11 @@ "flat-cache": "^3.0.4" } }, + "file-saver": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/file-saver/-/file-saver-2.0.5.tgz", + "integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA==" + }, "file-uri-to-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", @@ -19491,6 +19678,11 @@ "fetch-blob": "^3.1.2" } }, + "frac": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/frac/-/frac-1.1.2.tgz", + "integrity": "sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA==" + }, "fraction.js": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.2.0.tgz", @@ -21879,6 +22071,11 @@ "integrity": "sha512-U1etNYuMJoIz3ZXSrrySFjsXQTWOx2/jdi86L+2pRvph/qMKL6sbcCYdH23fqsbm8TH2Gn0OybpT4eSFlCVHww==", "dev": true }, + "papaparse": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/papaparse/-/papaparse-5.3.2.tgz", + "integrity": "sha512-6dNZu0Ki+gyV0eBsFKJhYr+MdQYAzFUGlBMNj3GNrmHxmz1lfRa24CjFObPXtjcetlOv5Ad299MhIK0znp3afw==" + }, "parse-cache-control": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parse-cache-control/-/parse-cache-control-1.0.1.tgz", @@ -22517,6 +22714,11 @@ "integrity": "sha512-6UqkYefdogmzqAZWzJ7laYeJnaXDy2/J+ZqiiMtS7t7OfpXWTlaeGMwX8U6EFvPV/YWWEKRkS8hKS4k60WHTOg==", "dev": true }, + "printj": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/printj/-/printj-1.1.2.tgz", + "integrity": "sha512-zA2SmoLaxZyArQTOPj5LXecR+RagfPSU5Kw1qP+jkWeNlrq+eJZyY2oS68SU1Z/7/myXM4lo9716laOFAVStCQ==" + }, "process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", @@ -23326,6 +23528,14 @@ "integrity": "sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==", "dev": true }, + "ssf": { + "version": "0.11.2", + "resolved": "https://registry.npmjs.org/ssf/-/ssf-0.11.2.tgz", + "integrity": "sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g==", + "requires": { + "frac": "~1.1.2" + } + }, "stable": { "version": "0.1.8", "resolved": "https://registry.npmjs.org/stable/-/stable-0.1.8.tgz", @@ -24664,6 +24874,16 @@ } } }, + "wmf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wmf/-/wmf-1.0.2.tgz", + "integrity": "sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw==" + }, + "word": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/word/-/word-0.3.0.tgz", + "integrity": "sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA==" + }, "word-wrap": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", @@ -24695,6 +24915,20 @@ "dev": true, "requires": {} }, + "xlsx": { + "version": "0.17.5", + "resolved": "https://registry.npmjs.org/xlsx/-/xlsx-0.17.5.tgz", + "integrity": "sha512-lXNU0TuYsvElzvtI6O7WIVb9Zar1XYw7Xb3VAx2wn8N/n0whBYrCnHMxtFyIiUU1Wjf09WzmLALDfBO5PqTb1g==", + "requires": { + "adler-32": "~1.2.0", + "cfb": "^1.1.4", + "codepage": "~1.15.0", + "crc-32": "~1.2.0", + "ssf": "~0.11.2", + "wmf": "~1.0.1", + "word": "~0.3.0" + } + }, "xml-name-validator": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-4.0.0.tgz", diff --git a/packages/nc-gui-v2/package.json b/packages/nc-gui-v2/package.json index c038b5bb59..24fb61d520 100644 --- a/packages/nc-gui-v2/package.json +++ b/packages/nc-gui-v2/package.json @@ -25,7 +25,6 @@ "unique-names-generator": "^4.7.1", "vue-i18n": "^9.1.10", "vue-toastification": "^2.0.0-rc.5", - "vuedraggable": "^4.1.0", "vuetify": "^3.0.0-alpha.13", "xlsx": "^0.17.3" }, From 6ab8bb86e5ed74793327ff3911562f9f6ac8bd00 Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Fri, 29 Jul 2022 11:24:24 +0200 Subject: [PATCH 03/34] feat(gui-v2): add barrel file to composables dir --- packages/nc-gui-v2/composables/index.ts | 18 ++++++++++++++++++ .../nc-gui-v2/composables/useAttachment.ts | 4 ++-- packages/nc-gui-v2/composables/useBelongsTo.ts | 9 ++++----- packages/nc-gui-v2/composables/useColors.ts | 4 ++-- packages/nc-gui-v2/composables/useColumn.ts | 2 +- packages/nc-gui-v2/composables/useHasMany.ts | 7 +++---- .../nc-gui-v2/composables/useManyToMany.ts | 9 ++++----- packages/nc-gui-v2/composables/useMetas.ts | 4 ++-- packages/nc-gui-v2/composables/useProject.ts | 4 ++-- .../nc-gui-v2/composables/useTableCreate.ts | 4 ++-- .../nc-gui-v2/composables/useViewColumns.ts | 2 +- packages/nc-gui-v2/composables/useViewData.ts | 6 +++--- .../nc-gui-v2/composables/useViewFilters.ts | 2 +- packages/nc-gui-v2/composables/useViewSorts.ts | 2 +- packages/nc-gui-v2/composables/useViews.ts | 8 ++------ .../nc-gui-v2/composables/useVirtualCell.ts | 4 ++-- 16 files changed, 50 insertions(+), 39 deletions(-) create mode 100644 packages/nc-gui-v2/composables/index.ts diff --git a/packages/nc-gui-v2/composables/index.ts b/packages/nc-gui-v2/composables/index.ts new file mode 100644 index 0000000000..b359f3b2fa --- /dev/null +++ b/packages/nc-gui-v2/composables/index.ts @@ -0,0 +1,18 @@ +export * from './useApi' +export * from './useGlobal' +export * from './useUIPermission' +export * from './useAttachment' +export * from './useBelongsTo' +export * from './useColors' +export * from './useColumn' +export * from './useManyToMany' +export * from './useMetas' +export * from './useProject' +export * from './useTableCreate' +export * from './useTabs' +export * from './useViewColumns' +export * from './useViewData' +export * from './useViewFilters' +export * from './useViews' +export * from './useViewSorts' +export * from './useVirtualCell' diff --git a/packages/nc-gui-v2/composables/useAttachment.ts b/packages/nc-gui-v2/composables/useAttachment.ts index 24b604d425..3aee3b2798 100644 --- a/packages/nc-gui-v2/composables/useAttachment.ts +++ b/packages/nc-gui-v2/composables/useAttachment.ts @@ -1,5 +1,5 @@ -// todo: -export default () => { +// todo: implement useAttachment +export function useAttachment() { const localFilesState = reactive([]) const attachments = ref([]) diff --git a/packages/nc-gui-v2/composables/useBelongsTo.ts b/packages/nc-gui-v2/composables/useBelongsTo.ts index 40e7d7ed1b..86adf7f731 100644 --- a/packages/nc-gui-v2/composables/useBelongsTo.ts +++ b/packages/nc-gui-v2/composables/useBelongsTo.ts @@ -1,15 +1,14 @@ import type { ColumnType, TableType } from 'nocodb-sdk' -import type LinkToAnotherRecordColumn from '../../nocodb/src/lib/models/LinkToAnotherRecordColumn' -import useMetas from '~/composables/useMetas' +import useMetas from './useMetas' -export default function (column: ColumnType) { +export function useBelongsTo(column: ColumnType) { const { metas, getMeta } = useMetas() const parentMeta = computed(() => { - return metas.value?.[(column.colOptions as LinkToAnotherRecordColumn)?.fk_related_model_id as string] + return metas.value?.[(column.colOptions as any)?.fk_related_model_id as string] }) const loadParentMeta = async () => { - await getMeta((column.colOptions as LinkToAnotherRecordColumn)?.fk_related_model_id as string) + await getMeta((column.colOptions as any)?.fk_related_model_id as string) } const primaryValueProp = computed(() => { diff --git a/packages/nc-gui-v2/composables/useColors.ts b/packages/nc-gui-v2/composables/useColors.ts index 7448ad7c1c..d2fd78b9ed 100644 --- a/packages/nc-gui-v2/composables/useColors.ts +++ b/packages/nc-gui-v2/composables/useColors.ts @@ -1,9 +1,9 @@ import type { MaybeRef } from '@vueuse/core' import { computed, effectScope, tryOnScopeDispose, unref, watch, watchEffect } from '#build/imports' import { useNuxtApp } from '#app' -import theme from '~/utils/colorsUtils' +import { theme } from '~/utils' -export default function useColors(darkMode?: MaybeRef) { +export function useColors(darkMode?: MaybeRef) { const scope = effectScope() let mode = $ref(unref(darkMode)) diff --git a/packages/nc-gui-v2/composables/useColumn.ts b/packages/nc-gui-v2/composables/useColumn.ts index 9eb65f1195..e46397fd87 100644 --- a/packages/nc-gui-v2/composables/useColumn.ts +++ b/packages/nc-gui-v2/composables/useColumn.ts @@ -2,7 +2,7 @@ import type { ColumnType } from 'nocodb-sdk' import { SqlUiFactory, UITypes, isVirtualCol } from 'nocodb-sdk' import { useProject } from '#imports' -export default (column: ColumnType) => { +export function useColumn(column: ColumnType) { const { project } = useProject() const uiDatatype: UITypes = (column && column.uidt) as UITypes diff --git a/packages/nc-gui-v2/composables/useHasMany.ts b/packages/nc-gui-v2/composables/useHasMany.ts index 2a2fafa9c5..dda56d1f55 100644 --- a/packages/nc-gui-v2/composables/useHasMany.ts +++ b/packages/nc-gui-v2/composables/useHasMany.ts @@ -1,15 +1,14 @@ import type { ColumnType, TableType } from 'nocodb-sdk' -import type LinkToAnotherRecordColumn from '../../nocodb/src/lib/models/LinkToAnotherRecordColumn' -import useMetas from '~/composables/useMetas' +import { useMetas } from './useMetas' export default function (column: ColumnType) { const { metas, getMeta } = useMetas() const childMeta = computed(() => { - return metas.value?.[(column.colOptions as LinkToAnotherRecordColumn)?.fk_related_model_id as string] + return metas.value?.[(column.colOptions as any)?.fk_related_model_id as string] }) const loadChildMeta = async () => { - await getMeta((column.colOptions as LinkToAnotherRecordColumn)?.fk_related_model_id as string) + await getMeta((column.colOptions as any)?.fk_related_model_id as string) } const primaryValueProp = computed(() => { diff --git a/packages/nc-gui-v2/composables/useManyToMany.ts b/packages/nc-gui-v2/composables/useManyToMany.ts index 2a2fafa9c5..3d9f1b5020 100644 --- a/packages/nc-gui-v2/composables/useManyToMany.ts +++ b/packages/nc-gui-v2/composables/useManyToMany.ts @@ -1,15 +1,14 @@ import type { ColumnType, TableType } from 'nocodb-sdk' -import type LinkToAnotherRecordColumn from '../../nocodb/src/lib/models/LinkToAnotherRecordColumn' -import useMetas from '~/composables/useMetas' +import useMetas from './useMetas' -export default function (column: ColumnType) { +export function useManyToMany(column: ColumnType) { const { metas, getMeta } = useMetas() const childMeta = computed(() => { - return metas.value?.[(column.colOptions as LinkToAnotherRecordColumn)?.fk_related_model_id as string] + return metas.value?.[(column.colOptions as any)?.fk_related_model_id as string] }) const loadChildMeta = async () => { - await getMeta((column.colOptions as LinkToAnotherRecordColumn)?.fk_related_model_id as string) + await getMeta((column.colOptions as any)?.fk_related_model_id as string) } const primaryValueProp = computed(() => { diff --git a/packages/nc-gui-v2/composables/useMetas.ts b/packages/nc-gui-v2/composables/useMetas.ts index 40232b1c49..b5f0a4548d 100644 --- a/packages/nc-gui-v2/composables/useMetas.ts +++ b/packages/nc-gui-v2/composables/useMetas.ts @@ -1,8 +1,8 @@ import type { TableInfoType, TableType } from 'nocodb-sdk' +import { useProject } from './useProject' import { useNuxtApp, useState } from '#app' -import { useProject } from '#imports' -export default () => { +export function useMetas() { const { $api } = useNuxtApp() const { tables } = useProject() diff --git a/packages/nc-gui-v2/composables/useProject.ts b/packages/nc-gui-v2/composables/useProject.ts index cad569363f..7d4fc760db 100644 --- a/packages/nc-gui-v2/composables/useProject.ts +++ b/packages/nc-gui-v2/composables/useProject.ts @@ -2,9 +2,9 @@ import { SqlUiFactory } from 'nocodb-sdk' import type { OracleUi, ProjectType, TableType } from 'nocodb-sdk' import type { MaybeRef } from '@vueuse/core' import { useNuxtApp, useState } from '#app' -import { USER_PROJECT_ROLES } from '~/lib/constants' +import { USER_PROJECT_ROLES } from '~/lib' -export default (projectId?: MaybeRef) => { +export function useProject(projectId?: MaybeRef) { const projectRoles = useState>(USER_PROJECT_ROLES, () => ({})) const { $api } = useNuxtApp() diff --git a/packages/nc-gui-v2/composables/useTableCreate.ts b/packages/nc-gui-v2/composables/useTableCreate.ts index f6f39dd493..581ea88463 100644 --- a/packages/nc-gui-v2/composables/useTableCreate.ts +++ b/packages/nc-gui-v2/composables/useTableCreate.ts @@ -1,9 +1,9 @@ import type { TableType } from 'nocodb-sdk' import { UITypes } from 'nocodb-sdk' +import { useProject } from './useProject' import { useNuxtApp } from '#app' -import { useProject } from '#imports' -export default (onTableCreate?: (tableMeta: TableType) => void) => { +export function useTableCreate(onTableCreate?: (tableMeta: TableType) => void) { const table = reactive<{ title: string; table_name: string; columns: string[] }>({ title: '', table_name: '', diff --git a/packages/nc-gui-v2/composables/useViewColumns.ts b/packages/nc-gui-v2/composables/useViewColumns.ts index b1057c5f56..2694cfc49f 100644 --- a/packages/nc-gui-v2/composables/useViewColumns.ts +++ b/packages/nc-gui-v2/composables/useViewColumns.ts @@ -4,7 +4,7 @@ import { watch } from 'vue' import type { ComputedRef, Ref } from 'vue' import { useNuxtApp } from '#app' -export default function ( +export function useViewColumns( view: Ref<(GridType | FormType | GalleryType) & { id?: string }> | undefined, meta: ComputedRef, isPublic = false, diff --git a/packages/nc-gui-v2/composables/useViewData.ts b/packages/nc-gui-v2/composables/useViewData.ts index afa02b242c..8446f8d6d8 100644 --- a/packages/nc-gui-v2/composables/useViewData.ts +++ b/packages/nc-gui-v2/composables/useViewData.ts @@ -2,7 +2,7 @@ import type { Api, FormType, GalleryType, GridType, PaginatedType, TableType } f import type { ComputedRef, Ref } from 'vue' import { useNuxtApp } from '#app' import { useProject } from '#imports' -import { NOCO } from '~/lib/constants' +import { NOCO } from '~/lib' const formatData = (list: Record[]) => list.map((row) => ({ @@ -11,13 +11,13 @@ const formatData = (list: Record[]) => rowMeta: {}, })) -export default ( +export function useViewData( meta: Ref | ComputedRef | undefined, viewMeta: | Ref<(GridType | GalleryType | FormType) & { id: string }> | ComputedRef<(GridType | GalleryType | FormType) & { id: string }> | undefined, -) => { +) { const data = ref[]>() const formattedData = ref<{ row: Record; oldRow: Record; rowMeta?: any }[]>() const paginationData = ref({ page: 1, pageSize: 25 }) diff --git a/packages/nc-gui-v2/composables/useViewFilters.ts b/packages/nc-gui-v2/composables/useViewFilters.ts index c794de80ed..64a82d24bc 100644 --- a/packages/nc-gui-v2/composables/useViewFilters.ts +++ b/packages/nc-gui-v2/composables/useViewFilters.ts @@ -2,7 +2,7 @@ import type { FilterType, GalleryType, GridType, KanbanType } from 'nocodb-sdk' import type { Ref } from 'vue' import { useNuxtApp } from '#imports' -export default function ( +export function useViewFilters( view: Ref<(GridType | KanbanType | GalleryType) & { id?: string }> | undefined, parentId?: string, reloadData?: () => void, diff --git a/packages/nc-gui-v2/composables/useViewSorts.ts b/packages/nc-gui-v2/composables/useViewSorts.ts index c0fe98f326..7d1bcf00f7 100644 --- a/packages/nc-gui-v2/composables/useViewSorts.ts +++ b/packages/nc-gui-v2/composables/useViewSorts.ts @@ -2,7 +2,7 @@ import type { GalleryType, GridType, KanbanType, SortType } from 'nocodb-sdk' import type { Ref } from 'vue' import { useNuxtApp } from '#imports' -export default function ( +export function useViewSorts( view: Ref<(GridType | KanbanType | GalleryType) & { id?: string }> | undefined, reloadData?: () => void, ) { diff --git a/packages/nc-gui-v2/composables/useViews.ts b/packages/nc-gui-v2/composables/useViews.ts index a042709e92..b7c9277609 100644 --- a/packages/nc-gui-v2/composables/useViews.ts +++ b/packages/nc-gui-v2/composables/useViews.ts @@ -1,9 +1,8 @@ import type { FormType, GalleryType, GridType, KanbanType, TableType } from 'nocodb-sdk' import type { MaybeRef } from '@vueuse/core' -import type { WatchOptions } from '@vue/runtime-core' import { useNuxtApp } from '#app' -export default function (meta: MaybeRef, watchOptions: WatchOptions = {}) { +export function useViews(meta: MaybeRef) { let views = $ref<(GridType | FormType | KanbanType | GalleryType)[]>([]) const { $api } = useNuxtApp() @@ -18,10 +17,7 @@ export default function (meta: MaybeRef, watchOptions: Wa } } - watch(() => meta, loadViews, { - immediate: true, - ...watchOptions, - }) + watch(() => meta, loadViews, { immediate: true }) return { views: $$(views), loadViews } } diff --git a/packages/nc-gui-v2/composables/useVirtualCell.ts b/packages/nc-gui-v2/composables/useVirtualCell.ts index e4cf181153..06bb61d318 100644 --- a/packages/nc-gui-v2/composables/useVirtualCell.ts +++ b/packages/nc-gui-v2/composables/useVirtualCell.ts @@ -1,8 +1,8 @@ -import { computed } from '@vue/reactivity' import type { ColumnType, LinkToAnotherRecordType } from 'nocodb-sdk' import { RelationTypes, UITypes } from 'nocodb-sdk' +import { computed } from '#imports' -export default function useVirtualCell(column: ColumnType) { +export function useVirtualCell(column: ColumnType) { const isHm = computed( () => column.uidt === UITypes.LinkToAnotherRecord && (column.colOptions).type === RelationTypes.HAS_MANY, From ec3b7af0cea0c4379e1493a1d769d72e0bc751e4 Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Fri, 29 Jul 2022 11:25:45 +0200 Subject: [PATCH 04/34] refactor(gui-v2): replace `useGlobalState` with `useGlobal` # What's changed? * `useGlobal` replaces `useGlobalState` * split into actions, getters, state * injects into nuxt app on init (regardless where it's called) --- .../composables/useGlobal/actions.ts | 54 ++++++ .../composables/useGlobal/getters.ts | 20 +++ .../nc-gui-v2/composables/useGlobal/index.ts | 53 ++++++ .../nc-gui-v2/composables/useGlobal/state.ts | 86 +++++++++ .../composables/useGlobalState/index.ts | 169 ------------------ .../composables/useUIPermission/index.ts | 2 +- packages/nc-gui-v2/plugins/state.ts | 19 +- packages/nc-gui-v2/utils/colorsUtils.ts | 2 +- 8 files changed, 228 insertions(+), 177 deletions(-) create mode 100644 packages/nc-gui-v2/composables/useGlobal/actions.ts create mode 100644 packages/nc-gui-v2/composables/useGlobal/getters.ts create mode 100644 packages/nc-gui-v2/composables/useGlobal/index.ts create mode 100644 packages/nc-gui-v2/composables/useGlobal/state.ts diff --git a/packages/nc-gui-v2/composables/useGlobal/actions.ts b/packages/nc-gui-v2/composables/useGlobal/actions.ts new file mode 100644 index 0000000000..fbbc0ac019 --- /dev/null +++ b/packages/nc-gui-v2/composables/useGlobal/actions.ts @@ -0,0 +1,54 @@ +import { notification } from 'ant-design-vue' +import type { UseGlobalStateReturn } from './state' +import type { Actions } from '~/lib' +import { useNuxtApp } from '#imports' + +export function useGlobalActions(state: UseGlobalStateReturn) { + const { $api } = useNuxtApp() + + /** Actions */ + /** Sign out by deleting the token from localStorage */ + const signOut: Actions['signOut'] = () => { + state.token.value = null + state.user.value = null + } + + /** Sign in by setting the token in localStorage */ + const signIn: Actions['signIn'] = async (newToken) => { + state.token.value = newToken + + if (state.payload.value) { + state.user.value = { + id: state.payload.value.id, + email: state.payload.value.email, + firstname: state.payload.value.firstname, + lastname: state.payload.value.lastname, + roles: state.payload.value.roles, + } + } + } + + /** manually try to refresh token */ + const refreshToken = async () => { + $api.instance + .post('/auth/refresh-token', null, { + withCredentials: true, + }) + .then((response) => { + if (response.data?.token) { + signIn(response.data.token) + } + }) + .catch((err) => { + notification.error({ + // todo: add translation + message: err.message || 'You have been signed out.', + }) + console.error(err) + + signOut() + }) + } + + return { signIn, signOut, refreshToken } +} diff --git a/packages/nc-gui-v2/composables/useGlobal/getters.ts b/packages/nc-gui-v2/composables/useGlobal/getters.ts new file mode 100644 index 0000000000..057c9b831a --- /dev/null +++ b/packages/nc-gui-v2/composables/useGlobal/getters.ts @@ -0,0 +1,20 @@ +import type { UseGlobalStateReturn } from './state' +import type { Getters } from '~/lib' +import { computed } from '#imports' + +export function useGlobalGetters(state: UseGlobalStateReturn) { + /** Getters */ + /** Verify that a user is signed in by checking if token exists and is not expired */ + const signedIn: Getters['signedIn'] = computed( + () => + !!( + !!state.token && + state.token.value !== '' && + state.payload.value && + state.payload.value.exp && + state.payload.value.exp > state.timestamp.value / 1000 + ), + ) + + return { signedIn } +} diff --git a/packages/nc-gui-v2/composables/useGlobal/index.ts b/packages/nc-gui-v2/composables/useGlobal/index.ts new file mode 100644 index 0000000000..6e0e0b7191 --- /dev/null +++ b/packages/nc-gui-v2/composables/useGlobal/index.ts @@ -0,0 +1,53 @@ +import { useGlobalState } from './state' +import { useGlobalActions } from './actions' +import { toRefs, useNuxtApp, watch } from '#imports' +import type { GlobalState } from '~/lib' +import { useGlobalGetters } from '~/composables/useGlobal/getters' + +/** + * Global state is injected by {@link import('~/plugins/state') state} plugin into our nuxt app (available as `$state`). + * Manual initialization is unnecessary and should be avoided. + * + * The state is stored in {@link WindowLocalStorage localStorage}, so it will be available even if the user closes the browser tab. + * + * @example + * ```js + * import { useNuxtApp } from '#app' + * + * const { $state } = useNuxtApp() + * + * const token = $state.token.value + * const user = $state.user.value + * ``` + */ +export const useGlobal = (): GlobalState => { + const { $state, provide } = useNuxtApp() + + if ($state) { + console.warn( + '[useGlobalState] Global state is injected by state plugin. Manual initialization is unnecessary and should be avoided.', + ) + return $state + } + + const state = $(useGlobalState()) + + const getters = useGlobalGetters($$(state)) + + const actions = useGlobalActions($$(state)) + + /** try to refresh token before expiry (5 min before expiry) */ + watch( + () => !!(state.payload && state.payload.exp && state.payload.exp - 5 * 60 < state.timestamp / 1000), + async (expiring) => { + if (getters.signedIn.value && state.payload && expiring) { + await actions.refreshToken() + } + }, + { immediate: true }, + ) + + provide('state', state) + + return { ...toRefs(state), ...getters, ...actions } +} diff --git a/packages/nc-gui-v2/composables/useGlobal/state.ts b/packages/nc-gui-v2/composables/useGlobal/state.ts new file mode 100644 index 0000000000..b546afb5f5 --- /dev/null +++ b/packages/nc-gui-v2/composables/useGlobal/state.ts @@ -0,0 +1,86 @@ +import { usePreferredLanguages, useStorage } from '@vueuse/core' +import { useJwt } from '@vueuse/integrations/useJwt' +import type { JwtPayload } from 'jwt-decode' +import type { ComputedRef, Ref, ToRefs } from 'vue' +import type { WritableComputedRef } from '@vue/reactivity' +import { computed, ref, toRefs, useNuxtApp, useTimestamp } from '#imports' +import type { StoredState, User } from '~/lib' + +const storageKey = 'nocodb-gui-v2' + +export type UseGlobalStateReturn = ToRefs & { + token: WritableComputedRef + payload: ComputedRef<(JwtPayload & User) | null> + sidebarOpen: Ref + timestamp: Ref +} + +export function useGlobalState(): UseGlobalStateReturn { + /** get the preferred languages of a user, according to browser settings */ + const preferredLanguages = $(usePreferredLanguages()) + /** todo: reimplement; get the preferred dark mode setting, according to browser settings */ + // const prefersDarkMode = $(usePreferredDark()) + const prefersDarkMode = false + + const { + vueApp: { i18n }, + } = useNuxtApp() + + /** + * Set initial language based on browser settings. + * If the user has not set a preferred language, we fallback to 'en'. + * If the user has set a preferred language, we try to find a matching locale in the available locales. + */ + const preferredLanguage = preferredLanguages.reduce((locale, language) => { + /** split language to language and code, e.g. en-GB -> [en, GB] */ + const [lang, code] = language.split(/[_-]/) + + /** find all locales that match the language */ + let availableLocales = i18n.availableLocales.filter((locale) => locale.startsWith(lang)) + + /** If we can match more than one locale, we check if the code of the language matches as well */ + if (availableLocales.length > 1) { + availableLocales = availableLocales.filter((locale) => locale.endsWith(code)) + } + + /** if there are still multiple locales, pick the first one */ + const availableLocale = availableLocales[0] + + /** if we found a matching locale, return it */ + if (availableLocale) locale = availableLocale + + return locale + }, 'en' /** fallback locale */) + + /** State */ + const initialState: StoredState = { token: null, user: null, lang: preferredLanguage, darkMode: prefersDarkMode } + + /** saves a reactive state, any change to these values will write/delete to localStorage */ + const storage = useStorage(storageKey, initialState) + + /** force turn off of dark mode, regardless of previously stored settings */ + storage.value.darkMode = false + + /** current token ref, used by `useJwt` to reactively parse our token payload */ + const token = computed({ + get: () => storage.value.token || '', + set: (val) => (storage.value.token = val), + }) + + /** reactive token payload */ + const { payload } = useJwt(token.value) + + /** is sidebar open */ + const sidebarOpen = ref(false) + + /** reactive timestamp to check token expiry against */ + const timestamp = useTimestamp({ immediate: true, interval: 100 }) + + return { + ...(toRefs(storage) as any), + token, + payload, + sidebarOpen, + timestamp, + } +} diff --git a/packages/nc-gui-v2/composables/useGlobalState/index.ts b/packages/nc-gui-v2/composables/useGlobalState/index.ts index 026b749b79..e69de29bb2 100644 --- a/packages/nc-gui-v2/composables/useGlobalState/index.ts +++ b/packages/nc-gui-v2/composables/useGlobalState/index.ts @@ -1,169 +0,0 @@ -import { breakpointsTailwind, usePreferredLanguages, useStorage } from '@vueuse/core' -import { useJwt } from '@vueuse/integrations/useJwt' -import type { JwtPayload } from 'jwt-decode' -import { notification } from 'ant-design-vue' -import initialFeedBackForm from './initialFeedbackForm' -import { computed, ref, toRefs, useBreakpoints, useNuxtApp, useTimestamp, watch } from '#imports' -import type { Actions, Getters, GlobalState, StoredState, User } from '~/lib/types' - -const storageKey = 'nocodb-gui-v2' - -/** - * Global state is injected by {@link import('~/plugins/state') state} plugin into our nuxt app (available as `$state`). - * Manual initialization is unnecessary and should be avoided. - * - * The state is stored in {@link WindowLocalStorage localStorage}, so it will be available even if the user closes the browser tab. - * - * @example - * ```js - * import { useNuxtApp } from '#app' - * - * const { $state } = useNuxtApp() - * - * const token = $state.token.value - * const user = $state.user.value - * ``` - */ -export const useGlobalState = (): GlobalState => { - const { $state } = useNuxtApp() - - if ($state) { - console.warn( - '[useGlobalState] Global state is injected by state plugin. Manual initialization is unnecessary and should be avoided.', - ) - return $state - } - - /** get the preferred languages of a user, according to browser settings */ - const preferredLanguages = $(usePreferredLanguages()) - /** todo: reimplement; get the preferred dark mode setting, according to browser settings */ - // const prefersDarkMode = $(usePreferredDark()) - const prefersDarkMode = false - - /** get current breakpoints (for enabling sidebar) */ - const breakpoints = useBreakpoints(breakpointsTailwind) - - /** reactive timestamp to check token expiry against */ - const timestamp = $(useTimestamp({ immediate: true, interval: 100 })) - - const { - $api, - vueApp: { i18n }, - } = useNuxtApp() - - /** - * Set initial language based on browser settings. - * If the user has not set a preferred language, we fallback to 'en'. - * If the user has set a preferred language, we try to find a matching locale in the available locales. - */ - const preferredLanguage = preferredLanguages.reduce((locale, language) => { - /** split language to language and code, e.g. en-GB -> [en, GB] */ - const [lang, code] = language.split(/[_-]/) - - /** find all locales that match the language */ - let availableLocales = i18n.availableLocales.filter((locale) => locale.startsWith(lang)) - - /** If we can match more than one locale, we check if the code of the language matches as well */ - if (availableLocales.length > 1) { - availableLocales = availableLocales.filter((locale) => locale.endsWith(code)) - } - - /** if there are still multiple locales, pick the first one */ - const availableLocale = availableLocales[0] - - /** if we found a matching locale, return it */ - if (availableLocale) locale = availableLocale - - return locale - }, 'en' /** fallback locale */) - - /** State */ - const initialState: StoredState = { - token: null, - user: null, - lang: preferredLanguage, - darkMode: prefersDarkMode, - feedbackForm: initialFeedBackForm, - } - - /** saves a reactive state, any change to these values will write/delete to localStorage */ - const storage = $(useStorage(storageKey, initialState)) - - /** force turn off of dark mode, regardless of previously stored settings */ - storage.darkMode = false - - /** current token ref, used by `useJwt` to reactively parse our token payload */ - let token = $computed({ - get: () => storage.token || '', - set: (val) => (storage.token = val), - }) - - /** reactive token payload */ - const { payload } = $(useJwt($$(token!))) - - /** Getters */ - /** Verify that a user is signed in by checking if token exists and is not expired */ - const signedIn: Getters['signedIn'] = computed( - () => !!(!!token && token !== '' && payload && payload.exp && payload.exp > timestamp / 1000), - ) - - /** is sidebar open */ - const sidebarOpen = ref(signedIn.value && breakpoints.greater('md').value) - - /** Actions */ - /** Sign out by deleting the token from localStorage */ - const signOut: Actions['signOut'] = () => { - storage.token = null - storage.user = null - } - - /** Sign in by setting the token in localStorage */ - const signIn: Actions['signIn'] = async (newToken) => { - token = newToken - - if (payload) { - storage.user = { - id: payload.id, - email: payload.email, - firstname: payload.firstname, - lastname: payload.lastname, - roles: payload.roles, - } - } - } - - /** manually try to refresh token */ - const refreshToken = async () => { - $api.instance - .post('/auth/refresh-token', null, { - withCredentials: true, - }) - .then((response) => { - if (response.data?.token) { - signIn(response.data.token) - } - }) - .catch((err) => { - notification.error({ - // todo: add translation - message: err.message || 'You have been signed out.', - }) - console.error(err) - - signOut() - }) - } - - /** try to refresh token before expiry (5 min before expiry) */ - watch( - () => !!(payload && payload.exp && payload.exp - 5 * 60 < timestamp / 1000), - async (expiring) => { - if (signedIn.value && payload && expiring) { - await refreshToken() - } - }, - { immediate: true }, - ) - - return { ...toRefs(storage), signedIn, signOut, signIn, sidebarOpen } -} diff --git a/packages/nc-gui-v2/composables/useUIPermission/index.ts b/packages/nc-gui-v2/composables/useUIPermission/index.ts index 8ac272f97a..c2fc037893 100644 --- a/packages/nc-gui-v2/composables/useUIPermission/index.ts +++ b/packages/nc-gui-v2/composables/useUIPermission/index.ts @@ -2,7 +2,7 @@ import rolePermissions from './rolePermissions' import { useState } from '#app' import { USER_PROJECT_ROLES } from '~/lib/constants' -export default () => { +export function useUIPermission() { const { $state } = useNuxtApp() const projectRoles = useState>(USER_PROJECT_ROLES, () => ({})) diff --git a/packages/nc-gui-v2/plugins/state.ts b/packages/nc-gui-v2/plugins/state.ts index 36b60df19c..c7cd9d5fe2 100644 --- a/packages/nc-gui-v2/plugins/state.ts +++ b/packages/nc-gui-v2/plugins/state.ts @@ -1,6 +1,6 @@ +import { breakpointsTailwind } from '@vueuse/core' import { defineNuxtPlugin } from '#app' -import { useDark, watch } from '#imports' -import { useGlobalState } from '~/composables/useGlobalState' +import { useBreakpoints, useDark, useGlobal, watch } from '#imports' /** * Injects global state into nuxt app. @@ -15,20 +15,27 @@ import { useGlobalState } from '~/composables/useGlobalState' * ``` */ export default defineNuxtPlugin((nuxtApp) => { - const storage = useGlobalState() + const state = useGlobal() + const darkMode = useDark() + /** get current breakpoints (for enabling sidebar) */ + const breakpoints = useBreakpoints(breakpointsTailwind) + /** set i18n locale to stored language */ - nuxtApp.vueApp.i18n.locale.value = storage.lang.value + nuxtApp.vueApp.i18n.locale.value = state.lang.value /** set current dark mode from storage */ watch( - storage.darkMode, + state.darkMode, (newMode) => { darkMode.value = newMode }, { immediate: true }, ) - nuxtApp.provide('state', storage) + /** is initial sidebar open */ + state.sidebarOpen.value = state.signedIn.value && breakpoints.greater('md').value + + nuxtApp.provide('state', state) }) diff --git a/packages/nc-gui-v2/utils/colorsUtils.ts b/packages/nc-gui-v2/utils/colorsUtils.ts index 4071abc981..fe5a297dc3 100644 --- a/packages/nc-gui-v2/utils/colorsUtils.ts +++ b/packages/nc-gui-v2/utils/colorsUtils.ts @@ -1,4 +1,4 @@ -export default { +export const theme = { light: ['#ffdce5', '#fee2d5', '#ffeab6', '#d1f7c4', '#ede2fe', '#eee', '#cfdffe', '#d0f1fd', '#c2f5e8', '#ffdaf6'], dark: [ '#f82b6099', From 0f8ea2510221bf3f34332e5d8fb2e65ad8e5a8b1 Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Fri, 29 Jul 2022 11:58:34 +0200 Subject: [PATCH 05/34] chore(gui-v2): update import paths for composables --- packages/nc-gui-v2/components/cell/Attachment.vue | 4 ++-- packages/nc-gui-v2/components/cell/Email.vue | 2 +- packages/nc-gui-v2/components/dlg/AirtableImport.vue | 2 +- packages/nc-gui-v2/components/monaco/Editor.vue | 4 +--- .../nc-gui-v2/components/smartsheet-header/CellIcon.vue | 2 +- .../components/smartsheet-toolbar/ColumnFilter.vue | 9 +++++---- .../components/smartsheet-toolbar/FieldsMenu.vue | 6 +++--- packages/nc-gui-v2/components/smartsheet/Cell.vue | 3 +-- packages/nc-gui-v2/components/smartsheet/Gallery.vue | 5 ++--- packages/nc-gui-v2/components/smartsheet/Grid.vue | 9 +++------ packages/nc-gui-v2/components/smartsheet/VirtualCell.vue | 3 +-- packages/nc-gui-v2/components/virtual-cell/BelongsTo.vue | 2 +- packages/nc-gui-v2/composables/useBelongsTo.ts | 2 +- packages/nc-gui-v2/composables/useManyToMany.ts | 2 +- packages/nc-gui-v2/composables/useTabs.ts | 2 +- packages/nc-gui-v2/nuxt-shim.d.ts | 5 ++--- packages/nc-gui-v2/pages/project/index/[id].vue | 2 +- packages/nc-gui-v2/plugins/i18n.ts | 5 ----- packages/nc-gui-v2/tsconfig.json | 3 ++- packages/nc-gui-v2/utils/index.ts | 1 + packages/nc-gui-v2/windi.config.ts | 2 +- 21 files changed, 32 insertions(+), 43 deletions(-) diff --git a/packages/nc-gui-v2/components/cell/Attachment.vue b/packages/nc-gui-v2/components/cell/Attachment.vue index 4f225160e3..4aaa5534bb 100644 --- a/packages/nc-gui-v2/components/cell/Attachment.vue +++ b/packages/nc-gui-v2/components/cell/Attachment.vue @@ -37,7 +37,7 @@ watchEffect(() => { } }) -const selectImage = (file: any, i) => { +const selectImage = (file: any, i: unknown) => { // todo: implement } @@ -49,7 +49,7 @@ const addFile = () => { fileInput.value?.click() } -const onFileSelection = async (e) => { +const onFileSelection = async (e: unknown) => { // if (this.isPublicGrid) { // return // } diff --git a/packages/nc-gui-v2/components/cell/Email.vue b/packages/nc-gui-v2/components/cell/Email.vue index 7c8f3217c7..5e1e1c671d 100644 --- a/packages/nc-gui-v2/components/cell/Email.vue +++ b/packages/nc-gui-v2/components/cell/Email.vue @@ -1,6 +1,6 @@ - diff --git a/packages/nc-gui-v2/components/general/Share.vue b/packages/nc-gui-v2/components/general/Share.vue index a48cd29a38..dfb908e93f 100644 --- a/packages/nc-gui-v2/components/general/Share.vue +++ b/packages/nc-gui-v2/components/general/Share.vue @@ -3,7 +3,7 @@ interface Props { url: string socialMedias: string[] title?: string - summary: string + summary?: string hashTags?: string css?: string iconClass?: string diff --git a/packages/nc-gui-v2/components/smartsheet/Pagination.vue b/packages/nc-gui-v2/components/smartsheet/Pagination.vue index aed95f8c7a..8fecc8d81e 100644 --- a/packages/nc-gui-v2/components/smartsheet/Pagination.vue +++ b/packages/nc-gui-v2/components/smartsheet/Pagination.vue @@ -73,7 +73,7 @@ export default { @keydown.enter="changePage(page)" > diff --git a/packages/nc-gui-v2/components/tabs/Smartsheet.vue b/packages/nc-gui-v2/components/tabs/Smartsheet.vue index e633514fcd..decbf18c6a 100644 --- a/packages/nc-gui-v2/components/tabs/Smartsheet.vue +++ b/packages/nc-gui-v2/components/tabs/Smartsheet.vue @@ -29,7 +29,7 @@ provide(FieldsInj, fields) provide('navDrawerOpen', ref(true)) watch( - () => tabMeta && tabMeta?.id, + () => tabMeta && tabMeta.value.id, async (newVal, oldVal) => { if (newVal !== oldVal) await getMeta(newVal) }, diff --git a/packages/nc-gui-v2/components/virtual-cell/Rollup.vue b/packages/nc-gui-v2/components/virtual-cell/Rollup.vue index a5c8aa2aed..2354a64d65 100644 --- a/packages/nc-gui-v2/components/virtual-cell/Rollup.vue +++ b/packages/nc-gui-v2/components/virtual-cell/Rollup.vue @@ -1,5 +1,5 @@