Left: | ||
Right: |
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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
356 mousemove: 'serviceMouseMove' | 356 mousemove: 'serviceMouseMove' |
357 }, | 357 }, |
358 | 358 |
359 '.service-status': { | 359 '.service-status': { |
360 mouseover: 'serviceStatusMouseOver', | 360 mouseover: 'serviceStatusMouseOver', |
361 mouseout: 'serviceStatusMouseOut' | 361 mouseout: 'serviceStatusMouseOut' |
362 }, | 362 }, |
363 // See _attachDragEvents for the drag and drop event registrations | 363 // See _attachDragEvents for the drag and drop event registrations |
364 '.zoom-plane': { | 364 '.zoom-plane': { |
365 click: 'canvasClick' | 365 click: 'canvasClick' |
366 }, | |
367 // Menu/Controls | |
368 '.view-service': { | |
369 click: 'viewServiceClick', | |
370 touchstart: 'viewServiceClick' | |
371 }, | |
372 '.destroy-service': { | |
373 click: 'destroyServiceClick' | |
rharding
2013/09/19 15:06:28
these menus are gone
| |
374 } | 366 } |
375 }, | 367 }, |
376 d3: { | 368 d3: { |
377 '.service': { | 369 '.service': { |
378 'mousedown.addrel': 'serviceAddRelMouseDown', | 370 'mousedown.addrel': 'serviceAddRelMouseDown', |
379 'mouseup.addrel': 'serviceAddRelMouseUp' | 371 'mouseup.addrel': 'serviceAddRelMouseUp' |
380 } | 372 } |
381 }, | 373 }, |
382 yui: { | 374 yui: { |
383 /** | 375 /** |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
574 box.ignoreNextClick = true; | 566 box.ignoreNextClick = true; |
575 } | 567 } |
576 | 568 |
577 if (box.ignoreNextClick) { | 569 if (box.ignoreNextClick) { |
578 box.ignoreNextClick = false; | 570 box.ignoreNextClick = false; |
579 return; | 571 return; |
580 } | 572 } |
581 | 573 |
582 // If the service box is pending, ensure that the charm panel is | 574 // If the service box is pending, ensure that the charm panel is |
583 // visible, but don't do anything else. | 575 // visible, but don't do anything else. |
584 if (box.pending && !window.flags.serviceInspector) { | 576 if (box.pending) { |
gary.poster
2013/09/19 15:51:29
Wait a sec, this says to only do the block if serv
rharding
2013/09/19 17:10:57
Yes, misread this one.
| |
585 // Prevent the clickoutside event from firing and immediately | 577 // Prevent the clickoutside event from firing and immediately |
586 // closing the panel. | 578 // closing the panel. |
587 d3.event.halt(); | 579 d3.event.halt(); |
588 // Ensure service menus are closed. | 580 // Ensure service menus are closed. |
589 topo.fire('clearState'); | 581 topo.fire('clearState'); |
590 views.CharmPanel.getInstance().show(); | 582 views.CharmPanel.getInstance().show(); |
591 return; | 583 return; |
592 } | 584 } |
593 // serviceClick is being called after dragend is processed. In those | 585 // serviceClick is being called after dragend is processed. In those |
594 // cases the current click action should not be invoked. | 586 // cases the current click action should not be invoked. |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
791 * @return {undefined} Side effects only. | 783 * @return {undefined} Side effects only. |
792 */ | 784 */ |
793 clearStateHandler: function() { | 785 clearStateHandler: function() { |
794 var container = this.get('container'), | 786 var container = this.get('container'), |
795 topo = this.get('component'); | 787 topo = this.get('component'); |
796 container.all('.environment-menu.active').removeClass('active'); | 788 container.all('.environment-menu.active').removeClass('active'); |
797 this.hideServiceMenu(); | 789 this.hideServiceMenu(); |
798 }, | 790 }, |
799 | 791 |
800 /** | 792 /** |
801 * The user clicked on the "View" menu item. | |
802 * | |
803 * @method viewServiceClick | |
804 */ | |
805 viewServiceClick: function(_, context) { | |
806 // Get the service element | |
807 var topo = context.get('component'); | |
808 var box = topo.get('active_service'); | |
809 var service = box.model; | |
810 context.hideServiceMenu(); | |
811 context.show_service(service); | |
812 }, | |
813 | |
814 /** | |
815 * The user clicked on the "Destroy" menu item. | |
816 * | |
817 * @method destroyServiceClick | |
818 */ | |
819 destroyServiceClick: function(_, context) { | |
820 // Get the service element | |
821 var topo = context.get('component'); | |
822 var box = topo.get('active_service'); | |
823 context.hideServiceMenu(); | |
824 if (window.flags && window.flags.serviceInspector) { | |
825 context.destroyServiceInspector(); | |
826 } | |
827 context.destroyServiceConfirm(box); | |
rharding
2013/09/19 15:06:28
and the callbacks for them are no longer required.
| |
828 }, | |
829 | |
830 /** | |
831 Destroys the service inspector when it's service topo destroy | 793 Destroys the service inspector when it's service topo destroy |
832 button is clicked. | 794 button is clicked. |
833 | 795 |
834 @method destroyServiceInspector | 796 @method destroyServiceInspector |
835 */ | 797 */ |
836 destroyServiceInspector: function() { | 798 destroyServiceInspector: function() { |
837 this.get('component').fire('destroyServiceInspector'); | 799 this.get('component').fire('destroyServiceInspector'); |
838 }, | 800 }, |
839 | 801 |
840 /** | 802 /** |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1358 */ | 1320 */ |
1359 showServiceMenu: function(box) { | 1321 showServiceMenu: function(box) { |
1360 var serviceMenu = this.get('container').one('#service-menu'); | 1322 var serviceMenu = this.get('container').one('#service-menu'); |
1361 var topo = this.get('component'); | 1323 var topo = this.get('component'); |
1362 var service = box.model; | 1324 var service = box.model; |
1363 var landscape = topo.get('landscape'); | 1325 var landscape = topo.get('landscape'); |
1364 var landscapeReboot = serviceMenu.one('.landscape-reboot').hide(); | 1326 var landscapeReboot = serviceMenu.one('.landscape-reboot').hide(); |
1365 var landscapeSecurity = serviceMenu.one('.landscape-security').hide(); | 1327 var landscapeSecurity = serviceMenu.one('.landscape-security').hide(); |
1366 var triangle = serviceMenu.one('.triangle'); | 1328 var triangle = serviceMenu.one('.triangle'); |
1367 var securityURL, rebootURL; | 1329 var securityURL, rebootURL; |
1368 var flags = window.flags; | |
1369 | 1330 |
1370 if (flags.serviceInspector) { | 1331 this.show_service(service); |
1371 this.show_service(service); | |
1372 } | |
1373 | 1332 |
1374 if (service.get('pending')) { | 1333 if (service.get('pending')) { |
1375 return true; | 1334 return true; |
1376 } | 1335 } |
1377 | 1336 |
1378 // Update landscape links and show/hide as needed. | 1337 // Update landscape links and show/hide as needed. |
1379 if (landscape && !flags.serviceInspector) { | 1338 if (landscape) { |
gary.poster
2013/09/19 15:51:29
No, look, this says *not* serviceInspector. We ca
| |
1380 rebootURL = landscape.getLandscapeURL(service, 'reboot'); | 1339 rebootURL = landscape.getLandscapeURL(service, 'reboot'); |
1381 securityURL = landscape.getLandscapeURL(service, 'security'); | 1340 securityURL = landscape.getLandscapeURL(service, 'security'); |
1382 | 1341 |
1383 if (rebootURL && service['landscape-needs-reboot']) { | 1342 if (rebootURL && service['landscape-needs-reboot']) { |
1384 landscapeReboot.show().one('a').set('href', rebootURL); | 1343 landscapeReboot.show().one('a').set('href', rebootURL); |
1385 } | 1344 } |
1386 if (securityURL && service['landscape-security-upgrades']) { | 1345 if (securityURL && service['landscape-security-upgrades']) { |
1387 landscapeSecurity.show().one('a').set('href', securityURL); | 1346 landscapeSecurity.show().one('a').set('href', securityURL); |
1388 } | 1347 } |
1389 } | 1348 } |
1390 | 1349 |
1391 // The view option should not be used with the inspector. | |
1392 if (flags.serviceInspector) { | |
1393 serviceMenu.one('.view-service').hide(); | |
1394 serviceMenu.one('.destroy-service').hide(); | |
1395 } | |
1396 | |
1397 if (box && !serviceMenu.hasClass('active')) { | 1350 if (box && !serviceMenu.hasClass('active')) { |
1398 topo.set('active_service', box); | 1351 topo.set('active_service', box); |
1399 topo.set('active_context', box.node); | 1352 topo.set('active_context', box.node); |
1400 serviceMenu.addClass('active'); | 1353 serviceMenu.addClass('active'); |
1401 | 1354 |
1402 var menuHeight = serviceMenu.getDOMNode().getClientRects()[0].height; | 1355 var menuHeight = serviceMenu.getDOMNode().getClientRects()[0].height; |
1403 var triHeight = 18; | 1356 var triHeight = 18; |
1404 triangle.setStyle('top', ((menuHeight - triHeight) / 2) + 'px'); | 1357 triangle.setStyle('top', ((menuHeight - triHeight) / 2) + 'px'); |
1405 | 1358 |
1406 // Disable the 'Build Relation' link if the charm has not yet loaded. | 1359 // Disable the 'Build Relation' link if the charm has not yet loaded. |
1407 var addRelation = serviceMenu.one('.add-relation'); | 1360 var addRelation = serviceMenu.one('.add-relation'); |
1408 if (this.allowBuildRelation(topo, service)) { | 1361 if (this.allowBuildRelation(topo, service)) { |
1409 addRelation.removeClass('disabled'); | 1362 addRelation.removeClass('disabled'); |
1410 } else { | 1363 } else { |
1411 addRelation.addClass('disabled'); | 1364 addRelation.addClass('disabled'); |
1412 } | 1365 } |
1413 | 1366 |
1414 // We do not want the user destroying the Juju GUI service. | |
1415 if (utils.isGuiService(service)) { | |
1416 serviceMenu.one('.destroy-service').addClass('disabled'); | |
1417 } | |
rharding
2013/09/19 15:06:28
this was about changing the menu for the inspector
| |
1418 this.updateServiceMenuLocation(); | 1367 this.updateServiceMenuLocation(); |
1419 } | 1368 } |
1420 }, | 1369 }, |
1421 | 1370 |
1422 /** | 1371 /** |
1423 * Hide the service menu. | 1372 * Hide the service menu. |
1424 * | 1373 * |
1425 * @method hideServiceMenu | 1374 * @method hideServiceMenu |
1426 * @param {object} box The presentation state for the service (unused). | 1375 * @param {object} box The presentation state for the service (unused). |
1427 * @return {undefined} Side effects only. | 1376 * @return {undefined} Side effects only. |
1428 */ | 1377 */ |
1429 hideServiceMenu: function(box) { | 1378 hideServiceMenu: function(box) { |
1430 var serviceMenu = this.get('container').one('#service-menu'); | 1379 var serviceMenu = this.get('container').one('#service-menu'); |
1431 var topo = this.get('component'); | 1380 var topo = this.get('component'); |
1432 | 1381 |
1433 if (serviceMenu.hasClass('active')) { | 1382 if (serviceMenu.hasClass('active')) { |
1434 serviceMenu.removeClass('active'); | 1383 serviceMenu.removeClass('active'); |
1435 topo.set('active_service', null); | 1384 topo.set('active_service', null); |
1436 topo.set('active_context', null); | 1385 topo.set('active_context', null); |
1437 // Most services can be destroyed via the GUI. | |
1438 serviceMenu.one('.destroy-service').removeClass('disabled'); | |
1439 } | 1386 } |
1440 }, | 1387 }, |
1441 | 1388 |
1442 /* | 1389 /* |
1443 * View a service | 1390 * View a service |
1444 * | 1391 * |
1445 * @method show_service | 1392 * @method show_service |
1446 */ | 1393 */ |
1447 show_service: function(service) { | 1394 show_service: function(service) { |
1448 var topo = this.get('component'); | 1395 var topo = this.get('component'); |
1449 var createServiceInspector = topo.get('createServiceInspector'); | 1396 var createServiceInspector = topo.get('createServiceInspector'); |
1450 var getModelURL = topo.get('getModelURL'); | |
1451 // to satisfy linter; | |
1452 var flags = window.flags; | |
1453 | 1397 |
1454 topo.detachContainer(); | 1398 topo.detachContainer(); |
1455 if (flags.serviceInspector) { | 1399 createServiceInspector(service); |
rharding
2013/09/19 15:06:28
this is what caused tests to have issues. The serv
| |
1456 createServiceInspector(service); | |
1457 } else { | |
1458 topo.fire('navigateTo', { | |
1459 url: getModelURL(service) | |
1460 }); | |
1461 } | |
1462 }, | 1400 }, |
1463 | 1401 |
1464 /* | 1402 /* |
1465 * Show a dialog before destroying a service | 1403 * Show a dialog before destroying a service |
1466 * | 1404 * |
1467 * @method destroyServiceConfirm | 1405 * @method destroyServiceConfirm |
1468 */ | 1406 */ |
1469 destroyServiceConfirm: function(box) { | 1407 destroyServiceConfirm: function(box) { |
1470 // Set service in view. | 1408 // Set service in view. |
1471 this.set('destroy_service', box.model); | 1409 this.set('destroy_service', box.model); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1537 'd3', | 1475 'd3', |
1538 'd3-components', | 1476 'd3-components', |
1539 'd3-statusbar', | 1477 'd3-statusbar', |
1540 'juju-view-service', | 1478 'juju-view-service', |
1541 'juju-templates', | 1479 'juju-templates', |
1542 'juju-models', | 1480 'juju-models', |
1543 'juju-env', | 1481 'juju-env', |
1544 'unscaled-pack-layout' | 1482 'unscaled-pack-layout' |
1545 ] | 1483 ] |
1546 }); | 1484 }); |
OLD | NEW |