4 appDS2.controller("attachTestEnvManifestController", ["$uibModalInstance", "$uibModal", "$log", "$scope",
5 attachTestEnvManifestController]);
7 function attachTestEnvManifestController($uibModalInstance, $uibModal, $log, $scope) {
10 var init = function () {
15 vm.close = function () {
16 $uibModalInstance.close();
19 vm.submit = function () {
20 $uibModalInstance.close(vm.manifest);
23 vm.isSubmitDisabled = function () {
24 return !(vm.manifest);
30 Must be $scope because we bind to the onchange of the html (cannot attached to vm variable).
31 We use scope because angular doesn't support ng-change on input file
32 https://github.com/angular/angular.js/issues/1375
33 https://stackoverflow.com/questions/17922557/angularjs-how-to-check-for-changes-in-file-input-fields
35 $scope.selectAttachmentManifest = function (fileInput) {
36 if (fileInput && fileInput.id) {
39 var file = fileInput.files[0];
40 vm.filename=file.name;
41 var fileReader = new FileReader();
42 fileReader.onload = function (load) {
44 var lines = load.target.result;
45 vm.manifest = JSON.parse(lines);
48 vm.error = "file: " + vm.filename + " is not a valid JSON"
52 fileReader.readAsText(file);