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

(-)umc/js/setup.js (-26 / +22 lines)
 Lines 363-375    Link Here 
363
363
364
		load: function() {
364
		load: function() {
365
			// get settings from server
365
			// get settings from server
366
			this.standby(true);
366
			return this.standbyDuring(this.umcpCommand('setup/load')).then(lang.hitch(this, function(data) {
367
			return this.umcpCommand('setup/load').then(lang.hitch(this, function(data) {
368
				// update setup pages with loaded values
367
				// update setup pages with loaded values
369
				this.setValues(data.result);
368
				this.setValues(data.result);
370
				this.standby(false);
371
			}), lang.hitch(this, function() {
372
				this.standby(false);
373
			}));
369
			}));
374
		},
370
		},
375
371
 Lines 501-507    Link Here 
501
			};
497
			};
502
498
503
			// function to locally validate the pages
499
			// function to locally validate the pages
504
			var _localValidation = function() {
500
			var _localValidation = lang.hitch(this, function() {
505
				var allValid = true;
501
				var allValid = true;
506
				var validationMessage = '<p>' + _('The following entries could not be validated:') + '</p><ul style="max-height:200px; overflow:auto;">';
502
				var validationMessage = '<p>' + _('The following entries could not be validated:') + '</p><ul style="max-height:200px; overflow:auto;">';
507
				array.forEach(this._pages, function(ipage) {
503
				array.forEach(this._pages, function(ipage) {
 Lines 525-534    Link Here 
525
					_alert(validationMessage);
521
					_alert(validationMessage);
526
					throw new Error('Validation failed!');
522
					throw new Error('Validation failed!');
527
				}
523
				}
528
			};
524
			});
529
525
530
			// function to confirm changes
526
			// function to confirm changes
531
			var _confirmChanges = function(values, summaries) {
527
			var _confirmChanges = lang.hitch(this, function(values, summaries) {
532
				// first see which message needs to be displayed for the confirmation message
528
				// first see which message needs to be displayed for the confirmation message
533
				tools.forIn(values, function(ikey) {
529
				tools.forIn(values, function(ikey) {
534
					array.forEach(summaries, function(idesc) {
530
					array.forEach(summaries, function(idesc) {
 Lines 560-569    Link Here 
560
						throw new CancelDialogException();
556
						throw new CancelDialogException();
561
					}
557
					}
562
				}));
558
				}));
563
			};
559
			});
564
560
565
			// function for server side validation of user changes
561
			// function for server side validation of user changes
566
			var _remoteValidation = function(values, summaries) {
562
			var _remoteValidation = lang.hitch(this, function(values, summaries) {
567
				this.standby(true);
563
				this.standby(true);
568
				return this.umcpCommand('setup/validate', { values: values }).then(lang.hitch(this, function(data) {
564
				return this.umcpCommand('setup/validate', { values: values }).then(lang.hitch(this, function(data) {
569
					var allValid = true;
565
					var allValid = true;
 Lines 606-615    Link Here 
606
					_alert(validationMessage);
602
					_alert(validationMessage);
607
					throw new Error('Validation failed!');
603
					throw new Error('Validation failed!');
608
				}));
604
				}));
609
			};
605
			});
610
606
611
			// function to save data
607
			// function to save data
612
			var _save = function(values, umc_url) {
608
			var _save = lang.hitch(this, function(values, umc_url) {
613
				var deferred = new Deferred();
609
				var deferred = new Deferred();
614
610
615
				// send save command to server
611
				// send save command to server
 Lines 639-660    Link Here 
639
				return deferred.then(lang.hitch(this, function() {
635
				return deferred.then(lang.hitch(this, function() {
640
					this.standby(false);
636
					this.standby(false);
641
				}));
637
				}));
642
			};
638
			});
643
639
644
			// ask user whether UMC server components shall be restarted or not
640
			// ask user whether UMC server components shall be restarted or not
645
			var _restart = function() {
641
			var _restart = lang.hitch(this, function() {
646
				libServer.askRestart(_('The changes have been applied successfully.'));
642
				libServer.askRestart(_('The changes have been applied successfully.'));
647
				this.load(); // sets 'standby(false)'
643
				this.load(); // sets 'standby(false)'
648
			};
644
			});
649
645
650
			// notify user that saving was successful
646
			// notify user that saving was successful
651
			var _success = function() {
647
			var _success = lang.hitch(this, function() {
652
				this.addNotification(_('The changes have been applied successfully.'));
648
				this.addNotification(_('The changes have been applied successfully.'));
653
				this.load(); // sets 'standby(false)'
649
				this.load(); // sets 'standby(false)'
654
			};
650
			});
655
651
656
			// tell user that saving was not successful (has to confirm)
652
			// tell user that saving was not successful (has to confirm)
657
			var _failure = function(errorHtml) {
653
			var _failure = lang.hitch(this, function(errorHtml) {
658
				var msg = _('Not all changes could be applied successfully:') + errorHtml;
654
				var msg = _('Not all changes could be applied successfully:') + errorHtml;
659
				var choices = [{
655
				var choices = [{
660
					name: 'apply',
656
					name: 'apply',
 Lines 664-673    Link Here 
664
				return dialog.confirm(msg, choices).then(lang.hitch(this, function() {
660
				return dialog.confirm(msg, choices).then(lang.hitch(this, function() {
665
					this.load(); // sets 'standby(false)'
661
					this.load(); // sets 'standby(false)'
666
				}));
662
				}));
667
			};
663
			});
668
664
669
			// show success/error message and eventually restart UMC server components
665
			// show success/error message and eventually restart UMC server components
670
			var _checkForErrorsDuringSave = function(values) {
666
			var _checkForErrorsDuringSave = lang.hitch(this, function(values) {
671
				var errors = this._progressBar.getErrors().errors;
667
				var errors = this._progressBar.getErrors().errors;
672
				if (errors.length) {
668
				if (errors.length) {
673
					// errors have occurred
669
					// errors have occurred
 Lines 696-711    Link Here 
696
						return _success();
692
						return _success();
697
					}
693
					}
698
				}
694
				}
699
			};
695
			});
700
696
701
			// chain all methods together
697
			// chain all methods together
702
			var deferred = new Deferred();
698
			var deferred = new Deferred();
703
			deferred.resolve();
699
			deferred.resolve();
704
			deferred = deferred.then(lang.hitch(this, _localValidation, values));
700
			deferred = deferred.then(lang.partial(_localValidation, values));
705
			deferred = deferred.then(lang.hitch(this, _confirmChanges, values, summaries));
701
			deferred = deferred.then(lang.partial(_confirmChanges, values, summaries));
706
			deferred = deferred.then(lang.hitch(this, _remoteValidation, values, summaries));
702
			deferred = deferred.then(lang.partial(_remoteValidation, values, summaries));
707
			deferred = deferred.then(lang.hitch(this, _save, values, umc_url));
703
			deferred = deferred.then(lang.partial(_save, values, umc_url));
708
			deferred = deferred.then(lang.hitch(this, _checkForErrorsDuringSave, values));
704
			deferred = deferred.then(lang.partial(_checkForErrorsDuringSave, values));
709
			deferred.then(
705
			deferred.then(
710
				lang.hitch(this, 'standby', false),
706
				lang.hitch(this, 'standby', false),
711
				lang.hitch(this, 'standby', false)
707
				lang.hitch(this, 'standby', false)

Return to bug 35815