Left: | ||
Right: |
OLD | NEW |
---|---|
1 'use strict'; | 1 'use strict'; |
2 /** | 2 /** |
3 * Provides the main app class. | 3 * Provides the main app class. |
4 * | 4 * |
5 * @module app | 5 * @module app |
6 */ | 6 */ |
7 | 7 |
8 // Create a global for debug console access to YUI context. | 8 // Create a global for debug console access to YUI context. |
9 var yui; | 9 var yui; |
10 | 10 |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
318 | 318 |
319 }, | 319 }, |
320 | 320 |
321 /** | 321 /** |
322 * @method on_database_changed | 322 * @method on_database_changed |
323 */ | 323 */ |
324 on_database_changed: function(evt) { | 324 on_database_changed: function(evt) { |
325 Y.log(evt, 'debug', 'App: Database changed'); | 325 Y.log(evt, 'debug', 'App: Database changed'); |
326 | 326 |
327 var self = this; | 327 var self = this; |
328 var active = this.get('activeView'); | |
328 | 329 |
329 // Compare endpoints map against db to see if it needs to be changed. | 330 // Compare endpoints map against db to see if it needs to be changed. |
330 var updateNeeded = this.db.services.some(function(service) { | 331 var updateNeeded = this.db.services.some(function(service) { |
331 return (self.serviceEndpoints[service.get('id')] === undefined); | 332 return (self.serviceEndpoints[service.get('id')] === undefined); |
332 }); | 333 }); |
333 | 334 |
334 // If there are new services in the DB, pull an updated endpoints map. | 335 // If there are new services in the DB, pull an updated endpoints map. |
335 if (updateNeeded) { | 336 if (updateNeeded) { |
336 this.updateEndpoints(); | 337 this.updateEndpoints(); |
337 } else { | 338 } else { |
338 // Check to see if any services have been removed (if there are, and | 339 // Check to see if any services have been removed (if there are, and |
339 // new ones also, updateEndpoints will replace the whole map, so only | 340 // new ones also, updateEndpoints will replace the whole map, so only |
340 // do this if needed). | 341 // do this if needed). |
341 Y.Object.each(this.serviceEndpoints, function(key, value, obj) { | 342 Y.Object.each(this.serviceEndpoints, function(key, value, obj) { |
342 if (self.db.services.getById(key) === null) { | 343 if (self.db.services.getById(key) === null) { |
343 delete(self.serviceEndpoints[key]); | 344 delete(self.serviceEndpoints[key]); |
344 } | 345 } |
345 }); | 346 }); |
346 } | 347 } |
347 | 348 |
348 // Redispatch to current view to update. | 349 // Redispatch to current view to update. |
349 this.dispatch(); | 350 if (active && active.name === 'EnvironmentView') { |
351 active.update(); | |
gary.poster
2013/01/20 15:58:45
cool
bcsaller
2013/01/21 15:40:31
Thanks, cutting to this should actually be a big i
| |
352 } else { | |
353 this.dispatch(); | |
354 } | |
350 }, | 355 }, |
351 | 356 |
352 /** | 357 /** |
353 * When services are added we update endpoints here. | 358 * When services are added we update endpoints here. |
354 * | 359 * |
355 * @method updateEndpoints | 360 * @method updateEndpoints |
356 */ | 361 */ |
357 updateEndpoints: function(callback) { | 362 updateEndpoints: function(callback) { |
358 var self = this; | 363 var self = this; |
359 | 364 |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
850 'juju-views', | 855 'juju-views', |
851 'juju-view-login', | 856 'juju-view-login', |
852 'io', | 857 'io', |
853 'json-parse', | 858 'json-parse', |
854 'app-base', | 859 'app-base', |
855 'app-transitions', | 860 'app-transitions', |
856 'base', | 861 'base', |
857 'node', | 862 'node', |
858 'model'] | 863 'model'] |
859 }); | 864 }); |
OLD | NEW |