Skip to content

Commit 435853a

Browse files
committed
update
1 parent b6daaad commit 435853a

File tree

7 files changed

+61
-24
lines changed

7 files changed

+61
-24
lines changed

dist/angular-csv-import.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/*! angular-csv-import - v0.0.36 - 2016-11-01
2-
* Copyright (c) 2016 ; Licensed */
1+
/*! angular-csv-import - v0.0.37 - 2017-05-19
2+
* Copyright (c) 2017 ; Licensed */
33
'use strict';
44

55
var csvImport = angular.module('ngCsvImport', []);
@@ -35,7 +35,7 @@ csvImport.directive('ngCsvImport', function() {
3535
'<div ng-show="headerVisible"><div class="label">Header</div>' +
3636
(material ? '<input type="checkbox" ng-model="header"></div>' :
3737
'<md-switch class="ng-csv-import-header-switch" ng-model="header"></md-switch>') +
38-
'<div ng-show="encoding"><div class="label">Encoding</div><span>{{encoding}}</span></div>'+
38+
'<div ng-show="encodingVisible"><div class="label">Encoding</div><span>{{encoding}}</span></div>'+
3939
'<div ng-show="separatorVisible">'+
4040
'<div class="label">Seperator</div>'+
4141
'<span><input class="separator-input ' + (material ? '_md md-input' : '') + ' " type="text" ng-change="changeSeparator" ng-model="separator"><span>'+
@@ -83,7 +83,9 @@ csvImport.directive('ngCsvImport', function() {
8383
scope.result = csvToJSON(content);
8484
scope.$apply();
8585
if ( typeof scope.callback === 'function' ) {
86-
scope.callback(e);
86+
if ( scope.callback != null) {
87+
scope.callback(e);
88+
}
8789
}
8890
}
8991
});
@@ -114,7 +116,9 @@ csvImport.directive('ngCsvImport', function() {
114116
scope.result.filename = scope.filename;
115117
scope.$$postDigest(function(){
116118
if ( typeof scope.callback === 'function' ) {
117-
scope.callback(onChangeEvent);
119+
if ( scope.callback != null) {
120+
scope.callback(onChangeEvent);
121+
}
118122
}
119123
});
120124
});
@@ -132,7 +136,9 @@ csvImport.directive('ngCsvImport', function() {
132136
scope.result = csvToJSON(content);
133137
scope.$$postDigest(function(){
134138
if ( typeof scope.callback === 'function' ) {
135-
scope.callback(onChangeEvent);
139+
if ( scope.callback != null) {
140+
scope.callback(onChangeEvent);
141+
}
136142
}
137143
});
138144
}

dist/angular-csv-import.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/app/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@
6969
<script src="bower_components/angular-csv-import/dist/angular-csv-import.js"></script>
7070
<!-- endbuild -->
7171

72+
<script src="lib/line-navigator-master/file-wrapper.js"></script>
73+
<script src="lib/line-navigator-master/line-navigator.js"></script>
74+
7275
<!-- build:js({.tmp,app}) scripts/scripts.js -->
7376
<script src="scripts/app.js"></script>
7477
<script src="scripts/controllers/main.js"></script>

examples/app/scripts/app.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ angular
1313
'ngResource',
1414
'ngRoute',
1515
'ngCsvImport',
16-
'hljs'
16+
'hljs',
17+
'ngMaterial'
1718
])
1819
.config(function ($routeProvider) {
1920
$routeProvider

examples/app/scripts/controllers/main.js

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
angular.module('examplesApp')
44
.controller('MainCtrl', ['$scope', '$parse', function ($scope, $parse) {
5+
$scope.Math = window.Math;
56
$scope.csv = {
67
content: null,
78
header: true,
@@ -11,23 +12,38 @@ angular.module('examplesApp')
1112
result: null,
1213
encoding: 'ISO-8859-1',
1314
encodingVisible: true,
14-
uploadButtonLabel: "upload a csv file"
15+
uploadButtonLabel: "upload a csv file",
16+
progressCallback: function(progress) {
17+
$scope.$apply( function() {
18+
$scope.progress = progress;
19+
});
20+
},
21+
streamingCallback: function(stream) {
22+
if ( typeof stream != "undefined" ) {
23+
$scope.$apply( function() {
24+
$scope.preview = stream[Math.floor(Math.random()*stream.length)];
25+
});
26+
}
27+
},
28+
streamingErrorCallback: function(streamError) {
29+
console.log(streamError);
30+
}
1531
};
1632

1733
var _lastGoodResult = '';
1834
$scope.toPrettyJSON = function (json, tabWidth) {
19-
var objStr = JSON.stringify(json);
20-
var obj = null;
21-
try {
22-
obj = $parse(objStr)({});
23-
} catch(e){
24-
// eat $parse error
25-
return _lastGoodResult;
26-
}
35+
var objStr = JSON.stringify(json);
36+
var obj = null;
37+
try {
38+
obj = $parse(objStr)({});
39+
} catch(e){
40+
// eat $parse error
41+
return _lastGoodResult;
42+
}
2743

28-
var result = JSON.stringify(obj, null, Number(tabWidth));
29-
_lastGoodResult = result;
44+
var result = JSON.stringify(obj, null, Number(tabWidth));
45+
_lastGoodResult = result;
3046

31-
return result;
47+
return result;
3248
};
3349
}]);

examples/app/styles/main.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ div.block>div.content>pre {
106106
margin: 0;
107107
}
108108

109+
.ng-csv-progress {
110+
color: white;
111+
}
112+
109113
footer {
110114
}
111115

examples/app/views/main.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,19 @@
1212
result="csv.result"
1313
encoding="csv.encoding"
1414
encoding-visible="csv.encodingVisible"
15-
upload-button-label="csv.uploadButtonLabel"></ng-csv-import>
15+
upload-button-label="csv.uploadButtonLabel"
16+
progress-callback="csv.progressCallback"
17+
streaming-callback="csv.streamingCallback"
18+
streaming-error-callback="csv.streamingCallback"></ng-csv-import>
1619
</div>
1720
</div>
1821

22+
<div ng-if="progress">
23+
<md-progress-linear md-mode="determinate" class="md-warn" value="{{progress}}"></md-progress-linear>
24+
</div>
25+
1926
<div class="block row" ng-if="csv.result">
20-
<div class="content" hljs source="toPrettyJSON(csv.result, 2)"></div>
27+
<div class="content" hljs source="toPrettyJSON(preview, 2)"></div>
2128
</div>
2229

2330
<!--div ng-if="csv.content" class="block left">

0 commit comments

Comments
 (0)