controllers.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. 'use strict';
  2. /* Controllers; their method are available where specified with the ng-controller
  3. * directive or for a given route/state (see app.js). They use some services to
  4. * connect to the backend (see services.js). */
  5. var eventManControllers = angular.module('eventManControllers', []);
  6. /* A controller that can be used to navigate. */
  7. eventManControllers.controller('NavigationCtrl', ['$scope', '$rootScope', '$location', 'Setting', 'Info',
  8. function ($scope, $rootScope, $location, Setting, Info) {
  9. $scope.logo = {};
  10. $scope.getLocation = function() {
  11. return $location.absUrl();
  12. };
  13. $scope.go = function(url) {
  14. $location.url(url);
  15. };
  16. Setting.query({setting: 'logo'}, function(data) {
  17. if (data && data.length) {
  18. $scope.logo = data[0];
  19. }
  20. });
  21. $scope.isActive = function(view) {
  22. if (view === $location.path()) {
  23. return true;
  24. }
  25. if (view[view.length-1] !== '/') {
  26. view = view + '/';
  27. }
  28. return $location.path().indexOf(view) == 0;
  29. };
  30. }]
  31. );
  32. /* Controller for a group of date and time pickers. */
  33. eventManControllers.controller('DatetimePickerCtrl', ['$scope',
  34. function ($scope) {
  35. $scope.open = function($event) {
  36. $event.preventDefault();
  37. $event.stopPropagation();
  38. $scope.opened = true;
  39. };
  40. }]
  41. );
  42. /* Controller for modals. */
  43. eventManControllers.controller('ModalConfirmInstanceCtrl', ['$scope', '$uibModalInstance', 'message',
  44. function ($scope, $uibModalInstance, message) {
  45. $scope.message = message;
  46. $scope.ok = function () {
  47. $uibModalInstance.close($scope);
  48. };
  49. $scope.cancel = function () {
  50. $uibModalInstance.dismiss('cancel');
  51. };
  52. }]
  53. );
  54. eventManControllers.controller('EventsListCtrl', ['$scope', 'Event', '$uibModal', '$log', '$translate', '$rootScope',
  55. function ($scope, Event, $uibModal, $log, $translate, $rootScope) {
  56. $scope.events = Event.all();
  57. $scope.personsOrderProp = 'name';
  58. $scope.eventsOrderProp = "-begin_date";
  59. $scope.confirm_delete = 'Do you really want to delete this event?';
  60. $rootScope.$on('$translateChangeSuccess', function () {
  61. $translate('Do you really want to delete this event?').then(function (translation) {
  62. $scope.confirm_delete = translation;
  63. });
  64. });
  65. $scope.remove = function(_id) {
  66. var modalInstance = $uibModal.open({
  67. scope: $scope,
  68. templateUrl: 'modal-confirm-action.html',
  69. controller: 'ModalConfirmInstanceCtrl',
  70. resolve: {
  71. message: function() { return $scope.confirm_delete; }
  72. }
  73. });
  74. modalInstance.result.then(function() {
  75. Event.remove({'id': _id}, function() {
  76. $scope.events = Event.all();
  77. }
  78. );
  79. });
  80. };
  81. }]
  82. );
  83. eventManControllers.controller('EventDetailsCtrl', ['$scope', '$state', 'Event', 'Person', 'EventUpdates', '$stateParams', 'Setting', '$log', '$translate', '$rootScope', 'easyFormSteWayConfig', '$uibModal',
  84. function ($scope, $state, Event, Person, EventUpdates, $stateParams, Setting, $log, $translate, $rootScope, easyFormSteWayConfig, $uibModal) {
  85. $scope.personsOrder = ["name", "surname"];
  86. $scope.countAttendees = 0;
  87. $scope.message = {};
  88. $scope.event = {};
  89. $scope.event.persons = [];
  90. $scope.event.formSchema = {};
  91. $scope.eventFormDisabled = false;
  92. $scope.customFields = Setting.query({setting: 'person_custom_field', in_event_details: true});
  93. if ($stateParams.id) {
  94. $scope.event = Event.get($stateParams, function() {
  95. $scope.$watchCollection(function() {
  96. return $scope.event.persons;
  97. }, function(prev, old) {
  98. $scope.calcAttendees();
  99. }
  100. );
  101. });
  102. if ($state.is('event.view') || !$rootScope.hasPermission('event|update')) {
  103. $scope.eventFormDisabled = true;
  104. }
  105. if ($state.is('event.tickets')) {
  106. $scope.allPersons = Person.all();
  107. // Handle WebSocket connection used to update the list of persons.
  108. $scope.EventUpdates = EventUpdates;
  109. $scope.EventUpdates.open();
  110. $scope.$watchCollection(function() {
  111. return $scope.EventUpdates.data;
  112. }, function(prev, old) {
  113. if (!($scope.EventUpdates.data && $scope.EventUpdates.data.update)) {
  114. return;
  115. }
  116. var data = $scope.EventUpdates.data.update;
  117. $log.debug('received ' + data.action + ' action from websocket source ' + data.uuid);
  118. if ($rootScope.app_uuid == data.uuid) {
  119. $log.debug('do not process our own message');
  120. return false;
  121. }
  122. if (!$scope.event.persons) {
  123. $scope.event.persons = [];
  124. }
  125. var person_idx = $scope.event.persons.findIndex(function(el, idx, array) {
  126. return data.person_id == el.person_id;
  127. });
  128. if (person_idx != -1) {
  129. $log.debug('person_id ' + data.person_id + ' found');
  130. } else {
  131. $log.debug('person_id ' + data.person_id + ' not found');
  132. }
  133. if (data.action == 'update' && person_idx != -1 && $scope.event.persons[person_idx] != data.person) {
  134. $scope.event.persons[person_idx] = data.person;
  135. } else if (data.action == 'add' && person_idx == -1) {
  136. $scope._localAddAttendee(data.person, true);
  137. } else if (data.action == 'delete' && person_idx != -1) {
  138. $scope._localRemoveAttendee({person_id: data.person_id});
  139. }
  140. }
  141. );
  142. }
  143. }
  144. $scope.updateOrded = function(key) {
  145. var new_order = [key];
  146. var inv_key;
  147. if (key && key[0] === '-') {
  148. inv_key = key.substring(1);
  149. } else {
  150. inv_key = '-' + key;
  151. }
  152. angular.forEach($scope.personsOrder,
  153. function(value, idx) {
  154. if (value !== key && value !== inv_key) {
  155. new_order.push(value);
  156. }
  157. }
  158. );
  159. $scope.personsOrder = new_order;
  160. };
  161. // store a new Event or update an existing one
  162. $scope.save = function() {
  163. // avoid override of event.persons list.
  164. var this_event = angular.copy($scope.event);
  165. if (this_event.persons) {
  166. delete this_event.persons;
  167. }
  168. if (this_event._id === undefined) {
  169. $scope.event = Event.save(this_event);
  170. } else {
  171. $scope.event = Event.update(this_event);
  172. }
  173. $scope.eventForm.$setPristine(false);
  174. };
  175. $scope.calcAttendees = function() {
  176. if (!($scope.event && $scope.event.persons)) {
  177. $scope.countAttendees = 0;
  178. return;
  179. }
  180. var attendees = 0;
  181. angular.forEach($scope.event.persons, function(value, key) {
  182. if (value.attended && !value.cancelled) {
  183. attendees += 1;
  184. }
  185. });
  186. $scope.countAttendees = attendees;
  187. };
  188. /* Stuff to do when an attendee is added locally. */
  189. $scope._localAddAttendee = function(person, hideMessage) {
  190. if (!$scope.event.persons) {
  191. $scope.event.persons = [];
  192. }
  193. var person_idx = $scope.event.persons.findIndex(function(el, idx, array) {
  194. return person.person_id == el.person_id;
  195. });
  196. if (person_idx != -1) {
  197. $log.debug('person already present: not added');
  198. return false;
  199. }
  200. $scope.event.persons.push(person);
  201. };
  202. $scope._addAttendee = function(person) {
  203. person.person_id = person._id;
  204. person._id = $stateParams.id; // that's the id of the event, not the person.
  205. Event.addPerson(person, function() {
  206. $scope._localAddAttendee(person);
  207. });
  208. $scope.query = '';
  209. return person;
  210. };
  211. $scope._setAttended = function(person) {
  212. $scope.setPersonAttribute(person, 'attended', true, function() {
  213. var all_person_idx = $scope.allPersons.findIndex(function(el, idx, array) {
  214. return person.person_id == el.person_id;
  215. });
  216. if (all_person_idx != -1) {
  217. $scope.allPersons.splice(all_person_idx, 1);
  218. }
  219. }, true);
  220. };
  221. $scope.fastAddAttendee = function(person, isNew) {
  222. $log.debug('EventDetailsCtrl.fastAddAttendee.person:');
  223. $log.debug(person);
  224. if (isNew) {
  225. var personObj = new Person(person);
  226. personObj.$save(function(p) {
  227. person = $scope._addAttendee(angular.copy(p));
  228. $scope._setAttended(person);
  229. $scope.newPerson = {};
  230. });
  231. } else {
  232. person = $scope._addAttendee(angular.copy(person));
  233. $scope._setAttended(person);
  234. }
  235. };
  236. $scope.openQuickAddTicket = function(_id) {
  237. var modalInstance = $uibModal.open({
  238. templateUrl: 'modal-quick-add-ticket.html',
  239. controller: 'EventTicketsCtrl'
  240. });
  241. modalInstance.result.then(function(x) {
  242. $scope.event = Event.get($stateParams);
  243. });
  244. };
  245. $scope.addRegisteredPerson = function(person) {
  246. $scope.fastAddAttendee(person, true);
  247. };
  248. $scope.setPersonAttribute = function(person, key, value, callback, hideMessage) {
  249. $log.debug('EventDetailsCtrl.setPersonAttribute.event_id: ' + $stateParams.id);
  250. $log.debug('EventDetailsCtrl.setPersonAttribute.person_id: ' + person.person_id);
  251. $log.debug('EventDetailsCtrl.setPersonAttribute.key: ' + key + ' value: ' + value);
  252. var data = {_id: $stateParams.id, person_id: person.person_id};
  253. data[key] = value;
  254. Event.updatePerson(data,
  255. function(data) {
  256. if (!(data && data.person_id && data.person)) {
  257. return;
  258. }
  259. var person_idx = $scope.event.persons.findIndex(function(el, idx, array) {
  260. return data.person_id == el.person_id;
  261. });
  262. if (person_idx == -1) {
  263. $log.warn('unable to find person_id ' + person_id);
  264. return;
  265. }
  266. if ($scope.event.persons[person_idx] != data.person) {
  267. $scope.event.persons[person_idx] = data.person;
  268. }
  269. if (callback) {
  270. callback(data);
  271. }
  272. if (key === 'attended' && !hideMessage) {
  273. var msg = {};
  274. if (value) {
  275. msg.message = '' + person.name + ' ' + person.surname + ' successfully added to event ' + $scope.event.title;
  276. } else {
  277. msg.message = '' + person.name + ' ' + person.surname + ' successfully removed from event ' + $scope.event.title;
  278. msg.isError = true;
  279. }
  280. $scope.showMessage(msg);
  281. }
  282. });
  283. };
  284. $scope.setPersonAttributeAndRefocus = function(person, key, value) {
  285. $scope.setPersonAttribute(person, key, value);
  286. $scope.query = '';
  287. };
  288. /* Stuff to do when an attendee is removed locally. */
  289. $scope._localRemoveAttendee = function(person) {
  290. $log.debug('_localRemoveAttendee');
  291. $log.debug(person);
  292. if (!(person && person.person_id && $scope.event.persons)) {
  293. return;
  294. }
  295. var person_idx = $scope.event.persons.findIndex(function(el, idx, array) {
  296. return person.person_id == el.person_id;
  297. });
  298. if (person_idx == -1) {
  299. $log.warn('unable to find and delete person_id ' + person.person_id);
  300. return;
  301. }
  302. var removed_person = $scope.event.persons.splice(person_idx, 1);
  303. // to be used to populate allPersons, if needed.
  304. if (removed_person.length) {
  305. person = removed_person[0];
  306. }
  307. var all_person_idx = $scope.allPersons.findIndex(function(el, idx, array) {
  308. return person.person_id == el._id;
  309. });
  310. if (all_person_idx == -1 && person.person_id) {
  311. $scope.allPersons.push(person);
  312. }
  313. };
  314. $scope.removeAttendee = function(person) {
  315. Event.deletePerson({
  316. _id: $stateParams.id,
  317. person_id: person.person_id
  318. }, function() {
  319. $scope._localRemoveAttendee(person);
  320. });
  321. };
  322. $scope.saveForm = function(easyFormGeneratorModel) {
  323. $scope.event.formSchema = easyFormGeneratorModel;
  324. $scope.save();
  325. };
  326. $scope.showMessage = function(cfg) {
  327. $scope.message.show(cfg);
  328. };
  329. $scope.$on('$destroy', function() {
  330. $scope.EventUpdates && $scope.EventUpdates.close();
  331. });
  332. }]
  333. );
  334. eventManControllers.controller('EventTicketsCtrl', ['$scope', '$state', 'Event', 'EventTicket', 'Person', 'Setting', '$log', '$translate', '$rootScope',
  335. function ($scope, $state, Event, EventTicket, Person, Setting, $log, $translate, $rootScope) {
  336. $scope.message = {};
  337. $scope.event = {};
  338. $scope.ticket = {};
  339. $scope.formSchema = {};
  340. $scope.formData = {};
  341. $scope.dangerousActionsEnabled = false;
  342. $scope.formFieldsMap = {};
  343. $scope.formFieldsMapRev = {};
  344. if ($state.params.id) {
  345. $scope.event = Event.get({id: $state.params.id}, function(data) {
  346. if (!(data && data.formSchema)) {
  347. return;
  348. }
  349. $scope.formSchema = data.formSchema.edaFieldsModel;
  350. $scope.extractFormFields(data.formSchema.formlyFieldsModel);
  351. if ($state.params.ticket_id) {
  352. EventTicket.get({id: $state.params.id, ticket_id: $state.params.ticket_id}, function(data) {
  353. $scope.ticket = data;
  354. angular.forEach(data, function(value, key) {
  355. if (!$scope.formFieldsMapRev[key]) {
  356. return;
  357. }
  358. $scope.formData[$scope.formFieldsMapRev[key]] = value;
  359. });
  360. });
  361. }
  362. });
  363. }
  364. $scope.extractFormFields = function(formlyFieldsModel) {
  365. if (!formlyFieldsModel) {
  366. return;
  367. }
  368. angular.forEach(formlyFieldsModel, function(row, idx) {
  369. if (!row.className == 'row') {
  370. return;
  371. }
  372. angular.forEach(row.fieldGroup || [], function(item, idx) {
  373. if (!(item.key && item.templateOptions && item.templateOptions.label)) {
  374. return;
  375. }
  376. var value = item.templateOptions.label.toLowerCase();
  377. $scope.formFieldsMap[item.key] = value;
  378. $scope.formFieldsMapRev[value] = item.key;
  379. });
  380. });
  381. };
  382. $scope.addTicket = function(person) {
  383. var personObj = new Person(person);
  384. personObj.$save(function(p) {
  385. person.person_id = p._id;
  386. person._id = $state.params.id; // that's the id of the event, not the person.
  387. EventTicket.add(person, function(ticket) {
  388. $log.debug(ticket);
  389. if (!$state.is('event.tickets')) {
  390. $state.go('event.ticket.edit', {id: $scope.event._id, ticket_id: ticket._id});
  391. } else if ($scope.$close) {
  392. $scope.$close();
  393. }
  394. });
  395. });
  396. };
  397. $scope.updateTicket = function(ticket, cb) {
  398. var data = angular.copy(ticket);
  399. data.ticket_id = data._id;
  400. data._id = $state.params.id;
  401. EventTicket.update(data, function(t) {
  402. if (cb) {
  403. cb(t);
  404. }
  405. });
  406. };
  407. $scope.submitForm = function(dataModelSubmitted) {
  408. angular.forEach(dataModelSubmitted, function(value, key) {
  409. key = $scope.formFieldsMap[key] || key;
  410. $scope.ticket[key] = value;
  411. });
  412. if (!$state.params.ticket_id) {
  413. $scope.addTicket($scope.ticket);
  414. } else {
  415. $scope.updateTicket($scope.ticket);
  416. }
  417. };
  418. $scope.toggleTicket = function() {
  419. if (!$scope.ticket._id) {
  420. return;
  421. }
  422. $scope.ticket.cancelled = !$scope.ticket.cancelled;
  423. $scope.updateTicket($scope.ticket, function() {
  424. $scope.dangerousActionsEnabled = false;
  425. });
  426. };
  427. $scope.cancelForm = function() {
  428. if (!$state.is('event.tickets')) {
  429. $state.go('events');
  430. } else if ($scope.$close) {
  431. $scope.$close();
  432. }
  433. };
  434. }]
  435. );
  436. eventManControllers.controller('PersonsListCtrl', ['$scope', 'Person', 'Setting', '$uibModal', '$translate', '$rootScope',
  437. function ($scope, Person, Setting, $uibModal, $translate, $rootScope) {
  438. $scope.persons = Person.all();
  439. $scope.personsOrder = ["name", "surname"];
  440. $scope.customFields = Setting.query({setting: 'person_custom_field',
  441. in_persons_list: true});
  442. $scope.confirm_delete = 'Do you really want to delete this person?';
  443. $rootScope.$on('$translateChangeSuccess', function () {
  444. $translate('Do you really want to delete this person?').then(function (translation) {
  445. $scope.confirm_delete = translation;
  446. });
  447. });
  448. $scope.updateOrded = function(key) {
  449. var new_order = [key];
  450. var inv_key;
  451. if (key && key[0] === '-') {
  452. inv_key = key.substring(1);
  453. } else {
  454. inv_key = '-' + key;
  455. }
  456. angular.forEach($scope.personsOrder,
  457. function(value, idx) {
  458. if (value !== key && value !== inv_key) {
  459. new_order.push(value);
  460. }
  461. }
  462. );
  463. $scope.personsOrder = new_order;
  464. };
  465. $scope.setAttribute = function(person, key, value) {
  466. var data = {_id: person._id};
  467. data[key] = value;
  468. Person.update(data, function() {
  469. $scope.persons = Person.all();
  470. });
  471. };
  472. $scope.remove = function(_id) {
  473. var modalInstance = $uibModal.open({
  474. scope: $scope,
  475. templateUrl: 'modal-confirm-action.html',
  476. controller: 'ModalConfirmInstanceCtrl',
  477. resolve: {
  478. message: function() { return $scope.confirm_delete; }
  479. }
  480. });
  481. modalInstance.result.then(function() {
  482. Person.remove({'id': _id}, function() {
  483. $scope.persons = Person.all();
  484. }
  485. );
  486. });
  487. };
  488. }]
  489. );
  490. eventManControllers.controller('PersonDetailsCtrl', ['$scope', '$stateParams', 'Person', 'Event', 'Setting', '$log',
  491. function ($scope, $stateParams, Person, Event, Setting, $log) {
  492. $scope.personsOrderProp = 'name';
  493. $scope.eventsOrderProp = '-begin_date';
  494. $scope.addToEvent = '';
  495. $scope.customFields = Setting.query({setting: 'person_custom_field',
  496. in_persons_list: true});
  497. if ($stateParams.id) {
  498. $scope.person = Person.get($stateParams);
  499. $scope.events = Person.getEvents({_id: $stateParams.id, all: true});
  500. } else {
  501. $scope.events = Event.all();
  502. }
  503. // store a new Person or update an existing one
  504. $scope.save = function() {
  505. if ($scope.person._id === undefined) {
  506. $scope.person = new Person($scope.person);
  507. $scope.person.$save(function(person) {
  508. if ($scope.addToEvent) {
  509. var data = angular.copy(person);
  510. data.person_id = data._id;
  511. data._id = $scope.addToEvent;
  512. data.attended = false;
  513. Event.addPerson(data);
  514. }
  515. });
  516. } else {
  517. $scope.person = Person.update($scope.person, function(data) {
  518. if ($scope.addToEvent) {
  519. var data = angular.copy($scope.person);
  520. data._id = $scope.addToEvent;
  521. data.person_id = $scope.person._id;
  522. data.attended = false;
  523. Event.addPerson(data);
  524. }
  525. });
  526. }
  527. $scope.personForm.$setPristine(false);
  528. };
  529. $scope.setPersonAttributeAtEvent = function(evnt, key, value) {
  530. var attrs = {_id: evnt._id, person_id: $stateParams.id};
  531. attrs[key] = value;
  532. Event.updatePerson(attrs,
  533. function(data) {
  534. $scope.events = Person.getEvents({_id: $stateParams.id, all: true});
  535. }
  536. );
  537. };
  538. $scope.switchRegistered = function(evnt, person, add) {
  539. $log.debug('PersonDetailsCtrl.switchRegistered.event_id: ' + evnt._id);
  540. $log.debug('PersonDetailsCtrl.switchRegistered.person_id: ' + person._id);
  541. $log.debug('PersonDetailsCtrl.switchRegistered.add: ' + add);
  542. if (add) {
  543. var data = angular.copy(person);
  544. data._id = evnt._id;
  545. data.person_id = person._id;
  546. data.attended = false;
  547. Event.addPerson(data,
  548. function(data) {
  549. $scope.events = Person.getEvents({_id: $stateParams.id, all: true});
  550. }
  551. );
  552. } else {
  553. Event.deletePerson({_id: evnt._id, person_id: person._id},
  554. function(data) {
  555. $scope.events = Person.getEvents({_id: $stateParams.id, all: true});
  556. }
  557. );
  558. }
  559. };
  560. }]
  561. );
  562. eventManControllers.controller('LoginCtrl', ['$scope', '$rootScope', '$state', '$log', 'User',
  563. function ($scope, $rootScope, $state, $log, User) {
  564. $scope.loginData = {};
  565. $scope.register = function() {
  566. User.add($scope.newUser, function(data) {
  567. $scope.login($scope.newUser);
  568. });
  569. };
  570. $scope.login = function(loginData) {
  571. if (!loginData) {
  572. loginData = $scope.loginData;
  573. }
  574. User.login(loginData, function(data) {
  575. if (!data.error) {
  576. $rootScope.readInfo(function() {
  577. $rootScope.clearError();
  578. $state.go('events');
  579. });
  580. }
  581. });
  582. };
  583. $scope.logout = function() {
  584. User.logout({}, function(data) {
  585. if (!data.error) {
  586. $rootScope.readInfo(function() {
  587. $state.go('events');
  588. });
  589. }
  590. });
  591. };
  592. }]
  593. );
  594. eventManControllers.controller('FileUploadCtrl', ['$scope', '$log', '$upload', 'Event',
  595. function ($scope, $log, $upload, Event) {
  596. $scope.file = null;
  597. $scope.reply = {};
  598. $scope.events = Event.all();
  599. $scope.upload = function(file, url) {
  600. $log.debug("FileUploadCtrl.upload");
  601. $upload.upload({
  602. url: url,
  603. file: file,
  604. fields: {targetEvent: $scope.targetEvent}
  605. }).progress(function(evt) {
  606. var progressPercentage = parseInt(100.0 * evt.loaded / evt.total);
  607. $log.debug('progress: ' + progressPercentage + '%');
  608. }).success(function(data, status, headers, config) {
  609. $scope.file = null;
  610. $scope.reply = angular.fromJson(data);
  611. });
  612. };
  613. }]
  614. );