Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 } else { | 93 } else { |
94 this._inspectors[name] = inspector; | 94 this._inspectors[name] = inspector; |
95 } | 95 } |
96 return this; | 96 return this; |
97 }, | 97 }, |
98 | 98 |
99 /** | 99 /** |
100 Creates a new service inspector instance of the passed in type. | 100 Creates a new service inspector instance of the passed in type. |
101 | 101 |
102 @method createServiceInspector | 102 @method createServiceInspector |
103 @param {String} type of inspector to create (ghost, service). | |
104 @param {Y.Model} model service or charm depending on inspector type. | 103 @param {Y.Model} model service or charm depending on inspector type. |
105 @param {Object} config object of options to overwrite default config. | 104 @param {Object} config object of options to overwrite default config. |
106 */ | 105 */ |
107 createServiceInspector: function(type, model, config) { | 106 createServiceInspector: function(model, config) { |
108 config = config || {}; | 107 config = config || {}; |
108 var type = 'service', | |
109 charm = this.get('db').charms.getById(model.get('charm')); | |
109 | 110 |
110 // This method is called with a charm or service depending on if it's | 111 // This method is called with a charm or service depending on if it's |
111 // called from the charm browser or from the environment. If it is | 112 // called from the charm browser or from the environment. If it is |
112 // called from the environment with a ghost it still needs access to | 113 // called from the environment with a ghost it still needs access to |
113 // the charm so that's what this switcheroo is doing here. | 114 // the charm so that's what this switcheroo is doing here. |
gary.poster
2013/06/28 13:11:54
Nice simple fix, thanks
jeff.pihach
2013/06/28 14:42:09
was contemplating a 'there be dragons' warning her
| |
114 if (model.get('pending')) { | 115 if (model.get('pending')) { |
115 type = 'ghost'; | 116 type = 'ghost'; |
116 config.ghostService = model; | 117 config.ghostService = model; |
benjamin.saller
2013/06/28 17:07:17
You do this dance explicitly when calling this met
jeff.pihach
2013/06/28 17:42:26
Done.
| |
117 model = this.get('db').charms.getById(model.get('charm')); | 118 model = charm; |
118 } | 119 } |
119 | 120 |
120 // If the user is trying to open the same inspector twice | 121 // If the user is trying to open the same inspector twice |
121 if (this.getInspector(model.get('id'))) { | 122 if (this.getInspector(model.get('id'))) { |
122 return; | 123 return; |
123 } | 124 } |
124 | 125 |
125 var serviceInspector = this.getInspector(model.get('id')); | 126 var serviceInspector = this.getInspector(model.get('id')); |
gary.poster
2013/06/28 13:11:54
hm. does this mean that you can't have two ghost
jeff.pihach
2013/06/28 14:42:09
Correct this limits that - working on fix now.
benjamin.saller
2013/06/28 17:07:17
They would have to have different ids computed to
| |
126 if (serviceInspector) { return serviceInspector; } | 127 if (serviceInspector) { return serviceInspector; } |
127 | 128 |
128 var combinedConfig = {}; | 129 var combinedConfig = {}; |
129 var configs = this._generateConfigs(model); | 130 var configs = this._generateConfigs(model); |
130 | 131 |
131 if (type === 'ghost') { | 132 if (type === 'ghost') { |
132 combinedConfig = Y.mix(configs.configBase, configs.configGhost, | 133 combinedConfig = Y.mix(configs.configBase, configs.configGhost, |
133 true, undefined, 0, true); | 134 true, undefined, 0, true); |
134 } else if (type === 'service') { | 135 } else if (type === 'service') { |
135 combinedConfig = Y.mix(configs.configBase, configs.configService, | 136 combinedConfig = Y.mix(configs.configBase, configs.configService, |
136 true, undefined, 0, true); | 137 true, undefined, 0, true); |
137 } else { | |
138 console.log('Service inspector type not supported.'); | |
gary.poster
2013/06/28 13:11:54
It would be interesting to use Google Analytics to
jeff.pihach
2013/06/28 14:42:09
Agreed!
benjamin.saller
2013/06/28 17:07:17
This particular error goes away if we sniff the ty
jeff.pihach
2013/06/28 17:42:26
Done.
| |
139 return; | |
140 } | 138 } |
141 | 139 |
142 Y.mix(combinedConfig, config, true, undefined, 0, true); | 140 Y.mix(combinedConfig, config, true, undefined, 0, true); |
143 | 141 |
144 serviceInspector = new views.ServiceInspector(model, combinedConfig); | 142 serviceInspector = new views.ServiceInspector(model, combinedConfig); |
145 | 143 |
144 // Because the inspector can trigger it's own destruction we need to | |
145 // listen for the event and remove it from the list of open inspectors | |
146 serviceInspector.inspector.after('destroy', function(e) { | 146 serviceInspector.inspector.after('destroy', function(e) { |
147 this.setInspector(e.currentTarget, true); | 147 this.setInspector(e.currentTarget, true); |
gary.poster
2013/06/28 13:11:54
comment as to motive would help me read this.
jeff.pihach
2013/06/28 14:42:09
Done.
| |
148 }, this); | 148 }, this); |
149 | 149 |
150 // Restrict to a single inspector instance | 150 // Restrict to a single inspector instance |
151 if (Y.Object.size(this._inspectors) >= 1) { | 151 if (Y.Object.size(this._inspectors) >= 1) { |
152 Y.Object.each(this._inspectors, function(inspector) { | 152 Y.Object.each(this._inspectors, function(inspector) { |
153 inspector.inspector.destroy(); | 153 inspector.inspector.destroy(); |
154 }); | 154 }); |
155 } | 155 } |
156 | 156 |
157 this.setInspector(serviceInspector); | 157 this.setInspector(serviceInspector); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 }, '0.1.0', { | 322 }, '0.1.0', { |
323 requires: ['juju-templates', | 323 requires: ['juju-templates', |
324 'juju-view-utils', | 324 'juju-view-utils', |
325 'juju-models', | 325 'juju-models', |
326 'juju-topology', | 326 'juju-topology', |
327 'base-build', | 327 'base-build', |
328 'handlebars-base', | 328 'handlebars-base', |
329 'node', | 329 'node', |
330 'view'] | 330 'view'] |
331 }); | 331 }); |
LEFT | RIGHT |