You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839
  1. /**
  2. * Created by robin on 11/21/15.
  3. */
  4. (function () {
  5. 'use strict';
  6. angular.module('camotionAdmin')
  7. .factory('HelperService', ['HostsService', 'CamerasService', '$q', function (HostsService, CamerasService, $q) {
  8. var HelperService = {};
  9. HelperService.getForeignEntities = function (promise) {
  10. var defer = $q.defer();
  11. HostsService.getAll({}, promise).then(function (hosts) {
  12. var hostsArray = {};
  13. for (var i = 0; i < hosts.Data.length; ++i) {
  14. var host = hosts.Data[i];
  15. hostsArray[host.Id] = host;
  16. }
  17. CamerasService.getAllTypes(promise).then(function(types)
  18. {
  19. var typesArray = {};
  20. for (var i = 0; i < types.Data.length; ++i) {
  21. var type = types.Data[i];
  22. typesArray[type.Id] = type;
  23. }
  24. defer.resolve({
  25. hosts: hostsArray,
  26. entityTypes: typesArray
  27. });
  28. }, defer.reject);
  29. }, defer.reject);
  30. return defer.promise;
  31. };
  32. return HelperService;
  33. }]);
  34. })();