Advertisement
DrakonFirestone

ng-flow usage JavaScript

Aug 31st, 2015
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     $scope.existingFlowObject = flowFactory.create({
  2.         singleFile: true,
  3.         target: base_url + 'file',
  4.         testChunks: false
  5.     });
  6.  
  7.  
  8.     $scope.deleteImage = function () {
  9.         $scope.existingFlowObject.cancel();
  10.         $scope.infant.imageId = null;
  11.     };
  12.  
  13.     $scope.uploadLogEvent = function (image_id) {
  14.         if (!isNaN(image_id) && image_id !== null) {
  15.             $scope.newLogEvent.imageId = image_id;
  16.         }
  17.         var sendData = {
  18.             infant_id: $scope.infant.infantId,
  19.             duration: $scope.dur.days + ' ' + $scope.dur.hours + ':' + $scope.dur.minutes,
  20.             start_date: $scope.prepareDate($scope.newLogEvent.startDate, $scope.newLogEvent.startDate),
  21.             event_category: $scope.newLogEvent.eventCategory,
  22.             event_type: $scope.newLogEvent.eventType,
  23.             sickness_type: $scope.newLogEvent.sicknessType,
  24.             number_detail: $scope.newLogEvent.numberDetail,
  25.             text_detail: $scope.newLogEvent.textDetail,
  26.             comment: $scope.newLogEvent.comment,
  27.             file_id: $scope.newLogEvent.imageId
  28.         };
  29.  
  30.         if (sendData.duration === "0 0:0") {
  31.             sendData.duration = null;
  32.         }
  33.  
  34.         rest.post('event')
  35.                 .preload('event')
  36.                 .data(sendData)
  37.                 .success(function (data) {
  38.                     if (data.status === 'ok') {
  39.                         //$scope.showAlert();
  40.                         self.reset();
  41.                         $scope.reloadPage();
  42.                     }
  43.                 })
  44.                 .send();
  45.     };
  46.  
  47. $scope.save() {
  48.     //...
  49.     if ($scope.existingFlowObject.files.length)
  50.     // po zakońceniu żądania automatycznie wywolywana funkcja uploadLogEvent(image_id)
  51.         existingFlowObject.upload()
  52.     }
  53.     else {
  54.     $scope.uploadLogEvent(null);
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement