@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.
@@ -3648,7 +3648,7 @@ module.exports =
3648
3648
  f = Math.floor(Math.log(a) / Math.log(c));return parseFloat((a / Math.pow(c, f)).toFixed(d)) + " " + e[f];
3649
3649
  }
3650
3650
 
3651
- var extensionBlacklist = ['xls', 'xlsx', 'xml', 'zip', 'tar', 'gz'];
3651
+ var extensionBlacklist = ['jsonl', 'xml', 'zip', 'tar', 'gz'];
3652
3652
 
3653
3653
  var FlatFile = function (_Component) {
3654
3654
  _inherits(FlatFile, _Component);
@@ -3740,30 +3740,34 @@ module.exports =
3740
3740
  var reader = new FileReader();
3741
3741
  reader.onload = function (e) {
3742
3742
 
3743
+ // PARSE METADATA
3743
3744
  var data = e.target.result;
3744
3745
  var csv = null;
3745
3746
  if (isXLS) {
3746
- var i;
3747
-
3748
3747
  (function () {
3749
- var binary = '';
3750
- var bytes = new Uint8Array(data);
3751
- for (i = 0; i < length; i++) {
3748
+ var sheetCounter = 0;
3749
+ var binary = data;
3750
+ /*const bytes = new Uint8Array(data)
3751
+ for (var i = 0; i < length; i++) {
3752
3752
  binary += String.fromCharCode(bytes[i]);
3753
- }
3753
+ }*/
3754
3754
  var workbook = _xlsx2.default.read(binary, { type: 'binary' });
3755
- workbook.SheetNames.forEach(function (sn) {
3756
- if (sn !== 'Export Summary') {
3757
- csv = _xlsx2.default.utils.sheet_to_csv(workbook.Sheets[sn]);
3758
- _this.parseCSV(file, csv).then(function (xlsMeta) {
3759
- meta = meta.concat(xlsMeta);
3760
- counter += 1;
3761
- if (counter === fs.length) {
3762
- _this.setState({ meta: meta });
3763
- _this.props.onDrop();
3764
- }
3765
- });
3766
- }
3755
+ var sheetNames = workbook.SheetNames.filter(function (sn) {
3756
+ return sn !== 'Export Summary';
3757
+ });
3758
+ sheetNames.forEach(function (sn) {
3759
+ csv = _xlsx2.default.utils.sheet_to_csv(workbook.Sheets[sn]);
3760
+ _this.parseCSV(file, csv).then(function (xlsMeta) {
3761
+ meta = meta.concat(Object.assign({}, xlsMeta, {
3762
+ sheetName: sn
3763
+ }));
3764
+ sheetCounter += 1;
3765
+ counter += 1;
3766
+ if (counter >= fs.length && sheetCounter === sheetNames.length) {
3767
+ _this.setState({ meta: meta });
3768
+ _this.props.onDrop();
3769
+ }
3770
+ });
3767
3771
  });
3768
3772
  })();
3769
3773
  } else if (extension === 'csv') {
@@ -3787,7 +3791,8 @@ module.exports =
3787
3791
  }
3788
3792
  }
3789
3793
 
3790
- fileContents = fileContents.concat(data);
3794
+ // ADD TO CONTENTS, TO UPLOAD
3795
+ fileContents = fileContents.concat(file);
3791
3796
  contentCounter += 1;
3792
3797
  if (contentCounter === fs.length) {
3793
3798
  _this.setState({ fileContents: fileContents });
@@ -3795,7 +3800,7 @@ module.exports =
3795
3800
  }; // end file reader on load callback
3796
3801
 
3797
3802
  if (isXLS) {
3798
- reader.readAsArrayBuffer(file); // read as binary string???
3803
+ reader.readAsBinaryString(file); // read as array buffer???
3799
3804
  } else {
3800
3805
  reader.readAsText(file);
3801
3806
  }
@@ -3823,7 +3828,6 @@ module.exports =
3823
3828
 
3824
3829
  _this.setState({ uploading: true });
3825
3830
  setCsvFields(_this.state.meta, _this.state.fileContents, providerType).then(function () {
3826
- console.log("SET META BACK");
3827
3831
  _this.setState({ meta: [], fileContents: [], uploading: false });
3828
3832
  });
3829
3833
  };
@@ -3837,8 +3841,8 @@ module.exports =
3837
3841
  meta: [],
3838
3842
  fileContents: [],
3839
3843
  uploading: false,
3840
- dropError: null
3841
- };
3844
+ dropError: null,
3845
+ sortFileTableBy: 'uploadedTime' };
3842
3846
  return _this;
3843
3847
  }
