Add missing files changed directive to upload
This commit is contained in:
		
							parent
							
								
									68f8eb5a8f
								
							
						
					
					
						commit
						b631b0f271
					
				
					 3 changed files with 45 additions and 2 deletions
				
			
		
							
								
								
									
										18
									
								
								config_app/js/components/files-changed.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								config_app/js/components/files-changed.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,18 @@ | |||
| /** | ||||
|  * Raises the 'filesChanged' event on the scope if a file on the marked <input type="file"> exists. | ||||
|  */ | ||||
| angular.module('quay-config').directive("filesChanged", [function () { | ||||
|     return { | ||||
|         restrict: 'A', | ||||
|         scope: { | ||||
|             'filesChanged': "&" | ||||
|         }, | ||||
|         link: function (scope, element, attributes) { | ||||
|             element.bind("change", function (changeEvent) { | ||||
|                 scope.$apply(function() { | ||||
|                     scope.filesChanged({'files': changeEvent.target.files}); | ||||
|                 }); | ||||
|             }); | ||||
|         } | ||||
|     } | ||||
| }]); | ||||
|  | @ -6,6 +6,27 @@ const templateUrl = require('./load-config.html'); | |||
|     templateUrl, | ||||
| }) | ||||
| export class LoadConfigComponent { | ||||
|     constructor() { | ||||
|     private resetUpload: number = 0; | ||||
| 
 | ||||
|     private handleTarballSelected(files, callback) { | ||||
|         console.log('hi world') | ||||
|         /* | ||||
|         $scope.certsUploading = true; | ||||
|         $upload.upload({ | ||||
|             url: '/api/v1/superuser/customcerts/' + files[0].name, | ||||
|             method: 'POST', | ||||
|             data: {'_csrf_token': window.__token}, | ||||
|             file: files[0] | ||||
|         }).success(function() { | ||||
|             callback(true); | ||||
|             $scope.resetUpload++; | ||||
|             loadCertificates(); | ||||
|         }).error(function(r) { | ||||
|             bootbox.alert('Could not upload certificate') | ||||
|             callback(false); | ||||
|             $scope.resetUpload++; | ||||
|             loadCertificates(); | ||||
|         }); | ||||
|         */ | ||||
|     } | ||||
| } | ||||
|  | @ -10,7 +10,11 @@ | |||
|                 <!-- Body --> | ||||
|                 <div> | ||||
|                     Please upload a tarball | ||||
|                     <input type="file" accept=".tar"></div> | ||||
|                     <div class="file-upload-box" | ||||
|                          select-message="Select a previous configuration to modify. Must be in tar.gz format" | ||||
|                          files-selected="$ctrl.handleTarballSelected(files, callback)" | ||||
|                          reset="$ctrl.resetUpload" | ||||
|                          extensions="['application/gzip', '.gz']"></div> | ||||
|                 </div> | ||||
|             </div><!-- /.modal-content --> | ||||
|         </div><!-- /.modal-dialog --> | ||||
|  |  | |||
		Reference in a new issue