@lingk/sync 1.1.13 → 1.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/main.js CHANGED
@@ -5545,7 +5545,7 @@ module.exports =
5545
5545
  f = Math.floor(Math.log(a) / Math.log(c));return parseFloat((a / Math.pow(c, f)).toFixed(d)) + " " + e[f];
5546
5546
  }
5547
5547
 
5548
- var extensionBlacklist = ['xls', 'xlsx', 'xml', 'zip', 'tar', 'gz'];
5548
+ var extensionBlacklist = ['jsonl', 'xml', 'zip', 'tar', 'gz'];
5549
5549
 
5550
5550
  var FlatFile = function (_Component) {
5551
5551
  _inherits(FlatFile, _Component);
@@ -5637,30 +5637,34 @@ module.exports =
5637
5637
  var reader = new FileReader();
5638
5638
  reader.onload = function (e) {
5639
5639
 
5640
+ // PARSE METADATA
5640
5641
  var data = e.target.result;
5641
5642
  var csv = null;
5642
5643
  if (isXLS) {
5643
- var i;
5644
-
5645
5644
  (function () {
5646
- var binary = '';
5647
- var bytes = new Uint8Array(data);
5648
- for (i = 0; i < length; i++) {
5645
+ var sheetCounter = 0;
5646
+ var binary = data;
5647
+ /*const bytes = new Uint8Array(data)
5648
+ for (var i = 0; i < length; i++) {
5649
5649
  binary += String.fromCharCode(bytes[i]);
5650
- }
5650
+ }*/
5651
5651
  var workbook = _xlsx2.default.read(binary, { type: 'binary' });
5652
- workbook.SheetNames.forEach(function (sn) {
5653
- if (sn !== 'Export Summary') {
5654
- csv = _xlsx2.default.utils.sheet_to_csv(workbook.Sheets[sn]);
5655
- _this.parseCSV(file, csv).then(function (xlsMeta) {
5656
- meta = meta.concat(xlsMeta);
5657
- counter += 1;
5658
- if (counter === fs.length) {
5659
- _this.setState({ meta: meta });
5660
- _this.props.onDrop();
5661
- }
5662
- });
5663
- }
5652
+ var sheetNames = workbook.SheetNames.filter(function (sn) {
5653
+ return sn !== 'Export Summary';
5654
+ });
5655
+ sheetNames.forEach(function (sn) {
5656
+ csv = _xlsx2.default.utils.sheet_to_csv(workbook.Sheets[sn]);
5657
+ _this.parseCSV(file, csv).then(function (xlsMeta) {
5658
+ meta = meta.concat(Object.assign({}, xlsMeta, {
5659
+ sheetName: sn
5660
+ }));
5661
+ sheetCounter += 1;
5662
+ counter += 1;
5663
+ if (counter >= fs.length && sheetCounter === sheetNames.length) {
5664
+ _this.setState({ meta: meta });
5665
+ _this.props.onDrop();
5666
+ }
5667
+ });
5664
5668
  });
5665
5669
  })();
5666
5670
  } else if (extension === 'csv') {
@@ -5684,7 +5688,8 @@ module.exports =
5684
5688
  }
5685
5689
  }
5686
5690
 
5687
- fileContents = fileContents.concat(data);
5691
+ // ADD TO CONTENTS, TO UPLOAD
5692
+ fileContents = fileContents.concat(file);
5688
5693
  contentCounter += 1;
5689
5694
  if (contentCounter === fs.length) {
5690
5695
  _this.setState({ fileContents: fileContents });
@@ -5692,7 +5697,7 @@ module.exports =
5692
5697
  }; // end file reader on load callback
5693
5698
 
5694
5699
  if (isXLS) {
5695
- reader.readAsArrayBuffer(file); // read as binary string???
5700
+ reader.readAsBinaryString(file); // read as array buffer???
5696
5701
  } else {
5697
5702
  reader.readAsText(file);
5698
5703
  }
@@ -5720,7 +5725,6 @@ module.exports =
5720
5725
 
5721
5726
  _this.setState({ uploading: true });
5722
5727
  setCsvFields(_this.state.meta, _this.state.fileContents, providerType).then(function () {
5723
- console.log("SET META BACK");
5724
5728
  _this.setState({ meta: [], fileContents: [], uploading: false });
5725
5729
  });
5726
5730
  };
@@ -5734,8 +5738,8 @@ module.exports =
5734
5738
  meta: [],
5735
5739
  fileContents: [],
5736
5740
  uploading: false,
5737
- dropError: null
5738
- };
5741
+ dropError: null,
5742
+ sortFileTableBy: 'uploadedTime' };
5739
5743
  return _this;
5740
5744
  }
5741
5745
 
@@ -5747,15 +5751,41 @@ module.exports =
5747
5751
  var _state = this.state,
5748
5752
  meta = _state.meta,
5749
5753
  uploading = _state.uploading,
5750
- dropError = _state.dropError;
5751
- var _props = this.props,
5752
- fileSchema = _props.fileSchema,
5753
- inputs = _props.inputs;
5754
+ dropError = _state.dropError,
5755
+ sortFileTableBy = _state.sortFileTableBy;
5756
+ var inputs = this.props.inputs;
5754
5757
 
5755
5758
  var Button = inputs.Button;
5756
5759
  var Spinner = inputs.Spinner;
5757
5760
  var hasFile = meta && meta.length > 0;
5758
5761
 