3844
3848
 
@@ -3850,15 +3854,41 @@ module.exports =
3850
3854
  var _state = this.state,
3851
3855
  meta = _state.meta,
3852
3856
  uploading = _state.uploading,
3853
- dropError = _state.dropError;
3854
- var _props = this.props,
3855
- fileSchema = _props.fileSchema,
3856
- inputs = _props.inputs;
3857
+ dropError = _state.dropError,
3858
+ sortFileTableBy = _state.sortFileTableBy;
3859
+ var inputs = this.props.inputs;
3857
3860
 
3858
3861
  var Button = inputs.Button;
3859
3862
  var Spinner = inputs.Spinner;
3860
3863
  var hasFile = meta && meta.length > 0;
3861
3864
 
3865
+ var fileSchema = [];
3866
+ var fileSchemaNames = [];
3867
+ this.props.fileSchema && this.props.fileSchema.forEach(function (f) {
3868
+ if (!fileSchemaNames.includes(f.name)) {
3869
+ fileSchema.push(f);
3870
+ fileSchemaNames.push(f.name);
3871
+ }
3872
+ });
3873
+ if (fileSchema && fileSchema.length) {
3874
+ fileSchema = fileSchema.sort(function (a, b) {
3875
+ var term = sortFileTableBy;
3876
+ if (term === 'uploadedTime') {
3877
+ return a[term] < b[term];
3878
+ }
3879
+ return a[term] > b[term];
3880
+ });
3881
+ }
3882
+
3883
+ var droppedFiles = [];
3884
+ var droppedFileNames = [];
3885
+ meta && meta.forEach(function (f) {
3886
+ if (!droppedFileNames.includes(f.name)) {
3887
+ droppedFiles.push(f);
3888
+ droppedFileNames.push(f.name);
3889
+ }
3890
+ });
3891
+
3862
3892
  return _react2.default.createElement(
3863
3893
  'div',
3864
3894
  null,
@@ -3872,7 +3902,7 @@ module.exports =
3872
3902
  !dropError ? _react2.default.createElement(
3873
3903
  'p',
3874
3904
  null,
3875
- 'Drop one or more CSV files here, or click to select files to upload.'
3905
+ 'Drop one or more files here, or click to select files to upload.'
3876
3906
  ) : _react2.default.createElement(
3877
3907
  'p',
3878
3908
  { style: { color: '#c9302c', fontWeight: 'bold' } },
@@ -3919,7 +3949,7 @@ module.exports =
3919
3949
  _react2.default.createElement(
3920
3950
  'ul',
3921
3951
  { style: { padding: 0 } },
3922
- meta.map(function (f, i) {
3952
+ droppedFiles.map(function (f, i) {
3923
3953
  return _react2.default.createElement(
3924
3954
  'li',
3925
3955
  { key: i, style: { listStyle: 'none' } },
@@ -3951,7 +3981,7 @@ module.exports =
3951
3981
  ),
3952
3982
  _react2.default.createElement(
3953
3983
  _reactBootstrap.Table,
3954
- { bordered: true, condensed: true },
3984
+ { bordered: true, condensed: true, className: 'file-manager-table' },
3955
3985
  _react2.default.createElement(
3956
3986
  'thead',
3957
3987
  null,
@@ -3960,18 +3990,24 @@ module.exports =
3960
3990
  null,
3961
3991
  _react2.default.createElement(
3962
3992
  'th',
3963
- null,
3993
+ { onClick: function onClick() {
3994
+ return _this2.setState({ sortFileTableBy: 'name' });
3995
+ } },
3964
3996
  'Name'
3965
3997
  ),
3966
3998
  _react2.default.createElement(
3967
3999
  'th',
3968
- null,
4000
+ { onClick: function onClick() {
4001
+ return _this2.setState({ sortFileTableBy: 'byteSize' });
4002
+ } },
3969
4003
  'Size'
3970
4004
  ),
3971
4005
  _react2.default.createElement(
3972
4006
  'th',
3973
- null,
3974
- 'Date Uploaded'
4007
+ { onClick: function onClick() {
4008
+ return _this2.setState({ sortFileTableBy: 'uploadedTime' });
4009
+ } },
4010
+ 'Date uploaded'
3975
4011
  )
3976
4012
  )
3977
4013
  ),