diff --git a/package-lock.json b/package-lock.json index 9fc7827..27e9035 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,12 +15,9 @@ "@ionic/core": "^7.6.0", "@ionic/vue": "^7.6.0", "@ionic/vue-router": "^7.6.0", - "@types/file-saver": "^2.0.4", - "@types/papaparse": "^5.3.1", "axios": "^0.21.1", "axios-cache-adapter": "^2.7.3", "core-js": "^3.6.5", - "file-saver": "^2.0.5", "http-status-codes": "^2.1.4", "luxon": "^2.3.0", "mitt": "^2.1.0", @@ -49,7 +46,6 @@ "cypress": "^8.3.0", "eslint": "^7.32.0", "eslint-plugin-vue": "^8.0.3", - "papaparse": "^5.3.1", "typescript": "~4.7.4", "vue-cli-plugin-i18n": "^1.0.1" } @@ -2752,11 +2748,6 @@ "@types/send": "*" } }, - "node_modules/@types/file-saver": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/@types/file-saver/-/file-saver-2.0.7.tgz", - "integrity": "sha512-dNKVfHd/jk0SkR/exKGj2ggkB45MAkzvWCaqLUUgkyjITkGNzH8H+yUwr+BLJUBjZOe9w8X3wgmXhZDRg1ED6A==" - }, "node_modules/@types/html-minifier-terser": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/@types/html-minifier-terser/-/html-minifier-terser-6.1.0.tgz", @@ -2806,6 +2797,7 @@ "version": "20.10.5", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.5.tgz", "integrity": "sha512-nNPsNE65wjMxEKI93yOP+NPGGBJz/PoN3kZsVLee0XMiJolxSekEVD8wRwBUBqkwc7UWop0edW50yrCQW4CyRw==", + "dev": true, "dependencies": { "undici-types": "~5.26.4" } @@ -2825,14 +2817,6 @@ "integrity": "sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==", "dev": true }, - "node_modules/@types/papaparse": { - "version": "5.3.14", - "resolved": "https://registry.npmjs.org/@types/papaparse/-/papaparse-5.3.14.tgz", - "integrity": "sha512-LxJ4iEFcpqc6METwp9f6BV6VVc43m6MfH0VqFosHvrUgfXiFe6ww7R3itkOQ+TCK6Y+Iv/+RnnvtRZnkc5Kc9g==", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/parse-json": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.2.tgz", @@ -8020,11 +8004,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/fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -11169,12 +11148,6 @@ "node": ">=6" } }, - "node_modules/papaparse": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/papaparse/-/papaparse-5.4.1.tgz", - "integrity": "sha512-HipMsgJkZu8br23pW15uvo6sib6wne/4woLZPlFf3rpDyMe9ywEXUsuD7+6K9PRkJlVT51j/sCOYDKGGS3ZJrw==", - "dev": true - }, "node_modules/param-case": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/param-case/-/param-case-3.0.4.tgz", @@ -14016,7 +13989,8 @@ "node_modules/undici-types": { "version": "5.26.5", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true }, "node_modules/unicode-canonical-property-names-ecmascript": { "version": "2.0.0", diff --git a/package.json b/package.json index a1cb765..9707228 100644 --- a/package.json +++ b/package.json @@ -19,12 +19,9 @@ "@ionic/core": "^7.6.0", "@ionic/vue": "^7.6.0", "@ionic/vue-router": "^7.6.0", - "@types/file-saver": "^2.0.4", - "@types/papaparse": "^5.3.1", "axios": "^0.21.1", "axios-cache-adapter": "^2.7.3", "core-js": "^3.6.5", - "file-saver": "^2.0.5", "http-status-codes": "^2.1.4", "luxon": "^2.3.0", "mitt": "^2.1.0", @@ -53,7 +50,6 @@ "cypress": "^8.3.0", "eslint": "^7.32.0", "eslint-plugin-vue": "^8.0.3", - "papaparse": "^5.3.1", "typescript": "~4.7.4", "vue-cli-plugin-i18n": "^1.0.1" } diff --git a/src/components/RouteMenu.vue b/src/components/RouteMenu.vue deleted file mode 100644 index 12b6ef2..0000000 --- a/src/components/RouteMenu.vue +++ /dev/null @@ -1,120 +0,0 @@ - - - diff --git a/src/utils/index.ts b/src/utils/index.ts index d8ed4ce..74eec03 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,6 +1,4 @@ -import saveAs from "file-saver"; import { toastController } from "@ionic/vue"; -import Papa from "papaparse" import { Group, Route, Rule } from "@/types"; import { DateTime } from "luxon"; @@ -21,104 +19,6 @@ const showToast = async (message: string) => { return toast.present(); } -// Utility for parsing CSV file -// Package Used : PapaParse (Link to Documentation : https://www.papaparse.com/docs#config) - -// In this we will be receiving the file and options in the function -// and we are returning a promise with results in it - -// We have used the parse method of the papaparse library which will take a config object with File. -// In the config object we have passed various keys: -// - header : It tells papaparse that there will be a header in the CSV. -// - skipEmptyLines : It will ignore any empty lines in the CSV. -// - complete : A parse result always contains three objects: data, errors, and meta. -// data and errors are arrays, and meta is an object. In the step callback, the data -// array will only contain one element. - -// Also, we have passed options, as if user wants to add some more properties to the method -// or if he want to modify some pre-build keys then he can do so. - -// Types of Responses - -// CSV FILE : -// columnA,columnB,columnC -// "Susan",41,a -// "Mike",5,b -// "Jake",33,c -// "Jill",30,d - -// For (header:true) we get -// [{columnA: "Susan", columnB: "41", columnC: "a"}, -// {columnA: "Mike", columnB: "5", columnC: "b"}, -// {columnA: "Jake", columnB: "33", columnC: "c"}, -// {columnA: "Jill", columnB: "30", columnC: "d"}] - -// // For (header:false) we get -// [["columnA", "columnB", "columnC"], -// ["Susan", "41", "a"], -// ["Mike", "5", "b"], -// ["Jake", "33", "c"], -// ["Jill", "30", "d"]] - -const parseCsv = async (file: File, options: any) => { - return new Promise ((resolve, reject) => { - Papa.parse(file, { - header: false, - skipEmptyLines: true, - complete: function (results: any) { - if (results.errors.length) { - reject(results.error) - } else { - resolve(results) - } - }, - ...options - }); - }) -} - -// Here we have created a JsonToCsvOption which contains the properties which we can pass to jsonToCsv function - -interface JsonToCsvOption { - parse?: object | null; - encode?: object | null; - name?: string; - download?: boolean; -} - -// Utility for converting Javascript Object into blob and download it as Csv -// Package Used : PapaParse (Link to Documentation : https://www.papaparse.com/docs#config) -// file-saver (Link to Documentation : https://www.npmjs.com/package/file-saver) - -// In this we will be receiving a Javascript object and options in the function and we will be -// returning a blob object - -// We have used a unparse method of papaparse library for converting javascript object into csv file, -// and in addition to this we are using saveAs method to download our blob file -// In the options we will be passing various keys: -// parse: In this we will be passing a object which contains various properties (headers,skipEmptyLines) to be passed in unparse method -// encode: In this we will be passing a object which contains various properties related to the encoding like { type } -// name: In this we will provide a name by which we want to download the csv File, and it is necessary to provide the .csv in the name -// download: In this we will provide a value which will decide whether we want to download the file or not - -const jsonToCsv = (file: any, options: JsonToCsvOption = {}) => { - const csv = Papa.unparse(file, { - ...options.parse - }); - const encoding = { - type: String, - default: "utf-8", - ...options.encode - }; - const blob = new Blob([csv], { - type: "application/csvcharset=" + encoding - }); - if (options.download) { - saveAs(blob, options.name ? options.name : "default.csv"); - } - return blob; -} - const sortSequence = (sequence: Array) => { // Currently, sorting is only performed on sequenceNum, so if two seqence have same seqNum then they will be arranged in FCFS basis // TODO: Need to check that if for the above case we need to define the sorting on name as well, when seqNum is same @@ -133,4 +33,4 @@ const getTimeFromSeconds = (time: any) => { return time ? DateTime.fromSeconds(time).toLocaleString(DateTime.DATETIME_MED) : "-"; } -export { getTime, getTimeFromSeconds, showToast, hasError , parseCsv , jsonToCsv, JsonToCsvOption, sortSequence } +export { getTime, getTimeFromSeconds, showToast, hasError, sortSequence }