Commit 0e89d002 authored by Christian Merten's avatar Christian Merten Committed by Fabien Maniere

feat: automatically detect file type on file selection

parent f9c5b3fa
Pipeline #6842 passed with stages
in 14 minutes and 12 seconds
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
"highlightjs": "~9.16.2", "highlightjs": "~9.16.2",
"immer": "~9.0.5", "immer": "~9.0.5",
"isomorphic-unfetch": "~3.1.0", "isomorphic-unfetch": "~3.1.0",
"jszip": "^3.10.1",
"markdown-it": "~13.0.1", "markdown-it": "~13.0.1",
"minify": "^11.3.0", "minify": "^11.3.0",
"prop-types": "~15.6.2", "prop-types": "~15.6.2",
...@@ -5178,7 +5179,6 @@ ...@@ -5178,7 +5179,6 @@
}, },
"node_modules/core-util-is": { "node_modules/core-util-is": {
"version": "1.0.3", "version": "1.0.3",
"dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/cosmiconfig": { "node_modules/cosmiconfig": {
...@@ -7370,6 +7370,11 @@ ...@@ -7370,6 +7370,11 @@
], ],
"license": "BSD-3-Clause" "license": "BSD-3-Clause"
}, },
"node_modules/immediate": {
"version": "3.0.6",
"resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz",
"integrity": "sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ=="
},
"node_modules/immer": { "node_modules/immer": {
"version": "9.0.21", "version": "9.0.21",
"license": "MIT", "license": "MIT",
...@@ -7661,7 +7666,6 @@ ...@@ -7661,7 +7666,6 @@
}, },
"node_modules/isarray": { "node_modules/isarray": {
"version": "1.0.0", "version": "1.0.0",
"dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/isexe": { "node_modules/isexe": {
...@@ -7767,6 +7771,17 @@ ...@@ -7767,6 +7771,17 @@
"graceful-fs": "^4.1.6" "graceful-fs": "^4.1.6"
} }
}, },
"node_modules/jszip": {
"version": "3.10.1",
"resolved": "https://registry.npmjs.org/jszip/-/jszip-3.10.1.tgz",
"integrity": "sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g==",
"dependencies": {
"lie": "~3.3.0",
"pako": "~1.0.2",
"readable-stream": "~2.3.6",
"setimmediate": "^1.0.5"
}
},
"node_modules/keyv": { "node_modules/keyv": {
"version": "4.5.4", "version": "4.5.4",
"dev": true, "dev": true,
...@@ -7800,6 +7815,14 @@ ...@@ -7800,6 +7815,14 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/lie": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/lie/-/lie-3.3.0.tgz",
"integrity": "sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==",
"dependencies": {
"immediate": "~3.0.5"
}
},
"node_modules/lightningcss": { "node_modules/lightningcss": {
"version": "1.24.1", "version": "1.24.1",
"dev": true, "dev": true,
...@@ -9847,6 +9870,11 @@ ...@@ -9847,6 +9870,11 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/pako": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz",
"integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw=="
},
"node_modules/pandemonium": { "node_modules/pandemonium": {
"version": "2.4.1", "version": "2.4.1",
"license": "MIT", "license": "MIT",
...@@ -10608,7 +10636,6 @@ ...@@ -10608,7 +10636,6 @@
}, },
"node_modules/process-nextick-args": { "node_modules/process-nextick-args": {
"version": "2.0.1", "version": "2.0.1",
"dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/progress": { "node_modules/progress": {
...@@ -11097,7 +11124,6 @@ ...@@ -11097,7 +11124,6 @@
}, },
"node_modules/readable-stream": { "node_modules/readable-stream": {
"version": "2.3.8", "version": "2.3.8",
"dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"core-util-is": "~1.0.0", "core-util-is": "~1.0.0",
...@@ -12142,7 +12168,6 @@ ...@@ -12142,7 +12168,6 @@
}, },
"node_modules/string_decoder": { "node_modules/string_decoder": {
"version": "1.1.1", "version": "1.1.1",
"dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"safe-buffer": "~5.1.0" "safe-buffer": "~5.1.0"
...@@ -12762,7 +12787,6 @@ ...@@ -12762,7 +12787,6 @@
}, },
"node_modules/util-deprecate": { "node_modules/util-deprecate": {
"version": "1.0.2", "version": "1.0.2",
"dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/utility-types": { "node_modules/utility-types": {
......
...@@ -4,6 +4,7 @@ import Gargantext.Prelude ...@@ -4,6 +4,7 @@ import Gargantext.Prelude
import Data.ArrayBuffer.Types (ArrayBuffer) import Data.ArrayBuffer.Types (ArrayBuffer)
import Data.Eq.Generic (genericEq) import Data.Eq.Generic (genericEq)
import Data.Ord.Generic (genericCompare)
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Show.Generic (genericShow) import Data.Show.Generic (genericShow)
...@@ -17,6 +18,7 @@ data FileType = TSV | TSV_HAL | Istex | WOS | PresseRIS | Arbitrary | JSON | Ira ...@@ -17,6 +18,7 @@ data FileType = TSV | TSV_HAL | Istex | WOS | PresseRIS | Arbitrary | JSON | Ira
derive instance Generic FileType _ derive instance Generic FileType _
instance Eq FileType where eq = genericEq instance Eq FileType where eq = genericEq
instance Ord FileType where compare = genericCompare
instance Show FileType where show = genericShow instance Show FileType where show = genericShow
instance Read FileType where instance Read FileType where
read :: String -> Maybe FileType read :: String -> Maybe FileType
......
/* global exports */
"use strict";
// module WebSocket
async function getFilesAsync_ (blob) {
var JSZip = require("jszip");
var zip = new JSZip();
var data = await zip.loadAsync(blob);
var vals = Object.values(data.files);
var fns = [];
for (var i = 0; i < vals.length; i++) {
fns.push(vals[i].name);
console.log(vals[i].name);
}
console.log(fns);
return fns;
}
export const getFilesAsync = blob => () =>
getFilesAsync_(blob);
-- | This module defines a simple low-level interface to the websockets API.
module Gargantext.Utils.ZIP
( getFiles
) where
import Gargantext.Prelude
import Data.ArrayBuffer.Types (ArrayBuffer)
import Effect
import Control.Promise
import Effect.Aff (Aff)
foreign import getFilesAsync :: ArrayBuffer -> Effect (Promise (Array String))
getFiles :: ArrayBuffer -> Aff (Array String)
getFiles blob = toAffE $ getFilesAsync blob
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment