@@ -12,10 +12,6 @@ function ScanCtrl($scope, ScanSvc) {
12
12
var pending = 0 ;
13
13
var selectedFile = 0 ;
14
14
var codeMirror_index = 0 ;
15
- $scope . loadPossible = false ;
16
- localforage . length ( function ( len ) {
17
- $scope . loadPossible = ( len == 3 ) ;
18
- } ) ;
19
15
20
16
$scope . run = function ( source , filename ) {
21
17
//empty last scan
@@ -183,6 +179,9 @@ function ScanCtrl($scope, ScanSvc) {
183
179
var serializedResults = JSON . stringify ( $scope . results , includedAttributes ) ;
184
180
localforage . setItem ( 'results' , serializedResults , function ( ) { } ) ;
185
181
182
+ var serializedErrors = JSON . stringify ( $scope . errors ) ;
183
+ localforage . setItem ( 'errors' , serializedErrors , function ( ) { } ) ;
184
+
186
185
var serializedInputFiles = $scope . inputFiles . map ( function ( el ) { return { data : el . asText ( ) , name : el . name } ; } ) ;
187
186
localforage . setItem ( "inputFiles" , JSON . stringify ( serializedInputFiles ) , function ( r ) { } ) ;
188
187
@@ -195,15 +194,19 @@ function ScanCtrl($scope, ScanSvc) {
195
194
} ;
196
195
197
196
//TODO loadstate isn't called anymore, need to make it work with new workflow
198
- $scope . loadState = function ( ) {
199
- // restore results as is
197
+ //TODO -> call loadState() around in main.js, line 36 (using the scanCtrlScope) and expose "reset" button in the UI.
198
+ $scope . restoreState = function ( ) {
199
+ var apply = false ;
200
200
localforage . getItem ( 'results' , function ( results_storage ) {
201
- if ( ! results_storage ) {
202
- alert ( 'No previous scan found.' )
203
- }
204
201
$scope . results = JSON . parse ( results_storage ) ;
205
- $scope . $ apply( ) ;
202
+ apply = true ;
206
203
} ) ;
204
+ localforage . getItem ( 'errors' , function ( errors_storage ) {
205
+ if ( errors_storage ) {
206
+ $scope . errors = JSON . parse ( errors_storage ) ;
207
+ apply = true ;
208
+ }
209
+ } ) ;
207
210
// restore files, by creating JSZip things :)
208
211
localforage . getItem ( "inputFiles" , function ( inputFiles_storage ) {
209
212
// mimic behavior from handleFileUpload
@@ -223,8 +226,9 @@ function ScanCtrl($scope, ScanSvc) {
223
226
document . getElementById ( "doScan_" + i ) . checked = checkboxes [ i ] ;
224
227
}
225
228
} ) ;
226
- $scope . $ apply( ) ;
229
+ apply = true ;
227
230
} ) ;
231
+ if ( apply ) { $scope . $apply ( ) ; }
228
232
} ;
229
233
230
234
$scope . selectAll = function ( ) {
0 commit comments