Revision 820ef2f0 ui/static/snf/js/ui/web/ui_create_view.js
b/ui/static/snf/js/ui/web/ui_create_view.js | ||
---|---|---|
64 | 64 |
initialize: function(view) { |
65 | 65 |
this.parent = view; |
66 | 66 |
this.el = view.$("div.create-step-cont.step-" + this.step); |
67 |
this.header = view.$(".subheader .step-" + this.step);
|
|
67 |
this.header = this.$(".step-header .step-" + this.step);
|
|
68 | 68 |
this.view_id = "create_step_" + this.step; |
69 | 69 |
|
70 | 70 |
views.CreateVMStepView.__super__.initialize.apply(this); |
... | ... | |
74 | 74 |
// show current |
75 | 75 |
this.el.show(); |
76 | 76 |
this.header.addClass("current"); |
77 |
this.header.show(); |
|
77 | 78 |
this.update_layout(); |
78 | 79 |
}, |
79 | 80 |
|
... | ... | |
86 | 87 |
initialize: function() { |
87 | 88 |
views.CreateImageSelectView.__super__.initialize.apply(this, arguments); |
88 | 89 |
|
89 |
this.predefined = this.$(".predefined-images ul"); |
|
90 |
this.custom = this.$(".predefined-images ul"); |
|
91 |
this.selected_image = undefined; |
|
92 |
this.reset_images(); |
|
90 |
// elements |
|
91 |
this.images_list = this.$(".images-list-cont ul"); |
|
92 |
this.image_details = this.$(".images-info-cont"); |
|
93 |
this.image_details_desc = this.$(".images-info-cont .description p"); |
|
94 |
this.image_details_title = this.$(".images-info-cont h4"); |
|
95 |
this.image_details_size = this.$(".images-info-cont .size p"); |
|
96 |
this.image_details_os = this.$(".images-info-cont .os p"); |
|
97 |
this.image_details_kernel = this.$(".images-info-cont .kernel p"); |
|
98 |
this.image_details_gui = this.$(".images-info-cont .gui p"); |
|
99 |
|
|
100 |
this.types = this.$(".type-filter li"); |
|
101 |
this.categories_list = this.$(".category-filters"); |
|
102 |
|
|
103 |
// params initialization |
|
104 |
this.type_selections = ["system", "custom"] |
|
105 |
this.selected_type = "system"; |
|
106 |
this.selected_categories = []; |
|
107 |
this.images = []; |
|
108 |
|
|
109 |
// update |
|
110 |
this.update_images(); |
|
111 |
|
|
112 |
// handlers initialization |
|
113 |
this.init_handlers(); |
|
114 |
this.init_position(); |
|
115 |
}, |
|
116 |
|
|
117 |
init_position: function() { |
|
118 |
//this.el.css({position: "absolute"}); |
|
119 |
//this.el.css({top:"10px"}) |
|
120 |
}, |
|
121 |
|
|
122 |
init_handlers: function() { |
|
123 |
var self = this; |
|
124 |
this.types.live("click", function() { |
|
125 |
self.select_type($(this).attr("id").replace("type-select-","")); |
|
126 |
}) |
|
127 |
}, |
|
128 |
|
|
129 |
update_images: function() { |
|
130 |
this.images = storage.images.active(); |
|
131 |
this.images_ids = _.map(this.images, function(img){return img.id}); |
|
132 |
if (this.selected_type == "custom") { this.images = []; this.images_ids = []; } |
|
133 |
|
|
134 |
return this.images; |
|
93 | 135 |
}, |
94 | 136 |
|
95 | 137 |
update_layout: function() { |
138 |
this.select_type(this.selected_type); |
|
139 |
}, |
|
140 |
|
|
141 |
get_categories: function(images) { |
|
142 |
return []; |
|
143 |
return ["Desktop", "Server", "Linux", "Windows"]; |
|
144 |
}, |
|
145 |
|
|
146 |
reset_categories: function() { |
|
147 |
var categories = this.get_categories(this.images); |
|
148 |
this.categories_list.find("li").remove(); |
|
149 |
|
|
150 |
_.each(categories, _.bind(function(cat) { |
|
151 |
var el = $("<li />"); |
|
152 |
el.text(cat); |
|
153 |
this.categories_list.append(el); |
|
154 |
}, this)); |
|
155 |
|
|
156 |
if (!categories.length) { |
|
157 |
this.categories_list.parent().find(".clear").hide(); |
|
158 |
this.categories_list.parent().find(".empty").show(); |
|
159 |
} else { |
|
160 |
this.categories_list.parent().find(".clear").show(); |
|
161 |
this.categories_list.parent().find(".empty").hide(); |
|
162 |
} |
|
163 |
}, |
|
164 |
|
|
165 |
select_type: function(type) { |
|
166 |
this.selected_type = type; |
|
167 |
this.types.removeClass("selected"); |
|
168 |
this.types.filter("#type-select-" + this.selected_type).addClass("selected"); |
|
169 |
|
|
170 |
this.reset_categories(); |
|
171 |
this.update_images(); |
|
172 |
this.reset_images(); |
|
173 |
this.select_image(); |
|
96 | 174 |
}, |
97 | 175 |
|
98 | 176 |
select_image: function(image) { |
99 |
if (!image) { |
|
100 |
image = storage.images.at(0); |
|
177 |
if (!image && this.images_ids.length) { |
|
178 |
if (this.selected_image && this.images_ids.indexOf(this.selected_image.id) > -1) { |
|
179 |
image = this.selected_image; |
|
180 |
} else { |
|
181 |
image = storage.images.get(this.images_ids[0]); |
|
182 |
} |
|
101 | 183 |
} |
102 | 184 |
|
185 |
if (!this.images_ids.length) { image = this.selected_image || undefined }; |
|
186 |
|
|
103 | 187 |
this.selected_image = image; |
104 |
this.trigger("change", this.selected_image);
|
|
188 |
this.trigger("change", image); |
|
105 | 189 |
|
106 |
this.predefined.find(".image-details").removeClass("selected"); |
|
107 |
this.predefined.find(".image-details#create-vm-image-" + this.selected_image.id).addClass("selected") |
|
190 |
if (image) { |
|
191 |
this.image_details.show(); |
|
192 |
this.images_list.find(".image-details").removeClass("selected"); |
|
193 |
this.images_list.find(".image-details#create-vm-image-" + this.selected_image.id).addClass("selected"); |
|
194 |
|
|
195 |
this.image_details_desc.text(image.get("description")); |
|
196 |
|
|
197 |
var img = snf.ui.helpers.os_icon_tag(image.get("OS")) |
|
198 |
this.image_details_title.html(img + image.get("name")); |
|
199 |
this.image_details_os.text(_(image.get("OS")).capitalize()); |
|
200 |
this.image_details_kernel.text(image.get("kernel")); |
|
201 |
|
|
202 |
var size = util.readablizeBytes(parseInt(image.get("size")) * 1000000); |
|
203 |
this.image_details_size.text(size); |
|
204 |
this.image_details_gui.text(image.get("GUI")); |
|
205 |
|
|
206 |
} else { |
|
207 |
this.image_details.hide(); |
|
208 |
} |
|
108 | 209 |
}, |
109 | 210 |
|
110 | 211 |
reset_images: function() { |
111 |
this.$(".image-details").remove();
|
|
112 |
_.each(storage.images.active(), _.bind(function(img){
|
|
212 |
this.images_list.find("li").remove();
|
|
213 |
_.each(this.images, _.bind(function(img){
|
|
113 | 214 |
this.add_image(img); |
114 | 215 |
}, this)) |
216 |
|
|
217 |
if (this.images.length) { |
|
218 |
this.images_list.parent().find(".empty").hide(); |
|
219 |
} else { |
|
220 |
this.images_list.parent().find(".empty").show(); |
|
221 |
} |
|
115 | 222 |
|
116 | 223 |
this.select_image(); |
117 | 224 |
|
118 | 225 |
var self = this; |
119 |
this.predefined.find(".image-details").click(function(){
|
|
226 |
this.images_list.find(".image-details").click(function(){
|
|
120 | 227 |
self.select_image($(this).data("image")); |
121 |
}) |
|
228 |
}); |
|
229 |
|
|
230 |
util.equalHeights(this.$(".images-filter-cont"), this.$(".images-list-cont"), this.$(".images-info-cont")); |
|
231 |
}, |
|
232 |
|
|
233 |
show: function() { |
|
234 |
views.CreateImageSelectView.__super__.show.apply(this, arguments); |
|
235 |
util.equalHeights(this.$(".images-filter-cont"), this.$(".images-list-cont"), this.$(".images-info-cont")); |
|
122 | 236 |
}, |
123 | 237 |
|
124 | 238 |
add_image: function(img) { |
125 |
var image = $('<li id="create-vm-image-{1}" class="image-details">{0}</li>'.format(img.get("name"), img.id)); |
|
239 |
var image = $(('<li id="create-vm-image-{1}"' + |
|
240 |
'class="image-details clearfix">{2}{0}' + |
|
241 |
'<p>{4}</p><span class="size">{3}' + |
|
242 |
'</span></li>').format(img.get("name"), |
|
243 |
img.id, |
|
244 |
snf.ui.helpers.os_icon_tag(img.get("OS")), |
|
245 |
util.readablizeBytes(parseInt(img.get("size"))*1000000), |
|
246 |
util.truncate(img.get("description"),35))); |
|
126 | 247 |
image.data("image", img); |
127 | 248 |
image.data("image_id", img.id); |
128 |
this.predefined.append(image);
|
|
249 |
this.images_list.append(image);
|
|
129 | 250 |
}, |
130 | 251 |
|
131 | 252 |
reset: function() { |
... | ... | |
144 | 265 |
views.CreateFlavorSelectView.__super__.initialize.apply(this, arguments); |
145 | 266 |
this.parent.bind("image:change", _.bind(this.handle_image_change, this)); |
146 | 267 |
|
147 |
this.cpus = this.$(".flavors-cpu-list") |
|
148 |
this.disks = this.$(".flavors-disk-list") |
|
149 |
this.mems = this.$(".flavors-mem-list") |
|
268 |
this.cpus = this.$(".flavors-cpu-list");
|
|
269 |
this.disks = this.$(".flavors-disk-list");
|
|
270 |
this.mems = this.$(".flavors-mem-list");
|
|
150 | 271 |
|
151 |
this.reset(); |
|
152 |
this.update_layout(); |
|
272 |
this.predefined_flavors = SUGGESTED_FLAVORS; |
|
273 |
this.predefined = this.$(".predefined-list"); |
|
274 |
this.update_predefined_flavors(); |
|
153 | 275 |
}, |
154 | 276 |
|
155 | 277 |
handle_image_change: function(data) { |
156 | 278 |
this.current_image = data; |
279 |
this.update_valid_predefined(); |
|
157 | 280 |
this.update_flavors_data(); |
158 | 281 |
this.reset_flavors(); |
159 | 282 |
this.update_layout(); |
... | ... | |
164 | 287 |
this.create_flavors(); |
165 | 288 |
}, |
166 | 289 |
|
290 |
update_predefined_flavors: function() { |
|
291 |
this.predefined.find("li").remove(); |
|
292 |
_.each(this.predefined_flavors, _.bind(function(val, key) { |
|
293 |
var el = $(('<li class="predefined-selection" id="predefined-flavor-{0}">' + |
|
294 |
'{1}</li>').format(key, key)); |
|
295 |
|
|
296 |
this.predefined.append(el); |
|
297 |
el.data({flavor: storage.flavors.get_flavor(val.cpu, val.ram, val.disk, this.flavors)}) |
|
298 |
el.click(_.bind(function() { |
|
299 |
this.handle_predefined_click(el); |
|
300 |
}, this)) |
|
301 |
}, this)); |
|
302 |
this.update_valid_predefined(); |
|
303 |
}, |
|
304 |
|
|
305 |
handle_predefined_click: function(el) { |
|
306 |
if (el.hasClass("disabled")) { return }; |
|
307 |
this.set_current(el.data("flavor")) |
|
308 |
}, |
|
309 |
|
|
310 |
update_valid_predefined: function() { |
|
311 |
this.update_unavailable_values(); |
|
312 |
var self = this; |
|
313 |
this.valid_predefined = _.select(_.map(this.predefined_flavors, function(flv, key){ |
|
314 |
var existing = storage.flavors.get_flavor(flv.cpu, flv.ram, flv.disk, self.flavors); |
|
315 |
// non existing |
|
316 |
if (!existing) { |
|
317 |
return false; |
|
318 |
} |
|
319 |
|
|
320 |
// not available for image |
|
321 |
if (self.unavailable_values && self.unavailable_values.disk.indexOf(existing.get_disk_size()) > -1) { |
|
322 |
return false |
|
323 |
} |
|
324 |
|
|
325 |
return key; |
|
326 |
}), function(ret) { return ret }); |
|
327 |
|
|
328 |
$("li.predefined-selection").addClass("disabled"); |
|
329 |
_.each(this.valid_predefined, function(key) { |
|
330 |
$("#predefined-flavor-" + key).removeClass("disabled"); |
|
331 |
}) |
|
332 |
}, |
|
333 |
|
|
334 |
update_selected_predefined: function() { |
|
335 |
var self = this; |
|
336 |
this.predefined.find("li").removeClass("selected"); |
|
337 |
|
|
338 |
_.each(this.valid_predefined, function(key){ |
|
339 |
var flv = self.predefined_flavors[key]; |
|
340 |
var exists = storage.flavors.get_flavor(flv.cpu, flv.ram, flv.disk, self.flavors); |
|
341 |
|
|
342 |
if (exists && (exists.id == self.current_flavor.id)) { |
|
343 |
$("#predefined-flavor-" + key).addClass("selected"); |
|
344 |
} |
|
345 |
}) |
|
346 |
}, |
|
347 |
|
|
167 | 348 |
update_flavors_data: function() { |
168 |
this.flavors = storage.flavors.for_image(this.current_image);
|
|
349 |
this.flavors = storage.flavors.active();
|
|
169 | 350 |
this.flavors_data = storage.flavors.get_data(this.flavors); |
170 |
|
|
171 |
if (this.flavors.indexOf(this.current_flavor) == -1) { |
|
172 |
this.set_current(this.flavors[0]); |
|
351 |
|
|
352 |
var self = this; |
|
353 |
var set = false; |
|
354 |
|
|
355 |
// FIXME: validate current flavor |
|
356 |
|
|
357 |
if (!this.current_flavor) { |
|
358 |
_.each(this.valid_predefined, function(key) { |
|
359 |
var flv = self.predefined_flavors[key]; |
|
360 |
var exists = storage.flavors.get_flavor(flv.cpu, flv.ram, flv.disk, self.flavors); |
|
361 |
if (exists && !set) { |
|
362 |
self.set_current(exists); |
|
363 |
set = true; |
|
364 |
} |
|
365 |
}) |
|
173 | 366 |
} |
367 |
|
|
368 |
this.update_unavailable_values(); |
|
174 | 369 |
}, |
175 | 370 |
|
371 |
update_unavailable_values: function() { |
|
372 |
if (!this.current_image) { this.unavailable_values = {disk:[], ram:[], cpu:[]}; return }; |
|
373 |
this.unavailable_values = storage.flavors.unavailable_values_for_image(this.current_image); |
|
374 |
}, |
|
375 |
|
|
376 |
flavor_is_valid: function(flv) { |
|
377 |
if (!flv) { return false }; |
|
378 |
var existing = storage.flavors.get_flavor(flv.get("cpu"), flv.get("ram"), flv.get("disk"), this.flavors); |
|
379 |
if (!existing) { return false }; |
|
380 |
if (this.unavailable_values && this.unavailable_values.disk.indexOf(flv.get("disk") > -1)) { |
|
381 |
return false |
|
382 |
} |
|
383 |
return true; |
|
384 |
}, |
|
385 |
|
|
176 | 386 |
set_current: function(flv) { |
387 |
//console.log(flv); |
|
388 |
//if (!this.flavor_is_valid(flv)) { flv = undefined }; |
|
389 |
|
|
390 |
console.log(flv); |
|
177 | 391 |
this.current_flavor = flv; |
178 | 392 |
this.trigger("change"); |
179 | 393 |
this.update_selected_flavor(); |
394 |
this.update_selected_predefined(); |
|
395 |
}, |
|
396 |
|
|
397 |
select_default_flavor: function() { |
|
398 |
|
|
399 |
}, |
|
400 |
|
|
401 |
update_selected_from_ui: function() { |
|
402 |
this.set_current(this.ui_selected()); |
|
403 |
}, |
|
404 |
|
|
405 |
update_disabled_flavors: function() { |
|
406 |
this.$(".flavor-options.disk li").removeClass("disabled"); |
|
407 |
if (!this.unavailable_values) { return } |
|
408 |
|
|
409 |
this.$(".flavor-options.disk li").each(_.bind(function(i, el){ |
|
410 |
var el_value = $(el).data("value") * 1000; |
|
411 |
if (this.unavailable_values.disk.indexOf(el_value) > -1) { |
|
412 |
$(el).addClass("disabled"); |
|
413 |
}; |
|
414 |
}, this)); |
|
180 | 415 |
}, |
181 | 416 |
|
182 | 417 |
create_flavors: function() { |
183 |
var flavors = this.get_flavors(); |
|
418 |
var flavors = this.get_active_flavors(); |
|
419 |
var valid_flavors = this.get_valid_flavors(); |
|
420 |
|
|
184 | 421 |
_.each(flavors, _.bind(function(flv){ |
185 | 422 |
this.add_flavor(flv); |
186 | 423 |
}, this)); |
... | ... | |
188 | 425 |
var self = this; |
189 | 426 |
this.$(".flavor-options li.option").click(function(){ |
190 | 427 |
var el = $(this); |
428 |
|
|
429 |
if (el.hasClass("disabled")) { return } |
|
430 |
|
|
191 | 431 |
el.parent().find(".option").removeClass("selected"); |
192 | 432 |
el.addClass("selected"); |
433 |
|
|
434 |
if (el.hasClass("mem")) { this.last_choice = "mem" } |
|
435 |
if (el.hasClass("cpu")) { this.last_choice = "cpu" } |
|
436 |
if (el.hasClass("disk")) { this.last_choice = "disk" } |
|
437 |
|
|
193 | 438 |
self.update_selected_from_ui(); |
194 | 439 |
}) |
195 | 440 |
}, |
196 | 441 |
|
197 | 442 |
ui_selected: function() { |
198 |
args = [this.$(".option.cpu.selected").data("value"), |
|
443 |
var args = [this.$(".option.cpu.selected").data("value"),
|
|
199 | 444 |
this.$(".option.mem.selected").data("value"), |
200 | 445 |
this.$(".option.disk.selected").data("value"), |
201 | 446 |
this.flavors]; |
202 | 447 |
|
203 |
storage.flavors.apply(storage.flavors, args) |
|
448 |
var flv = storage.flavors.get_flavor.apply(storage.flavors, args); |
|
449 |
return flv; |
|
204 | 450 |
}, |
205 | 451 |
|
206 | 452 |
update_selected_flavor: function() { |
453 |
var flv = this.current_flavor; |
|
454 |
this.$(".option").removeClass("selected"); |
|
207 | 455 |
|
456 |
this.$(".option.cpu.value-" + flv.get("cpu")).addClass("selected"); |
|
457 |
this.$(".option.mem.value-" + flv.get("ram")).addClass("selected"); |
|
458 |
this.$(".option.disk.value-" + flv.get("disk")).addClass("selected"); |
|
208 | 459 |
}, |
209 | 460 |
|
210 | 461 |
add_flavor: function(flv) { |
211 | 462 |
var values = {'cpu': flv.get('cpu'), 'mem': flv.get('ram'), 'disk': flv.get('disk')}; |
212 |
|
|
463 |
|
|
464 |
disabled = ""; |
|
465 |
|
|
213 | 466 |
if (this.$('li.option.cpu.value-{0}'.format(values.cpu)).length == 0) { |
214 |
var cpu = $('<li class="option cpu value-{0}">{0}</li>'.format(values.cpu)).data('value', values.cpu); |
|
467 |
var cpu = $(('<li class="option cpu value-{0} {1}">' + |
|
468 |
'<span class="value">{0}</span>' + |
|
469 |
'<span class="metric">x</span></li>').format(values.cpu, disabled)).data('value', values.cpu); |
|
470 |
|
|
215 | 471 |
this.cpus.append(cpu); |
216 | 472 |
} |
217 | 473 |
if (this.$('li.option.mem.value-{0}'.format(values.mem)).length == 0) { |
218 |
var mem = $('<li class="option mem value-{0}">{0}</li>'.format(values.mem)).data('value', values.mem); |
|
474 |
var mem = $(('<li class="option mem value-{0}">' + |
|
475 |
'<span class="value">{0}</span>' + |
|
476 |
'<span class="metric">MB</span></li>').format(values.mem)).data('value', values.mem); |
|
477 |
|
|
219 | 478 |
this.mems.append(mem); |
220 | 479 |
} |
221 | 480 |
if (this.$('li.option.disk.value-{0}'.format(values.disk)).length == 0) { |
222 |
var disk = $('<li class="option disk value-{0}">{0}</li>'.format(values.disk)).data('value', values.disk); |
|
481 |
var disk = $(('<li class="option disk value-{0}">' + |
|
482 |
'<span class="value">{0}</span>' + |
|
483 |
'<span class="metric">GB</span></li>').format(values.disk)).data('value', values.disk); |
|
484 |
|
|
223 | 485 |
this.disks.append(disk); |
224 | 486 |
} |
225 | 487 |
|
226 | 488 |
}, |
489 |
|
|
490 |
get_active_flavors: function() { |
|
491 |
return storage.flavors.active(); |
|
492 |
}, |
|
227 | 493 |
|
228 |
get_flavors: function() { |
|
494 |
get_valid_flavors: function() {
|
|
229 | 495 |
return this.flavors; |
230 | 496 |
}, |
231 | 497 |
|
232 | 498 |
update_layout: function() { |
233 |
var flv = this.current_flavor; |
|
234 |
this.$(".option.value").removeClass("selected"); |
|
235 |
|
|
236 |
this.$(".option.cpu.value-" + flv.get("cpu")).addClass("selected"); |
|
237 |
this.$(".option.mem.value-" + flv.get("ram")).addClass("selected"); |
|
238 |
this.$(".option.disk.value-" + flv.get("disk")).addClass("selected"); |
|
499 |
this.update_selected_flavor(); |
|
500 |
this.update_disabled_flavors(); |
|
239 | 501 |
}, |
240 | 502 |
|
241 | 503 |
reset: function() { |
... | ... | |
263 | 525 |
}, |
264 | 526 |
|
265 | 527 |
init_handlers: function() { |
266 |
this.name.bind("keypress", _.bind(function() { |
|
528 |
this.name.bind("keypress", _.bind(function(e) {
|
|
267 | 529 |
this.name_changed = true; |
530 |
if (e.keyCode == 13) { this.parent.submit() }; |
|
268 | 531 |
}, this)); |
269 | 532 |
|
270 | 533 |
this.name.bind("click", _.bind(function() { |
... | ... | |
278 | 541 |
views.CreateSubmitView.__super__.show.apply(this, arguments); |
279 | 542 |
this.update_layout(); |
280 | 543 |
}, |
544 |
|
|
545 |
update_image_details: function() { |
|
546 |
var image = this.parent.get_params().image; |
|
547 |
|
|
548 |
function set_img_detail(sel, key) { |
|
549 |
if (!key) { key = image.get(key) }; |
|
550 |
this.$(".confirm-cont.image .image-" + sel + " .value").text(key) |
|
551 |
} |
|
552 |
|
|
553 |
set_img_detail("description"); |
|
554 |
set_img_detail("name"); |
|
555 |
set_img_detail("os", image.get("OS")); |
|
556 |
}, |
|
281 | 557 |
|
282 | 558 |
update_layout: function() { |
283 | 559 |
var params = this.parent.get_params(); |
560 |
|
|
561 |
if (!params.image) { return } |
|
284 | 562 |
var vm_name = "My {0} server".format(params.image.get("name")); |
285 | 563 |
var orig_name = vm_name; |
286 | 564 |
|
287 | 565 |
var existing = true; |
288 | 566 |
var j = 0; |
289 |
while (existing) { |
|
567 |
while (existing && !this.name_changed) {
|
|
290 | 568 |
var existing = storage.vms.select(function(vm){return vm.get("name") == vm_name}).length |
291 | 569 |
if (existing) { |
292 | 570 |
j++; |
293 | 571 |
vm_name = orig_name + " " + j; |
294 | 572 |
} |
295 | 573 |
} |
296 |
|
|
297 | 574 |
if (!_(this.name.val()).trim() || !this.name_changed) { |
298 | 575 |
this.name.val(vm_name); |
299 | 576 |
} |
... | ... | |
302 | 579 |
this.confirm.find("li.cpu .value").text(params.flavor.get("cpu")); |
303 | 580 |
this.confirm.find("li.mem .value").text(params.flavor.get("ram")); |
304 | 581 |
this.confirm.find("li.disk .value").text(params.flavor.get("disk")); |
582 |
|
|
583 |
if (!this.name_changed) { |
|
584 |
this.name.select().focus(); |
|
585 |
} |
|
586 |
|
|
587 |
var img = snf.ui.helpers.os_icon_path(params.image.get("OS")) |
|
588 |
this.name.css({backgroundImage:"url({0})".format(img)}) |
|
589 |
|
|
590 |
this.update_image_details(); |
|
305 | 591 |
}, |
306 | 592 |
|
307 | 593 |
reset: function() { |
594 |
this.name_changed = false; |
|
308 | 595 |
this.update_layout(); |
309 | 596 |
}, |
310 | 597 |
|
... | ... | |
375 | 662 |
}, |
376 | 663 |
|
377 | 664 |
submit: function() { |
665 |
if (this.submiting) { return }; |
|
378 | 666 |
var data = this.get_params(); |
379 | 667 |
if (this.validate(data)) { |
380 | 668 |
this.submit_btn.addClass("in-progress"); |
669 |
this.submiting = true; |
|
381 | 670 |
storage.vms.create(data.name, data.image, data.flavor, {}, {}, _.bind(function(data){ |
382 | 671 |
this.close_all(); |
383 |
this.password_view.show(data.server.adminPass); |
|
672 |
this.password_view.show(data.server.adminPass, data.server.id); |
|
673 |
this.submiting = false; |
|
384 | 674 |
}, this)); |
385 | 675 |
} |
386 | 676 |
}, |
... | ... | |
409 | 699 |
}, |
410 | 700 |
|
411 | 701 |
beforeOpen: function() { |
702 |
this.submiting = false; |
|
412 | 703 |
this.reset(); |
413 | 704 |
this.current_step = 1; |
705 |
this.$(".steps-container").css({"margin-left":0 + "px"}); |
|
414 | 706 |
this.show_step(1); |
415 | 707 |
}, |
416 | 708 |
|
... | ... | |
423 | 715 |
} |
424 | 716 |
|
425 | 717 |
// hide other |
426 |
this.$(".subheader .header-step").removeClass("current"); |
|
427 |
this.$(".create-step-cont").hide(); |
|
718 |
//this.$(".step-header .header-step").removeClass("current").hide(); |
|
719 |
//this.$(".create-step-cont").hide(); |
|
720 |
var width = this.el.find('.container').width(); |
|
721 |
var left = (step -1) * width * -1; |
|
722 |
this.$(".steps-container").css({"margin-left":left + "px"}); |
|
428 | 723 |
|
429 | 724 |
this.steps[step].show(); |
430 | 725 |
this.current_step = step; |
431 | 726 |
this.current_view = this.steps[step]; |
432 |
// |
|
433 | 727 |
this.update_controls(); |
434 | 728 |
}, |
435 | 729 |
|
Also available in: Unified diff