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

Side by Side Diff: app/views/viewlets/unit-details.js

Issue 13358045: Enable Landscape links.
Patch Set: Enable Landscape links. Created 11 years, 7 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:
View unified diff | Download patch
« no previous file with comments | « app/views/viewlets/service-overview.js ('k') | lib/views/juju-inspector.less » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, 11 ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
12 SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero 12 SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
13 General Public License for more details. 13 General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License along 15 You should have received a copy of the GNU Affero General Public License along
16 with this program. If not, see <http://www.gnu.org/licenses/>. 16 with this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 17 */
18 18
19 'use strict'; 19 'use strict';
20 20
21 21
22 YUI.add('viewlet-unit-details', function(Y) { 22 YUI.add('viewlet-unit-details', function(Y) {
23 var ns = Y.namespace('juju.viewlets'), 23 var ns = Y.namespace('juju.viewlets'),
24 templates = Y.namespace('juju.views').Templates, 24 views = Y.namespace('juju.views'),
25 templates = views.Templates,
25 models = Y.namespace('juju.models'), 26 models = Y.namespace('juju.models'),
26 utils = Y.namespace('juju.views.utils'); 27 utils = Y.namespace('juju.views.utils');
27 28
28 ns.unitDetails = { 29 ns.unitDetails = {
29 name: 'unitDetails', 30 name: 'unitDetails',
30 templateWrapper: templates['left-breakout-panel'], 31 templateWrapper: templates['left-breakout-panel'],
31 template: templates.unitOverview, 32 template: templates.unitOverview,
32 slot: 'left-hand-panel', 33 slot: 'left-hand-panel',
33 'render': function(unit, viewletManagerAttrs) {
34 var db = viewletManagerAttrs.db,
35 service = db.services.getById(unit.service);
36 34
37 var ip_description_chunks = []; 35 // Return the template context for the unit detail view.
36 'getContext': function(db, service, unit) {
37 var ipDescriptionChunks = [];
38 if (unit.public_address) { 38 if (unit.public_address) {
39 ip_description_chunks.push(unit.public_address); 39 ipDescriptionChunks.push(unit.public_address);
40 } 40 }
41 if (unit.private_address) { 41 if (unit.private_address) {
42 ip_description_chunks.push(unit.private_address); 42 ipDescriptionChunks.push(unit.private_address);
43 } 43 }
44 if (unit.open_ports) { 44 if (unit.open_ports) {
45 ip_description_chunks.push(unit.open_ports.join()); 45 ipDescriptionChunks.push(unit.open_ports.join(', '));
46 } 46 }
47 var unit_ip_description; 47 var unitIPDescription;
48 if (ip_description_chunks.length) { 48 if (ipDescriptionChunks.length) {
49 unit_ip_description = ip_description_chunks.join(' | '); 49 unitIPDescription = ipDescriptionChunks.join(' | ');
50 } 50 }
51
52 // Ignore relations errors. 51 // Ignore relations errors.
53 var relation_errors = unit.relation_errors || {}, 52 var relation_errors = unit.relation_errors || {},
54 relations = utils.getRelationDataForService(db, service); 53 relations = utils.getRelationDataForService(db, service);
55
56 Y.each(relations, function(rel) { 54 Y.each(relations, function(rel) {
57 var match = relation_errors[rel.near.name], 55 var match = relation_errors[rel.near.name],
58 far = rel.far || rel.near; 56 far = rel.far || rel.near;
59 rel.has_error = !!(match && match.indexOf(far.service) > -1); 57 rel.has_error = !!(match && match.indexOf(far.service) > -1);
60 }); 58 });
59 return {
60 unit: unit,
61 unitIPDescription: unitIPDescription,
62 relations: relations,
63 landscapeURL: utils.getLandscapeURL(db.environment, unit)
64 };
65 },
61 66
62 var templateData = { 67 'render': function(unit, viewletManagerAttrs) {
63 unit: unit, 68 var db = viewletManagerAttrs.db;
64 unitIPDescription: unit_ip_description, 69 var service = db.services.getById(unit.service);
65 relations: relations 70 var context = this.getContext(db, service, unit);
66 };
67 this.container = Y.Node.create(this.templateWrapper({})); 71 this.container = Y.Node.create(this.templateWrapper({}));
68 this.container.one('.content').setHTML(this.template(templateData)); 72 this.container.one('.content').setHTML(this.template(context));
69 } 73 }
70 }; 74 };
71 }, '0.0.1', { 75 }, '0.0.1', {
72 requires: [ 76 requires: [
73 'node', 77 'node',
74 'juju-charm-models', 78 'juju-charm-models',
75 'juju-templates', 79 'juju-templates',
76 'juju-view' 80 'juju-view'
77 ] 81 ]
78 }); 82 });
OLDNEW
« no previous file with comments | « app/views/viewlets/service-overview.js ('k') | lib/views/juju-inspector.less » ('j') | no next file with comments »

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