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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
257 box.ignoreNextClick = true; | 257 box.ignoreNextClick = true; |
258 } | 258 } |
259 | 259 |
260 if (box.ignoreNextClick) { | 260 if (box.ignoreNextClick) { |
261 box.ignoreNextClick = false; | 261 box.ignoreNextClick = false; |
262 return; | 262 return; |
263 } | 263 } |
264 | 264 |
265 // If the service box is pending, ensure that the charm panel is | 265 // If the service box is pending, ensure that the charm panel is |
266 // visible, but don't do anything else. | 266 // visible, but don't do anything else. |
267 if (box.pending) { | 267 if (box.pending && !window.flags.serviceInspector) { |
268 // Prevent the clickoutside event from firing and immediately closing | 268 // Prevent the clickoutside event from firing and immediately closing |
269 // the panel. | 269 // the panel. |
270 d3.event.halt(); | 270 d3.event.halt(); |
271 // Ensure service menus are closed. | 271 // Ensure service menus are closed. |
272 topo.fire('clearState'); | 272 topo.fire('clearState'); |
273 views.CharmPanel.getInstance().show(); | 273 views.CharmPanel.getInstance().show(); |
274 return; | 274 return; |
275 } | 275 } |
276 // serviceClick is being called after dragend is processed. In those | 276 // serviceClick is being called after dragend is processed. In those |
277 // cases the current click action should not be invoked. | 277 // cases the current click action should not be invoked. |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
375 */ | 375 */ |
376 canvasClick: function(box, self) { | 376 canvasClick: function(box, self) { |
377 var topo = self.get('component'); | 377 var topo = self.get('component'); |
378 topo.fire('clearState'); | 378 topo.fire('clearState'); |
379 }, | 379 }, |
380 | 380 |
381 /** | 381 /** |
382 * Handle deploying a services by dropping a charm onto the canvas. | 382 * Handle deploying a services by dropping a charm onto the canvas. |
383 * | 383 * |
384 * @method canvasDropHandler | 384 * @method canvasDropHandler |
385 * @static | |
385 * @return {undefined} Nothing. | 386 * @return {undefined} Nothing. |
386 */ | 387 */ |
387 canvasDropHandler: function() { | 388 canvasDropHandler: function() { |
jeff.pihach
2013/06/24 22:35:08
- possible followup branch
This should take note
benji
2013/06/25 20:56:36
+1
| |
388 // XXX Why do we have to dig so deep just to get to the event? And why | 389 var evt = d3.event._event; // So well hidden. |
jeff.pihach
2013/06/24 22:35:08
Typically libraries will wrap native objects with
| |
389 // is it not just passed into the handler? | |
390 var evt = d3.event._event; | |
391 var dataType = evt.dataTransfer.getData('dataType'); | 390 var dataType = evt.dataTransfer.getData('dataType'); |
392 if (dataType === 'charm-token-drag-and-drop') { | 391 if (dataType === 'charm-token-drag-and-drop') { |
392 // The charm data was JSON encoded because the dataTransfer mechanism | |
393 // only allows for string values. | |
393 var charmData = Y.JSON.parse(evt.dataTransfer.getData('charmData')); | 394 var charmData = Y.JSON.parse(evt.dataTransfer.getData('charmData')); |
394 var charm = new models.Charm(charmData); | 395 var charm = new models.Charm(charmData); |
395 Y.fire('initiateDeploy', charm); | 396 Y.fire('initiateDeploy', charm); |
jeff.pihach
2013/06/24 22:35:08
This should not be firing on Y, but firing from th
benji
2013/06/25 20:56:36
See note on subscribing end.
| |
396 } | 397 } |
397 }, | 398 }, |
398 | 399 |
399 /** | 400 /** |
400 * Clear any stateful actions (menus, etc.) when a clearState event is | 401 * Clear any stateful actions (menus, etc.) when a clearState event is |
401 * received. | 402 * received. |
402 * | 403 * |
403 * @method clearStateHandler | 404 * @method clearStateHandler |
404 * @return {undefined} Side effects only. | 405 * @return {undefined} Side effects only. |
405 */ | 406 */ |
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1338 var topo = this.get('component'); | 1339 var topo = this.get('component'); |
1339 var setInspector = topo.get('setInspector'); | 1340 var setInspector = topo.get('setInspector'); |
1340 var getInspector = topo.get('getInspector'); | 1341 var getInspector = topo.get('getInspector'); |
1341 var nsRouter = topo.get('nsRouter'); | 1342 var nsRouter = topo.get('nsRouter'); |
1342 var getModelURL = topo.get('getModelURL'); | 1343 var getModelURL = topo.get('getModelURL'); |
1343 // to satisfy linter; | 1344 // to satisfy linter; |
1344 var flags = window.flags; | 1345 var flags = window.flags; |
1345 | 1346 |
1346 topo.detachContainer(); | 1347 topo.detachContainer(); |
1347 if (flags.serviceInspector) { | 1348 if (flags.serviceInspector) { |
1349 // XXX: switch on pending to handle ghost config. | |
1348 var serviceInspector = getInspector(service.get('id')); | 1350 var serviceInspector = getInspector(service.get('id')); |
1349 if (!serviceInspector) { | 1351 if (!serviceInspector) { |
1350 serviceInspector = new views.ServiceInspector(service); | 1352 serviceInspector = new views.ServiceInspector(service, { |
1353 db: topo.get('db') | |
1354 }); | |
1351 serviceInspector.inspector.after('destroy', function(e) { | 1355 serviceInspector.inspector.after('destroy', function(e) { |
1352 setInspector(e.currentTarget, true); | 1356 setInspector(e.currentTarget, true); |
1353 }); | 1357 }); |
1354 setInspector(serviceInspector); | 1358 setInspector(serviceInspector); |
1355 } | 1359 } |
1356 } else { | 1360 } else { |
1357 topo.fire('navigateTo', { | 1361 topo.fire('navigateTo', { |
1358 url: getModelURL(service) | 1362 url: getModelURL(service) |
1359 }); | 1363 }); |
1360 } | 1364 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1435 requires: [ | 1439 requires: [ |
1436 'd3', | 1440 'd3', |
1437 'd3-components', | 1441 'd3-components', |
1438 'juju-view-service', | 1442 'juju-view-service', |
1439 'juju-templates', | 1443 'juju-templates', |
1440 'juju-models', | 1444 'juju-models', |
1441 'juju-env', | 1445 'juju-env', |
1442 'unscaled-pack-layout' | 1446 'unscaled-pack-layout' |
1443 ] | 1447 ] |
1444 }); | 1448 }); |
LEFT | RIGHT |