Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* | 1 /* |
2 This file is part of the Juju GUI, which lets users view and manage Juju | 2 This file is part of the Juju GUI, which lets users view and manage Juju |
3 environments within a graphical interface (https://launchpad.net/juju-gui). | 3 environments within a graphical interface (https://launchpad.net/juju-gui). |
4 Copyright (C) 2012-2013 Canonical Ltd. | 4 Copyright (C) 2012-2013 Canonical Ltd. |
5 | 5 |
6 This program is free software: you can redistribute it and/or modify it under | 6 This program is free software: you can redistribute it and/or modify it under |
7 the terms of the GNU Affero General Public License version 3, as published by | 7 the terms of the GNU Affero General Public License version 3, as published by |
8 the Free Software Foundation. | 8 the Free Software Foundation. |
9 | 9 |
10 This program is distributed in the hope that it will be useful, but WITHOUT | 10 This program is distributed in the hope that it will be useful, but WITHOUT |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 instance[key] = value; | 71 instance[key] = value; |
72 }); | 72 }); |
73 // Lazy model lists don't fire change events | 73 // Lazy model lists don't fire change events |
74 list.fire('change'); | 74 list.fire('change'); |
75 } | 75 } |
76 } | 76 } |
77 } | 77 } |
78 else if (action === 'remove') { | 78 else if (action === 'remove') { |
79 if (exists) { | 79 if (exists) { |
80 list.remove(instance); | 80 list.remove(instance); |
81 if (list.name === 'serviceList') { | |
82 instance.destroy(); | |
jeff.pihach
2013/09/27 19:19:25
Whenever we remove a service from a list we now de
gary.poster
2013/09/27 19:46:37
Cool. This sounds like it is worth a comment in t
jeff.pihach
2013/09/27 20:13:39
Done.
| |
83 } | |
81 } | 84 } |
82 } else { | 85 } else { |
83 console.warn('Unknown change kind in _process_delta:', action); | 86 console.warn('Unknown change kind in _process_delta:', action); |
84 } | 87 } |
85 return instance; | 88 return instance; |
86 }; | 89 }; |
87 | 90 |
88 /** | 91 /** |
89 Utility method to return the services involved in the delta. | 92 Utility method to return the services involved in the delta. |
90 | 93 |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
373 @type {string} | 376 @type {string} |
374 */ | 377 */ |
375 upgrade_to: {}, | 378 upgrade_to: {}, |
376 aggregated_status: {}, | 379 aggregated_status: {}, |
377 /** | 380 /** |
378 The original name from the Charm | 381 The original name from the Charm |
379 | 382 |
380 @attribute packageName | 383 @attribute packageName |
381 @type {String} | 384 @type {String} |
382 */ | 385 */ |
383 packageName: {} | 386 packageName: { |
387 'getter': function(value) { | |
388 if (value) { | |
389 return value; | |
390 } else { | |
391 // Because the packageName is not set if the | |
392 // model was created from the core delta. | |
393 var charm = this.get('charm'); | |
394 // If there is no charm as well, well you have bigger problems :) | |
395 // but this helps so that we don't need to provide charm data | |
396 // for every test suite. | |
397 if (charm) { | |
398 charm = charm.split('/'); | |
399 charm = charm[charm.length - 1].split('-')[0]; | |
400 } | |
401 return charm || undefined; | |
402 } | |
403 } | |
404 } | |
384 } | 405 } |
385 }); | 406 }); |
386 models.Service = Service; | 407 models.Service = Service; |
387 | 408 |
388 var ServiceList = Y.Base.create('serviceList', Y.ModelList, [], { | 409 var ServiceList = Y.Base.create('serviceList', Y.ModelList, [], { |
389 model: Service, | 410 model: Service, |
390 | 411 |
391 /** | 412 /** |
392 Return a list of visible model instances. | 413 Return a list of visible model instances. |
393 | 414 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
523 // someone else watching the GUI as a service's charm changes, differ in | 544 // someone else watching the GUI as a service's charm changes, differ in |
524 // the amount of information the GUI has originally. By setting this | 545 // the amount of information the GUI has originally. By setting this |
525 // flag, both cases can react in the same way. | 546 // flag, both cases can react in the same way. |
526 if (flags.upgradeCharm && oldModelCharm && | 547 if (flags.upgradeCharm && oldModelCharm && |
527 oldModelCharm !== instance.charmUrl && !service.get('charmChanged')) { | 548 oldModelCharm !== instance.charmUrl && !service.get('charmChanged')) { |
528 service.set('charmChanged', true); | 549 service.set('charmChanged', true); |
529 } | 550 } |
530 // Some tests add units without creating a service so we need to check | 551 // Some tests add units without creating a service so we need to check |
531 // for a valid service here. | 552 // for a valid service here. |
532 if (service) { | 553 if (service) { |
533 _process_delta(service.get('units'), action, data, {}); | 554 var units = service.get('units'); |
555 _process_delta(units, action, data, {}); | |
556 units.fire('deltaChange', { service: service }); | |
jeff.pihach
2013/09/27 19:19:25
Because units are POJO's they don't fire change ev
gary.poster
2013/09/27 19:46:37
Nice! we could include the units themselves too, o
jeff.pihach
2013/09/27 20:13:39
I was thinking about that, but they are readily av
| |
534 } else { | 557 } else { |
535 // fixTests | 558 // fixTests |
536 console.error('Units added without matching Service'); | 559 console.error('Units added without matching Service'); |
537 } | 560 } |
538 }, | 561 }, |
539 | 562 |
540 _setDefaultsAndCalculatedValues: function(obj) { | 563 _setDefaultsAndCalculatedValues: function(obj) { |
541 var raw = obj.id.split('/'); | 564 var raw = obj.id.split('/'); |
542 obj.service = raw[0]; | 565 obj.service = raw[0]; |
543 obj.number = parseInt(raw[1], 10); | 566 obj.number = parseInt(raw[1], 10); |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1192 'datasource-jsonschema', | 1215 'datasource-jsonschema', |
1193 'io-base', | 1216 'io-base', |
1194 'json-parse', | 1217 'json-parse', |
1195 'juju-delta-handlers', | 1218 'juju-delta-handlers', |
1196 'juju-endpoints', | 1219 'juju-endpoints', |
1197 'juju-view-utils', | 1220 'juju-view-utils', |
1198 'juju-charm-models', | 1221 'juju-charm-models', |
1199 'promise' | 1222 'promise' |
1200 ] | 1223 ] |
1201 }); | 1224 }); |
OLD | NEW |