@@ -8,14 +8,9 @@ function AdminLayerEditController($scope, $injector, $location, $routeParams, Lo
88 $scope . wmsFormats = [ 'image/jpeg' , 'image/png' ] ;
99 $scope . wmsVersions = [ '1.1.1' , '1.3.0' ] ;
1010
11- $scope . fileUploadOptions = {
12- acceptFileTypes : / ( \. | \/ ) ( k m l ) $ / i,
13- } ;
14-
1511 if ( $routeParams . layerId ) {
1612 Layer . get ( { id : $routeParams . layerId } , function ( layer ) {
1713 $scope . layer = layer ;
18- $scope . fileUploadOptions . url = '/api/layers/' + layer . id + '/kml?access_token=' + LocalStorageService . getToken ( )
1914 } ) ;
2015 } else {
2116 $scope . layer = new Layer ( ) ;
@@ -32,65 +27,4 @@ function AdminLayerEditController($scope, $injector, $location, $routeParams, Lo
3227 $scope . cancel = function ( ) {
3328 $location . path ( '/admin/layers/' + $scope . layer . id ) ;
3429 }
35-
36- $scope . addAnotherFile = function ( ) {
37- $scope . uploads . push ( { } ) ;
38- }
39-
40- $scope . confirmUpload = function ( ) {
41- $scope . uploadConfirmed = true ;
42- }
43-
44- $scope . setFiles = function ( element ) {
45- $scope . $apply ( function ( scope ) {
46- console . log ( 'files:' , element . files ) ;
47- // Turn the FileList object into an Array
48- $scope . files = [ ]
49- for ( var i = 0 ; i < element . files . length ; i ++ ) {
50- $scope . files . push ( element . files [ i ] )
51- }
52- $scope . progressVisible = false
53- } ) ;
54- }
55-
56- $scope . uploadFile = function ( ) {
57- var fd = new FormData ( )
58- for ( var i in $scope . files ) {
59- fd . append ( "attachment" , $scope . files [ i ] )
60- }
61- var xhr = new XMLHttpRequest ( )
62- xhr . upload . addEventListener ( "progress" , uploadProgress , false )
63- xhr . addEventListener ( "load" , uploadComplete , false )
64- xhr . addEventListener ( "error" , uploadFailed , false )
65- xhr . addEventListener ( "abort" , uploadCanceled , false )
66- xhr . open ( "POST" , $scope . fileUploadUrl )
67- $scope . progressVisible = true
68- xhr . send ( fd )
69- }
70-
71- function uploadProgress ( evt ) {
72- $scope . $apply ( function ( ) {
73- if ( evt . lengthComputable ) {
74- $scope . progress = Math . round ( evt . loaded * 100 / evt . total )
75- } else {
76- $scope . progress = 'unable to compute'
77- }
78- } ) ;
79- }
80-
81- function uploadComplete ( evt ) {
82- $scope . files = [ ] ;
83- $scope . progressVisible = false
84- }
85-
86- function uploadFailed ( evt ) {
87- alert ( "There was an error attempting to upload the file." )
88- }
89-
90- function uploadCanceled ( evt ) {
91- $scope . $apply ( function ( ) {
92- $scope . progressVisible = false
93- } )
94- alert ( "The upload has been canceled by the user or the browser dropped the connection." )
95- }
9630}
0 commit comments