PageSourceSearch

https://launio.es/site/236621/js/entregascontroller.js

js launio.es collected 2026-09-26 19:43:05 UTC 4,880 bytes, 161 lines download raw bytes

1console.log("entregascontroller.js loaded");
2
3angular.module('chilApp')
4.config(function ($interpolateProvider) {
5  $interpolateProvider.startSymbol('{[{').endSymbol('}]}');
6})
7.factory('dataManagementApi', function($http, $q){
8  
9  return {
10    browse: function(postId) { 
11      return $http.get('/api/post/' + postId )
12      .then(function(r){
13        return r.data;
14      });
15    },
16    
17    me: function() { 
18      return $http.get('/api/actor/me')
19      .then(function(r){
20        // console.log(r)
21        if (r.statusText !== 'OK') {
22            return null;
23          } else {
24            return r.data;
25          }
26      	},
27        function(error){
28        	return null;
29      	}
30       );
31    },
32    
33    encode: function(id,objectType) { 
34    	return $http.get('http://api2.chil.me/id/encode?id=' +
35                     String(id) + '&type=' + objectType )
36      .then(function(r){
37        return r.data;
38      });
39    },
40    
41    getData: function(where) {
42      var where2 = btoa(where)  //90.173.7.173:8080
43      
44      return $http.get('https://api2.chil.me/bd/YLO7ZNRRQXWL/table/YLO7BHSC75M0/data?where=%22' + String(where2) + '%22',
45       {headers: {'Authorization': 'Bearer rXERk7huhzjS1L8wjQ7bV4KLShDk1K-D4eQnmyhqVpcgEv45vHntqZyDesdKt_KMUdNe9GuNIHSAde8UjMsqTyUkGzzlvHlsMb8rJuWPtTeAa8oDAJMoeewGFKVemP7N_DNdAbhL78BtbDS7gWgOb0C24EY22AEDpIFHcl4lDQb1nOg5E8SELXYKeRdB-zRdyPPkjKualQHm5lp8FkqjEwm_iSCRBA8wlJvyelD6E_NHqQ8EeKSSjhRrZHqyh9vvhyKhqEDYurqsXV3vhvduSU1GfXF0yAAYot4G9kd_DaqXu2KcciPErhWJIszxLGrZ'}})
46      .then(function(r){
47        return r.data;
48      });
49      
50      /*
51      return $http.get('http://90.173.7.173:8080/bd/YLO7ZNRRQXWL/table/XK98BHSV84L2/data?where=%22' + String(where2) + '%22',
52       {headers: {'Authorization': 'Bearer leyBOdwxRa96i80jicyZpI1iRDrMED0oXeVrvFML7NT9lcIri-gZBd-GB0v41jvFoHXhePFA_wMSMrPUIPqxUQ8R8jEfcKoiHQpfFMSWaXC19YxmcZFog2vvUMD6kH-yJOEC3Kvowz-H4iTYiokKRPsVCNvp8xwCIgM5GLYU-gIPk-4wt1uBpz9FlHs5-k14EyhGkc85VqhJCb2BRyTmTUZlKtJHVNzd46EjZ6jm313Sn7NBjiG7jN453wORgPPgmAMNhQdT6zYwM5Q2HEXVc0DXR1BU2plBcMepdt2nClf6NuVyqIHEHTD_ditqPZHr'}})
53      .then(function(r){
54        return r.data;
55      });
56      */
57    },
58    
59    /*
60    getData: function(where) { 
61    	return $http.get('//api2.chil.me/bd/YLO7ZNRRQXWL/table/YLO7BHSC75M0/data?where=%22' + where + '%22' +)
62      .then(function(r){
63    		console.log(r);
64        return r.data;
65      });
66    },    
67    */
68  }
69})
70.directive('checkList', function() {
71  return {
72    scope: {
73      list: '=checkList',
74      value: '@'
75    },
76    link: function(scope, elem, attrs) {
77      var handler = function(setup) {
78        var checked = elem.prop('checked');
79				
80        if (scope.list[attrs.name] === null || scope.list[attrs.name] === undefined)
81        	scope.list[attrs.name] = []; 
82        
83        var index = scope.list[attrs.name].indexOf(scope.value);
84
85        if (checked && index == -1) {
86          if (setup) elem.prop('checked', false);
87          else scope.list[attrs.name].push(scope.value);
88        } else if (!checked && index != -1) {
89          if (setup) elem.prop('checked', true);
90          else scope.list[attrs.name].splice(index, 1);
91        }
92      };
93
94      var setupHandler = handler.bind(null, true);
95      var changeHandler = handler.bind(null, false);
96
97      elem.bind('change', function() {
98        scope.$apply(changeHandler);
99      });
100      scope.$watch('list', setupHandler, true);
101    }
102  };
103})
104.controller("EntregasController", function($scope, $window, $sce, $timeout, siteId, dataManagementApi){
105  var scope = this; 
106  scope.actor = {displayName: 'Centro no definido'}
107  scope.siteId = 444;
108  scope.siteUid = 'XXXXXXXXXXXX';
109  scope.actorUid = 'XXXXXXXXXXXX';
110	scope.items = null;
111  scope.isLoading = false;
112
113  if (typeof _userId !== 'undefined') {scope.actorId = _userId;}
114
115  if (typeof _siteId !== 'undefined') {scope.siteId = _siteId;}
116
117
118  scope.init = function () {
119    scope.load(postId);
120
121  };
122  
123
124  scope.load = function(){ 
125    // console.log('Cargando entregas...');
126    scope.isLoading = true;
127    
128    dataManagementApi.me()
129    .then(function(r){
130      scope.actor = r;
131      // console.log(scope.actor)
132      if (scope.actor !== null) {
133        return dataManagementApi.encode(scope.actor.id,'ACTOR')
134      } else {
135        return new Promise(function(resolve,reject){ return resolve(''); } );
136      }
137    })
138    .then(function(r){
139      scope.actorUid = r;
140      console.log(scope.actorUid)
141      return dataManagementApi.getData('{ "_state": "Activo" , "centro.uid": "' + scope.actorUid + '"}')
142    })    
143    .then(function(r){
144      // console.log(r);
145      scope.items = r;
146      scope.items.sort(function (a, b) { return a.fecha > b.fecha; });
147      scope.isLoading = false;
148    });
149    
150    dataManagementApi.encode(scope.siteId,'GROUP')
151    .then(function(r){
152      scope.siteUid = r;
153    });
154
155  };
156  
157  scope.load();
158  
159})
160
161

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.