View | Details | Raw Unified | Return to bug 26216
Collapse All | Expand All

(-)uvmm/DomainPage.js (-23 / +74 lines)
 Lines 34-39    Link Here 
34
	"dojo/_base/array",
34
	"dojo/_base/array",
35
	"dojo/store/Memory",
35
	"dojo/store/Memory",
36
	"dojo/store/Observable",
36
	"dojo/store/Observable",
37
	"dojo/promise/all",
37
	"umc/tools",
38
	"umc/tools",
38
	"umc/dialog",
39
	"umc/dialog",
39
	"umc/store",
40
	"umc/store",
 Lines 55-61    Link Here 
55
	"umc/modules/uvmm/DriveGrid",
56
	"umc/modules/uvmm/DriveGrid",
56
	"umc/modules/uvmm/types",
57
	"umc/modules/uvmm/types",
57
	"umc/i18n!umc/modules/uvmm"
58
	"umc/i18n!umc/modules/uvmm"
58
], function(declare, lang, array, Memory, Observable, tools, dialog, store, Page, Form, ContainerWidget, TabContainer, TitlePane, ExpandingTitlePane, StandbyMixin,
59
], function(declare, lang, array, Memory, Observable, all, tools, dialog, store, Page, Form, ContainerWidget, TabContainer, TitlePane, ExpandingTitlePane, StandbyMixin,
59
	TextBox, HiddenInput, ComboBox, MultiInput, CheckBox, PasswordBox, SnapshotGrid, InterfaceGrid, DriveGrid, types, _) {
60
	TextBox, HiddenInput, ComboBox, MultiInput, CheckBox, PasswordBox, SnapshotGrid, InterfaceGrid, DriveGrid, types, _) {
60
61
61
	return declare("umc.modules.uvmm.DomainPage", [ TabContainer, StandbyMixin ], {
62
	return declare("umc.modules.uvmm.DomainPage", [ TabContainer, StandbyMixin ], {
 Lines 77-82    Link Here 
77
		_snapshotGrid: null,
78
		_snapshotGrid: null,
78
79
79
		_domain: null,
80
		_domain: null,
81
		_loadedValues: null,
80
82
81
		disabled: false,
83
		disabled: false,
82
84
 Lines 92-98    Link Here 
92
				footerButtons: [{
94
				footerButtons: [{
93
					label: _('Back to overview'),
95
					label: _('Back to overview'),
94
					name: 'cancel',
96
					name: 'cancel',
95
					callback: lang.hitch(this, 'onClose')
97
					callback: lang.hitch(this, 'confirmClose')
96
				}, {
98
				}, {
97
					label: _('Save'),
99
					label: _('Save'),
98
					defaultButton: true,
100
					defaultButton: true,
 Lines 162-168    Link Here 
162
				footerButtons: [{
164
				footerButtons: [{
163
					label: _('Back to overview'),
165
					label: _('Back to overview'),
164
					name: 'cancel',
166
					name: 'cancel',
165
					callback: lang.hitch(this, 'onClose')
167
					callback: lang.hitch(this, 'confirmClose')
166
				}, {
168
				}, {
167
					label: _('Save'),
169
					label: _('Save'),
168
					defaultButton: true,
170
					defaultButton: true,
 Lines 295-301    Link Here 
295
				footerButtons: [{
297
				footerButtons: [{
296
					label: _('Back to overview'),
298
					label: _('Back to overview'),
297
					name: 'cancel',
299
					name: 'cancel',
298
					callback: lang.hitch(this, 'onClose')
300
					callback: lang.hitch(this, 'confirmClose')
299
				}, {
301
				}, {
300
					label: _('Save'),
302
					label: _('Save'),
301
					defaultButton: true,
303
					defaultButton: true,
 Lines 354-360    Link Here 
354
				footerButtons: [{
356
				footerButtons: [{
355
					label: _('Back to overview'),
357
					label: _('Back to overview'),
356
					name: 'cancel',
358
					name: 'cancel',
357
					callback: lang.hitch(this, 'onClose')
359
					callback: lang.hitch(this, 'confirmClose')
358
				}, {
360
				}, {
359
					label: _('Save'),
361
					label: _('Save'),
360
					defaultButton: true,
362
					defaultButton: true,
 Lines 386-396    Link Here 
386
			// validate
388
			// validate
387
			var valid = true;
389
			var valid = true;
388
			var widgets = lang.mixin({}, this._generalForm._widgets, this._advancedForm._widgets);
390
			var widgets = lang.mixin({}, this._generalForm._widgets, this._advancedForm._widgets);
389
			var values = lang.clone(this._domain);
391
			var values = this.getValues();
390
			delete values.domainURI;
392
			delete values.domainURI;
393
391
			tools.forIn(widgets, function(iname, iwidget) {
394
			tools.forIn(widgets, function(iname, iwidget) {
392
				valid = valid && (false !== iwidget.isValid());
395
				valid = valid && (false !== iwidget.isValid());
393
				values[iname] = iwidget.get('value');
394
				return valid;
396
				return valid;
395
			}, this);
397
			}, this);
396
398
 Lines 398-418    Link Here 
398
				dialog.alert(_('The entered data is not valid. Please correct your input.'));
400
				dialog.alert(_('The entered data is not valid. Please correct your input.'));
399
				return;
401
				return;
400
			}
402
			}
401
			// special handling for boot devices
402
			var paravirtual = this._domain.type == 'xen-xen';
403
			if ( paravirtual ) {
404
				var disks = [], boot_medium = null;
405
				array.forEach( this._domain.disks, function( disk ) {
406
					if ( values.boot_pv == disk.source ) {
407
						disks.unshift( disk );
408
					} else {
409
						disks.push( disk );
410
					}
411
				} );
412
				values.disks = disks;
413
			} else {
414
				values.boot = values.boot_hvm;
415
			}
416
403
417
			this.standby(true);
404
			this.standby(true);
418
			tools.umcpCommand('uvmm/domain/put', {
405
			tools.umcpCommand('uvmm/domain/put', {
 Lines 489-495    Link Here 
489
						idev.$id$ = i + 1;
476
						idev.$id$ = i + 1;
490
					});
477
					});
491
478
492
					// we need to add pseudo ids for the network interfaces
479
					// we need to add pseudo ids for the disk drives
493
					array.forEach(this._domain.disks, function(idrive, i) {
480
					array.forEach(this._domain.disks, function(idrive, i) {
494
						idrive.$id$ = i + 1;
481
						idrive.$id$ = i + 1;
495
					});
482
					});
 Lines 556-561    Link Here 
556
					} ) );
543
					} ) );
557
					this.selectChild( this._generalPage, true);
544
					this.selectChild( this._generalPage, true);
558
545
546
//					this._loadedValues = this.getValues();
547
//					// iterate over all advanced settings to set dynamically loaded values
548
//					tools.forIn(this._advancedForm._widgets, function(ikey) {
549
//						if (this._loadedValues[ikey] === '' && this._domain[ikey] !== null && this._domain[ikey] !== undefined) {
550
//							this._loadedValues[ikey] = String(this._domain[ikey]);
551
//						}
552
//					}, this);
553
554
					all([this._advancedForm.ready(), this._generalForm.ready()]).then(lang.hitch(this, function() {
555
						this._loadedValues = this.getValues();
556
					}));
557
559
					// force a refresh of the grids
558
					// force a refresh of the grids
560
					this._interfaceGrid.filter();
559
					this._interfaceGrid.filter();
561
					this._driveGrid.filter();
560
					this._driveGrid.filter();
 Lines 567-572    Link Here 
567
			}));
566
			}));
568
		},
567
		},
569
568
569
		getValues: function() {
570
//			var values = lang.mixin({}, this._domain,
571
//				this._generalForm.get('value'),
572
//				this._advancedForm.get('value')
573
//			);
574
			var values = lang.clone(this._domain);
575
			var widgets = lang.mixin({}, this._generalForm._widgets, this._advancedForm._widgets);
576
577
			tools.forIn(widgets, function(iname, iwidget) {
578
				values[iname] = iwidget.get('value');
579
			}, this);
580
581
			// special handling for boot devices
582
			var paravirtual = this._domain.type == 'xen-xen';
583
			if ( paravirtual ) {
584
				var disks = [], boot_medium = null;
585
				array.forEach( this._domain.disks, function( disk ) {
586
					if ( values.boot_pv == disk.source ) {
587
						disks.unshift( disk );
588
					} else {
589
						disks.push( disk );
590
					}
591
				} );
592
				values.disks = disks;
593
			} else {
594
				values.boot = values.boot_hvm;
595
			}
596
			return values;
597
		},
598
599
		confirmClose: function() {
600
			// summary:
601
			// 		If changes have been made show a confirmation dialogue before closing the page
602
603
			if (!tools.isEqual(this._loadedValues, this.getValues())) {
604
				// Changes have been made. Display confirm dialogue.
605
				return dialog.confirm( _('There are unsaved changes. Are you sure to cancel nevertheless?'), [{
606
					label: _('Discard changes'),
607
					name: 'quit',
608
					callback: lang.hitch(this, 'onClose')
609
					}, {
610
						label: _('Continue editing'),
611
						name: 'cancel',
612
						'default': true
613
					}]
614
				);
615
			}
616
617
			// No changes have been made. Close the page
618
			this.onClose();
619
		},
620
570
		onClose: function() {
621
		onClose: function() {
571
			// event stub
622
			// event stub
572
		},
623
		},
(-)de.po (+8 lines)
 Lines 1963-1965    Link Here 
1963
1963
1964
#~ msgid "unknown value"
1964
#~ msgid "unknown value"
1965
#~ msgstr "Unbekannter Wert"
1965
#~ msgstr "Unbekannter Wert"
1966
msgid "There are unsaved changes. Are you sure to cancel nevertheless?"
1967
msgstr "Einige Änderungen sind noch nicht gespeichert. Möchten Sie trotzdem abbrechen?"
1968
1969
msgid "Continue editing"
1970
msgstr "Bearbeiten fortführen"
1971
1972
msgid "Discard changes"
1973
msgstr "Änderungen verwerfen"

Return to bug 26216