5762
+ var fileSchema = [];
5763
+ var fileSchemaNames = [];
5764
+ this.props.fileSchema && this.props.fileSchema.forEach(function (f) {
5765
+ if (!fileSchemaNames.includes(f.name)) {
5766
+ fileSchema.push(f);
5767
+ fileSchemaNames.push(f.name);
5768
+ }
5769
+ });
5770
+ if (fileSchema && fileSchema.length) {
5771
+ fileSchema = fileSchema.sort(function (a, b) {
5772
+ var term = sortFileTableBy;
5773
+ if (term === 'uploadedTime') {
5774
+ return a[term] < b[term];
5775
+ }
5776
+ return a[term] > b[term];
5777
+ });
5778
+ }
5779
+
5780
+ var droppedFiles = [];
5781
+ var droppedFileNames = [];
5782
+ meta && meta.forEach(function (f) {
5783
+ if (!droppedFileNames.includes(f.name)) {
5784
+ droppedFiles.push(f);
5785
+ droppedFileNames.push(f.name);
5786
+ }
5787
+ });
5788
+
5759
5789
  return _react2.default.createElement(
5760
5790
  'div',
5761
5791
  null,
@@ -5769,7 +5799,7 @@ module.exports =
5769
5799
  !dropError ? _react2.default.createElement(
5770
5800
  'p',
5771
5801
  null,
5772
- 'Drop one or more CSV files here, or click to select files to upload.'
5802
+ 'Drop one or more files here, or click to select files to upload.'
5773
5803
  ) : _react2.default.createElement(
5774
5804
  'p',
5775
5805
  { style: { color: '#c9302c', fontWeight: 'bold' } },
@@ -5816,7 +5846,7 @@ module.exports =
5816
5846
  _react2.default.createElement(
5817
5847
  'ul',
5818
5848
  { style: { padding: 0 } },
5819
- meta.map(function (f, i) {
5849
+ droppedFiles.map(function (f, i) {
5820
5850
  return _react2.default.createElement(
5821
5851
  'li',
5822
5852
  { key: i, style: { listStyle: 'none' } },
@@ -5848,7 +5878,7 @@ module.exports =
5848
5878
  ),
5849
5879
  _react2.default.createElement(
5850
5880
  _reactBootstrap.Table,
5851
- { bordered: true, condensed: true },
5881
+ { bordered: true, condensed: true, className: 'file-manager-table' },
5852
5882
  _react2.default.createElement(
5853
5883
  'thead',
5854
5884
  null,
@@ -5857,18 +5887,24 @@ module.exports =
5857
5887
  null,
5858
5888
  _react2.default.createElement(
5859
5889
  'th',
5860
- null,
5890
+ { onClick: function onClick() {
5891
+ return _this2.setState({ sortFileTableBy: 'name' });
5892
+ } },
5861
5893
  'Name'
5862
5894
  ),
5863
5895
  _react2.default.createElement(
5864
5896
  'th',
5865
- null,
5897
+ { onClick: function onClick() {
5898
+ return _this2.setState({ sortFileTableBy: 'byteSize' });
5899
+ } },
5866
5900
  'Size'
5867
5901
  ),
5868
5902
  _react2.default.createElement(
5869
5903
  'th',
5870
- null,
5871
- 'Date Uploaded'
5904
+ { onClick: function onClick() {
5905
+ return _this2.setState({ sortFileTableBy: 'uploadedTime' });
5906
+ } },
5907
+ 'Date uploaded'
5872
5908
  )
5873
5909
  )
5874
5910
  ),
@@ -50733,7 +50769,6 @@ module.exports =
50733
50769
  }
50734
50770
 
50735
50771
  function uploadFilesToS3(tenantKey, appKey, envId, metadata, d, contents) {
50736
- console.log("UPLOAD", metadata, contents);
50737
50772
  var args = contents.map(function (fileContent, i) {
50738
50773
  return { tenantKey: tenantKey, appKey: appKey, envId: envId, fileContent: fileContent, d: d, fileName: metadata[i].name };
50739
50774
  });
@@ -50750,12 +50785,10 @@ module.exports =
50750
50785
  fileContent = _ref.fileContent,
50751
50786
  fileName = _ref.fileName;
50752
50787
 
50753
- console.log(fileName, d);
50754
50788
  /*if(!d.guids.files[fileName]){
50755
50789
  return () => Promise.resolve(null)
50756
50790
  }*/
50757
50791
  var p = JSON.parse(atob(d.policy));
50758
- console.log(p);
50759
50792
  var pFind = function pFind(s) {
50760
50793
  return p.conditions.find(function (pf) {
50761
50794
  return Object.keys(pf).includes(s);
@@ -50780,7 +50813,6 @@ module.exports =
50780
50813
  }
50781
50814
 
50782
50815
  function downloadFileFromAws(tenantId, appId, tenantKey, appKey, envId, file) {
50783
- console.log(file);
50784
50816
  return function (dispatch, getState, api) {
50785
50817
  var _getState5 = getState(),
50786
50818
  config = _getState5.config;
@@ -55858,7 +55890,8 @@ module.exports =
55858
55890
  ) : _react2.default.createElement(
55859
55891
  'div',
55860
55892
  null,
55861
- rsc.name
55893
+ rsc.name,
55894
+ rsc.sheetName ? ' (' + rsc.sheetName + ')' : ''
55862
55895
  )
55863
55896
  );
55864
55897
  })