Revision 54235b2e snf-app/synnefo/ui/static/snf/js/ui/web/ui_create_view.js
b/snf-app/synnefo/ui/static/snf/js/ui/web/ui_create_view.js | ||
---|---|---|
167 | 167 |
this.selected_type = "system"; |
168 | 168 |
this.selected_categories = []; |
169 | 169 |
this.images = []; |
170 |
this.custom_images = []; |
|
170 | 171 |
|
171 | 172 |
// update |
172 | 173 |
this.update_images(); |
... | ... | |
191 | 192 |
update_images: function() { |
192 | 193 |
this.images = storage.images.active(); |
193 | 194 |
this.images_ids = _.map(this.images, function(img){return img.id}); |
194 |
if (this.selected_type == "custom") { this.images = []; this.images_ids = []; } |
|
195 |
|
|
195 |
if (this.selected_type == "custom") { |
|
196 |
this.update_custom_images(); |
|
197 |
} |
|
196 | 198 |
return this.images; |
197 | 199 |
}, |
198 | 200 |
|
201 |
update_custom_images: function() { |
|
202 |
this.images = storage.glance.images.active(); |
|
203 |
this.images_ids = _.map(this.images, function(img){return img.id}); |
|
204 |
}, |
|
205 |
|
|
199 | 206 |
update_layout: function() { |
200 | 207 |
this.select_type(this.selected_type); |
201 | 208 |
}, |
... | ... | |
225 | 232 |
}, |
226 | 233 |
|
227 | 234 |
select_type: function(type) { |
235 |
|
|
228 | 236 |
this.selected_type = type; |
229 | 237 |
this.types.removeClass("selected"); |
230 | 238 |
this.types.filter("#type-select-" + this.selected_type).addClass("selected"); |
239 |
|
|
240 |
var check_load_date = new Date() - (this.last_custom_load || 0); |
|
241 |
if (type == "custom" && check_load_date > 30000) { |
|
231 | 242 |
|
232 |
this.reset_categories(); |
|
233 |
this.update_images(); |
|
234 |
this.reset_images(); |
|
235 |
this.select_image(); |
|
243 |
if (snf.storage.glance.images.length == 0) { |
|
244 |
this.$(".images-list-cont .empty").hide(); |
|
245 |
this.$(".images-list-cont .loading").show(); |
|
246 |
this.$(".images-list-cont .images-list").hide(); |
|
247 |
} |
|
248 |
|
|
249 |
this.show_list_loading(); |
|
250 |
snf.storage.glance.images.fetch({refresh:true, success: _.bind(function(){ |
|
251 |
this.last_custom_load = new Date(); |
|
252 |
this.$(".images-list-cont .loading").hide(); |
|
253 |
this.reset_categories(); |
|
254 |
this.update_images(); |
|
255 |
this.reset_images(); |
|
256 |
this.select_image(); |
|
257 |
this.$(".images-list-cont .images-list").show(); |
|
258 |
this.hide_list_loading(); |
|
259 |
}, this)}); |
|
260 |
} else { |
|
261 |
this.reset_categories(); |
|
262 |
this.update_images(); |
|
263 |
this.reset_images(); |
|
264 |
this.select_image(); |
|
265 |
this.hide_list_loading(); |
|
266 |
} |
|
267 |
|
|
268 |
}, |
|
269 |
|
|
270 |
show_list_loading: function() { |
|
271 |
this.$(".images-list-cont").addClass("loading"); |
|
272 |
}, |
|
273 |
|
|
274 |
hide_list_loading: function() { |
|
275 |
this.$(".images-list-cont").removeClass("loading"); |
|
236 | 276 |
}, |
237 | 277 |
|
238 | 278 |
select_image: function(image) { |
Also available in: Unified diff