Left: | ||
Right: |
OLD | NEW |
---|---|
1 'use strict'; | 1 'use strict'; |
2 | 2 |
3 /** | 3 /** |
4 * The database models. | 4 * The database models. |
5 * | 5 * |
6 * @module models | 6 * @module models |
7 */ | 7 */ |
8 | 8 |
9 YUI.add('juju-models', function(Y) { | 9 YUI.add('juju-models', function(Y) { |
10 | 10 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 ATTRS: { | 84 ATTRS: { |
85 name: {}, | 85 name: {}, |
86 provider: {}, | 86 provider: {}, |
87 annotations: { | 87 annotations: { |
88 valueFn: function() {return {};} | 88 valueFn: function() {return {};} |
89 } | 89 } |
90 } | 90 } |
91 }); | 91 }); |
92 models.Environment = Environment; | 92 models.Environment = Environment; |
93 | 93 |
94 var Service = Y.Base.create('service', Y.Model, [], {}, { | 94 var ALIVE = 'alive'; |
95 | |
96 var Service = Y.Base.create('service', Y.Model, [], { | |
97 | |
98 /** | |
99 Return true if this service life is "alive", false otherwise. | |
benji
2013/04/17 12:37:59
It might be nice to explain (ether here or in "ali
gary.poster
2013/04/17 12:54:26
+1
frankban
2013/04/17 13:39:01
Done.
| |
100 | |
101 @method isAlive | |
102 @return {Boolean} Whether this service is alive. | |
103 */ | |
104 isAlive: function() { | |
105 return this.get('life') === ALIVE; | |
106 } | |
107 | |
108 }, { | |
95 ATTRS: { | 109 ATTRS: { |
96 displayName: { | 110 displayName: { |
97 /** | 111 /** |
98 Dynamically calculate a display name that accounts for Juju Core name | 112 Dynamically calculate a display name that accounts for Juju Core name |
99 prefixes. | 113 prefixes. |
100 */ | 114 */ |
101 getter: function() { | 115 getter: function() { |
102 return this.get('id').replace('service-', ''); | 116 return this.get('id').replace('service-', ''); |
103 } | 117 } |
104 }, | 118 }, |
105 name: {}, | 119 name: {}, |
106 charm: {}, | 120 charm: {}, |
107 config: {}, | 121 config: {}, |
108 constraints: {}, | 122 constraints: {}, |
109 exposed: { | 123 exposed: { |
110 value: false | 124 value: false |
111 }, | 125 }, |
112 subordinate: { | 126 subordinate: { |
113 value: false | 127 value: false |
114 }, | 128 }, |
115 pending: { | 129 pending: { |
116 value: false | 130 value: false |
117 }, | 131 }, |
132 life: { | |
133 value: ALIVE | |
134 }, | |
118 unit_count: {}, | 135 unit_count: {}, |
119 aggregated_status: {} | 136 aggregated_status: {} |
120 } | 137 } |
121 }); | 138 }); |
122 models.Service = Service; | 139 models.Service = Service; |
123 | 140 |
124 var ServiceList = Y.Base.create('serviceList', Y.ModelList, [], { | 141 var ServiceList = Y.Base.create('serviceList', Y.ModelList, [], { |
125 model: Service, | 142 model: Service, |
126 | 143 |
144 /** | |
145 Return a list of alive model instances. | |
146 | |
147 @method alive | |
148 @return {Y.ModelList} The model instances having life === 'alive'. | |
149 */ | |
150 alive: function() { | |
151 return this.filter({asList: true}, function(model) { | |
152 return model.isAlive(); | |
153 }); | |
154 }, | |
155 | |
127 process_delta: function(action, data) { | 156 process_delta: function(action, data) { |
128 _process_delta(this, action, data, {exposed: false}); | 157 _process_delta(this, action, data, {exposed: false}); |
129 } | 158 } |
130 }, { | 159 }, { |
131 ATTRS: { | 160 ATTRS: { |
132 } | 161 } |
133 }); | 162 }); |
134 models.ServiceList = ServiceList; | 163 models.ServiceList = ServiceList; |
135 | 164 |
136 // This model is barely used. Units are in a lazy model list, so we | 165 // This model is barely used. Units are in a lazy model list, so we |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
695 'datasource-io', | 724 'datasource-io', |
696 'datasource-jsonschema', | 725 'datasource-jsonschema', |
697 'io-base', | 726 'io-base', |
698 'json-parse', | 727 'json-parse', |
699 'juju-delta-handlers', | 728 'juju-delta-handlers', |
700 'juju-endpoints', | 729 'juju-endpoints', |
701 'juju-view-utils', | 730 'juju-view-utils', |
702 'juju-charm-models' | 731 'juju-charm-models' |
703 ] | 732 ] |
704 }); | 733 }); |
OLD | NEW |