OLD | NEW |
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 1512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1523 title: 'Constraints saved successfully', | 1523 title: 'Constraints saved successfully', |
1524 message: ev.service_name + ' constraints set successfully.', | 1524 message: ev.service_name + ' constraints set successfully.', |
1525 level: 'info' | 1525 level: 'info' |
1526 }) | 1526 }) |
1527 ); | 1527 ); |
1528 } | 1528 } |
1529 container.one('.save-constraints').removeAttribute('disabled'); | 1529 container.one('.save-constraints').removeAttribute('disabled'); |
1530 }, | 1530 }, |
1531 | 1531 |
1532 /** | 1532 /** |
1533 * Show a unit within the left-hand panel. | 1533 Show a unit within the left-hand panel. |
1534 * Note that, due to the revived model below, this model can potentially | 1534 Note that, due to the revived model below, this model can potentially |
1535 * be out of date, as the POJO from the LazyModelList is the one kept up | 1535 be out of date, as the POJO from the LazyModelList is the one kept up |
1536 * to date. This is just a first-pass and will be changed later. | 1536 to date. This is just a first-pass and will be changed later. |
1537 * | 1537 |
1538 * @method showUnit | 1538 @method showUnitDetails |
1539 * @param {object} ev The click event. | 1539 @param {object} ev The click event. |
1540 * @return {undefined} Nothing. | 1540 @return {undefined} Nothing. |
1541 */ | 1541 */ |
1542 showUnit: function(ev) { | 1542 showUnitDetails: function(ev) { |
1543 ev.halt(); | 1543 ev.halt(); |
1544 var db = this.inspector.get('db'); | 1544 var db = this.inspector.get('db'); |
1545 var unitId = ev.currentTarget.getData('unit'); | 1545 var unitId = ev.currentTarget.getData('unit'); |
1546 var unit = db.units.revive(db.units.getById(unitId)); | 1546 var unit = db.units.revive(db.units.getById(unitId)); |
1547 this.inspector.showViewlet('unit', unit); | 1547 this.inspector.showViewlet('unit', unit); |
1548 }, | 1548 }, |
1549 | 1549 |
1550 /** | 1550 /** |
1551 Toggles the close-unit class on the unit-list-wrapper which triggers | 1551 Toggles the close-unit class on the unit-list-wrapper which triggers |
1552 the css close and open animations. | 1552 the css close and open animations. |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1691 // D3 content enter section | 1691 // D3 content enter section |
1692 var unitItem = unitsList.enter() | 1692 var unitItem = unitsList.enter() |
1693 .append('li'); | 1693 .append('li'); |
1694 | 1694 |
1695 unitItem.append('input') | 1695 unitItem.append('input') |
1696 .attr({'type': 'checkbox', | 1696 .attr({'type': 'checkbox', |
1697 'name': function(unit) { | 1697 'name': function(unit) { |
1698 return unit.id; | 1698 return unit.id; |
1699 }}); | 1699 }}); |
1700 | 1700 |
1701 unitItem.append('span').text(function(d) { | 1701 unitItem.append('a').text( |
1702 return d.id; | 1702 function(d) { |
1703 }); | 1703 return d.id; |
| 1704 }) |
| 1705 .attr('data-unit', function(d) { |
| 1706 return d.service + '/' + d.number; |
| 1707 }); |
1704 | 1708 |
1705 // D3 content update section | 1709 // D3 content update section |
1706 unitsList.sort( | 1710 unitsList.sort( |
1707 function(a, b) { | 1711 function(a, b) { |
1708 return a.number - b.number; | 1712 return a.number - b.number; |
1709 }); | 1713 }); |
1710 | 1714 |
1711 // D3 content exit section | 1715 // D3 content exit section |
1712 unitsList.exit().remove(); | 1716 unitsList.exit().remove(); |
1713 | 1717 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1755 this.viewlet.generateAndBindUnitHeaders(node, statuses); | 1759 this.viewlet.generateAndBindUnitHeaders(node, statuses); |
1756 } | 1760 } |
1757 } | 1761 } |
1758 }, | 1762 }, |
1759 // These methods are exposed here to allow us access for testing. | 1763 // These methods are exposed here to allow us access for testing. |
1760 updateUnitList: updateUnitList, | 1764 updateUnitList: updateUnitList, |
1761 generateAndBindUnitHeaders: generateAndBindUnitHeaders | 1765 generateAndBindUnitHeaders: generateAndBindUnitHeaders |
1762 }, | 1766 }, |
1763 unit: { | 1767 unit: { |
1764 name: 'unit', | 1768 name: 'unit', |
| 1769 templateWrapper: Templates['left-breakout-panel'], |
1765 template: Templates.unitOverview, | 1770 template: Templates.unitOverview, |
1766 slot: 'left-hand-panel', | 1771 slot: 'left-hand-panel', |
1767 'render': function(unitModel, viewContainerAttrs) { | 1772 'render': function(unitModel, viewContainerAttrs) { |
1768 // Since we're given a Model and need a POJO for the template, | 1773 // Since we're given a Model and need a POJO for the template, |
1769 // retrieve the attrs and use those. This will likely change in | 1774 // retrieve the attrs and use those. This will likely change in |
1770 // the future with POJO databinding. | 1775 // the future with POJO databinding. |
1771 var unit = unitModel.getAttrs(), | 1776 var unit = unitModel.getAttrs(), |
1772 db = viewContainerAttrs.db, | 1777 db = viewContainerAttrs.db, |
1773 service = db.services.getById(unit.service), | 1778 service = db.services.getById(unit.service), |
1774 env = db.environment.get('annotations'); | 1779 env = db.environment.get('annotations'); |
(...skipping 23 matching lines...) Expand all Loading... |
1798 var match = relation_errors[rel.near.name], | 1803 var match = relation_errors[rel.near.name], |
1799 far = rel.far || rel.near; | 1804 far = rel.far || rel.near; |
1800 rel.has_error = !!(match && match.indexOf(far.service) > -1); | 1805 rel.has_error = !!(match && match.indexOf(far.service) > -1); |
1801 }); | 1806 }); |
1802 | 1807 |
1803 var templateData = { | 1808 var templateData = { |
1804 unit: unit, | 1809 unit: unit, |
1805 unitIPDescription: unit_ip_description, | 1810 unitIPDescription: unit_ip_description, |
1806 relations: relations | 1811 relations: relations |
1807 }; | 1812 }; |
1808 this.container = Y.Node.create(this.templateWrapper); | 1813 this.container = Y.Node.create(this.templateWrapper()); |
1809 this.container.setHTML(this.template(templateData)); | 1814 this.container.one('.content').setHTML(this.template(templateData)); |
1810 } | 1815 } |
1811 }, | 1816 }, |
1812 config: { | 1817 config: { |
1813 name: 'config', | 1818 name: 'config', |
1814 template: Templates['service-configuration'], | 1819 template: Templates['service-configuration'], |
1815 'render': function(service, viewContainerAttrs) { | 1820 'render': function(service, viewContainerAttrs) { |
1816 var settings = []; | 1821 var settings = []; |
1817 var db = viewContainerAttrs.db; | 1822 var db = viewContainerAttrs.db; |
1818 var charm = db.charms.getById(service.get('charm')); | 1823 var charm = db.charms.getById(service.get('charm')); |
1819 var charmConfig = charm.get('config'); | 1824 var charmConfig = charm.get('config'); |
1820 var charmOptions = charmConfig && charmConfig.options; | 1825 var charmOptions = charmConfig && charmConfig.options; |
1821 Y.Object.each(service.get('config'), function(value, key) { | 1826 Y.Object.each(service.get('config'), function(value, key) { |
1822 var setting = { | 1827 var setting = { |
1823 name: key, | 1828 name: key, |
1824 value: value | 1829 value: value |
1825 }; | 1830 }; |
1826 if (charmOptions) { | 1831 if (charmOptions) { |
1827 var option = charmOptions[key]; | 1832 var option = charmOptions[key]; |
1828 if (option) { | 1833 if (option) { |
1829 setting.description = option.description; | 1834 setting.description = option.description; |
1830 setting.type = option.type; | 1835 setting.type = option.type; |
1831 } | 1836 } |
1832 } | 1837 } |
1833 settings.push(setting); | 1838 settings.push(setting); |
1834 }); | 1839 }); |
1835 this.container = Y.Node.create(this.templateWrapper); | 1840 this.container = Y.Node.create(this.templateWrapper); |
| 1841 |
1836 this.container.setHTML( | 1842 this.container.setHTML( |
1837 this.template({ | 1843 this.template({ |
1838 service: service, | 1844 service: service, |
1839 settings: settings, | 1845 settings: settings, |
1840 exposed: service.get('exposed')})); | 1846 exposed: service.get('exposed')})); |
1841 this.container.all('textarea.config-field') | 1847 this.container.all('textarea.config-field') |
1842 .plug(plugins.ResizingTextarea, | 1848 .plug(plugins.ResizingTextarea, |
1843 { max_height: 200, | 1849 { max_height: 200, |
1844 min_height: 18, | 1850 min_height: 18, |
1845 single_line: 18}); | 1851 single_line: 18}); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2033 Y.Object.each(handlers, function(callback, event, obj) { | 2039 Y.Object.each(handlers, function(callback, event, obj) { |
2034 options.viewletEvents[selector][event] = Y.bind( | 2040 options.viewletEvents[selector][event] = Y.bind( |
2035 controllerPrototype[callback], self); | 2041 controllerPrototype[callback], self); |
2036 }); | 2042 }); |
2037 }); | 2043 }); |
2038 | 2044 |
2039 options.events = Y.mix(options.events, options.viewletEvents); | 2045 options.events = Y.mix(options.events, options.viewletEvents); |
2040 | 2046 |
2041 this.inspector = new views.ViewContainer(options); | 2047 this.inspector = new views.ViewContainer(options); |
2042 this.inspector.slots = { | 2048 this.inspector.slots = { |
2043 'left-hand-panel': '.left' | 2049 'left-hand-panel': '.left-breakout' |
2044 }; | 2050 }; |
2045 this.inspector.render(); | 2051 this.inspector.render(); |
2046 this.inspector.showViewlet(options.viewletList[0]); | 2052 this.inspector.showViewlet(options.viewletList[0]); |
2047 } | 2053 } |
2048 | 2054 |
2049 ServiceInspector.prototype = controllerPrototype; | 2055 ServiceInspector.prototype = controllerPrototype; |
2050 | 2056 |
2051 return ServiceInspector; | 2057 return ServiceInspector; |
2052 })(); | 2058 })(); |
2053 | 2059 |
2054 views.ServiceInspector = ServiceInspector; | 2060 views.ServiceInspector = ServiceInspector; |
2055 }, '0.1.0', { | 2061 }, '0.1.0', { |
2056 requires: ['panel', | 2062 requires: ['panel', |
2057 'dd', | 2063 'dd', |
2058 'd3-statusbar', | 2064 'd3-statusbar', |
2059 'juju-databinding', | 2065 'juju-databinding', |
2060 'juju-view-container', | 2066 'juju-view-container', |
2061 'juju-view-utils', | 2067 'juju-view-utils', |
2062 'juju-models', | 2068 'juju-models', |
2063 'base-build', | 2069 'base-build', |
2064 'handlebars', | 2070 'handlebars', |
2065 'node', | 2071 'node', |
2066 'view', | 2072 'view', |
2067 'event-key', | 2073 'event-key', |
2068 'transition', | 2074 'transition', |
2069 'event-resize', | 2075 'event-resize', |
2070 'json-stringify'] | 2076 'json-stringify'] |
2071 }); | 2077 }); |
OLD | NEW |