Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(448)

Delta Between Two Patch Sets: app/views/inspector.js

Issue 13997043: Remove DB.units list
Left Patch Set: Remove DB.units list Created 11 years, 6 months ago
Right Patch Set: Remove DB.units list Created 11 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « app/views/charm-panel.js ('k') | app/views/landscape.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 This file is part of the Juju GUI, which lets users view and manage Juju 2 This file is part of the Juju GUI, which lets users view and manage Juju
3 environments within a graphical interface (https://launchpad.net/juju-gui). 3 environments within a graphical interface (https://launchpad.net/juju-gui).
4 Copyright (C) 2012-2013 Canonical Ltd. 4 Copyright (C) 2012-2013 Canonical Ltd.
5 5
6 This program is free software: you can redistribute it and/or modify it under 6 This program is free software: you can redistribute it and/or modify it under
7 the terms of the GNU Affero General Public License version 3, as published by 7 the terms of the GNU Affero General Public License version 3, as published by
8 the Free Software Foundation. 8 the Free Software Foundation.
9 9
10 This program is distributed in the hope that it will be useful, but WITHOUT 10 This program is distributed in the hope that it will be useful, but WITHOUT
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 db = inspector.get('db'), 699 db = inspector.get('db'),
700 service = inspector.get('model'), 700 service = inspector.get('model'),
701 charmUrl = service.get('charm'), 701 charmUrl = service.get('charm'),
702 charm = db.charms.getById(charmUrl), 702 charm = db.charms.getById(charmUrl),
703 schema = charm.get('options'), 703 schema = charm.get('options'),
704 container = this.viewletManager.viewlets.config.container, 704 container = this.viewletManager.viewlets.config.container,
705 button = container.one('button.confirm'); 705 button = container.one('button.confirm');
706 706
707 button.set('disabled', 'disabled'); 707 button.set('disabled', 'disabled');
708 708
709 var newVals = utils.getElementsValuesMapping(container, '.config-field'); 709 var config = utils.getElementsValuesMapping(container, '.config-field');
710 var errors = utils.validate(newVals, schema); 710 var errors = utils.validate(config, schema);
711 711
712 if (Y.Object.isEmpty(errors)) { 712 if (Y.Object.isEmpty(errors)) {
713 env.set_config( 713 env.set_config(
714 service.get('id'), 714 service.get('id'),
715 newVals, 715 config,
716 null, 716 null,
717 service.get('config'), 717 service.get('config'),
718 Y.bind(this._setConfigCallback, this, container, newVals) 718 Y.bind(this._setConfigCallback, this, container)
719 ); 719 );
720 } else { 720 } else {
721 db.notifications.add( 721 db.notifications.add(
722 new models.Notification({ 722 new models.Notification({
723 title: 'Error saving service config', 723 title: 'Error saving service config',
724 message: 'Error saving service config', 724 message: 'Error saving service config',
725 level: 'error' 725 level: 'error'
726 }) 726 })
727 ); 727 );
728 // We don't have a story for passing the full error messages 728 // We don't have a story for passing the full error messages
729 // through so will log to the console for now. 729 // through so will log to the console for now.
730 console.log('Error setting config', errors); 730 console.log('Error setting config', errors);
731 } 731 }
732 }, 732 },
733 733
734 /** 734 /**
735 Handles the success or failure of setting the new config values 735 Handles the success or failure of setting the new config values
736 736
737 @method _setConfigCallback 737 @method _setConfigCallback
738 @param {Y.Node} container of the viewlet-manager. 738 @param {Y.Node} container of the viewlet-manager.
739 @param {Y.EventFacade} e yui event object. 739 @param {Y.EventFacade} evt YUI event object with the following attrs:
740 */ 740 - err: whether or not an error occurred;
741 _setConfigCallback: function(container, config, e) { 741 - service_name: the name of the service;
742 - newValues: an object including the modified config options.
743 */
744 _setConfigCallback: function(container, evt) {
742 // If the user has conflicted fields and still chooses to 745 // If the user has conflicted fields and still chooses to
743 // save, then we will be overwriting the values in Juju. 746 // save, then we will be overwriting the values in Juju.
744 if (e.err) { 747 if (evt.err) {
745 var db = this.viewletManager.get('db'); 748 var db = this.viewletManager.get('db');
746 db.notifications.add( 749 db.notifications.add(
747 new models.Notification({ 750 new models.Notification({
748 title: 'Error setting service configuration', 751 title: 'Error setting service configuration',
749 message: 'Service name: ' + e.service_name, 752 message: 'Service name: ' + evt.service_name,
750 level: 'error' 753 level: 'error'
751 }) 754 })
752 ); 755 );
753 } else { 756 } else {
754 this._highlightSaved(container); 757 this._highlightSaved(container);
755 this.viewletManager.get('model').set('config', config); 758 var service = this.viewletManager.get('model');
759 // Mix the current config (stored in the db) with the modified options.
760 var config = Y.mix(service.get('config'), evt.newValues, true);
761 service.set('config', config);
756 var bindingEngine = this.viewletManager.bindingEngine; 762 var bindingEngine = this.viewletManager.bindingEngine;
757 bindingEngine.resetDOMToModel('config'); 763 bindingEngine.resetDOMToModel('config');
758 } 764 }
759 container.one('.controls .confirm').removeAttribute('disabled'); 765 container.one('.controls .confirm').removeAttribute('disabled');
760 }, 766 },
761 767
762 /** 768 /**
763 Cancel any configuration changes. 769 Cancel any configuration changes.
764 770
765 @method cancelConfig 771 @method cancelConfig
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
1384 'viewlet-inspector-header', 1390 'viewlet-inspector-header',
1385 'viewlet-inspector-overview', 1391 'viewlet-inspector-overview',
1386 'viewlet-service-config', 1392 'viewlet-service-config',
1387 'viewlet-service-constraints', 1393 'viewlet-service-constraints',
1388 'viewlet-service-ghost', 1394 'viewlet-service-ghost',
1389 'viewlet-unit-details', 1395 'viewlet-unit-details',
1390 'viewlet-service-relations' 1396 'viewlet-service-relations'
1391 ] 1397 ]
1392 }); 1398 });
1393 1399
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b