From 25275685e9a735e51fae8b1a936ba5733f6fb770 Mon Sep 17 00:00:00 2001 From: Parker Berberian Date: Wed, 10 Oct 2018 16:06:47 -0400 Subject: Lab as a Service 2.0 See changes here: https://wiki.opnfv.org/display/INF/Pharos+Laas Change-Id: I59ada5f98e70a28d7f8c14eab3239597e236ca26 Signed-off-by: Sawyer Bergeron Signed-off-by: Parker Berberian --- dashboard/Makefile | 4 +- dashboard/booking_communication_agent.py | 8 + dashboard/config.env.sample | 5 +- dashboard/config/nginx/pharos_dashboard.conf | 26 +- dashboard/data/UNH_IOL/HPE_Proliant/hpe13.yaml | 53 + dashboard/data/UNH_IOL/HPE_Proliant/hpe14.yaml | 41 + dashboard/data/UNH_IOL/HPE_Proliant/hpe15.yaml | 41 + dashboard/data/UNH_IOL/HPE_Proliant/hpe16.yaml | 41 + dashboard/data/UNH_IOL/HPE_Proliant/hpe17.yaml | 41 + dashboard/data/UNH_IOL/HPE_Proliant/hpe18.yaml | 41 + dashboard/data/UNH_IOL/HPE_Proliant/hpe19.yaml | 41 + dashboard/data/UNH_IOL/HPE_Proliant/hpe20.yaml | 41 + dashboard/data/UNH_IOL/hostlist.json | 14 + dashboard/docker-compose.yml | 1 + dashboard/requirements.txt | 12 +- dashboard/src/account/admin.py | 5 +- dashboard/src/account/migrations/0001_initial.py | 33 +- .../account/migrations/0002_auto_20180110_1636.py | 33 - .../src/account/migrations/0002_lab_description.py | 19 + .../account/migrations/0003_auto_20180110_1639.py | 24 - .../src/account/migrations/0003_publicnetwork.py | 25 + dashboard/src/account/migrations/__init__.py | 10 - dashboard/src/account/models.py | 127 ++ dashboard/src/account/tasks.py | 4 +- dashboard/src/account/urls.py | 7 + dashboard/src/account/views.py | 48 + dashboard/src/api/admin.py | 28 + dashboard/src/api/migrations/0001_initial.py | 185 ++ dashboard/src/api/migrations/__init__.py | 4 +- dashboard/src/api/models.py | 713 ++++++++ dashboard/src/api/serializers.py | 53 - dashboard/src/api/serializers/__init__.py | 8 + .../src/api/serializers/booking_serializer.py | 156 ++ dashboard/src/api/serializers/old_serializers.py | 28 + dashboard/src/api/tests/__init__.py | 8 + dashboard/src/api/tests/test_serializers.py | 213 +++ dashboard/src/api/urls.py | 13 +- dashboard/src/api/views.py | 101 +- dashboard/src/booking/__init__.py | 2 - dashboard/src/booking/admin.py | 4 +- dashboard/src/booking/forms.py | 65 - dashboard/src/booking/migrations/0001_initial.py | 48 +- .../booking/migrations/0002_booking_changeid.py | 38 - .../booking/migrations/0003_auto_20180108_2024.py | 25 - .../booking/migrations/0004_booking_ext_count.py | 27 - dashboard/src/booking/migrations/__init__.py | 10 - dashboard/src/booking/models.py | 60 +- dashboard/src/booking/stats.py | 56 + dashboard/src/booking/tests/__init__.py | 2 - dashboard/src/booking/tests/test_models.py | 216 ++- dashboard/src/booking/tests/test_views.py | 106 -- dashboard/src/booking/urls.py | 16 +- dashboard/src/booking/views.py | 138 +- dashboard/src/dashboard/__init__.py | 2 - dashboard/src/dashboard/admin.py | 6 +- dashboard/src/dashboard/context_processors.py | 12 + dashboard/src/dashboard/exceptions.py | 46 + dashboard/src/dashboard/migrations/0001_initial.py | 64 - .../migrations/0002_auto_20170505_0815.py | 42 - .../migrations/0003_resource_resource_lab.py | 22 - dashboard/src/dashboard/migrations/__init__.py | 10 - dashboard/src/dashboard/models.py | 90 +- dashboard/src/dashboard/populate_db_iol.py | 346 ++++ dashboard/src/dashboard/tasks.py | 113 +- .../src/dashboard/templatetags/jenkins_filters.py | 38 - dashboard/src/dashboard/tests/test_models.py | 69 - dashboard/src/dashboard/tests/test_views.py | 75 - dashboard/src/dashboard/urls.py | 17 +- dashboard/src/dashboard/views.py | 196 +-- dashboard/src/jenkins/__init__.py | 10 - dashboard/src/jenkins/adapter.py | 137 -- dashboard/src/jenkins/admin.py | 17 - dashboard/src/jenkins/apps.py | 15 - dashboard/src/jenkins/migrations/0001_initial.py | 53 - dashboard/src/jenkins/migrations/__init__.py | 10 - dashboard/src/jenkins/models.py | 62 - dashboard/src/jenkins/tasks.py | 64 - dashboard/src/jenkins/tests.py | 129 -- dashboard/src/manage.py | 0 dashboard/src/notifier/__init__.py | 8 + dashboard/src/notifier/admin.py | 4 +- dashboard/src/notifier/apps.py | 3 +- dashboard/src/notifier/dispatchers.py | 4 +- dashboard/src/notifier/manager.py | 98 ++ dashboard/src/notifier/migrations/0001_initial.py | 25 +- dashboard/src/notifier/models.py | 33 +- dashboard/src/notifier/tests/test_dispatcher.py | 17 + dashboard/src/notifier/tests/test_models.py | 29 + dashboard/src/notifier/urls.py | 21 + dashboard/src/notifier/views.py | 34 + dashboard/src/pharos_dashboard/settings.py | 52 +- dashboard/src/pharos_dashboard/urls.py | 11 +- dashboard/src/resource_inventory/__init__.py | 8 + dashboard/src/resource_inventory/admin.py | 29 + dashboard/src/resource_inventory/apps.py | 14 + .../resource_inventory/migrations/0001_initial.py | 328 ++++ .../migrations/0002_auto_20180919_1459.py | 18 + .../migrations/0003_vlan_public.py | 18 + .../src/resource_inventory/migrations/__init__.py | 0 dashboard/src/resource_inventory/models.py | 299 ++++ .../src/resource_inventory/resource_manager.py | 197 +++ .../src/resource_inventory/tests/test_managers.py | 236 +++ .../src/resource_inventory/tests/test_models.py | 162 ++ dashboard/src/resource_inventory/urls.py | 34 + dashboard/src/resource_inventory/views.py | 24 + dashboard/src/static/css/graph_common.css | 162 ++ dashboard/src/static/css/theme.css | 6 + dashboard/src/static/img/mxgraph/add.png | Bin 0 -> 1564 bytes dashboard/src/static/img/mxgraph/button.gif | Bin 0 -> 137 bytes dashboard/src/static/img/mxgraph/camera.png | Bin 0 -> 887 bytes dashboard/src/static/img/mxgraph/check.png | Bin 0 -> 253 bytes dashboard/src/static/img/mxgraph/close.gif | Bin 0 -> 70 bytes dashboard/src/static/img/mxgraph/close.png | Bin 0 -> 1910 bytes dashboard/src/static/img/mxgraph/collapsed.gif | Bin 0 -> 877 bytes dashboard/src/static/img/mxgraph/connector.gif | Bin 0 -> 954 bytes dashboard/src/static/img/mxgraph/copy.png | Bin 0 -> 728 bytes dashboard/src/static/img/mxgraph/cut.png | Bin 0 -> 781 bytes dashboard/src/static/img/mxgraph/delete2.png | Bin 0 -> 914 bytes dashboard/src/static/img/mxgraph/dot.gif | Bin 0 -> 517 bytes dashboard/src/static/img/mxgraph/error.gif | Bin 0 -> 907 bytes dashboard/src/static/img/mxgraph/expanded.gif | Bin 0 -> 878 bytes dashboard/src/static/img/mxgraph/export1.png | Bin 0 -> 857 bytes dashboard/src/static/img/mxgraph/fit_to_size.png | Bin 0 -> 529 bytes .../src/static/img/mxgraph/gradient_background.jpg | Bin 0 -> 6164 bytes dashboard/src/static/img/mxgraph/green-dot.gif | Bin 0 -> 326 bytes dashboard/src/static/img/mxgraph/group.png | Bin 0 -> 899 bytes .../src/static/img/mxgraph/handle-connect.png | Bin 0 -> 1300 bytes dashboard/src/static/img/mxgraph/handle-main.png | Bin 0 -> 379 bytes .../src/static/img/mxgraph/icons48/column.png | Bin 0 -> 1787 bytes dashboard/src/static/img/mxgraph/icons48/earth.png | Bin 0 -> 4520 bytes dashboard/src/static/img/mxgraph/icons48/gear.png | Bin 0 -> 4418 bytes dashboard/src/static/img/mxgraph/icons48/keys.png | Bin 0 -> 4295 bytes .../src/static/img/mxgraph/icons48/mail_new.png | Bin 0 -> 3944 bytes .../src/static/img/mxgraph/icons48/server.png | Bin 0 -> 3556 bytes dashboard/src/static/img/mxgraph/icons48/table.png | Bin 0 -> 1574 bytes dashboard/src/static/img/mxgraph/key.png | Bin 0 -> 300 bytes dashboard/src/static/img/mxgraph/loading.gif | Bin 0 -> 7517 bytes dashboard/src/static/img/mxgraph/maximize.gif | Bin 0 -> 843 bytes dashboard/src/static/img/mxgraph/minimize.gif | Bin 0 -> 64 bytes .../src/static/img/mxgraph/navigate_minus.png | Bin 0 -> 485 bytes dashboard/src/static/img/mxgraph/navigate_plus.png | Bin 0 -> 709 bytes dashboard/src/static/img/mxgraph/normalize.gif | Bin 0 -> 845 bytes dashboard/src/static/img/mxgraph/paste.png | Bin 0 -> 783 bytes dashboard/src/static/img/mxgraph/plus.png | Bin 0 -> 236 bytes dashboard/src/static/img/mxgraph/point.gif | Bin 0 -> 55 bytes dashboard/src/static/img/mxgraph/press32.png | Bin 0 -> 2261 bytes dashboard/src/static/img/mxgraph/print32.png | Bin 0 -> 2111 bytes dashboard/src/static/img/mxgraph/printer.png | Bin 0 -> 896 bytes dashboard/src/static/img/mxgraph/redo.png | Bin 0 -> 895 bytes dashboard/src/static/img/mxgraph/resize.gif | Bin 0 -> 74 bytes dashboard/src/static/img/mxgraph/separator.gif | Bin 0 -> 146 bytes dashboard/src/static/img/mxgraph/sidebar_bg.gif | Bin 0 -> 80 bytes dashboard/src/static/img/mxgraph/spacer.gif | Bin 0 -> 43 bytes dashboard/src/static/img/mxgraph/submenu.gif | Bin 0 -> 56 bytes dashboard/src/static/img/mxgraph/toolbar_bg.gif | Bin 0 -> 155 bytes dashboard/src/static/img/mxgraph/transparent.gif | Bin 0 -> 90 bytes dashboard/src/static/img/mxgraph/undo.png | Bin 0 -> 879 bytes dashboard/src/static/img/mxgraph/view_1_1.png | Bin 0 -> 849 bytes dashboard/src/static/img/mxgraph/view_1_132.png | Bin 0 -> 2199 bytes dashboard/src/static/img/mxgraph/view_next.png | Bin 0 -> 918 bytes dashboard/src/static/img/mxgraph/view_previous.png | Bin 0 -> 912 bytes dashboard/src/static/img/mxgraph/warning.gif | Bin 0 -> 276 bytes dashboard/src/static/img/mxgraph/warning.png | Bin 0 -> 425 bytes dashboard/src/static/img/mxgraph/window-title.gif | Bin 0 -> 275 bytes dashboard/src/static/img/mxgraph/window.gif | Bin 0 -> 75 bytes dashboard/src/static/img/mxgraph/wires-grid.gif | Bin 0 -> 50 bytes dashboard/src/static/img/mxgraph/zoom_in.png | Bin 0 -> 858 bytes dashboard/src/static/img/mxgraph/zoom_in32.png | Bin 0 -> 2184 bytes dashboard/src/static/img/mxgraph/zoom_out.png | Bin 0 -> 847 bytes dashboard/src/static/img/mxgraph/zoom_out32.png | Bin 0 -> 2150 bytes dashboard/src/static/js/mxClient.min.js | 1808 ++++++++++++++++++++ dashboard/src/templates/account/booking_list.html | 52 + .../src/templates/account/configuration_list.html | 28 + dashboard/src/templates/account/details.html | 9 + dashboard/src/templates/account/image_list.html | 27 + dashboard/src/templates/account/resource_list.html | 28 + dashboard/src/templates/account/user_list.html | 2 +- dashboard/src/templates/base.html | 118 +- .../src/templates/booking/booking_calendar.html | 65 + .../src/templates/booking/booking_detail.html | 361 +++- .../src/templates/booking/booking_grid_item.html | 11 + dashboard/src/templates/booking/booking_list.html | 6 +- dashboard/src/templates/booking/stats.html | 60 + .../templates/booking/steps/booking_confirm.html | 25 + .../src/templates/booking/steps/booking_meta.html | 66 + .../templates/booking/steps/resource_select.html | 73 + .../templates/booking/steps/swconfig_select.html | 73 + .../config_bundle/steps/config_software.html | 72 + .../config_bundle/steps/define_software.html | 102 ++ dashboard/src/templates/dashboard/ci_pods.html | 61 - dashboard/src/templates/dashboard/dev_pods.html | 70 - dashboard/src/templates/dashboard/grid.html | 10 + .../templates/dashboard/host_profile_detail.html | 71 + .../src/templates/dashboard/jenkins_slaves.html | 46 - dashboard/src/templates/dashboard/lab_detail.html | 157 ++ dashboard/src/templates/dashboard/lab_list.html | 87 + dashboard/src/templates/dashboard/landing.html | 88 + dashboard/src/templates/dashboard/login.html | 8 + .../dashboard/multiple_select_filter_widget.html | 402 +++++ dashboard/src/templates/dashboard/pdf.yaml | 95 + dashboard/src/templates/dashboard/resource.html | 3 +- .../src/templates/dashboard/resource_all.html | 5 +- .../src/templates/dashboard/resource_detail.html | 52 - .../dashboard/searchable_select_multiple.html | 408 +++++ dashboard/src/templates/dashboard/table.html | 1 + dashboard/src/templates/layout.html | 10 +- dashboard/src/templates/notifier/inbox.html | 86 + dashboard/src/templates/notifier/notification.html | 34 + dashboard/src/templates/resource/hosts.html | 45 + dashboard/src/templates/resource/mxClient.min.js | 1808 ++++++++++++++++++++ .../templates/resource/steps/define_hardware.html | 37 + .../src/templates/resource/steps/host_info.html | 43 + .../templates/resource/steps/pod_definition.html | 653 +++++++ dashboard/src/templates/resource/uncommon.css | 162 ++ .../templates/snapshot_workflow/steps/meta.html | 27 + .../snapshot_workflow/steps/select_host.html | 95 + dashboard/src/templates/workflow/confirm.html | 125 ++ dashboard/src/templates/workflow/no_workflow.html | 7 + .../src/templates/workflow/resource_select.html | 50 + .../src/templates/workflow/viewport-base.html | 426 +++++ .../src/templates/workflow/viewport-element.html | 69 + dashboard/src/workflow/__init__.py | 8 + dashboard/src/workflow/apps.py | 15 + dashboard/src/workflow/booking_workflow.py | 295 ++++ dashboard/src/workflow/forms.py | 446 +++++ dashboard/src/workflow/models.py | 508 ++++++ dashboard/src/workflow/resource_bundle_workflow.py | 427 +++++ dashboard/src/workflow/snapshot_workflow.py | 111 ++ dashboard/src/workflow/sw_bundle_workflow.py | 238 +++ dashboard/src/workflow/tests/__init__.py | 8 + dashboard/src/workflow/tests/constants.py | 198 +++ dashboard/src/workflow/tests/test_steps.py | 271 +++ dashboard/src/workflow/tests/test_steps_render.py | 36 + dashboard/src/workflow/tests/test_workflows.py | 96 ++ dashboard/src/workflow/urls.py | 34 + dashboard/src/workflow/views.py | 108 ++ dashboard/src/workflow/workflow_factory.py | 149 ++ dashboard/src/workflow/workflow_manager.py | 251 +++ dashboard/test.sh | 12 + 239 files changed, 15978 insertions(+), 2047 deletions(-) create mode 100644 dashboard/data/UNH_IOL/HPE_Proliant/hpe13.yaml create mode 100644 dashboard/data/UNH_IOL/HPE_Proliant/hpe14.yaml create mode 100644 dashboard/data/UNH_IOL/HPE_Proliant/hpe15.yaml create mode 100644 dashboard/data/UNH_IOL/HPE_Proliant/hpe16.yaml create mode 100644 dashboard/data/UNH_IOL/HPE_Proliant/hpe17.yaml create mode 100644 dashboard/data/UNH_IOL/HPE_Proliant/hpe18.yaml create mode 100644 dashboard/data/UNH_IOL/HPE_Proliant/hpe19.yaml create mode 100644 dashboard/data/UNH_IOL/HPE_Proliant/hpe20.yaml create mode 100644 dashboard/data/UNH_IOL/hostlist.json delete mode 100644 dashboard/src/account/migrations/0002_auto_20180110_1636.py create mode 100644 dashboard/src/account/migrations/0002_lab_description.py delete mode 100644 dashboard/src/account/migrations/0003_auto_20180110_1639.py create mode 100644 dashboard/src/account/migrations/0003_publicnetwork.py create mode 100644 dashboard/src/api/admin.py create mode 100644 dashboard/src/api/migrations/0001_initial.py create mode 100644 dashboard/src/api/models.py delete mode 100644 dashboard/src/api/serializers.py create mode 100644 dashboard/src/api/serializers/__init__.py create mode 100644 dashboard/src/api/serializers/booking_serializer.py create mode 100644 dashboard/src/api/serializers/old_serializers.py create mode 100644 dashboard/src/api/tests/__init__.py create mode 100644 dashboard/src/api/tests/test_serializers.py delete mode 100644 dashboard/src/booking/forms.py delete mode 100644 dashboard/src/booking/migrations/0002_booking_changeid.py delete mode 100644 dashboard/src/booking/migrations/0003_auto_20180108_2024.py delete mode 100644 dashboard/src/booking/migrations/0004_booking_ext_count.py create mode 100644 dashboard/src/booking/stats.py delete mode 100644 dashboard/src/booking/tests/test_views.py create mode 100644 dashboard/src/dashboard/context_processors.py create mode 100644 dashboard/src/dashboard/exceptions.py delete mode 100644 dashboard/src/dashboard/migrations/0001_initial.py delete mode 100644 dashboard/src/dashboard/migrations/0002_auto_20170505_0815.py delete mode 100644 dashboard/src/dashboard/migrations/0003_resource_resource_lab.py delete mode 100644 dashboard/src/dashboard/migrations/__init__.py create mode 100644 dashboard/src/dashboard/populate_db_iol.py delete mode 100644 dashboard/src/dashboard/templatetags/jenkins_filters.py delete mode 100644 dashboard/src/dashboard/tests/test_models.py delete mode 100644 dashboard/src/dashboard/tests/test_views.py delete mode 100644 dashboard/src/jenkins/__init__.py delete mode 100644 dashboard/src/jenkins/adapter.py delete mode 100644 dashboard/src/jenkins/admin.py delete mode 100644 dashboard/src/jenkins/apps.py delete mode 100644 dashboard/src/jenkins/migrations/0001_initial.py delete mode 100644 dashboard/src/jenkins/migrations/__init__.py delete mode 100644 dashboard/src/jenkins/models.py delete mode 100644 dashboard/src/jenkins/tasks.py delete mode 100644 dashboard/src/jenkins/tests.py mode change 100644 => 100755 dashboard/src/manage.py create mode 100644 dashboard/src/notifier/manager.py create mode 100644 dashboard/src/notifier/tests/test_dispatcher.py create mode 100644 dashboard/src/notifier/tests/test_models.py create mode 100644 dashboard/src/notifier/urls.py create mode 100644 dashboard/src/notifier/views.py create mode 100644 dashboard/src/resource_inventory/__init__.py create mode 100644 dashboard/src/resource_inventory/admin.py create mode 100644 dashboard/src/resource_inventory/apps.py create mode 100644 dashboard/src/resource_inventory/migrations/0001_initial.py create mode 100644 dashboard/src/resource_inventory/migrations/0002_auto_20180919_1459.py create mode 100644 dashboard/src/resource_inventory/migrations/0003_vlan_public.py create mode 100644 dashboard/src/resource_inventory/migrations/__init__.py create mode 100644 dashboard/src/resource_inventory/models.py create mode 100644 dashboard/src/resource_inventory/resource_manager.py create mode 100644 dashboard/src/resource_inventory/tests/test_managers.py create mode 100644 dashboard/src/resource_inventory/tests/test_models.py create mode 100644 dashboard/src/resource_inventory/urls.py create mode 100644 dashboard/src/resource_inventory/views.py create mode 100644 dashboard/src/static/css/graph_common.css create mode 100644 dashboard/src/static/img/mxgraph/add.png create mode 100644 dashboard/src/static/img/mxgraph/button.gif create mode 100644 dashboard/src/static/img/mxgraph/camera.png create mode 100644 dashboard/src/static/img/mxgraph/check.png create mode 100644 dashboard/src/static/img/mxgraph/close.gif create mode 100644 dashboard/src/static/img/mxgraph/close.png create mode 100644 dashboard/src/static/img/mxgraph/collapsed.gif create mode 100644 dashboard/src/static/img/mxgraph/connector.gif create mode 100644 dashboard/src/static/img/mxgraph/copy.png create mode 100644 dashboard/src/static/img/mxgraph/cut.png create mode 100644 dashboard/src/static/img/mxgraph/delete2.png create mode 100644 dashboard/src/static/img/mxgraph/dot.gif create mode 100644 dashboard/src/static/img/mxgraph/error.gif create mode 100644 dashboard/src/static/img/mxgraph/expanded.gif create mode 100644 dashboard/src/static/img/mxgraph/export1.png create mode 100644 dashboard/src/static/img/mxgraph/fit_to_size.png create mode 100644 dashboard/src/static/img/mxgraph/gradient_background.jpg create mode 100644 dashboard/src/static/img/mxgraph/green-dot.gif create mode 100644 dashboard/src/static/img/mxgraph/group.png create mode 100644 dashboard/src/static/img/mxgraph/handle-connect.png create mode 100644 dashboard/src/static/img/mxgraph/handle-main.png create mode 100644 dashboard/src/static/img/mxgraph/icons48/column.png create mode 100644 dashboard/src/static/img/mxgraph/icons48/earth.png create mode 100644 dashboard/src/static/img/mxgraph/icons48/gear.png create mode 100644 dashboard/src/static/img/mxgraph/icons48/keys.png create mode 100644 dashboard/src/static/img/mxgraph/icons48/mail_new.png create mode 100644 dashboard/src/static/img/mxgraph/icons48/server.png create mode 100644 dashboard/src/static/img/mxgraph/icons48/table.png create mode 100644 dashboard/src/static/img/mxgraph/key.png create mode 100644 dashboard/src/static/img/mxgraph/loading.gif create mode 100644 dashboard/src/static/img/mxgraph/maximize.gif create mode 100644 dashboard/src/static/img/mxgraph/minimize.gif create mode 100644 dashboard/src/static/img/mxgraph/navigate_minus.png create mode 100644 dashboard/src/static/img/mxgraph/navigate_plus.png create mode 100644 dashboard/src/static/img/mxgraph/normalize.gif create mode 100644 dashboard/src/static/img/mxgraph/paste.png create mode 100644 dashboard/src/static/img/mxgraph/plus.png create mode 100644 dashboard/src/static/img/mxgraph/point.gif create mode 100644 dashboard/src/static/img/mxgraph/press32.png create mode 100644 dashboard/src/static/img/mxgraph/print32.png create mode 100644 dashboard/src/static/img/mxgraph/printer.png create mode 100644 dashboard/src/static/img/mxgraph/redo.png create mode 100644 dashboard/src/static/img/mxgraph/resize.gif create mode 100644 dashboard/src/static/img/mxgraph/separator.gif create mode 100644 dashboard/src/static/img/mxgraph/sidebar_bg.gif create mode 100644 dashboard/src/static/img/mxgraph/spacer.gif create mode 100644 dashboard/src/static/img/mxgraph/submenu.gif create mode 100644 dashboard/src/static/img/mxgraph/toolbar_bg.gif create mode 100644 dashboard/src/static/img/mxgraph/transparent.gif create mode 100644 dashboard/src/static/img/mxgraph/undo.png create mode 100644 dashboard/src/static/img/mxgraph/view_1_1.png create mode 100644 dashboard/src/static/img/mxgraph/view_1_132.png create mode 100644 dashboard/src/static/img/mxgraph/view_next.png create mode 100644 dashboard/src/static/img/mxgraph/view_previous.png create mode 100644 dashboard/src/static/img/mxgraph/warning.gif create mode 100644 dashboard/src/static/img/mxgraph/warning.png create mode 100644 dashboard/src/static/img/mxgraph/window-title.gif create mode 100644 dashboard/src/static/img/mxgraph/window.gif create mode 100644 dashboard/src/static/img/mxgraph/wires-grid.gif create mode 100644 dashboard/src/static/img/mxgraph/zoom_in.png create mode 100644 dashboard/src/static/img/mxgraph/zoom_in32.png create mode 100644 dashboard/src/static/img/mxgraph/zoom_out.png create mode 100644 dashboard/src/static/img/mxgraph/zoom_out32.png create mode 100644 dashboard/src/static/js/mxClient.min.js create mode 100644 dashboard/src/templates/account/booking_list.html create mode 100644 dashboard/src/templates/account/configuration_list.html create mode 100644 dashboard/src/templates/account/details.html create mode 100644 dashboard/src/templates/account/image_list.html create mode 100644 dashboard/src/templates/account/resource_list.html create mode 100644 dashboard/src/templates/booking/booking_grid_item.html create mode 100644 dashboard/src/templates/booking/stats.html create mode 100644 dashboard/src/templates/booking/steps/booking_confirm.html create mode 100644 dashboard/src/templates/booking/steps/booking_meta.html create mode 100644 dashboard/src/templates/booking/steps/resource_select.html create mode 100644 dashboard/src/templates/booking/steps/swconfig_select.html create mode 100644 dashboard/src/templates/config_bundle/steps/config_software.html create mode 100644 dashboard/src/templates/config_bundle/steps/define_software.html delete mode 100644 dashboard/src/templates/dashboard/ci_pods.html delete mode 100644 dashboard/src/templates/dashboard/dev_pods.html create mode 100644 dashboard/src/templates/dashboard/grid.html create mode 100644 dashboard/src/templates/dashboard/host_profile_detail.html delete mode 100644 dashboard/src/templates/dashboard/jenkins_slaves.html create mode 100644 dashboard/src/templates/dashboard/lab_detail.html create mode 100644 dashboard/src/templates/dashboard/lab_list.html create mode 100644 dashboard/src/templates/dashboard/landing.html create mode 100644 dashboard/src/templates/dashboard/login.html create mode 100644 dashboard/src/templates/dashboard/multiple_select_filter_widget.html create mode 100644 dashboard/src/templates/dashboard/pdf.yaml create mode 100644 dashboard/src/templates/dashboard/searchable_select_multiple.html create mode 100644 dashboard/src/templates/notifier/inbox.html create mode 100644 dashboard/src/templates/notifier/notification.html create mode 100644 dashboard/src/templates/resource/hosts.html create mode 100644 dashboard/src/templates/resource/mxClient.min.js create mode 100644 dashboard/src/templates/resource/steps/define_hardware.html create mode 100644 dashboard/src/templates/resource/steps/host_info.html create mode 100644 dashboard/src/templates/resource/steps/pod_definition.html create mode 100644 dashboard/src/templates/resource/uncommon.css create mode 100644 dashboard/src/templates/snapshot_workflow/steps/meta.html create mode 100644 dashboard/src/templates/snapshot_workflow/steps/select_host.html create mode 100644 dashboard/src/templates/workflow/confirm.html create mode 100644 dashboard/src/templates/workflow/no_workflow.html create mode 100644 dashboard/src/templates/workflow/resource_select.html create mode 100644 dashboard/src/templates/workflow/viewport-base.html create mode 100644 dashboard/src/templates/workflow/viewport-element.html create mode 100644 dashboard/src/workflow/__init__.py create mode 100644 dashboard/src/workflow/apps.py create mode 100644 dashboard/src/workflow/booking_workflow.py create mode 100644 dashboard/src/workflow/forms.py create mode 100644 dashboard/src/workflow/models.py create mode 100644 dashboard/src/workflow/resource_bundle_workflow.py create mode 100644 dashboard/src/workflow/snapshot_workflow.py create mode 100644 dashboard/src/workflow/sw_bundle_workflow.py create mode 100644 dashboard/src/workflow/tests/__init__.py create mode 100644 dashboard/src/workflow/tests/constants.py create mode 100644 dashboard/src/workflow/tests/test_steps.py create mode 100644 dashboard/src/workflow/tests/test_steps_render.py create mode 100644 dashboard/src/workflow/tests/test_workflows.py create mode 100644 dashboard/src/workflow/urls.py create mode 100644 dashboard/src/workflow/views.py create mode 100644 dashboard/src/workflow/workflow_factory.py create mode 100644 dashboard/src/workflow/workflow_manager.py create mode 100755 dashboard/test.sh diff --git a/dashboard/Makefile b/dashboard/Makefile index e5f4fb2..31243b0 100644 --- a/dashboard/Makefile +++ b/dashboard/Makefile @@ -32,10 +32,10 @@ shell-db: docker exec -ti ps01 bash log-nginx: - docker-compose logs nginx + docker-compose logs nginx log-web: - docker-compose logs web + docker-compose logs web log-ps: docker-compose logs postgres diff --git a/dashboard/booking_communication_agent.py b/dashboard/booking_communication_agent.py index c52e98b..dc4ea4d 100644 --- a/dashboard/booking_communication_agent.py +++ b/dashboard/booking_communication_agent.py @@ -1,3 +1,11 @@ +############################################################################## +# Copyright (c) 2018 Sawyer Bergeron and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## from dashboard_notification.notification import Notification from dashboard_api.api import DashboardAPI diff --git a/dashboard/config.env.sample b/dashboard/config.env.sample index 5072779..7677c2f 100644 --- a/dashboard/config.env.sample +++ b/dashboard/config.env.sample @@ -2,6 +2,7 @@ DASHBOARD_URL=http://labs.opnfv.org # SECURITY WARNING: don't run with debug turned on in production! DEBUG=False +TEST=False POSTGRES_DB=sample_name POSTGRES_USER=sample_user @@ -26,10 +27,6 @@ JIRA_USER_PASSWORD=sample_jira_pass RABBITMQ_DEFAULT_USER=opnfv RABBITMQ_DEFAULT_PASS=opnfvopnfv -# Cleanup: time is in days -BOOKING_EXPIRE_TIME=30 -BOOKING_MAXIMUM_NUMBER=10 - #Jenkins Build Server JENKINS_URL=https://build.opnfv.org/ci diff --git a/dashboard/config/nginx/pharos_dashboard.conf b/dashboard/config/nginx/pharos_dashboard.conf index 87b6f8e..6f32979 100644 --- a/dashboard/config/nginx/pharos_dashboard.conf +++ b/dashboard/config/nginx/pharos_dashboard.conf @@ -1,24 +1,24 @@ upstream web { - ip_hash; - server web:8000; + ip_hash; + server web:8000; } # portal -server { - listen 80; - server_name localhost; - charset utf-8; +server { + listen 80; + server_name localhost; + charset utf-8; - location /static { + location /static { alias /static; - } + } - location /media { + location /media { alias /media; - } + } - location / { + location / { proxy_set_header Host $host; - proxy_pass http://web/; - } + proxy_pass http://web/; + } } diff --git a/dashboard/data/UNH_IOL/HPE_Proliant/hpe13.yaml b/dashboard/data/UNH_IOL/HPE_Proliant/hpe13.yaml new file mode 100644 index 0000000..fd40aff --- /dev/null +++ b/dashboard/data/UNH_IOL/HPE_Proliant/hpe13.yaml @@ -0,0 +1,53 @@ +--- +disk: + - + name: sda + size: 894.2G + - + name: loop0 + size: 100G + - + name: loop1 + size: 2G + - + name: loop2 + size: 792M + - + name: loop3 + size: 825M +cpu: + arch: x86_64 + cpus: 2 + cores: 88 +memory: 503G +interface: + - + name: eno49 + mac: '48:df:37:1d:54:00' + busaddr: '0000:04:00.0' + speed: 10000 + - + name: ens1f0 + mac: '3c:fd:fe:b2:c3:70' + busaddr: '0000:05:00.0' + speed: 10000 + - + name: ens1f1 + mac: '3c:fd:fe:b2:c3:71' + busaddr: '0000:05:00.1' + speed: 10000 + - + name: ens1f2 + mac: '3c:fd:fe:b2:c3:72' + busaddr: '0000:05:00.2' + speed: 10000 + - + name: ens4f0 + mac: '3c:fd:fe:b2:ae:d0' + busaddr: '0000:88:00.0' + speed: 10000 + - + name: ens4f1 + mac: '3c:fd:fe:b2:ae:d1' + busaddr: '0000:88:00.1' + speed: 10000 diff --git a/dashboard/data/UNH_IOL/HPE_Proliant/hpe14.yaml b/dashboard/data/UNH_IOL/HPE_Proliant/hpe14.yaml new file mode 100644 index 0000000..612f4d0 --- /dev/null +++ b/dashboard/data/UNH_IOL/HPE_Proliant/hpe14.yaml @@ -0,0 +1,41 @@ +--- +disk: + - + name: sda + size: 894.2G +cpu: + arch: x86_64 + cpus: 2 + cores: 88 +memory: 503G +interface: + - + name: eno49 + mac: '48:df:37:1d:4d:60' + busaddr: '0000:04:00.0' + speed: 10000 + - + name: ens1f0 + mac: '3c:fd:fe:b2:b2:00' + busaddr: '0000:05:00.0' + speed: 10000 + - + name: ens1f1 + mac: '3c:fd:fe:b2:b2:01' + busaddr: '0000:05:00.1' + speed: 10000 + - + name: ens1f2 + mac: '3c:fd:fe:b2:b2:02' + busaddr: '0000:05:00.2' + speed: 10000 + - + name: ens4f0 + mac: '3c:fd:fe:b2:b1:d8' + busaddr: '0000:88:00.0' + speed: 10000 + - + name: ens4f1 + mac: '3c:fd:fe:b2:b1:d9' + busaddr: '0000:88:00.1' + speed: 10000 diff --git a/dashboard/data/UNH_IOL/HPE_Proliant/hpe15.yaml b/dashboard/data/UNH_IOL/HPE_Proliant/hpe15.yaml new file mode 100644 index 0000000..c6799ac --- /dev/null +++ b/dashboard/data/UNH_IOL/HPE_Proliant/hpe15.yaml @@ -0,0 +1,41 @@ +--- +disk: + - + name: sda + size: 894.2G +cpu: + arch: x86_64 + cpus: 2 + cores: 88 +memory: 503G +interface: + - + name: eno49 + mac: '48:df:37:22:c5:c0' + busaddr: '0000:04:00.0' + speed: 10000 + - + name: ens1f0 + mac: '3c:fd:fe:b2:ae:68' + busaddr: '0000:05:00.0' + speed: 10000 + - + name: ens1f1 + mac: '3c:fd:fe:b2:ae:69' + busaddr: '0000:05:00.1' + speed: 10000 + - + name: ens1f2 + mac: '3c:fd:fe:b2:ae:6a' + busaddr: '0000:05:00.2' + speed: 10000 + - + name: ens4f0 + mac: '3c:fd:fe:b2:ad:90' + busaddr: '0000:88:00.0' + speed: 10000 + - + name: ens4f1 + mac: '3c:fd:fe:b2:ad:91' + busaddr: '0000:88:00.1' + speed: 10000 diff --git a/dashboard/data/UNH_IOL/HPE_Proliant/hpe16.yaml b/dashboard/data/UNH_IOL/HPE_Proliant/hpe16.yaml new file mode 100644 index 0000000..3148532 --- /dev/null +++ b/dashboard/data/UNH_IOL/HPE_Proliant/hpe16.yaml @@ -0,0 +1,41 @@ +--- +disk: + - + name: sda + size: 894.2G +cpu: + arch: x86_64 + cpus: 2 + cores: 88 +memory: 503G +interface: + - + name: eth0 + mac: '48:df:37:22:c5:30' + busaddr: '0000:04:00.0' + speed: 10000 + - + name: eth2 + mac: '3c:fd:fe:b2:b1:60' + busaddr: '0000:05:00.0' + speed: 10000 + - + name: eth3 + mac: '3c:fd:fe:b2:b1:61' + busaddr: '0000:05:00.1' + speed: 10000 + - + name: eth4 + mac: '3c:fd:fe:b2:b1:62' + busaddr: '0000:05:00.2' + speed: 10000 + - + name: eth6 + mac: '3c:fd:fe:b2:b3:b8' + busaddr: '0000:88:00.0' + speed: 10000 + - + name: eth7 + mac: '3c:fd:fe:b2:b3:b9' + busaddr: '0000:88:00.1' + speed: 10000 diff --git a/dashboard/data/UNH_IOL/HPE_Proliant/hpe17.yaml b/dashboard/data/UNH_IOL/HPE_Proliant/hpe17.yaml new file mode 100644 index 0000000..4b13ae2 --- /dev/null +++ b/dashboard/data/UNH_IOL/HPE_Proliant/hpe17.yaml @@ -0,0 +1,41 @@ +--- +disk: + - + name: sda + size: 894.2G +cpu: + arch: x86_64 + cpus: 2 + cores: 88 +memory: 503G +interface: + - + name: eno49 + mac: '48:df:37:1d:48:e0' + busaddr: '0000:04:00.0' + speed: 10000 + - + name: ens1f0 + mac: '3c:fd:fe:b2:ad:80' + busaddr: '0000:05:00.0' + speed: 10000 + - + name: ens1f1 + mac: '3c:fd:fe:b2:ad:81' + busaddr: '0000:05:00.1' + speed: 10000 + - + name: ens1f2 + mac: '3c:fd:fe:b2:ad:82' + busaddr: '0000:05:00.2' + speed: 10000 + - + name: ens4f0 + mac: '3c:fd:fe:b2:b2:d0' + busaddr: '0000:88:00.0' + speed: 10000 + - + name: ens4f1 + mac: '3c:fd:fe:b2:b2:d1' + busaddr: '0000:88:00.1' + speed: 10000 diff --git a/dashboard/data/UNH_IOL/HPE_Proliant/hpe18.yaml b/dashboard/data/UNH_IOL/HPE_Proliant/hpe18.yaml new file mode 100644 index 0000000..aa411f1 --- /dev/null +++ b/dashboard/data/UNH_IOL/HPE_Proliant/hpe18.yaml @@ -0,0 +1,41 @@ +--- +disk: + - + name: sda + size: 894.2G +cpu: + arch: x86_64 + cpus: 2 + cores: 88 +memory: 503G +interface: + - + name: eno49 + mac: '48:df:37:19:a9:b0' + busaddr: '0000:04:00.0' + speed: 10000 + - + name: ens1f0 + mac: '3c:fd:fe:b2:ae:b8' + busaddr: '0000:05:00.0' + speed: 10000 + - + name: ens1f1 + mac: '3c:fd:fe:b2:ae:b9' + busaddr: '0000:05:00.1' + speed: 10000 + - + name: ens1f2 + mac: '3c:fd:fe:b2:ae:ba' + busaddr: '0000:05:00.2' + speed: 10000 + - + name: ens4f0 + mac: '3c:fd:fe:b2:af:50' + busaddr: '0000:88:00.0' + speed: 10000 + - + name: ens4f1 + mac: '3c:fd:fe:b2:af:51' + busaddr: '0000:88:00.1' + speed: 10000 diff --git a/dashboard/data/UNH_IOL/HPE_Proliant/hpe19.yaml b/dashboard/data/UNH_IOL/HPE_Proliant/hpe19.yaml new file mode 100644 index 0000000..40e538c --- /dev/null +++ b/dashboard/data/UNH_IOL/HPE_Proliant/hpe19.yaml @@ -0,0 +1,41 @@ +--- +disk: + - + name: sda + size: 894.2G +cpu: + arch: x86_64 + cpus: 2 + cores: 88 +memory: 503G +interface: + - + name: eno49 + mac: '48:df:37:22:b5:90' + busaddr: '0000:04:00.0' + speed: 10000 + - + name: ens1f0 + mac: '3c:fd:fe:b2:ad:20' + busaddr: '0000:05:00.0' + speed: 10000 + - + name: ens1f1 + mac: '3c:fd:fe:b2:ad:21' + busaddr: '0000:05:00.1' + speed: 10000 + - + name: ens1f2 + mac: '3c:fd:fe:b2:ad:22' + busaddr: '0000:05:00.2' + speed: 10000 + - + name: ens4f0 + mac: '3c:fd:fe:b2:b3:10' + busaddr: '0000:88:00.0' + speed: 10000 + - + name: ens4f1 + mac: '3c:fd:fe:b2:b3:11' + busaddr: '0000:88:00.1' + speed: 10000 diff --git a/dashboard/data/UNH_IOL/HPE_Proliant/hpe20.yaml b/dashboard/data/UNH_IOL/HPE_Proliant/hpe20.yaml new file mode 100644 index 0000000..6c83e79 --- /dev/null +++ b/dashboard/data/UNH_IOL/HPE_Proliant/hpe20.yaml @@ -0,0 +1,41 @@ +--- +disk: + - + name: sda + size: 894.2G +cpu: + arch: x86_64 + cpus: 2 + cores: 88 +memory: 503G +interface: + - + name: eno49 + mac: '48:df:37:1d:49:a0' + busaddr: '0000:04:00.0' + speed: 10000 + - + name: ens1f0 + mac: '3c:fd:fe:b2:b1:c8' + busaddr: '0000:05:00.0' + speed: 10000 + - + name: ens1f1 + mac: '3c:fd:fe:b2:b1:c9' + busaddr: '0000:05:00.1' + speed: 10000 + - + name: ens1f2 + mac: '3c:fd:fe:b2:b1:ca' + busaddr: '0000:05:00.2' + speed: 10000 + - + name: ens4f0 + mac: '3c:fd:fe:b2:ae:a0' + busaddr: '0000:88:00.0' + speed: 10000 + - + name: ens4f1 + mac: '3c:fd:fe:b2:ae:a1' + busaddr: '0000:88:00.1' + speed: 10000 diff --git a/dashboard/data/UNH_IOL/hostlist.json b/dashboard/data/UNH_IOL/hostlist.json new file mode 100644 index 0000000..cd03859 --- /dev/null +++ b/dashboard/data/UNH_IOL/hostlist.json @@ -0,0 +1,14 @@ +{ + "profiles": { + "HPE_Proliant": [ + "hpe13", + "hpe14", + "hpe15", + "hpe16", + "hpe17", + "hpe18", + "hpe19", + "hpe20" + ] + } +} diff --git a/dashboard/docker-compose.yml b/dashboard/docker-compose.yml index 19e9afd..2f96343 100644 --- a/dashboard/docker-compose.yml +++ b/dashboard/docker-compose.yml @@ -1,6 +1,7 @@ --- ############################################################################## # Copyright (c) 2016 Max Breitenfeldt and others. +# Copyright (c) 2018 Parker Berberian, Sawyer Bergeron, and others. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 diff --git a/dashboard/requirements.txt b/dashboard/requirements.txt index 19365bc..9ea10a4 100644 --- a/dashboard/requirements.txt +++ b/dashboard/requirements.txt @@ -1,11 +1,11 @@ celery==3.1.23 cryptography==2.3.1 -Django==1.10 -django-bootstrap3==7.0.1 -django-crispy-forms==1.6.0 -django-filter==0.14.0 +Django==2.1 +django-bootstrap3==10.0.1 +django-crispy-forms==1.7.2 +django-filter==2.0.0 django-registration==2.1.2 -djangorestframework==3.4.6 +djangorestframework==3.8.2 gunicorn==19.6.0 jira==1.0.7 jsonpickle==0.9.3 @@ -16,3 +16,5 @@ psycopg2==2.6.2 PyJWT==1.4.2 requests==2.11.0 django-fernet-fields==0.5 +pyyaml==3.13 +pytz==2018.5 diff --git a/dashboard/src/account/admin.py b/dashboard/src/account/admin.py index 6f77122..b4c142c 100644 --- a/dashboard/src/account/admin.py +++ b/dashboard/src/account/admin.py @@ -1,5 +1,6 @@ ############################################################################## # Copyright (c) 2016 Max Breitenfeldt and others. +# Copyright (c) 2018 Parker Berberian, Sawyer Bergeron, and others. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 @@ -10,7 +11,9 @@ from django.contrib import admin -from account.models import UserProfile, Lab +from account.models import UserProfile, Lab, VlanManager, PublicNetwork admin.site.register(UserProfile) admin.site.register(Lab) +admin.site.register(VlanManager) +admin.site.register(PublicNetwork) diff --git a/dashboard/src/account/migrations/0001_initial.py b/dashboard/src/account/migrations/0001_initial.py index 591f702..c8b5bdc 100644 --- a/dashboard/src/account/migrations/0001_initial.py +++ b/dashboard/src/account/migrations/0001_initial.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10 on 2016-11-03 13:33 -from __future__ import unicode_literals +# Generated by Django 2.1 on 2018-09-14 14:48 import account.models from django.conf import settings @@ -17,6 +15,18 @@ class Migration(migrations.Migration): ] operations = [ + migrations.CreateModel( + name='Lab', + fields=[ + ('name', models.CharField(max_length=200, primary_key=True, serialize=False, unique=True)), + ('contact_email', models.EmailField(blank=True, max_length=200, null=True)), + ('contact_phone', models.CharField(blank=True, max_length=20, null=True)), + ('status', models.IntegerField(default=0)), + ('location', models.TextField(default='unknown')), + ('api_token', models.CharField(max_length=50)), + ('lab_user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + ), migrations.CreateModel( name='UserProfile', fields=[ @@ -24,15 +34,32 @@ class Migration(migrations.Migration): ('timezone', models.CharField(default='UTC', max_length=100)), ('ssh_public_key', models.FileField(blank=True, null=True, upload_to=account.models.upload_to)), ('pgp_public_key', models.FileField(blank=True, null=True, upload_to=account.models.upload_to)), + ('email_addr', models.CharField(default='email@mail.com', max_length=300)), ('company', models.CharField(max_length=200)), ('oauth_token', models.CharField(max_length=1024)), ('oauth_secret', models.CharField(max_length=1024)), ('jira_url', models.CharField(default='', max_length=100)), ('full_name', models.CharField(default='', max_length=100)), + ('booking_privledge', models.BooleanField(default=False)), ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], options={ 'db_table': 'user_profile', }, ), + migrations.CreateModel( + name='VlanManager', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('vlans', models.TextField()), + ('block_size', models.IntegerField()), + ('allow_overlapping', models.BooleanField()), + ('reserved_vlans', models.TextField()), + ], + ), + migrations.AddField( + model_name='lab', + name='vlan_manager', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='account.VlanManager'), + ), ] diff --git a/dashboard/src/account/migrations/0002_auto_20180110_1636.py b/dashboard/src/account/migrations/0002_auto_20180110_1636.py deleted file mode 100644 index 6170acb..0000000 --- a/dashboard/src/account/migrations/0002_auto_20180110_1636.py +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10 on 2018-01-10 16:36 -from __future__ import unicode_literals - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('account', '0001_initial'), - ] - - operations = [ - migrations.CreateModel( - name='Lab', - fields=[ - ('id', models.CharField(max_length=200, primary_key=True, serialize=False)), - ('name', models.CharField(max_length=200, unique=True)), - ('contact_email', models.EmailField(blank=True, max_length=200, null=True)), - ('contact_phone', models.CharField(blank=True, max_length=20, null=True)), - ('lab_user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), - ], - ), - migrations.AddField( - model_name='userprofile', - name='email_addr', - field=models.CharField(default='email@mail.com', max_length=300), - ), - ] diff --git a/dashboard/src/account/migrations/0002_lab_description.py b/dashboard/src/account/migrations/0002_lab_description.py new file mode 100644 index 0000000..445501a --- /dev/null +++ b/dashboard/src/account/migrations/0002_lab_description.py @@ -0,0 +1,19 @@ +# Generated by Django 2.1 on 2018-09-14 20:22 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('account', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='lab', + name='description', + field=models.CharField(default='Lab description default', max_length=240), + preserve_default=False, + ), + ] diff --git a/dashboard/src/account/migrations/0003_auto_20180110_1639.py b/dashboard/src/account/migrations/0003_auto_20180110_1639.py deleted file mode 100644 index d0bc4d6..0000000 --- a/dashboard/src/account/migrations/0003_auto_20180110_1639.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10 on 2018-01-10 16:39 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('account', '0002_auto_20180110_1636'), - ] - - operations = [ - migrations.RemoveField( - model_name='lab', - name='id', - ), - migrations.AlterField( - model_name='lab', - name='name', - field=models.CharField(max_length=200, primary_key=True, serialize=False, unique=True), - ), - ] diff --git a/dashboard/src/account/migrations/0003_publicnetwork.py b/dashboard/src/account/migrations/0003_publicnetwork.py new file mode 100644 index 0000000..71e5caa --- /dev/null +++ b/dashboard/src/account/migrations/0003_publicnetwork.py @@ -0,0 +1,25 @@ +# Generated by Django 2.1 on 2018-09-26 14:41 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('account', '0002_lab_description'), + ] + + operations = [ + migrations.CreateModel( + name='PublicNetwork', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('vlan', models.IntegerField()), + ('in_use', models.BooleanField(default=False)), + ('cidr', models.CharField(default='0.0.0.0/0', max_length=50)), + ('gateway', models.CharField(default='0.0.0.0', max_length=50)), + ('lab', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='account.Lab')), + ], + ), + ] diff --git a/dashboard/src/account/migrations/__init__.py b/dashboard/src/account/migrations/__init__.py index b5914ce..e69de29 100644 --- a/dashboard/src/account/migrations/__init__.py +++ b/dashboard/src/account/migrations/__init__.py @@ -1,10 +0,0 @@ -############################################################################## -# Copyright (c) 2016 Max Breitenfeldt and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - - diff --git a/dashboard/src/account/models.py b/dashboard/src/account/models.py index aad4c50..18a8cbb 100644 --- a/dashboard/src/account/models.py +++ b/dashboard/src/account/models.py @@ -10,6 +10,14 @@ from django.contrib.auth.models import User from django.db import models +import json +import random + + +class LabStatus(object): + UP = 0 + TEMP_DOWN = 100 + DOWN = 200 def upload_to(object, filename): @@ -28,6 +36,7 @@ class UserProfile(models.Model): jira_url = models.CharField(max_length=100, default='') full_name = models.CharField(max_length=100, default='') + booking_privledge = models.BooleanField(default=False) class Meta: db_table = 'user_profile' @@ -35,11 +44,129 @@ class UserProfile(models.Model): def __str__(self): return self.user.username + +class VlanManager(models.Model): + # list of length 4096 containing either 0 (not available) or 1 (available) + vlans = models.TextField() + block_size = models.IntegerField() + allow_overlapping = models.BooleanField() + # list of length 4096 containing either 0 (not rexerved) or 1 (reserved) + reserved_vlans = models.TextField() + + def get_vlan(self, count=1): + allocated = [] + vlans = json.loads(self.vlans) + for i in range(count): + new_vlan = vlans.index(1) # will throw if none available + vlans[new_vlan] = 0 + allocated.append(new_vlan) + if count is 1: + return allocated[0] + return allocated + + def get_public_vlan(self): + return PublicNetwork.objects.filter(lab=self.lab_set.first(), in_use=False).first() + + def reserve_public_vlan(self, vlan): + net = PublicNetwork.objects.get(lab=self.lab_set.first(), vlan=vlan, in_use=False) + net.in_use = True + net.save() + + def release_public_vlan(self, vlan): + net = PublicNetwork.objects.get(lab=self.lab_set.first(), vlan=vlan, in_use=True) + net.in_use = False + net.save() + + def public_vlan_is_available(self, vlan): + net = PublicNetwork.objects.get(lab=self.lab_set.first(), vlan=vlan) + return not net.in_use + + + def is_available(self, vlans): + """ + 'vlans' is either a single vlan id integer or a list of integers + will return true (available) or false + """ + if self.allow_overlapping: + return True + + reserved = json.loads(self.reserved_vlans) + vlan_master_list = json.loads(self.vlans) + try: + iter(vlans) + except: + vlans = [vlans] + + for vlan in vlans: + if not vlan_master_list[vlan] or reserved[vlan]: + return False + return True + + def release_vlans(self, vlans): + """ + 'vlans' is either a single vlan id integer or a list of integers + will make the vlans available + doesnt return a value + """ + my_vlans = json.loads(self.vlans) + + try: + iter(vlans) + except: + vlans = [vlans] + + for vlan in vlans: + my_vlans[vlan] = 1 + self.vlans = json.dumps(my_vlans) + self.save() + + def reserve_vlans(self, vlans): + my_vlans = json.loads(self.vlans) + + try: + iter(vlans) + except: + vlans = [vlans] + + vlans = set(vlans) + + for vlan in vlans: + if my_vlans[vlan] is 0: + raise ValueError("vlan " + str(vlan) + " is not available") + + my_vlans[vlan] = 0 + self.vlans = json.dumps(my_vlans) + self.save() + + + class Lab(models.Model): lab_user = models.OneToOneField(User, on_delete=models.CASCADE) name = models.CharField(max_length=200, primary_key=True, unique=True, null=False, blank=False) contact_email = models.EmailField(max_length=200, null=True, blank=True) contact_phone = models.CharField(max_length=20, null=True, blank=True) + status = models.IntegerField(default=LabStatus.UP) + vlan_manager = models.ForeignKey(VlanManager, on_delete=models.CASCADE, null=True) + location = models.TextField(default="unknown") + api_token = models.CharField(max_length=50) + description = models.CharField(max_length=240) + + @staticmethod + def make_api_token(): + alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" + key = "" + for i in range(45): + key += random.choice(alphabet) + return key + def __str__(self): return self.name + + +class PublicNetwork(models.Model): + vlan = models.IntegerField() + lab = models.ForeignKey(Lab, on_delete=models.CASCADE) + in_use = models.BooleanField(default=False) + cidr = models.CharField(max_length=50, default="0.0.0.0/0") + gateway = models.CharField(max_length=50, default="0.0.0.0") diff --git a/dashboard/src/account/tasks.py b/dashboard/src/account/tasks.py index bfb865d..fe51974 100644 --- a/dashboard/src/account/tasks.py +++ b/dashboard/src/account/tasks.py @@ -1,5 +1,6 @@ ############################################################################## # Copyright (c) 2016 Max Breitenfeldt and others. +# Copyright (c) 2018 Parker Berberian, Sawyer Bergeron, and others. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 @@ -28,7 +29,6 @@ def sync_jira_accounts(): user.email = user_dict['emailAddress'] user.userprofile.url = user_dict['self'] user.userprofile.full_name = user_dict['displayName'] - print(user_dict) user.userprofile.save() - user.save() \ No newline at end of file + user.save() diff --git a/dashboard/src/account/urls.py b/dashboard/src/account/urls.py index 3962a0c..6ce2115 100644 --- a/dashboard/src/account/urls.py +++ b/dashboard/src/account/urls.py @@ -1,5 +1,6 @@ ############################################################################## # Copyright (c) 2016 Max Breitenfeldt and others. +# Copyright (c) 2018 Parker Berberian, Sawyer Bergeron, and others. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 @@ -27,10 +28,16 @@ from django.conf.urls import url from account.views import * +app_name = "account" urlpatterns = [ url(r'^settings/', AccountSettingsView.as_view(), name='settings'), url(r'^authenticated/$', JiraAuthenticatedView.as_view(), name='authenticated'), url(r'^login/$', JiraLoginView.as_view(), name='login'), url(r'^logout/$', JiraLogoutView.as_view(), name='logout'), url(r'^users/$', UserListView.as_view(), name='users'), + url(r'^my/resources', account_resource_view, name="my-resources"), + url(r'^my/bookings', account_booking_view, name="my-bookings"), + url(r'^my/images', account_images_view, name="my-images"), + url(r'^my/configurations', account_configuration_view, name="my-configurations"), + url(r'^my/$', account_detail_view, name="my-account"), ] diff --git a/dashboard/src/account/views.py b/dashboard/src/account/views.py index e6a0e5d..04d21b8 100644 --- a/dashboard/src/account/views.py +++ b/dashboard/src/account/views.py @@ -1,5 +1,6 @@ ############################################################################## # Copyright (c) 2016 Max Breitenfeldt and others. +# Copyright (c) 2018 Parker Berberian, Sawyer Bergeron, and others. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 @@ -21,12 +22,15 @@ from django.contrib.auth.models import User from django.urls import reverse from django.utils.decorators import method_decorator from django.views.generic import RedirectView, TemplateView, UpdateView +from django.shortcuts import render from jira import JIRA from rest_framework.authtoken.models import Token from account.forms import AccountSettingsForm from account.jira_util import SignatureMethod_RSA_SHA1 from account.models import UserProfile +from booking.models import Booking +from resource_inventory.models import GenericResourceBundle, ConfigBundle, Image @method_decorator(login_required, name='dispatch') @@ -153,3 +157,47 @@ class UserListView(TemplateView): context = super(UserListView, self).get_context_data(**kwargs) context.update({'title': "Dashboard Users", 'users': users}) return context + + +def account_detail_view(request): + template = "account/details.html" + return render(request, template) + +def account_resource_view(request): + """ + gathers a users genericResoureBundles and + turns them into displayable objects + """ + if not request.user.is_authenticated: + return render(request, "dashboard/login.html", {'title': 'Authentication Required'}) + template = "account/resource_list.html" + resources = list(GenericResourceBundle.objects.filter(owner=request.user)) + context = {"resources": resources, "title": "My Resources"} + return render(request, template, context=context) + +def account_booking_view(request): + if not request.user.is_authenticated: + return render(request, "dashboard/login.html", {'title': 'Authentication Required'}) + template = "account/booking_list.html" + bookings = list(Booking.objects.filter(owner=request.user)) + collab_bookings = list(request.user.collaborators.all()) + context = {"title": "My Bookings", "bookings": bookings, "collab_bookings": collab_bookings} + return render(request, template, context=context) + +def account_configuration_view(request): + if not request.user.is_authenticated: + return render(request, "dashboard/login.html", {'title': 'Authentication Required'}) + template = "account/configuration_list.html" + configs = list(ConfigBundle.objects.filter(owner=request.user)) + context = {"title": "Configuration List", "configurations": configs} + return render(request, template, context=context) + +def account_images_view(request): + if not request.user.is_authenticated: + return render(request, "dashboard/login.html", {'title': 'Authentication Required'}) + template = "account/image_list.html" + my_images = Image.objects.filter(owner=request.user) + public_images = Image.objects.filter(public=True) + context = {"title": "Images", "images": my_images, "public_images": public_images } + return render(request, template, context=context) + diff --git a/dashboard/src/api/admin.py b/dashboard/src/api/admin.py new file mode 100644 index 0000000..f1bc70a --- /dev/null +++ b/dashboard/src/api/admin.py @@ -0,0 +1,28 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +from django.apps import AppConfig +from django.contrib import admin + +from api.models import * + + +class ApiConfig(AppConfig): + name = 'apiJobs' + +admin.site.register(Job) +admin.site.register(OpnfvApiConfig) +admin.site.register(HardwareConfig) +admin.site.register(NetworkConfig) +admin.site.register(SoftwareConfig) +admin.site.register(AccessRelation) +admin.site.register(SoftwareRelation) +admin.site.register(HostHardwareRelation) +admin.site.register(HostNetworkRelation) diff --git a/dashboard/src/api/migrations/0001_initial.py b/dashboard/src/api/migrations/0001_initial.py new file mode 100644 index 0000000..abe6f5e --- /dev/null +++ b/dashboard/src/api/migrations/0001_initial.py @@ -0,0 +1,185 @@ +############################################################################## +# Copyright (c) 2018 Parker Berberian, Sawyer Bergeron, and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +# Generated by Django 2.1 on 2018-09-14 14:48 + +import api.models +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('booking', '__first__'), + ('resource_inventory', '__first__'), + ] + + operations = [ + migrations.CreateModel( + name='AccessRelation', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('status', models.IntegerField(default=0)), + ('task_id', models.CharField(default=api.models.get_task_uuid, max_length=37)), + ('lab_token', models.CharField(default='null', max_length=50)), + ('message', models.TextField(default='')), + ], + options={ + 'abstract': False, + }, + ), + migrations.CreateModel( + name='HostHardwareRelation', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('status', models.IntegerField(default=0)), + ('task_id', models.CharField(default=api.models.get_task_uuid, max_length=37)), + ('lab_token', models.CharField(default='null', max_length=50)), + ('message', models.TextField(default='')), + ('host', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='resource_inventory.Host')), + ], + options={ + 'abstract': False, + }, + ), + migrations.CreateModel( + name='HostNetworkRelation', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('status', models.IntegerField(default=0)), + ('task_id', models.CharField(default=api.models.get_task_uuid, max_length=37)), + ('lab_token', models.CharField(default='null', max_length=50)), + ('message', models.TextField(default='')), + ('host', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='resource_inventory.Host')), + ], + options={ + 'abstract': False, + }, + ), + migrations.CreateModel( + name='Job', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('status', models.IntegerField(default=0)), + ('delta', models.TextField()), + ('complete', models.BooleanField(default=False)), + ('booking', models.OneToOneField(null=True, on_delete=django.db.models.deletion.CASCADE, to='booking.Booking')), + ], + ), + migrations.CreateModel( + name='OpnfvApiConfig', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('installer', models.CharField(max_length=100)), + ('scenario', models.CharField(max_length=100)), + ('delta', models.TextField()), + ('roles', models.ManyToManyField(to='resource_inventory.Host')), + ], + ), + migrations.CreateModel( + name='SoftwareRelation', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('status', models.IntegerField(default=0)), + ('task_id', models.CharField(default=api.models.get_task_uuid, max_length=37)), + ('lab_token', models.CharField(default='null', max_length=50)), + ('message', models.TextField(default='')), + ('job', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.Job')), + ], + options={ + 'abstract': False, + }, + ), + migrations.CreateModel( + name='TaskConfig', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ], + ), + migrations.CreateModel( + name='AccessConfig', + fields=[ + ('taskconfig_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='api.TaskConfig')), + ('access_type', models.CharField(max_length=50)), + ('revoke', models.BooleanField(default=False)), + ('context', models.TextField(default='')), + ('delta', models.TextField()), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + bases=('api.taskconfig',), + ), + migrations.CreateModel( + name='HardwareConfig', + fields=[ + ('taskconfig_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='api.TaskConfig')), + ('image', models.CharField(default='defimage', max_length=100)), + ('power', models.CharField(default='off', max_length=100)), + ('hostname', models.CharField(default='hostname', max_length=100)), + ('ipmi_create', models.BooleanField(default=False)), + ('delta', models.TextField()), + ], + bases=('api.taskconfig',), + ), + migrations.CreateModel( + name='NetworkConfig', + fields=[ + ('taskconfig_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='api.TaskConfig')), + ('delta', models.TextField()), + ('interfaces', models.ManyToManyField(to='resource_inventory.Interface')), + ], + bases=('api.taskconfig',), + ), + migrations.CreateModel( + name='SoftwareConfig', + fields=[ + ('taskconfig_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='api.TaskConfig')), + ('opnfv', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.OpnfvApiConfig')), + ], + bases=('api.taskconfig',), + ), + migrations.AddField( + model_name='hostnetworkrelation', + name='job', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.Job'), + ), + migrations.AddField( + model_name='hosthardwarerelation', + name='job', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.Job'), + ), + migrations.AddField( + model_name='accessrelation', + name='job', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.Job'), + ), + migrations.AddField( + model_name='softwarerelation', + name='config', + field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='api.SoftwareConfig'), + ), + migrations.AddField( + model_name='hostnetworkrelation', + name='config', + field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='api.NetworkConfig'), + ), + migrations.AddField( + model_name='hosthardwarerelation', + name='config', + field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='api.HardwareConfig'), + ), + migrations.AddField( + model_name='accessrelation', + name='config', + field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='api.AccessConfig'), + ), + ] diff --git a/dashboard/src/api/migrations/__init__.py b/dashboard/src/api/migrations/__init__.py index b5914ce..e0408fa 100644 --- a/dashboard/src/api/migrations/__init__.py +++ b/dashboard/src/api/migrations/__init__.py @@ -1,10 +1,8 @@ ############################################################################## -# Copyright (c) 2016 Max Breitenfeldt and others. +# Copyright (c) 2018 Parker Berberian, Sawyer Bergeron, and others. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## - - diff --git a/dashboard/src/api/models.py b/dashboard/src/api/models.py new file mode 100644 index 0000000..f1e9130 --- /dev/null +++ b/dashboard/src/api/models.py @@ -0,0 +1,713 @@ +############################################################################## +# Copyright (c) 2018 Sawyer Bergeron, Parker Berberian, and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +from django.db import models +from django.core.exceptions import PermissionDenied + +import json +import uuid + +from resource_inventory.models import * +from booking.models import Booking + + +class JobStatus(object): + NEW = 0 + CURRENT = 100 + DONE = 200 + ERROR = 300 + + +class LabManagerTracker(object): + + @classmethod + def get(cls, lab_name, token): + """ + Takes in a lab name (from a url path) + returns a lab manager instance for that lab, if it exists + """ + try: + lab = Lab.objects.get(name=lab_name) + except: + raise PermissionDenied("Lab not found") + if lab.api_token == token: + return LabManager(lab) + raise PermissionDenied("Lab not authorized") + + +class LabManager(object): + """ + This is the class that will ultimately handle all REST calls to + lab endpoints. + handles jobs, inventory, status, etc + may need to create helper classes + """ + + def __init__(self, lab): + self.lab = lab + + def get_profile(self): + prof = {} + prof['name'] = self.lab.name + prof['contact'] = { + "phone": self.lab.contact_phone, + "email": self.lab.contact_email + } + prof['host_count'] = [] + for host in HostProfile.objects.filter(labs=self.lab): + count = Host.objects.filter(profile=host, lab=self.lab).count() + prof['host_count'].append({ + "type": host.name, + "count": count + }) + return prof + + def get_inventory(self): + inventory = {} + hosts = Host.objects.filter(lab=self.lab) + images = Image.objects.filter(from_lab=self.lab) + profiles = HostProfile.objects.filter(labs=self.lab) + inventory['hosts'] = self.serialize_hosts(hosts) + inventory['images'] = self.serialize_images(images) + inventory['host_types'] = self.serialize_host_profiles(profiles) + return inventory + + def get_status(self): + return {"status": self.lab.status} + + def set_status(self, payload): + {} + + def get_current_jobs(self): + jobs = Job.objects.filter(booking__lab=self.lab) + + return self.serialize_jobs(jobs, status=JobStatus.CURRENT) + + def get_new_jobs(self): + jobs = Job.objects.filter(booking__lab=self.lab) + + return self.serialize_jobs(jobs, status=JobStatus.NEW) + + def get_done_jobs(self): + jobs = Job.objects.filter(booking__lab=self.lab) + + return self.serialize_jobs(jobs, status=JobStatus.DONE) + + def get_job(self, jobid): + return Job.objects.get(pk=jobid).to_dict() + + def update_job(self, jobid, data): + {} + + def serialize_jobs(self, jobs, status=JobStatus.NEW): + job_ser = [] + for job in jobs: + jsonized_job = job.get_delta(status) + if len(jsonized_job['payload']) < 1: + continue + job_ser.append(jsonized_job) + + return job_ser + + def serialize_hosts(self, hosts): + host_ser = [] + for host in hosts: + h = {} + h['interfaces'] = [] + h['hostname'] = host.name + h['host_type'] = host.profile.name + for iface in host.interfaces.all(): + eth = {} + eth['mac'] = iface.mac_address + eth['busaddr'] = iface.bus_address + eth['name'] = iface.name + eth['switchport'] = {"switch_name": iface.switch_name, "port_name": iface.port_name} + h['interfaces'].append(eth) + return host_ser + + def serialize_images(self, images): + images_ser = [] + for image in images: + images_ser.append({ + "name": image.name, + "lab_id": image.lab_id, + "dashboard_id": image.id + }) + return images_ser + + def serialize_host_profiles(self, profiles): + profile_ser = [] + for profile in profiles: + p = {} + p['cpu'] = { + "cores": profile.cpuprofile.first().cores, + "arch": profile.cpuprofile.first().architecture, + "cpus": profile.cpuprofile.first().cpus, + } + p['disks'] = [] + for disk in profile.storageprofile.all(): + d = { + "size": disk.size, + "type": disk.media_type, + "name": disk.name + } + p['disks'].append(d) + p['description'] = profile.description + p['interfaces'] = [] + for iface in profile.interfaceprofile.all(): + p['interfaces'].append({ + "speed": iface.speed, + "name": iface.name + }) + + p['ram'] = {"amount": profile.ramprofile.first().amount} + p['name'] = profile.name + profile_ser.append(p) + return profile_ser + + +class Job(models.Model): + """ + This is the class that is serialized and put into the api + """ + booking = models.OneToOneField(Booking, on_delete=models.CASCADE, null=True) + status = models.IntegerField(default=JobStatus.NEW) + complete = models.BooleanField(default=False) + + def to_dict(self): + d = {} + j = {} + j['id'] = self.id + for relation in AccessRelation.objects.filter(job=self): + if 'access' not in d: + d['access'] = {} + d['access'][relation.task_id] = relation.config.to_dict() + for relation in SoftwareRelation.objects.filter(job=self): + if 'software' not in d: + d['software'] = {} + d['software'][relation.task_id] = relation.config.to_dict() + for relation in HostHardwareRelation.objects.filter(job=self): + if 'hardware' not in d: + d['hardware'] = {} + d['hardware'][relation.task_id] = relation.config.to_dict() + for relation in HostNetworkRelation.objects.filter(job=self): + if 'network' not in d: + d['network'] = {} + d['network'][relation.task_id] = relation.config.to_dict() + + j['payload'] = d + + return j + + def get_tasklist(self, status="all"): + tasklist = [] + clist = [HostHardwareRelation, AccessRelation, HostNetworkRelation, SoftwareRelation] + if status == "all": + for cls in clist: + tasklist += list(cls.objects.filter(job=self)) + else: + for cls in clist: + tasklist += list(cls.objects.filter(job=self).filter(status=status)) + return tasklist + + def get_delta(self, status): + d = {} + j = {} + j['id'] = self.id + for relation in AccessRelation.objects.filter(job=self).filter(status=status): + if 'access' not in d: + d['access'] = {} + d['access'][relation.task_id] = relation.config.get_delta() + for relation in SoftwareRelation.objects.filter(job=self).filter(status=status): + if 'software' not in d: + d['software'] = {} + d['software'][relation.task_id] = relation.config.get_delta() + for relation in HostHardwareRelation.objects.filter(job=self).filter(status=status): + if 'hardware' not in d: + d['hardware'] = {} + d['hardware'][relation.task_id] = relation.config.get_delta() + for relation in HostNetworkRelation.objects.filter(job=self).filter(status=status): + if 'network' not in d: + d['network'] = {} + d['network'][relation.task_id] = relation.config.get_delta() + + j['payload'] = d + return j + + def to_json(self): + return json.dumps(self.to_dict()) + + +class TaskConfig(models.Model): + def to_dict(self): + pass + + def get_delta(self): + pass + + def to_json(self): + return json.dumps(self.to_dict()) + + def clear_delta(self): + self.delta = '{}' + +class OpnfvApiConfig(models.Model): + + installer = models.CharField(max_length=100) + scenario = models.CharField(max_length=100) + roles = models.ManyToManyField(Host) + delta = models.TextField() + + def to_dict(self): + d = {} + if self.installer: + d['installer'] = self.installer + if self.scenario: + d['scenario'] = self.scenario + + hosts = self.roles.all() + if hosts.exists(): + d['roles'] = [] + for host in self.roles.all(): + d['roles'].append({host.labid: host.config.opnfvRole.name}) + + return d + + def to_json(self): + return json.dumps(self.to_dict()) + + def set_installer(self, installer): + self.installer = installer + d = json.loads(self.delta) + d['installer'] = installer + self.delta = json.dumps(d) + + def set_scenario(self, scenario): + self.scenario = scenario + d = json.loads(self.delta) + d['scenario'] = scenario + self.delta = json.dumps(d) + + def add_role(self, host): + self.roles.add(host) + d = json.loads(self.delta) + if 'role' not in d: + d['role'] = [] + d['roles'].append({host.labid: host.config.opnfvRole.name}) + self.delta = json.dumps(d) + + def clear_delta(self): + self.delta = '{}' + + def get_delta(self): + if not self.delta: + self.delta = self.to_json() + self.save() + return json.loads(self.delta) + +class AccessConfig(TaskConfig): + access_type = models.CharField(max_length=50) + user = models.ForeignKey(User, on_delete=models.CASCADE) + revoke = models.BooleanField(default=False) + context = models.TextField(default="") + delta = models.TextField() + + def to_dict(self): + d = {} + d['access_type'] = self.access_type + d['user'] = self.user.id + d['revoke'] = self.revoke + d['context'] = self.context + return d + + def get_delta(self): + if not self.delta: + self.delta = self.to_json() + self.save() + d = json.loads(self.delta) + d["lab_token"] = self.accessrelation.lab_token + + return d + + def to_json(self): + return json.dumps(self.to_dict()) + + def clear_delta(self): + d = {} + d["lab_token"] = self.accessrelation.lab_token + self.delta = json.dumps(d) + + def set_access_type(self, access_type): + self.access_type = access_type + d = json.loads(self.delta) + d['access_type'] = access_type + self.delta = json.dumps(d) + + def set_user(self, user): + self.user = user + d = json.loads(self.delta) + d['user'] = self.user.id + self.delta = json.dumps(d) + + def set_revoke(self, revoke): + self.revoke = revoke + d = json.loads(self.delta) + d['revoke'] = revoke + self.delta = json.dumps(d) + + def set_context(self, context): + self.context = context + d = json.loads(self.delta) + d['context'] = context + self.delta = json.dumps(d) + +class SoftwareConfig(TaskConfig): + """ + handled opnfv installations, etc + """ + opnfv = models.ForeignKey(OpnfvApiConfig, on_delete=models.CASCADE) + + def to_dict(self): + d = {} + if self.opnfv: + d['opnfv'] = self.opnfv.to_dict() + + d["lab_token"] = self.softwarerelation.lab_token + self.delta = json.dumps(d) + + return d + + def get_delta(self): + d = {} + d['opnfv'] = self.opnfv.get_delta() + d['lab_token'] = self.softwarerelation.lab_token + + return d + + def clear_delta(self): + self.opnfv.clear_delta() + + def to_json(self): + return json.dumps(self.to_dict()) + +class HardwareConfig(TaskConfig): + """ + handles imaging, user accounts, etc + """ + image = models.CharField(max_length=100, default="defimage") + power = models.CharField(max_length=100, default="off") + hostname = models.CharField(max_length=100, default="hostname") + ipmi_create = models.BooleanField(default=False) + delta = models.TextField() + + def to_dict(self): + d = {} + d['image'] = self.image + d['power'] = self.power + d['hostname'] = self.hostname + d['ipmi_create'] = str(self.ipmi_create) + d['id'] = self.hosthardwarerelation.host.labid + return d + + def to_json(self): + return json.dumps(self.to_dict()) + + def get_delta(self): + if not self.delta: + self.delta = self.to_json() + self.save() + d = json.loads(self.delta) + d['lab_token'] = self.hosthardwarerelation.lab_token + return d + + def clear_delta(self): + d = {} + d["id"] = self.hosthardwarerelation.host.labid + d["lab_token"] = self.hosthardwarerelation.lab_token + self.delta = json.dumps(d) + + def set_image(self, image): + self.image = image + d = json.loads(self.delta) + d['image'] = self.image + self.delta = json.dumps(d) + + def set_power(self, power): + self.power = power + d = json.loads(self.delta) + d['power'] = power + self.delta = json.dumps(d) + + def set_hostname(self, hostname): + self.hostname = hostname + d = json.loads(self.delta) + d['hostname'] = hostname + self.delta = json.dumps(d) + + def set_ipmi_create(self, ipmi_create): + self.ipmi_create = ipmi_create + d = json.loads(self.delta) + d['ipmi_create'] = ipmi_create + self.delta = json.dumps(d) + + +class NetworkConfig(TaskConfig): + """ + handles network configuration + """ + interfaces = models.ManyToManyField(Interface) + delta = models.TextField() + + def to_dict(self): + d = {} + hid = self.hostnetworkrelation.host.labid + d[hid] = {} + for interface in self.interfaces.all(): + d[hid][interface.mac_address] = [] + for vlan in interface.config.all(): + d[hid][interface.mac_address].append({"vlan_id": vlan.vlan_id, "tagged": vlan.tagged}) + + return d + + def to_json(self): + return json.dumps(self.to_dict()) + + def get_delta(self): + if not self.delta: + self.delta = self.to_json() + self.save() + d = json.loads(self.delta) + d['lab_token'] = self.hostnetworkrelation.lab_token + return d + + def clear_delta(self): + pass + + def add_interface(self, interface): + self.interfaces.add(interface) + d = json.loads(self.delta) + hid = self.hostnetworkrelation.host.labid + if hid not in d: + d[hid] = {} + d[hid][interface.mac_address] = [] + for vlan in interface.config.all(): + d[hid][interface.mac_address].append({"vlan_id": vlan.vlan_id, "tagged": vlan.tagged}) + self.delta = json.dumps(d) + + +def get_task(task_id): + for taskclass in [AccessRelation, SoftwareRelation, HostHardwareRelation, HostNetworkRelation]: + try: + ret = taskclass.objects.get(task_id=task_id) + return ret + except taskclass.DoesNotExist: + pass + from django.core.exceptions import ObjectDoesNotExist + raise ObjectDoesNotExist("Could not find matching TaskRelation instance") + + +def get_task_uuid(): + return str(uuid.uuid4()) + + +class TaskRelation(models.Model): + status = models.IntegerField(default=JobStatus.NEW) + job = models.ForeignKey(Job, on_delete=models.CASCADE) + config = models.OneToOneField(TaskConfig, on_delete=models.CASCADE) + task_id = models.CharField(default=get_task_uuid, max_length=37) + lab_token = models.CharField(default="null", max_length=50) + message = models.TextField(default="") + + def delete(self, *args, **kwargs): + self.config.delete() + return super(self.__class__, self).delete(*args, **kwargs) + + def type_str(self): + return "Generic Task" + + class Meta: + abstract = True + + +class AccessRelation(TaskRelation): + config = models.OneToOneField(AccessConfig, on_delete=models.CASCADE) + + def type_str(self): + return "Access Task" + + def delete(self, *args, **kwargs): + self.config.delete() + return super(self.__class__, self).delete(*args, **kwargs) + + +class SoftwareRelation(TaskRelation): + config = models.OneToOneField(SoftwareConfig, on_delete=models.CASCADE) + + def type_str(self): + return "Software Configuration Task" + + def delete(self, *args, **kwargs): + self.config.delete() + return super(self.__class__, self).delete(*args, **kwargs) + + +class HostHardwareRelation(TaskRelation): + host = models.ForeignKey(Host, on_delete=models.CASCADE) + config = models.OneToOneField(HardwareConfig, on_delete=models.CASCADE) + + def type_str(self): + return "Hardware Configuration Task" + + def get_delta(self): + return self.config.to_dict() + + def delete(self, *args, **kwargs): + self.config.delete() + return super(self.__class__, self).delete(*args, **kwargs) + + +class HostNetworkRelation(TaskRelation): + host = models.ForeignKey(Host, on_delete=models.CASCADE) + config = models.OneToOneField(NetworkConfig, on_delete=models.CASCADE) + + def type_str(self): + return "Network Configuration Task" + + def delete(self, *args, **kwargs): + self.config.delete() + return super(self.__class__, self).delete(*args, **kwargs) + + +class JobFactory(object): + + @classmethod + def makeCompleteJob(cls, booking): + hosts = Host.objects.filter(bundle=booking.resource) + job = None + try: + job = Job.objects.get(booking=booking) + except: + job = Job.objects.create(status=JobStatus.NEW, booking=booking) + cls.makeHardwareConfigs( + hosts=hosts, + job=job + ) + cls.makeNetworkConfigs( + hosts=hosts, + job=job + ) + cls.makeSoftware( + hosts=hosts, + job=job + ) + cls.makeAccessConfig( + users=booking.collaborators.all(), + access_type="vpn", + revoke=False, + job=job + ) + cls.makeAccessConfig( + users=[booking.owner], + access_type="vpn", + revoke=False, + job=job + ) + + @classmethod + def makeHardwareConfigs(cls, hosts=[], job=Job()): + for host in hosts: + hardware_config = None + try: + hardware_config = HardwareConfig.objects.get(relation__host=host) + except: + hardware_config = HardwareConfig() + + relation = HostHardwareRelation() + relation.host = host + relation.job = job + relation.config = hardware_config + relation.config.save() + relation.config = relation.config + relation.save() + + hardware_config.clear_delta() + hardware_config.set_image(host.config.image.lab_id) + hardware_config.set_hostname(host.template.resource.name) + hardware_config.set_power("on") + hardware_config.set_ipmi_create(True) + hardware_config.save() + + @classmethod + def makeAccessConfig(cls, users, access_type, revoke=False, job=Job()): + for user in users: + relation = AccessRelation() + relation.job = job + config = AccessConfig() + config.access_type = access_type + config.user = user + config.save() + relation.config = config + relation.save() + config.clear_delta() + config.set_access_type(access_type) + config.set_revoke(revoke) + config.set_user(user) + config.save() + + @classmethod + def makeNetworkConfigs(cls, hosts=[], job=Job()): + for host in hosts: + network_config = None + try: + network_config = NetworkConfig.objects.get(relation__host=host) + except: + network_config = NetworkConfig.objects.create() + + relation = HostNetworkRelation() + relation.host = host + relation.job = job + network_config.save() + relation.config = network_config + relation.save() + network_config.clear_delta() + + for interface in host.interfaces.all(): + network_config.add_interface(interface) + network_config.save() + + @classmethod + def makeSoftware(cls, hosts=[], job=Job()): + def init_config(host): + opnfv_config = OpnfvApiConfig() + if host is not None: + opnfv = host.config.bundle.opnfv_config.first() + opnfv_config.installer = opnfv.installer.name + opnfv_config.scenario = opnfv.scenario.name + opnfv_config.save() + return opnfv_config + + try: + host = None + if len(hosts) > 0: + host = hosts[0] + opnfv_config = init_config(host) + + for host in hosts: + opnfv_config.roles.add(host) + software_config = SoftwareConfig.objects.create(opnfv=opnfv_config) + software_config.save() + software_relation = SoftwareRelation.objects.create(job=job, config=software_config) + software_relation.save() + return software_relation + except: + return None + + def makeAccess(cls, user, access_type, revoke): + pass diff --git a/dashboard/src/api/serializers.py b/dashboard/src/api/serializers.py deleted file mode 100644 index 10e1975..0000000 --- a/dashboard/src/api/serializers.py +++ /dev/null @@ -1,53 +0,0 @@ -############################################################################## -# Copyright (c) 2016 Max Breitenfeldt and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - - -from rest_framework import serializers - -from account.models import UserProfile -from notifier.models import Notifier -from booking.models import Booking -from dashboard.models import Server, Resource, ResourceStatus - -class BookingSerializer(serializers.ModelSerializer): - installer_name = serializers.CharField(source='installer.name') - scenario_name = serializers.CharField(source='scenario.name') - opsys_name = serializers.CharField(source='opsys.name') - - class Meta: - model = Booking - fields = ('id', 'changeid', 'reset', 'user', 'resource_id', 'opsys_name', 'start', 'end', 'installer_name', 'scenario_name', 'purpose') - - -class ServerSerializer(serializers.ModelSerializer): - class Meta: - model = Server - fields = ('id', 'resource_id', 'name', 'model', 'cpu', 'ram', 'storage') - - -class ResourceSerializer(serializers.ModelSerializer): - class Meta: - model = Resource - fields = ('id', 'name', 'description', 'resource_lab', 'url', 'server_set', 'dev_pod') - -class ResourceStatusSerializer(serializers.ModelSerializer): - class Meta: - model = ResourceStatus - fields = ('id', 'resource', 'timestamp','type', 'title', 'content') - -class NotifierSerializer(serializers.ModelSerializer): - class Meta: - model = Notifier - fields = ('id', 'title', 'content', 'user', 'sender', 'message_type', 'msg_sent') - -class UserSerializer(serializers.ModelSerializer): - username = serializers.CharField(source='user.username') - class Meta: - model = UserProfile - fields = ('user', 'username', 'ssh_public_key', 'pgp_public_key', 'email_addr') diff --git a/dashboard/src/api/serializers/__init__.py b/dashboard/src/api/serializers/__init__.py new file mode 100644 index 0000000..e0408fa --- /dev/null +++ b/dashboard/src/api/serializers/__init__.py @@ -0,0 +1,8 @@ +############################################################################## +# Copyright (c) 2018 Parker Berberian, Sawyer Bergeron, and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## diff --git a/dashboard/src/api/serializers/booking_serializer.py b/dashboard/src/api/serializers/booking_serializer.py new file mode 100644 index 0000000..e891de4 --- /dev/null +++ b/dashboard/src/api/serializers/booking_serializer.py @@ -0,0 +1,156 @@ +############################################################################## +# Copyright (c) 2018 Parker Berberian, Sawyer Bergeron, and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +from rest_framework import serializers + +from resource_inventory.models import * + +class BookingField(serializers.Field): + + def to_representation(self, booking): + """ + Takes in a booking object. + Returns a dictionary of primitives representing that booking + """ + ser = {} + ser['id'] = booking.id + # main loop to grab relevant info out of booking + host_configs = {} # mapping hostname -> config + networks = {} # mapping vlan id -> network_hosts + for host in booking.resource.hosts.all(): + host_configs[host.name] = HostConfiguration.objects.get(host=host.template) + if "jumphost" not in ser and host_configs[host.name].opnfvRole.name.lower() == "jumphost": + ser['jumphost'] = host.name + #host is a Host model + for i in range(len(host.interfaces.all())): + interface = host.interfaces.all()[i] + #interface is an Interface model + for vlan in interface.config.all(): + #vlan is Vlan model + if vlan.id not in networks: + networks[vlan.id] = [] + net_host = {"hostname": host.name, "tagged": vlan.tagged, "interface":i} + networks[vlan.id].append(net_host) + #creates networking object of proper form + networking = [] + for vlanid in networks: + network = {} + network['vlan_id'] = vlanid + network['hosts'] = networks[vlanid] + + ser['networking'] = networking + + #creates hosts object of correct form + hosts = [] + for hostname in host_configs: + host = {"hostname": hostname} + host['deploy_image'] = True # TODO? + image = host_configs[hostname].image + host['image'] = { + "name": image.name, + "lab_id": image.lab_id, + "dashboard_id": image.id + } + hosts.append(host) + + ser['hosts'] = hosts + + return ser + + def to_internal_value(self, data): + """ + Takes in a dictionary of primitives + Returns a booking object + + This is not going to be implemented or allowed. + If someone needs to create a booking through the api, + they will send a different booking object + """ + return None + +class BookingSerializer(serializers.Serializer): + + booking = BookingField() + +#Host Type stuff, for inventory + +class CPUSerializer(serializers.ModelSerializer): + class Meta: + model = CpuProfile + fields = ('cores', 'architecture', 'cpus') + +class DiskSerializer(serializers.ModelSerializer): + class Meta: + model = DiskProfile + fields = ('size', 'media_type', 'name') + +class InterfaceProfileSerializer(serializers.ModelSerializer): + class Meta: + model = InterfaceProfile + fields = ('speed', 'name') + +class RamSerializer(serializers.ModelSerializer): + class Meta: + model = RamProfile + fields = ('amount', 'channels') + +class HostTypeSerializer(serializers.Serializer): + name = serializers.CharField(max_length=200) + ram = RamSerializer() + interface = InterfaceProfileSerializer() + description = serializers.CharField(max_length=1000) + disks = DiskSerializer() + cpu = CPUSerializer() + +#the rest of the inventory stuff +class NetworkSerializer(serializers.Serializer): + cidr = serializers.CharField(max_length=200) + gateway = serializers.IPAddressField(max_length=200) + vlan = serializers.IntegerField() + +class ImageSerializer(serializers.ModelSerializer): + lab_id = serializers.IntegerField() + id = serializers.IntegerField(source="dashboard_id") + name = serializers.CharField(max_length=50) + description = serializers.CharField(max_length=200) + class Meta: + model = Image + +class InterfaceField(serializers.Field): + def to_representation(self, interface): + pass + + def to_internal_value(self, data): + """ + takes in a serialized interface and creates an Interface model + """ + mac = data['mac'] + bus_address = data['busaddr'] + switch_name = data['switchport']['switch_name'] + port_name = data['switchport']['port_name'] + # TODO config?? + return Interface.objects.create( + mac_address=mac, + bus_address=bus_address, + switch_name=switch_name, + port_name=port_name + ) + +class InventoryHostSerializer(serializers.Serializer): + hostname = serializers.CharField(max_length=100) + host_type = serializers.CharField(max_length=100) + interfaces = InterfaceField() + + +class InventorySerializer(serializers.Serializer): + hosts = InventoryHostSerializer() + networks = NetworkSerializer() + images = ImageSerializer() + host_types = HostTypeSerializer() diff --git a/dashboard/src/api/serializers/old_serializers.py b/dashboard/src/api/serializers/old_serializers.py new file mode 100644 index 0000000..f50b90b --- /dev/null +++ b/dashboard/src/api/serializers/old_serializers.py @@ -0,0 +1,28 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +from rest_framework import serializers + +from account.models import UserProfile +from notifier.models import Notifier + + +class NotifierSerializer(serializers.ModelSerializer): + class Meta: + model = Notifier + fields = ('id', 'title', 'content', 'user', 'sender', 'message_type', 'msg_sent') + + +class UserSerializer(serializers.ModelSerializer): + username = serializers.CharField(source='user.username') + + class Meta: + model = UserProfile + fields = ('user', 'username', 'ssh_public_key', 'pgp_public_key', 'email_addr') diff --git a/dashboard/src/api/tests/__init__.py b/dashboard/src/api/tests/__init__.py new file mode 100644 index 0000000..fe2a32d --- /dev/null +++ b/dashboard/src/api/tests/__init__.py @@ -0,0 +1,8 @@ +############################################################################## +# Copyright (c) 2016 Parker Berberian and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## \ No newline at end of file diff --git a/dashboard/src/api/tests/test_serializers.py b/dashboard/src/api/tests/test_serializers.py new file mode 100644 index 0000000..c49010c --- /dev/null +++ b/dashboard/src/api/tests/test_serializers.py @@ -0,0 +1,213 @@ +############################################################################## +# Copyright (c) 2018 Sawyer Bergeron and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +from django.test import TestCase +from booking.models import Booking +from resource_inventory.models import * +from account.models import Lab +from api.serializers.booking_serializer import * +from datetime import timedelta +from django.utils import timezone +from django.contrib.auth.models import Permission, User + + +class BookingSerializerTestCase(TestCase): + + count = 0 + + def makeHostConfigurations(self, hosts, config): + lab_user = User.objects.create(username="asfasdfasdf") + owner = User.objects.create(username="asfasdfasdffffff") + lab = Lab.objects.create( + lab_user=lab_user, + name="TestLab123123", + contact_email="mail@email.com", + contact_phone="" + ) + jumphost=True + for host in hosts: + image = Image.objects.create( + lab_id=12, + from_lab=lab, + name="this is a test image", + owner=owner + ) + name = "jumphost" + if not jumphost: + name = "compute" + role = OPNFVRole.objects.create( + name=name, + description="stuff" + ) + + HostConfiguration.objects.create( + host=host, + image=image, + bundle=config, + opnfvRole=role + ) + jumphost=False + + + def setUp(self): + self.serializer = BookingField() + lab_user = User.objects.create(username="lab user") + lab = Lab.objects.create(name="test lab", lab_user=lab_user) + # create hostProfile + hostProfile = HostProfile.objects.create( + host_type=0, + name='Test profile', + description='a test profile' + ) + interfaceProfile = InterfaceProfile.objects.create( + speed=1000, + name='eno3', + host=hostProfile + ) + diskProfile = DiskProfile.objects.create( + size=1000, + media_type="SSD", + name='/dev/sda', + host=hostProfile + ) + cpuProfile = CpuProfile.objects.create( + cores=96, + architecture="x86_64", + cpus=2, + host=hostProfile + ) + ramProfile = RamProfile.objects.create( + amount=256, + channels=4, + host=hostProfile + ) + + #create GenericResourceBundle + genericBundle = GenericResourceBundle.objects.create() + + gres1 = GenericResource.objects.create( + bundle=genericBundle, + name='generic resource ' + str(self.count) + ) + self.count += 1 + gHost1 = GenericHost.objects.create( + resource=gres1, + profile=hostProfile + ) + + gres2 = GenericResource.objects.create( + bundle=genericBundle, + name='generic resource ' + str(self.count) + ) + self.count += 1 + gHost2 = GenericHost.objects.create( + resource=gres2, + profile=hostProfile + ) + user1 = User.objects.create(username='user1') + + add_booking_perm = Permission.objects.get(codename='add_booking') + user1.user_permissions.add(add_booking_perm) + + user1 = User.objects.get(pk=user1.id) + + conf = ConfigBundle.objects.create(owner=user1, name="test conf") + self.makeHostConfigurations([gHost1, gHost2], conf) + + #actual resource bundle + bundle = ResourceBundle.objects.create( + template = genericBundle + ) + + host1 = Host.objects.create( + template=gHost1, + booked=True, + name='host1', + bundle=bundle, + profile=hostProfile, + lab=lab + ) + + host2 = Host.objects.create( + template=gHost2, + booked=True, + name='host2', + bundle=bundle, + profile=hostProfile, + lab=lab + ) + + vlan1 = Vlan.objects.create(vlan_id=300, tagged=False) + vlan2 = Vlan.objects.create(vlan_id=300, tagged=False) + + iface1 = Interface.objects.create( + mac_address='00:11:22:33:44:55', + bus_address='some bus address', + switch_name='switch1', + port_name='port10', + host=host1 + ) + + iface1.config = [vlan1] + + iface2 = Interface.objects.create( + mac_address='00:11:22:33:44:56', + bus_address='some bus address', + switch_name='switch1', + port_name='port12', + host=host2 + ) + + iface2.config = [vlan2] + + # finally, can create booking + self.booking = Booking.objects.create( + owner=user1, + start = timezone.now(), + end = timezone.now() + timedelta(weeks=1), + purpose='Testing', + resource=bundle, + config_bundle=conf + ) + + serialized_booking = {} + + host1 = {} + host1['hostname'] = 'host1' + host1['image'] = {} # TODO: Images + host1['deploy_image'] = True + host2 = {} + host2['hostname'] = 'host2' + host2['image'] = {} # TODO: Images + host2['deploy_image'] = True + + serialized_booking['hosts'] = [host1, host2] + + net = {} + net['name'] = 'network_name' + net['vlan_id'] = 300 + netHost1 = {} + netHost1['hostname'] = 'host1' + netHost1['tagged'] = False + netHost1['interface'] = 0 + netHost2 = {} + netHost2['hostname'] = 'host2' + netHost2['tagged'] = False + netHost2['interface'] = 0 + net['hosts'] = [netHost1, netHost2] + + serialized_booking['networking'] = [net] + serialized_booking['jumphost'] = 'host1' + + self.serialized_booking = serialized_booking + + def test_to_representation(self): + keys = ['hosts', 'networking', 'jumphost'] + serialized_form = self.serializer.to_representation(self.booking) + for key in keys: + self.assertEquals(serialized_form[key], self.serialized_booking) diff --git a/dashboard/src/api/urls.py b/dashboard/src/api/urls.py index c2cd510..94f8279 100644 --- a/dashboard/src/api/urls.py +++ b/dashboard/src/api/urls.py @@ -1,5 +1,6 @@ ############################################################################## # Copyright (c) 2016 Max Breitenfeldt and others. +# Copyright (c) 2018 Sawyer Bergeron, Parker Berberian, and others # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 @@ -24,19 +25,25 @@ Including another URLconf 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) """ from django.conf.urls import url, include +from django.urls import path from rest_framework import routers from api.views import * router = routers.DefaultRouter() -router.register(r'resources', ResourceViewSet) -router.register(r'servers', ServerViewSet) router.register(r'bookings', BookingViewSet) -router.register(r'resource_status', ResourceStatusViewSet) router.register(r'notifier', NotifierViewSet) router.register(r'user', UserViewSet) urlpatterns = [ url(r'^', include(router.urls)), + path('labs//profile', lab_profile), + path('labs//status', lab_status), + path('labs//inventory', lab_inventory), + path('labs//jobs/', specific_job), + path('labs//jobs//', specific_task), + path('labs//jobs/new', new_jobs), + path('labs//jobs/current', current_jobs), + path('labs//jobs/done', done_jobs), url(r'^token$', GenerateTokenView.as_view(), name='generate_token'), ] diff --git a/dashboard/src/api/views.py b/dashboard/src/api/views.py index b873ef1..cefd131 100644 --- a/dashboard/src/api/views.py +++ b/dashboard/src/api/views.py @@ -1,5 +1,6 @@ ############################################################################## # Copyright (c) 2016 Max Breitenfeldt and others. +# Copyright (c) 2018 Parker Berberian, Sawyer Bergeron, and others. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 @@ -8,17 +9,23 @@ ############################################################################## -from django.contrib.auth.decorators import login_required, user_passes_test +from django.contrib.auth.decorators import login_required from django.shortcuts import redirect from django.utils.decorators import method_decorator from django.views import View +from django.http.response import JsonResponse from rest_framework import viewsets from rest_framework.authtoken.models import Token +from django.views.decorators.csrf import csrf_exempt -from api.serializers import * +import json + +from api.serializers.booking_serializer import * +from api.serializers.old_serializers import NotifierSerializer, UserSerializer from account.models import UserProfile from booking.models import Booking -from dashboard.models import Resource, Server, ResourceStatus +from notifier.models import Notifier +from api.models import * class BookingViewSet(viewsets.ModelViewSet): @@ -27,29 +34,16 @@ class BookingViewSet(viewsets.ModelViewSet): filter_fields = ('resource', 'id') -class ServerViewSet(viewsets.ModelViewSet): - queryset = Server.objects.all() - serializer_class = ServerSerializer - filter_fields = ('resource', 'name') - - -class ResourceViewSet(viewsets.ModelViewSet): - queryset = Resource.objects.all() - serializer_class = ResourceSerializer - filter_fields = ('name', 'id') - -class ResourceStatusViewSet(viewsets.ModelViewSet): - queryset = ResourceStatus.objects.all() - serializer_class = ResourceStatusSerializer - class NotifierViewSet(viewsets.ModelViewSet): queryset = Notifier.objects.none() serializer_class = NotifierSerializer + class UserViewSet(viewsets.ModelViewSet): queryset = UserProfile.objects.all() serializer_class = UserSerializer + @method_decorator(login_required, name='dispatch') class GenerateTokenView(View): def get(self, request, *args, **kwargs): @@ -59,3 +53,74 @@ class GenerateTokenView(View): token.delete() Token.objects.create(user=user) return redirect('account:settings') + + +def lab_inventory(request, lab_name=""): + lab_token = request.META.get('HTTP_AUTH_TOKEN') + lab_manager = LabManagerTracker.get(lab_name, lab_token) + return JsonResponse(lab_manager.get_inventory(), safe=False) + + +def lab_status(request, lab_name=""): + lab_token = request.META.get('HTTP_AUTH_TOKEN') + lab_manager = LabManagerTracker.get(lab_name, lab_token) + if request.method == "POST": + return JsonResponse(lab_manager.set_status(request.POST), safe=False) + return JsonResponse(lab_manager.get_status(), safe=False) + + +def lab_profile(request, lab_name=""): + lab_token = request.META.get('HTTP_AUTH_TOKEN') + lab_manager = LabManagerTracker.get(lab_name, lab_token) + return JsonResponse(lab_manager.get_profile(), safe=False) + + +@csrf_exempt +def specific_task(request, lab_name="", job_id="", task_id=""): + lab_token = request.META.get('HTTP_AUTH_TOKEN') + LabManagerTracker.get(lab_name, lab_token) # Authorize caller, but we dont need the result + + if request.method == "POST": + task = get_task(task_id) + if 'status' in request.POST: + task.status = request.POST.get('status') + if 'message' in request.POST: + task.message = request.POST.get('message') + task.save() + d = {} + d['task'] = task.config.get_delta() + m = {} + m['status'] = task.status + m['job'] = str(task.job) + m['message'] = task.message + d['meta'] = m + response = json.dumps(d) + return JsonResponse(response) + elif request.method == "GET": + return JsonResponse(get_task(task_id).config.get_delta()) + + +def specific_job(request, lab_name="", job_id=""): + lab_token = request.META.get('HTTP_AUTH_TOKEN') + lab_manager = LabManagerTracker.get(lab_name, lab_token) + if request.method == "POST": + return JsonResponse(lab_manager.update_job(job_id, request.POST), safe=False) + return JsonResponse(lab_manager.get_job(job_id), safe=False) + + +def new_jobs(request, lab_name=""): + lab_token = request.META.get('HTTP_AUTH_TOKEN') + lab_manager = LabManagerTracker.get(lab_name, lab_token) + return JsonResponse(lab_manager.get_new_jobs(), safe=False) + + +def current_jobs(request, lab_name=""): + lab_token = request.META.get('HTTP_AUTH_TOKEN') + lab_manager = LabManagerTracker.get(lab_name, lab_token) + return JsonResponse(lab_manager.get_current_jobs(), safe=False) + + +def done_jobs(request, lab_name=""): + lab_token = request.META.get('HTTP_AUTH_TOKEN') + lab_manager = LabManagerTracker.get(lab_name, lab_token) + return JsonResponse(lab_manager.get_done_jobs(), safe=False) diff --git a/dashboard/src/booking/__init__.py b/dashboard/src/booking/__init__.py index b5914ce..b6fef6c 100644 --- a/dashboard/src/booking/__init__.py +++ b/dashboard/src/booking/__init__.py @@ -6,5 +6,3 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## - - diff --git a/dashboard/src/booking/admin.py b/dashboard/src/booking/admin.py index 51e1031..2beb05b 100644 --- a/dashboard/src/booking/admin.py +++ b/dashboard/src/booking/admin.py @@ -1,5 +1,6 @@ ############################################################################## # Copyright (c) 2016 Max Breitenfeldt and others. +# Copyright (c) 2018 Parker Berberian, Sawyer Bergeron, and others. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 @@ -13,6 +14,3 @@ from django.contrib import admin from booking.models import * admin.site.register(Booking) -admin.site.register(Opsys) -admin.site.register(Installer) -admin.site.register(Scenario) diff --git a/dashboard/src/booking/forms.py b/dashboard/src/booking/forms.py deleted file mode 100644 index 9d71b42..0000000 --- a/dashboard/src/booking/forms.py +++ /dev/null @@ -1,65 +0,0 @@ -############################################################################## -# Copyright (c) 2016 Max Breitenfeldt and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - - -import django.forms as forms - -from booking.models import Installer, Scenario, Opsys -from datetime import datetime - -class BookingForm(forms.Form): - fields = ['start', 'end', 'purpose', 'opsys', 'reset', 'installer', 'scenario'] - - start = forms.DateTimeField() - end = forms.DateTimeField() - reset = forms.ChoiceField(choices = ((True, 'Yes'),(False, 'No')), label="Reset System", initial='False', required=False) - purpose = forms.CharField(max_length=300) - opsys = forms.ModelChoiceField(queryset=Opsys.objects.all(), required=False) - opsys.label = "Operating System" - installer = forms.ModelChoiceField(queryset=Installer.objects.all(), required=False) - scenario = forms.ModelChoiceField(queryset=Scenario.objects.all(), required=False) - -class BookingEditForm(forms.Form): - fields = ['start', 'end', 'purpose', 'opsys', 'reset', 'installer', 'scenario'] - - start = forms.DateTimeField() - end = forms.DateTimeField() - purpose = forms.CharField(max_length=300) - opsys = forms.ModelChoiceField(queryset=Opsys.objects.all(), required=False) - installer = forms.ModelChoiceField(queryset=Installer.objects.all(), required=False) - scenario = forms.ModelChoiceField(queryset=Scenario.objects.all(), required=False) - reset = forms.ChoiceField(choices = ((True, 'Yes'),(False, 'No')), label="Reset System", initial='False', required=True) - - - def __init__(self, *args, **kwargs ): - cloned_kwargs = {} - cloned_kwargs['purpose'] = kwargs.pop('purpose') - cloned_kwargs['start'] = kwargs.pop('start') - cloned_kwargs['end'] = kwargs.pop('end') - if 'installer' in kwargs: - cloned_kwargs['installer'] = kwargs.pop('installer') - if 'scenario' in kwargs: - cloned_kwargs['scenario'] = kwargs.pop('scenario') - super(BookingEditForm, self).__init__( *args, **kwargs) - - self.fields['purpose'].initial = cloned_kwargs['purpose'] - self.fields['start'].initial = cloned_kwargs['start'].strftime('%m/%d/%Y %H:%M') - self.fields['end'].initial = cloned_kwargs['end'].strftime('%m/%d/%Y %H:%M') - try: - self.fields['installer'].initial = cloned_kwargs['installer'].id - except KeyError: - pass - except AttributeError: - pass - try: - self.fields['scenario'].initial = cloned_kwargs['scenario'].id - except KeyError: - pass - except AttributeError: - pass diff --git a/dashboard/src/booking/migrations/0001_initial.py b/dashboard/src/booking/migrations/0001_initial.py index 6932dae..20415fe 100644 --- a/dashboard/src/booking/migrations/0001_initial.py +++ b/dashboard/src/booking/migrations/0001_initial.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10 on 2016-11-03 13:33 -from __future__ import unicode_literals +# Generated by Django 2.1 on 2018-09-14 14:48 from django.conf import settings from django.db import migrations, models @@ -12,8 +10,9 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('dashboard', '0001_initial'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('account', '0001_initial'), + ('resource_inventory', '__first__'), ] operations = [ @@ -23,9 +22,17 @@ class Migration(migrations.Migration): ('id', models.AutoField(primary_key=True, serialize=False)), ('start', models.DateTimeField()), ('end', models.DateTimeField()), - ('jira_issue_id', models.IntegerField(null=True)), - ('jira_issue_status', models.CharField(max_length=50)), + ('reset', models.BooleanField(default=False)), + ('jira_issue_id', models.IntegerField(blank=True, null=True)), + ('jira_issue_status', models.CharField(blank=True, max_length=50)), ('purpose', models.CharField(max_length=300)), + ('ext_count', models.IntegerField(default=2)), + ('project', models.CharField(blank=True, default='', max_length=100, null=True)), + ('collaborators', models.ManyToManyField(related_name='collaborators', to=settings.AUTH_USER_MODEL)), + ('config_bundle', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='resource_inventory.ConfigBundle')), + ('lab', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='account.Lab')), + ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='owner', to=settings.AUTH_USER_MODEL)), + ('resource', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='resource_inventory.ResourceBundle')), ], options={ 'db_table': 'booking', @@ -38,6 +45,14 @@ class Migration(migrations.Migration): ('name', models.CharField(max_length=30)), ], ), + migrations.CreateModel( + name='Opsys', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('name', models.CharField(max_length=100)), + ('sup_installers', models.ManyToManyField(blank=True, to='booking.Installer')), + ], + ), migrations.CreateModel( name='Scenario', fields=[ @@ -46,23 +61,8 @@ class Migration(migrations.Migration): ], ), migrations.AddField( - model_name='booking', - name='installer', - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='booking.Installer'), - ), - migrations.AddField( - model_name='booking', - name='resource', - field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='dashboard.Resource'), - ), - migrations.AddField( - model_name='booking', - name='scenario', - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='booking.Scenario'), - ), - migrations.AddField( - model_name='booking', - name='user', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), + model_name='installer', + name='sup_scenarios', + field=models.ManyToManyField(blank=True, to='booking.Scenario'), ), ] diff --git a/dashboard/src/booking/migrations/0002_booking_changeid.py b/dashboard/src/booking/migrations/0002_booking_changeid.py deleted file mode 100644 index 33af8fd..0000000 --- a/dashboard/src/booking/migrations/0002_booking_changeid.py +++ /dev/null @@ -1,38 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10 on 2017-12-13 15:06 -from __future__ import unicode_literals - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('booking', '0001_initial'), - ] - - operations = [ - migrations.CreateModel( - name='Opsys', - fields=[ - ('id', models.AutoField(primary_key=True, serialize=False)), - ('name', models.CharField(max_length=100)), - ], - ), - migrations.AddField( - model_name='booking', - name='opsys', - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='booking.Opsys'), - ), - migrations.AddField( - model_name='booking', - name='changeid', - field=models.TextField(default='no change ID'), - ), - migrations.AlterField( - model_name='booking', - name='changeid', - field=models.TextField(blank=True, default='no change ID', null=True), - ), - ] diff --git a/dashboard/src/booking/migrations/0003_auto_20180108_2024.py b/dashboard/src/booking/migrations/0003_auto_20180108_2024.py deleted file mode 100644 index 93cecc2..0000000 --- a/dashboard/src/booking/migrations/0003_auto_20180108_2024.py +++ /dev/null @@ -1,25 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10 on 2018-01-08 20:24 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('booking', '0002_booking_changeid'), - ] - - operations = [ - migrations.AddField( - model_name='booking', - name='reset', - field=models.BooleanField(default=False), - ), - migrations.AlterField( - model_name='booking', - name='changeid', - field=models.TextField(blank=True, default='initial', null=True), - ), - ] \ No newline at end of file diff --git a/dashboard/src/booking/migrations/0004_booking_ext_count.py b/dashboard/src/booking/migrations/0004_booking_ext_count.py deleted file mode 100644 index 6bcc3ce..0000000 --- a/dashboard/src/booking/migrations/0004_booking_ext_count.py +++ /dev/null @@ -1,27 +0,0 @@ -############################################################################## -# Copyright (c) 2018 Sawyer Bergeron and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('booking', '0003_auto_20180108_2024'), - ] - - operations = [ - migrations.AddField( - model_name='booking', - name='ext_count', - field=models.IntegerField(default=2), - ), - ] diff --git a/dashboard/src/booking/migrations/__init__.py b/dashboard/src/booking/migrations/__init__.py index b5914ce..e69de29 100644 --- a/dashboard/src/booking/migrations/__init__.py +++ b/dashboard/src/booking/migrations/__init__.py @@ -1,10 +0,0 @@ -############################################################################## -# Copyright (c) 2016 Max Breitenfeldt and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - - diff --git a/dashboard/src/booking/models.py b/dashboard/src/booking/models.py index 8762d46..adfc28d 100644 --- a/dashboard/src/booking/models.py +++ b/dashboard/src/booking/models.py @@ -1,5 +1,6 @@ ############################################################################## # Copyright (c) 2016 Max Breitenfeldt and others. +# Copyright (c) 2018 Sawyer Bergeron, Parker Berberian, and others. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 @@ -8,67 +9,61 @@ ############################################################################## +from resource_inventory.models import ResourceBundle, ConfigBundle +from account.models import Lab from django.conf import settings from django.contrib.auth.models import User from django.db import models from jira import JIRA from jira import JIRAError -from django.utils.crypto import get_random_string -import hashlib +import resource_inventory.resource_manager -from dashboard.models import Resource - -class Installer(models.Model): +class Scenario(models.Model): id = models.AutoField(primary_key=True) - name = models.CharField(max_length=30) + name = models.CharField(max_length=300) def __str__(self): return self.name -class Scenario(models.Model): + +class Installer(models.Model): id = models.AutoField(primary_key=True) - name = models.CharField(max_length=300) + name = models.CharField(max_length=30) + sup_scenarios = models.ManyToManyField(Scenario, blank=True) def __str__(self): return self.name + class Opsys(models.Model): id = models.AutoField(primary_key=True) name = models.CharField(max_length=100) + sup_installers = models.ManyToManyField(Installer, blank=True) def __str__(self): return self.name + class Booking(models.Model): id = models.AutoField(primary_key=True) - changeid = models.TextField(default='initial', blank=True, null=True) - user = models.ForeignKey(User, models.CASCADE) # delete if user is deleted - resource = models.ForeignKey(Resource, models.PROTECT) + owner = models.ForeignKey(User, models.CASCADE, related_name='owner') # delete if user is deleted + collaborators = models.ManyToManyField(User, related_name='collaborators') start = models.DateTimeField() end = models.DateTimeField() reset = models.BooleanField(default=False) - jira_issue_id = models.IntegerField(null=True) - jira_issue_status = models.CharField(max_length=50) - - opsys = models.ForeignKey(Opsys, models.DO_NOTHING, null=True) - installer = models.ForeignKey(Installer, models.DO_NOTHING, null=True) - scenario = models.ForeignKey(Scenario, models.DO_NOTHING, null=True) + jira_issue_id = models.IntegerField(null=True, blank=True) + jira_issue_status = models.CharField(max_length=50, blank=True) purpose = models.CharField(max_length=300, blank=False) ext_count = models.IntegerField(default=2) + resource = models.ForeignKey(ResourceBundle, on_delete=models.SET_NULL, null=True) #need to decide behavior here on delete + config_bundle = models.ForeignKey(ConfigBundle, on_delete=models.SET_NULL, null=True) + project = models.CharField(max_length=100, default="", blank=True, null=True) + lab = models.ForeignKey(Lab, null=True, on_delete=models.SET_NULL) class Meta: db_table = 'booking' - def get_jira_issue(self): - try: - jira = JIRA(server=settings.JIRA_URL, - basic_auth=(settings.JIRA_USER_NAME, settings.JIRA_USER_PASSWORD)) - issue = jira.issue(self.jira_issue_id) - return issue - except JIRAError: - return None - def save(self, *args, **kwargs): """ Save the booking if self.user is authorized and there is no overlapping booking. @@ -83,11 +78,14 @@ class Booking(models.Model): conflicting_dates = conflicting_dates.filter(start__lt=self.end) if conflicting_dates.count() > 0: raise ValueError('This booking overlaps with another booking') - if not self.changeid: - self.changeid = self.id - else: - self.changeid = hashlib.md5(self.changeid.encode() + get_random_string(length=32).encode()).hexdigest() return super(Booking, self).save(*args, **kwargs) + def delete(self, *args, **kwargs): + res = self.resource + self.resource = None + self.save() + resource_inventory.resource_manager.ResourceManager.getInstance().deleteResourceBundle(res) + return super(self.__class__, self).delete(*args, **kwargs) + def __str__(self): - return str(self.resource) + ' from ' + str(self.start) + ' until ' + str(self.end) + return str(self.purpose) + ' from ' + str(self.start) + ' until ' + str(self.end) diff --git a/dashboard/src/booking/stats.py b/dashboard/src/booking/stats.py new file mode 100644 index 0000000..31f7ef1 --- /dev/null +++ b/dashboard/src/booking/stats.py @@ -0,0 +1,56 @@ +############################################################################## +# Copyright (c) 2018 Parker Berberian, Sawyer Bergeron, and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +from booking.models import Booking +import datetime +import pytz + + +class StatisticsManager(object): + + @staticmethod + def getContinuousBookingTimeSeries(span=28): + """ + Will return a dictionary of names and 2-D array of x and y data points. + e.g. {"plot1": [["x1", "x2", "x3"],["y1", "y2", "y3]]} + x values will be dates in string + every change (booking start / end) will be reflected, instead of one data point per day + y values are the integer number of bookings/users active at some point in the given date + span is the number of days to plot. The last x value will always be the current time + """ + x_set = set() + x = [] + y = [] + users = [] + now = datetime.datetime.now(pytz.utc) + delta = datetime.timedelta(days=span) + end = now-delta + bookings = Booking.objects.filter(start__lte=now, end__gte=end) + for booking in bookings: + x_set.add(booking.start) + if booking.end < now: + x_set.add(booking.end) + + x_set.add(now) + x_set.add(end) + + x_list = list(x_set) + x_list.sort(reverse=True) + for time in x_list: + x.append(str(time)) + active = Booking.objects.filter(start__lte=time, end__gt=time) + booking_count = len(active) + users_set = set() + for booking in active: + users_set.add(booking.owner) + for user in booking.collaborators.all(): + users_set.add(user) + y.append(booking_count) + users.append(len(users_set)) + + return {"booking": [x, y], "user": [x, users]} diff --git a/dashboard/src/booking/tests/__init__.py b/dashboard/src/booking/tests/__init__.py index b5914ce..b6fef6c 100644 --- a/dashboard/src/booking/tests/__init__.py +++ b/dashboard/src/booking/tests/__init__.py @@ -6,5 +6,3 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## - - diff --git a/dashboard/src/booking/tests/test_models.py b/dashboard/src/booking/tests/test_models.py index b4cd113..a83f817 100644 --- a/dashboard/src/booking/tests/test_models.py +++ b/dashboard/src/booking/tests/test_models.py @@ -1,5 +1,6 @@ ############################################################################## # Copyright (c) 2016 Max Breitenfeldt and others. +# Copyright (c) 2018 Parker Berberian, Sawyer Bergeron, and others. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 @@ -15,29 +16,28 @@ from django.test import TestCase from django.utils import timezone from booking.models import * -from dashboard.models import Resource -from jenkins.models import JenkinsSlave - +from resource_inventory.models import ResourceBundle, GenericResourceBundle, ConfigBundle class BookingModelTestCase(TestCase): + count = 0 def setUp(self): - self.slave = JenkinsSlave.objects.create(name='test', url='test') self.owner = User.objects.create(username='owner') - self.res1 = Resource.objects.create(name='res1', slave=self.slave, description='x', - url='x',owner=self.owner) - self.res2 = Resource.objects.create(name='res2', slave=self.slave, description='x', - url='x',owner=self.owner) - + self.res1 = ResourceBundle.objects.create( + template=GenericResourceBundle.objects.create(name="gbundle" + str(self.count)) + ) + self.count += 1 + self.res2 = ResourceBundle.objects.create( + template=GenericResourceBundle.objects.create(name="gbundle2" + str(self.count)) + ) + self.count += 1 self.user1 = User.objects.create(username='user1') self.add_booking_perm = Permission.objects.get(codename='add_booking') self.user1.user_permissions.add(self.add_booking_perm) self.user1 = User.objects.get(pk=self.user1.id) - - self.installer = Installer.objects.create(name='TestInstaller') - self.scenario = Scenario.objects.create(name='TestScenario') + self.config_bundle = ConfigBundle.objects.create(owner=self.user1, name="test config") def test_start_end(self): """ @@ -46,11 +46,25 @@ class BookingModelTestCase(TestCase): """ start = timezone.now() end = start - timedelta(weeks=1) - self.assertRaises(ValueError, Booking.objects.create, start=start, end=end, - resource=self.res1, user=self.user1) + self.assertRaises( + ValueError, + Booking.objects.create, + start=start, + end=end, + resource=self.res1, + owner=self.user1, + config_bundle=self.config_bundle + ) end = start - self.assertRaises(ValueError, Booking.objects.create, start=start, end=end, - resource=self.res1, user=self.user1) + self.assertRaises( + ValueError, + Booking.objects.create, + start=start, + end=end, + resource=self.res1, + owner=self.user1, + config_bundle=self.config_bundle + ) def test_conflicts(self): """ @@ -60,35 +74,153 @@ class BookingModelTestCase(TestCase): start = timezone.now() end = start + timedelta(weeks=1) self.assertTrue( - Booking.objects.create(start=start, end=end, user=self.user1, resource=self.res1)) - - self.assertRaises(ValueError, Booking.objects.create, start=start, - end=end, resource=self.res1, user=self.user1) - self.assertRaises(ValueError, Booking.objects.create, start=start + timedelta(days=1), - end=end - timedelta(days=1), resource=self.res1, user=self.user1) + Booking.objects.create( + start=start, + end=end, + owner=self.user1, + resource=self.res1, + config_bundle=self.config_bundle + ) + ) + + self.assertRaises( + ValueError, + Booking.objects.create, + start=start, + end=end, + resource=self.res1, + owner=self.user1, + config_bundle=self.config_bundle + ) + self.assertRaises( + ValueError, + Booking.objects.create, + start=start + timedelta(days=1), + end=end - timedelta(days=1), + resource=self.res1, + owner=self.user1, + config_bundle=self.config_bundle + ) + + self.assertRaises( + ValueError, + Booking.objects.create, + start=start - timedelta(days=1), + end=end, + resource=self.res1, + owner=self.user1, + config_bundle=self.config_bundle + ) + + self.assertRaises( + ValueError, + Booking.objects.create, + start=start - timedelta(days=1), + end=end - timedelta(days=1), + resource=self.res1, + owner=self.user1, + config_bundle=self.config_bundle + ) + + self.assertRaises( + ValueError, + Booking.objects.create, + start=start, + end=end + timedelta(days=1), + resource=self.res1, + owner=self.user1, + config_bundle=self.config_bundle + ) + + self.assertRaises( + ValueError, + Booking.objects.create, + start=start + timedelta(days=1), + end=end + timedelta(days=1), + resource=self.res1, + owner=self.user1, + config_bundle=self.config_bundle + ) - self.assertRaises(ValueError, Booking.objects.create, start=start - timedelta(days=1), - end=end, resource=self.res1, user=self.user1) - self.assertRaises(ValueError, Booking.objects.create, start=start - timedelta(days=1), - end=end - timedelta(days=1), resource=self.res1, user=self.user1) - - self.assertRaises(ValueError, Booking.objects.create, start=start, - end=end + timedelta(days=1), resource=self.res1, user=self.user1) - self.assertRaises(ValueError, Booking.objects.create, start=start + timedelta(days=1), - end=end + timedelta(days=1), resource=self.res1, user=self.user1) + self.assertTrue( + Booking.objects.create( + start=start - timedelta(days=1), + end=start, + owner=self.user1, + resource=self.res1, + config_bundle=self.config_bundle + ) + ) + self.assertTrue( + Booking.objects.create( + start=end, + end=end + timedelta(days=1), + owner=self.user1, + resource=self.res1, + config_bundle=self.config_bundle + ) + ) - self.assertTrue(Booking.objects.create(start=start - timedelta(days=1), end=start, - user=self.user1, resource=self.res1)) - self.assertTrue(Booking.objects.create(start=end, end=end + timedelta(days=1), - user=self.user1, resource=self.res1)) + self.assertTrue( + Booking.objects.create( + start=start - timedelta(days=2), + end=start - timedelta(days=1), + owner=self.user1, + resource=self.res1, + config_bundle=self.config_bundle + ) + ) self.assertTrue( - Booking.objects.create(start=start - timedelta(days=2), end=start - timedelta(days=1), - user=self.user1, resource=self.res1)) + Booking.objects.create( + start=end + timedelta(days=1), + end=end + timedelta(days=2), + owner=self.user1, + resource=self.res1, + config_bundle=self.config_bundle + ) + ) + self.assertTrue( - Booking.objects.create(start=end + timedelta(days=1), end=end + timedelta(days=2), - user=self.user1, resource=self.res1)) + Booking.objects.create( + start=start, + end=end, + owner=self.user1, + resource=self.res2, + config_bundle=self.config_bundle + ) + ) + + def test_extensions(self): + """ + saving a booking with an extended end time is allows to happen twice, + and each extension must be a maximum of one week long + """ + start = timezone.now() + end = start + timedelta(weeks=1) self.assertTrue( - Booking.objects.create(start=start, end=end, - user=self.user1, resource=self.res2, scenario=self.scenario, - installer=self.installer)) \ No newline at end of file + Booking.objects.create( + start=start, + end=end, + owner=self.user1, + resource=self.res1, + config_bundle=self.config_bundle + ) + ) + + booking = Booking.objects.all().first() # should be only thing in db + + self.assertEquals(booking.ext_count, 2) + booking.end = booking.end + timedelta(days=3) + try: + booking.save() + except Exception: + self.fail("save() threw an exception") + booking.end = booking.end + timedelta(weeks=2) + self.assertRaises(ValueError, booking.save) + booking.end = booking.end - timedelta(days=8) + try: + self.assertTrue(booking.save()) + except Exception: + self.fail("save() threw an exception") + diff --git a/dashboard/src/booking/tests/test_views.py b/dashboard/src/booking/tests/test_views.py deleted file mode 100644 index c1da013..0000000 --- a/dashboard/src/booking/tests/test_views.py +++ /dev/null @@ -1,106 +0,0 @@ -############################################################################## -# Copyright (c) 2016 Max Breitenfeldt and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - - -from datetime import timedelta - -from django.test import Client -from django.test import TestCase -from django.urls import reverse -from django.utils import timezone -from django.utils.encoding import force_text -from registration.forms import User - -from account.models import UserProfile -from booking.models import Booking -from dashboard.models import Resource -from jenkins.models import JenkinsSlave - - -class BookingViewTestCase(TestCase): - def setUp(self): - self.client = Client() - self.slave = JenkinsSlave.objects.create(name='test', url='test') - self.owner = User.objects.create(username='owner') - self.res1 = Resource.objects.create(name='res1', slave=self.slave, description='x', - url='x',owner=self.owner) - self.user1 = User.objects.create(username='user1') - self.user1.set_password('user1') - self.user1profile = UserProfile.objects.create(user=self.user1) - self.user1.save() - - self.user1 = User.objects.get(pk=self.user1.id) - - - def test_resource_bookings_json(self): - url = reverse('booking:bookings_json', kwargs={'resource_id': 0}) - self.assertEqual(self.client.get(url).status_code, 404) - - url = reverse('booking:bookings_json', kwargs={'resource_id': self.res1.id}) - response = self.client.get(url) - self.assertEqual(response.status_code, 200) - self.assertJSONEqual(force_text(response.content), {"bookings": []}) - booking1 = Booking.objects.create(start=timezone.now(), - end=timezone.now() + timedelta(weeks=1), user=self.user1, - resource=self.res1) - response = self.client.get(url) - json = response.json() - self.assertEqual(response.status_code, 200) - self.assertIn('bookings', json) - self.assertEqual(len(json['bookings']), 1) - self.assertIn('start', json['bookings'][0]) - self.assertIn('end', json['bookings'][0]) - self.assertIn('id', json['bookings'][0]) - self.assertIn('purpose', json['bookings'][0]) - - def test_booking_form_view(self): - url = reverse('booking:create', kwargs={'resource_id': 0}) - self.assertEqual(self.client.get(url).status_code, 404) - - # authenticated user - url = reverse('booking:create', kwargs={'resource_id': self.res1.id}) - self.client.login(username='user1',password='user1') - response = self.client.get(url) - self.assertEqual(response.status_code, 200) - self.assertTemplateUsed('booking/booking_calendar.html') - self.assertTemplateUsed('booking/booking_form.html') - self.assertIn('resource', response.context) - - - def test_booking_view(self): - start = timezone.now() - end = start + timedelta(weeks=1) - booking = Booking.objects.create(start=start, end=end, user=self.user1, resource=self.res1) - - url = reverse('booking:detail', kwargs={'booking_id':0}) - response = self.client.get(url) - self.assertEqual(response.status_code, 404) - - url = reverse('booking:detail', kwargs={'booking_id':booking.id}) - response = self.client.get(url) - self.assertEqual(response.status_code, 200) - self.assertTemplateUsed('booking/booking_detail.html') - self.assertIn('booking', response.context) - - def test_booking_list_view(self): - start = timezone.now() - timedelta(weeks=2) - end = start + timedelta(weeks=1) - Booking.objects.create(start=start, end=end, user=self.user1, resource=self.res1) - - url = reverse('booking:list') - response = self.client.get(url) - self.assertEqual(response.status_code, 200) - self.assertTemplateUsed('booking/booking_list.html') - self.assertTrue(len(response.context['bookings']) == 0) - - start = timezone.now() - end = start + timedelta(weeks=1) - Booking.objects.create(start=start, end=end, user=self.user1, resource=self.res1) - response = self.client.get(url) - self.assertTrue(len(response.context['bookings']) == 1) \ No newline at end of file diff --git a/dashboard/src/booking/urls.py b/dashboard/src/booking/urls.py index ed3b1d4..88fbb0a 100644 --- a/dashboard/src/booking/urls.py +++ b/dashboard/src/booking/urls.py @@ -1,5 +1,6 @@ ############################################################################## # Copyright (c) 2016 Max Breitenfeldt and others. +# Copyright (c) 2018 Parker Berberian, Sawyer Bergeron, and others. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 @@ -27,20 +28,19 @@ from django.conf.urls import url from booking.views import * +app_name = "booking" urlpatterns = [ - url(r'^(?P[0-9]+)/$', BookingFormView.as_view(), name='create'), - url(r'^(?P[0-9]+)/edit/(?P[0-9]+)/$', BookingEditFormView.as_view(), name='edit'), - url(r'^(?P[0-9]+)/bookings_json/$', ResourceBookingsJSON.as_view(), - name='bookings_json'), - url(r'^detail/$', BookingView.as_view(), name='detail_prefix'), - url(r'^detail/(?P[0-9]+)/$', BookingView.as_view(), name='detail'), + url(r'^detail/(?P[0-9]+)/$', booking_detail_view, name='detail'), + url(r'^(?P[0-9]+)/$', booking_detail_view, name='booking_detail'), url(r'^delete/$', BookingDeleteView.as_view(), name='delete_prefix'), url(r'^delete/(?P[0-9]+)/$', BookingDeleteView.as_view(), name='delete'), url(r'^delete/(?P[0-9]+)/confirm/$', bookingDelete, name='delete_booking'), - url(r'^list/$', BookingListView.as_view(), name='list') -] \ No newline at end of file + url(r'^list/$', BookingListView.as_view(), name='list'), + url(r'^stats/$', booking_stats_view, name='stats'), + url(r'^stats/json$', booking_stats_json, name='stats_json'), +] diff --git a/dashboard/src/booking/views.py b/dashboard/src/booking/views.py index a52cfe2..c139b4c 100644 --- a/dashboard/src/booking/views.py +++ b/dashboard/src/booking/views.py @@ -1,5 +1,6 @@ ############################################################################## # Copyright (c) 2016 Max Breitenfeldt and others. +# Copyright (c) 2018 Parker Berberian, Sawyer Bergeron, and others. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 @@ -7,39 +8,38 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -from django.conf import settings from django.contrib import messages -from django.contrib.auth.mixins import LoginRequiredMixin -from django.http import JsonResponse from django.shortcuts import get_object_or_404 +from django.http import JsonResponse from django.urls import reverse from django.utils import timezone from django.views import View from django.views.generic import FormView from django.views.generic import TemplateView -from jira import JIRAError -from django.shortcuts import redirect +from django.shortcuts import redirect, render +import json -from account.jira_util import get_jira from booking.forms import BookingForm, BookingEditForm -from booking.models import Booking -from dashboard.models import Resource - -def create_jira_ticket(user, booking): - jira = get_jira(user) - issue_dict = { - 'project': 'PHAROS', - 'summary': str(booking.resource) + ': Access Request', - 'description': booking.purpose, - 'issuetype': {'name': 'Task'}, - 'components': [{'name': 'POD Access Request'}], - 'assignee': {'name': booking.resource.owner.username} - } - issue = jira.create_issue(fields=issue_dict) - jira.add_attachment(issue, user.userprofile.pgp_public_key) - jira.add_attachment(issue, user.userprofile.ssh_public_key) - booking.jira_issue_id = issue.id - booking.save() +from resource_inventory.models import ResourceBundle +from resource_inventory.resource_manager import ResourceManager +from booking.models import Booking, Installer, Opsys +from booking.stats import StatisticsManager + + +def drop_filter(context): + installer_filter = {} + for os in Opsys.objects.all(): + installer_filter[os.id] = [] + for installer in os.sup_installers.all(): + installer_filter[os.id].append(installer.id) + + scenario_filter = {} + for installer in Installer.objects.all(): + scenario_filter[installer.id] = [] + for scenario in installer.sup_scenarios.all(): + scenario_filter[installer.id].append(scenario.id) + + context.update({'installer_filter': json.dumps(installer_filter), 'scenario_filter': json.dumps(scenario_filter)}) class BookingFormView(FormView): @@ -47,14 +47,16 @@ class BookingFormView(FormView): form_class = BookingForm def dispatch(self, request, *args, **kwargs): - self.resource = get_object_or_404(Resource, id=self.kwargs['resource_id']) + self.resource = get_object_or_404(ResourceBundle, id=self.kwargs['resource_id']) return super(BookingFormView, self).dispatch(request, *args, **kwargs) def get_context_data(self, **kwargs): - title = 'Booking: ' + self.resource.name + title = 'Booking: ' + str(self.resource.id) context = super(BookingFormView, self).get_context_data(**kwargs) context.update({'title': title, 'resource': self.resource}) - #raise PermissionDenied('check') + + drop_filter(context) + return context def get_success_url(self): @@ -75,24 +77,16 @@ class BookingFormView(FormView): booking = Booking(start=form.cleaned_data['start'], end=form.cleaned_data['end'], purpose=form.cleaned_data['purpose'], - opsys=form.cleaned_data['opsys'], installer=form.cleaned_data['installer'], scenario=form.cleaned_data['scenario'], - resource=self.resource, user=user) + resource=self.resource, + owner=user + ) try: booking.save() except ValueError as err: messages.add_message(self.request, messages.ERROR, err) return super(BookingFormView, self).form_invalid(form) - try: - if settings.CREATE_JIRA_TICKET: - create_jira_ticket(user, booking) - except JIRAError: - messages.add_message(self.request, messages.ERROR, 'Failed to create Jira Ticket. ' - 'Please check your Jira ' - 'permissions.') - booking.delete() - return super(BookingFormView, self).form_invalid(form) messages.add_message(self.request, messages.SUCCESS, 'Booking saved') return super(BookingFormView, self).form_valid(form) @@ -105,7 +99,7 @@ class BookingEditFormView(FormView): return True def dispatch(self, request, *args, **kwargs): - self.resource = get_object_or_404(Resource, id=self.kwargs['resource_id']) + self.resource = get_object_or_404(ResourceBundle, id=self.kwargs['resource_id']) self.original_booking = get_object_or_404(Booking, id=self.kwargs['booking_id']) return super(BookingEditFormView, self).dispatch(request, *args, **kwargs) @@ -113,6 +107,9 @@ class BookingEditFormView(FormView): title = 'Editing Booking on: ' + self.resource.name context = super(BookingEditFormView, self).get_context_data(**kwargs) context.update({'title': title, 'resource': self.resource, 'booking': self.original_booking}) + + drop_filter(context) + return context def get_form_kwargs(self): @@ -120,14 +117,6 @@ class BookingEditFormView(FormView): kwargs['purpose'] = self.original_booking.purpose kwargs['start'] = self.original_booking.start kwargs['end'] = self.original_booking.end - try: - kwargs['installer'] = self.original_booking.installer - except AttributeError: - pass - try: - kwargs['scenario'] = self.original_booking.scenario - except AttributeError: - pass return kwargs def get_success_url(self): @@ -145,7 +134,7 @@ class BookingEditFormView(FormView): 'You are not the owner of this booking.') return super(BookingEditFormView, self).form_invalid(form) - #Do Conflict Checks + # Do Conflict Checks if self.original_booking.end != form.cleaned_data['end']: if form.cleaned_data['end'] - self.original_booking.end > timezone.timedelta(days=7): messages.add_message(self.request, messages.ERROR, @@ -176,13 +165,12 @@ class BookingEditFormView(FormView): messages.add_message(self.request, messages.ERROR, err) return super(BookingEditFormView, self).form_invalid(form) - user = self.request.user return super(BookingEditFormView, self).form_valid(form) + class BookingView(TemplateView): template_name = "booking/booking_detail.html" - def get_context_data(self, **kwargs): booking = get_object_or_404(Booking, id=self.kwargs['booking_id']) title = 'Booking Details' @@ -190,6 +178,7 @@ class BookingView(TemplateView): context.update({'title': title, 'booking': booking}) return context + class BookingDeleteView(TemplateView): template_name = "booking/booking_delete.html" @@ -200,12 +189,14 @@ class BookingDeleteView(TemplateView): context.update({'title': title, 'booking': booking}) return context + def bookingDelete(request, booking_id): booking = get_object_or_404(Booking, id=booking_id) booking.delete() messages.add_message(request, messages.SUCCESS, 'Booking deleted') return redirect('../../../../') + class BookingListView(TemplateView): template_name = "booking/booking_list.html" @@ -219,8 +210,47 @@ class BookingListView(TemplateView): class ResourceBookingsJSON(View): def get(self, request, *args, **kwargs): - resource = get_object_or_404(Resource, id=self.kwargs['resource_id']) - bookings = resource.booking_set.get_queryset().values('id', 'start', 'end', 'purpose', - 'jira_issue_status', 'opsys__name', - 'installer__name', 'scenario__name') + resource = get_object_or_404(ResourceBundle, id=self.kwargs['resource_id']) + bookings = resource.booking_set.get_queryset().values( + 'id', + 'start', + 'end', + 'purpose', + 'jira_issue_status', + 'config_bundle__name' + ) return JsonResponse({'bookings': list(bookings)}) + + +def booking_detail_view(request, booking_id): + user = None + if request.user.is_authenticated: + user = request.user + else: + return render(request, "dashboard/login.html", {'title': 'Authentication Required'}) + + booking = get_object_or_404(Booking, id=booking_id) + return render(request, "booking/booking_detail.html", { + 'title': 'Booking Details', + 'booking': booking, + 'pdf': ResourceManager().makePDF(booking.resource), + 'user_id': user.id}) + + +def booking_stats_view(request): + return render( + request, + "booking/stats.html", + context={ + "data": StatisticsManager.getContinuousBookingTimeSeries(), + "title": "Booking Statistics" + } + ) + + +def booking_stats_json(request): + try: + span = int(request.GET.get("days", 14)) + except: + span = 14 + return JsonResponse(StatisticsManager.getContinuousBookingTimeSeries(span), safe=False) diff --git a/dashboard/src/dashboard/__init__.py b/dashboard/src/dashboard/__init__.py index b5914ce..b6fef6c 100644 --- a/dashboard/src/dashboard/__init__.py +++ b/dashboard/src/dashboard/__init__.py @@ -6,5 +6,3 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## - - diff --git a/dashboard/src/dashboard/admin.py b/dashboard/src/dashboard/admin.py index 0bfdef8..43b5386 100644 --- a/dashboard/src/dashboard/admin.py +++ b/dashboard/src/dashboard/admin.py @@ -1,5 +1,6 @@ ############################################################################## # Copyright (c) 2016 Max Breitenfeldt and others. +# Copyright (c) 2018 Sawyer Bergeron, Parker Berberian, and others. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 @@ -10,11 +11,6 @@ from django.contrib import admin -from dashboard.models import * admin.site.site_header = "Pharos Dashboard Administration" admin.site.site_title = "Pharos Dashboard" - -admin.site.register(Resource) -admin.site.register(Server) -admin.site.register(ResourceStatus) diff --git a/dashboard/src/dashboard/context_processors.py b/dashboard/src/dashboard/context_processors.py new file mode 100644 index 0000000..32c70b8 --- /dev/null +++ b/dashboard/src/dashboard/context_processors.py @@ -0,0 +1,12 @@ +############################################################################## +# Copyright (c) 2018 Sawyer Bergeron, Parker Berberian, and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +from django.conf import settings + +def debug(context): + return {'DEBUG': settings.DEBUG} diff --git a/dashboard/src/dashboard/exceptions.py b/dashboard/src/dashboard/exceptions.py new file mode 100644 index 0000000..bc3fcac --- /dev/null +++ b/dashboard/src/dashboard/exceptions.py @@ -0,0 +1,46 @@ +############################################################################## +# Copyright (c) 2018 Parker Berberian, Sawyer Bergeron, and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +class ResourceProvisioningException(Exception): + """ + Resources could not be provisioned + """ + pass + +class ModelValidationException(Exception): + """ + Validation before saving model returned issues + """ + pass + +class ResourceAvailabilityException(ResourceProvisioningException): + """ + Requested resources are not *currently* available + """ + pass + +class ResourceExistenceException(ResourceAvailabilityException): + """ + Requested resources do not exist or do not match any known resources + """ + pass + + +class NonUniqueHostnameException(Exception): + pass + +class InvalidHostnameException(Exception): + pass + +class InvalidVlanConfigurationException(Exception): + pass + +class NetworkExistsException(Exception): + pass diff --git a/dashboard/src/dashboard/migrations/0001_initial.py b/dashboard/src/dashboard/migrations/0001_initial.py deleted file mode 100644 index aaf3945..0000000 --- a/dashboard/src/dashboard/migrations/0001_initial.py +++ /dev/null @@ -1,64 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10 on 2016-11-03 13:33 -from __future__ import unicode_literals - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('jenkins', '0001_initial'), - ] - - operations = [ - migrations.CreateModel( - name='Resource', - fields=[ - ('id', models.AutoField(primary_key=True, serialize=False)), - ('name', models.CharField(max_length=100, unique=True)), - ('description', models.CharField(blank=True, max_length=300, null=True)), - ('url', models.CharField(blank=True, max_length=100, null=True)), - ('owner', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='user_lab_owner', to=settings.AUTH_USER_MODEL)), - ('slave', models.ForeignKey(null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='jenkins.JenkinsSlave')), - ('vpn_users', models.ManyToManyField(blank=True, related_name='user_vpn_users', to=settings.AUTH_USER_MODEL)), - ], - options={ - 'db_table': 'resource', - }, - ), - migrations.CreateModel( - name='ResourceStatus', - fields=[ - ('id', models.AutoField(primary_key=True, serialize=False)), - ('timestamp', models.DateTimeField(auto_now_add=True)), - ('type', models.CharField(max_length=20)), - ('title', models.CharField(max_length=50)), - ('content', models.CharField(max_length=5000)), - ('resource', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dashboard.Resource')), - ], - options={ - 'db_table': 'resource_status', - }, - ), - migrations.CreateModel( - name='Server', - fields=[ - ('id', models.AutoField(primary_key=True, serialize=False)), - ('name', models.CharField(blank=True, max_length=100)), - ('model', models.CharField(blank=True, max_length=100)), - ('cpu', models.CharField(blank=True, max_length=100)), - ('ram', models.CharField(blank=True, max_length=100)), - ('storage', models.CharField(blank=True, max_length=100)), - ('resource', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dashboard.Resource')), - ], - options={ - 'db_table': 'server', - }, - ), - ] diff --git a/dashboard/src/dashboard/migrations/0002_auto_20170505_0815.py b/dashboard/src/dashboard/migrations/0002_auto_20170505_0815.py deleted file mode 100644 index 4285b88..0000000 --- a/dashboard/src/dashboard/migrations/0002_auto_20170505_0815.py +++ /dev/null @@ -1,42 +0,0 @@ -############################################################################## -# Copyright (c) 2016 Max Breitenfeldt and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - - -# -*- coding: utf-8 -*- -# Generated by Django 1.10 on 2017-05-05 08:15 -from __future__ import unicode_literals - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('dashboard', '0001_initial'), - ] - - operations = [ - migrations.AddField( - model_name='resource', - name='dev_pod', - field=models.BooleanField(default=False), - ), - migrations.AlterField( - model_name='resource', - name='owner', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='user_lab_owner', to=settings.AUTH_USER_MODEL), - ), - migrations.AlterField( - model_name='resource', - name='slave', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='jenkins.JenkinsSlave'), - ), - ] diff --git a/dashboard/src/dashboard/migrations/0003_resource_resource_lab.py b/dashboard/src/dashboard/migrations/0003_resource_resource_lab.py deleted file mode 100644 index fff93fd..0000000 --- a/dashboard/src/dashboard/migrations/0003_resource_resource_lab.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10 on 2018-01-10 16:36 -from __future__ import unicode_literals - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('account', '0002_auto_20180110_1636'), - ('dashboard', '0002_auto_20170505_0815'), - ] - - operations = [ - migrations.AddField( - model_name='resource', - name='resource_lab', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='lab_resource_set', to='account.Lab'), - ), - ] diff --git a/dashboard/src/dashboard/migrations/__init__.py b/dashboard/src/dashboard/migrations/__init__.py deleted file mode 100644 index b5914ce..0000000 --- a/dashboard/src/dashboard/migrations/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################## -# Copyright (c) 2016 Max Breitenfeldt and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - - diff --git a/dashboard/src/dashboard/models.py b/dashboard/src/dashboard/models.py index ff55232..f9bd07e 100644 --- a/dashboard/src/dashboard/models.py +++ b/dashboard/src/dashboard/models.py @@ -1,97 +1,9 @@ ############################################################################## # Copyright (c) 2016 Max Breitenfeldt and others. +# Copyright (c) 2018 Parker Berberian, Sawyer Bergeron, and others. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## - - -from datetime import timedelta - -from django.contrib.auth.models import User -from django.db import models -from django.utils import timezone - -from jenkins.models import JenkinsSlave -from account.models import Lab - - -class Resource(models.Model): - id = models.AutoField(primary_key=True) - name = models.CharField(max_length=100, unique=True) - description = models.CharField(max_length=300, blank=True, null=True) - url = models.CharField(max_length=100, blank=True, null=True) - resource_lab = models.ForeignKey(Lab, related_name='lab_resource_set', null=True, blank=True) - owner = models.ForeignKey(User, related_name='user_lab_owner', null=True, blank=True) - vpn_users = models.ManyToManyField(User, related_name='user_vpn_users', blank=True) - slave = models.ForeignKey(JenkinsSlave, on_delete=models.DO_NOTHING, null=True, blank=True) - dev_pod = models.BooleanField(default=False) - - def get_booking_utilization(self, weeks): - """ - Return a dictionary containing the count of booked and free seconds for a resource in the - range [now,now + weeks] if weeks is positive, - or [now-weeks, now] if weeks is negative - """ - - length = timedelta(weeks=abs(weeks)) - now = timezone.now() - - start = now - end = now + length - if weeks < 0: - start = now - length - end = now - - bookings = self.booking_set.filter(start__lt=start + length, end__gt=start) - - booked_seconds = 0 - for booking in bookings: - booking_start = booking.start - booking_end = booking.end - if booking_start < start: - booking_start = start - if booking_end > end: - booking_end = start + length - total = booking_end - booking_start - booked_seconds += total.total_seconds() - - return {'booked_seconds': booked_seconds, - 'available_seconds': length.total_seconds() - booked_seconds} - - class Meta: - db_table = 'resource' - - def __str__(self): - return self.name - -class Server(models.Model): - id = models.AutoField(primary_key=True) - resource = models.ForeignKey(Resource, on_delete=models.CASCADE) - name = models.CharField(max_length=100, blank=True) - model = models.CharField(max_length=100, blank=True) - cpu = models.CharField(max_length=100, blank=True) - ram = models.CharField(max_length=100, blank=True) - storage = models.CharField(max_length=100, blank=True) - - class Meta: - db_table = 'server' - - def __str__(self): - return self.name - -class ResourceStatus(models.Model): - id = models.AutoField(primary_key=True) - resource = models.ForeignKey(Resource, on_delete=models.CASCADE) - timestamp = models.DateTimeField(auto_now_add=True) - type = models.CharField(max_length=20) - title = models.CharField(max_length=50) - content = models.CharField(max_length=5000) - - class Meta: - db_table = 'resource_status' - - def __str__(self): - return self.resource.name + ': ' + self.title + ' ' + str(self.timestamp) diff --git a/dashboard/src/dashboard/populate_db_iol.py b/dashboard/src/dashboard/populate_db_iol.py new file mode 100644 index 0000000..8c8b271 --- /dev/null +++ b/dashboard/src/dashboard/populate_db_iol.py @@ -0,0 +1,346 @@ +############################################################################## +# Copyright (c) 2018 Parker Berberian, Sawyer Bergeron, and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +from django.test import TestCase +from booking.models import Booking +from resource_inventory.models import * +from account.models import * +from api.serializers.booking_serializer import * +from datetime import timedelta +from django.utils import timezone +from django.contrib.auth.models import Permission, User +import json +import yaml + + +class Populator: + + def __init__(self): + self.host_profile_count = 0 + self.generic_host_count = 0 + self.host_profiles = [] + self.generic_bundle_count = 0 + self.booking_count = 0 + + + def make_host_profile(self, lab, data): + hostProfile = HostProfile.objects.create( + host_type=data['host']['type'], + name=data['host']['name'], + description=data['host']['description'] + ) + hostProfile.save() + + for iface_data in data['interfaces']: + + interfaceProfile = InterfaceProfile.objects.create( + speed=iface_data['speed'], + name=iface_data['name'], + host=hostProfile + ) + interfaceProfile.save() + + + for disk_data in data['disks']: + + diskProfile = DiskProfile.objects.create( + size=disk_data['size'], + media_type=disk_data['type'], + name=disk_data['name'], + host=hostProfile + ) + diskProfile.save() + + cpuProfile = CpuProfile.objects.create( + cores=data['cpu']['cores'], + architecture=data['cpu']['arch'], + cpus=data['cpu']['cpus'], + host=hostProfile + ) + cpuProfile.save() + ramProfile = RamProfile.objects.create( + amount=data['ram']['amount'], + channels=data['ram']['channels'], + host=hostProfile + ) + ramProfile.save() + hostProfile.labs.add(lab) + return hostProfile + + def make_users(self): + user_pberberian = User.objects.create(username="pberberian") + user_pberberian.save() + user_pberberian_prof = UserProfile.objects.create(user=user_pberberian) + user_pberberian_prof.save() + + user_sbergeron = User.objects.create(username="sbergeron") + user_sbergeron.save() + user_sbergeron_prof = UserProfile.objects.create(user=user_sbergeron) + user_sbergeron_prof.save() + return [user_sbergeron, user_pberberian,] + + + def make_labs(self): + unh_iol = User.objects.create(username="unh_iol") + unh_iol.save() + vlans = [] + reserved = [] + for i in range(1,4096): + vlans.append(1) + reserved.append(0) + # TODO: put reserved vlans here + iol = Lab.objects.create( + lab_user=unh_iol, + name="UNH_IOL", + vlan_manager=VlanManager.objects.create( + vlans = json.dumps(vlans), + reserved_vlans = json.dumps(reserved), + allow_overlapping = False, + block_size = 20, + ), + api_token = Lab.make_api_token(), + contact_email = "nfv-lab@iol.unh.edu", + location = "University of New Hampshire, Durham NH, 03824 USA" + ) + return [iol] + + + def make_configurations(self): + #scenarios + scen1 = Scenario.objects.create(name="os-nosdn-nofeature-noha") + scen2 = Scenario.objects.create(name="os-odl-kvm-ha") + scen3 = Scenario.objects.create(name="os-nosdn-nofeature-ha") + + #installers + fuel = Installer.objects.create(name="Fuel") + fuel.sup_scenarios.add(scen1) + fuel.sup_scenarios.add(scen3) + fuel.save() + joid = Installer.objects.create(name="Joid") + joid.sup_scenarios.add(scen1) + joid.sup_scenarios.add(scen2) + joid.save() + apex = Installer.objects.create(name="Apex") + apex.sup_scenarios.add(scen2) + apex.sup_scenarios.add(scen3) + apex.save() + daisy = Installer.objects.create(name="Daisy") + daisy.sup_scenarios.add(scen1) + daisy.sup_scenarios.add(scen2) + daisy.sup_scenarios.add(scen3) + daisy.save() + compass = Installer.objects.create(name="Compass") + compass.sup_scenarios.add(scen1) + compass.sup_scenarios.add(scen3) + compass.save() + + #operating systems + ubuntu = Opsys.objects.create(name="Ubuntu") + ubuntu.sup_installers.add(compass) + ubuntu.sup_installers.add(joid) + ubuntu.save() + centos = Opsys.objects.create(name="CentOs") + centos.sup_installers.add(apex) + centos.sup_installers.add(fuel) + centos.save() + suse = Opsys.objects.create(name="Suse") + suse.sup_installers.add(fuel) + suse.save() + + + #opnfv roles + compute = OPNFVRole.objects.create(name="Compute", description="Does the heavy lifting") + controller = OPNFVRole.objects.create(name="Controller", description="Controls everything") + jumphost = OPNFVRole.objects.create(name="Jumphost", description="Entry Point") + + lab = Lab.objects.first() + user = UserProfile.objects.first().user + image = Image.objects.create( + lab_id=23, + name="hpe centos", + from_lab=lab, + owner=user, + host_type=HostProfile.objects.get(name="hpe") + ) + image = Image.objects.create( + lab_id=25, + name="hpe ubuntu", + from_lab=lab, + owner=user, + host_type=HostProfile.objects.get(name="hpe") + ) + + image = Image.objects.create( + lab_id=26, + name="hpe suse", + from_lab=lab, + owner=user, + host_type=HostProfile.objects.get(name="hpe") + ) + image = Image.objects.create( + lab_id=27, + name="arm ubuntu", + from_lab=lab, + owner=user, + host_type=HostProfile.objects.get(name="arm") + ) + + def make_lab_hosts(self, hostcount, profile, lab, data, offset=1): + for i in range(hostcount): + name="Host_" + lab.name + "_" + profile.name + "_" + str(i + offset) + host = Host.objects.create( + name=name, + lab=lab, + profile=profile, + labid=data[i]['labid'] + ) + for iface_profile in profile.interfaceprofile.all(): + iface_data = data[i]['interfaces'][iface_profile.name] + Interface.objects.create( + mac_address=iface_data['mac'], + bus_address=iface_data['bus'], + name=iface_profile.name, + host=host + ) + + def make_profile_data(self): + """ + returns a dictionary of data from the yaml files + created by inspection scripts + """ + data = [] + for prof in ["hpe", "arm"]: # TODO + profile_dict = {} + host = { + "name": prof, + "type": 0, + "description": "some LaaS servers" + } + profile_dict['host'] = host + profile_dict['interfaces'] = [] + for interface in [{"name": "eno1", "speed": 1000}, {"name": "eno2", "speed": 10000}]: # TODO + iface_dict = {} + iface_dict["name"] = interface['name'] + iface_dict['speed'] = interface['speed'] + profile_dict['interfaces'].append(iface_dict) + + profile_dict['disks'] = [] + for disk in [{"size": 1000, "type": "ssd", "name": "sda"}]: # TODO + disk_dict = {} + disk_dict['size'] = disk['size'] + disk_dict['type'] = disk['type'] + disk_dict['name'] = disk['name'] + profile_dict['disks'].append(disk_dict) + + # cpu + cpu = {} + cpu['cores'] = 4 + cpu['arch'] = "x86" + cpu['cpus'] = 2 + profile_dict['cpu'] = cpu + + # ram + ram = {} + ram['amount'] = 256 + ram['channels'] = 4 + profile_dict['ram'] = ram + + data.append(profile_dict) + + return data + + def get_lab_data(self, lab): + data = {} + path = "/pharos_dashboard/data/" + lab.name + "/" + host_file = open(path + "hostlist.json") + host_structure = json.loads(host_file.read()) + host_file.close() + for profile in host_structure['profiles'].keys(): + data[profile] = {} + prof_path = path + profile + for host in host_structure['profiles'][profile]: + host_file = open(prof_path + "/" + host + ".yaml") + host_data = yaml.load(host_file.read()) + host_file.close() + data[profile][host] = host_data + return data + + def make_profiles_and_hosts(self, lab, lab_data): + for host_profile_name, host_data_dict in lab_data.items(): + if len(host_data_dict) < 1: + continue + host_profile = HostProfile.objects.create( + name=host_profile_name, + description="" + ) + host_profile.labs.add(lab) + example_host_data = list(host_data_dict.values())[0] + + cpu_data = example_host_data['cpu'] + CpuProfile.objects.create( + cores=cpu_data['cores'], + architecture=cpu_data['arch'], + cpus=cpu_data['cpus'], + host=host_profile + ) + + ram_data = example_host_data['memory'] + RamProfile.objects.create( + amount=int(ram_data[:-1]), + channels=1, + host=host_profile + ) + + disks_data = example_host_data['disk'] + for disk_data in disks_data: + size = 0 + try: + size=int(disk_data['size'].split('.')[0]) + except: + size=int(disk_data['size'].split('.')[0][:-1]) + DiskProfile.objects.create( + size=size, + media_type="SSD", + name=disk_data['name'], + host=host_profile + ) + + ifaces_data = example_host_data['interface'] + for iface_data in ifaces_data: + InterfaceProfile.objects.create( + speed=iface_data['speed'], + name=iface_data['name'], + host=host_profile + ) + + # all profiles created + for hostname, host_data in host_data_dict.items(): + host = Host.objects.create( + name=hostname, + labid=hostname, + profile=host_profile, + lab=lab + ) + for iface_data in host_data['interface']: + Interface.objects.create( + mac_address=iface_data['mac'], + bus_address=iface_data['busaddr'], + name=iface_data['name'], + host=host + ) + + def populate(self): + self.labs = self.make_labs() + # We should use the existing users, not creating our own + for lab in self.labs: + lab_data = self.get_lab_data(lab) + self.make_profiles_and_hosts(lab, lab_data) + + # We will add opnfv info and images as they are created and supported diff --git a/dashboard/src/dashboard/tasks.py b/dashboard/src/dashboard/tasks.py index fa2ee9d..827c7c5 100644 --- a/dashboard/src/dashboard/tasks.py +++ b/dashboard/src/dashboard/tasks.py @@ -1,5 +1,6 @@ ############################################################################## # Copyright (c) 2016 Max Breitenfeldt and others. +# Copyright (c) 2018 Parker Berberian, Sawyer Bergeron, and others. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 @@ -7,32 +8,100 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -from datetime import timedelta from celery import shared_task from django.utils import timezone -from django.conf import settings +from django.db.models import Q from booking.models import Booking +from notifier.manager import * +from notifier.models import * +from api.models import * +from resource_inventory.resource_manager import ResourceManager -from jenkins.models import JenkinsStatistic @shared_task -def database_cleanup(): - now = timezone.now() - JenkinsStatistic.objects.filter(timestamp__lt=now - timedelta(weeks=4)).delete() - -def booking_cleanup(): - expire_time = timedelta(days=int(settings.BOOKING_EXP_TIME)) - expire_number = int(settings.BOOKING_MAX_NUM) - expired_set = Booking.objects.filter(end__lte=timezone.now()) - expired_count = len(expired_set) - - for booking in expired_set: - if timezone.now() - booking.end > expire_time: - booking.delete() - expired_count = expired_count - 1 - - if expired_count > expire_number: - oldest = expired_set.order_by("end")[:expired_count-expire_number] - for booking in oldest: - booking.delete() +def conjure_aggregate_notifiers(): + NotifyPeriodic.task() + + +@shared_task +def booking_poll(): + def cleanup_hardware(qs): + for hostrelation in qs: + config = hostrelation.config + config.clear_delta() + config.set_power("off") + config.save() + hostrelation.status=JobStatus.NEW + hostrelation.save() + + def cleanup_network(qs): + for hostrelation in qs: + network = hostrelation.config + network.interfaces.clear() + host = hostrelation.host + network.clear_delta() + vlans = [] + for interface in host.interfaces.all(): + for vlan in interface.config: + if vlan.public: + try: + host.lab.vlan_manager.release_public_vlan(vlan.vlan_id) + except: # will fail if we already released in this loop + pass + else: + vlans.append(vlan.vlan_id) + + # release all vlans + if len(vlans) > 0: + host.lab.vlan_manager.release_vlans(vlans) + + interface.config.clear() + network.add_interface(interface) + network.save() + hostrelation.status=JobStatus.NEW + hostrelation.save() + + def cleanup_software(qs): + if qs.exists(): + relation = qs.first() + software = relation.config.opnfv + software.clear_delta() + software.save() + relation.status=JobStatus.NEW + relation.save() + + def cleanup_access(qs): + for relation in qs: + pass # TODO + + cleanup_set = Booking.objects.filter(end__lte=timezone.now()).filter(job__complete=False) + + for booking in cleanup_set: + if not booking.job.complete: + job = booking.job + cleanup_software(SoftwareRelation.objects.filter(job=job)) + cleanup_hardware(HostHardwareRelation.objects.filter(job=job)) + cleanup_network(HostNetworkRelation.objects.filter(job=job)) + cleanup_access(AccessRelation.objects.filter(job=job)) + job.complete = True + job.save() + + +@shared_task +def free_hosts(): + """ + gets all hosts from the database that need to be freed and frees them + """ + networks = ~Q(~Q(job__hostnetworkrelation__status=200)) + hardware = ~Q(~Q(job__hosthardwarerelation__status=200)) + + bookings = Booking.objects.filter( + networks, + hardware, + end__lt=timezone.now(), + job__complete=True, + resource__isnull=False + ) + for booking in bookings: + ResourceManager.getInstance().deleteResourceBundle(booking.resource) diff --git a/dashboard/src/dashboard/templatetags/jenkins_filters.py b/dashboard/src/dashboard/templatetags/jenkins_filters.py deleted file mode 100644 index e7e1425..0000000 --- a/dashboard/src/dashboard/templatetags/jenkins_filters.py +++ /dev/null @@ -1,38 +0,0 @@ -############################################################################## -# Copyright (c) 2016 Max Breitenfeldt and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - - -from django.template.defaultfilters import register - - -@register.filter -def jenkins_job_color(job_result): - if job_result == 'SUCCESS': - return '#5cb85c' - if job_result == 'FAILURE': - return '#d9534f' - if job_result == 'UNSTABLE': - return '#EDD62B' - return '#646F73' # job is still building - - -@register.filter -def jenkins_status_color(slave_status): - if slave_status == 'offline': - return '#d9534f' - if slave_status == 'online': - return '#5cb85c' - if slave_status == 'online / idle': - return '#5bc0de' - - -@register.filter -def jenkins_job_blink(job_result): - if job_result == '': # job is still building - return 'class=blink_me' diff --git a/dashboard/src/dashboard/tests/test_models.py b/dashboard/src/dashboard/tests/test_models.py deleted file mode 100644 index 3a3aeab..0000000 --- a/dashboard/src/dashboard/tests/test_models.py +++ /dev/null @@ -1,69 +0,0 @@ -############################################################################## -# Copyright (c) 2016 Max Breitenfeldt and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - - -from datetime import timedelta -from math import ceil, floor - -from django.test import TestCase -from django.utils import timezone - -from booking.models import * -from dashboard.models import Resource -from jenkins.models import JenkinsSlave - - -class ResourceModelTestCase(TestCase): - def setUp(self): - self.slave = JenkinsSlave.objects.create(name='test', url='test') - self.owner = User.objects.create(username='owner') - - self.res1 = Resource.objects.create(name='res1', slave=self.slave, description='x', - url='x', owner=self.owner) - - def test_booking_utilization(self): - utilization = self.res1.get_booking_utilization(1) - self.assertTrue(utilization['booked_seconds'] == 0) - self.assertTrue(utilization['available_seconds'] == timedelta(weeks=1).total_seconds()) - - start = timezone.now() + timedelta(days=1) - end = start + timedelta(days=1) - booking = Booking.objects.create(start=start, end=end, purpose='test', resource=self.res1, - user=self.owner) - - utilization = self.res1.get_booking_utilization(1) - booked_seconds = timedelta(days=1).total_seconds() - self.assertEqual(utilization['booked_seconds'], booked_seconds) - - utilization = self.res1.get_booking_utilization(-1) - self.assertEqual(utilization['booked_seconds'], 0) - - booking.delete() - start = timezone.now() - timedelta(days=1) - end = start + timedelta(days=2) - booking = Booking.objects.create(start=start, end=end, purpose='test', resource=self.res1, - user=self.owner) - booked_seconds = self.res1.get_booking_utilization(1)['booked_seconds'] - # use ceil because a fraction of the booked time has already passed now - booked_seconds = ceil(booked_seconds) - self.assertEqual(booked_seconds, timedelta(days=1).total_seconds()) - - booking.delete() - start = timezone.now() + timedelta(days=6) - end = start + timedelta(days=2) - booking = Booking.objects.create(start=start, end=end, purpose='test', resource=self.res1, - user=self.owner) - booked_seconds = self.res1.get_booking_utilization(1)['booked_seconds'] - booked_seconds = floor(booked_seconds) - self.assertEqual(booked_seconds, timedelta(days=1).total_seconds()) - - - - - diff --git a/dashboard/src/dashboard/tests/test_views.py b/dashboard/src/dashboard/tests/test_views.py deleted file mode 100644 index f5e17c2..0000000 --- a/dashboard/src/dashboard/tests/test_views.py +++ /dev/null @@ -1,75 +0,0 @@ -############################################################################## -# Copyright (c) 2016 Max Breitenfeldt and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - - -from django.test import TestCase -from django.urls import reverse - -from dashboard.models import Resource -from jenkins.models import JenkinsSlave - - -class DashboardViewTestCase(TestCase): - def setUp(self): - self.slave_active = JenkinsSlave.objects.create(name='slave_active', url='x', active=True) - self.slave_inactive = JenkinsSlave.objects.create(name='slave_inactive', url='x', - active=False) - self.res_active = Resource.objects.create(name='res_active', slave=self.slave_active, - description='x', url='x') - self.res_inactive = Resource.objects.create(name='res_inactive', slave=self.slave_inactive, - description='x', url='x') - - def test_booking_utilization_json(self): - url = reverse('dashboard:booking_utilization', kwargs={'resource_id': 0, 'weeks': 0}) - self.assertEqual(self.client.get(url).status_code, 404) - - url = reverse('dashboard:booking_utilization', kwargs={'resource_id': self.res_active.id, - 'weeks': 0}) - response = self.client.get(url) - self.assertEqual(response.status_code, 200) - self.assertContains(response, 'data') - - def test_jenkins_utilization_json(self): - url = reverse('dashboard:jenkins_utilization', kwargs={'resource_id': 0, 'weeks': 0}) - self.assertEqual(self.client.get(url).status_code, 404) - - url = reverse('dashboard:jenkins_utilization', kwargs={'resource_id': self.res_active.id, - 'weeks': 0}) - response = self.client.get(url) - self.assertEqual(response.status_code, 200) - self.assertContains(response, 'data') - - def test_jenkins_slaves_view(self): - url = reverse('dashboard:jenkins_slaves') - response = self.client.get(url) - self.assertEqual(response.status_code, 200) - self.assertIn(self.slave_active, response.context['slaves']) - self.assertNotIn(self.slave_inactive, response.context['slaves']) - - def test_ci_pods_view(self): - url = reverse('dashboard:ci_pods') - response = self.client.get(url) - self.assertEqual(response.status_code, 200) - self.assertEqual(len(response.context['ci_pods']), 0) - - self.slave_active.ci_slave = True - self.slave_inactive.ci_slave = True - self.slave_active.save() - self.slave_inactive.save() - - response = self.client.get(url) - self.assertIn(self.res_active, response.context['ci_pods']) - self.assertNotIn(self.res_inactive, response.context['ci_pods']) - - def test_dev_pods_view(self): - url = reverse('dashboard:dev_pods') - response = self.client.get(url) - self.assertEqual(response.status_code, 200) - self.assertEqual(len(response.context['dev_pods']), 0) - diff --git a/dashboard/src/dashboard/urls.py b/dashboard/src/dashboard/urls.py index 609e5d6..0d7ee87 100644 --- a/dashboard/src/dashboard/urls.py +++ b/dashboard/src/dashboard/urls.py @@ -1,5 +1,6 @@ ############################################################################## # Copyright (c) 2016 Max Breitenfeldt and others. +# Copyright (c) 2018 Sawyer Bergeron, Parker Berberian, and others. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 @@ -24,18 +25,12 @@ Including another URLconf 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) """ from django.conf.urls import url - from dashboard.views import * +app_name="dashboard" urlpatterns = [ - url(r'^ci_pods/$', CIPodsView.as_view(), name='ci_pods'), - url(r'^dev_pods/$', DevelopmentPodsView.as_view(), name='dev_pods'), - url(r'^jenkins_slaves/$', JenkinsSlavesView.as_view(), name='jenkins_slaves'), - url(r'^resource/all/$', LabOwnerView.as_view(), name='resources'), - url(r'^resource/(?P[0-9]+)/$', ResourceView.as_view(), name='resource'), - url(r'^resource/(?P[0-9]+)/booking_utilization/(?P-?\d+)/$', - BookingUtilizationJSON.as_view(), name='booking_utilization'), - url(r'^resource/(?P[0-9]+)/jenkins_utilization/(?P-?\d+)/$', - JenkinsUtilizationJSON.as_view(), name='jenkins_utilization'), - url(r'^$', DevelopmentPodsView.as_view(), name="index"), + url(r'^$', landing_view, name='index'), + url(r'^lab/$', lab_list_view, name='all_labs'), + url(r'^lab/(?P.+)/$', lab_detail_view, name='lab_detail'), + url(r'^hosts/$', host_profile_detail_view, name="hostprofile_detail") ] diff --git a/dashboard/src/dashboard/views.py b/dashboard/src/dashboard/views.py index 4bab036..2d1f8b2 100644 --- a/dashboard/src/dashboard/views.py +++ b/dashboard/src/dashboard/views.py @@ -1,5 +1,6 @@ ############################################################################## # Copyright (c) 2016 Max Breitenfeldt and others. +# Copyright (c) 2018 Parker Berberian, Sawyer Bergeron, and others. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 @@ -8,139 +9,106 @@ ############################################################################## -from datetime import timedelta - -from django.http import JsonResponse from django.shortcuts import get_object_or_404 -from django.utils import timezone -from django.views import View from django.views.generic import TemplateView +from django.shortcuts import render +from django.http import HttpResponseRedirect from booking.models import Booking -from dashboard.models import Resource -from jenkins.models import JenkinsSlave +from account.models import Lab +from resource_inventory.models import * +from workflow.views import * +from workflow.workflow_manager import * -class JenkinsSlavesView(TemplateView): - template_name = "dashboard/jenkins_slaves.html" - def get_context_data(self, **kwargs): - slaves = JenkinsSlave.objects.filter(active=True) - context = super(JenkinsSlavesView, self).get_context_data(**kwargs) - context.update({'title': "Jenkins Slaves", 'slaves': slaves}) - return context +def lab_list_view(request): + labs = Lab.objects.all() + context = {"labs": labs} + return render(request, "dashboard/lab_list.html", context) -class CIPodsView(TemplateView): - template_name = "dashboard/ci_pods.html" - def get_context_data(self, **kwargs): - ci_pods = Resource.objects.filter(slave__ci_slave=True, slave__active=True) - context = super(CIPodsView, self).get_context_data(**kwargs) - context.update({'title': "CI Pods", 'ci_pods': ci_pods}) - return context +def lab_detail_view(request, lab_name): + user = None + if request.user.is_authenticated: + user = request.user + lab = get_object_or_404(Lab, name=lab_name) -class DevelopmentPodsView(TemplateView): - template_name = "dashboard/dev_pods.html" + images = Image.objects.filter(from_lab=lab).filter(public=True) + if user: + images = images | Image.objects.filter(from_lab=lab).filter(owner=user) - def get_context_data(self, **kwargs): - resources = Resource.objects.filter(dev_pod=True) - - bookings = Booking.objects.filter(start__lte=timezone.now()) - bookings = bookings.filter(end__gt=timezone.now()) - - dev_pods = [] - for resource in resources: - booking_utilization = resource.get_booking_utilization(weeks=4) - total = booking_utilization['booked_seconds'] + booking_utilization['available_seconds'] - try: - utilization_percentage = "%d%%" % (float(booking_utilization['booked_seconds']) / - total * 100) - except (ValueError, ZeroDivisionError): - return "" - - dev_pod = (resource, None, utilization_percentage) - for booking in bookings: - if booking.resource == resource: - dev_pod = (resource, booking, utilization_percentage) - dev_pods.append(dev_pod) - - context = super(DevelopmentPodsView, self).get_context_data(**kwargs) - context.update({'title': "Development Pods", 'dev_pods': dev_pods}) - return context + return render(request, "dashboard/lab_detail.html", + {'title': "Lab Overview", + 'lab': lab, + 'hostprofiles': lab.hostprofiles.all(), + 'images': images}) -class ResourceView(TemplateView): - template_name = "dashboard/resource.html" +def host_profile_detail_view(request): - def get_context_data(self, **kwargs): - resource = get_object_or_404(Resource, id=self.kwargs['resource_id']) - bookings = Booking.objects.filter(resource=resource, end__gt=timezone.now()) - context = super(ResourceView, self).get_context_data(**kwargs) - context.update({'title': str(resource), 'resource': resource, 'bookings': bookings}) - return context + return render(request, "dashboard/host_profile_detail.html", + {'title': "Host Types", + }) -class LabOwnerView(TemplateView): - template_name = "dashboard/resource_all.html" +def landing_view(request): + manager = None + manager_detected = False + if 'manager_session' in request.session: - def get_context_data(self, **kwargs): - resources = Resource.objects.filter(slave__dev_pod=True, slave__active=True) - pods = [] - for resource in resources: - utilization = resource.slave.get_utilization(timedelta(days=7)) - bookings = Booking.objects.filter(resource=resource, end__gt=timezone.now()) - pods.append((resource, utilization, bookings)) - context = super(LabOwnerView, self).get_context_data(**kwargs) - context.update({'title': "Overview", 'pods': pods}) - return context + try: + manager = ManagerTracker.managers[request.session['manager_session']] + + + except KeyError as e: + pass + + if manager is not None: + #no manager detected, don't display continue button + manager_detected = True + if request.method == 'GET': + return render(request, 'dashboard/landing.html', {'manager': manager_detected, 'title': "Welcome!"}) -class BookingUtilizationJSON(View): - def get(self, request, *args, **kwargs): - resource = get_object_or_404(Resource, id=kwargs['resource_id']) - utilization = resource.get_booking_utilization(int(kwargs['weeks'])) - utilization = [ - { - 'label': 'Booked', - 'data': utilization['booked_seconds'], - 'color': '#d9534f' - }, - { - 'label': 'Available', - 'data': utilization['available_seconds'], - 'color': '#5cb85c' - }, - ] - return JsonResponse({'data': utilization}) - - -class JenkinsUtilizationJSON(View): - def get(self, request, *args, **kwargs): - resource = get_object_or_404(Resource, id=kwargs['resource_id']) - weeks = int(kwargs['weeks']) + if request.method == 'POST': try: - utilization = resource.slave.get_utilization(timedelta(weeks=weeks)) - utilization = [ - { - 'label': 'Offline', - 'data': utilization['offline'], - 'color': '#d9534f' - }, - { - 'label': 'Online', - 'data': utilization['online'], - 'color': '#5cb85c' - }, - { - 'label': 'Idle', - 'data': utilization['idle'], - 'color': '#5bc0de' - }, - ] - jutilization = JsonResponse({'data': utilization}) - except AttributeError: - return JsonResponse({'data': ''}) - if jutilization: - return jutilization + create = request.POST['create'] + + if manager is not None: + del manager + + mgr_uuid = create_session(create, request=request,) + request.session['manager_session'] = mgr_uuid + return HttpResponseRedirect('/wf/') + + except KeyError as e: + pass + + +class LandingView(TemplateView): + template_name = "dashboard/landing.html" + + def get_context_data(self, **kwargs): + context = super(LandingView, self).get_context_data(**kwargs) + + hosts = [] + + for host_profile in HostProfile.objects.all(): + name = host_profile.name + description = host_profile.description + in_labs = host_profile.labs + + interfaces = host_profile.interfaceprofile + storage = host_profile.storageprofile + cpu = host_profile.cpuprofile + ram = host_profile.ramprofile + + host = (name, description, in_labs, interfaces, storage, cpu, ram) + hosts.append(host) + + context.update({'hosts': hosts}) + + return context diff --git a/dashboard/src/jenkins/__init__.py b/dashboard/src/jenkins/__init__.py deleted file mode 100644 index b5914ce..0000000 --- a/dashboard/src/jenkins/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################## -# Copyright (c) 2016 Max Breitenfeldt and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - - diff --git a/dashboard/src/jenkins/adapter.py b/dashboard/src/jenkins/adapter.py deleted file mode 100644 index b48b868..0000000 --- a/dashboard/src/jenkins/adapter.py +++ /dev/null @@ -1,137 +0,0 @@ -############################################################################## -# Copyright (c) 2016 Max Breitenfeldt and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - - -import logging -import re -from django.conf import settings - -import requests -from django.core.cache import cache - -logger = logging.getLogger(__name__) - -# TODO: implement caching decorator, cache get_* functions -def get_json(url): - if cache.get(url) is None: - try: - response = requests.get(url) - json = response.json() - cache.set(url, json, 180) # cache result for 180 seconds - return json - except requests.exceptions.RequestException as e: - logger.exception(e) - except ValueError as e: - logger.exception(e) - else: - return cache.get(url) - - -def get_all_slaves(): - url = settings.ALL_SLAVES_URL - json = get_json(url) - if json is not None: - return json['computer'] # return list of dictionaries - return [] - - - - -def get_slave(slavename): - slaves = get_all_slaves() - for slave in slaves: - if slave['displayName'] == slavename: - return slave - return {} - - -def get_ci_slaves(): - url = settings.CI_SLAVES_URL - json = get_json(url) - if json is not None: - return json['nodes'] - return [] - - -def get_all_jobs(): - url = settings.ALL_JOBS_URL - json = get_json(url) - if json is not None: - return json['jobs'] # return list of dictionaries - return [] - - -def get_jenkins_job(slavename): - jobs = get_all_jobs() - max_time = 0 - last_job = None - for job in jobs: - if job['lastBuild'] is not None: - if job['lastBuild']['builtOn'] == slavename: - if job['lastBuild']['building'] is True: - return job # return active build - if job['lastBuild']['timestamp'] > max_time: - last_job = job - max_time = job['lastBuild']['timestamp'] - return last_job - - -def is_ci_slave(slavename): - ci_slaves = get_ci_slaves() - for ci_slave in ci_slaves: - if ci_slave['nodeName'] == slavename: - return True - return False - - -def is_dev_pod(slavename): - if is_ci_slave(slavename): - return False - if slavename.find('pod') != -1: - return True - return False - - -def parse_job(job): - result = parse_job_string(job['lastBuild']['fullDisplayName']) - result['building'] = job['lastBuild']['building'] - result['result'] = '' - if not job['lastBuild']['building']: - result['result'] = job['lastBuild']['result'] - result['url'] = job['url'] - return result - - -def parse_job_string(full_displayname): - job = {} - job['scenario'] = '' - job['installer'] = '' - job['branch'] = '' - tokens = re.split(r'[ -]', full_displayname) - for i in range(len(tokens)): - if tokens[i] == 'os': - job['scenario'] = '-'.join(tokens[i: i + 4]) - elif tokens[i] in ['fuel', 'joid', 'apex', 'compass']: - job['installer'] = tokens[i] - elif tokens[i] in ['master', 'arno', 'brahmaputra', 'colorado']: - job['branch'] = tokens[i] - tokens = full_displayname.split(' ') - job['name'] = tokens[0] - return job - -def get_slave_url(slave): - return settings.GET_SLAVE_URL + slave['displayName'] - - -def get_slave_status(slave): - if not slave['offline'] and slave['idle']: - return 'online / idle' - if not slave['offline']: - return 'online' - return 'offline' diff --git a/dashboard/src/jenkins/admin.py b/dashboard/src/jenkins/admin.py deleted file mode 100644 index c499670..0000000 --- a/dashboard/src/jenkins/admin.py +++ /dev/null @@ -1,17 +0,0 @@ -############################################################################## -# Copyright (c) 2016 Max Breitenfeldt and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - - -from django.conf import settings -from django.contrib import admin - -from jenkins.models import JenkinsSlave - -if settings.DEBUG: - admin.site.register(JenkinsSlave) \ No newline at end of file diff --git a/dashboard/src/jenkins/apps.py b/dashboard/src/jenkins/apps.py deleted file mode 100644 index 41faf60..0000000 --- a/dashboard/src/jenkins/apps.py +++ /dev/null @@ -1,15 +0,0 @@ -############################################################################## -# Copyright (c) 2016 Max Breitenfeldt and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - - -from django.apps import AppConfig - - -class JenkinsConfig(AppConfig): - name = 'jenkins' diff --git a/dashboard/src/jenkins/migrations/0001_initial.py b/dashboard/src/jenkins/migrations/0001_initial.py deleted file mode 100644 index b1c7889..0000000 --- a/dashboard/src/jenkins/migrations/0001_initial.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10 on 2016-11-03 13:33 -from __future__ import unicode_literals - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ] - - operations = [ - migrations.CreateModel( - name='JenkinsSlave', - fields=[ - ('id', models.AutoField(primary_key=True, serialize=False)), - ('name', models.CharField(max_length=100, unique=True)), - ('status', models.CharField(default='offline', max_length=30)), - ('url', models.CharField(max_length=1024)), - ('ci_slave', models.BooleanField(default=False)), - ('dev_pod', models.BooleanField(default=False)), - ('building', models.BooleanField(default=False)), - ('last_job_name', models.CharField(default='', max_length=1024)), - ('last_job_url', models.CharField(default='', max_length=1024)), - ('last_job_scenario', models.CharField(default='', max_length=50)), - ('last_job_branch', models.CharField(default='', max_length=50)), - ('last_job_installer', models.CharField(default='', max_length=50)), - ('last_job_result', models.CharField(default='', max_length=30)), - ('active', models.BooleanField(default=False)), - ], - options={ - 'db_table': 'jenkins_slave', - }, - ), - migrations.CreateModel( - name='JenkinsStatistic', - fields=[ - ('id', models.AutoField(primary_key=True, serialize=False)), - ('offline', models.BooleanField(default=False)), - ('idle', models.BooleanField(default=False)), - ('online', models.BooleanField(default=False)), - ('timestamp', models.DateTimeField(auto_now_add=True)), - ('slave', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='jenkins.JenkinsSlave')), - ], - options={ - 'db_table': 'jenkins_statistic', - }, - ), - ] diff --git a/dashboard/src/jenkins/migrations/__init__.py b/dashboard/src/jenkins/migrations/__init__.py deleted file mode 100644 index b5914ce..0000000 --- a/dashboard/src/jenkins/migrations/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################## -# Copyright (c) 2016 Max Breitenfeldt and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - - diff --git a/dashboard/src/jenkins/models.py b/dashboard/src/jenkins/models.py deleted file mode 100644 index 8254ff3..0000000 --- a/dashboard/src/jenkins/models.py +++ /dev/null @@ -1,62 +0,0 @@ -############################################################################## -# Copyright (c) 2016 Max Breitenfeldt and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - - -from django.db import models -from django.utils import timezone - - -class JenkinsSlave(models.Model): - id = models.AutoField(primary_key=True) - name = models.CharField(max_length=100, unique=True) - status = models.CharField(max_length=30, default='offline') - url = models.CharField(max_length=1024) - ci_slave = models.BooleanField(default=False) - dev_pod = models.BooleanField(default=False) - - building = models.BooleanField(default=False) - - last_job_name = models.CharField(max_length=1024, default='') - last_job_url = models.CharField(max_length=1024, default='') - last_job_scenario = models.CharField(max_length=50, default='') - last_job_branch = models.CharField(max_length=50, default='') - last_job_installer = models.CharField(max_length=50, default='') - last_job_result = models.CharField(max_length=30, default='') - - active = models.BooleanField(default=False) - - def get_utilization(self, timedelta): - """ - Return a dictionary containing the count of idle, online and offline measurements in the time from - now-timedelta to now - """ - utilization = {'idle': 0, 'online': 0, 'offline': 0} - statistics = self.jenkinsstatistic_set.filter(timestamp__gte=timezone.now() - timedelta) - utilization['idle'] = statistics.filter(idle=True).count() - utilization['online'] = statistics.filter(online=True).count() - utilization['offline'] = statistics.filter(offline=True).count() - return utilization - - class Meta: - db_table = 'jenkins_slave' - - def __str__(self): - return self.name - - -class JenkinsStatistic(models.Model): - id = models.AutoField(primary_key=True) - slave = models.ForeignKey(JenkinsSlave, on_delete=models.CASCADE) - offline = models.BooleanField(default=False) - idle = models.BooleanField(default=False) - online = models.BooleanField(default=False) - timestamp = models.DateTimeField(auto_now_add=True) - - class Meta: - db_table = 'jenkins_statistic' diff --git a/dashboard/src/jenkins/tasks.py b/dashboard/src/jenkins/tasks.py deleted file mode 100644 index ea986c1..0000000 --- a/dashboard/src/jenkins/tasks.py +++ /dev/null @@ -1,64 +0,0 @@ -############################################################################## -# Copyright (c) 2016 Max Breitenfeldt and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - - -from celery import shared_task - -from dashboard.models import Resource -from jenkins.models import JenkinsSlave, JenkinsStatistic -from .adapter import * - - -@shared_task -def sync_jenkins(): - update_jenkins_slaves() - - -def update_jenkins_slaves(): - JenkinsSlave.objects.all().update(active=False) - - jenkins_slaves = get_all_slaves() - for slave in jenkins_slaves: - jenkins_slave, created = JenkinsSlave.objects.get_or_create(name=slave['displayName'], - url=get_slave_url(slave)) - jenkins_slave.active = True - jenkins_slave.ci_slave = is_ci_slave(slave['displayName']) - jenkins_slave.dev_pod = is_dev_pod(slave['displayName']) - jenkins_slave.status = get_slave_status(slave) - - # if this is a new slave and a pod, check if there is a resource for it, create one if not - if created and 'pod' in slave['displayName']: - # parse resource name from slave name - # naming example: orange-pod1, resource name: Orange POD 1 - tokens = slave['displayName'].split('-') - name = tokens[0].capitalize() + ' POD '# company name - name += tokens[1][3:] # remove 'pod' - resource, created = Resource.objects.get_or_create(name=name) - resource.slave = jenkins_slave - resource.save() - - last_job = get_jenkins_job(jenkins_slave.name) - if last_job is not None: - last_job = parse_job(last_job) - jenkins_slave.last_job_name = last_job['name'] - jenkins_slave.last_job_url = last_job['url'] - jenkins_slave.last_job_scenario = last_job['scenario'] - jenkins_slave.last_job_branch = last_job['branch'] - jenkins_slave.last_job_installer = last_job['installer'] - jenkins_slave.last_job_result = last_job['result'] - jenkins_slave.save() - - jenkins_statistic = JenkinsStatistic(slave=jenkins_slave) - if jenkins_slave.status == 'online' or jenkins_slave.status == 'building': - jenkins_statistic.online = True - if jenkins_slave.status == 'offline': - jenkins_statistic.offline = True - if jenkins_slave.status == 'online / idle': - jenkins_statistic.idle = True - jenkins_statistic.save() diff --git a/dashboard/src/jenkins/tests.py b/dashboard/src/jenkins/tests.py deleted file mode 100644 index 3723cd3..0000000 --- a/dashboard/src/jenkins/tests.py +++ /dev/null @@ -1,129 +0,0 @@ -############################################################################## -# Copyright (c) 2016 Max Breitenfeldt and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - - -from datetime import timedelta -from unittest import TestCase - -import jenkins.adapter as jenkins -from jenkins.models import * - - -# Tests that the data we get with the jenkinsadapter contains all the -# data we need. These test will fail if; -# - there is no internet connection -# - the opnfv jenkins url has changed -# - the jenkins api has changed -# - jenkins is not set up / there is no data -class JenkinsAdapterTestCase(TestCase): - def test_get_all_slaves(self): - slaves = jenkins.get_all_slaves() - self.assertTrue(len(slaves) > 0) - for slave in slaves: - self.assertTrue('displayName' in slave) - self.assertTrue('idle' in slave) - self.assertTrue('offline' in slave) - - def test_get_slave(self): - slaves = jenkins.get_all_slaves() - self.assertEqual(slaves[0], jenkins.get_slave(slaves[0]['displayName'])) - self.assertEqual({}, jenkins.get_slave('098f6bcd4621d373cade4e832627b4f6')) - - def test_get_ci_slaves(self): - slaves = jenkins.get_ci_slaves() - self.assertTrue(len(slaves) > 0) - for slave in slaves: - self.assertTrue('nodeName' in slave) - - def test_get_jenkins_job(self): - slaves = jenkins.get_ci_slaves() - job = None - for slave in slaves: - job = jenkins.get_jenkins_job(slave['nodeName']) - if job is not None: - break - # We need to test at least one job - self.assertNotEqual(job, None) - - def test_get_all_jobs(self): - jobs = jenkins.get_all_jobs() - lastBuild = False - self.assertTrue(len(jobs) > 0) - for job in jobs: - self.assertTrue('displayName' in job) - self.assertTrue('url' in job) - self.assertTrue('lastBuild' in job) - if job['lastBuild'] is not None: - lastBuild = True - self.assertTrue('building' in job['lastBuild']) - self.assertTrue('fullDisplayName' in job['lastBuild']) - self.assertTrue('result' in job['lastBuild']) - self.assertTrue('timestamp' in job['lastBuild']) - self.assertTrue('builtOn' in job['lastBuild']) - self.assertTrue(lastBuild) - - def test_parse_job(self): - job = { - "displayName": "apex-deploy-baremetal-os-nosdn-fdio-noha-colorado", - "url": "https://build.opnfv.org/ci/job/apex-deploy-baremetal-os-nosdn-fdio-noha-colorado/", - "lastBuild": { - "building": False, - "fullDisplayName": "apex-deploy-baremetal-os-nosdn-fdio-noha-colorado #37", - "result": "SUCCESS", - "timestamp": 1476283629917, - "builtOn": "lf-pod1" - } - } - - job = jenkins.parse_job(job) - self.assertEqual(job['scenario'], 'os-nosdn-fdio-noha') - self.assertEqual(job['installer'], 'apex') - self.assertEqual(job['branch'], 'colorado') - self.assertEqual(job['result'], 'SUCCESS') - self.assertEqual(job['building'], False) - self.assertEqual(job['url'], - "https://build.opnfv.org/ci/job/apex-deploy-baremetal-os-nosdn-fdio-noha-colorado/") - self.assertEqual(job['name'], - 'apex-deploy-baremetal-os-nosdn-fdio-noha-colorado') - - def test_get_slave_status(self): - slave = { - 'offline': True, - 'idle': False - } - self.assertEqual(jenkins.get_slave_status(slave), 'offline') - slave = { - 'offline': False, - 'idle': False - } - self.assertEqual(jenkins.get_slave_status(slave), 'online') - slave = { - 'offline': False, - 'idle': True - } - self.assertEqual(jenkins.get_slave_status(slave), 'online / idle') - - -class JenkinsModelTestCase(TestCase): - def test_get_utilization(self): - jenkins_slave = JenkinsSlave.objects.create(name='test', status='offline', url='') - utilization = jenkins_slave.get_utilization(timedelta(weeks=1)) - self.assertEqual(utilization['idle'], 0) - self.assertEqual(utilization['offline'], 0) - self.assertEqual(utilization['online'], 0) - - for i in range(10): - JenkinsStatistic.objects.create(slave=jenkins_slave, - offline=True, idle=True, - online=True) - - utilization = jenkins_slave.get_utilization(timedelta(weeks=1)) - self.assertEqual(utilization['idle'], 10) - self.assertEqual(utilization['offline'], 10) - self.assertEqual(utilization['online'], 10) diff --git a/dashboard/src/manage.py b/dashboard/src/manage.py old mode 100644 new mode 100755 diff --git a/dashboard/src/notifier/__init__.py b/dashboard/src/notifier/__init__.py index e69de29..d65b13a 100644 --- a/dashboard/src/notifier/__init__.py +++ b/dashboard/src/notifier/__init__.py @@ -0,0 +1,8 @@ +############################################################################## +# Copyright (c) 2018 Sawyer Bergeron and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## diff --git a/dashboard/src/notifier/admin.py b/dashboard/src/notifier/admin.py index cfbe778..d3e8be5 100644 --- a/dashboard/src/notifier/admin.py +++ b/dashboard/src/notifier/admin.py @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2016 Max Breitenfeldt and others. +# Copyright (c) 2018 Sawyer Bergeron, Parker Berberian, and others. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 @@ -12,3 +12,5 @@ from django.contrib import admin from notifier.models import * admin.site.register(Notifier) +admin.site.register(MetaBooking) +admin.site.register(LabMessage) diff --git a/dashboard/src/notifier/apps.py b/dashboard/src/notifier/apps.py index da5d3b0..52902da 100644 --- a/dashboard/src/notifier/apps.py +++ b/dashboard/src/notifier/apps.py @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2016 Max Breitenfeldt and others. +# Copyright (c) 2018 Sawyer Bergeron, Parker Berberian, and others. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 @@ -7,6 +7,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## + from django.apps import AppConfig diff --git a/dashboard/src/notifier/dispatchers.py b/dashboard/src/notifier/dispatchers.py index c35fe2b..1b66b37 100644 --- a/dashboard/src/notifier/dispatchers.py +++ b/dashboard/src/notifier/dispatchers.py @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2016 Max Breitenfeldt and others. +# Copyright (c) 2018 Sawyer Bergeron, Parker Berberian, and others. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 @@ -30,4 +30,4 @@ class DispatchHandler(): instance.sender,[instance.user.email_addr], fail_silently=False) def webnotification(instance): - instance.msg_sent='by web notification' \ No newline at end of file + instance.msg_sent='by web notification' diff --git a/dashboard/src/notifier/manager.py b/dashboard/src/notifier/manager.py new file mode 100644 index 0000000..a705d00 --- /dev/null +++ b/dashboard/src/notifier/manager.py @@ -0,0 +1,98 @@ +############################################################################## +# Copyright (c) 2018 Sawyer Bergeron and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +from booking.models import * +from notifier.models import Notifier, MetaBooking, LabMessage +from django.utils import timezone +from datetime import timedelta +from django.template import Template, Context +from account.models import UserProfile + +from django.db import models + +class NotifyPeriodic(object): + def task(): + bookings_new = Booking.objects.filter(metabooking__isnull=True) + bookings_old = Booking.objects.filter(end__lte=timezone.now() + timedelta(hours=24)).filter(metabooking__ended_notified=False) + + for booking in bookings_old: + metabooking = booking.metabooking + if booking.end <= timezone.now() + timedelta(hours=24): + if not metabooking.ending_notified: + Notify().notify(Notify.TOCLEAN, booking) + metabooking.ending_notified = True + metabooking.save() + if booking.end <= timezone.now(): + metabooking = booking.metabooking + if not metabooking.ended_notified: + Notify().notify(Notify.CLEANED, booking) + metabooking.ended_notified = True + metabooking.save() + + for booking in bookings_new: + metabooking = MetaBooking() + metabooking.booking = booking + metabooking.created_notified = True + metabooking.save() + + Notify().notify(Notify.CREATED, booking) + + +class Notify(object): + + CREATED = "created" + TOCLEAN = "toclean" + CLEANED = "cleaned" + + TITLES = {} + TITLES["created"] = "Your booking has been confirmed" + TITLES["toclean"] = "Your booking is ending soon" + TITLES["cleaned"] = "Your booking has ended" + + """ + Lab message is provided with the following context elements: + * if is for owner or for collaborator (if owner) + * recipient username (.username) + * recipient full name (.userprofile.full_name) + * booking it pertains to (booking) + * status message should convey (currently "created", "toclean" and "cleaned" as strings) + It should be a django template that can be rendered with these context elements + and should generally use all of them in one way or another. + It should be applicable to email, the web based general view, and should be scalable for + all device formats across those mediums. + """ + def notify(self, notifier_type, booking): + template = Template(LabMessage.objects.filter(lab=booking.lab).first().msg) + + context = {} + context["owner"] = booking.owner + context["notify_type"] = notifier_type + context["booking"] = booking + message = template.render(Context(context)) + notifier = Notifier() + notifier.title = self.TITLES[notifier_type] + notifier.content = message + notifier.user = booking.owner.userprofile + notifier.sender = str(booking.lab) + notifier.save() + notifier.send() + + + context["owner"] = False + + for user in booking.collaborators.all(): + context["collaborator"] = user + message = template.render(Context(context)) + notifier = Notifier() + notifier.title = self.TITLES[notifier_type] + notifier.content = message + notifier.user = UserProfile.objects.get(user=user) + notifier.sender = str(booking.lab) + notifier.save() + notifier.send() diff --git a/dashboard/src/notifier/migrations/0001_initial.py b/dashboard/src/notifier/migrations/0001_initial.py index cac4d04..e5d0009 100644 --- a/dashboard/src/notifier/migrations/0001_initial.py +++ b/dashboard/src/notifier/migrations/0001_initial.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10 on 2017-12-14 21:41 -from __future__ import unicode_literals +# Generated by Django 2.1 on 2018-09-14 14:48 from django.db import migrations, models import django.db.models.deletion @@ -12,10 +10,29 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('dashboard', '0002_auto_20170505_0815'), + ('account', '0001_initial'), + ('booking', '0001_initial'), ] operations = [ + migrations.CreateModel( + name='LabMessage', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('msg', models.TextField()), + ('lab', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='account.Lab')), + ], + ), + migrations.CreateModel( + name='MetaBooking', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('ending_notified', models.BooleanField(default=False)), + ('ended_notified', models.BooleanField(default=False)), + ('created_notified', models.BooleanField(default=False)), + ('booking', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='metabooking', to='booking.Booking')), + ], + ), migrations.CreateModel( name='Notifier', fields=[ diff --git a/dashboard/src/notifier/models.py b/dashboard/src/notifier/models.py index 9ebc6fc..ed0edeb 100644 --- a/dashboard/src/notifier/models.py +++ b/dashboard/src/notifier/models.py @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2016 Max Breitenfeldt and others. +# Copyright (c) 2018 Sawyer Bergeron, Parker Berberian, and others. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 @@ -8,14 +8,24 @@ ############################################################################## from django.db import models -from jira import JIRA, JIRAError -from dashboard.models import Resource from booking.models import Booking -from django.contrib.auth.models import User from account.models import UserProfile -from django.contrib import messages -from django.db.models.signals import pre_save from fernet_fields import EncryptedTextField +from account.models import Lab + + +class MetaBooking(models.Model): + id = models.AutoField(primary_key=True) + booking = models.OneToOneField(Booking, on_delete=models.CASCADE, related_name="metabooking") + ending_notified = models.BooleanField(default=False) + ended_notified = models.BooleanField(default=False) + created_notified = models.BooleanField(default=False) + + +class LabMessage(models.Model): + lab = models.ForeignKey(Lab, on_delete=models.CASCADE) + msg = models.TextField() # django template should be put here + class Notifier(models.Model): id = models.AutoField(primary_key=True) @@ -24,15 +34,18 @@ class Notifier(models.Model): user = models.ForeignKey(UserProfile, on_delete=models.CASCADE, null=True, blank=True) sender = models.CharField(max_length=240, default='unknown') message_type = models.CharField(max_length=240, default='email', choices=( - ('email','Email'), + ('email', 'Email'), ('webnotification', 'Web Notification'))) msg_sent = '' - import notifier.dispatchers - def __str__(self): return self.title + """ + Implement for next PR: send Notifier by media agreed to by user + """ + def send(self): + pass + def getEmail(self): return self.user.email_addr - diff --git a/dashboard/src/notifier/tests/test_dispatcher.py b/dashboard/src/notifier/tests/test_dispatcher.py new file mode 100644 index 0000000..07d8387 --- /dev/null +++ b/dashboard/src/notifier/tests/test_dispatcher.py @@ -0,0 +1,17 @@ +############################################################################## +# Copyright (c) 2018 Sawyer Bergeron and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +from django.test import TestCase +from notifier.models import * +from django.contrib.auth.models import User + +class DispatchTestCase(TestCase): + # This is a stub, it will be filled out as this feature is remade with saner practices. + pass diff --git a/dashboard/src/notifier/tests/test_models.py b/dashboard/src/notifier/tests/test_models.py new file mode 100644 index 0000000..10aec3e --- /dev/null +++ b/dashboard/src/notifier/tests/test_models.py @@ -0,0 +1,29 @@ +############################################################################## +# Copyright (c) 2018 Sawyer Bergeron and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +from django.test import TestCase +from notifier.models import * +from django.contrib.auth.models import User + +class NotifierTestCase(TestCase): + + def test_valid_notifier_saves(self): + + sender = User.objects.create() + recipient = User.objects.create() + self.assertTrue( + Notifier.objects.create( + title='notification title', + content='notification body', + user=recipient, + sender=sender, + message_type='email' + ) + ) diff --git a/dashboard/src/notifier/urls.py b/dashboard/src/notifier/urls.py new file mode 100644 index 0000000..9bbc3bf --- /dev/null +++ b/dashboard/src/notifier/urls.py @@ -0,0 +1,21 @@ +############################################################################## +# Copyright (c) 2018 Sawyer Bergeron, Parker Berberian, and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +from django.conf.urls import url + +from notifier.views import * + +app_name = "notifier" +urlpatterns = [ + + + url(r'^$', InboxView, name='messages'), + url(r'^notification/(?P[0-9]+)/$', NotificationView, name='notifier_single') +] diff --git a/dashboard/src/notifier/views.py b/dashboard/src/notifier/views.py new file mode 100644 index 0000000..026894a --- /dev/null +++ b/dashboard/src/notifier/views.py @@ -0,0 +1,34 @@ +############################################################################## +# Copyright (c) 2018 Sawyer Bergeron and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +from notifier.models import * +from django.shortcuts import render + +def InboxView(request): + if request.user.is_authenticated: + user = request.user + else: + return render(request, "dashboard/login.html", {'title': 'Authentication Required'}) + + return render(request, "notifier/inbox.html", {'notifier_messages': Notifier.objects.filter(user=user.userprofile)}) + + +def NotificationView(request, notification_id): + if notification_id == 0: + pass + if request.user.is_authenticated: + user = request.user + else: + return render(request, "dashboard/login.html", {'title': 'Authentication Required'}) + + notification = Notifier.objects.get(id=notification_id) + if not notification.user.user.username == user.username: + return render(request, "dashboard/login.html", {'title': 'Access Denied'}) + + return render(request, "notifier/notification.html", {'notification': notification}) diff --git a/dashboard/src/pharos_dashboard/settings.py b/dashboard/src/pharos_dashboard/settings.py index 8155fd4..7fccb32 100644 --- a/dashboard/src/pharos_dashboard/settings.py +++ b/dashboard/src/pharos_dashboard/settings.py @@ -1,3 +1,11 @@ +############################################################################## +# Copyright (c) 2018 Sawyer Bergeron and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## import os from datetime import timedelta @@ -8,15 +16,18 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # NOTE: os.environ only returns strings, so making a comparison to # 'True' here will convert it to the correct Boolean value. DEBUG = os.environ['DEBUG'] == 'True' +TESTING = os.environ['TEST'] == 'True' # Application definition INSTALLED_APPS = [ 'dashboard', + 'resource_inventory', 'booking', 'account', - 'jenkins', 'notifier', + 'workflow', + 'api', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', @@ -51,6 +62,7 @@ TEMPLATES = [ 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ + 'dashboard.context_processors.debug', 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', @@ -60,6 +72,10 @@ TEMPLATES = [ }, ] +TEMPLATE_CONTEXT_PROCESSORS = [ + 'dashboard.context_processors.debug', +] + WSGI_APPLICATION = 'pharos_dashboard.wsgi.application' # Password validation @@ -128,13 +144,12 @@ DATABASES = { } } - # Rest API Settings REST_FRAMEWORK = { 'DEFAULT_PERMISSION_CLASSES': [ 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly' ], - 'DEFAULT_FILTER_BACKENDS': ('rest_framework.filters.DjangoFilterBackend',), + 'DEFAULT_FILTER_BACKENDS': ('django_filters.rest_framework.FilterSet',), 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.SessionAuthentication', 'rest_framework.authentication.TokenAuthentication', @@ -170,32 +185,20 @@ RABBITMQ_DEFAULT_PASS = os.environ['RABBITMQ_DEFAULT_PASS'] BROKER_URL = 'amqp://' + RABBITMQ_DEFAULT_USER + ':' + RABBITMQ_DEFAULT_PASS + '@rabbitmq:5672//' -BOOKING_EXP_TIME = os.environ['BOOKING_EXPIRE_TIME'] -BOOKING_MAX_NUM = os.environ['BOOKING_MAXIMUM_NUMBER'] - CELERYBEAT_SCHEDULE = { - 'sync-jenkins': { - 'task': 'jenkins.tasks.sync_jenkins', - 'schedule': timedelta(minutes=5) - }, - 'send-booking-notifications': { - 'task': 'notification.tasks.send_booking_notifications', - 'schedule': timedelta(minutes=5) + 'booking_poll': { + 'task': 'dashboard.tasks.booking_poll', + 'schedule': timedelta(minutes=1) }, - 'clean-database': { - 'task': 'dashboard.tasks.database_cleanup', - 'schedule': timedelta(hours=24) + 'free_hosts': { + 'task': 'dashboard.tasks.free_hosts', + 'schedule': timedelta(minutes=1) }, - 'booking_cleanup': { - 'task': 'dashboard.tasks.booking_cleanup', - 'schedule': timedelta(hours=24) + 'conjure_notifiers': { + 'task': 'dashboard.tasks.conjure_aggregate_notifiers', + 'schedule': timedelta(seconds=30) }, } -# Jenkins Settings -ALL_SLAVES_URL = os.environ['JENKINS_URL'] + '/computer/api/json?tree=computer[displayName,offline,idle]' -CI_SLAVES_URL = os.environ['JENKINS_URL'] + '/label/ci-pod/api/json?tree=nodes[nodeName,offline,idle]' -ALL_JOBS_URL = os.environ['JENKINS_URL'] + '/api/json?tree=jobs[displayName,url,lastBuild[fullDisplayName,building,builtOn,timestamp,result]' -GET_SLAVE_URL = os.environ['JENKINS_URL'] + '/computer/' # Notifier Settings EMAIL_HOST = os.environ['EMAIL_HOST'] @@ -204,3 +207,4 @@ EMAIL_HOST_USER = os.environ['EMAIL_HOST_USER'] EMAIL_HOST_PASSWORD = os.environ['EMAIL_HOST_PASSWORD'] EMAIL_USE_TLS=True DEFAULT_EMAIL_FROM = os.environ.get('DEFAULT_EMAIL_FROM', 'webmaster@localhost') +SESSION_ENGINE="django.contrib.sessions.backends.signed_cookies" diff --git a/dashboard/src/pharos_dashboard/urls.py b/dashboard/src/pharos_dashboard/urls.py index adcb5b8..8535bed 100644 --- a/dashboard/src/pharos_dashboard/urls.py +++ b/dashboard/src/pharos_dashboard/urls.py @@ -1,5 +1,6 @@ ############################################################################## # Copyright (c) 2016 Max Breitenfeldt and others. +# Copyright (c) 2018 Sawyer Bergeron, Parker Berberian, and others. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 @@ -30,15 +31,17 @@ from django.contrib import admin urlpatterns = [ + + url(r'^wf/', include('workflow.urls', namespace='workflow')), url(r'^', include('dashboard.urls', namespace='dashboard')), url(r'^booking/', include('booking.urls', namespace='booking')), url(r'^accounts/', include('account.urls', namespace='account')), - + url(r'^resource/', include('resource_inventory.urls', namespace='resource')), url(r'^admin/', admin.site.urls), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), - - url(r'^api/', include('api.urls')) + url(r'^api/', include('api.urls')), + url(r'^messages/', include('notifier.urls', namespace='notifier')) ] if settings.DEBUG is True: - urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \ No newline at end of file + urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/dashboard/src/resource_inventory/__init__.py b/dashboard/src/resource_inventory/__init__.py new file mode 100644 index 0000000..f903394 --- /dev/null +++ b/dashboard/src/resource_inventory/__init__.py @@ -0,0 +1,8 @@ +############################################################################## +# Copyright (c) 2018 Sawyer Bergeron, Parker Berberian, and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## diff --git a/dashboard/src/resource_inventory/admin.py b/dashboard/src/resource_inventory/admin.py new file mode 100644 index 0000000..222877a --- /dev/null +++ b/dashboard/src/resource_inventory/admin.py @@ -0,0 +1,29 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +from django.contrib import admin + +from resource_inventory.models import * + +profiles = [HostProfile, InterfaceProfile, DiskProfile, CpuProfile, RamProfile] + +admin.site.register(profiles) + +generics = [GenericResourceBundle, GenericResource, GenericHost, GenericPod, GenericInterface] + +admin.site.register(generics) + +physical = [Host, Interface, Network, Vlan, ResourceBundle] + +admin.site.register(physical) + +config = [Scenario, Installer, Opsys, ConfigBundle, OPNFVConfig, OPNFVRole, Image, HostConfiguration] + +admin.site.register(config) diff --git a/dashboard/src/resource_inventory/apps.py b/dashboard/src/resource_inventory/apps.py new file mode 100644 index 0000000..79768a7 --- /dev/null +++ b/dashboard/src/resource_inventory/apps.py @@ -0,0 +1,14 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +from django.apps import AppConfig + + +class ResourcesConfig(AppConfig): + name = 'hwresource' diff --git a/dashboard/src/resource_inventory/migrations/0001_initial.py b/dashboard/src/resource_inventory/migrations/0001_initial.py new file mode 100644 index 0000000..d01e8e7 --- /dev/null +++ b/dashboard/src/resource_inventory/migrations/0001_initial.py @@ -0,0 +1,328 @@ +# Generated by Django 2.1 on 2018-09-14 14:48 + +from django.conf import settings +import django.core.validators +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('account', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='ConfigBundle', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('name', models.CharField(max_length=200, unique=True)), + ('description', models.CharField(default='', max_length=1000)), + ], + ), + migrations.CreateModel( + name='CpuProfile', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('cores', models.IntegerField()), + ('architecture', models.CharField(choices=[('x86_64', 'x86_64'), ('aarch64', 'aarch64')], max_length=50)), + ('cpus', models.IntegerField()), + ('cflags', models.TextField(null=True)), + ], + ), + migrations.CreateModel( + name='DiskProfile', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('size', models.IntegerField()), + ('media_type', models.CharField(choices=[('SSD', 'SSD'), ('HDD', 'HDD')], max_length=50)), + ('name', models.CharField(max_length=50)), + ('rotation', models.IntegerField(default=0)), + ('interface', models.CharField(choices=[('sata', 'sata'), ('sas', 'sas'), ('ssd', 'ssd'), ('nvme', 'nvme'), ('scsi', 'scsi'), ('iscsi', 'iscsi')], default='sata', max_length=50)), + ], + ), + migrations.CreateModel( + name='GenericHost', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ], + ), + migrations.CreateModel( + name='GenericInterface', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('host', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='generic_interfaces', to='resource_inventory.GenericHost')), + ], + ), + migrations.CreateModel( + name='GenericResource', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=200, validators=[django.core.validators.RegexValidator(message='Enter a valid hostname. Full domain name may be 1-253 characters, each hostname 1-63 characters (including suffixed dot), and valid characters for hostnames are A-Z, a-z, 0-9, hyphen (-), and underscore (_)', regex='(?=^.{1,253}$)(?=(^([A-Za-z0-9\\-\\_]{1,62}\\.)*[A-Za-z0-9\\-\\_]{1,63}$))')])), + ], + ), + migrations.CreateModel( + name='GenericResourceBundle', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('name', models.CharField(max_length=300, unique=True)), + ('xml', models.TextField()), + ('description', models.CharField(default='', max_length=1000)), + ('lab', models.ForeignKey(null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='account.Lab')), + ('owner', models.ForeignKey(null=True, on_delete=django.db.models.deletion.DO_NOTHING, to=settings.AUTH_USER_MODEL)), + ], + ), + migrations.CreateModel( + name='Host', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('booked', models.BooleanField(default=False)), + ('name', models.CharField(max_length=200, unique=True)), + ('labid', models.CharField(default='default_id', max_length=200)), + ('working', models.BooleanField(default=True)), + ('vendor', models.CharField(default='unknown', max_length=100)), + ('model', models.CharField(default='unknown', max_length=150)), + ], + ), + migrations.CreateModel( + name='HostConfiguration', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('bundle', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='hostConfigurations', to='resource_inventory.ConfigBundle')), + ('host', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='configuration', to='resource_inventory.GenericHost')), + ], + ), + migrations.CreateModel( + name='HostProfile', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('host_type', models.PositiveSmallIntegerField()), + ('name', models.CharField(max_length=200, unique=True)), + ('description', models.TextField()), + ('labs', models.ManyToManyField(related_name='hostprofiles', to='account.Lab')), + ], + ), + migrations.CreateModel( + name='Image', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('lab_id', models.IntegerField()), + ('name', models.CharField(max_length=200)), + ('public', models.BooleanField(default=True)), + ('description', models.TextField()), + ('from_lab', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='account.Lab')), + ('host_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='resource_inventory.HostProfile')), + ('owner', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)), + ], + ), + migrations.CreateModel( + name='Installer', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('name', models.CharField(max_length=200)), + ], + ), + migrations.CreateModel( + name='Interface', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('mac_address', models.CharField(max_length=17)), + ('bus_address', models.CharField(max_length=50)), + ('name', models.CharField(default='eth0', max_length=100)), + ], + ), + migrations.CreateModel( + name='InterfaceProfile', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('speed', models.IntegerField()), + ('name', models.CharField(max_length=100)), + ('nic_type', models.CharField(choices=[('onboard', 'onboard'), ('pcie', 'pcie')], default='onboard', max_length=50)), + ('host', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='interfaceprofile', to='resource_inventory.HostProfile')), + ], + ), + migrations.CreateModel( + name='Network', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('vlan_id', models.IntegerField()), + ('name', models.CharField(max_length=100)), + ], + ), + migrations.CreateModel( + name='OPNFVConfig', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('bundle', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='opnfv_config', to='resource_inventory.ConfigBundle')), + ('installer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='resource_inventory.Installer')), + ], + ), + migrations.CreateModel( + name='OPNFVRole', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('name', models.CharField(max_length=200)), + ('description', models.TextField()), + ], + ), + migrations.CreateModel( + name='Opsys', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('name', models.CharField(max_length=100)), + ('sup_installers', models.ManyToManyField(blank=True, to='resource_inventory.Installer')), + ], + ), + migrations.CreateModel( + name='RamProfile', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('amount', models.IntegerField()), + ('channels', models.IntegerField()), + ('host', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='ramprofile', to='resource_inventory.HostProfile')), + ], + ), + migrations.CreateModel( + name='ResourceBundle', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('template', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='resource_inventory.GenericResourceBundle')), + ], + ), + migrations.CreateModel( + name='Scenario', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('name', models.CharField(max_length=300)), + ], + ), + migrations.CreateModel( + name='Vlan', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('vlan_id', models.IntegerField()), + ('tagged', models.BooleanField()), + ], + ), + migrations.CreateModel( + name='GenericPod', + fields=[ + ('genericresource_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='resource_inventory.GenericResource')), + ], + bases=('resource_inventory.genericresource',), + ), + migrations.AddField( + model_name='opnfvconfig', + name='scenario', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='resource_inventory.Scenario'), + ), + migrations.AddField( + model_name='interface', + name='config', + field=models.ManyToManyField(to='resource_inventory.Vlan'), + ), + migrations.AddField( + model_name='interface', + name='host', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='interfaces', to='resource_inventory.Host'), + ), + migrations.AddField( + model_name='installer', + name='sup_scenarios', + field=models.ManyToManyField(blank=True, to='resource_inventory.Scenario'), + ), + migrations.AddField( + model_name='hostconfiguration', + name='image', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='resource_inventory.Image'), + ), + migrations.AddField( + model_name='hostconfiguration', + name='opnfvRole', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='resource_inventory.OPNFVRole'), + ), + migrations.AddField( + model_name='host', + name='bundle', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='hosts', to='resource_inventory.ResourceBundle'), + ), + migrations.AddField( + model_name='host', + name='config', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='configuration', to='resource_inventory.HostConfiguration'), + ), + migrations.AddField( + model_name='host', + name='lab', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='account.Lab'), + ), + migrations.AddField( + model_name='host', + name='profile', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='resource_inventory.HostProfile'), + ), + migrations.AddField( + model_name='host', + name='template', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='resource_inventory.GenericHost'), + ), + migrations.AddField( + model_name='genericresource', + name='bundle', + field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='generic_resources', to='resource_inventory.GenericResourceBundle'), + ), + migrations.AddField( + model_name='genericinterface', + name='profile', + field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='resource_inventory.InterfaceProfile'), + ), + migrations.AddField( + model_name='genericinterface', + name='vlans', + field=models.ManyToManyField(to='resource_inventory.Vlan'), + ), + migrations.AddField( + model_name='generichost', + name='profile', + field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='resource_inventory.HostProfile'), + ), + migrations.AddField( + model_name='generichost', + name='resource', + field=models.OneToOneField(on_delete=django.db.models.deletion.DO_NOTHING, related_name='generic_host', to='resource_inventory.GenericResource'), + ), + migrations.AddField( + model_name='diskprofile', + name='host', + field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='storageprofile', to='resource_inventory.HostProfile'), + ), + migrations.AddField( + model_name='cpuprofile', + name='host', + field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='cpuprofile', to='resource_inventory.HostProfile'), + ), + migrations.AddField( + model_name='configbundle', + name='bundle', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='resource_inventory.GenericResourceBundle'), + ), + migrations.AddField( + model_name='configbundle', + name='owner', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), + ), + migrations.AddField( + model_name='genericpod', + name='hosts', + field=models.ManyToManyField(to='resource_inventory.GenericHost'), + ), + migrations.AddField( + model_name='genericpod', + name='networks', + field=models.ManyToManyField(to='resource_inventory.Network'), + ), + ] diff --git a/dashboard/src/resource_inventory/migrations/0002_auto_20180919_1459.py b/dashboard/src/resource_inventory/migrations/0002_auto_20180919_1459.py new file mode 100644 index 0000000..80c9e6f --- /dev/null +++ b/dashboard/src/resource_inventory/migrations/0002_auto_20180919_1459.py @@ -0,0 +1,18 @@ +# Generated by Django 2.1 on 2018-09-19 14:59 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('resource_inventory', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='hostprofile', + name='host_type', + field=models.PositiveSmallIntegerField(default=0), + ), + ] diff --git a/dashboard/src/resource_inventory/migrations/0003_vlan_public.py b/dashboard/src/resource_inventory/migrations/0003_vlan_public.py new file mode 100644 index 0000000..07dc647 --- /dev/null +++ b/dashboard/src/resource_inventory/migrations/0003_vlan_public.py @@ -0,0 +1,18 @@ +# Generated by Django 2.1 on 2018-09-26 14:41 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('resource_inventory', '0002_auto_20180919_1459'), + ] + + operations = [ + migrations.AddField( + model_name='vlan', + name='public', + field=models.BooleanField(default=False), + ), + ] diff --git a/dashboard/src/resource_inventory/migrations/__init__.py b/dashboard/src/resource_inventory/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dashboard/src/resource_inventory/models.py b/dashboard/src/resource_inventory/models.py new file mode 100644 index 0000000..b71748e --- /dev/null +++ b/dashboard/src/resource_inventory/models.py @@ -0,0 +1,299 @@ +############################################################################## +# Copyright (c) 2018 Sawyer Bergeron, Parker Berberian, and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +from django.contrib.auth.models import User +from django.db import models +from django.core.validators import RegexValidator + +import re + +from account.models import Lab + + +# profile of resources hosted by labs +class HostProfile(models.Model): + id = models.AutoField(primary_key=True) + host_type = models.PositiveSmallIntegerField(default=0) + name = models.CharField(max_length=200, unique=True) + description = models.TextField() + labs = models.ManyToManyField(Lab, related_name="hostprofiles") + + def validate(self): + validname = re.compile("^[A-Za-z0-9\-\_\.\/\, ]+$") + if not validname.match(self.name): + return "Invalid host profile name given. Name must only use A-Z, a-z, 0-9, hyphens, underscores, dots, commas, or spaces." + else: + return None + + def __str__(self): + return self.name + + +class InterfaceProfile(models.Model): + id = models.AutoField(primary_key=True) + speed = models.IntegerField() + name = models.CharField(max_length=100) + host = models.ForeignKey(HostProfile, on_delete=models.DO_NOTHING, related_name='interfaceprofile') + nic_type = models.CharField(max_length=50, choices=[ + ("onboard", "onboard"), + ("pcie", "pcie") + ], default="onboard") + + def __str__(self): + return self.name + " for " + str(self.host) + + +class DiskProfile(models.Model): + id = models.AutoField(primary_key=True) + size = models.IntegerField() + media_type = models.CharField(max_length=50, choices=[ + ("SSD", "SSD"), + ("HDD", "HDD") + ]) + name = models.CharField(max_length=50) + host = models.ForeignKey(HostProfile, on_delete=models.DO_NOTHING, related_name='storageprofile') + rotation = models.IntegerField(default=0) + interface = models.CharField(max_length=50, choices=[ + ("sata", "sata"), + ("sas", "sas"), + ("ssd", "ssd"), + ("nvme", "nvme"), + ("scsi", "scsi"), + ("iscsi", "iscsi"), + ], default="sata") + + def __str__(self): + return self.name + " for " + str(self.host) + + +class CpuProfile(models.Model): + id = models.AutoField(primary_key=True) + cores = models.IntegerField() + architecture = models.CharField(max_length=50, choices=[ + ("x86_64", "x86_64"), + ("aarch64", "aarch64") + ]) + cpus = models.IntegerField() + host = models.ForeignKey(HostProfile, on_delete=models.DO_NOTHING, related_name='cpuprofile') + cflags = models.TextField(null=True) + + def __str__(self): + return str(self.architecture) + " " + str(self.cpus) + "S" + str(self.cores) + " C for " + str(self.host) + + +class RamProfile(models.Model): + id = models.AutoField(primary_key=True) + amount = models.IntegerField() + channels = models.IntegerField() + host = models.ForeignKey(HostProfile, on_delete=models.DO_NOTHING, related_name='ramprofile') + + def __str__(self): + return str(self.amount) + "G for " + str(self.host) + + +##Networking -- located here due to import order requirements +class Network(models.Model): + id = models.AutoField(primary_key=True) + vlan_id = models.IntegerField() + name = models.CharField(max_length=100) + + def __str__(self): + return self.name + +class Vlan(models.Model): + id = models.AutoField(primary_key=True) + vlan_id = models.IntegerField() + tagged = models.BooleanField() + public = models.BooleanField(default=False) + + def __str__(self): + return str(self.vlan_id) + ("_T" if self.tagged else "") + + +# Generic resource templates +class GenericResourceBundle(models.Model): + id = models.AutoField(primary_key=True) + name = models.CharField(max_length=300, unique=True) + xml = models.TextField() + owner = models.ForeignKey(User, null=True, on_delete=models.DO_NOTHING) + lab = models.ForeignKey(Lab, null=True, on_delete=models.DO_NOTHING) + description = models.CharField(max_length=1000, default="") + + def getHosts(self): + return_hosts = [] + for genericResource in self.generic_resources.all(): + return_hosts.append(genericResource.getHost()) + + return return_hosts + + def __str__(self): + return self.name + + +class GenericResource(models.Model): + bundle = models.ForeignKey(GenericResourceBundle, related_name='generic_resources', on_delete=models.DO_NOTHING) + hostname_validchars = RegexValidator(regex='(?=^.{1,253}$)(?=(^([A-Za-z0-9\-\_]{1,62}\.)*[A-Za-z0-9\-\_]{1,63}$))', message="Enter a valid hostname. Full domain name may be 1-253 characters, each hostname 1-63 characters (including suffixed dot), and valid characters for hostnames are A-Z, a-z, 0-9, hyphen (-), and underscore (_)") + name = models.CharField(max_length=200, validators=[hostname_validchars]) + + def getHost(self): + return self.generic_host + + def __str__(self): + return self.name + + def validate(self): + validname = re.compile('(?=^.{1,253}$)(?=(^([A-Za-z0-9\-\_]{1,62}\.)*[A-Za-z0-9\-\_]{1,63}$))') + if not validname.match(self.name): + return "Enter a valid hostname. Full domain name may be 1-253 characters, each hostname 1-63 characters (including suffixed dot), and valid characters for hostnames are A-Z, a-z, 0-9, hyphen (-), and underscore (_)" + else: + return None + + +# Host template +class GenericHost(models.Model): + id = models.AutoField(primary_key=True) + profile = models.ForeignKey(HostProfile, on_delete=models.DO_NOTHING) + resource = models.OneToOneField(GenericResource, related_name='generic_host', on_delete=models.DO_NOTHING) + + def __str__(self): + return self.resource.name + + +# Physical, actual resources +class ResourceBundle(models.Model): + id = models.AutoField(primary_key=True) + template = models.ForeignKey(GenericResourceBundle, on_delete=models.DO_NOTHING) + + def __str__(self): + return "instance of " + str(self.template) + + +# Networking + + +class GenericInterface(models.Model): + id = models.AutoField(primary_key=True) + vlans = models.ManyToManyField(Vlan) + profile = models.ForeignKey(InterfaceProfile, on_delete=models.DO_NOTHING) + host = models.ForeignKey(GenericHost, on_delete=models.DO_NOTHING, related_name='generic_interfaces') + + def __str__(self): + return "type " + str(self.profile) + " on host " + str(self.host) + + +class Scenario(models.Model): + id = models.AutoField(primary_key=True) + name = models.CharField(max_length=300) + + def __str__(self): + return self.name + +class Installer(models.Model): + id = models.AutoField(primary_key=True) + name = models.CharField(max_length=200) + sup_scenarios = models.ManyToManyField(Scenario, blank=True) + + def __str__(self): + return self.name + +class Opsys(models.Model): + id = models.AutoField(primary_key=True) + name = models.CharField(max_length=100) + sup_installers = models.ManyToManyField(Installer, blank=True) + + def __str__(self): + return self.name + +class ConfigBundle(models.Model): + id = models.AutoField(primary_key=True) + owner = models.ForeignKey(User, on_delete=models.CASCADE) #consider setting to root user? + name = models.CharField(max_length=200, unique=True) + description = models.CharField(max_length=1000, default="") + bundle = models.ForeignKey(GenericResourceBundle, null=True, on_delete=models.CASCADE) + + def __str__(self): + return self.name + +class OPNFVConfig(models.Model): + id = models.AutoField(primary_key=True) + installer = models.ForeignKey(Installer, on_delete=models.CASCADE) + scenario = models.ForeignKey(Scenario, on_delete=models.CASCADE) + bundle = models.ForeignKey(ConfigBundle, related_name="opnfv_config", on_delete=models.CASCADE) + + def __str__(self): + return "OPNFV job with " + str(self.installer) + " and " + str(self.scenario) + +class OPNFVRole(models.Model): + id = models.AutoField(primary_key=True) + name = models.CharField(max_length=200) + description = models.TextField() + + def __str__(self): + return self.name + +class Image(models.Model): + """ + model for representing OS images / snapshots of hosts + """ + id = models.AutoField(primary_key=True) + lab_id = models.IntegerField() # ID the lab who holds this image knows + from_lab = models.ForeignKey(Lab, on_delete=models.CASCADE) + name = models.CharField(max_length=200) + owner = models.ForeignKey(User, null=True, on_delete=models.SET_NULL) + public = models.BooleanField(default=True) + host_type = models.ForeignKey(HostProfile, on_delete=models.CASCADE) #may need to change to models.SET() once images are transferrable between compatible host types + description = models.TextField() + + def __str__(self): + return self.name + +class HostConfiguration(models.Model): + """ + model to represent a complete configuration for a single + physical host + """ + id = models.AutoField(primary_key=True) + host = models.ForeignKey(GenericHost, related_name="configuration", on_delete=models.CASCADE) + image = models.ForeignKey(Image, on_delete=models.PROTECT) + bundle = models.ForeignKey(ConfigBundle, related_name="hostConfigurations", null=True, on_delete=models.CASCADE) + opnfvRole = models.ForeignKey(OPNFVRole, on_delete=models.PROTECT) #need protocol for phasing out a role if we are going to allow that to happen + + def __str__(self): + return "config with " + str(self.host) + " and image " + str(self.image) + + +# Concrete host, actual machine in a lab +class Host(models.Model): + id = models.AutoField(primary_key=True) + template = models.ForeignKey(GenericHost, on_delete=models.SET_NULL, null=True) + booked = models.BooleanField(default=False) + name = models.CharField(max_length=200, unique=True) + bundle = models.ForeignKey(ResourceBundle, related_name='hosts', on_delete=models.SET_NULL, null=True) + config = models.ForeignKey(HostConfiguration, null=True, related_name="configuration", on_delete=models.SET_NULL) + labid = models.CharField(max_length=200, default="default_id") + profile = models.ForeignKey(HostProfile, on_delete=models.CASCADE) + lab = models.ForeignKey(Lab, on_delete=models.CASCADE) + working = models.BooleanField(default=True) + vendor = models.CharField(max_length=100, default="unknown") + model = models.CharField(max_length=150, default="unknown") + + def __str__(self): + return self.name + + +class Interface(models.Model): + id = models.AutoField(primary_key=True) + mac_address = models.CharField(max_length=17) + bus_address = models.CharField(max_length=50) + name = models.CharField(max_length=100, default="eth0") + config = models.ManyToManyField(Vlan) + host = models.ForeignKey(Host, on_delete=models.CASCADE, related_name='interfaces') + + def __str__(self): + return self.mac_address + " on host " + str(self.host) diff --git a/dashboard/src/resource_inventory/resource_manager.py b/dashboard/src/resource_inventory/resource_manager.py new file mode 100644 index 0000000..cd70867 --- /dev/null +++ b/dashboard/src/resource_inventory/resource_manager.py @@ -0,0 +1,197 @@ +############################################################################## +# Copyright (c) 2018 Parker Berberian, Sawyer Bergeron, and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +from django.core.exceptions import * +from django.template.loader import render_to_string + +import booking +from dashboard.exceptions import * +from resource_inventory.models import * + +class ResourceManager: + + instance = None + + def __init__(self): + pass + + @staticmethod + def getInstance(): + if ResourceManager.instance is None: + ResourceManager.instance = ResourceManager() + return ResourceManager.instance + + #public interface + def deleteResourceBundle(self, resourceBundle): + for host in Host.objects.filter(bundle=resourceBundle): + self.releaseHost(host) + resourceBundle.delete() + + def convertResourceBundle(self, genericResourceBundle, lab=None, config=None): + """ + Takes in a GenericResourceBundle and 'converts' it into a ResourceBundle + """ + resource_bundle = ResourceBundle() + resource_bundle.template = genericResourceBundle + resource_bundle.save() + + hosts = genericResourceBundle.getHosts() + + #current supported case: user creating new booking + #currently unsupported: editing existing booking + + physical_hosts = [] + + for host in hosts: + host_config=None + if config: + host_config = HostConfiguration.objects.get(bundle=config, host=host) + try: + physical_host = self.acquireHost(host, genericResourceBundle.lab.name) + except ResourceAvailabilityException: + self.fail_acquire(physical_hosts) + raise ResourceAvailabilityException("Could not provision hosts, not enough available") + try: + physical_host.bundle = resource_bundle + physical_host.template = host + physical_host.config = host_config + physical_hosts.append(physical_host) + + self.configureNetworking(physical_host) + except: + self.fail_acquire(physical_hosts) + raise ResourceProvisioningException("Network configuration failed.") + try: + physical_host.save() + except: + self.fail_acquire(physical_hosts) + raise ModelValidationException("Saving hosts failed") + + return resource_bundle + + def configureNetworking(self, host): + generic_interfaces = list(host.template.generic_interfaces.all()) + for int_num, physical_interface in enumerate(host.interfaces.all()): + generic_interface = generic_interfaces[int_num] + physical_interface.config.clear() + for vlan in generic_interface.vlans.all(): + physical_interface.config.add(vlan) + + #private interface + def acquireHost(self, genericHost, labName): + host_full_set = Host.objects.filter(lab__name__exact=labName, profile=genericHost.profile) + if not host_full_set.first(): + raise ResourceExistenceException("No matching servers found") + host_set = host_full_set.filter(booked=False) + if not host_set.first(): + raise ResourceAvailabilityException("No unbooked hosts match requested hosts") + host = host_set.first() + host.booked = True + host.template = genericHost + host.save() + return host + + def releaseHost(self, host): + host.template = None + host.bundle = None + host.booked = False + host.save() + + def fail_acquire(self, hosts): + for host in hosts: + self.releaseHost(host) + + def makePDF(self, resource): + """ + fills the pod descriptor file template with info about the resource + """ + template = "dashboard/pdf.yaml" + info = {} + info['details'] = self.get_pdf_details(resource) + info['jumphost'] = self.get_pdf_jumphost(resource) + info['nodes'] = self.get_pdf_nodes(resource) + + return render_to_string(template, context=info) + + def get_pdf_details(self, resource): + details = {} + owner = "Anon" + email = "email@mail.com" + resource_lab = resource.template.lab + lab = resource_lab.name + location = resource_lab.location + pod_type = "development" + link = "https://wiki.opnfv.org/display/INF/Pharos+Laas" + + try: + # try to get more specific info that may fail, we dont care if it does + booking_owner = booking.models.Booking.objects.get(resource=resource).owner + owner = booking_owner.username + email = booking_owner.userprofile.email_addr + except Exception as e: + pass + + details['owner'] = owner + details['email'] = email + details['lab'] = lab + details['location'] = location + details['type'] = pod_type + details['link'] = link + + return details + + def get_pdf_jumphost(self, resource): + jumphost = Host.objects.get(bundle=resource, config__opnfvRole__name__iexact="jumphost") + return self.get_pdf_host(jumphost) + + def get_pdf_nodes(self, resource): + pdf_nodes = [] + nodes = Host.objects.filter(bundle=resource).exclude(config__opnfvRole__name__iexact="jumphost") + for node in nodes: + pdf_nodes.append(self.get_pdf_host(node)) + + return pdf_nodes + + + def get_pdf_host(self, host): + host_info = {} + host_info['name'] = host.template.resource.name + host_info['node'] = {} + host_info['node']['type'] = "baremetal" + host_info['node']['vendor'] = host.vendor + host_info['node']['model'] = host.model + host_info['node']['arch'] = host.profile.cpuprofile.first().architecture + host_info['node']['cpus'] = host.profile.cpuprofile.first().cpus + host_info['node']['cores'] = host.profile.cpuprofile.first().cores + cflags = host.profile.cpuprofile.first().cflags + if cflags and cflags.strip(): + host_info['node']['cpu_cflags'] = cflags + host_info['node']['memory'] = str(host.profile.ramprofile.first().amount) + "G" + host_info['disks'] = [] + for disk in host.profile.storageprofile.all(): + disk_info = {} + disk_info['name'] = disk.name + disk_info['capacity'] = str(disk.size) + "G" + disk_info['type'] = disk.media_type + disk_info['interface'] = disk.interface + disk_info['rotation'] = disk.rotation + host_info['disks'].append(disk_info) + + host_info['interfaces'] = [] + for interface in host.interfaces.all(): + iface_info = {} + iface_info['name'] = interface.name + iface_info['address'] = "unknown" + iface_info['mac_address'] = interface.mac_address + vlans = "|".join([str(vlan.vlan_id) for vlan in interface.config.all()]) + iface_info['vlans'] = vlans + host_info['interfaces'].append(iface_info) + + return host_info diff --git a/dashboard/src/resource_inventory/tests/test_managers.py b/dashboard/src/resource_inventory/tests/test_managers.py new file mode 100644 index 0000000..5a13b2e --- /dev/null +++ b/dashboard/src/resource_inventory/tests/test_managers.py @@ -0,0 +1,236 @@ +############################################################################## +# Copyright (c) 2018 Parker Berberian, Sawyer Bergeron, and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +from django.test import TestCase +from django.contrib.auth.models import User + +from resource.inventory_manager import InventoryManager +from resource.resource_manager import ResourceManager +from resource.models import * + + +class InventoryManagerTestCase(TestCase): + + def test_singleton(self): + instance = InventoryManager.getInstance() + self.assertTrue(isinstance(instance, InventoryManager)) + self.assertTrue(instance is InventoryManager.getInstance()) + + def setUp(self): + # setup + # create lab and give it resources + user = User.objects.create(username="username") + self.lab = Lab.objects.create( + lab_user=user, + name='test lab', + contact_email='someone@email.com', + contact_phone='dont call me' + ) + + # create hostProfile + hostProfile = HostProfile.objects.create( + host_type=0, + name='Test profile', + description='a test profile' + ) + interfaceProfile = InterfaceProfile.objects.create( + speed=1000, + name='eno3', + host=hostProfile + ) + diskProfile = DiskProfile.objects.create( + size=1000, + media_type="SSD", + name='/dev/sda', + host=hostProfile + ) + cpuProfile = CpuProfile.objects.create( + cores=96, + architecture="x86_64", + cpus=2, + host=hostProfile + ) + ramProfile = RamProfile.objects.create( + amount=256, + channels=4, + host=hostProfile + ) + + #create GenericResourceBundle + genericBundle = GenericResourceBundle.objects.create() + + self.gHost1 = GenericHost.objects.create( + bundle=genericBundle, + name='generic host 1', + profile=hostProfile + ) + self.gHost2 = GenericHost.objects.create( + bundle=genericBundle, + name='generic host 2', + profile=hostProfile + ) + + #actual resource bundle + bundle = ResourceBundle.objects.create(template=genericBundle) + + self.host1 = Host.objects.create( + template=self.gHost1, + booked=True, + name='host1', + bundle=bundle, + profile=hostProfile, + lab=self.lab + ) + + self.host2 = Host.objects.create( + template=self.gHost2, + booked=True, + name='host2', + bundle=bundle, + profile=hostProfile, + lab=self.lab + ) + + vlan1 = Vlan.objects.create(vlan_id=300, tagged=False) + vlan2 = Vlan.objects.create(vlan_id=300, tagged=False) + + iface1 = Interface.objects.create( + mac_address='00:11:22:33:44:55', + bus_address='some bus address', + switch_name='switch1', + port_name='port10', + config=vlan1, + host=self.host1 + ) + iface2 = Interface.objects.create( + mac_address='00:11:22:33:44:56', + bus_address='some bus address', + switch_name='switch1', + port_name='port12', + config=vlan2, + host=self.host2 + ) + + def test_acquire_host(self): + host = InventoryManager.getInstance().acquireHost(self.gHost1, self.lab.name) + self.assertNotEquals(host, None) + self.assertTrue(host.booked) + self.assertEqual(host.template, self.gHost1) + + def test_release_host(self): + host = InventoryManager.getInstance().acquireHost(self.gHost1, self.lab.name) + self.assertTrue(host.booked) + InventoryManager.getInstance().releaseHost(host) + self.assertFalse(host.booked) + + +class ResourceManagerTestCase(TestCase): + def test_singleton(self): + instance = ResourceManager.getInstance() + self.assertTrue(isinstance(instance, ResourceManager)) + self.assertTrue(instance is ResourceManager.getInstance()) + + def setUp(self): + # setup + # create lab and give it resources + user = User.objects.create(username="username") + self.lab = Lab.objects.create( + lab_user=user, + name='test lab', + contact_email='someone@email.com', + contact_phone='dont call me' + ) + + # create hostProfile + hostProfile = HostProfile.objects.create( + host_type=0, + name='Test profile', + description='a test profile' + ) + interfaceProfile = InterfaceProfile.objects.create( + speed=1000, + name='eno3', + host=hostProfile + ) + diskProfile = DiskProfile.objects.create( + size=1000, + media_type="SSD", + name='/dev/sda', + host=hostProfile + ) + cpuProfile = CpuProfile.objects.create( + cores=96, + architecture="x86_64", + cpus=2, + host=hostProfile + ) + ramProfile = RamProfile.objects.create( + amount=256, + channels=4, + host=hostProfile + ) + + #create GenericResourceBundle + genericBundle = GenericResourceBundle.objects.create() + + self.gHost1 = GenericHost.objects.create( + bundle=genericBundle, + name='generic host 1', + profile=hostProfile + ) + self.gHost2 = GenericHost.objects.create( + bundle=genericBundle, + name='generic host 2', + profile=hostProfile + ) + + #actual resource bundle + bundle = ResourceBundle.objects.create(template=genericBundle) + + self.host1 = Host.objects.create( + template=self.gHost1, + booked=True, + name='host1', + bundle=bundle, + profile=hostProfile, + lab=self.lab + ) + + self.host2 = Host.objects.create( + template=self.gHost2, + booked=True, + name='host2', + bundle=bundle, + profile=hostProfile, + lab=self.lab + ) + + vlan1 = Vlan.objects.create(vlan_id=300, tagged=False) + vlan2 = Vlan.objects.create(vlan_id=300, tagged=False) + + iface1 = Interface.objects.create( + mac_address='00:11:22:33:44:55', + bus_address='some bus address', + switch_name='switch1', + port_name='port10', + config=vlan1, + host=self.host1 + ) + iface2 = Interface.objects.create( + mac_address='00:11:22:33:44:56', + bus_address='some bus address', + switch_name='switch1', + port_name='port12', + config=vlan2, + host=self.host2 + ) + + def test_convert_bundle(self): + bundle = ResourceManager.getInstance().convertResoureBundle(self.genericBundle, self.lab.name) + # verify bundle configuration diff --git a/dashboard/src/resource_inventory/tests/test_models.py b/dashboard/src/resource_inventory/tests/test_models.py new file mode 100644 index 0000000..4ddedf2 --- /dev/null +++ b/dashboard/src/resource_inventory/tests/test_models.py @@ -0,0 +1,162 @@ +############################################################################## +# Copyright (c) 2018 Parker Berberian, Sawyer Bergeron, and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +from django.test import TestCase +from django.contrib.auth.models import User +from account.models import Lab +from resource_inventory.models import * + + +class ConfigUtil(): + count=0 + + @staticmethod + def makeScenario(): + return Scenario.objects.create(name="testScenario") + + @staticmethod + def makeInstaller(): + inst = Installer.objects.create( + name = "testInstaller" + ) + inst.sup_scenarios = [ConfigUtil.makeScenario()] + return inst + + @staticmethod + def makeOpsys(): + os = Opsys.objects.create( + name = "test Operating System" + ) + os.sup_installers = [ConfigUtil.makeInstaller()] + return os + + @staticmethod + def makeConfigBundle(): + user = User.objects.create(username="test_user" + str(ConfigUtil.count)) + ConfigUtil.count += 1 + return ConfigBundle.objects.create( + owner = user + ) + + @staticmethod + def makeOPNFVConfig(): + installer = ConfigUtil.makeInstaller() + scenario = ConfigUtil.makeScenario() + bundle = ConfigUtil.makeConfigBundle() + return OPNFVConfig.objects.create( + installer=installer, + scenario=scenario, + bundle=bundle + ) + + @staticmethod + def makeOPNFVRole(): + return OPNFVRole.objects.create( + name="Test role", + description="This is a test role" + ) + + @staticmethod + def makeImage(): + owner = User.objects.create(username="another test user") + lab_user = User.objects.create(username="labUserForTests") + lab = Lab.objects.create( + lab_user=lab_user, + name="this is lab for testing", + contact_email="email@mail.com", + contact_phone="123-4567" + ) + + return Image.objects.create( + lab_id=0, + from_lab=lab, + name="an image for testing", + owner=owner + ) + + + @staticmethod + def makeGenericHost(): + profile = HostProfile.objects.create( + host_type=0, + name="test lab for config bundle", + description="this is a test profile" + ) + user = User.objects.create(username="test sample user 12") + bundle = GenericResourceBundle.objects.create( + name="Generic bundle for config tests", + xml="", + owner=user, + description="" + ) + + resource = GenericResource.objects.create( + bundle=bundle, + name="a test generic resource" + ) + + return GenericHost.objects.create( + profile=profile, + resource=resource + ) + + @staticmethod + def makeHostConfiguration(): + host = ConfigUtil.makeGenericHost() + image = ConfigUtil.makeImage() + bundle = ConfigUtil.makeConfigBundle() + opnfvRole = ConfigUtil.makeOPNFVRole() + return HostConfiguration.objects.create( + host=host, + image=image, + bundle=bundle, + opnfvRole=opnfvRole + ) + + +class ScenarioTestCase(TestCase): + + def test_save(self): + self.assertTrue(ConfigUtil.makeScenario()) + +class InstallerTestCase(TestCase): + + def test_save(self): + self.assertTrue(ConfigUtil.makeInstaller()) + +class OperatingSystemTestCase(TestCase): + + def test_save(self): + self.assertTrue(ConfigUtil.makeOpsys()) + +class ConfigBundleTestCase(TestCase): + + def test_save(self): + self.assertTrue(ConfigUtil.makeConfigBundle()) + +class OPNFVConfigTestCase(TestCase): + + def test_save(self): + self.assertTrue(ConfigUtil.makeOPNFVConfig()) + +class OPNFVRoleTestCase(TestCase): + + def test_save(self): + self.assertTrue(ConfigUtil.makeOPNFVRole()) + + +class HostConfigurationTestCase(TestCase): + + def test_save(self): + self.assertTrue(ConfigUtil.makeHostConfiguration()) + + +class ImageTestCase(TestCase): + + def test_save(self): + self.assertTrue(ConfigUtil.makeImage()) diff --git a/dashboard/src/resource_inventory/urls.py b/dashboard/src/resource_inventory/urls.py new file mode 100644 index 0000000..4e159ba --- /dev/null +++ b/dashboard/src/resource_inventory/urls.py @@ -0,0 +1,34 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# Copyright (c) 2018 Parker Berberian, Sawyer Bergeron, and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +"""pharos_dashboard URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/1.10/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.conf.urls import url, include + 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) +""" +from django.conf.urls import url +from resource_inventory.views import HostView + + +app_name = "resource" +urlpatterns = [ + url(r'^hosts$', HostView.as_view(), name='hosts') +] diff --git a/dashboard/src/resource_inventory/views.py b/dashboard/src/resource_inventory/views.py new file mode 100644 index 0000000..7e73006 --- /dev/null +++ b/dashboard/src/resource_inventory/views.py @@ -0,0 +1,24 @@ +############################################################################## +# Copyright (c) 2018 Sawyer Bergeron, Parker Berberian, and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +from django.shortcuts import render +from django.views import View +from django.views.generic import TemplateView + +from resource_inventory.models import Host + +class HostView(TemplateView): + template_name = "resource/hosts.html" + + def get_context_data(self, **kwargs): + context = super(HostView, self).get_context_data(**kwargs) + hosts = Host.objects.filter(working=True) + context.update({'hosts':hosts, 'title':"Hardware Resources"}) + return context diff --git a/dashboard/src/static/css/graph_common.css b/dashboard/src/static/css/graph_common.css new file mode 100644 index 0000000..7f90a66 --- /dev/null +++ b/dashboard/src/static/css/graph_common.css @@ -0,0 +1,162 @@ +div.mxRubberband { + position: absolute; + overflow: hidden; + border-style: solid; + border-width: 1px; + border-color: #0000FF; + background: #0077FF; +} +.mxCellEditor { + background: url(data:image/gif;base64,R0lGODlhMAAwAIAAAP///wAAACH5BAEAAAAALAAAAAAwADAAAAIxhI+py+0Po5y02ouz3rz7D4biSJbmiabqyrbuC8fyTNf2jef6zvf+DwwKh8Si8egpAAA7); + _background: url('/static/img/mxgraph/transparent.gif'); + border-color: transparent; + border-style: solid; + display: inline-block; + position: absolute; + overflow: visible; + word-wrap: normal; + border-width: 0; + min-width: 1px; + resize: none; + padding: 0px; + margin: 0px; +} +.mxPlainTextEditor * { + padding: 0px; + margin: 0px; +} +div.mxWindow { + -webkit-box-shadow: 3px 3px 12px #C0C0C0; + -moz-box-shadow: 3px 3px 12px #C0C0C0; + box-shadow: 3px 3px 12px #C0C0C0; + background: url('../img/mxgraph/window.gif'); + border:1px solid #c3c3c3; + position: absolute; + overflow: hidden; + z-index: 3; +} +table.mxWindow { + border-collapse: collapse; + table-layout: fixed; + font-family: Arial; + font-size: 8pt; +} +td.mxWindowTitle { + background: url('/static/img/mxgraph/window-title.gif') repeat-x; + text-overflow: ellipsis; + white-space: nowrap; + text-align: center; + font-weight: bold; + overflow: hidden; + height: 13px; + padding: 2px; + padding-top: 4px; + padding-bottom: 6px; + color: black; +} +td.mxWindowPane { + vertical-align: top; + padding: 0px; +} +div.mxWindowPane { + overflow: hidden; + position: relative; +} +td.mxWindowPane td { + font-family: Arial; + font-size: 8pt; +} +td.mxWindowPane input, td.mxWindowPane select, td.mxWindowPane textarea, td.mxWindowPane radio { + border-color: #8C8C8C; + border-style: solid; + border-width: 1px; + font-family: Arial; + font-size: 8pt; + padding: 1px; +} +td.mxWindowPane button { + background: url('/static/img/mxgraph/button.gif') repeat-x; + font-family: Arial; + font-size: 8pt; + padding: 2px; + float: left; +} +img.mxToolbarItem { + margin-right: 6px; + margin-bottom: 6px; + border-width: 1px; +} +select.mxToolbarCombo { + vertical-align: top; + border-style: inset; + border-width: 2px; +} +div.mxToolbarComboContainer { + padding: 2px; +} +img.mxToolbarMode { + margin: 2px; + margin-right: 4px; + margin-bottom: 4px; + border-width: 0px; +} +img.mxToolbarModeSelected { + margin: 0px; + margin-right: 2px; + margin-bottom: 2px; + border-width: 2px; + border-style: inset; +} +div.mxTooltip { + -webkit-box-shadow: 3px 3px 12px #C0C0C0; + -moz-box-shadow: 3px 3px 12px #C0C0C0; + box-shadow: 3px 3px 12px #C0C0C0; + background: #FFFFCC; + border-style: solid; + border-width: 1px; + border-color: black; + font-family: Arial; + font-size: 8pt; + position: absolute; + cursor: default; + padding: 4px; + color: black; +} +div.mxPopupMenu { + -webkit-box-shadow: 3px 3px 12px #C0C0C0; + -moz-box-shadow: 3px 3px 12px #C0C0C0; + box-shadow: 3px 3px 12px #C0C0C0; + background: url('/static/img/mxgraph/window.gif'); + position: absolute; + border-style: solid; + border-width: 1px; + border-color: black; +} +table.mxPopupMenu { + border-collapse: collapse; + margin-top: 1px; + margin-bottom: 1px; +} +tr.mxPopupMenuItem { + color: black; + cursor: pointer; +} +tr.mxPopupMenuItemHover { + background-color: #000066; + color: #FFFFFF; + cursor: pointer; +} +td.mxPopupMenuItem { + padding: 2px 30px 2px 10px; + white-space: nowrap; + font-family: Arial; + font-size: 8pt; +} +td.mxPopupMenuIcon { + background-color: #D0D0D0; + padding: 2px 4px 2px 4px; +} +.mxDisabled { + opacity: 0.2 !important; + cursor:default !important; +} diff --git a/dashboard/src/static/css/theme.css b/dashboard/src/static/css/theme.css index bd15637..fb350e2 100644 --- a/dashboard/src/static/css/theme.css +++ b/dashboard/src/static/css/theme.css @@ -10,4 +10,10 @@ .modal p { word-wrap: break-word; +} + +.create_drop { + display: none; + width: 100%; + } \ No newline at end of file diff --git a/dashboard/src/static/img/mxgraph/add.png b/dashboard/src/static/img/mxgraph/add.png new file mode 100644 index 0000000..bf5f8ed Binary files /dev/null and b/dashboard/src/static/img/mxgraph/add.png differ diff --git a/dashboard/src/static/img/mxgraph/button.gif b/dashboard/src/static/img/mxgraph/button.gif new file mode 100644 index 0000000..ad55cab Binary files /dev/null and b/dashboard/src/static/img/mxgraph/button.gif differ diff --git a/dashboard/src/static/img/mxgraph/camera.png b/dashboard/src/static/img/mxgraph/camera.png new file mode 100644 index 0000000..aecc94d Binary files /dev/null and b/dashboard/src/static/img/mxgraph/camera.png differ diff --git a/dashboard/src/static/img/mxgraph/check.png b/dashboard/src/static/img/mxgraph/check.png new file mode 100644 index 0000000..ce81bce Binary files /dev/null and b/dashboard/src/static/img/mxgraph/check.png differ diff --git a/dashboard/src/static/img/mxgraph/close.gif b/dashboard/src/static/img/mxgraph/close.gif new file mode 100644 index 0000000..1069e94 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/close.gif differ diff --git a/dashboard/src/static/img/mxgraph/close.png b/dashboard/src/static/img/mxgraph/close.png new file mode 100644 index 0000000..4de4396 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/close.png differ diff --git a/dashboard/src/static/img/mxgraph/collapsed.gif b/dashboard/src/static/img/mxgraph/collapsed.gif new file mode 100644 index 0000000..0276444 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/collapsed.gif differ diff --git a/dashboard/src/static/img/mxgraph/connector.gif b/dashboard/src/static/img/mxgraph/connector.gif new file mode 100644 index 0000000..326e061 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/connector.gif differ diff --git a/dashboard/src/static/img/mxgraph/copy.png b/dashboard/src/static/img/mxgraph/copy.png new file mode 100644 index 0000000..a987d43 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/copy.png differ diff --git a/dashboard/src/static/img/mxgraph/cut.png b/dashboard/src/static/img/mxgraph/cut.png new file mode 100644 index 0000000..52bf944 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/cut.png differ diff --git a/dashboard/src/static/img/mxgraph/delete2.png b/dashboard/src/static/img/mxgraph/delete2.png new file mode 100644 index 0000000..be78c61 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/delete2.png differ diff --git a/dashboard/src/static/img/mxgraph/dot.gif b/dashboard/src/static/img/mxgraph/dot.gif new file mode 100644 index 0000000..08b9947 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/dot.gif differ diff --git a/dashboard/src/static/img/mxgraph/error.gif b/dashboard/src/static/img/mxgraph/error.gif new file mode 100644 index 0000000..14e1aee Binary files /dev/null and b/dashboard/src/static/img/mxgraph/error.gif differ diff --git a/dashboard/src/static/img/mxgraph/expanded.gif b/dashboard/src/static/img/mxgraph/expanded.gif new file mode 100644 index 0000000..3767b0b Binary files /dev/null and b/dashboard/src/static/img/mxgraph/expanded.gif differ diff --git a/dashboard/src/static/img/mxgraph/export1.png b/dashboard/src/static/img/mxgraph/export1.png new file mode 100644 index 0000000..b8a01b8 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/export1.png differ diff --git a/dashboard/src/static/img/mxgraph/fit_to_size.png b/dashboard/src/static/img/mxgraph/fit_to_size.png new file mode 100644 index 0000000..4de46b0 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/fit_to_size.png differ diff --git a/dashboard/src/static/img/mxgraph/gradient_background.jpg b/dashboard/src/static/img/mxgraph/gradient_background.jpg new file mode 100644 index 0000000..7dbf35b Binary files /dev/null and b/dashboard/src/static/img/mxgraph/gradient_background.jpg differ diff --git a/dashboard/src/static/img/mxgraph/green-dot.gif b/dashboard/src/static/img/mxgraph/green-dot.gif new file mode 100644 index 0000000..acaf7b2 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/green-dot.gif differ diff --git a/dashboard/src/static/img/mxgraph/group.png b/dashboard/src/static/img/mxgraph/group.png new file mode 100644 index 0000000..585ad79 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/group.png differ diff --git a/dashboard/src/static/img/mxgraph/handle-connect.png b/dashboard/src/static/img/mxgraph/handle-connect.png new file mode 100644 index 0000000..513ab2b Binary files /dev/null and b/dashboard/src/static/img/mxgraph/handle-connect.png differ diff --git a/dashboard/src/static/img/mxgraph/handle-main.png b/dashboard/src/static/img/mxgraph/handle-main.png new file mode 100644 index 0000000..ee067ff Binary files /dev/null and b/dashboard/src/static/img/mxgraph/handle-main.png differ diff --git a/dashboard/src/static/img/mxgraph/icons48/column.png b/dashboard/src/static/img/mxgraph/icons48/column.png new file mode 100644 index 0000000..5ae2c24 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/icons48/column.png differ diff --git a/dashboard/src/static/img/mxgraph/icons48/earth.png b/dashboard/src/static/img/mxgraph/icons48/earth.png new file mode 100644 index 0000000..4493880 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/icons48/earth.png differ diff --git a/dashboard/src/static/img/mxgraph/icons48/gear.png b/dashboard/src/static/img/mxgraph/icons48/gear.png new file mode 100644 index 0000000..647d897 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/icons48/gear.png differ diff --git a/dashboard/src/static/img/mxgraph/icons48/keys.png b/dashboard/src/static/img/mxgraph/icons48/keys.png new file mode 100644 index 0000000..41828e4 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/icons48/keys.png differ diff --git a/dashboard/src/static/img/mxgraph/icons48/mail_new.png b/dashboard/src/static/img/mxgraph/icons48/mail_new.png new file mode 100644 index 0000000..16c6662 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/icons48/mail_new.png differ diff --git a/dashboard/src/static/img/mxgraph/icons48/server.png b/dashboard/src/static/img/mxgraph/icons48/server.png new file mode 100644 index 0000000..9621c6e Binary files /dev/null and b/dashboard/src/static/img/mxgraph/icons48/server.png differ diff --git a/dashboard/src/static/img/mxgraph/icons48/table.png b/dashboard/src/static/img/mxgraph/icons48/table.png new file mode 100644 index 0000000..d4df646 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/icons48/table.png differ diff --git a/dashboard/src/static/img/mxgraph/key.png b/dashboard/src/static/img/mxgraph/key.png new file mode 100644 index 0000000..e66758a Binary files /dev/null and b/dashboard/src/static/img/mxgraph/key.png differ diff --git a/dashboard/src/static/img/mxgraph/loading.gif b/dashboard/src/static/img/mxgraph/loading.gif new file mode 100644 index 0000000..118f4b0 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/loading.gif differ diff --git a/dashboard/src/static/img/mxgraph/maximize.gif b/dashboard/src/static/img/mxgraph/maximize.gif new file mode 100644 index 0000000..e27cf3e Binary files /dev/null and b/dashboard/src/static/img/mxgraph/maximize.gif differ diff --git a/dashboard/src/static/img/mxgraph/minimize.gif b/dashboard/src/static/img/mxgraph/minimize.gif new file mode 100644 index 0000000..1e95e7c Binary files /dev/null and b/dashboard/src/static/img/mxgraph/minimize.gif differ diff --git a/dashboard/src/static/img/mxgraph/navigate_minus.png b/dashboard/src/static/img/mxgraph/navigate_minus.png new file mode 100644 index 0000000..71edaf9 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/navigate_minus.png differ diff --git a/dashboard/src/static/img/mxgraph/navigate_plus.png b/dashboard/src/static/img/mxgraph/navigate_plus.png new file mode 100644 index 0000000..b5b7e87 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/navigate_plus.png differ diff --git a/dashboard/src/static/img/mxgraph/normalize.gif b/dashboard/src/static/img/mxgraph/normalize.gif new file mode 100644 index 0000000..34a8d30 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/normalize.gif differ diff --git a/dashboard/src/static/img/mxgraph/paste.png b/dashboard/src/static/img/mxgraph/paste.png new file mode 100644 index 0000000..fd628d9 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/paste.png differ diff --git a/dashboard/src/static/img/mxgraph/plus.png b/dashboard/src/static/img/mxgraph/plus.png new file mode 100644 index 0000000..24a84bb Binary files /dev/null and b/dashboard/src/static/img/mxgraph/plus.png differ diff --git a/dashboard/src/static/img/mxgraph/point.gif b/dashboard/src/static/img/mxgraph/point.gif new file mode 100644 index 0000000..9074c39 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/point.gif differ diff --git a/dashboard/src/static/img/mxgraph/press32.png b/dashboard/src/static/img/mxgraph/press32.png new file mode 100644 index 0000000..f00e3f7 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/press32.png differ diff --git a/dashboard/src/static/img/mxgraph/print32.png b/dashboard/src/static/img/mxgraph/print32.png new file mode 100644 index 0000000..0cca86c Binary files /dev/null and b/dashboard/src/static/img/mxgraph/print32.png differ diff --git a/dashboard/src/static/img/mxgraph/printer.png b/dashboard/src/static/img/mxgraph/printer.png new file mode 100644 index 0000000..6004816 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/printer.png differ diff --git a/dashboard/src/static/img/mxgraph/redo.png b/dashboard/src/static/img/mxgraph/redo.png new file mode 100644 index 0000000..3eae59c Binary files /dev/null and b/dashboard/src/static/img/mxgraph/redo.png differ diff --git a/dashboard/src/static/img/mxgraph/resize.gif b/dashboard/src/static/img/mxgraph/resize.gif new file mode 100644 index 0000000..ff558db Binary files /dev/null and b/dashboard/src/static/img/mxgraph/resize.gif differ diff --git a/dashboard/src/static/img/mxgraph/separator.gif b/dashboard/src/static/img/mxgraph/separator.gif new file mode 100644 index 0000000..5c1b895 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/separator.gif differ diff --git a/dashboard/src/static/img/mxgraph/sidebar_bg.gif b/dashboard/src/static/img/mxgraph/sidebar_bg.gif new file mode 100644 index 0000000..67e8244 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/sidebar_bg.gif differ diff --git a/dashboard/src/static/img/mxgraph/spacer.gif b/dashboard/src/static/img/mxgraph/spacer.gif new file mode 100644 index 0000000..35d42e8 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/spacer.gif differ diff --git a/dashboard/src/static/img/mxgraph/submenu.gif b/dashboard/src/static/img/mxgraph/submenu.gif new file mode 100644 index 0000000..ffe7617 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/submenu.gif differ diff --git a/dashboard/src/static/img/mxgraph/toolbar_bg.gif b/dashboard/src/static/img/mxgraph/toolbar_bg.gif new file mode 100644 index 0000000..87b9374 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/toolbar_bg.gif differ diff --git a/dashboard/src/static/img/mxgraph/transparent.gif b/dashboard/src/static/img/mxgraph/transparent.gif new file mode 100644 index 0000000..76040f2 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/transparent.gif differ diff --git a/dashboard/src/static/img/mxgraph/undo.png b/dashboard/src/static/img/mxgraph/undo.png new file mode 100644 index 0000000..4ba0ffb Binary files /dev/null and b/dashboard/src/static/img/mxgraph/undo.png differ diff --git a/dashboard/src/static/img/mxgraph/view_1_1.png b/dashboard/src/static/img/mxgraph/view_1_1.png new file mode 100644 index 0000000..88657a1 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/view_1_1.png differ diff --git a/dashboard/src/static/img/mxgraph/view_1_132.png b/dashboard/src/static/img/mxgraph/view_1_132.png new file mode 100644 index 0000000..e9a1b72 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/view_1_132.png differ diff --git a/dashboard/src/static/img/mxgraph/view_next.png b/dashboard/src/static/img/mxgraph/view_next.png new file mode 100644 index 0000000..b4094f0 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/view_next.png differ diff --git a/dashboard/src/static/img/mxgraph/view_previous.png b/dashboard/src/static/img/mxgraph/view_previous.png new file mode 100644 index 0000000..b385b44 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/view_previous.png differ diff --git a/dashboard/src/static/img/mxgraph/warning.gif b/dashboard/src/static/img/mxgraph/warning.gif new file mode 100644 index 0000000..705235f Binary files /dev/null and b/dashboard/src/static/img/mxgraph/warning.gif differ diff --git a/dashboard/src/static/img/mxgraph/warning.png b/dashboard/src/static/img/mxgraph/warning.png new file mode 100644 index 0000000..2f78789 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/warning.png differ diff --git a/dashboard/src/static/img/mxgraph/window-title.gif b/dashboard/src/static/img/mxgraph/window-title.gif new file mode 100644 index 0000000..231def8 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/window-title.gif differ diff --git a/dashboard/src/static/img/mxgraph/window.gif b/dashboard/src/static/img/mxgraph/window.gif new file mode 100644 index 0000000..6631c4f Binary files /dev/null and b/dashboard/src/static/img/mxgraph/window.gif differ diff --git a/dashboard/src/static/img/mxgraph/wires-grid.gif b/dashboard/src/static/img/mxgraph/wires-grid.gif new file mode 100644 index 0000000..ad888a2 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/wires-grid.gif differ diff --git a/dashboard/src/static/img/mxgraph/zoom_in.png b/dashboard/src/static/img/mxgraph/zoom_in.png new file mode 100644 index 0000000..ad6abb9 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/zoom_in.png differ diff --git a/dashboard/src/static/img/mxgraph/zoom_in32.png b/dashboard/src/static/img/mxgraph/zoom_in32.png new file mode 100644 index 0000000..438ff0f Binary files /dev/null and b/dashboard/src/static/img/mxgraph/zoom_in32.png differ diff --git a/dashboard/src/static/img/mxgraph/zoom_out.png b/dashboard/src/static/img/mxgraph/zoom_out.png new file mode 100644 index 0000000..0566f26 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/zoom_out.png differ diff --git a/dashboard/src/static/img/mxgraph/zoom_out32.png b/dashboard/src/static/img/mxgraph/zoom_out32.png new file mode 100644 index 0000000..8edb765 Binary files /dev/null and b/dashboard/src/static/img/mxgraph/zoom_out32.png differ diff --git a/dashboard/src/static/js/mxClient.min.js b/dashboard/src/static/js/mxClient.min.js new file mode 100644 index 0000000..150a0ac --- /dev/null +++ b/dashboard/src/static/js/mxClient.min.js @@ -0,0 +1,1808 @@ +var mxClient={VERSION:"3.9.6",IS_IE:0<=navigator.userAgent.indexOf("MSIE"),IS_IE6:0<=navigator.userAgent.indexOf("MSIE 6"),IS_IE11:!!navigator.userAgent.match(/Trident\/7\./),IS_EDGE:!!navigator.userAgent.match(/Edge\//),IS_QUIRKS:0<=navigator.userAgent.indexOf("MSIE")&&(null==document.documentMode||5==document.documentMode),IS_EM:"spellcheck"in document.createElement("textarea")&&8==document.documentMode,VML_PREFIX:"v",OFFICE_PREFIX:"o",IS_NS:0<=navigator.userAgent.indexOf("Mozilla/")&&0>navigator.userAgent.indexOf("MSIE")&& +0>navigator.userAgent.indexOf("Edge/"),IS_OP:0<=navigator.userAgent.indexOf("Opera/")||0<=navigator.userAgent.indexOf("OPR/"),IS_OT:0<=navigator.userAgent.indexOf("Presto/")&&0>navigator.userAgent.indexOf("Presto/2.4.")&&0>navigator.userAgent.indexOf("Presto/2.3.")&&0>navigator.userAgent.indexOf("Presto/2.2.")&&0>navigator.userAgent.indexOf("Presto/2.1.")&&0>navigator.userAgent.indexOf("Presto/2.0.")&&0>navigator.userAgent.indexOf("Presto/1."),IS_SF:0<=navigator.userAgent.indexOf("AppleWebKit/")&& +0>navigator.userAgent.indexOf("Chrome/")&&0>navigator.userAgent.indexOf("Edge/"),IS_IOS:navigator.userAgent.match(/(iPad|iPhone|iPod)/g)?!0:!1,IS_GC:0<=navigator.userAgent.indexOf("Chrome/")&&0>navigator.userAgent.indexOf("Edge/"),IS_CHROMEAPP:null!=window.chrome&&null!=chrome.app&&null!=chrome.app.runtime,IS_FF:0<=navigator.userAgent.indexOf("Firefox/"),IS_MT:0<=navigator.userAgent.indexOf("Firefox/")&&0>navigator.userAgent.indexOf("Firefox/1.")&&0>navigator.userAgent.indexOf("Firefox/2.")||0<=navigator.userAgent.indexOf("Iceweasel/")&& +0>navigator.userAgent.indexOf("Iceweasel/1.")&&0>navigator.userAgent.indexOf("Iceweasel/2.")||0<=navigator.userAgent.indexOf("SeaMonkey/")&&0>navigator.userAgent.indexOf("SeaMonkey/1.")||0<=navigator.userAgent.indexOf("Iceape/")&&0>navigator.userAgent.indexOf("Iceape/1."),IS_SVG:0<=navigator.userAgent.indexOf("Firefox/")||0<=navigator.userAgent.indexOf("Iceweasel/")||0<=navigator.userAgent.indexOf("Seamonkey/")||0<=navigator.userAgent.indexOf("Iceape/")||0<=navigator.userAgent.indexOf("Galeon/")|| +0<=navigator.userAgent.indexOf("Epiphany/")||0<=navigator.userAgent.indexOf("AppleWebKit/")||0<=navigator.userAgent.indexOf("Gecko/")||0<=navigator.userAgent.indexOf("Opera/")||null!=document.documentMode&&9<=document.documentMode,NO_FO:!document.createElementNS||"[object SVGForeignObjectElement]"!=document.createElementNS("http://www.w3.org/2000/svg","foreignObject")||0<=navigator.userAgent.indexOf("Opera/"),IS_VML:"MICROSOFT INTERNET EXPLORER"==navigator.appName.toUpperCase(),IS_WIN:0document.location.href.indexOf("http://")&&0>document.location.href.indexOf("https://"),defaultBundles:[],isBrowserSupported:function(){return mxClient.IS_VML||mxClient.IS_SVG},link:function(a,b,c){c=c||document;if(mxClient.IS_IE6)c.write('');else{var d= +c.createElement("link");d.setAttribute("rel",a);d.setAttribute("href",b);d.setAttribute("charset","UTF-8");d.setAttribute("type","text/css");c.getElementsByTagName("head")[0].appendChild(d)}},loadResources:function(a,b){function c(){0==--d&&a()}for(var d=mxClient.defaultBundles.length,e=0;e\x3c/script>')},dispose:function(){for(var a=0;ad&&g?(d++,window.setTimeout(e,f)):null!=c&&c()},f=30;e()},cascadeOpacity:function(a,b,c){for(var d=a.model.getChildCount(b),e=0;edocument.documentMode)?function(a){return null!=a?a.currentStyle:null}:function(a){return null!=a?window.getComputedStyle(a, +""):null}}(),parseCssNumber:function(a){"thin"==a?a="2":"medium"==a?a="4":"thick"==a&&(a="6");a=parseFloat(a);isNaN(a)&&(a=0);return a},setPrefixedStyle:function(){var a=null;mxClient.IS_OT?a="O":mxClient.IS_SF||mxClient.IS_GC?a="Webkit":mxClient.IS_MT?a="Moz":mxClient.IS_IE&&9<=document.documentMode&&10>document.documentMode&&(a="ms");return function(b,c,d){b[c]=d;null!=a&&0document.documentMode))switch(b.nodeType){case 1:var d=a.createElement(b.nodeName);if(b.attributes&&0\n");null!=e;)d.push(mxUtils.getPrettyXml(e,b,c+b)),e=e.nextSibling;d.push(c+"\n")}else d.push("/>\n")}return d.join("")},removeWhitespace:function(a,b){for(var c=b?a.previousSibling:a.nextSibling;null!=c&&c.nodeType==mxConstants.NODETYPE_TEXT;){var d= +b?c.previousSibling:c.nextSibling,e=mxUtils.getTextContent(c);0==mxUtils.trim(e).length&&c.parentNode.removeChild(c);c=d}},htmlEntities:function(a,b){a=String(a||"");a=a.replace(/&/g,"&");a=a.replace(/"/g,""");a=a.replace(/\'/g,"'");a=a.replace(//g,">");if(null==b||b)a=a.replace(/\n/g," ");return a},isVml:function(a){return null!=a&&"urn:schemas-microsoft-com:vml"==a.tagUrn},getXml:function(a,b){var c="";null!=window.XMLSerializer?c=(new XMLSerializer).serializeToString(a): +null!=a.xml&&(c=a.xml.replace(/\r\n\t[\t]*/g,"").replace(/>\r\n/g,">").replace(/\r\n/g,"\n"));return c=c.replace(/\n/g,b||" ")},extractTextWithWhitespace:function(a){function b(a){if(1!=a.length||"BR"!=a[0].nodeName&&"\n"!=a[0].innerHTML)for(var e=0;e"==g.innerHTML.toLowerCase()?d.push("\n"):(3===g.nodeType||4===g.nodeType?0"):(b.push(">"),b.push(a.innerHTML),b.push(""));return b.join("")}return""}:function(a){return null!=a?(new XMLSerializer).serializeToString(a):""}}(),write:function(a,b){var c=a.ownerDocument.createTextNode(b);null!=a&&a.appendChild(c);return c},writeln:function(a,b){var c=a.ownerDocument.createTextNode(b);null!=a&&(a.appendChild(c),a.appendChild(document.createElement("br")));return c},br:function(a,b){b=b||1;for(var c= +null,d=0;dk&&(a.style.left=Math.max(e,k-c)+"px");b=parseInt(a.offsetTop);c=parseInt(a.offsetHeight);f=d+Math.max(f.clientHeight||0,g.clientHeight);b+c>f&&(a.style.top=Math.max(d,f-c)+"px")},load:function(a){a=new mxXmlRequest(a,null,"GET",!1);a.send();return a},get:function(a,b,c,d,e,f){a=new mxXmlRequest(a,null,"GET");null!=d&&a.setBinary(d);a.send(b,c,e,f);return a}, +getAll:function(a,b,c){for(var d=a.length,e=[],f=0,g=function(){0==f&&null!=c&&c();f++},k=0;kf||299mxUtils.indexOf(b,e))&&(d[e]=c||"object"!=typeof a[e]?a[e]:mxUtils.clone(a[e]))}return d}, +equalPoints:function(a,b){if(null==a&&null!=b||null!=a&&null==b||null!=a&&null!=b&&a.length!=b.length)return!1;if(null!=a&&null!=b)for(var c=0;c [Function]\n";else if("object"==typeof a[c])var d=mxUtils.getFunctionName(a[c].constructor),b=b+(c+" => ["+d+"]\n");else b+= +c+" = "+a[c]+"\n"}catch(e){b+=c+"="+e.message}return b},toRadians:function(a){return Math.PI*a/180},toDegree:function(a){return 180*a/Math.PI},arcToCurves:function(a,b,c,d,e,f,g,k,l){k-=a;l-=b;if(0===c||0===d)return q;c=Math.abs(c);d=Math.abs(d);var m=-k/2,n=-l/2,p=Math.cos(e*Math.PI/180),q=Math.sin(e*Math.PI/180);e=p*m+q*n;var m=-1*q*m+p*n,n=e*e,r=m*m,t=c*c,u=d*d,x=n/t+r/u;1e&&(e+=2*Math.PI);g=2*e/Math.PI;g=Math.ceil(0>g?-1*g:g);e/=g;m=8/3*Math.sin(e/4)*Math.sin(e/4)/Math.sin(e/2);n=p*c;p*=d;c*=q;d*=q;for(var y=Math.cos(f),A=Math.sin(f),r=-m*(n*A+d*y),t=-m*(c*A-p*y),q=[],z=0;zc&&(a=3,-135>=c&&(a=2));if(0<=d.indexOf(mxConstants.DIRECTION_NORTH))switch(a){case 0:b|=mxConstants.DIRECTION_MASK_NORTH;break;case 1:b|=mxConstants.DIRECTION_MASK_EAST;break;case 2:b|=mxConstants.DIRECTION_MASK_SOUTH; +break;case 3:b|=mxConstants.DIRECTION_MASK_WEST}if(0<=d.indexOf(mxConstants.DIRECTION_WEST))switch(a){case 0:b|=mxConstants.DIRECTION_MASK_WEST;break;case 1:b|=mxConstants.DIRECTION_MASK_NORTH;break;case 2:b|=mxConstants.DIRECTION_MASK_EAST;break;case 3:b|=mxConstants.DIRECTION_MASK_SOUTH}if(0<=d.indexOf(mxConstants.DIRECTION_SOUTH))switch(a){case 0:b|=mxConstants.DIRECTION_MASK_SOUTH;break;case 1:b|=mxConstants.DIRECTION_MASK_WEST;break;case 2:b|=mxConstants.DIRECTION_MASK_NORTH;break;case 3:b|= +mxConstants.DIRECTION_MASK_EAST}if(0<=d.indexOf(mxConstants.DIRECTION_EAST))switch(a){case 0:b|=mxConstants.DIRECTION_MASK_EAST;break;case 1:b|=mxConstants.DIRECTION_MASK_SOUTH;break;case 2:b|=mxConstants.DIRECTION_MASK_WEST;break;case 3:b|=mxConstants.DIRECTION_MASK_NORTH}return b},reversePortConstraints:function(a){var b;b=(a&mxConstants.DIRECTION_MASK_WEST)<<3;b|=(a&mxConstants.DIRECTION_MASK_NORTH)<<1;b|=(a&mxConstants.DIRECTION_MASK_SOUTH)>>1;return b|=(a&mxConstants.DIRECTION_MASK_EAST)>>3}, +findNearestSegment:function(a,b,c){var d=-1;if(0f.distSq)&&(d=f)}}return null!=d?d.p:null},rectangleIntersectsSegment:function(a,b,c){var d=a.y,e=a.x,f=d+a.height,g=e+a.width;a=b.x;var k=c.x;b.x>c.x&&(a=c.x,k=b.x);k>g&&(k=g);ak)return!1;var e=b.y,g=c.y,l=c.x-b.x;1E-7g&&(b=g,g=e,e=b);g>f&&(g=f);eg?!1:!0},contains:function(a,b,c){return a.x<= +b&&a.x+a.width>=b&&a.y<=c&&a.y+a.height>=c},intersects:function(a,b){var c=a.width,d=a.height,e=b.width,f=b.height;if(0>=e||0>=f||0>=c||0>=d)return!1;var g=a.x,k=a.y,l=b.x,m=b.y,e=e+l,f=f+m,c=c+g,d=d+k;return(eg)&&(fk)&&(cl)&&(dm)},intersectsHotspot:function(a,b,c,d,e,f){d=null!=d?d:1;e=null!=e?e:0;f=null!=f?f:0;if(0a.toLowerCase().indexOf("0x"))},isInteger:function(a){return String(parseInt(a))===String(a)},mod:function(a,b){return(a%b+b)%b},intersection:function(a,b,c,d,e,f,g,k){var l=(k-f)*(c-a)-(g-e)*(d-b);g=((g-e)*(b-f)-(k-f)*(a-e))/l;e=((c-a)*(b-f)-(d-b)*(a-e))/l;return 0<=g&&1>=g&&0<=e&&1>=e?new mxPoint(a+g*(c-a),b+g*(d-b)):null},ptSegDistSq:function(a,b,c,d,e,f){c-=a;d-=b;e-=a;f-=b;0>=e*c+f*d?c=0:(e=c-e,f=d- +f,a=e*c+f*d,c=0>=a?0:a*a/(c*c+d*d));e=e*e+f*f-c;0>e&&(e=0);return e},ptLineDist:function(a,b,c,d,e,f){return Math.abs((d-b)*e-(c-a)*f+c*b-d*a)/Math.sqrt((d-b)*(d-b)+(c-a)*(c-a))},relativeCcw:function(a,b,c,d,e,f){c-=a;d-=b;e-=a;f-=b;a=e*d-f*c;0==a&&(a=e*c+f*d,0a&&(a=0)));return 0>a?-1:0document.documentMode)?a.style.filter=100<=b?"":"alpha(opacity="+b+")":a.style.opacity=b/100},createImage:function(a){var b;mxClient.IS_IE6&&"CSS1Compat"!=document.compatMode?(b=document.createElement(mxClient.VML_PREFIX+":image"),b.setAttribute("src",a),b.style.borderStyle="none"):(b=document.createElement("img"), +b.setAttribute("src",a),b.setAttribute("border","0"));return b},sortCells:function(a,b){b=null!=b?b:!0;var c=new mxDictionary;a.sort(function(a,e){var d=c.get(a);null==d&&(d=mxCellPath.create(a).split(mxCellPath.PATH_SEPARATOR),c.put(a,d));var g=c.get(e);null==g&&(g=mxCellPath.create(e).split(mxCellPath.PATH_SEPARATOR),c.put(e,g));d=mxCellPath.compare(d,g);return 0==d?0:0a.indexOf("="))?a:""},getStylenames:function(a){var b= +[];if(null!=a){a=a.split(";");for(var c=0;ca[c].indexOf("=")&&b.push(a[c])}return b},indexOfStylename:function(a,b){if(null!=a&&null!=b)for(var c=a.split(";"),d=0,e=0;emxUtils.indexOfStylename(a,b)&&(null==a?a="":0e?";":a.substring(e)):0>e||e==a.length-1?"":a.substring(e+1)}else{var f=a.indexOf(";"+b+"=");0>f?d&&(d=";"==a.charAt(a.length-1)?"":";",a=a+d+b+"="+c+";"):(e=a.indexOf(";",f+1),a=d?a.substring(0,f+1)+b+"="+c+(0>e?";":a.substring(e)):a.substring(0,f)+(0>e?";":a.substring(e)))}return a},setCellStyleFlags:function(a,b,c,d,e){if(null!=b&&0e)e=";"==a.charAt(a.length-1)?"":";",a=d||null==d?a+e+b+"="+c:a+e+b+"=0";else{var f=a.indexOf(";",e),g;g=0>f?a.substring(e+b.length+1):a.substring(e+b.length+1,f);g=null==d?parseInt(g)^c:d?parseInt(g)|c:parseInt(g)&~c;a=a.substring(0,e)+b+"="+g+(0<=f?a.substring(f):"")}}return a},getAlignmentAsPoint:function(a,b){var c=0,d=0;a==mxConstants.ALIGN_CENTER? +c=-.5:a==mxConstants.ALIGN_RIGHT&&(c=-1);b==mxConstants.ALIGN_MIDDLE?d=-.5:b==mxConstants.ALIGN_BOTTOM&&(d=-1);return new mxPoint(c,d)},getSizeForString:function(a,b,c,d){b=null!=b?b:mxConstants.DEFAULT_FONTSIZE;c=null!=c?c:mxConstants.DEFAULT_FONTFAMILY;var e=document.createElement("div");e.style.fontFamily=c;e.style.fontSize=Math.round(b)+"px";e.style.lineHeight=Math.round(b*mxConstants.LINE_HEIGHT)+"px";e.style.position="absolute";e.style.visibility="hidden";e.style.display=mxClient.IS_QUIRKS? +"inline":"inline-block";e.style.zoom="1";null!=d?(e.style.width=d+"px",e.style.whiteSpace="normal"):e.style.whiteSpace="nowrap";e.innerHTML=a;document.body.appendChild(e);a=new mxRectangle(0,0,e.offsetWidth,e.offsetHeight);document.body.removeChild(e);return a},getViewXml:function(a,b,c,d,e){d=null!=d?d:0;e=null!=e?e:0;b=null!=b?b:1;null==c&&(c=[a.getModel().getRoot()]);var f=a.getView(),g=null,k=f.isEventsEnabled();f.setEventsEnabled(!1);var l=f.drawPane,m=f.overlayPane;a.dialect==mxConstants.DIALECT_SVG? +(f.drawPane=document.createElementNS(mxConstants.NS_SVG,"g"),f.canvas.appendChild(f.drawPane),f.overlayPane=document.createElementNS(mxConstants.NS_SVG,"g")):(f.drawPane=f.drawPane.cloneNode(!1),f.canvas.appendChild(f.drawPane),f.overlayPane=f.overlayPane.cloneNode(!1));f.canvas.appendChild(f.overlayPane);var n=f.getTranslate();f.translate=new mxPoint(d,e);b=new mxTemporaryCellStates(a.getView(),b,c);try{g=(new mxCodec).encode(a.getView())}finally{b.destroy(),f.translate=n,f.canvas.removeChild(f.drawPane), +f.canvas.removeChild(f.overlayPane),f.drawPane=l,f.overlayPane=m,f.setEventsEnabled(k)}return g},getScaleForPageCount:function(a,b,c,d){if(1>a)return 1;c=null!=c?c:mxConstants.PAGE_FORMAT_A4_PORTRAIT;d=null!=d?d:0;var e=c.width-2*d;c=c.height-2*d;d=b.getGraphBounds().clone();b=b.getView().getScale();d.width/=b;d.height/=b;b=d.width;var f=Math.sqrt(a);d=Math.sqrt(b/d.height/(e/c));c=f*d;d=f/d;if(1>c&&d>a){var g=d/a;d=a;c/=g}1>d&&c>a&&(g=c/a,c=a,d/=g);g=Math.ceil(c)*Math.ceil(d);for(f=0;g>a;){var g= +Math.floor(c)/c,k=Math.floor(d)/d;1==g&&(g=Math.floor(c-1)/c);1==k&&(k=Math.floor(d-1)/d);g=g>k?g:k;c*=g;d*=g;g=Math.ceil(c)*Math.ceil(d);f++;if(10";g=document.getElementsByTagName("base");for(c=0;c";for(c=0;c'+('
')+ +a.container.innerHTML;b.writeln(d+"
");b.close()}else{b.writeln("");g=document.getElementsByTagName("base");for(c=0;c');b.close();c=b.createElement("div"); +c.position="absolute";c.overflow="hidden";c.style.width=e+"px";c.style.height=f+"px";e=b.createElement("div");e.style.position="absolute";e.style.left=k+"px";e.style.top=l+"px";f=a.container.firstChild;for(d=null;null!=f;)g=f.cloneNode(!0),f==a.view.drawPane.ownerSVGElement?(c.appendChild(g),d=g):e.appendChild(g),f=f.nextSibling;b.body.appendChild(c);null!=e.firstChild&&b.body.appendChild(e);null!=d&&(d.style.minWidth="",d.style.minHeight="",d.firstChild.setAttribute("transform","translate("+k+","+ +l+")"))}mxUtils.removeCursors(b.body);return b},printScreen:function(a){var b=window.open();a.getGraphBounds();mxUtils.show(a,b.document);a=function(){b.focus();b.print();b.close()};mxClient.IS_GC?b.setTimeout(a,500):a()},popup:function(a,b){if(b){var c=document.createElement("div");c.style.overflow="scroll";c.style.width="636px";c.style.height="460px";var d=document.createElement("pre");d.innerHTML=mxUtils.htmlEntities(a,!1).replace(/\n/g,"
").replace(/ /g," ");c.appendChild(d);c=new mxWindow("Popup Window", +c,document.body.clientWidth/2-320,Math.max(document.body.clientHeight||0,document.documentElement.clientHeight)/2-240,640,480,!1,!0);c.setClosable(!0);c.setVisible(!0)}else mxClient.IS_NS?(c=window.open(),c.document.writeln("
"+mxUtils.htmlEntities(a)+"").replace(/ /g," "),c.document.body.appendChild(d))},alert:function(a){alert(a)},prompt:function(a,b){return prompt(a,
+null!=b?b:"")},confirm:function(a){return confirm(a)},error:function(a,b,c,d){var e=document.createElement("div");e.style.padding="20px";var f=document.createElement("img");f.setAttribute("src",d||mxUtils.errorImage);f.setAttribute("valign","bottom");f.style.verticalAlign="middle";e.appendChild(f);e.appendChild(document.createTextNode(" "));e.appendChild(document.createTextNode(" "));e.appendChild(document.createTextNode(" "));mxUtils.write(e,a);a=document.body.clientWidth;d=document.body.clientHeight||
+document.documentElement.clientHeight;var g=new mxWindow(mxResources.get(mxUtils.errorResource)||mxUtils.errorResource,e,(a-b)/2,d/4,b,null,!1,!0);c&&(mxUtils.br(e),b=document.createElement("p"),c=document.createElement("button"),mxClient.IS_IE?c.style.cssText="float:right":c.setAttribute("style","float:right"),mxEvent.addListener(c,"click",function(a){g.destroy()}),mxUtils.write(c,mxResources.get(mxUtils.closeResource)||mxUtils.closeResource),b.appendChild(c),e.appendChild(b),mxUtils.br(e),g.setClosable(!0));
+g.setVisible(!0);return g},makeDraggable:function(a,b,c,d,e,f,g,k,l,m){a=new mxDragSource(a,c);a.dragOffset=new mxPoint(null!=e?e:0,null!=f?f:mxConstants.TOOLTIP_VERTICAL_OFFSET);a.autoscroll=g;a.setGuidesEnabled(!1);null!=l&&(a.highlightDropTargets=l);null!=m&&(a.getDropTarget=m);a.getGraphForEvent=function(a){return"function"==typeof b?b(a):b};null!=d&&(a.createDragElement=function(){return d.cloneNode(!0)},k&&(a.createPreviewElement=function(a){var b=d.cloneNode(!0),c=parseInt(b.style.width),e=
+parseInt(b.style.height);b.style.width=Math.round(c*a.view.scale)+"px";b.style.height=Math.round(e*a.view.scale)+"px";return b}));return a}},mxConstants={DEFAULT_HOTSPOT:.3,MIN_HOTSPOT_SIZE:8,MAX_HOTSPOT_SIZE:0,RENDERING_HINT_EXACT:"exact",RENDERING_HINT_FASTER:"faster",RENDERING_HINT_FASTEST:"fastest",DIALECT_SVG:"svg",DIALECT_VML:"vml",DIALECT_MIXEDHTML:"mixedHtml",DIALECT_PREFERHTML:"preferHtml",DIALECT_STRICTHTML:"strictHtml",NS_SVG:"http://www.w3.org/2000/svg",NS_XHTML:"http://www.w3.org/1999/xhtml",
+NS_XLINK:"http://www.w3.org/1999/xlink",SHADOWCOLOR:"gray",VML_SHADOWCOLOR:"gray",SHADOW_OFFSET_X:2,SHADOW_OFFSET_Y:3,SHADOW_OPACITY:1,NODETYPE_ELEMENT:1,NODETYPE_ATTRIBUTE:2,NODETYPE_TEXT:3,NODETYPE_CDATA:4,NODETYPE_ENTITY_REFERENCE:5,NODETYPE_ENTITY:6,NODETYPE_PROCESSING_INSTRUCTION:7,NODETYPE_COMMENT:8,NODETYPE_DOCUMENT:9,NODETYPE_DOCUMENTTYPE:10,NODETYPE_DOCUMENT_FRAGMENT:11,NODETYPE_NOTATION:12,TOOLTIP_VERTICAL_OFFSET:16,DEFAULT_VALID_COLOR:"#00FF00",DEFAULT_INVALID_COLOR:"#FF0000",OUTLINE_HIGHLIGHT_COLOR:"#00FF00",
+OUTLINE_HIGHLIGHT_STROKEWIDTH:5,HIGHLIGHT_STROKEWIDTH:3,HIGHLIGHT_SIZE:2,HIGHLIGHT_OPACITY:100,CURSOR_MOVABLE_VERTEX:"move",CURSOR_MOVABLE_EDGE:"move",CURSOR_LABEL_HANDLE:"default",CURSOR_TERMINAL_HANDLE:"pointer",CURSOR_BEND_HANDLE:"crosshair",CURSOR_VIRTUAL_BEND_HANDLE:"crosshair",CURSOR_CONNECT:"pointer",HIGHLIGHT_COLOR:"#00FF00",CONNECT_TARGET_COLOR:"#0000FF",INVALID_CONNECT_TARGET_COLOR:"#FF0000",DROP_TARGET_COLOR:"#0000FF",VALID_COLOR:"#00FF00",INVALID_COLOR:"#FF0000",EDGE_SELECTION_COLOR:"#00FF00",
+VERTEX_SELECTION_COLOR:"#00FF00",VERTEX_SELECTION_STROKEWIDTH:1,EDGE_SELECTION_STROKEWIDTH:1,VERTEX_SELECTION_DASHED:!0,EDGE_SELECTION_DASHED:!0,GUIDE_COLOR:"#FF0000",GUIDE_STROKEWIDTH:1,OUTLINE_COLOR:"#0099FF",OUTLINE_STROKEWIDTH:mxClient.IS_IE?2:3,HANDLE_SIZE:6,LABEL_HANDLE_SIZE:4,HANDLE_FILLCOLOR:"#00FF00",HANDLE_STROKECOLOR:"black",LABEL_HANDLE_FILLCOLOR:"yellow",CONNECT_HANDLE_FILLCOLOR:"#0000FF",LOCKED_HANDLE_FILLCOLOR:"#FF0000",OUTLINE_HANDLE_FILLCOLOR:"#00FFFF",OUTLINE_HANDLE_STROKECOLOR:"#0033FF",
+DEFAULT_FONTFAMILY:"Arial,Helvetica",DEFAULT_FONTSIZE:11,DEFAULT_TEXT_DIRECTION:"",LINE_HEIGHT:1.2,WORD_WRAP:"normal",ABSOLUTE_LINE_HEIGHT:!1,DEFAULT_FONTSTYLE:0,DEFAULT_STARTSIZE:40,DEFAULT_MARKERSIZE:6,DEFAULT_IMAGESIZE:24,ENTITY_SEGMENT:30,RECTANGLE_ROUNDING_FACTOR:.15,LINE_ARCSIZE:20,ARROW_SPACING:0,ARROW_WIDTH:30,ARROW_SIZE:30,PAGE_FORMAT_A4_PORTRAIT:new mxRectangle(0,0,827,1169),PAGE_FORMAT_A4_LANDSCAPE:new mxRectangle(0,0,1169,827),PAGE_FORMAT_LETTER_PORTRAIT:new mxRectangle(0,0,850,1100),
+PAGE_FORMAT_LETTER_LANDSCAPE:new mxRectangle(0,0,1100,850),NONE:"none",STYLE_PERIMETER:"perimeter",STYLE_SOURCE_PORT:"sourcePort",STYLE_TARGET_PORT:"targetPort",STYLE_PORT_CONSTRAINT:"portConstraint",STYLE_PORT_CONSTRAINT_ROTATION:"portConstraintRotation",STYLE_SOURCE_PORT_CONSTRAINT:"sourcePortConstraint",STYLE_TARGET_PORT_CONSTRAINT:"targetPortConstraint",STYLE_OPACITY:"opacity",STYLE_FILL_OPACITY:"fillOpacity",STYLE_STROKE_OPACITY:"strokeOpacity",STYLE_TEXT_OPACITY:"textOpacity",STYLE_TEXT_DIRECTION:"textDirection",
+STYLE_OVERFLOW:"overflow",STYLE_ORTHOGONAL:"orthogonal",STYLE_EXIT_X:"exitX",STYLE_EXIT_Y:"exitY",STYLE_EXIT_PERIMETER:"exitPerimeter",STYLE_ENTRY_X:"entryX",STYLE_ENTRY_Y:"entryY",STYLE_ENTRY_PERIMETER:"entryPerimeter",STYLE_WHITE_SPACE:"whiteSpace",STYLE_ROTATION:"rotation",STYLE_FILLCOLOR:"fillColor",STYLE_POINTER_EVENTS:"pointerEvents",STYLE_SWIMLANE_FILLCOLOR:"swimlaneFillColor",STYLE_MARGIN:"margin",STYLE_GRADIENTCOLOR:"gradientColor",STYLE_GRADIENT_DIRECTION:"gradientDirection",STYLE_STROKECOLOR:"strokeColor",
+STYLE_SEPARATORCOLOR:"separatorColor",STYLE_STROKEWIDTH:"strokeWidth",STYLE_ALIGN:"align",STYLE_VERTICAL_ALIGN:"verticalAlign",STYLE_LABEL_WIDTH:"labelWidth",STYLE_LABEL_POSITION:"labelPosition",STYLE_VERTICAL_LABEL_POSITION:"verticalLabelPosition",STYLE_IMAGE_ASPECT:"imageAspect",STYLE_IMAGE_ALIGN:"imageAlign",STYLE_IMAGE_VERTICAL_ALIGN:"imageVerticalAlign",STYLE_GLASS:"glass",STYLE_IMAGE:"image",STYLE_IMAGE_WIDTH:"imageWidth",STYLE_IMAGE_HEIGHT:"imageHeight",STYLE_IMAGE_BACKGROUND:"imageBackground",
+STYLE_IMAGE_BORDER:"imageBorder",STYLE_FLIPH:"flipH",STYLE_FLIPV:"flipV",STYLE_NOLABEL:"noLabel",STYLE_NOEDGESTYLE:"noEdgeStyle",STYLE_LABEL_BACKGROUNDCOLOR:"labelBackgroundColor",STYLE_LABEL_BORDERCOLOR:"labelBorderColor",STYLE_LABEL_PADDING:"labelPadding",STYLE_INDICATOR_SHAPE:"indicatorShape",STYLE_INDICATOR_IMAGE:"indicatorImage",STYLE_INDICATOR_COLOR:"indicatorColor",STYLE_INDICATOR_STROKECOLOR:"indicatorStrokeColor",STYLE_INDICATOR_GRADIENTCOLOR:"indicatorGradientColor",STYLE_INDICATOR_SPACING:"indicatorSpacing",
+STYLE_INDICATOR_WIDTH:"indicatorWidth",STYLE_INDICATOR_HEIGHT:"indicatorHeight",STYLE_INDICATOR_DIRECTION:"indicatorDirection",STYLE_SHADOW:"shadow",STYLE_SEGMENT:"segment",STYLE_ENDARROW:"endArrow",STYLE_STARTARROW:"startArrow",STYLE_ENDSIZE:"endSize",STYLE_STARTSIZE:"startSize",STYLE_SWIMLANE_LINE:"swimlaneLine",STYLE_ENDFILL:"endFill",STYLE_STARTFILL:"startFill",STYLE_DASHED:"dashed",STYLE_DASH_PATTERN:"dashPattern",STYLE_FIX_DASH:"fixDash",STYLE_ROUNDED:"rounded",STYLE_CURVED:"curved",STYLE_ARCSIZE:"arcSize",
+STYLE_ABSOLUTE_ARCSIZE:"absoluteArcSize",STYLE_SOURCE_PERIMETER_SPACING:"sourcePerimeterSpacing",STYLE_TARGET_PERIMETER_SPACING:"targetPerimeterSpacing",STYLE_PERIMETER_SPACING:"perimeterSpacing",STYLE_SPACING:"spacing",STYLE_SPACING_TOP:"spacingTop",STYLE_SPACING_LEFT:"spacingLeft",STYLE_SPACING_BOTTOM:"spacingBottom",STYLE_SPACING_RIGHT:"spacingRight",STYLE_HORIZONTAL:"horizontal",STYLE_DIRECTION:"direction",STYLE_ELBOW:"elbow",STYLE_FONTCOLOR:"fontColor",STYLE_FONTFAMILY:"fontFamily",STYLE_FONTSIZE:"fontSize",
+STYLE_FONTSTYLE:"fontStyle",STYLE_ASPECT:"aspect",STYLE_AUTOSIZE:"autosize",STYLE_FOLDABLE:"foldable",STYLE_EDITABLE:"editable",STYLE_BENDABLE:"bendable",STYLE_MOVABLE:"movable",STYLE_RESIZABLE:"resizable",STYLE_RESIZE_WIDTH:"resizeWidth",STYLE_RESIZE_HEIGHT:"resizeHeight",STYLE_ROTATABLE:"rotatable",STYLE_CLONEABLE:"cloneable",STYLE_DELETABLE:"deletable",STYLE_SHAPE:"shape",STYLE_EDGE:"edgeStyle",STYLE_JETTY_SIZE:"jettySize",STYLE_SOURCE_JETTY_SIZE:"sourceJettySize",STYLE_TARGET_JETTY_SIZE:"targetJettySize",
+STYLE_LOOP:"loopStyle",STYLE_ORTHOGONAL_LOOP:"orthogonalLoop",STYLE_ROUTING_CENTER_X:"routingCenterX",STYLE_ROUTING_CENTER_Y:"routingCenterY",FONT_BOLD:1,FONT_ITALIC:2,FONT_UNDERLINE:4,SHAPE_RECTANGLE:"rectangle",SHAPE_ELLIPSE:"ellipse",SHAPE_DOUBLE_ELLIPSE:"doubleEllipse",SHAPE_RHOMBUS:"rhombus",SHAPE_LINE:"line",SHAPE_IMAGE:"image",SHAPE_ARROW:"arrow",SHAPE_ARROW_CONNECTOR:"arrowConnector",SHAPE_LABEL:"label",SHAPE_CYLINDER:"cylinder",SHAPE_SWIMLANE:"swimlane",SHAPE_CONNECTOR:"connector",SHAPE_ACTOR:"actor",
+SHAPE_CLOUD:"cloud",SHAPE_TRIANGLE:"triangle",SHAPE_HEXAGON:"hexagon",ARROW_CLASSIC:"classic",ARROW_CLASSIC_THIN:"classicThin",ARROW_BLOCK:"block",ARROW_BLOCK_THIN:"blockThin",ARROW_OPEN:"open",ARROW_OPEN_THIN:"openThin",ARROW_OVAL:"oval",ARROW_DIAMOND:"diamond",ARROW_DIAMOND_THIN:"diamondThin",ALIGN_LEFT:"left",ALIGN_CENTER:"center",ALIGN_RIGHT:"right",ALIGN_TOP:"top",ALIGN_MIDDLE:"middle",ALIGN_BOTTOM:"bottom",DIRECTION_NORTH:"north",DIRECTION_SOUTH:"south",DIRECTION_EAST:"east",DIRECTION_WEST:"west",
+TEXT_DIRECTION_DEFAULT:"",TEXT_DIRECTION_AUTO:"auto",TEXT_DIRECTION_LTR:"ltr",TEXT_DIRECTION_RTL:"rtl",DIRECTION_MASK_NONE:0,DIRECTION_MASK_WEST:1,DIRECTION_MASK_NORTH:2,DIRECTION_MASK_SOUTH:4,DIRECTION_MASK_EAST:8,DIRECTION_MASK_ALL:15,ELBOW_VERTICAL:"vertical",ELBOW_HORIZONTAL:"horizontal",EDGESTYLE_ELBOW:"elbowEdgeStyle",EDGESTYLE_ENTITY_RELATION:"entityRelationEdgeStyle",EDGESTYLE_LOOP:"loopEdgeStyle",EDGESTYLE_SIDETOSIDE:"sideToSideEdgeStyle",EDGESTYLE_TOPTOBOTTOM:"topToBottomEdgeStyle",EDGESTYLE_ORTHOGONAL:"orthogonalEdgeStyle",
+EDGESTYLE_SEGMENT:"segmentEdgeStyle",PERIMETER_ELLIPSE:"ellipsePerimeter",PERIMETER_RECTANGLE:"rectanglePerimeter",PERIMETER_RHOMBUS:"rhombusPerimeter",PERIMETER_HEXAGON:"hexagonPerimeter",PERIMETER_TRIANGLE:"trianglePerimeter"};function mxEventObject(a){this.name=a;this.properties=[];for(var b=1;bnavigator.userAgent.indexOf("Presto/2.5")&&(this.contentWrapper.style.overflow=a?"auto":"hidden")};
+mxWindow.prototype.activate=function(){if(mxWindow.activeWindow!=this){var a=mxUtils.getCurrentStyle(this.getElement()),a=null!=a?a.zIndex:3;if(mxWindow.activeWindow){var b=mxWindow.activeWindow.getElement();null!=b&&null!=b.style&&(b.style.zIndex=a)}b=mxWindow.activeWindow;this.getElement().style.zIndex=parseInt(a)+1;mxWindow.activeWindow=this;this.fireEvent(new mxEventObject(mxEvent.ACTIVATE,"previousWindow",b))}};mxWindow.prototype.getElement=function(){return this.div};
+mxWindow.prototype.fit=function(){mxUtils.fit(this.div)};mxWindow.prototype.isResizable=function(){return null!=this.resize?"none"!=this.resize.style.display:!1};
+mxWindow.prototype.setResizable=function(a){if(a)if(null==this.resize){this.resize=document.createElement("img");this.resize.style.position="absolute";this.resize.style.bottom="2px";this.resize.style.right="2px";this.resize.setAttribute("src",this.resizeImage);this.resize.style.cursor="nw-resize";var b=null,c=null,d=null,e=null;a=mxUtils.bind(this,function(a){this.activate();b=mxEvent.getClientX(a);c=mxEvent.getClientY(a);d=this.div.offsetWidth;e=this.div.offsetHeight;mxEvent.addGestureListeners(document,
+null,f,g);this.fireEvent(new mxEventObject(mxEvent.RESIZE_START,"event",a));mxEvent.consume(a)});var f=mxUtils.bind(this,function(a){if(null!=b&&null!=c){var f=mxEvent.getClientX(a)-b,g=mxEvent.getClientY(a)-c;this.setSize(d+f,e+g);this.fireEvent(new mxEventObject(mxEvent.RESIZE,"event",a));mxEvent.consume(a)}}),g=mxUtils.bind(this,function(a){null!=b&&null!=c&&(c=b=null,mxEvent.removeGestureListeners(document,null,f,g),this.fireEvent(new mxEventObject(mxEvent.RESIZE_END,"event",a)),mxEvent.consume(a))});
+mxEvent.addGestureListeners(this.resize,a,f,g);this.div.appendChild(this.resize)}else this.resize.style.display="inline";else null!=this.resize&&(this.resize.style.display="none")};
+mxWindow.prototype.setSize=function(a,b){a=Math.max(this.minimumSize.width,a);b=Math.max(this.minimumSize.height,b);mxClient.IS_QUIRKS||(this.div.style.width=a+"px",this.div.style.height=b+"px");this.table.style.width=a+"px";this.table.style.height=b+"px";mxClient.IS_QUIRKS||(this.contentWrapper.style.height=this.div.offsetHeight-this.title.offsetHeight-this.contentHeightCorrection+"px")};mxWindow.prototype.setMinimizable=function(a){this.minimize.style.display=a?"":"none"};
+mxWindow.prototype.getMinimumSize=function(){return new mxRectangle(0,0,0,this.title.offsetHeight)};
+mxWindow.prototype.installMinimizeHandler=function(){this.minimize=document.createElement("img");this.minimize.setAttribute("src",this.minimizeImage);this.minimize.setAttribute("title","Minimize");this.minimize.style.cursor="pointer";this.minimize.style.marginLeft="2px";this.minimize.style.display="none";this.buttons.appendChild(this.minimize);var a=!1,b=null,c=null,d=mxUtils.bind(this,function(d){this.activate();if(a)a=!1,this.minimize.setAttribute("src",this.minimizeImage),this.minimize.setAttribute("title",
+"Minimize"),this.contentWrapper.style.display="",this.maximize.style.display=b,mxClient.IS_QUIRKS||(this.div.style.height=c),this.table.style.height=c,null!=this.resize&&(this.resize.style.visibility=""),this.fireEvent(new mxEventObject(mxEvent.NORMALIZE,"event",d));else{a=!0;this.minimize.setAttribute("src",this.normalizeImage);this.minimize.setAttribute("title","Normalize");this.contentWrapper.style.display="none";b=this.maximize.style.display;this.maximize.style.display="none";c=this.table.style.height;
+var e=this.getMinimumSize();0=e.x-f.x&&d>=e.y-f.y&&c<=e.x-f.x+a.container.offsetWidth&&d<=e.y-f.y+a.container.offsetHeight};
+mxDragSource.prototype.mouseMove=function(a){var b=this.getGraphForEvent(a);null==b||this.graphContainsEvent(b,a)||(b=null);b!=this.currentGraph&&(null!=this.currentGraph&&this.dragExit(this.currentGraph,a),this.currentGraph=b,null!=this.currentGraph&&this.dragEnter(this.currentGraph,a));null!=this.currentGraph&&this.dragOver(this.currentGraph,a);if(null==this.dragElement||null!=this.previewElement&&"visible"==this.previewElement.style.visibility)null!=this.dragElement&&(this.dragElement.style.visibility=
+"hidden");else{var b=mxEvent.getClientX(a),c=mxEvent.getClientY(a);null==this.dragElement.parentNode&&document.body.appendChild(this.dragElement);this.dragElement.style.visibility="visible";null!=this.dragOffset&&(b+=this.dragOffset.x,c+=this.dragOffset.y);var d=mxUtils.getDocumentScrollOrigin(document);this.dragElement.style.left=b+d.x+"px";this.dragElement.style.top=c+d.y+"px"}mxEvent.consume(a)};
+mxDragSource.prototype.mouseUp=function(a){if(null!=this.currentGraph){if(null!=this.currentPoint&&(null==this.previewElement||"hidden"!=this.previewElement.style.visibility)){var b=this.currentGraph.view.scale,c=this.currentGraph.view.translate;this.drop(this.currentGraph,a,this.currentDropTarget,this.currentPoint.x/b-c.x,this.currentPoint.y/b-c.y)}this.dragExit(this.currentGraph);this.currentGraph=null}this.stopDrag();this.removeListeners();mxEvent.consume(a)};
+mxDragSource.prototype.removeListeners=function(){null!=this.eventSource&&(mxEvent.removeGestureListeners(this.eventSource,null,this.mouseMoveHandler,this.mouseUpHandler),this.eventSource=null);mxEvent.removeGestureListeners(document,null,this.mouseMoveHandler,this.mouseUpHandler);this.mouseUpHandler=this.mouseMoveHandler=null};
+mxDragSource.prototype.dragEnter=function(a,b){a.isMouseDown=!0;a.isMouseTrigger=mxEvent.isMouseEvent(b);this.previewElement=this.createPreviewElement(a);null!=this.previewElement&&this.checkEventSource&&mxClient.IS_SVG&&(this.previewElement.style.pointerEvents="none");this.isGuidesEnabled()&&null!=this.previewElement&&(this.currentGuide=new mxGuide(a,a.graphHandler.getGuideStates()));this.highlightDropTargets&&(this.currentHighlight=new mxCellHighlight(a,mxConstants.DROP_TARGET_COLOR));a.addListener(mxEvent.FIRE_MOUSE_EVENT,
+this.eventConsumer)};mxDragSource.prototype.dragExit=function(a,b){this.currentPoint=this.currentDropTarget=null;a.isMouseDown=!1;a.removeListener(this.eventConsumer);null!=this.previewElement&&(null!=this.previewElement.parentNode&&this.previewElement.parentNode.removeChild(this.previewElement),this.previewElement=null);null!=this.currentGuide&&(this.currentGuide.destroy(),this.currentGuide=null);null!=this.currentHighlight&&(this.currentHighlight.destroy(),this.currentHighlight=null)};
+mxDragSource.prototype.dragOver=function(a,b){var c=mxUtils.getOffset(a.container),d=mxUtils.getScrollOrigin(a.container),e=mxEvent.getClientX(b)-c.x+d.x-a.panDx,c=mxEvent.getClientY(b)-c.y+d.y-a.panDy;a.autoScroll&&(null==this.autoscroll||this.autoscroll)&&a.scrollPointToVisible(e,c,a.autoExtend);null!=this.currentHighlight&&a.isDropEnabled()&&(this.currentDropTarget=this.getDropTarget(a,e,c,b),d=a.getView().getState(this.currentDropTarget),this.currentHighlight.highlight(d));if(null!=this.previewElement){null==
+this.previewElement.parentNode&&(a.container.appendChild(this.previewElement),this.previewElement.style.zIndex="3",this.previewElement.style.position="absolute");var d=this.isGridEnabled()&&a.isGridEnabledEvent(b),f=!0;if(null!=this.currentGuide&&this.currentGuide.isEnabledForEvent(b))var f=parseInt(this.previewElement.style.width),g=parseInt(this.previewElement.style.height),f=new mxRectangle(0,0,f,g),c=new mxPoint(e,c),c=this.currentGuide.move(f,c,d),f=!1,e=c.x,c=c.y;else if(d)var d=a.view.scale,
+g=a.view.translate,k=a.gridSize/2,e=(a.snap(e/d-g.x-k)+g.x)*d,c=(a.snap(c/d-g.y-k)+g.y)*d;null!=this.currentGuide&&f&&this.currentGuide.hide();null!=this.previewOffset&&(e+=this.previewOffset.x,c+=this.previewOffset.y);this.previewElement.style.left=Math.round(e)+"px";this.previewElement.style.top=Math.round(c)+"px";this.previewElement.style.visibility="visible"}this.currentPoint=new mxPoint(e,c)};
+mxDragSource.prototype.drop=function(a,b,c,d,e){this.dropHandler.apply(this,arguments);"hidden"!=a.container.style.visibility&&a.container.focus()};function mxToolbar(a){this.container=a}mxToolbar.prototype=new mxEventSource;mxToolbar.prototype.constructor=mxToolbar;mxToolbar.prototype.container=null;mxToolbar.prototype.enabled=!0;mxToolbar.prototype.noReset=!1;mxToolbar.prototype.updateDefaultMode=!0;
+mxToolbar.prototype.addItem=function(a,b,c,d,e,f){var g=document.createElement(null!=b?"img":"button"),k=e||(null!=f?"mxToolbarMode":"mxToolbarItem");g.className=k;g.setAttribute("src",b);null!=a&&(null!=b?g.setAttribute("title",a):mxUtils.write(g,a));this.container.appendChild(g);null!=c&&(mxEvent.addListener(g,"click",c),mxClient.IS_TOUCH&&mxEvent.addListener(g,"touchend",c));a=mxUtils.bind(this,function(a){null!=d?g.setAttribute("src",b):g.style.backgroundColor=""});mxEvent.addGestureListeners(g,
+mxUtils.bind(this,function(a){null!=d?g.setAttribute("src",d):g.style.backgroundColor="gray";if(null!=f){null==this.menu&&(this.menu=new mxPopupMenu,this.menu.init());var b=this.currentImg;this.menu.isMenuShowing()&&this.menu.hideMenu();b!=g&&(this.currentImg=g,this.menu.factoryMethod=f,b=new mxPoint(g.offsetLeft,g.offsetTop+g.offsetHeight),this.menu.popup(b.x,b.y,null,a),this.menu.isMenuShowing()&&(g.className=k+"Selected",this.menu.hideMenu=function(){mxPopupMenu.prototype.hideMenu.apply(this);
+g.className=k;this.currentImg=null}))}}),null,a);mxEvent.addListener(g,"mouseout",a);return g};mxToolbar.prototype.addCombo=function(a){var b=document.createElement("div");b.style.display="inline";b.className="mxToolbarComboContainer";var c=document.createElement("select");c.className=a||"mxToolbarCombo";b.appendChild(c);this.container.appendChild(b);return c};
+mxToolbar.prototype.addActionCombo=function(a,b){var c=document.createElement("select");c.className=b||"mxToolbarCombo";this.addOption(c,a,null);mxEvent.addListener(c,"change",function(a){var b=c.options[c.selectedIndex];c.selectedIndex=0;null!=b.funct&&b.funct(a)});this.container.appendChild(c);return c};mxToolbar.prototype.addOption=function(a,b,c){var d=document.createElement("option");mxUtils.writeln(d,b);"function"==typeof c?d.funct=c:d.setAttribute("value",c);a.appendChild(d);return d};
+mxToolbar.prototype.addSwitchMode=function(a,b,c,d,e){var f=document.createElement("img");f.initialClassName=e||"mxToolbarMode";f.className=f.initialClassName;f.setAttribute("src",b);f.altIcon=d;null!=a&&f.setAttribute("title",a);mxEvent.addListener(f,"click",mxUtils.bind(this,function(a){a=this.selectedMode.altIcon;null!=a?(this.selectedMode.altIcon=this.selectedMode.getAttribute("src"),this.selectedMode.setAttribute("src",a)):this.selectedMode.className=this.selectedMode.initialClassName;this.updateDefaultMode&&
+(this.defaultMode=f);this.selectedMode=f;a=f.altIcon;null!=a?(f.altIcon=f.getAttribute("src"),f.setAttribute("src",a)):f.className=f.initialClassName+"Selected";this.fireEvent(new mxEventObject(mxEvent.SELECT));c()}));this.container.appendChild(f);null==this.defaultMode&&(this.defaultMode=f,this.selectMode(f),c());return f};
+mxToolbar.prototype.addMode=function(a,b,c,d,e,f){f=null!=f?f:!0;var g=document.createElement(null!=b?"img":"button");g.initialClassName=e||"mxToolbarMode";g.className=g.initialClassName;g.setAttribute("src",b);g.altIcon=d;null!=a&&g.setAttribute("title",a);this.enabled&&f&&(mxEvent.addListener(g,"click",mxUtils.bind(this,function(a){this.selectMode(g,c);this.noReset=!1})),mxEvent.addListener(g,"dblclick",mxUtils.bind(this,function(a){this.selectMode(g,c);this.noReset=!0})),null==this.defaultMode&&
+(this.defaultMode=g,this.defaultFunction=c,this.selectMode(g,c)));this.container.appendChild(g);return g};
+mxToolbar.prototype.selectMode=function(a,b){if(this.selectedMode!=a){if(null!=this.selectedMode){var c=this.selectedMode.altIcon;null!=c?(this.selectedMode.altIcon=this.selectedMode.getAttribute("src"),this.selectedMode.setAttribute("src",c)):this.selectedMode.className=this.selectedMode.initialClassName}this.selectedMode=a;c=this.selectedMode.altIcon;null!=c?(this.selectedMode.altIcon=this.selectedMode.getAttribute("src"),this.selectedMode.setAttribute("src",c)):this.selectedMode.className=this.selectedMode.initialClassName+
+"Selected";this.fireEvent(new mxEventObject(mxEvent.SELECT,"function",b))}};mxToolbar.prototype.resetMode=function(a){!a&&this.noReset||this.selectedMode==this.defaultMode||this.selectMode(this.defaultMode,this.defaultFunction)};mxToolbar.prototype.addSeparator=function(a){return this.addItem(null,a,null)};mxToolbar.prototype.addBreak=function(){mxUtils.br(this.container)};
+mxToolbar.prototype.addLine=function(){var a=document.createElement("hr");a.style.marginRight="6px";a.setAttribute("size","1");this.container.appendChild(a)};mxToolbar.prototype.destroy=function(){mxEvent.release(this.container);this.selectedMode=this.defaultFunction=this.defaultMode=this.container=null;null!=this.menu&&this.menu.destroy()};function mxUndoableEdit(a,b){this.source=a;this.changes=[];this.significant=null!=b?b:!0}mxUndoableEdit.prototype.source=null;
+mxUndoableEdit.prototype.changes=null;mxUndoableEdit.prototype.significant=null;mxUndoableEdit.prototype.undone=!1;mxUndoableEdit.prototype.redone=!1;mxUndoableEdit.prototype.isEmpty=function(){return 0==this.changes.length};mxUndoableEdit.prototype.isSignificant=function(){return this.significant};mxUndoableEdit.prototype.add=function(a){this.changes.push(a)};mxUndoableEdit.prototype.notify=function(){};mxUndoableEdit.prototype.die=function(){};
+mxUndoableEdit.prototype.undo=function(){if(!this.undone){this.source.fireEvent(new mxEventObject(mxEvent.START_EDIT));for(var a=this.changes.length-1;0<=a;a--){var b=this.changes[a];null!=b.execute?b.execute():null!=b.undo&&b.undo();this.source.fireEvent(new mxEventObject(mxEvent.EXECUTED,"change",b))}this.undone=!0;this.redone=!1;this.source.fireEvent(new mxEventObject(mxEvent.END_EDIT))}this.notify()};
+mxUndoableEdit.prototype.redo=function(){if(!this.redone){this.source.fireEvent(new mxEventObject(mxEvent.START_EDIT));for(var a=this.changes.length,b=0;bthis.indexOfNextAdd)for(var a=this.history.splice(this.indexOfNextAdd,this.history.length-this.indexOfNextAdd),b=0;bthis.dx&&Math.abs(this.dx)<
+this.border?this.border+this.dx:this.handleMouseOut?Math.max(this.dx,0):0;0==this.dx&&(this.dx=c-g.scrollLeft,this.dx=0this.dy&&Math.abs(this.dy)e.x+(document.body.clientWidth||f.clientWidth)&&(b.div.style.left=Math.max(0,a.div.offsetLeft-d+(mxClient.IS_IE?6:-6))+"px");mxUtils.fit(b.div)}};
+mxPopupMenu.prototype.addSeparator=function(a,b){a=a||this;if(this.smartSeparators&&!b)a.willAddSeparator=!0;else if(null!=a.tbody){a.willAddSeparator=!1;var c=document.createElement("tr"),d=document.createElement("td");d.className="mxPopupMenuIcon";d.style.padding="0 0 0 0px";c.appendChild(d);d=document.createElement("td");d.style.padding="0 0 0 0px";d.setAttribute("colSpan","2");var e=document.createElement("hr");e.setAttribute("size","1");d.appendChild(e);c.appendChild(d);a.tbody.appendChild(c)}};
+mxPopupMenu.prototype.popup=function(a,b,c,d){if(null!=this.div&&null!=this.tbody&&null!=this.factoryMethod){this.div.style.left=a+"px";for(this.div.style.top=b+"px";null!=this.tbody.firstChild;)mxEvent.release(this.tbody.firstChild),this.tbody.removeChild(this.tbody.firstChild);this.itemCount=0;this.factoryMethod(this,c,d);0this.autoSaveDelay||this.ignoredChanges>=this.autoSaveThreshold&&a>this.autoSaveThrottle?(this.save(),this.reset()):this.ignoredChanges++};mxAutoSaveManager.prototype.reset=function(){this.lastSnapshot=(new Date).getTime();this.ignoredChanges=0};mxAutoSaveManager.prototype.destroy=function(){this.setGraph(null)};
+function mxAnimation(a){this.delay=null!=a?a:20}mxAnimation.prototype=new mxEventSource;mxAnimation.prototype.constructor=mxAnimation;mxAnimation.prototype.delay=null;mxAnimation.prototype.thread=null;mxAnimation.prototype.isRunning=function(){return null!=this.thread};mxAnimation.prototype.startAnimation=function(){null==this.thread&&(this.thread=window.setInterval(mxUtils.bind(this,this.updateAnimation),this.delay))};mxAnimation.prototype.updateAnimation=function(){this.fireEvent(new mxEventObject(mxEvent.EXECUTE))};
+mxAnimation.prototype.stopAnimation=function(){null!=this.thread&&(window.clearInterval(this.thread),this.thread=null,this.fireEvent(new mxEventObject(mxEvent.DONE)))};function mxMorphing(a,b,c,d){mxAnimation.call(this,d);this.graph=a;this.steps=null!=b?b:6;this.ease=null!=c?c:1.5}mxMorphing.prototype=new mxAnimation;mxMorphing.prototype.constructor=mxMorphing;mxMorphing.prototype.graph=null;mxMorphing.prototype.steps=null;mxMorphing.prototype.step=0;mxMorphing.prototype.ease=null;
+mxMorphing.prototype.cells=null;mxMorphing.prototype.updateAnimation=function(){mxAnimation.prototype.updateAnimation.apply(this,arguments);var a=new mxCellStatePreview(this.graph);if(null!=this.cells)for(var b=0;b=this.steps)&&this.stopAnimation()};mxMorphing.prototype.show=function(a){a.show()};
+mxMorphing.prototype.animateCell=function(a,b,c){var d=this.graph.getView().getState(a),e=null;if(null!=d&&(e=this.getDelta(d),this.graph.getModel().isVertex(a)&&(0!=e.x||0!=e.y))){var f=this.graph.view.getTranslate(),g=this.graph.view.getScale();e.x+=f.x*g;e.y+=f.y*g;b.moveState(d,-e.x/this.ease,-e.y/this.ease)}if(c&&!this.stopRecursion(d,e))for(d=this.graph.getModel().getChildCount(a),e=0;ec?";stop-opacity:"+c:"";e=this.createElement("stop");
+e.setAttribute("offset","0%");e.setAttribute("style","stop-color:"+a+c);f.appendChild(e);c=1>d?";stop-opacity:"+d:"";e=this.createElement("stop");e.setAttribute("offset","100%");e.setAttribute("style","stop-color:"+b+c);f.appendChild(e);return f};
+mxSvgCanvas2D.prototype.addNode=function(a,b){var c=this.node,d=this.state;if(null!=c){if("path"==c.nodeName)if(null!=this.path&&0a.alpha||1>a.fillAlpha)&&this.node.setAttribute("fill-opacity",a.alpha*a.fillAlpha);if(null!=a.fillColor)if(null!=a.gradientColor)if(a=this.getSvgGradient(a.fillColor,a.gradientColor,a.gradientFillAlpha,a.gradientAlpha,a.gradientDirection),mxClient.IS_CHROME_APP||mxClient.IS_IE||mxClient.IS_IE11||mxClient.IS_EDGE||this.root.ownerDocument!=document)this.node.setAttribute("fill","url(#"+a+")");else{var b=this.getBaseUrl().replace(/([\(\)])/g,
+"\\$1");this.node.setAttribute("fill","url("+b+"#"+a+")")}else this.node.setAttribute("fill",a.fillColor.toLowerCase())};mxSvgCanvas2D.prototype.getCurrentStrokeWidth=function(){return Math.max(this.minStrokeWidth,Math.max(.01,this.format(this.state.strokeWidth*this.state.scale)))};
+mxSvgCanvas2D.prototype.updateStroke=function(){var a=this.state;this.node.setAttribute("stroke",a.strokeColor.toLowerCase());(1>a.alpha||1>a.strokeAlpha)&&this.node.setAttribute("stroke-opacity",a.alpha*a.strokeAlpha);var b=this.getCurrentStrokeWidth();1!=b&&this.node.setAttribute("stroke-width",b);"path"==this.node.nodeName&&this.updateStrokeAttributes();a.dashed&&this.node.setAttribute("stroke-dasharray",this.createDashPattern((a.fixDash?1:a.strokeWidth)*a.scale))};
+mxSvgCanvas2D.prototype.updateStrokeAttributes=function(){var a=this.state;null!=a.lineJoin&&"miter"!=a.lineJoin&&this.node.setAttribute("stroke-linejoin",a.lineJoin);if(null!=a.lineCap){var b=a.lineCap;"flat"==b&&(b="butt");"butt"!=b&&this.node.setAttribute("stroke-linecap",b)}null==a.miterLimit||this.styleEnabled&&10==a.miterLimit||this.node.setAttribute("stroke-miterlimit",a.miterLimit)};
+mxSvgCanvas2D.prototype.createDashPattern=function(a){var b=[];if("string"===typeof this.state.dashPattern){var c=this.state.dashPattern.split(" ");if(0l.alpha||1>l.fillAlpha)&&m.setAttribute("opacity",l.alpha*l.fillAlpha);e=this.state.transform||"";if(g||k){var n=f=1,p=0,q=0;g&&(f=-1,p=-c-2*a);k&&(n=-1,q=-d-2*b);e+="scale("+f+","+n+")translate("+p*l.scale+","+q*l.scale+")"}0",5)+1)),""==a.substring(a.length-7,a.length)&&(a=a.substring(0,a.length-7)))}else{if(null!=document.implementation&&null!=document.implementation.createDocument){var b=document.implementation.createDocument("http://www.w3.org/1999/xhtml","html",null),c=b.createElement("body");
+b.documentElement.appendChild(c);var d=document.createElement("div");d.innerHTML=a;for(a=d.firstChild;null!=a;)d=a.nextSibling,c.appendChild(b.adoptNode(a)),a=d;return c.innerHTML}b=document.createElement("textarea");b.innerHTML=a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(//g,">");a=b.value.replace(/&/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,
+"&").replace(/
/g,"
").replace(/
/g,"
").replace(/(]+)>/gm,"$1 />")}return a}; +mxSvgCanvas2D.prototype.createDiv=function(a,b,c,d,e){c=this.state;d="display:inline-block;font-size:"+c.fontSize+"px;font-family:"+c.fontFamily+";color:"+c.fontColor+";line-height:"+(mxConstants.ABSOLUTE_LINE_HEIGHT?c.fontSize*mxConstants.LINE_HEIGHT+"px":mxConstants.LINE_HEIGHT*this.lineHeightCorrection)+";"+d;(c.fontStyle&mxConstants.FONT_BOLD)==mxConstants.FONT_BOLD&&(d+="font-weight:bold;");(c.fontStyle&mxConstants.FONT_ITALIC)==mxConstants.FONT_ITALIC&&(d+="font-style:italic;");(c.fontStyle& +mxConstants.FONT_UNDERLINE)==mxConstants.FONT_UNDERLINE&&(d+="text-decoration:underline;");b==mxConstants.ALIGN_CENTER?d+="text-align:center;":b==mxConstants.ALIGN_RIGHT&&(d+="text-align:right;");b="";null!=c.fontBackgroundColor&&(b+="background-color:"+c.fontBackgroundColor+";");null!=c.fontBorderColor&&(b+="border:1px solid "+c.fontBorderColor+";");mxUtils.isNode(a)||(a=this.convertHtml(a),"fill"!=e&&"width"!=e?a='
'+a+"
":d+=b);if(!mxClient.IS_IE&&document.createElementNS)return e=document.createElementNS("http://www.w3.org/1999/xhtml","div"),e.setAttribute("style",d),mxUtils.isNode(a)?this.root.ownerDocument!=document?e.appendChild(a.cloneNode(!0)):e.appendChild(a):e.innerHTML=a,e;mxUtils.isNode(a)&&this.root.ownerDocument!=document&&(a=a.outerHTML);return mxUtils.parseXml('
'+a+"
").documentElement}; +mxSvgCanvas2D.prototype.invalidateCachedOffsetSize=function(a){delete a.firstChild.mxCachedOffsetWidth;delete a.firstChild.mxCachedFinalOffsetWidth;delete a.firstChild.mxCachedFinalOffsetHeight}; +mxSvgCanvas2D.prototype.updateText=function(a,b,c,d,e,f,g,k,l,m,n){if(null!=n&&null!=n.firstChild&&null!=n.firstChild.firstChild&&null!=n.firstChild.firstChild.firstChild){n=n.firstChild;var p=n.firstChild,q=p.firstChild;m=null!=m?m:0;var r=this.state;a+=r.dx;b+=r.dy;l?(q.style.maxHeight=Math.round(d)+"px",q.style.maxWidth=Math.round(c)+"px"):"fill"==k?(q.style.width=Math.round(c+1)+"px",q.style.height=Math.round(d+1)+"px"):"width"==k&&(q.style.width=Math.round(c+1)+"px",0r.alpha&&u.setAttribute("opacity",r.alpha);var x=this.createElement("foreignObject");x.setAttribute("style","overflow:visible;");x.setAttribute("pointer-events","all");t=this.createDiv(e,f,g,t,m);if(null!=t){null!=q&&t.setAttribute("dir",q);u.appendChild(x);this.root.appendChild(u);var y,A;q=y=2;if(!mxClient.IS_IE||9!=document.documentMode&&mxClient.IS_SVG){this.root.ownerDocument!= +document?(t.style.visibility="hidden",document.body.appendChild(t)):x.appendChild(t);var z=t;null!=z.firstChild&&"DIV"==z.firstChild.nodeName&&(z=z.firstChild,k&&"break-word"==t.style.wordWrap&&(z.style.width="100%"));v=z.offsetWidth;0==v&&t.parentNode==x&&(t.style.visibility="hidden",document.body.appendChild(t),v=z.offsetWidth);this.cacheOffsetSize&&(u.mxCachedOffsetWidth=v);!n&&k&&0r.alpha&&u.setAttribute("opacity",r.alpha);q=t=0;f==mxConstants.ALIGN_CENTER?t-=c/2:f==mxConstants.ALIGN_RIGHT&&(t-=c);a+=t;g==mxConstants.ALIGN_MIDDLE?q-= +d/2:g==mxConstants.ALIGN_BOTTOM&&(q-=d);"fill"!=m&&mxClient.IS_FF&&mxClient.IS_WIN&&(q-=2);b+=q;z=1!=r.scale?"scale("+r.scale+")":"";0!=r.rotation&&this.rotateHtml?(z+="rotate("+r.rotation+","+c/2+","+d/2+")",b=this.rotatePoint((a+c/2)*r.scale,(b+d/2)*r.scale,r.rotation,r.rotationCx,r.rotationCy),a=b.x-c*r.scale/2,b=b.y-d*r.scale/2):(a*=r.scale,b*=r.scale);0!=p&&(z+="rotate("+p+","+-t+","+-q+")");u.setAttribute("transform","translate("+(Math.round(a)+this.foOffset)+","+(Math.round(b)+this.foOffset)+ +")"+z);x.setAttribute("width",Math.round(Math.max(1,c)));x.setAttribute("height",Math.round(Math.max(1,d)));this.root.ownerDocument!=document&&(a=this.createAlternateContent(x,a,b,c,d,e,f,g,k,l,m,n,p),null!=a&&(x.setAttribute("requiredFeatures","http://www.w3.org/TR/SVG11/feature#Extensibility"),c=this.createElement("switch"),c.appendChild(x),c.appendChild(a),u.appendChild(c)))}}else this.plainText(a,b,c,d,e,f,g,k,m,n,p,q)}}; +mxSvgCanvas2D.prototype.createClip=function(a,b,c,d){a=Math.round(a);b=Math.round(b);c=Math.round(c);d=Math.round(d);for(var e="mx-clip-"+a+"-"+b+"-"+c+"-"+d,f=0,g=e+"-"+f;null!=document.getElementById(g);)g=e+"-"+ ++f;clip=this.createElement("clipPath");clip.setAttribute("id",g);e=this.createElement("rect");e.setAttribute("x",a);e.setAttribute("y",b);e.setAttribute("width",c);e.setAttribute("height",d);clip.appendChild(e);return clip}; +mxSvgCanvas2D.prototype.plainText=function(a,b,c,d,e,f,g,k,l,m,n,p){n=null!=n?n:0;k=this.state;var q=k.fontSize,r=this.createElement("g"),t=k.transform||"";this.updateFont(r);0!=n&&(t+="rotate("+n+","+this.format(a*k.scale)+","+this.format(b*k.scale)+")");null!=p&&r.setAttribute("direction",p);m&&0k.alpha&&r.setAttribute("opacity",k.alpha);t=e.split("\n");p=Math.round(q*mxConstants.LINE_HEIGHT);var u=q+(t.length-1)*p;n=b+q-1;g==mxConstants.ALIGN_MIDDLE?"fill"==l?n-=d/2:(m=(this.matchHtmlAlignment&&m&&0"),document.body.appendChild(n),e=n.offsetWidth,f=n.offsetHeight,n.parentNode.removeChild(n),g==mxConstants.ALIGN_CENTER?c-=e/2:g==mxConstants.ALIGN_RIGHT&&(c-=e),k==mxConstants.ALIGN_MIDDLE?d-=f/2:k==mxConstants.ALIGN_BOTTOM&&(d-=f),n=new mxRectangle((c+1)*m.scale,(d+2)*m.scale,e*m.scale,(f+1)*m.scale);null!=n&&(b= +this.createElement("rect"),b.setAttribute("fill",m.fontBackgroundColor||"none"),b.setAttribute("stroke",m.fontBorderColor||"none"),b.setAttribute("x",Math.floor(n.x-1)),b.setAttribute("y",Math.floor(n.y-1)),b.setAttribute("width",Math.ceil(n.width+2)),b.setAttribute("height",Math.ceil(n.height)),m=null!=m.fontBorderColor?Math.max(1,this.format(m.scale)):0,b.setAttribute("stroke-width",m),this.root.ownerDocument==document&&1==mxUtils.mod(m,2)&&b.setAttribute("transform","translate(0.5, 0.5)"),a.insertBefore(b, +a.firstChild))}};mxSvgCanvas2D.prototype.stroke=function(){this.addNode(!1,!0)};mxSvgCanvas2D.prototype.fill=function(){this.addNode(!0,!1)};mxSvgCanvas2D.prototype.fillAndStroke=function(){this.addNode(!0,!0)};var mxVmlCanvas2D=function(a){mxAbstractCanvas2D.call(this);this.root=a};mxUtils.extend(mxVmlCanvas2D,mxAbstractCanvas2D);mxVmlCanvas2D.prototype.node=null;mxVmlCanvas2D.prototype.textEnabled=!0;mxVmlCanvas2D.prototype.moveOp="m";mxVmlCanvas2D.prototype.lineOp="l"; +mxVmlCanvas2D.prototype.curveOp="c";mxVmlCanvas2D.prototype.closeOp="x";mxVmlCanvas2D.prototype.rotatedHtmlBackground="";mxVmlCanvas2D.prototype.vmlScale=1;mxVmlCanvas2D.prototype.createElement=function(a){return document.createElement(a)};mxVmlCanvas2D.prototype.createVmlElement=function(a){return this.createElement(mxClient.VML_PREFIX+":"+a)}; +mxVmlCanvas2D.prototype.addNode=function(a,b){var c=this.node,d=this.state;if(null!=c){if("shape"==c.nodeName)if(null!=this.path&&0a.alpha||1>a.fillAlpha)b.opacity=a.alpha*a.fillAlpha*100+"%";return b}; +mxVmlCanvas2D.prototype.createStroke=function(){var a=this.state,b=this.createVmlElement("stroke");b.endcap=a.lineCap||"flat";b.joinstyle=a.lineJoin||"miter";b.miterlimit=a.miterLimit||"10";if(1>a.alpha||1>a.strokeAlpha)b.opacity=a.alpha*a.strokeAlpha*100+"%";a.dashed&&(b.dashstyle=this.getVmlDashStyle());return b};mxVmlCanvas2D.prototype.getVmlDashStyle=function(){var a="dash";if("string"===typeof this.state.dashPattern){var b=this.state.dashPattern.split(" ");0this.state.alpha||1>this.state.fillAlpha)a.style.filter+="alpha(opacity="+this.state.alpha*this.state.fillAlpha*100+")";this.root.appendChild(a)}; +mxVmlCanvas2D.prototype.createDiv=function(a,b,c,d){c=this.createElement("div");var e=this.state,f="";null!=e.fontBackgroundColor&&(f+="background-color:"+e.fontBackgroundColor+";");null!=e.fontBorderColor&&(f+="border:1px solid "+e.fontBorderColor+";");mxUtils.isNode(a)?c.appendChild(a):"fill"!=d&&"width"!=d?(d=this.createElement("div"),d.style.cssText=f,d.style.display=mxClient.IS_QUIRKS?"inline":"inline-block",d.style.zoom="1",d.style.textDecoration="inherit",d.innerHTML=a,c.appendChild(d)):(c.style.cssText= +f,c.innerHTML=a);a=c.style;a.fontSize=e.fontSize/this.vmlScale+"px";a.fontFamily=e.fontFamily;a.color=e.fontColor;a.verticalAlign="top";a.textAlign=b||"left";a.lineHeight=mxConstants.ABSOLUTE_LINE_HEIGHT?e.fontSize*mxConstants.LINE_HEIGHT/this.vmlScale+"px":mxConstants.LINE_HEIGHT;(e.fontStyle&mxConstants.FONT_BOLD)==mxConstants.FONT_BOLD&&(a.fontWeight="bold");(e.fontStyle&mxConstants.FONT_ITALIC)==mxConstants.FONT_ITALIC&&(a.fontStyle="italic");(e.fontStyle&mxConstants.FONT_UNDERLINE)==mxConstants.FONT_UNDERLINE&& +(a.textDecoration="underline");return c}; +mxVmlCanvas2D.prototype.text=function(a,b,c,d,e,f,g,k,l,m,n,p,q){if(this.textEnabled&&null!=e){var r=this.state;if("html"==l){null!=r.rotation&&(b=this.rotatePoint(a,b,r.rotation,r.rotationCx,r.rotationCy),a=b.x,b=b.y);8!=document.documentMode||mxClient.IS_EM?(a*=r.scale,b*=r.scale):(a+=r.dx,b+=r.dy,"fill"!=m&&g==mxConstants.ALIGN_TOP&&--b);l=8!=document.documentMode||mxClient.IS_EM?this.createElement("div"):this.createVmlElement("group");l.style.position="absolute";l.style.display="inline";l.style.left= +this.format(a)+"px";l.style.top=this.format(b)+"px";l.style.zoom=r.scale;var t=this.createElement("div");t.style.position="relative";t.style.display="inline";var u=mxUtils.getAlignmentAsPoint(f,g),x=u.x,u=u.y;e=this.createDiv(e,f,g,m);f=this.createElement("div");null!=q&&e.setAttribute("dir",q);if(k&&0y&&(y+=2*Math.PI);y%=Math.PI;y>Math.PI/2&&(y=Math.PI-y);g=Math.cos(y);var A=Math.sin(y);8!=document.documentMode||mxClient.IS_EM||(e.style.display="inline-block",f.style.display="inline-block",t.style.display="inline-block");e.style.visibility="hidden";e.style.position="absolute";document.body.appendChild(e);t=e;null!=t.firstChild&&"DIV"==t.firstChild.nodeName&&(t=t.firstChild);y=t.offsetWidth+3;t=t.offsetHeight;n?(c=Math.min(c,y),t= +Math.min(t,d)):c=y;k&&(e.style.width=c+"px");mxClient.IS_QUIRKS&&(n||"width"==m)&&t>d&&(t=d,e.style.height=t+"px");d=t;n=(d-d*g+c*-A)/2-q*c*(x+.5)+p*d*(u+.5);k=(c-c*g+d*-A)/2+p*c*(x+.5)+q*d*(u+.5);"group"==l.nodeName&&"DIV"==this.root.nodeName?(m=this.createElement("div"),m.style.display="inline-block",m.style.position="absolute",m.style.left=this.format(a+(k-c/2)*r.scale)+"px",m.style.top=this.format(b+(n-d/2)*r.scale)+"px",l.parentNode.appendChild(m),m.appendChild(l)):(r=8!=document.documentMode|| +mxClient.IS_EM?r.scale:1,l.style.left=this.format(a+(k-c/2)*r)+"px",l.style.top=this.format(b+(n-d/2)*r)+"px");f.style.filter="progid:DXImageTransform.Microsoft.Matrix(M11="+p+", M12="+q+", M21="+-q+", M22="+p+", sizingMethod='auto expand')";f.style.backgroundColor=this.rotatedHtmlBackground;1>this.state.alpha&&(f.style.filter+="alpha(opacity="+100*this.state.alpha+")");f.appendChild(e);e.style.position="";e.style.visibility=""}else 8!=document.documentMode||mxClient.IS_EM?(e.style.verticalAlign= +"top",1>this.state.alpha&&(l.style.filter="alpha(opacity="+100*this.state.alpha+")"),r=e.parentNode,e.style.visibility="hidden",document.body.appendChild(e),c=e.offsetWidth,t=e.offsetHeight,mxClient.IS_QUIRKS&&n&&t>d&&(t=d,e.style.height=t+"px"),d=t,e.style.visibility="",r.appendChild(e),l.style.left=this.format(a+c*x*this.state.scale)+"px",l.style.top=this.format(b+d*u*this.state.scale)+"px"):(1>this.state.alpha&&(e.style.filter="alpha(opacity="+100*this.state.alpha+")"),t.style.left=100*x+"%",t.style.top= +100*u+"%")}else this.plainText(a,b,c,d,mxUtils.htmlEntities(e,!1),f,g,k,l,m,n,p,q)}}; +mxVmlCanvas2D.prototype.plainText=function(a,b,c,d,e,f,g,k,l,m,n,p,q){k=this.state;a=(a+k.dx)*k.scale;b=(b+k.dy)*k.scale;c=this.createVmlElement("shape");c.style.width="1px";c.style.height="1px";c.stroked="false";d=this.createVmlElement("fill");d.color=k.fontColor;d.opacity=100*k.alpha+"%";c.appendChild(d);d=this.createVmlElement("path");d.textpathok="true";d.v="m "+this.format(0)+" "+this.format(0)+" l "+this.format(1)+" "+this.format(0);c.appendChild(d);d=this.createVmlElement("textpath");d.style.cssText= +"v-text-align:"+f;d.style.align=f;d.style.fontFamily=k.fontFamily;d.string=e;d.on="true";f=k.fontSize*k.scale/this.vmlScale;d.style.fontSize=f+"px";(k.fontStyle&mxConstants.FONT_BOLD)==mxConstants.FONT_BOLD&&(d.style.fontWeight="bold");(k.fontStyle&mxConstants.FONT_ITALIC)==mxConstants.FONT_ITALIC&&(d.style.fontStyle="italic");(k.fontStyle&mxConstants.FONT_UNDERLINE)==mxConstants.FONT_UNDERLINE&&(d.style.textDecoration="underline");e=e.split("\n");k=f+(e.length-1)*f*mxConstants.LINE_HEIGHT;f=e=0; +g==mxConstants.ALIGN_BOTTOM?f=-k/2:g!=mxConstants.ALIGN_MIDDLE&&(f=k/2);null!=p&&(c.style.rotation=p,g=Math.PI/180*p,e=Math.sin(g)*f,f*=Math.cos(g));c.appendChild(d);c.style.left=this.format(a-e)+"px";c.style.top=this.format(b+f)+"px";this.root.appendChild(c)};mxVmlCanvas2D.prototype.stroke=function(){this.addNode(!1,!0)};mxVmlCanvas2D.prototype.fill=function(){this.addNode(!0,!1)};mxVmlCanvas2D.prototype.fillAndStroke=function(){this.addNode(!0,!0)}; +function mxGuide(a,b){this.graph=a;this.setStates(b)}mxGuide.prototype.graph=null;mxGuide.prototype.states=null;mxGuide.prototype.horizontal=!0;mxGuide.prototype.vertical=!0;mxGuide.prototype.guideX=null;mxGuide.prototype.guideY=null;mxGuide.prototype.setStates=function(a){this.states=a};mxGuide.prototype.isEnabledForEvent=function(a){return!0};mxGuide.prototype.getGuideTolerance=function(){return this.graph.gridSize/2}; +mxGuide.prototype.createGuideShape=function(a){a=new mxPolyline([],mxConstants.GUIDE_COLOR,mxConstants.GUIDE_STROKEWIDTH);a.isDashed=!0;return a}; +mxGuide.prototype.move=function(a,b,c){if(null!=this.states&&(this.horizontal||this.vertical)&&null!=a&&null!=b){var d=function(b){b+=this.graph.panDy;var c=!1;Math.abs(b-F)this.opacity&&(b+="alpha(opacity="+this.opacity+")");this.isShadow&&(b+="progid:DXImageTransform.Microsoft.dropShadow (OffX='"+Math.round(mxConstants.SHADOW_OFFSET_X*this.scale)+"', OffY='"+Math.round(mxConstants.SHADOW_OFFSET_Y*this.scale)+"', Color='"+mxConstants.VML_SHADOWCOLOR+"')");if(null!=this.fill&&this.fill!=mxConstants.NONE&&this.gradient&&this.gradient!=mxConstants.NONE){var c=this.fill,d=this.gradient,e="0",f={east:0,south:1, +west:2,north:3},g=null!=this.direction?f[this.direction]:0;null!=this.gradientDirection&&(g=mxUtils.mod(g+f[this.gradientDirection]-1,4));1==g?(e="1",f=c,c=d,d=f):2==g?(f=c,c=d,d=f):3==g&&(e="1");b+="progid:DXImageTransform.Microsoft.gradient(startColorStr='"+c+"', endColorStr='"+d+"', gradientType='"+e+"')"}a.style.filter=b}; +mxShape.prototype.updateHtmlColors=function(a){var b=this.stroke;null!=b&&b!=mxConstants.NONE?(a.style.borderColor=b,this.isDashed?a.style.borderStyle="dashed":0mxUtils.indexOf(f,l-1))){var p=Math.sqrt(n*n+m*m);a.lineTo(g.x+n*Math.min(d,p/2)/p,g.y+m*Math.min(d,p/2)/p);for(m=b[mxUtils.mod(l+ +1,b.length)];l
"));var m=!mxUtils.isNode(this.value)&&this.replaceLinefeeds&&"html"==l?m.replace(/\n/g,"
"):m,n=this.textDirection;n!=mxConstants.TEXT_DIRECTION_AUTO||k||(n=this.getAutoDirection());n!=mxConstants.TEXT_DIRECTION_LTR&&n!=mxConstants.TEXT_DIRECTION_RTL&&(n=null); +a.text(d,e,f,c,m,this.align,this.valign,this.wrap,l,this.overflow,this.clipped,this.getTextRotation(),n)}this.lastUnscaledWidth=g}; +mxText.prototype.redraw=function(){if(this.visible&&this.checkBounds()&&this.cacheEnabled&&this.lastValue==this.value&&(mxUtils.isNode(this.value)||this.dialect==mxConstants.DIALECT_STRICTHTML))if("DIV"!=this.node.nodeName||!this.isHtmlAllowed()&&mxClient.IS_VML){var a=this.createCanvas();null!=a&&null!=a.updateText&&null!=a.invalidateCachedOffsetSize?(this.paint(a,!0),this.destroyCanvas(a),this.updateBoundingBox()):mxShape.prototype.redraw.apply(this,arguments)}else this.updateSize(this.node,null== +this.state||null==this.state.view.textDiv),mxClient.IS_IE&&(null==document.documentMode||8>=document.documentMode)?this.updateHtmlFilter():this.updateHtmlTransform(),this.updateBoundingBox();else mxShape.prototype.redraw.apply(this,arguments),mxUtils.isNode(this.value)||this.dialect==mxConstants.DIALECT_STRICTHTML?this.lastValue=this.value:this.lastValue=null}; +mxText.prototype.resetStyles=function(){mxShape.prototype.resetStyles.apply(this,arguments);this.color="black";this.align=mxConstants.ALIGN_CENTER;this.valign=mxConstants.ALIGN_MIDDLE;this.family=mxConstants.DEFAULT_FONTFAMILY;this.size=mxConstants.DEFAULT_FONTSIZE;this.fontStyle=mxConstants.DEFAULT_FONTSTYLE;this.spacingLeft=this.spacingBottom=this.spacingRight=this.spacingTop=this.spacing=2;this.horizontal=!0;delete this.background;delete this.border;this.textDirection=mxConstants.DEFAULT_TEXT_DIRECTION; +delete this.margin}; +mxText.prototype.apply=function(a){var b=this.spacing;mxShape.prototype.apply.apply(this,arguments);null!=this.style&&(this.fontStyle=mxUtils.getValue(this.style,mxConstants.STYLE_FONTSTYLE,this.fontStyle),this.family=mxUtils.getValue(this.style,mxConstants.STYLE_FONTFAMILY,this.family),this.size=mxUtils.getValue(this.style,mxConstants.STYLE_FONTSIZE,this.size),this.color=mxUtils.getValue(this.style,mxConstants.STYLE_FONTCOLOR,this.color),this.align=mxUtils.getValue(this.style,mxConstants.STYLE_ALIGN, +this.align),this.valign=mxUtils.getValue(this.style,mxConstants.STYLE_VERTICAL_ALIGN,this.valign),this.spacing=parseInt(mxUtils.getValue(this.style,mxConstants.STYLE_SPACING,this.spacing)),this.spacingTop=parseInt(mxUtils.getValue(this.style,mxConstants.STYLE_SPACING_TOP,this.spacingTop-b))+this.spacing,this.spacingRight=parseInt(mxUtils.getValue(this.style,mxConstants.STYLE_SPACING_RIGHT,this.spacingRight-b))+this.spacing,this.spacingBottom=parseInt(mxUtils.getValue(this.style,mxConstants.STYLE_SPACING_BOTTOM, +this.spacingBottom-b))+this.spacing,this.spacingLeft=parseInt(mxUtils.getValue(this.style,mxConstants.STYLE_SPACING_LEFT,this.spacingLeft-b))+this.spacing,this.horizontal=mxUtils.getValue(this.style,mxConstants.STYLE_HORIZONTAL,this.horizontal),this.background=mxUtils.getValue(this.style,mxConstants.STYLE_LABEL_BACKGROUNDCOLOR,this.background),this.border=mxUtils.getValue(this.style,mxConstants.STYLE_LABEL_BORDERCOLOR,this.border),this.textDirection=mxUtils.getValue(this.style,mxConstants.STYLE_TEXT_DIRECTION, +mxConstants.DEFAULT_TEXT_DIRECTION),this.opacity=mxUtils.getValue(this.style,mxConstants.STYLE_TEXT_OPACITY,100),this.updateMargin());this.flipH=this.flipV=null};mxText.prototype.getAutoDirection=function(){var a=/[A-Za-z\u05d0-\u065f\u066a-\u06ef\u06fa-\u07ff\ufb1d-\ufdff\ufe70-\ufefc]/.exec(this.value);return null!=a&&0=document.documentMode)?this.updateHtmlFilter():this.updateHtmlTransform()}; +mxText.prototype.updateHtmlTransform=function(){var a=this.getTextRotation(),b=this.node.style,c=this.margin.x,d=this.margin.y;0!=a?(mxUtils.setPrefixedStyle(b,"transformOrigin",100*-c+"% "+100*-d+"%"),mxUtils.setPrefixedStyle(b,"transform","translate("+100*c+"%,"+100*d+"%)scale("+this.scale+") rotate("+a+"deg)")):(mxUtils.setPrefixedStyle(b,"transformOrigin","0% 0%"),mxUtils.setPrefixedStyle(b,"transform","scale("+this.scale+")translate("+100*c+"%,"+100*d+"%)"));b.left=Math.round(this.bounds.x-Math.ceil(c* +("fill"!=this.overflow&&"width"!=this.overflow?3:1)))+"px";b.top=Math.round(this.bounds.y-d*("fill"!=this.overflow?3:1))+"px";b.opacity=100>this.opacity?this.opacity/100:""}; +mxText.prototype.updateInnerHtml=function(a){if(mxUtils.isNode(this.value))a.innerHTML=this.value.outerHTML;else{var b=this.value;this.dialect!=mxConstants.DIALECT_STRICTHTML&&(b=mxUtils.htmlEntities(b,!1));b=mxUtils.replaceTrailingNewlines(b,"
 
");b=this.replaceLinefeeds?b.replace(/\n/g,"
"):b;a.innerHTML='
'+b+"
"}}; +mxText.prototype.updateHtmlFilter=function(){var a=this.node.style,b=this.margin.x,c=this.margin.y,d=this.scale;mxUtils.setOpacity(this.node,this.opacity);var e,f=0,g=null!=this.state?this.state.view.textDiv:null,k=this.node;if(null!=g){g.style.overflow="";g.style.height="";g.style.width="";this.updateFont(g);this.updateSize(g,!1);this.updateInnerHtml(g);var l=Math.round(this.bounds.width/this.scale);this.wrap&&0m&&(m+=2*Math.PI);m%=Math.PI;m>Math.PI/2&&(m=Math.PI-m);var k=Math.cos(m),n=Math.sin(-m),b=l*-(b+.5),p=g*-(c+.5);0!=m&&(c="progid:DXImageTransform.Microsoft.Matrix(M11="+e+", M12="+f+", M21="+-f+", M22="+e+", sizingMethod='auto expand')",a.filter=null!=a.filter&&0
"),a=this.replaceLinefeeds?a.replace(/\n/g,"
"):a,b=null!=this.background&&this.background!=mxConstants.NONE?this.background:null,c=null!=this.border&&this.border!=mxConstants.NONE?this.border:null;if("fill"==this.overflow|| +"width"==this.overflow)null!=b&&(this.node.style.backgroundColor=b),null!=c&&(this.node.style.border="1px solid "+c);else{var d="";null!=b&&(d+="background-color:"+b+";");null!=c&&(d+="border:1px solid "+c+";");a='
'+a+"
"}this.node.innerHTML=a;a=this.node.getElementsByTagName("div"); +0=document.documentMode)&&0!=this.rotation?mxClient.VML_PREFIX+":image":"img");a.setAttribute("border","0");a.style.position="absolute";a.src=this.image;b=100>this.opacity?"alpha(opacity="+this.opacity+")":"";this.node.style.filter=b;this.flipH&&this.flipV?b+="progid:DXImageTransform.Microsoft.BasicImage(rotation=2)":this.flipH?b+="progid:DXImageTransform.Microsoft.BasicImage(mirror=1)":this.flipV&& +(b+="progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)");a.style.filter!=b&&(a.style.filter=b);"image"==a.nodeName?a.style.rotation=this.rotation:0!=this.rotation?mxUtils.setPrefixedStyle(a.style,"transform","rotate("+this.rotation+"deg)"):mxUtils.setPrefixedStyle(a.style,"transform","");a.style.width=this.node.style.width;a.style.height=this.node.style.height;this.node.style.backgroundImage="";this.node.appendChild(a)}else this.setTransparentBackgroundImage(this.node)}; +function mxLabel(a,b,c,d){mxRectangleShape.call(this,a,b,c,d)}mxUtils.extend(mxLabel,mxRectangleShape);mxLabel.prototype.imageSize=mxConstants.DEFAULT_IMAGESIZE;mxLabel.prototype.spacing=2;mxLabel.prototype.indicatorSize=10;mxLabel.prototype.indicatorSpacing=2;mxLabel.prototype.init=function(a){mxShape.prototype.init.apply(this,arguments);null!=this.indicatorShape&&(this.indicator=new this.indicatorShape,this.indicator.dialect=this.dialect,this.indicator.init(this.node))}; +mxLabel.prototype.redraw=function(){null!=this.indicator&&(this.indicator.fill=this.indicatorColor,this.indicator.stroke=this.indicatorStrokeColor,this.indicator.gradient=this.indicatorGradientColor,this.indicator.direction=this.indicatorDirection);mxShape.prototype.redraw.apply(this,arguments)};mxLabel.prototype.isHtmlAllowed=function(){return mxRectangleShape.prototype.isHtmlAllowed.apply(this,arguments)&&null==this.indicatorColor&&null==this.indicatorShape}; +mxLabel.prototype.paintForeground=function(a,b,c,d,e){this.paintImage(a,b,c,d,e);this.paintIndicator(a,b,c,d,e);mxRectangleShape.prototype.paintForeground.apply(this,arguments)};mxLabel.prototype.paintImage=function(a,b,c,d,e){null!=this.image&&(b=this.getImageBounds(b,c,d,e),a.image(b.x,b.y,b.width,b.height,this.image,!1,!1,!1))}; +mxLabel.prototype.getImageBounds=function(a,b,c,d){var e=mxUtils.getValue(this.style,mxConstants.STYLE_IMAGE_ALIGN,mxConstants.ALIGN_LEFT),f=mxUtils.getValue(this.style,mxConstants.STYLE_IMAGE_VERTICAL_ALIGN,mxConstants.ALIGN_MIDDLE),g=mxUtils.getNumber(this.style,mxConstants.STYLE_IMAGE_WIDTH,mxConstants.DEFAULT_IMAGESIZE),k=mxUtils.getNumber(this.style,mxConstants.STYLE_IMAGE_HEIGHT,mxConstants.DEFAULT_IMAGESIZE),l=mxUtils.getNumber(this.style,mxConstants.STYLE_SPACING,this.spacing)+5;a=e==mxConstants.ALIGN_CENTER? +a+(c-g)/2:e==mxConstants.ALIGN_RIGHT?a+(c-g-l):a+l;b=f==mxConstants.ALIGN_TOP?b+l:f==mxConstants.ALIGN_BOTTOM?b+(d-k-l):b+(d-k)/2;return new mxRectangle(a,b,g,k)};mxLabel.prototype.paintIndicator=function(a,b,c,d,e){null!=this.indicator?(this.indicator.bounds=this.getIndicatorBounds(b,c,d,e),this.indicator.paint(a)):null!=this.indicatorImage&&(b=this.getIndicatorBounds(b,c,d,e),a.image(b.x,b.y,b.width,b.height,this.indicatorImage,!1,!1,!1))}; +mxLabel.prototype.getIndicatorBounds=function(a,b,c,d){var e=mxUtils.getValue(this.style,mxConstants.STYLE_IMAGE_ALIGN,mxConstants.ALIGN_LEFT),f=mxUtils.getValue(this.style,mxConstants.STYLE_IMAGE_VERTICAL_ALIGN,mxConstants.ALIGN_MIDDLE),g=mxUtils.getNumber(this.style,mxConstants.STYLE_INDICATOR_WIDTH,this.indicatorSize),k=mxUtils.getNumber(this.style,mxConstants.STYLE_INDICATOR_HEIGHT,this.indicatorSize),l=this.spacing+5;a=e==mxConstants.ALIGN_RIGHT?a+(c-g-l):e==mxConstants.ALIGN_CENTER?a+(c-g)/ +2:a+l;b=f==mxConstants.ALIGN_BOTTOM?b+(d-k-l):f==mxConstants.ALIGN_TOP?b+l:b+(d-k)/2;return new mxRectangle(a,b,g,k)}; +mxLabel.prototype.redrawHtmlShape=function(){for(mxRectangleShape.prototype.redrawHtmlShape.apply(this,arguments);this.node.hasChildNodes();)this.node.removeChild(this.node.lastChild);if(null!=this.image){var a=document.createElement("img");a.style.position="relative";a.setAttribute("border","0");var b=this.getImageBounds(this.bounds.x,this.bounds.y,this.bounds.width,this.bounds.height);b.x-=this.bounds.x;b.y-=this.bounds.y;a.style.left=Math.round(b.x)+"px";a.style.top=Math.round(b.y)+"px";a.style.width= +Math.round(b.width)+"px";a.style.height=Math.round(b.height)+"px";a.src=this.image;this.node.appendChild(a)}};function mxCylinder(a,b,c,d){mxShape.call(this);this.bounds=a;this.fill=b;this.stroke=c;this.strokewidth=null!=d?d:1}mxUtils.extend(mxCylinder,mxShape);mxCylinder.prototype.maxHeight=40;mxCylinder.prototype.svgStrokeTolerance=0; +mxCylinder.prototype.paintVertexShape=function(a,b,c,d,e){a.translate(b,c);a.begin();this.redrawPath(a,b,c,d,e,!1);a.fillAndStroke();a.setShadow(!1);a.begin();this.redrawPath(a,b,c,d,e,!0);a.stroke()}; +mxCylinder.prototype.redrawPath=function(a,b,c,d,e,f){b=Math.min(this.maxHeight,Math.round(e/5));if(f&&null!=this.fill||!f&&null==this.fill)a.moveTo(0,b),a.curveTo(0,2*b,d,2*b,d,b),f||(a.stroke(),a.begin());f||(a.moveTo(0,b),a.curveTo(0,-b/3,d,-b/3,d,b),a.lineTo(d,e-b),a.curveTo(d,e+b/3,0,e+b/3,0,e-b),a.close())};function mxConnector(a,b,c){mxPolyline.call(this,a,b,c)}mxUtils.extend(mxConnector,mxPolyline); +mxConnector.prototype.updateBoundingBox=function(){this.useSvgBoundingBox=null!=this.style&&1==this.style[mxConstants.STYLE_CURVED];mxShape.prototype.updateBoundingBox.apply(this,arguments)};mxConnector.prototype.paintEdgeShape=function(a,b){var c=this.createMarker(a,b,!0),d=this.createMarker(a,b,!1);mxPolyline.prototype.paintEdgeShape.apply(this,arguments);a.setFillColor(this.stroke);a.setShadow(!1);a.setDashed(!1);null!=c&&c();null!=d&&d()}; +mxConnector.prototype.createMarker=function(a,b,c){var d=null,e=b.length,f=mxUtils.getValue(this.style,c?mxConstants.STYLE_STARTARROW:mxConstants.STYLE_ENDARROW),g=c?b[1]:b[e-2],k=c?b[0]:b[e-1];if(null!=f&&null!=g&&null!=k){for(d=1;d=e)&&a.close(),a.fillAndStroke(),f=d)&& +a.close(),a.fillAndStroke(),f=e)&&a.close(),a.fillAndStroke(),f=d)&&a.close(),a.fillAndStroke(),fa.weightedValue?-1:b.weightedValuec)break;g=l}}f=e.getIndex(a);f=Math.max(0,b-(b>f?1:0));d.add(e,a,f)}}; +mxStackLayout.prototype.getParentSize=function(a){var b=this.graph.getModel(),c=b.getGeometry(a);null!=this.graph.container&&(null==c&&b.isLayer(a)||a==this.graph.getView().currentRoot)&&(c=new mxRectangle(0,0,this.graph.container.offsetWidth-1,this.graph.container.offsetHeight-1));return c}; +mxStackLayout.prototype.execute=function(a){if(null!=a){var b=this.getParentSize(a),c=this.isHorizontal(),d=this.graph.getModel(),e=null;null!=b&&(e=c?b.height-this.marginTop-this.marginBottom:b.width-this.marginLeft-this.marginRight);var e=e-2*this.border,f=this.x0+this.border+this.marginLeft,g=this.y0+this.border+this.marginTop;if(this.graph.isSwimlane(a)){var k=this.graph.getCellStyle(a),l=mxUtils.getNumber(k,mxConstants.STYLE_STARTSIZE,mxConstants.DEFAULT_STARTSIZE),k=1==mxUtils.getValue(k,mxConstants.STYLE_HORIZONTAL, +!0);null!=b&&(l=k?Math.min(l,b.height):Math.min(l,b.width));c==k&&(e-=l);k?g+=l:f+=l}d.beginUpdate();try{for(var l=0,k=null,m=0,n=null,p=d.getChildCount(a),q=0;qthis.wrap||!c&&k.y+k.height+t.height+2*this.spacing>this.wrap)&&(k=null,c?g+=l+this.spacing:f+=l+this.spacing,l=0);var l=Math.max(l,c?t.height: +t.width),u=0;if(!this.borderCollapse)var x=this.graph.getCellStyle(r),u=mxUtils.getNumber(x,mxConstants.STYLE_STROKEWIDTH,1);null!=k?c?t.x=m+this.spacing+Math.floor(u/2):t.y=m+this.spacing+Math.floor(u/2):this.keepFirstLocation||(c?t.x=f:t.y=g);c?t.y=g:t.x=f;this.fill&&null!=e&&(c?t.height=e:t.width=e);this.setChildGeometry(r,t);n=r;k=t;m=c?k.x+k.width+Math.floor(u/2):k.y+k.height+Math.floor(u/2)}}}this.resizeParent&&null!=b&&null!=k&&!this.graph.isCellCollapsed(a)?this.updateParentGeometry(a,b,k): +this.resizeLast&&null!=b&&null!=k&&null!=n&&(c?k.width=b.width-k.x-this.spacing-this.marginRight-this.marginLeft:k.height=b.height-k.y-this.spacing-this.marginBottom,this.setChildGeometry(n,k))}finally{d.endUpdate()}}};mxStackLayout.prototype.setChildGeometry=function(a,b){var c=this.graph.getCellGeometry(a);null!=c&&b.x==c.x&&b.y==c.y&&b.width==c.width&&b.height==c.height||this.graph.getModel().setGeometry(a,b)}; +mxStackLayout.prototype.updateParentGeometry=function(a,b,c){var d=this.isHorizontal(),e=this.graph.getModel(),f=b.clone();d?(c=c.x+c.width+this.marginRight+this.border,f.width=this.resizeParentMax?Math.max(f.width,c):c):(c=c.y+c.height+this.marginBottom+this.border,f.height=this.resizeParentMax?Math.max(f.height,c):c);b.x==f.x&&b.y==f.y&&b.width==f.width&&b.height==f.height||e.setGeometry(a,f)}; +function mxPartitionLayout(a,b,c,d){mxGraphLayout.call(this,a);this.horizontal=null!=b?b:!0;this.spacing=c||0;this.border=d||0}mxPartitionLayout.prototype=new mxGraphLayout;mxPartitionLayout.prototype.constructor=mxPartitionLayout;mxPartitionLayout.prototype.horizontal=null;mxPartitionLayout.prototype.spacing=null;mxPartitionLayout.prototype.border=null;mxPartitionLayout.prototype.resizeVertices=!0;mxPartitionLayout.prototype.isHorizontal=function(){return this.horizontal}; +mxPartitionLayout.prototype.moveCell=function(a,b,c){c=this.graph.getModel();var d=c.getParent(a);if(null!=a&&null!=d){var e,f=0,g=c.getChildCount(d);for(e=0;eb)break;f=k}}b=d.getIndex(a);b=Math.max(0,e-(e>b?1:0));c.add(d,a,b)}}; +mxPartitionLayout.prototype.execute=function(a){var b=this.isHorizontal(),c=this.graph.getModel(),d=c.getGeometry(a);null!=this.graph.container&&(null==d&&c.isLayer(a)||a==this.graph.getView().currentRoot)&&(d=new mxRectangle(0,0,this.graph.container.offsetWidth-1,this.graph.container.offsetHeight-1));if(null!=d){for(var e=[],f=c.getChildCount(a),g=0;gk.x&&(e=Math.abs(g-k.x));0>k.y&&(l=Math.abs(d-k.y));0==e&&0==l||this.moveNode(this.node,e,l);this.resizeParent&&this.adjustParents();this.edgeRouting&&this.localEdgeProcessing(this.node)}null!=this.parentX&&null!=this.parentY&&(f=this.graph.getCellGeometry(a),null!=f&&(f=f.clone(),f.x=this.parentX,f.y=this.parentY,c.setGeometry(a,f)))}}finally{c.endUpdate()}}}; +mxCompactTreeLayout.prototype.moveNode=function(a,b,c){a.x+=b;a.y+=c;this.apply(a);for(a=a.child;null!=a;)this.moveNode(a,b,c),a=a.next}; +mxCompactTreeLayout.prototype.sortOutgoingEdges=function(a,b){var c=new mxDictionary;b.sort(function(b,e){var d=b.getTerminal(b.getTerminal(!1)==a),g=c.get(d);null==g&&(g=mxCellPath.create(d).split(mxCellPath.PATH_SEPARATOR),c.put(d,g));var d=e.getTerminal(e.getTerminal(!1)==a),k=c.get(d);null==k&&(k=mxCellPath.create(d).split(mxCellPath.PATH_SEPARATOR),c.put(d,k));return mxCellPath.compare(g,k)})}; +mxCompactTreeLayout.prototype.findRankHeights=function(a,b){if(null==this.maxRankHeight[b]||this.maxRankHeight[b]a.height&&(a.height=this.maxRankHeight[b]);for(var c=a.child;null!=c;)this.setCellHeights(c,b+1),c=c.next}; +mxCompactTreeLayout.prototype.dfs=function(a,b){var c=mxCellPath.create(a),d=null;if(null!=a&&null==this.visited[c]&&!this.isVertexIgnored(a)){this.visited[c]=a;var d=this.createNode(a),c=this.graph.getModel(),e=null,f=this.graph.getEdges(a,b,this.invert,!this.invert,!1,!0),g=this.graph.getView();this.sortEdges&&this.sortOutgoingEdges(a,f);for(var k=0;k=a+c)return 0;a=0a?a*d/c-b:0a+c?(c+a)*f/e-(b+d):f-(b+d);return 0g+2*this.prefHozEdgeSep&&(f-=2*this.prefHozEdgeSep);a=f/d;b=a/2;f>g+2*this.prefHozEdgeSep&&(b+=this.prefHozEdgeSep);for(var f=this.minEdgeJetty-this.prefVertEdgeOff,g=this.getVertexBounds(c),k=0;kd/2&&(f-=this.prefVertEdgeOff);b+=a}}; +function mxRadialTreeLayout(a){mxCompactTreeLayout.call(this,a,!1)}mxUtils.extend(mxRadialTreeLayout,mxCompactTreeLayout);mxRadialTreeLayout.prototype.angleOffset=.5;mxRadialTreeLayout.prototype.rootx=0;mxRadialTreeLayout.prototype.rooty=0;mxRadialTreeLayout.prototype.levelDistance=120;mxRadialTreeLayout.prototype.nodeDistance=10;mxRadialTreeLayout.prototype.autoRadius=!1;mxRadialTreeLayout.prototype.sortEdges=!1;mxRadialTreeLayout.prototype.rowMinX=[];mxRadialTreeLayout.prototype.rowMaxX=[]; +mxRadialTreeLayout.prototype.rowMinCenX=[];mxRadialTreeLayout.prototype.rowMaxCenX=[];mxRadialTreeLayout.prototype.rowRadi=[];mxRadialTreeLayout.prototype.row=[];mxRadialTreeLayout.prototype.isVertexIgnored=function(a){return mxGraphLayout.prototype.isVertexIgnored.apply(this,arguments)||0==this.graph.getConnections(a).length}; +mxRadialTreeLayout.prototype.execute=function(a,b){this.parent=a;this.edgeRouting=this.useBoundingBox=!1;mxCompactTreeLayout.prototype.execute.apply(this,arguments);var c=null,d=this.getVertexBounds(this.root);this.centerX=d.x+d.width/2;this.centerY=d.y+d.height/2;for(var e in this.visited){var f=this.getVertexBounds(this.visited[e]),c=null!=c?c:f.clone();c.add(f)}this.calcRowDims([this.node],0);for(var g=0,k=0,c=0;c +d.theta&&ethis.forceConstant&&(this.forceConstant= +.001);this.forceConstantSquared=this.forceConstant*this.forceConstant;for(d=0;db&&(b=.001);var c=this.dispX[a]/b*Math.min(b,this.temperature),b=this.dispY[a]/b*Math.min(b,this.temperature);this.dispX[a]=0;this.dispY[a]=0;this.cellLocation[a][0]+=c;this.cellLocation[a][1]+=b}}; +mxFastOrganicLayout.prototype.calcAttraction=function(){for(var a=0;athis.maxDistanceLimit||(ga?a+"-"+c:c+"-"+a):null}; +mxParallelEdgeLayout.prototype.layout=function(a){var b=a[0],c=this.graph.getView(),d=this.graph.getModel(),e=d.getGeometry(c.getVisibleTerminal(b,!0)),d=d.getGeometry(c.getVisibleTerminal(b,!1));if(e==d)for(var b=e.x+e.width+this.spacing,c=e.y+e.height/2,f=0;fmxUtils.indexOf(l.connectsAsTarget,g)&&l.connectsAsTarget.push(g))}}c[d].temp[0]=1}}mxGraphHierarchyModel.prototype.maxRank=null;mxGraphHierarchyModel.prototype.vertexMapper=null;mxGraphHierarchyModel.prototype.edgeMapper=null;mxGraphHierarchyModel.prototype.ranks=null;mxGraphHierarchyModel.prototype.roots=null;mxGraphHierarchyModel.prototype.parent=null; +mxGraphHierarchyModel.prototype.dfsCount=0;mxGraphHierarchyModel.prototype.SOURCESCANSTARTRANK=1E8;mxGraphHierarchyModel.prototype.tightenToSource=!1; +mxGraphHierarchyModel.prototype.createInternalCells=function(a,b,c){for(var d=a.getGraph(),e=0;e=l.length){for(var k= +new mxGraphHierarchyEdge(l),m=0;mmxUtils.indexOf(c[e].connectsAsSource,k)&&c[e].connectsAsSource.push(k)}}}c[e].temp[0]=0}}; +mxGraphHierarchyModel.prototype.initialRank=function(){var a=[];if(null!=this.roots)for(var b=0;bc.maxRank&&0>c.minRank&&(a[c.temp[0]].push(c),c.maxRank=c.temp[0],c.minRank=c.temp[0],c.temp[0]=a[c.maxRank].length-1);if(null!=b&&null!=d&&1mxUtils.indexOf(l.connectsAsTarget,g)&&l.connectsAsTarget.push(g))}}c[d].temp[0]=1}}mxSwimlaneModel.prototype.maxRank=null;mxSwimlaneModel.prototype.vertexMapper=null;mxSwimlaneModel.prototype.edgeMapper=null;mxSwimlaneModel.prototype.ranks=null;mxSwimlaneModel.prototype.roots=null;mxSwimlaneModel.prototype.parent=null;mxSwimlaneModel.prototype.dfsCount=0; +mxSwimlaneModel.prototype.SOURCESCANSTARTRANK=1E8;mxSwimlaneModel.prototype.tightenToSource=!1;mxSwimlaneModel.prototype.ranksPerGroup=null; +mxSwimlaneModel.prototype.createInternalCells=function(a,b,c){for(var d=a.getGraph(),e=a.swimlanes,f=0;f=m.length){for(var l=new mxGraphHierarchyEdge(m),n=0;nmxUtils.indexOf(c[f].connectsAsSource,l)&&c[f].connectsAsSource.push(l)}}}c[f].temp[0]=0}}; +mxSwimlaneModel.prototype.initialRank=function(){this.ranksPerGroup=[];var a=[],b={};if(null!=this.roots)for(var c=0;cb[d.swimlaneIndex]&&(k=b[d.swimlaneIndex]);d.temp[0]=k;if(null!=f)for(c=0;cc.maxRank&&0>c.minRank&&(a[c.temp[0]].push(c),c.maxRank=c.temp[0],c.minRank=c.temp[0],c.temp[0]=a[c.maxRank].length-1);if(null!=b&&null!=d&&1>1,++e[l];return c}; +mxMedianHybridCrossingReduction.prototype.transpose=function(a,b){for(var c=!0,d=0;c&&10>d++;)for(var e=1==a%2&&1==d%2,c=!1,f=0;fn&&(n=l);k[n]=m}for(var p=null,q=null,r,t,u=null,x=null,y,A=null,l=0;lu[C]&&v++,r[z]x[C]&&v++,t[z]a.medianValue?-1:b.medianValuex+1&&(m==d[l].length-1?(e.setGeneralPurposeVariable(l,y),p=!0):(m=d[l][m+1],x=m.getGeneralPurposeVariable(l),x=x-m.width/2-this.intraCellSpacing-e.width/2,x>y?(e.setGeneralPurposeVariable(l, +y),p=!0):x>e.getGeneralPurposeVariable(l)+1&&(e.setGeneralPurposeVariable(l,x),p=!0)));if(p){for(e=0;e=k&&l<=q?g.setGeneralPurposeVariable(a,l):lq&&(g.setGeneralPurposeVariable(a,q),this.currentXDelta+=l-q);d[f].visited=!0}};mxCoordinateAssignment.prototype.calculatedWeightedValue=function(a,b){for(var c=0,d=0;dthis.widestRankValue&&(this.widestRankValue=k,this.widestRank=e);this.rankWidths[e]=k}1==l&&mxLog.warn("At least one cell has no bounds");this.rankY[e]=c;k=f/2+d/2+this.interRankCellSpacing;d=f;c=this.orientation==mxConstants.DIRECTION_NORTH||this.orientation==mxConstants.DIRECTION_WEST?c+k:c- +k;for(m=0;me.maxRank-e.minRank-1)){for(var f=e.getGeneralPurposeVariable(e.minRank+1),g=!0,k=0,l=e.minRank+2;le.minRank+1;l--)q=e.getX(l-1),p==q?(n[l-e.minRank-2]=p,g++):this.repositionValid(b,e,l-1,p)?(n[l-e.minRank-2]=p,g++):(n[l-e.minRank-2]=e.getX(l-1),p=q);if(g>k||f>k)if(g>=f)for(l=e.maxRank-2;l>e.minRank;l--)e.setX(l,n[l-e.minRank-1]);else if(f>g)for(l=e.minRank+2;le)return!1;f=b.getGeneralPurposeVariable(c);if(df){if(e==a.length-1)return!0;a=a[e+1];c=a.getGeneralPurposeVariable(c);c=c-a.width/2-this.intraCellSpacing-b.width/2;if(!(c>=d))return!1}return!0}; +mxCoordinateAssignment.prototype.setCellLocations=function(a,b){this.rankTopY=[];this.rankBottomY=[];for(var c=0;ck;k++){if(-1(f+1)*this.prefHozEdgeSep+2*this.prefHozEdgeSep&&(n+=this.prefHozEdgeSep,p-=this.prefHozEdgeSep);l=(p-n)/f;n+=l/2;p=this.minEdgeJetty-this.prefVertEdgeOff;for(m=0;mf/2&&(p-=this.prefVertEdgeOff),t=0;tf&&(f=l,e=k)}}0==c.length&&null!=e&&c.push(e)}return c}; +mxHierarchicalLayout.prototype.getEdges=function(a){var b=this.edgesCache.get(a);if(null!=b)return b;for(var c=this.graph.model,b=[],d=this.graph.isCellCollapsed(a),e=c.getChildCount(a),f=0;fb.length)){null==a&&(a=c.getParent(b[0]));this.parentY=this.parentX=null;if(a!=this.root&&null!=c.isVertex(a)&&this.maintainParentLocation){var d=this.graph.getCellGeometry(a);null!=d&&(this.parentX=d.x,this.parentY=d.y)}this.swimlanes=b;this.dummyVertices=[];for(var e=0;ef&&(f=l,e=k)}}0==c.length&&null!=e&&c.push(e)}return c}; +mxSwimlaneLayout.prototype.getEdges=function(a){var b=this.edgesCache.get(a);if(null!=b)return b;for(var c=this.graph.model,b=[],d=this.graph.isCellCollapsed(a),e=c.getChildCount(a),f=0;f=this.swimlanes.length||!(q>k||(!b||p)&&q==k)||(e=this.traverse(n, +b,m[c],d,e,f,g,q))}}else if(null==e[l])for(c=0;cmxUtils.indexOf(this.edges,a))&&(null==this.edges&&(this.edges=[]),this.edges.push(a));return a};mxCell.prototype.removeEdge=function(a,b){if(null!=a){if(a.getTerminal(!b)!=this&&null!=this.edges){var c=this.getEdgeIndex(a);0<=c&&this.edges.splice(c,1)}a.setTerminal(null,b)}return a}; +mxCell.prototype.removeFromTerminal=function(a){var b=this.getTerminal(a);null!=b&&b.removeEdge(this,a)};mxCell.prototype.hasAttribute=function(a){var b=this.getValue();return null!=b&&b.nodeType==mxConstants.NODETYPE_ELEMENT&&b.hasAttribute?b.hasAttribute(a):null!=b.getAttribute(a)};mxCell.prototype.getAttribute=function(a,b){var c=this.getValue();return(null!=c&&c.nodeType==mxConstants.NODETYPE_ELEMENT?c.getAttribute(a):null)||b}; +mxCell.prototype.setAttribute=function(a,b){var c=this.getValue();null!=c&&c.nodeType==mxConstants.NODETYPE_ELEMENT&&c.setAttribute(a,b)};mxCell.prototype.clone=function(){var a=mxUtils.clone(this,this.mxTransient);a.setValue(this.cloneValue());return a};mxCell.prototype.cloneValue=function(){var a=this.getValue();null!=a&&("function"==typeof a.clone?a=a.clone():isNaN(a.nodeType)||(a=a.cloneNode(!0)));return a};function mxGeometry(a,b,c,d){mxRectangle.call(this,a,b,c,d)}mxGeometry.prototype=new mxRectangle; +mxGeometry.prototype.constructor=mxGeometry;mxGeometry.prototype.TRANSLATE_CONTROL_POINTS=!0;mxGeometry.prototype.alternateBounds=null;mxGeometry.prototype.sourcePoint=null;mxGeometry.prototype.targetPoint=null;mxGeometry.prototype.points=null;mxGeometry.prototype.offset=null;mxGeometry.prototype.relative=!1; +mxGeometry.prototype.swap=function(){if(null!=this.alternateBounds){var a=new mxRectangle(this.x,this.y,this.width,this.height);this.x=this.alternateBounds.x;this.y=this.alternateBounds.y;this.width=this.alternateBounds.width;this.height=this.alternateBounds.height;this.alternateBounds=a}};mxGeometry.prototype.getTerminalPoint=function(a){return a?this.sourcePoint:this.targetPoint};mxGeometry.prototype.setTerminalPoint=function(a,b){b?this.sourcePoint=a:this.targetPoint=a;return a}; +mxGeometry.prototype.rotate=function(a,b){var c=mxUtils.toRadians(a),d=Math.cos(c),c=Math.sin(c);if(!this.relative){var e=new mxPoint(this.getCenterX(),this.getCenterY()),e=mxUtils.getRotatedPoint(e,d,c,b);this.x=Math.round(e.x-this.width/2);this.y=Math.round(e.y-this.height/2)}null!=this.sourcePoint&&(e=mxUtils.getRotatedPoint(this.sourcePoint,d,c,b),this.sourcePoint.x=Math.round(e.x),this.sourcePoint.y=Math.round(e.y));null!=this.targetPoint&&(e=mxUtils.getRotatedPoint(this.targetPoint,d,c,b),this.targetPoint.x= +Math.round(e.x),this.targetPoint.y=Math.round(e.y));if(null!=this.points)for(var f=0;fb[e]?1:-1:(c=parseInt(a[e]),e=parseInt(b[e]),d=c==e?0:c>e?1:-1);break}0==d&&(c=a.length,e=b.length,c!=e&&(d=c>e?1:-1));return d}},mxPerimeter={RectanglePerimeter:function(a,b,c,d){b=a.getCenterX();var e=a.getCenterY(),f=Math.atan2(c.y-e,c.x-b),g=new mxPoint(0,0),k=Math.PI,l=Math.PI/2-f,m=Math.atan2(a.height,a.width);f<-k+m||f>k-m?(g.x=a.x,g.y=e-a.width* +Math.tan(f)/2):f<-m?(g.y=a.y,g.x=b-a.height*Math.tan(l)/2):f=a.x&&c.x<=a.x+a.width?g.x=c.x:c.y>=a.y&&c.y<=a.y+a.height&&(g.y=c.y),c.xa.x+a.width&&(g.x=a.x+a.width),c.ya.y+a.height&&(g.y=a.y+a.height));return g},EllipsePerimeter:function(a,b,c,d){var e=a.x,f=a.y,g=a.width/2,k=a.height/2,l=e+g,m=f+k;b=c.x;c=c.y;var n=parseInt(b-l),p=parseInt(c-m);if(0==n&&0!=p)return new mxPoint(l, +m+k*p/Math.abs(p));if(0==n&&0==p)return new mxPoint(b,c);if(d){if(c>=f&&c<=f+a.height)return a=c-m,a=Math.sqrt(g*g*(1-a*a/(k*k)))||0,b<=e&&(a=-a),new mxPoint(l+a,c);if(b>=e&&b<=e+a.width)return a=b-l,a=Math.sqrt(k*k*(1-a*a/(g*g)))||0,c<=f&&(a=-a),new mxPoint(b,m+a)}e=p/n;m-=e*l;f=g*g*e*e+k*k;a=-2*l*f;k=Math.sqrt(a*a-4*f*(g*g*e*e*l*l+k*k*l*l-g*g*k*k));g=(-a+k)/(2*f);l=(-a-k)/(2*f);k=e*g+m;m=e*l+m;Math.sqrt(Math.pow(g-b,2)+Math.pow(k-c,2))c?new mxPoint(g,e):new mxPoint(g,e+a);if(k==c)return g>l?new mxPoint(b,k):new mxPoint(b+f,k);var m=g,n=k;d&&(l>=b&&l<=b+f?m=l:c>=e&&c<=e+a&&(n=c));return l-t&&rMath.PI-t)?c=d&&(e&&c.x>=n.x&&c.x<=q.x||!e&&c.y>=n.y&&c.y<=q.y)?e?new mxPoint(c.x,n.y):new mxPoint(n.x,c.y):b==mxConstants.DIRECTION_NORTH?new mxPoint(f+k/2+l*Math.tan(r)/2,g+l):b==mxConstants.DIRECTION_SOUTH?new mxPoint(f+k/2-l*Math.tan(r)/2,g):b==mxConstants.DIRECTION_WEST?new mxPoint(f+k,g+l/2+k*Math.tan(r)/2):new mxPoint(f,g+ +l/2-k*Math.tan(r)/2):(d&&(d=new mxPoint(a,m),c.y>=g&&c.y<=g+l?(d.x=e?a:b==mxConstants.DIRECTION_WEST?f+k:f,d.y=c.y):c.x>=f&&c.x<=f+k&&(d.x=c.x,d.y=e?b==mxConstants.DIRECTION_NORTH?g+l:g:m),a=d.x,m=d.y),c=e&&c.x<=f+k/2||!e&&c.y<=g+l/2?mxUtils.intersection(c.x,c.y,a,m,n.x,n.y,p.x,p.y):mxUtils.intersection(c.x,c.y,a,m,p.x,p.y,q.x,q.y));null==c&&(c=new mxPoint(a,m));return c},HexagonPerimeter:function(a,b,c,d){var e=a.x,f=a.y,g=a.width,k=a.height,l=a.getCenterX();a=a.getCenterY();var m=c.x,n=c.y,p=-Math.atan2(n- +a,m-l),q=Math.PI,r=Math.PI/2;new mxPoint(l,a);b=null!=b?mxUtils.getValue(b.style,mxConstants.STYLE_DIRECTION,mxConstants.DIRECTION_EAST):mxConstants.DIRECTION_EAST;var t=b==mxConstants.DIRECTION_NORTH||b==mxConstants.DIRECTION_SOUTH;b=new mxPoint;var u=new mxPoint;if(mf+k||m>e+g&&ne+g&&n>f+k)d=!1;if(d){if(t){if(m==l){if(n<=f)return new mxPoint(l,f);if(n>=f+k)return new mxPoint(l,f+k)}else if(me+g){if(n==f+k/4)return new mxPoint(e+g,f+k/4);if(n==f+3*k/4)return new mxPoint(e+g,f+3*k/4)}else if(m==e){if(na)return new mxPoint(e,f+3*k/4)}else if(m==e+g){if(na)return new mxPoint(e+g,f+3*k/4)}if(n==f)return new mxPoint(l,f);if(n==f+k)return new mxPoint(l,f+k);mf+k/4&&nf+3*k/4&&(b=new mxPoint(e-Math.floor(.5*g),f+Math.floor(.5*k)),u=new mxPoint(e+g,f+Math.floor(1.25*k))):m>l&&(n>f+k/4&&nf+3*k/4&&(b=new mxPoint(e+Math.floor(1.5*g),f+Math.floor(.5*k)),u=new mxPoint(e,f+Math.floor(1.25*k))))}else{if(n==a){if(m<=e)return new mxPoint(e,f+k/2);if(m>=e+g)return new mxPoint(e+g,f+k/2)}else if(n< +f){if(m==e+g/4)return new mxPoint(e+g/4,f);if(m==e+3*g/4)return new mxPoint(e+3*g/4,f)}else if(n>f+k){if(m==e+g/4)return new mxPoint(e+g/4,f+k);if(m==e+3*g/4)return new mxPoint(e+3*g/4,f+k)}else if(n==f){if(ml)return new mxPoint(e+3*g/4,f)}else if(n==f+k){if(ma)return new mxPoint(e+3*g/4,f+k)}if(m==e)return new mxPoint(e,a);if(m==e+g)return new mxPoint(e+g,a);ne+g/4&&me+3*g/4&&(b=new mxPoint(e+Math.floor(.5*g),f-Math.floor(.5*k)),u=new mxPoint(e+Math.floor(1.25*g),f+k)):n>a&&(m>e+g/4&&me+3*g/4&&(b=new mxPoint(e+Math.floor(.5*g),f+Math.floor(1.5*k)),u=new mxPoint(e+Math.floor(1.25*g),f)))}d=l;p=a;m>=e&&m<= +e+g?(d=m,p=n=f&&n<=f+k&&(p=n,d=m-m?(b=new mxPoint(e+g,f),u=new mxPoint(e+g,f+ +k)):p>m&&pr&&pq-m&&p<=q||p<-q+m&&p>=-q?(b=new mxPoint(e,f),u=new mxPoint(e,f+k)):p<-m&&p>-r?(b=new mxPoint(e+Math.floor(1.5*g),f+Math.floor(.5*k)),u=new mxPoint(e,f+Math.floor(1.25*k))):p<-r&&p>-q+m&&(b=new mxPoint(e-Math.floor(.5*g),f+Math.floor(.5*k)),u=new mxPoint(e+g,f+Math.floor(1.25*k)))}else{m= +Math.atan2(k/2,g/4);if(p==m)return new mxPoint(e+Math.floor(.75*g),f);if(p==q-m)return new mxPoint(e+Math.floor(.25*g),f);if(p==q||p==-q)return new mxPoint(e,f+Math.floor(.5*k));if(0==p)return new mxPoint(e+g,f+Math.floor(.5*k));if(p==-m)return new mxPoint(e+Math.floor(.75*g),f+k);if(p==-q+m)return new mxPoint(e+Math.floor(.25*g),f+k);0m&&pq-m&& +pp&&p>-m?(b=new mxPoint(e+Math.floor(.5*g),f+Math.floor(1.5*k)),u=new mxPoint(e+Math.floor(1.25*g),f)):p<-m&&p>-q+m?(b=new mxPoint(e,f+k),u=new mxPoint(e+g,f+k)):p<-q+m&&p>-q&&(b=new mxPoint(e-Math.floor(.25*g),f),u=new mxPoint(e+Math.floor(.5*g),f+Math.floor(1.5*k)))}c=mxUtils.intersection(l,a,c.x,c.y,b.x,b.y,u.x,u.y)}return null==c?new mxPoint(l,a):c}}; +function mxPrintPreview(a,b,c,d,e,f,g,k,l){this.graph=a;this.scale=null!=b?b:1/a.pageScale;this.border=null!=d?d:0;this.pageFormat=mxRectangle.fromRectangle(null!=c?c:a.pageFormat);this.title=null!=k?k:"Printer-friendly version";this.x0=null!=e?e:0;this.y0=null!=f?f:0;this.borderColor=g;this.pageSelector=null!=l?l:!0}mxPrintPreview.prototype.graph=null;mxPrintPreview.prototype.pageFormat=null;mxPrintPreview.prototype.scale=null;mxPrintPreview.prototype.border=0; +mxPrintPreview.prototype.marginTop=0;mxPrintPreview.prototype.marginBottom=0;mxPrintPreview.prototype.x0=0;mxPrintPreview.prototype.y0=0;mxPrintPreview.prototype.autoOrigin=!0;mxPrintPreview.prototype.printOverlays=!1;mxPrintPreview.prototype.printControls=!1;mxPrintPreview.prototype.printBackgroundImage=!1;mxPrintPreview.prototype.backgroundColor="#ffffff";mxPrintPreview.prototype.borderColor=null;mxPrintPreview.prototype.title=null;mxPrintPreview.prototype.pageSelector=null; +mxPrintPreview.prototype.wnd=null;mxPrintPreview.prototype.targetWindow=null;mxPrintPreview.prototype.pageCount=0;mxPrintPreview.prototype.clipping=!0;mxPrintPreview.prototype.getWindow=function(){return this.wnd}; +mxPrintPreview.prototype.getDoctype=function(){var a="";5==document.documentMode?a='':8==document.documentMode?a='':8'):("CSS1Compat"===document.compatMode&&k.writeln(""),k.writeln(""));k.writeln("");this.writeHead(k,a);k.writeln("");k.writeln('')}var m=this.graph.getGraphBounds().clone(),n=this.graph.getView().getScale(),p=n/this.scale,q=this.graph.getView().getTranslate();this.autoOrigin||(this.x0-=q.x*this.scale,this.y0-= +q.y*this.scale,m.width+=m.x,m.height+=m.y,m.x=0,this.border=m.y=0);var r=this.pageFormat.width-2*this.border,t=this.pageFormat.height-2*this.border;this.pageFormat.height+=this.marginTop+this.marginBottom;m.width/=p;m.height/=p;var u=Math.max(1,Math.ceil((m.width+this.x0)/r)),x=Math.max(1,Math.ceil((m.height+this.y0)/t));this.pageCount=u*x;var y=mxUtils.bind(this,function(){if(this.pageSelector&&(1");a.writeln("");a.close();mxEvent.release(a.body)}}; +mxPrintPreview.prototype.writeHead=function(a,b){null!=this.title&&a.writeln(""+this.title+"");mxClient.IS_VML&&a.writeln('');mxClient.link("stylesheet",mxClient.basePath+"/css/common.css",a);a.writeln('")};mxPrintPreview.prototype.writePostfix=function(a){}; +mxPrintPreview.prototype.createPageSelector=function(a,b){var c=this.wnd.document,d=c.createElement("table");d.className="mxPageSelector";d.setAttribute("border","0");for(var e=c.createElement("tbody"),f=0;f":"";mxCellEditor.prototype.escapeCancelsEditing=!0;mxCellEditor.prototype.textNode="";mxCellEditor.prototype.zIndex=5;mxCellEditor.prototype.minResize=new mxRectangle(0,20); +mxCellEditor.prototype.wordWrapPadding=mxClient.IS_QUIRKS?2:mxClient.IS_IE11?0:1;mxCellEditor.prototype.blurEnabled=!1;mxCellEditor.prototype.initialValue=null;mxCellEditor.prototype.init=function(){this.textarea=document.createElement("div");this.textarea.className="mxCellEditor mxPlainTextEditor";this.textarea.contentEditable=!0;mxClient.IS_GC&&(this.textarea.style.minHeight="1em");this.textarea.style.position=this.isLegacyEditor()?"absolute":"relative";this.installListeners(this.textarea)}; +mxCellEditor.prototype.applyValue=function(a,b){this.graph.labelChanged(a.cell,b,this.trigger)};mxCellEditor.prototype.getInitialValue=function(a,b){var c=mxUtils.htmlEntities(this.graph.getEditingValue(a.cell,b),!1);mxClient.IS_QUIRKS||8==document.documentMode||9==document.documentMode||10==document.documentMode||(c=mxUtils.replaceTrailingNewlines(c,"

"));return c.replace(/\n/g,"
")};mxCellEditor.prototype.getCurrentValue=function(a){return mxUtils.extractTextWithWhitespace(this.textarea.childNodes)}; +mxCellEditor.prototype.isCancelEditingKeyEvent=function(a){return this.escapeCancelsEditing||mxEvent.isShiftDown(a)||mxEvent.isControlDown(a)||mxEvent.isMetaDown(a)}; +mxCellEditor.prototype.installListeners=function(a){mxEvent.addListener(a,"blur",mxUtils.bind(this,function(a){this.blurEnabled&&this.focusLost(a)}));mxEvent.addListener(a,"keydown",mxUtils.bind(this,function(a){mxEvent.isConsumed(a)||(this.isStopEditingEvent(a)?(this.graph.stopEditing(!1),mxEvent.consume(a)):27==a.keyCode&&(this.graph.stopEditing(this.isCancelEditingKeyEvent(a)),mxEvent.consume(a)))}));var b=mxUtils.bind(this,function(b){null!=this.editingCell&&this.clearOnChange&&a.innerHTML==this.getEmptyLabelText()&& +(!mxClient.IS_FF||8!=b.keyCode&&46!=b.keyCode)&&(this.clearOnChange=!1,a.innerHTML="")});mxEvent.addListener(a,"keypress",b);mxEvent.addListener(a,"paste",b);b=mxUtils.bind(this,function(a){null!=this.editingCell&&(0==this.textarea.innerHTML.length||"
"==this.textarea.innerHTML?(this.textarea.innerHTML=this.getEmptyLabelText(),this.clearOnChange=0e&&(this.textarea.style.width=this.textarea.scrollWidth+"px")):this.textarea.style.maxWidth=e+"px"):(this.textarea.style.whiteSpace="nowrap",this.textarea.style.width= +"");8==document.documentMode&&(this.textarea.style.zoom="1",this.textarea.style.height="auto");a=this.textarea.scrollWidth;e=this.textarea.scrollHeight;8==document.documentMode?(this.textarea.style.left=Math.max(0,Math.ceil((this.bounds.x-d.x*(this.bounds.width-(a+1)*c)+a*(c-1)*0+2*(d.x+.5))/c))+"px",this.textarea.style.top=Math.max(0,Math.ceil((this.bounds.y-d.y*(this.bounds.height-(e+.5)*c)+e*(c-1)*0+1*Math.abs(d.y+.5))/c))+"px",this.textarea.style.width=Math.round(a*c)+"px",this.textarea.style.height= +Math.round(e*c)+"px"):mxClient.IS_QUIRKS?(this.textarea.style.left=Math.max(0,Math.ceil(this.bounds.x-d.x*(this.bounds.width-(a+1)*c)+a*(c-1)*0+2*(d.x+.5)))+"px",this.textarea.style.top=Math.max(0,Math.ceil(this.bounds.y-d.y*(this.bounds.height-(e+.5)*c)+e*(c-1)*0+1*Math.abs(d.y+.5)))+"px"):(this.textarea.style.left=Math.max(0,Math.round(this.bounds.x-d.x*(this.bounds.width-2))+1)+"px",this.textarea.style.top=Math.max(0,Math.round(this.bounds.y-d.y*(this.bounds.height-4)+(-1==d.y?3:0))+1)+"px")}else this.bounds= +this.getEditorBounds(a),this.textarea.style.width=Math.round(this.bounds.width/c)+"px",this.textarea.style.height=Math.round(this.bounds.height/c)+"px",8==document.documentMode||mxClient.IS_QUIRKS?(this.textarea.style.left=Math.round(this.bounds.x)+"px",this.textarea.style.top=Math.round(this.bounds.y)+"px"):(this.textarea.style.left=Math.max(0,Math.round(this.bounds.x+1))+"px",this.textarea.style.top=Math.max(0,Math.round(this.bounds.y+1))+"px"),this.graph.isWrapping(a.cell)&&(2<=this.bounds.width|| +2<=this.bounds.height)&&this.textarea.innerHTML!=this.getEmptyLabelText()?(this.textarea.style.wordWrap=mxConstants.WORD_WRAP,this.textarea.style.whiteSpace="normal","fill"!=a.style[mxConstants.STYLE_OVERFLOW]&&(this.textarea.style.width=Math.round(this.bounds.width/c)+this.wordWrapPadding+"px")):(this.textarea.style.whiteSpace="nowrap","fill"!=a.style[mxConstants.STYLE_OVERFLOW]&&(this.textarea.style.width=""));mxClient.IS_VML?this.textarea.style.zoom=c:(mxUtils.setPrefixedStyle(this.textarea.style, +"transformOrigin","0px 0px"),mxUtils.setPrefixedStyle(this.textarea.style,"transform","scale("+c+","+c+")"+(null==d?"":" translate("+100*d.x+"%,"+100*d.y+"%)")))}};mxCellEditor.prototype.focusLost=function(){this.stopEditing(!this.graph.isInvokesStopCellEditing())};mxCellEditor.prototype.getBackgroundColor=function(a){return null}; +mxCellEditor.prototype.isLegacyEditor=function(){if(mxClient.IS_VML)return!0;var a=!1;if(mxClient.IS_SVG){var b=this.graph.view.getDrawPane().ownerSVGElement;null!=b&&(a="absolute"==mxUtils.getCurrentStyle(b).position)}return!a}; +mxCellEditor.prototype.startEditing=function(a,b){this.stopEditing(!0);null==this.textarea&&this.init();null!=this.graph.tooltipHandler&&this.graph.tooltipHandler.hideTooltip();var c=this.graph.getView().getState(a);if(null!=c){this.graph.getView();var d=mxUtils.getValue(c.style,mxConstants.STYLE_FONTSIZE,mxConstants.DEFAULT_FONTSIZE),e=mxUtils.getValue(c.style,mxConstants.STYLE_FONTFAMILY,mxConstants.DEFAULT_FONTFAMILY),f=mxUtils.getValue(c.style,mxConstants.STYLE_FONTCOLOR,"black"),g=mxUtils.getValue(c.style, +mxConstants.STYLE_ALIGN,mxConstants.ALIGN_LEFT),k=(mxUtils.getValue(c.style,mxConstants.STYLE_FONTSTYLE,0)&mxConstants.FONT_BOLD)==mxConstants.FONT_BOLD,l=(mxUtils.getValue(c.style,mxConstants.STYLE_FONTSTYLE,0)&mxConstants.FONT_ITALIC)==mxConstants.FONT_ITALIC,m=(mxUtils.getValue(c.style,mxConstants.STYLE_FONTSTYLE,0)&mxConstants.FONT_UNDERLINE)==mxConstants.FONT_UNDERLINE;this.textarea.style.lineHeight=mxConstants.ABSOLUTE_LINE_HEIGHT?Math.round(d*mxConstants.LINE_HEIGHT)+"px":mxConstants.LINE_HEIGHT; +this.textarea.style.backgroundColor=this.getBackgroundColor(c);this.textarea.style.textDecoration=m?"underline":"";this.textarea.style.fontWeight=k?"bold":"normal";this.textarea.style.fontStyle=l?"italic":"";this.textarea.style.fontSize=Math.round(d)+"px";this.textarea.style.zIndex=this.zIndex;this.textarea.style.fontFamily=e;this.textarea.style.textAlign=g;this.textarea.style.outline="none";this.textarea.style.color=f;d=this.textDirection=mxUtils.getValue(c.style,mxConstants.STYLE_TEXT_DIRECTION, +mxConstants.DEFAULT_TEXT_DIRECTION);d==mxConstants.TEXT_DIRECTION_AUTO&&(null==c||null==c.text||c.text.dialect==mxConstants.DIALECT_STRICTHTML||mxUtils.isNode(c.text.value)||(d=c.text.getAutoDirection()));d==mxConstants.TEXT_DIRECTION_LTR||d==mxConstants.TEXT_DIRECTION_RTL?this.textarea.setAttribute("dir",d):this.textarea.removeAttribute("dir");this.textarea.innerHTML=this.getInitialValue(c,b)||"";this.initialValue=this.textarea.innerHTML;0==this.textarea.innerHTML.length||"
"==this.textarea.innerHTML? +(this.textarea.innerHTML=this.getEmptyLabelText(),this.clearOnChange=!0):this.clearOnChange=this.textarea.innerHTML==this.getEmptyLabelText();this.graph.container.appendChild(this.textarea);this.editingCell=a;this.trigger=b;this.textNode=null;null!=c.text&&this.isHideLabel(c)&&(this.textNode=c.text.node,this.textNode.style.visibility="hidden");this.autoSize&&(this.graph.model.isEdge(c.cell)||"fill"!=c.style[mxConstants.STYLE_OVERFLOW])&&window.setTimeout(mxUtils.bind(this,function(){this.resize()}), +0);this.resize();try{this.textarea.focus(),this.isSelectText()&&0=l.x:null!=c&&(k=c.x+c.width=a.x:null!=b&&(l=b.x+b.widthb.x+b.width?null!=c?(d=c.x,m=Math.max(Math.abs(l-c.y),m)):a==mxConstants.DIRECTION_NORTH? +l=b.y-2*k:a==mxConstants.DIRECTION_SOUTH?l=b.y+b.height+2*k:d=a==mxConstants.DIRECTION_EAST?b.x-2*m:b.x+b.width+2*m:null!=c&&(d=f.getRoutingCenterX(b),k=Math.max(Math.abs(d-c.x),m),l=c.y,m=0);e.push(new mxPoint(d-k,l-m));e.push(new mxPoint(d+k,l+m))}},ElbowConnector:function(a,b,c,d,e){var f=null!=d&&0n,k=f.xm;else l=Math.max(b.x,c.x),m=Math.min(b.x+b.width,c.x+c.width),g=l==m,g||(k=Math.max(b.y,c.y),n=Math.min(b.y+b.height,c.y+c.height),k=k==n);k||!g&&a.style[mxConstants.STYLE_ELBOW]!=mxConstants.ELBOW_VERTICAL?mxEdgeStyle.SideToSide(a,b,c,d,e):mxEdgeStyle.TopToBottom(a,b,c,d,e)},SideToSide:function(a,b,c,d,e){var f=a.view;d=null!=d&&0=b.y&&d.y<=b.y+b.height&&(k=d.y),d.y>=c.y&&d.y<=c.y+c.height&&(f=d.y)),mxUtils.contains(c,a,k)||mxUtils.contains(b,a,k)||e.push(new mxPoint(a,k)),mxUtils.contains(c,a,f)||mxUtils.contains(b,a,f)||e.push(new mxPoint(a,f)),1==e.length&&(null!=d?mxUtils.contains(c,a, +d.y)||mxUtils.contains(b,a,d.y)||e.push(new mxPoint(a,d.y)):(f=Math.max(b.y,c.y),e.push(new mxPoint(a,f+(Math.min(b.y+b.height,c.y+c.height)-f)/2)))))},TopToBottom:function(a,b,c,d,e){var f=a.view;d=null!=d&&0=b.x&&d.x<=b.x+b.width&&(a=d.x),k=null!=d?d.y:Math.round(g+(k-g)/2),mxUtils.contains(c,a,k)||mxUtils.contains(b,a,k)||e.push(new mxPoint(a,k)),a=null!=d&&d.x>=c.x&&d.x<=c.x+c.width?d.x:f.getRoutingCenterX(c),mxUtils.contains(c,a,k)||mxUtils.contains(b,a,k)||e.push(new mxPoint(a,k)),1==e.length&&(null!=d&&1==e.length?mxUtils.contains(c,d.x,k)||mxUtils.contains(b,d.x,k)||e.push(new mxPoint(d.x,k)):(f=Math.max(b.x,c.x),e.push(new mxPoint(f+(Math.min(b.x+b.width,c.x+c.width)-f)/2,k)))))}, +SegmentConnector:function(a,b,c,d,e){function f(a){if(null==l||Math.abs(l.x-a.x)>=k||Math.abs(l.y-a.y)>=k)e.push(a),l=a;return l}var g=a.absolutePoints,k=Math.max(1,a.view.scale),l=0r;r++){var z=null!=x&&x.x==y.x,v=null!=x&&x.y==y.y,B=null!=u&&y.y>=u.y&&y.y<=u.y+ +u.height,u=null!=u&&y.x>=u.x&&y.x<=u.x+u.width,y=v||null==x&&B,A=z||null==x&&u;if(0!=r||!(y&&A||z&&v)){if(null!=x&&!v&&!z&&(B||u)){m=B?!1:!0;break}if(A||y){m=y;1==r&&(m=0==d.length%2?y:A);break}}u=c;x=g[q];null!=x&&(x.x=Math.round(x.x),x.y=Math.round(x.y),u=null);y=d[d.length-1];z&&v&&(d=d.slice(1))}m&&(null!=g[0]&&g[0].y!=n.y||null==g[0]&&null!=b&&(n.yb.y+b.height))?f(new mxPoint(p.x,n.y)):!m&&(null!=g[0]&&g[0].x!=n.x||null==g[0]&&null!=b&&(n.xb.x+b.width))&&f(new mxPoint(n.x, +p.y));m?p.y=n.y:p.x=n.x;for(r=0;rc.y+c.height))?f(new mxPoint(p.x,n.y)):!m&&(null!=g[q]&&g[q].x!=n.x||null==g[q]&&null!=c&&(n.xc.x+c.width))&&f(new mxPoint(n.x,p.y))));if(null==g[0]&&null!=b)for(;1< +e.length&&null!=e[1]&&mxUtils.contains(b,e[1].x,e[1].y);)e.splice(1,1);if(null==g[q]&&null!=c)for(;1v;v++)mxEdgeStyle.limits[v][1]= +n[v][0]-A[v],mxEdgeStyle.limits[v][2]=n[v][1]-A[v],mxEdgeStyle.limits[v][4]=n[v][0]+n[v][2]+A[v],mxEdgeStyle.limits[v][8]=n[v][1]+n[v][3]+A[v];A=n[0][1]+n[0][3]/2;p=n[1][1]+n[1][3]/2;v=n[0][0]+n[0][2]/2-(n[1][0]+n[1][2]/2);B=A-p;A=0;0>v?A=0>B?2:1:0>=B&&(A=3,0==v&&(A=2));p=null;null!=b&&(p=l);b=[[.5,.5],[.5,.5]];for(v=0;2>v;v++)null!=p&&(b[v][0]=(p.x-n[v][0])/n[v][2],1>=Math.abs(p.x-n[v][0])?a[v]=mxConstants.DIRECTION_MASK_WEST:1>=Math.abs(p.x-n[v][0]-n[v][2])&&(a[v]=mxConstants.DIRECTION_MASK_EAST), +b[v][1]=(p.y-n[v][1])/n[v][3],1>=Math.abs(p.y-n[v][1])?a[v]=mxConstants.DIRECTION_MASK_NORTH:1>=Math.abs(p.y-n[v][1]-n[v][3])&&(a[v]=mxConstants.DIRECTION_MASK_SOUTH)),p=null,null!=c&&(p=m);v=n[0][1]-(n[1][1]+n[1][3]);m=n[0][0]-(n[1][0]+n[1][2]);p=n[1][1]-(n[0][1]+n[0][3]);q=n[1][0]-(n[0][0]+n[0][2]);mxEdgeStyle.vertexSeperations[1]=Math.max(m-z,0);mxEdgeStyle.vertexSeperations[2]=Math.max(v-z,0);mxEdgeStyle.vertexSeperations[4]=Math.max(p-z,0);mxEdgeStyle.vertexSeperations[3]=Math.max(q-z,0);z=[]; +c=[];l=[];c[0]=m>=q?mxConstants.DIRECTION_MASK_WEST:mxConstants.DIRECTION_MASK_EAST;l[0]=v>=p?mxConstants.DIRECTION_MASK_NORTH:mxConstants.DIRECTION_MASK_SOUTH;c[1]=mxUtils.reversePortConstraints(c[0]);l[1]=mxUtils.reversePortConstraints(l[0]);m=m>=q?m:q;p=v>=p?v:p;q=[[0,0],[0,0]];r=!1;for(v=0;2>v;v++)0==a[v]&&(0==(c[v]&d[v])&&(c[v]=mxUtils.reversePortConstraints(c[v])),0==(l[v]&d[v])&&(l[v]=mxUtils.reversePortConstraints(l[v])),q[v][0]=l[v],q[v][1]=c[v]);0v;v++)0==a[v]&&(0==(q[v][0]&d[v])&&(q[v][0]=q[v][1]),z[v]=q[v][0]&d[v],z[v]|=(q[v][1]&d[v])<<8,z[v]|=(q[1-v][v]&d[v])<<16,z[v]|=(q[1-v][1-v]&d[v])<<24,0==(z[v]&15)&&(z[v]<<=8),0==(z[v]&3840)&&(z[v]=z[v]&15|z[v]>>8),0==(z[v]& +983040)&&(z[v]=z[v]&65535|(z[v]&251658240)>>8),a[v]=z[v]&15,d[v]==mxConstants.DIRECTION_MASK_WEST||d[v]==mxConstants.DIRECTION_MASK_NORTH||d[v]==mxConstants.DIRECTION_MASK_EAST||d[v]==mxConstants.DIRECTION_MASK_SOUTH)&&(a[v]=d[v]);d=a[0]==mxConstants.DIRECTION_MASK_EAST?3:a[0];z=a[1]==mxConstants.DIRECTION_MASK_EAST?3:a[1];d-=A;z-=A;1>d&&(d+=4);1>z&&(z+=4);d=mxEdgeStyle.routePatterns[d-1][z-1];mxEdgeStyle.wayPoints1[0][0]=n[0][0];mxEdgeStyle.wayPoints1[0][1]=n[0][1];switch(a[0]){case mxConstants.DIRECTION_MASK_WEST:mxEdgeStyle.wayPoints1[0][0]-= +f;mxEdgeStyle.wayPoints1[0][1]+=b[0][1]*n[0][3];break;case mxConstants.DIRECTION_MASK_SOUTH:mxEdgeStyle.wayPoints1[0][0]+=b[0][0]*n[0][2];mxEdgeStyle.wayPoints1[0][1]+=n[0][3]+f;break;case mxConstants.DIRECTION_MASK_EAST:mxEdgeStyle.wayPoints1[0][0]+=n[0][2]+f;mxEdgeStyle.wayPoints1[0][1]+=b[0][1]*n[0][3];break;case mxConstants.DIRECTION_MASK_NORTH:mxEdgeStyle.wayPoints1[0][0]+=b[0][0]*n[0][2],mxEdgeStyle.wayPoints1[0][1]-=f}f=0;c=z=0<(a[0]&(mxConstants.DIRECTION_MASK_EAST|mxConstants.DIRECTION_MASK_WEST))? +0:1;for(v=0;v>5,p<<=A,15>=4),q=0<(d[v]&mxEdgeStyle.CENTER_MASK),(u||t)&&9>p?(r=u?0:1,p=q&&0==l?n[r][0]+b[r][0]*n[r][2]:q?n[r][1]+b[r][1]* +n[r][3]:mxEdgeStyle.limits[r][p],0==l?(p=(p-mxEdgeStyle.wayPoints1[f][0])*m[0],0e&&(e+=4);1>a&&(a+=4);b=routePatterns[e-1][a-1];0!=c&&0!=d||null==inlineRoutePatterns[e-1][a- +1]||(b=inlineRoutePatterns[e-1][a-1]);return b}},mxStyleRegistry={values:[],putValue:function(a,b){mxStyleRegistry.values[a]=b},getValue:function(a){return mxStyleRegistry.values[a]},getName:function(a){for(var b in mxStyleRegistry.values)if(mxStyleRegistry.values[b]==a)return b;return null}};mxStyleRegistry.putValue(mxConstants.EDGESTYLE_ELBOW,mxEdgeStyle.ElbowConnector);mxStyleRegistry.putValue(mxConstants.EDGESTYLE_ENTITY_RELATION,mxEdgeStyle.EntityRelation); +mxStyleRegistry.putValue(mxConstants.EDGESTYLE_LOOP,mxEdgeStyle.Loop);mxStyleRegistry.putValue(mxConstants.EDGESTYLE_SIDETOSIDE,mxEdgeStyle.SideToSide);mxStyleRegistry.putValue(mxConstants.EDGESTYLE_TOPTOBOTTOM,mxEdgeStyle.TopToBottom);mxStyleRegistry.putValue(mxConstants.EDGESTYLE_ORTHOGONAL,mxEdgeStyle.OrthConnector);mxStyleRegistry.putValue(mxConstants.EDGESTYLE_SEGMENT,mxEdgeStyle.SegmentConnector);mxStyleRegistry.putValue(mxConstants.PERIMETER_ELLIPSE,mxPerimeter.EllipsePerimeter); +mxStyleRegistry.putValue(mxConstants.PERIMETER_RECTANGLE,mxPerimeter.RectanglePerimeter);mxStyleRegistry.putValue(mxConstants.PERIMETER_RHOMBUS,mxPerimeter.RhombusPerimeter);mxStyleRegistry.putValue(mxConstants.PERIMETER_TRIANGLE,mxPerimeter.TrianglePerimeter);mxStyleRegistry.putValue(mxConstants.PERIMETER_HEXAGON,mxPerimeter.HexagonPerimeter);function mxGraphView(a){this.graph=a;this.translate=new mxPoint;this.graphBounds=new mxRectangle;this.states=new mxDictionary}mxGraphView.prototype=new mxEventSource; +mxGraphView.prototype.constructor=mxGraphView;mxGraphView.prototype.EMPTY_POINT=new mxPoint;mxGraphView.prototype.doneResource="none"!=mxClient.language?"done":"";mxGraphView.prototype.updatingDocumentResource="none"!=mxClient.language?"updatingDocument":"";mxGraphView.prototype.allowEval=!1;mxGraphView.prototype.captureDocumentGesture=!0;mxGraphView.prototype.optimizeVmlReflows=!0;mxGraphView.prototype.rendering=!0;mxGraphView.prototype.graph=null;mxGraphView.prototype.currentRoot=null; +mxGraphView.prototype.graphBounds=null;mxGraphView.prototype.scale=1;mxGraphView.prototype.translate=null;mxGraphView.prototype.states=null;mxGraphView.prototype.updateStyle=!1;mxGraphView.prototype.lastNode=null;mxGraphView.prototype.lastHtmlNode=null;mxGraphView.prototype.lastForegroundNode=null;mxGraphView.prototype.lastForegroundHtmlNode=null;mxGraphView.prototype.getGraphBounds=function(){return this.graphBounds};mxGraphView.prototype.setGraphBounds=function(a){this.graphBounds=a}; +mxGraphView.prototype.getBounds=function(a){var b=null;if(null!=a&&0 +c.length||null==c[0]||null==c[c.length-1])?this.clear(a.cell,!0):(this.updateEdgeBounds(a),this.updateEdgeLabelOffset(a)))}; +mxGraphView.prototype.updateVertexLabelOffset=function(a){var b=mxUtils.getValue(a.style,mxConstants.STYLE_LABEL_POSITION,mxConstants.ALIGN_CENTER);if(b==mxConstants.ALIGN_LEFT)b=mxUtils.getValue(a.style,mxConstants.STYLE_LABEL_WIDTH,null),b=null!=b?b*this.scale:a.width,a.absoluteOffset.x-=b;else if(b==mxConstants.ALIGN_RIGHT)a.absoluteOffset.x+=a.width;else if(b==mxConstants.ALIGN_CENTER&&(b=mxUtils.getValue(a.style,mxConstants.STYLE_LABEL_WIDTH,null),null!=b)){var c=mxUtils.getValue(a.style,mxConstants.STYLE_ALIGN, +mxConstants.ALIGN_CENTER),d=0;c==mxConstants.ALIGN_CENTER?d=.5:c==mxConstants.ALIGN_RIGHT&&(d=1);0!=d&&(a.absoluteOffset.x-=(b*this.scale-a.width)*d)}b=mxUtils.getValue(a.style,mxConstants.STYLE_VERTICAL_LABEL_POSITION,mxConstants.ALIGN_MIDDLE);b==mxConstants.ALIGN_TOP?a.absoluteOffset.y-=a.height:b==mxConstants.ALIGN_BOTTOM&&(a.absoluteOffset.y+=a.height)};mxGraphView.prototype.resetValidationState=function(){this.lastForegroundHtmlNode=this.lastForegroundNode=this.lastHtmlNode=this.lastNode=null}; +mxGraphView.prototype.stateValidated=function(a){var b=this.graph.getModel().isEdge(a.cell)&&this.graph.keepEdgesInForeground||this.graph.getModel().isVertex(a.cell)&&this.graph.keepEdgesInBackground;a=this.graph.cellRenderer.insertStateAfter(a,b?this.lastForegroundNode||this.lastNode:this.lastNode,b?this.lastForegroundHtmlNode||this.lastHtmlNode:this.lastHtmlNode);b?(this.lastForegroundHtmlNode=a[1],this.lastForegroundNode=a[0]):(this.lastHtmlNode=a[1],this.lastNode=a[0])}; +mxGraphView.prototype.updateFixedTerminalPoints=function(a,b,c){this.updateFixedTerminalPoint(a,b,!0,this.graph.getConnectionConstraint(a,b,!0));this.updateFixedTerminalPoint(a,c,!1,this.graph.getConnectionConstraint(a,c,!1))};mxGraphView.prototype.updateFixedTerminalPoint=function(a,b,c,d){a.setAbsoluteTerminalPoint(this.getFixedTerminalPoint(a,b,c,d),c)}; +mxGraphView.prototype.getFixedTerminalPoint=function(a,b,c,d){var e=null;null!=d&&(e=this.graph.getConnectionPoint(b,d));if(null==e&&null==b){b=this.scale;d=this.translate;var f=a.origin,e=this.graph.getCellGeometry(a.cell).getTerminalPoint(c);null!=e&&(e=new mxPoint(b*(d.x+e.x+f.x),b*(d.y+e.y+f.y)))}return e}; +mxGraphView.prototype.updateBoundsFromStencil=function(a){var b=null;if(null!=a&&null!=a.shape&&null!=a.shape.stencil&&"fixed"==a.shape.stencil.aspect){var b=mxRectangle.fromRectangle(a),c=a.shape.stencil.computeAspect(a.style,a.x,a.y,a.width,a.height);a.setRect(c.x,c.y,a.shape.stencil.w0*c.width,a.shape.stencil.h0*c.height)}return b}; +mxGraphView.prototype.updatePoints=function(a,b,c,d){if(null!=a){var e=[];e.push(a.absolutePoints[0]);var f=this.getEdgeStyle(a,b,c,d);if(null!=f){c=this.getTerminalPort(a,c,!0);d=this.getTerminalPort(a,d,!1);var g=this.updateBoundsFromStencil(c),k=this.updateBoundsFromStencil(d);f(a,c,d,b,e);null!=g&&c.setRect(g.x,g.y,g.width,g.height);null!=k&&d.setRect(k.x,k.y,k.width,k.height)}else if(null!=b)for(f=0;fb.length)||mxUtils.getValue(a.style,mxConstants.STYLE_ORTHOGONAL_LOOP,!1)&&(null!=e&&null!=e.point||null!=f&&null!=f.point)?!1:null!=c&&c==d}; +mxGraphView.prototype.getEdgeStyle=function(a,b,c,d){a=this.isLoopStyleEnabled(a,b,c,d)?mxUtils.getValue(a.style,mxConstants.STYLE_LOOP,this.graph.defaultLoopStyle):mxUtils.getValue(a.style,mxConstants.STYLE_NOEDGESTYLE,!1)?null:a.style[mxConstants.STYLE_EDGE];"string"==typeof a&&(b=mxStyleRegistry.getValue(a),null==b&&this.isAllowEval()&&(b=mxUtils.eval(a)),a=b);return"function"==typeof a?a:null}; +mxGraphView.prototype.updateFloatingTerminalPoints=function(a,b,c){var d=a.absolutePoints,e=d[0];null==d[d.length-1]&&null!=c&&this.updateFloatingTerminalPoint(a,c,b,!1);null==e&&null!=b&&this.updateFloatingTerminalPoint(a,b,c,!0)};mxGraphView.prototype.updateFloatingTerminalPoint=function(a,b,c,d){a.setAbsoluteTerminalPoint(this.getFloatingTerminalPoint(a,b,c,d),d)}; +mxGraphView.prototype.getFloatingTerminalPoint=function(a,b,c,d){b=this.getTerminalPort(a,b,d);var e=this.getNextPoint(a,c,d),f=this.graph.isOrthogonal(a);c=mxUtils.toRadians(Number(b.style[mxConstants.STYLE_ROTATION]||"0"));var g=new mxPoint(b.getCenterX(),b.getCenterY());if(0!=c)var k=Math.cos(-c),l=Math.sin(-c),e=mxUtils.getRotatedPoint(e,k,l,g);k=parseFloat(a.style[mxConstants.STYLE_PERIMETER_SPACING]||0);k+=parseFloat(a.style[d?mxConstants.STYLE_SOURCE_PERIMETER_SPACING:mxConstants.STYLE_TARGET_PERIMETER_SPACING]|| +0);a=this.getPerimeterPoint(b,e,0==c&&f,k);0!=c&&(k=Math.cos(c),l=Math.sin(c),a=mxUtils.getRotatedPoint(a,k,l,g));return a};mxGraphView.prototype.getTerminalPort=function(a,b,c){a=mxUtils.getValue(a.style,c?mxConstants.STYLE_SOURCE_PORT:mxConstants.STYLE_TARGET_PORT);null!=a&&(a=this.getState(this.graph.getModel().getCell(a)),null!=a&&(b=a));return b}; +mxGraphView.prototype.getPerimeterPoint=function(a,b,c,d){var e=null;if(null!=a){var f=this.getPerimeterFunction(a);if(null!=f&&null!=b&&(d=this.getPerimeterBounds(a,d),0=Math.round(k+g)&&l=f?0:f*f/(a*a+m*m));a>e&&(a=e);e=Math.sqrt(mxUtils.ptSegDistSq(g.x,g.y,k.x,k.y,b,c));-1==mxUtils.relativeCcw(g.x,g.y,k.x,k.y,b,c)&&(e=-e);return new mxPoint((d/2-p-a)/d*-2,e/this.scale)}}return new mxPoint}; +mxGraphView.prototype.updateEdgeLabelOffset=function(a){var b=a.absolutePoints;a.absoluteOffset.x=a.getCenterX();a.absoluteOffset.y=a.getCenterY();if(null!=b&&0c&&a.x>c+2&&a.x<=b)return!0;b=this.graph.container.offsetHeight;c=this.graph.container.clientHeight;return b>c&&a.y>c+2&&a.y<=b?!0:!1}; +mxGraphView.prototype.init=function(){this.installListeners();var a=this.graph;a.dialect==mxConstants.DIALECT_SVG?this.createSvg():a.dialect==mxConstants.DIALECT_VML?this.createVml():this.createHtml()}; +mxGraphView.prototype.installListeners=function(){var a=this.graph,b=a.container;if(null!=b){mxClient.IS_TOUCH&&(mxEvent.addListener(b,"gesturestart",mxUtils.bind(this,function(b){a.fireGestureEvent(b);mxEvent.consume(b)})),mxEvent.addListener(b,"gesturechange",mxUtils.bind(this,function(b){a.fireGestureEvent(b);mxEvent.consume(b)})),mxEvent.addListener(b,"gestureend",mxUtils.bind(this,function(b){a.fireGestureEvent(b);mxEvent.consume(b)})));mxEvent.addGestureListeners(b,mxUtils.bind(this,function(b){!this.isContainerEvent(b)|| +(mxClient.IS_IE||mxClient.IS_IE11||mxClient.IS_GC||mxClient.IS_OP||mxClient.IS_SF)&&this.isScrollEvent(b)||a.fireMouseEvent(mxEvent.MOUSE_DOWN,new mxMouseEvent(b))}),mxUtils.bind(this,function(b){this.isContainerEvent(b)&&a.fireMouseEvent(mxEvent.MOUSE_MOVE,new mxMouseEvent(b))}),mxUtils.bind(this,function(b){this.isContainerEvent(b)&&a.fireMouseEvent(mxEvent.MOUSE_UP,new mxMouseEvent(b))}));mxEvent.addListener(b,"dblclick",mxUtils.bind(this,function(b){this.isContainerEvent(b)&&a.dblClick(b)})); +var c=function(c){var d=null;mxClient.IS_TOUCH&&(d=mxEvent.getClientX(c),c=mxEvent.getClientY(c),c=mxUtils.convertPoint(b,d,c),d=a.view.getState(a.getCellAt(c.x,c.y)));return d};a.addMouseListener({mouseDown:function(b,c){a.popupMenuHandler.hideMenu()},mouseMove:function(){},mouseUp:function(){}});this.moveHandler=mxUtils.bind(this,function(b){null!=a.tooltipHandler&&a.tooltipHandler.isHideOnHover()&&a.tooltipHandler.hide();this.captureDocumentGesture&&a.isMouseDown&&null!=a.container&&!this.isContainerEvent(b)&& +"none"!=a.container.style.display&&"hidden"!=a.container.style.visibility&&!mxEvent.isConsumed(b)&&a.fireMouseEvent(mxEvent.MOUSE_MOVE,new mxMouseEvent(b,c(b)))});this.endHandler=mxUtils.bind(this,function(b){this.captureDocumentGesture&&a.isMouseDown&&null!=a.container&&!this.isContainerEvent(b)&&"none"!=a.container.style.display&&"hidden"!=a.container.style.visibility&&a.fireMouseEvent(mxEvent.MOUSE_UP,new mxMouseEvent(b))});mxEvent.addGestureListeners(document,null,this.moveHandler,this.endHandler)}}; +mxGraphView.prototype.createHtml=function(){var a=this.graph.container;null!=a&&(this.canvas=this.createHtmlPane("100%","100%"),this.canvas.style.overflow="hidden",this.backgroundPane=this.createHtmlPane("1px","1px"),this.drawPane=this.createHtmlPane("1px","1px"),this.overlayPane=this.createHtmlPane("1px","1px"),this.decoratorPane=this.createHtmlPane("1px","1px"),this.canvas.appendChild(this.backgroundPane),this.canvas.appendChild(this.drawPane),this.canvas.appendChild(this.overlayPane),this.canvas.appendChild(this.decoratorPane), +a.appendChild(this.canvas),this.updateContainerStyle(a),mxClient.IS_QUIRKS&&(a=mxUtils.bind(this,function(a){a=this.getGraphBounds();this.updateHtmlCanvasSize(a.x+a.width+this.graph.border,a.y+a.height+this.graph.border)}),mxEvent.addListener(window,"resize",a)))}; +mxGraphView.prototype.updateHtmlCanvasSize=function(a,b){if(null!=this.graph.container){var c=this.graph.container.offsetHeight;this.canvas.style.width=this.graph.container.offsetWidth")}; +mxGraph.prototype.createHandlers=function(){this.tooltipHandler=this.createTooltipHandler();this.tooltipHandler.setEnabled(!1);this.selectionCellsHandler=this.createSelectionCellsHandler();this.connectionHandler=this.createConnectionHandler();this.connectionHandler.setEnabled(!1);this.graphHandler=this.createGraphHandler();this.panningHandler=this.createPanningHandler();this.panningHandler.panningEnabled=!1;this.popupMenuHandler=this.createPopupMenuHandler()}; +mxGraph.prototype.createTooltipHandler=function(){return new mxTooltipHandler(this)};mxGraph.prototype.createSelectionCellsHandler=function(){return new mxSelectionCellsHandler(this)};mxGraph.prototype.createConnectionHandler=function(){return new mxConnectionHandler(this)};mxGraph.prototype.createGraphHandler=function(){return new mxGraphHandler(this)};mxGraph.prototype.createPanningHandler=function(){return new mxPanningHandler(this)};mxGraph.prototype.createPopupMenuHandler=function(){return new mxPopupMenuHandler(this)}; +mxGraph.prototype.createSelectionModel=function(){return new mxGraphSelectionModel(this)};mxGraph.prototype.createStylesheet=function(){return new mxStylesheet};mxGraph.prototype.createGraphView=function(){return new mxGraphView(this)};mxGraph.prototype.createCellRenderer=function(){return new mxCellRenderer};mxGraph.prototype.createCellEditor=function(){return new mxCellEditor(this)};mxGraph.prototype.getModel=function(){return this.model};mxGraph.prototype.getView=function(){return this.view}; +mxGraph.prototype.getStylesheet=function(){return this.stylesheet};mxGraph.prototype.setStylesheet=function(a){this.stylesheet=a};mxGraph.prototype.getSelectionModel=function(){return this.selectionModel};mxGraph.prototype.setSelectionModel=function(a){this.selectionModel=a}; +mxGraph.prototype.getSelectionCellsForChanges=function(a){for(var b=[],c=0;cmxUtils.indexOf(b,e)&&b.push(e)}}return this.getModel().getTopmostCells(b)}; +mxGraph.prototype.graphModelChanged=function(a){for(var b=0;b"+b+""),d&&b.addListener(mxEvent.CLICK,mxUtils.bind(this,function(b,c){this.isEnabled()&&this.setSelectionCell(a)})),this.addCellOverlay(a,b);this.removeCellOverlays(a);return null};mxGraph.prototype.startEditing=function(a){this.startEditingAtCell(null,a)}; +mxGraph.prototype.startEditingAtCell=function(a,b){null!=b&&mxEvent.isMultiTouchEvent(b)||(null==a&&(a=this.getSelectionCell(),null==a||this.isCellEditable(a)||(a=null)),null!=a&&(this.fireEvent(new mxEventObject(mxEvent.START_EDITING,"cell",a,"event",b)),this.cellEditor.startEditing(a,b),this.fireEvent(new mxEventObject(mxEvent.EDITING_STARTED,"cell",a,"event",b))))};mxGraph.prototype.getEditingValue=function(a,b){return this.convertValueToString(a)}; +mxGraph.prototype.stopEditing=function(a){this.cellEditor.stopEditing(a);this.fireEvent(new mxEventObject(mxEvent.EDITING_STOPPED,"cancel",a))};mxGraph.prototype.labelChanged=function(a,b,c){this.model.beginUpdate();try{var d=a.value;this.cellLabelChanged(a,b,this.isAutoSizeCell(a));this.fireEvent(new mxEventObject(mxEvent.LABEL_CHANGED,"cell",a,"value",b,"old",d,"event",c))}finally{this.model.endUpdate()}return a}; +mxGraph.prototype.cellLabelChanged=function(a,b,c){this.model.beginUpdate();try{this.model.setValue(a,b),c&&this.cellSizeUpdated(a,!1)}finally{this.model.endUpdate()}};mxGraph.prototype.escape=function(a){this.fireEvent(new mxEventObject(mxEvent.ESCAPE,"event",a))}; +mxGraph.prototype.click=function(a){var b=a.getEvent(),c=a.getCell(),d=new mxEventObject(mxEvent.CLICK,"event",b,"cell",c);a.isConsumed()&&d.consume();this.fireEvent(d);if(this.isEnabled()&&!mxEvent.isConsumed(b)&&!d.isConsumed())if(null!=c){if(this.isTransparentClickEvent(b)){var e=!1;a=this.getCellAt(a.graphX,a.graphY,null,null,null,mxUtils.bind(this,function(a){a=this.isCellSelected(a.cell);e=e||a;return!e||a}));null!=a&&(c=a)}this.selectCellForEvent(c,b)}else c=null,this.isSwimlaneSelectionEnabled()&& +(c=this.getSwimlaneAt(a.getGraphX(),a.getGraphY())),null!=c?this.selectCellForEvent(c,b):this.isToggleEvent(b)||this.clearSelection()};mxGraph.prototype.dblClick=function(a,b){var c=new mxEventObject(mxEvent.DOUBLE_CLICK,"event",a,"cell",b);this.fireEvent(c);!this.isEnabled()||mxEvent.isConsumed(a)||c.isConsumed()||null==b||!this.isCellEditable(b)||this.isEditing(b)||(this.startEditingAtCell(b,a),mxEvent.consume(a))}; +mxGraph.prototype.tapAndHold=function(a){var b=a.getEvent(),c=new mxEventObject(mxEvent.TAP_AND_HOLD,"event",b,"cell",a.getCell());this.fireEvent(c);c.isConsumed()&&(this.panningHandler.panningTrigger=!1);this.isEnabled()&&!mxEvent.isConsumed(b)&&!c.isConsumed()&&this.connectionHandler.isEnabled()&&(b=this.view.getState(this.connectionHandler.marker.getCell(a)),null!=b&&(this.connectionHandler.marker.currentColor=this.connectionHandler.marker.validColor,this.connectionHandler.marker.markedState=b, +this.connectionHandler.marker.mark(),this.connectionHandler.first=new mxPoint(a.getGraphX(),a.getGraphY()),this.connectionHandler.edgeState=this.connectionHandler.createEdgeState(a),this.connectionHandler.previous=b,this.connectionHandler.fireEvent(new mxEventObject(mxEvent.START,"state",this.connectionHandler.previous))))}; +mxGraph.prototype.scrollPointToVisible=function(a,b,c,d){if(this.timerAutoScroll||!this.ignoreScrollbars&&!mxUtils.hasScrollbars(this.container))this.allowAutoPanning&&!this.panningHandler.isActive()&&(null==this.panningManager&&(this.panningManager=this.createPanningManager()),this.panningManager.panTo(a+this.panDx,b+this.panDy));else{var e=this.container;d=null!=d?d:20;if(a>=e.scrollLeft&&b>=e.scrollTop&&a<=e.scrollLeft+e.clientWidth&&b<=e.scrollTop+e.clientHeight){var f=e.scrollLeft+e.clientWidth- +a;if(fthis.minPageBreakDist)?Math.ceil(d.height/f.height)+1:0,k=a?Math.ceil(d.width/f.width)+1:0,l=(k-1)*f.width,m=(g-1)*f.height;null==this.horizontalPageBreaks&&0this.model.getChildCount(b)&&c--;this.model.add(b,a[l],c+l);this.autoSizeCellsOnAdd&&this.autoSizeCell(a[l],!0);(null==k||k)&&this.isExtendParentsOnAdd(a[l])&&this.isExtendParent(a[l])&&this.extendParent(a[l]);(null==g||g)&&this.constrainChild(a[l]);null!=d&&this.cellConnected(a[l],d,!0);null!=e&&this.cellConnected(a[l],e,!1)}this.fireEvent(new mxEventObject(mxEvent.CELLS_ADDED,"cells",a,"parent",b,"index",c,"source", +d,"target",e,"absolute",f))}finally{this.model.endUpdate()}}};mxGraph.prototype.autoSizeCell=function(a,b){if(null!=b?b:1)for(var c=this.model.getChildCount(a),d=0;d"),e=mxUtils.getSizeForString(f,e,d[mxConstants.STYLE_FONTFAMILY]),c=e.width+b,a=e.height+a,mxUtils.getValue(d,mxConstants.STYLE_HORIZONTAL,!0)||(d=a,a=c,c=d),this.gridEnabled&&(c=this.snap(c+this.gridSize/2),a=this.snap(a+this.gridSize/2)),b=new mxRectangle(0,0,c,a)):(d=4*this.gridSize,b=new mxRectangle(0,0,d,d))}}return b};mxGraph.prototype.resizeCell=function(a,b,c){return this.resizeCells([a],[b],c)[0]}; +mxGraph.prototype.resizeCells=function(a,b,c){c=null!=c?c:this.isRecursiveResize();this.model.beginUpdate();try{this.cellsResized(a,b,c),this.fireEvent(new mxEventObject(mxEvent.RESIZE_CELLS,"cells",a,"bounds",b))}finally{this.model.endUpdate()}return a}; +mxGraph.prototype.cellsResized=function(a,b,c){c=null!=c?c:!1;if(null!=a&&null!=b&&a.length==b.length){this.model.beginUpdate();try{for(var d=0;de.width&&(f=c.width-e.width,c.width-=f);d.x+d.width>e.x+e.width&&(f-=d.x+d.width-e.x-e.width-f);g=0;c.height>e.height&&(g=c.height-e.height,c.height-=g);d.y+d.height> +e.y+e.height&&(g-=d.y+d.height-e.y-e.height-g);d.xf&&(n=0),b>g&&(p=0),this.view.setTranslate(Math.floor(n/2-k.x),Math.floor(p/2-k.y)),this.container.scrollLeft=(a-f)/ +2,this.container.scrollTop=(b-g)/2):this.view.setTranslate(a?Math.floor(l.x-k.x*m+n*c/m):l.x,b?Math.floor(l.y-k.y*m+p*d/m):l.y)}; +mxGraph.prototype.zoom=function(a,b){b=null!=b?b:this.centerZoom;var c=Math.round(this.view.scale*a*100)/100,d=this.view.getState(this.getSelectionCell());a=c/this.view.scale;if(this.keepSelectionVisibleOnZoom&&null!=d)d=new mxRectangle(d.x*a,d.y*a,d.width*a,d.height*a),this.view.scale=c,this.scrollRectToVisible(d)||(this.view.revalidate(),this.view.setScale(c));else if(d=mxUtils.hasScrollbars(this.container),b&&!d){var d=this.container.offsetWidth,e=this.container.offsetHeight;if(1b?(b=a.height/b,c=(b-a.height)/2,a.height=b,a.y-=Math.min(a.y,c),d=Math.min(this.container.scrollHeight,a.y+a.height),a.height=d-a.y):(b*=a.width,c=(b-a.width)/2,a.width=b,a.x-=Math.min(a.x,c),c=Math.min(this.container.scrollWidth, +a.x+a.width),a.width=c-a.x);b=this.container.clientWidth/a.width;c=this.view.scale*b;mxUtils.hasScrollbars(this.container)?(this.view.setScale(c),this.container.scrollLeft=Math.round(a.x*b),this.container.scrollTop=Math.round(a.y*b)):this.view.scaleAndTranslate(c,this.view.translate.x-a.x/this.view.scale,this.view.translate.y-a.y/this.view.scale)}; +mxGraph.prototype.scrollCellToVisible=function(a,b){var c=-this.view.translate.x,d=-this.view.translate.y,e=this.view.getState(a);null!=e&&(c=new mxRectangle(c+e.x,d+e.y,e.width,e.height),b&&null!=this.container&&(d=this.container.clientWidth,e=this.container.clientHeight,c.x=c.getCenterX()-d/2,c.width=d,c.y=c.getCenterY()-e/2,c.height=e),d=new mxPoint(this.view.translate.x,this.view.translate.y),this.scrollRectToVisible(c)&&(c=new mxPoint(this.view.translate.x,this.view.translate.y),this.view.translate.x= +d.x,this.view.translate.y=d.y,this.view.setTranslate(c.x,c.y)))}; +mxGraph.prototype.scrollRectToVisible=function(a){var b=!1;if(null!=a){var c=this.container.offsetWidth,d=this.container.offsetHeight,e=Math.min(c,a.width),f=Math.min(d,a.height);if(mxUtils.hasScrollbars(this.container)){c=this.container;a.x+=this.view.translate.x;a.y+=this.view.translate.y;var g=c.scrollLeft-a.x,d=Math.max(g-c.scrollLeft,0);0g+c&&(this.view.translate.x-=(a.x+e-c-g)/l,b=!0);a.y+f>k+d&&(this.view.translate.y-=(a.y+f-d-k)/l,b=!0);a.x")):this.setCellWarning(f,null);c=c&&null==g}d="";this.isCellCollapsed(a)&&!c&&(d+=(mxResources.get(this.containsValidationErrorsResource)||this.containsValidationErrorsResource)+"\n");d=this.model.isEdge(a)?d+ +(this.getEdgeValidationError(a,this.model.getTerminal(a,!0),this.model.getTerminal(a,!1))||""):d+(this.getCellValidationError(a)||"");e=this.validateCell(a,b);null!=e&&(d+=e);null==this.model.getParent(a)&&this.view.validate();return 0f.max||bf.max||c")),null==e&&null!=a.overlays&&a.overlays.visit(function(a,c){null!=e||b!=c.node&&b.parentNode!=c.node||(e=c.overlay.toString())}),null==e&&(c=this.selectionCellsHandler.getHandler(a.cell),null!=c&&"function"==typeof c.getTooltipForNode&&(e=c.getTooltipForNode(b))),null== +e&&(e=this.getTooltipForCell(a.cell)));return e};mxGraph.prototype.getTooltipForCell=function(a){return null!=a&&null!=a.getTooltip?a.getTooltip():this.convertValueToString(a)};mxGraph.prototype.getLinkForCell=function(a){return null};mxGraph.prototype.getCursorForMouseEvent=function(a){return this.getCursorForCell(a.getCell())};mxGraph.prototype.getCursorForCell=function(a){return null}; +mxGraph.prototype.getStartSize=function(a){var b=new mxRectangle,c=this.view.getState(a);a=null!=c?c.style:this.getCellStyle(a);null!=a&&(c=parseInt(mxUtils.getValue(a,mxConstants.STYLE_STARTSIZE,mxConstants.DEFAULT_STARTSIZE)),mxUtils.getValue(a,mxConstants.STYLE_HORIZONTAL,!0)?b.height=c:b.width=c);return b};mxGraph.prototype.getImage=function(a){return null!=a&&null!=a.style?a.style[mxConstants.STYLE_IMAGE]:null}; +mxGraph.prototype.getVerticalAlign=function(a){return null!=a&&null!=a.style?a.style[mxConstants.STYLE_VERTICAL_ALIGN]||mxConstants.ALIGN_MIDDLE:null};mxGraph.prototype.getIndicatorColor=function(a){return null!=a&&null!=a.style?a.style[mxConstants.STYLE_INDICATOR_COLOR]:null};mxGraph.prototype.getIndicatorGradientColor=function(a){return null!=a&&null!=a.style?a.style[mxConstants.STYLE_INDICATOR_GRADIENTCOLOR]:null}; +mxGraph.prototype.getIndicatorShape=function(a){return null!=a&&null!=a.style?a.style[mxConstants.STYLE_INDICATOR_SHAPE]:null};mxGraph.prototype.getIndicatorImage=function(a){return null!=a&&null!=a.style?a.style[mxConstants.STYLE_INDICATOR_IMAGE]:null};mxGraph.prototype.getBorder=function(){return this.border};mxGraph.prototype.setBorder=function(a){this.border=a}; +mxGraph.prototype.isSwimlane=function(a){if(null!=a&&this.model.getParent(a)!=this.model.getRoot()){var b=this.view.getState(a),b=null!=b?b.style:this.getCellStyle(a);if(null!=b&&!this.model.isEdge(a))return b[mxConstants.STYLE_SHAPE]==mxConstants.SHAPE_SWIMLANE}return!1};mxGraph.prototype.isResizeContainer=function(){return this.resizeContainer};mxGraph.prototype.setResizeContainer=function(a){this.resizeContainer=a};mxGraph.prototype.isEnabled=function(){return this.enabled}; +mxGraph.prototype.setEnabled=function(a){this.enabled=a};mxGraph.prototype.isEscapeEnabled=function(){return this.escapeEnabled};mxGraph.prototype.setEscapeEnabled=function(a){this.escapeEnabled=a};mxGraph.prototype.isInvokesStopCellEditing=function(){return this.invokesStopCellEditing};mxGraph.prototype.setInvokesStopCellEditing=function(a){this.invokesStopCellEditing=a};mxGraph.prototype.isEnterStopsCellEditing=function(){return this.enterStopsCellEditing}; +mxGraph.prototype.setEnterStopsCellEditing=function(a){this.enterStopsCellEditing=a};mxGraph.prototype.isCellLocked=function(a){var b=this.model.getGeometry(a);return this.isCellsLocked()||null!=b&&this.model.isVertex(a)&&b.relative};mxGraph.prototype.isCellsLocked=function(){return this.cellsLocked};mxGraph.prototype.setCellsLocked=function(a){this.cellsLocked=a};mxGraph.prototype.getCloneableCells=function(a){return this.model.filterCells(a,mxUtils.bind(this,function(a){return this.isCellCloneable(a)}))}; +mxGraph.prototype.isCellCloneable=function(a){var b=this.view.getState(a);a=null!=b?b.style:this.getCellStyle(a);return this.isCellsCloneable()&&0!=a[mxConstants.STYLE_CLONEABLE]};mxGraph.prototype.isCellsCloneable=function(){return this.cellsCloneable};mxGraph.prototype.setCellsCloneable=function(a){this.cellsCloneable=a};mxGraph.prototype.getExportableCells=function(a){return this.model.filterCells(a,mxUtils.bind(this,function(a){return this.canExportCell(a)}))}; +mxGraph.prototype.canExportCell=function(a){return this.exportEnabled};mxGraph.prototype.getImportableCells=function(a){return this.model.filterCells(a,mxUtils.bind(this,function(a){return this.canImportCell(a)}))};mxGraph.prototype.canImportCell=function(a){return this.importEnabled};mxGraph.prototype.isCellSelectable=function(a){return this.isCellsSelectable()};mxGraph.prototype.isCellsSelectable=function(){return this.cellsSelectable}; +mxGraph.prototype.setCellsSelectable=function(a){this.cellsSelectable=a};mxGraph.prototype.getDeletableCells=function(a){return this.model.filterCells(a,mxUtils.bind(this,function(a){return this.isCellDeletable(a)}))};mxGraph.prototype.isCellDeletable=function(a){var b=this.view.getState(a);a=null!=b?b.style:this.getCellStyle(a);return this.isCellsDeletable()&&0!=a[mxConstants.STYLE_DELETABLE]};mxGraph.prototype.isCellsDeletable=function(){return this.cellsDeletable}; +mxGraph.prototype.setCellsDeletable=function(a){this.cellsDeletable=a};mxGraph.prototype.isLabelMovable=function(a){return!this.isCellLocked(a)&&(this.model.isEdge(a)&&this.edgeLabelsMovable||this.model.isVertex(a)&&this.vertexLabelsMovable)};mxGraph.prototype.isCellRotatable=function(a){var b=this.view.getState(a);return 0!=(null!=b?b.style:this.getCellStyle(a))[mxConstants.STYLE_ROTATABLE]};mxGraph.prototype.getMovableCells=function(a){return this.model.filterCells(a,mxUtils.bind(this,function(a){return this.isCellMovable(a)}))}; +mxGraph.prototype.isCellMovable=function(a){var b=this.view.getState(a),b=null!=b?b.style:this.getCellStyle(a);return this.isCellsMovable()&&!this.isCellLocked(a)&&0!=b[mxConstants.STYLE_MOVABLE]};mxGraph.prototype.isCellsMovable=function(){return this.cellsMovable};mxGraph.prototype.setCellsMovable=function(a){this.cellsMovable=a};mxGraph.prototype.isGridEnabled=function(){return this.gridEnabled};mxGraph.prototype.setGridEnabled=function(a){this.gridEnabled=a};mxGraph.prototype.isPortsEnabled=function(){return this.portsEnabled}; +mxGraph.prototype.setPortsEnabled=function(a){this.portsEnabled=a};mxGraph.prototype.getGridSize=function(){return this.gridSize};mxGraph.prototype.setGridSize=function(a){this.gridSize=a};mxGraph.prototype.getTolerance=function(){return this.tolerance};mxGraph.prototype.setTolerance=function(a){this.tolerance=a};mxGraph.prototype.isVertexLabelsMovable=function(){return this.vertexLabelsMovable};mxGraph.prototype.setVertexLabelsMovable=function(a){this.vertexLabelsMovable=a}; +mxGraph.prototype.isEdgeLabelsMovable=function(){return this.edgeLabelsMovable};mxGraph.prototype.setEdgeLabelsMovable=function(a){this.edgeLabelsMovable=a};mxGraph.prototype.isSwimlaneNesting=function(){return this.swimlaneNesting};mxGraph.prototype.setSwimlaneNesting=function(a){this.swimlaneNesting=a};mxGraph.prototype.isSwimlaneSelectionEnabled=function(){return this.swimlaneSelectionEnabled};mxGraph.prototype.setSwimlaneSelectionEnabled=function(a){this.swimlaneSelectionEnabled=a}; +mxGraph.prototype.isMultigraph=function(){return this.multigraph};mxGraph.prototype.setMultigraph=function(a){this.multigraph=a};mxGraph.prototype.isAllowLoops=function(){return this.allowLoops};mxGraph.prototype.setAllowDanglingEdges=function(a){this.allowDanglingEdges=a};mxGraph.prototype.isAllowDanglingEdges=function(){return this.allowDanglingEdges};mxGraph.prototype.setConnectableEdges=function(a){this.connectableEdges=a};mxGraph.prototype.isConnectableEdges=function(){return this.connectableEdges}; +mxGraph.prototype.setCloneInvalidEdges=function(a){this.cloneInvalidEdges=a};mxGraph.prototype.isCloneInvalidEdges=function(){return this.cloneInvalidEdges};mxGraph.prototype.setAllowLoops=function(a){this.allowLoops=a};mxGraph.prototype.isDisconnectOnMove=function(){return this.disconnectOnMove};mxGraph.prototype.setDisconnectOnMove=function(a){this.disconnectOnMove=a};mxGraph.prototype.isDropEnabled=function(){return this.dropEnabled}; +mxGraph.prototype.setDropEnabled=function(a){this.dropEnabled=a};mxGraph.prototype.isSplitEnabled=function(){return this.splitEnabled};mxGraph.prototype.setSplitEnabled=function(a){this.splitEnabled=a};mxGraph.prototype.isCellResizable=function(a){var b=this.view.getState(a),b=null!=b?b.style:this.getCellStyle(a);return this.isCellsResizable()&&!this.isCellLocked(a)&&"0"!=mxUtils.getValue(b,mxConstants.STYLE_RESIZABLE,"1")};mxGraph.prototype.isCellsResizable=function(){return this.cellsResizable}; +mxGraph.prototype.setCellsResizable=function(a){this.cellsResizable=a};mxGraph.prototype.isTerminalPointMovable=function(a,b){return!0};mxGraph.prototype.isCellBendable=function(a){var b=this.view.getState(a),b=null!=b?b.style:this.getCellStyle(a);return this.isCellsBendable()&&!this.isCellLocked(a)&&0!=b[mxConstants.STYLE_BENDABLE]};mxGraph.prototype.isCellsBendable=function(){return this.cellsBendable};mxGraph.prototype.setCellsBendable=function(a){this.cellsBendable=a}; +mxGraph.prototype.isCellEditable=function(a){var b=this.view.getState(a),b=null!=b?b.style:this.getCellStyle(a);return this.isCellsEditable()&&!this.isCellLocked(a)&&0!=b[mxConstants.STYLE_EDITABLE]};mxGraph.prototype.isCellsEditable=function(){return this.cellsEditable};mxGraph.prototype.setCellsEditable=function(a){this.cellsEditable=a};mxGraph.prototype.isCellDisconnectable=function(a,b,c){return this.isCellsDisconnectable()&&!this.isCellLocked(a)};mxGraph.prototype.isCellsDisconnectable=function(){return this.cellsDisconnectable}; +mxGraph.prototype.setCellsDisconnectable=function(a){this.cellsDisconnectable=a};mxGraph.prototype.isValidSource=function(a){return null==a&&this.allowDanglingEdges||null!=a&&(!this.model.isEdge(a)||this.connectableEdges)&&this.isCellConnectable(a)};mxGraph.prototype.isValidTarget=function(a){return this.isValidSource(a)};mxGraph.prototype.isValidConnection=function(a,b){return this.isValidSource(a)&&this.isValidTarget(b)};mxGraph.prototype.setConnectable=function(a){this.connectionHandler.setEnabled(a)}; +mxGraph.prototype.isConnectable=function(a){return this.connectionHandler.isEnabled()};mxGraph.prototype.setTooltips=function(a){this.tooltipHandler.setEnabled(a)};mxGraph.prototype.setPanning=function(a){this.panningHandler.panningEnabled=a};mxGraph.prototype.isEditing=function(a){if(null!=this.cellEditor){var b=this.cellEditor.getEditingCell();return null==a?null!=b:a==b}return!1}; +mxGraph.prototype.isAutoSizeCell=function(a){var b=this.view.getState(a);a=null!=b?b.style:this.getCellStyle(a);return this.isAutoSizeCells()||1==a[mxConstants.STYLE_AUTOSIZE]};mxGraph.prototype.isAutoSizeCells=function(){return this.autoSizeCells};mxGraph.prototype.setAutoSizeCells=function(a){this.autoSizeCells=a};mxGraph.prototype.isExtendParent=function(a){return!this.getModel().isEdge(a)&&this.isExtendParents()};mxGraph.prototype.isExtendParents=function(){return this.extendParents}; +mxGraph.prototype.setExtendParents=function(a){this.extendParents=a};mxGraph.prototype.isExtendParentsOnAdd=function(a){return this.extendParentsOnAdd};mxGraph.prototype.setExtendParentsOnAdd=function(a){this.extendParentsOnAdd=a};mxGraph.prototype.isExtendParentsOnMove=function(){return this.extendParentsOnMove};mxGraph.prototype.setExtendParentsOnMove=function(a){this.extendParentsOnMove=a};mxGraph.prototype.isRecursiveResize=function(a){return this.recursiveResize}; +mxGraph.prototype.setRecursiveResize=function(a){this.recursiveResize=a};mxGraph.prototype.isConstrainChild=function(a){return this.isConstrainChildren()&&!this.getModel().isEdge(this.getModel().getParent(a))};mxGraph.prototype.isConstrainChildren=function(){return this.constrainChildren};mxGraph.prototype.setConstrainChildren=function(a){this.constrainChildren=a};mxGraph.prototype.isConstrainRelativeChildren=function(){return this.constrainRelativeChildren}; +mxGraph.prototype.setConstrainRelativeChildren=function(a){this.constrainRelativeChildren=a};mxGraph.prototype.isAllowNegativeCoordinates=function(){return this.allowNegativeCoordinates};mxGraph.prototype.setAllowNegativeCoordinates=function(a){this.allowNegativeCoordinates=a};mxGraph.prototype.getOverlap=function(a){return this.isAllowOverlapParent(a)?this.defaultOverlap:0};mxGraph.prototype.isAllowOverlapParent=function(a){return!1}; +mxGraph.prototype.getFoldableCells=function(a,b){return this.model.filterCells(a,mxUtils.bind(this,function(a){return this.isCellFoldable(a,b)}))};mxGraph.prototype.isCellFoldable=function(a,b){var c=this.view.getState(a),c=null!=c?c.style:this.getCellStyle(a);return 0mxUtils.indexOf(a,g);)g=this.model.getParent(g);return this.model.isLayer(c)||null!=g?null:c};mxGraph.prototype.getDefaultParent=function(){var a=this.getCurrentRoot();null==a&&(a=this.defaultParent,null==a&&(a=this.model.getRoot(),a=this.model.getChildAt(a,0)));return a};mxGraph.prototype.setDefaultParent=function(a){this.defaultParent=a};mxGraph.prototype.getSwimlane=function(a){for(;null!=a&&!this.isSwimlane(a);)a=this.model.getParent(a);return a}; +mxGraph.prototype.getSwimlaneAt=function(a,b,c){c=c||this.getDefaultParent();if(null!=c)for(var d=this.model.getChildCount(c),e=0;ea.width*e||0a.height*e)return!0}return!1};mxGraph.prototype.getChildVertices=function(a){return this.getChildCells(a,!0,!1)};mxGraph.prototype.getChildEdges=function(a){return this.getChildCells(a,!1,!0)}; +mxGraph.prototype.getChildCells=function(a,b,c){a=null!=a?a:this.getDefaultParent();a=this.model.getChildCells(a,null!=b?b:!1,null!=c?c:!1);b=[];for(c=0;c=a&&q.y+q.height<=l&&q.y>=b&&q.x+q.width<=k?f.push(p):this.getCells(a, +b,c,d,p,f)}}}return f};mxGraph.prototype.getCellsBeyond=function(a,b,c,d,e){var f=[];if(d||e)if(null==c&&(c=this.getDefaultParent()),null!=c)for(var g=this.model.getChildCount(c),k=0;k=a)&&(!e||m.y>=b)&&f.push(l)}return f}; +mxGraph.prototype.findTreeRoots=function(a,b,c){b=null!=b?b:!1;c=null!=c?c:!1;var d=[];if(null!=a){for(var e=this.getModel(),f=e.getChildCount(a),g=null,k=0,l=0;lk&&(k=n,g=m)}}0==d.length&&null!=g&&d.push(g)}return d}; +mxGraph.prototype.traverse=function(a,b,c,d,e,f){if(null!=c&&null!=a&&(b=null!=b?b:!0,f=null!=f?f:!1,e=e||new mxDictionary,!e.get(a)&&(e.put(a,!0),d=c(a,d),null==d||d))&&(d=this.model.getEdgeCount(a),0b?f-1:b)),this.setSelectionCell(a)):this.getCurrentRoot()!=d&&this.setSelectionCell(d)};mxGraph.prototype.selectAll=function(a,b){a=a||this.getDefaultParent();var c=b?this.model.filterDescendants(function(b){return b!=a},a):this.model.getChildren(a);null!=c&&this.setSelectionCells(c)};mxGraph.prototype.selectVertices=function(a){this.selectCells(!0,!1,a)};mxGraph.prototype.selectEdges=function(a){this.selectCells(!1,!0,a)}; +mxGraph.prototype.selectCells=function(a,b,c){c=c||this.getDefaultParent();var d=mxUtils.bind(this,function(c){return null!=this.view.getState(c)&&(0==this.model.getChildCount(c)&&this.model.isVertex(c)&&a&&!this.model.isEdge(this.model.getParent(c))||this.model.isEdge(c)&&b)});c=this.model.filterDescendants(d,c);this.setSelectionCells(c)}; +mxGraph.prototype.selectCellForEvent=function(a,b){var c=this.isCellSelected(a);this.isToggleEvent(b)?c?this.removeSelectionCell(a):this.addSelectionCell(a):c&&1==this.getSelectionCount()||this.setSelectionCell(a)};mxGraph.prototype.selectCellsForEvent=function(a,b){this.isToggleEvent(b)?this.addSelectionCells(a):this.setSelectionCells(a)}; +mxGraph.prototype.createHandler=function(a){var b=null;if(null!=a)if(this.model.isEdge(a.cell))var b=a.getVisibleTerminalState(!0),c=a.getVisibleTerminalState(!1),d=this.getCellGeometry(a.cell),b=this.view.getEdgeStyle(a,null!=d?d.points:null,b,c),b=this.createEdgeHandler(a,b);else b=this.createVertexHandler(a);return b};mxGraph.prototype.createVertexHandler=function(a){return new mxVertexHandler(a)}; +mxGraph.prototype.createEdgeHandler=function(a,b){return b==mxEdgeStyle.Loop||b==mxEdgeStyle.ElbowConnector||b==mxEdgeStyle.SideToSide||b==mxEdgeStyle.TopToBottom?this.createElbowEdgeHandler(a):b==mxEdgeStyle.SegmentConnector||b==mxEdgeStyle.OrthConnector?this.createEdgeSegmentHandler(a):new mxEdgeHandler(a)};mxGraph.prototype.createEdgeSegmentHandler=function(a){return new mxEdgeSegmentHandler(a)};mxGraph.prototype.createElbowEdgeHandler=function(a){return new mxElbowEdgeHandler(a)}; +mxGraph.prototype.addMouseListener=function(a){null==this.mouseListeners&&(this.mouseListeners=[]);this.mouseListeners.push(a)};mxGraph.prototype.removeMouseListener=function(a){if(null!=this.mouseListeners)for(var b=0;bthis.doubleClickCounter){if(this.doubleClickCounter++,d=!1,a==mxEvent.MOUSE_UP?b.getCell()==this.lastTouchCell&&null!=this.lastTouchCell&&(this.lastTouchTime=0,d=this.lastTouchCell,this.lastTouchCell=null,mxClient.IS_QUIRKS&&b.getSource().fireEvent("ondblclick"),this.dblClick(b.getEvent(), +d),d=!0):(this.fireDoubleClick=!0,this.lastTouchTime=0),!mxClient.IS_QUIRKS||d){mxEvent.consume(b.getEvent());return}}else{if(null==this.lastTouchEvent||this.lastTouchEvent!=b.getEvent())this.lastTouchCell=b.getCell(),this.lastTouchX=b.getX(),this.lastTouchY=b.getY(),this.lastTouchTime=d,this.lastTouchEvent=b.getEvent(),this.doubleClickCounter=0}else if((this.isMouseDown||a==mxEvent.MOUSE_UP)&&this.fireDoubleClick){this.fireDoubleClick=!1;d=this.lastTouchCell;this.lastTouchCell=null;this.isMouseDown= +!1;(null!=d||(mxEvent.isTouchEvent(b.getEvent())||mxEvent.isPenEvent(b.getEvent()))&&(mxClient.IS_GC||mxClient.IS_SF))&&Math.abs(this.lastTouchX-b.getX())c.x&&(f-=c.x);0>c.y&&(g-=c.y);if(b.translate.x!=f||b.translate.y!=g)b.translate.x=f,b.translate.y=g,a=!0;var c=b.translate,d=this.source.getView().scale,f=d/b.scale,g=1/b.scale,k=this.source.container;this.bounds=new mxRectangle((c.x-e.x-this.source.panDx)/g,(c.y-e.y-this.source.panDy)/g,k.clientWidth/f,k.clientHeight/f);this.bounds.x+=this.source.container.scrollLeft*b.scale/d;this.bounds.y+=this.source.container.scrollTop*b.scale/d;c=this.selectionBorder.bounds;if(c.x!=this.bounds.x|| +c.y!=this.bounds.y||c.width!=this.bounds.width||c.height!=this.bounds.height)this.selectionBorder.bounds=this.bounds,this.selectionBorder.redraw();c=this.sizer.bounds;b=new mxRectangle(this.bounds.x+this.bounds.width-c.width/2,this.bounds.y+this.bounds.height-c.height/2,c.width,c.height);if(c.x!=b.x||c.y!=b.y||c.width!=b.width||c.height!=b.height)this.sizer.bounds=b,"hidden"!=this.sizer.node.style.visibility&&this.sizer.redraw();a&&this.outline.view.revalidate()}}}; +mxOutline.prototype.mouseDown=function(a,b){if(this.enabled&&this.showViewport){var c=mxEvent.isMouseEvent(b.getEvent())?0:this.source.tolerance,c=this.source.allowHandleBoundsCheck&&(mxClient.IS_IE||0=this.max)||!this.source&&(0==this.max||f>=this.max))&&(g+=this.countError+"\n"),null!=this.validNeighbors&&null!=this.typeError&&0mxUtils.indexOf(a,f)&&(f=this.getLayout(f),null!=f&&f.moveCell(a[e],c.x,c.y))}}; +mxLayoutManager.prototype.getCellsForChanges=function(a){for(var b=new mxDictionary,c=[],d=0;df||Math.abs(d)>f){null==this.highlight&&(this.highlight=new mxCellHighlight(this.graph,mxConstants.DROP_TARGET_COLOR,3));null==this.shape&&(this.shape=this.createPreviewShape(this.bounds));var g=c.isGridEnabledEvent(b.getEvent()), +f=!0;if(null!=this.guide&&this.useGuidesForEvent(b))d=this.guide.move(this.bounds,new mxPoint(e,d),g),f=!1,e=d.x,d=d.y;else if(g)var k=c.getView().translate,l=c.getView().scale,g=this.bounds.x-(c.snap(this.bounds.x/l-k.x)+k.x)*l,k=this.bounds.y-(c.snap(this.bounds.y/l-k.y)+k.y)*l,d=this.snap(new mxPoint(e,d)),e=d.x-g,d=d.y-k;null!=this.guide&&f&&this.guide.hide();c.isConstrainedEvent(b.getEvent())&&(Math.abs(e)>Math.abs(d)?d=0:e=0);this.currentDx=e;this.currentDy=d;this.updatePreviewShape();f=null; +d=b.getCell();g=c.isCloneEvent(b.getEvent())&&c.isCellsCloneable()&&this.isCloneEnabled();c.isDropEnabled()&&this.highlightEnabled&&(f=c.getDropTarget(this.cells,b.getEvent(),d,g));e=c.getView().getState(f);k=!1;null==e||c.model.getParent(this.cell)==f&&!g?(this.target=null,this.connectOnDrop&&null!=d&&1==this.cells.length&&c.getModel().isVertex(d)&&c.isCellConnectable(d)&&(e=c.getView().getState(d),null!=e&&(c=null==c.getEdgeValidationError(null,this.cell,d)?mxConstants.VALID_COLOR:mxConstants.INVALID_CONNECT_TARGET_COLOR, +this.setHighlightColor(c),k=!0))):(this.target!=f&&(this.target=f,this.setHighlightColor(mxConstants.DROP_TARGET_COLOR)),k=!0);null!=e&&k?this.highlight.highlight(e):this.highlight.hide()}this.updateHint(b);this.consumeMouseEvent(mxEvent.MOUSE_MOVE,b);mxEvent.consume(b.getEvent())}else!this.isMoveEnabled()&&!this.isCloneEnabled()||!this.updateCursor||b.isConsumed()||null==b.getState()&&null==b.sourceState||c.isMouseDown||(e=c.getCursorForMouseEvent(b),null==e&&c.isEnabled()&&c.isCellMovable(b.getCell())&& +(e=c.getModel().isEdge(b.getCell())?mxConstants.CURSOR_MOVABLE_EDGE:mxConstants.CURSOR_MOVABLE_VERTEX),null!=e&&null!=b.sourceState&&b.sourceState.setCursor(e))};mxGraphHandler.prototype.updatePreviewShape=function(){null!=this.shape&&(this.shape.bounds=new mxRectangle(Math.round(this.pBounds.x+this.currentDx-this.graph.panDx),Math.round(this.pBounds.y+this.currentDy-this.graph.panDy),this.pBounds.width,this.pBounds.height),this.shape.redraw())}; +mxGraphHandler.prototype.setHighlightColor=function(a){null!=this.highlight&&this.highlight.setHighlightColor(a)}; +mxGraphHandler.prototype.mouseUp=function(a,b){if(!b.isConsumed()){var c=this.graph;if(null!=this.cell&&null!=this.first&&null!=this.shape&&null!=this.currentDx&&null!=this.currentDy){var d=b.getCell();if(this.connectOnDrop&&null==this.target&&null!=d&&c.getModel().isVertex(d)&&c.isCellConnectable(d)&&c.isEdgeValid(null,this.cell,d))c.connectionHandler.connect(this.cell,d,b.getEvent());else{var d=c.isCloneEvent(b.getEvent())&&c.isCellsCloneable()&&this.isCloneEnabled(),e=c.getView().scale,f=this.roundLength(this.currentDx/ +e),e=this.roundLength(this.currentDy/e),g=this.target;c.isSplitEnabled()&&c.isSplitTarget(g,this.cells,b.getEvent())?c.splitEdge(g,this.cells,null,f,e):this.moveCells(this.cells,f,e,d,this.target,b.getEvent())}}else this.isSelectEnabled()&&this.delayedSelection&&null!=this.cell&&this.selectDelayed(b)}this.cellWasClicked&&this.consumeMouseEvent(mxEvent.MOUSE_UP,b);this.reset()}; +mxGraphHandler.prototype.selectDelayed=function(a){this.graph.isCellSelected(this.cell)&&this.graph.popupMenuHandler.isPopupTrigger(a)||this.graph.selectCellForEvent(this.cell,a.getEvent())};mxGraphHandler.prototype.reset=function(){this.destroyShapes();this.removeHint();this.delayedSelection=this.cellWasClicked=!1;this.target=this.cell=this.first=this.guides=this.currentDy=this.currentDx=null}; +mxGraphHandler.prototype.shouldRemoveCellsFromParent=function(a,b,c){if(this.graph.getModel().isVertex(a)&&(a=this.graph.getView().getState(a),null!=a)){c=mxUtils.convertPoint(this.graph.container,mxEvent.getClientX(c),mxEvent.getClientY(c));var d=mxUtils.toRadians(mxUtils.getValue(a.style,mxConstants.STYLE_ROTATION)||0);if(0!=d){b=Math.cos(-d);var d=Math.sin(-d),e=new mxPoint(a.getCenterX(),a.getCenterY());c=mxUtils.getRotatedPoint(c,b,d,e)}return!mxUtils.contains(a,c.x,c.y)}return!1}; +mxGraphHandler.prototype.moveCells=function(a,b,c,d,e,f){d&&(a=this.graph.getCloneableCells(a));null==e&&this.isRemoveCellsFromParent()&&this.shouldRemoveCellsFromParent(this.graph.getModel().getParent(this.cell),a,f)&&(e=this.graph.getDefaultParent());d=d&&!this.graph.isCellLocked(e||this.graph.getDefaultParent());a=this.graph.moveCells(a,b-this.graph.panDx/this.graph.view.scale,c-this.graph.panDy/this.graph.view.scale,d,e,f);this.isSelectEnabled()&&this.scrollOnMove&&this.graph.scrollCellToVisible(a[0]); +d&&this.graph.setSelectionCells(a)};mxGraphHandler.prototype.destroyShapes=function(){null!=this.shape&&(this.shape.destroy(),this.shape=null);null!=this.guide&&(this.guide.destroy(),this.guide=null);null!=this.highlight&&(this.highlight.destroy(),this.highlight=null)}; +mxGraphHandler.prototype.destroy=function(){this.graph.removeMouseListener(this);this.graph.removeListener(this.panHandler);null!=this.escapeHandler&&(this.graph.removeListener(this.escapeHandler),this.escapeHandler=null);this.destroyShapes();this.removeHint()}; +function mxPanningHandler(a){null!=a&&(this.graph=a,this.graph.addMouseListener(this),this.forcePanningHandler=mxUtils.bind(this,function(a,c){var b=c.getProperty("eventName"),e=c.getProperty("event");b==mxEvent.MOUSE_DOWN&&this.isForcePanningEvent(e)&&(this.start(e),this.active=!0,this.fireEvent(new mxEventObject(mxEvent.PAN_START,"event",e)),e.consume())}),this.graph.addListener(mxEvent.FIRE_MOUSE_EVENT,this.forcePanningHandler),this.gestureHandler=mxUtils.bind(this,function(a,c){if(this.isPinchEnabled()){var b= +c.getProperty("event");mxEvent.isConsumed(b)||"gesturestart"!=b.type?"gestureend"==b.type&&null!=this.initialScale&&(this.initialScale=null):(this.initialScale=this.graph.view.scale,this.active||null==this.mouseDownEvent||(this.start(this.mouseDownEvent),this.mouseDownEvent=null));if(null!=this.initialScale){var e=Math.round(this.initialScale*b.scale*100)/100;null!=this.minScale&&(e=Math.max(this.minScale,e));null!=this.maxScale&&(e=Math.min(this.maxScale,e));this.graph.view.scale!=e&&(this.graph.zoomTo(e), +mxEvent.consume(b))}}}),this.graph.addListener(mxEvent.GESTURE,this.gestureHandler),this.mouseUpListener=mxUtils.bind(this,function(){this.active&&this.reset()}),mxEvent.addListener(document,"mouseup",this.mouseUpListener))}mxPanningHandler.prototype=new mxEventSource;mxPanningHandler.prototype.constructor=mxPanningHandler;mxPanningHandler.prototype.graph=null;mxPanningHandler.prototype.useLeftButtonForPanning=!1;mxPanningHandler.prototype.usePopupTrigger=!0; +mxPanningHandler.prototype.ignoreCell=!1;mxPanningHandler.prototype.previewEnabled=!0;mxPanningHandler.prototype.useGrid=!1;mxPanningHandler.prototype.panningEnabled=!0;mxPanningHandler.prototype.pinchEnabled=!0;mxPanningHandler.prototype.maxScale=8;mxPanningHandler.prototype.minScale=.01;mxPanningHandler.prototype.dx=null;mxPanningHandler.prototype.dy=null;mxPanningHandler.prototype.startX=0;mxPanningHandler.prototype.startY=0; +mxPanningHandler.prototype.isActive=function(){return this.active||null!=this.initialScale};mxPanningHandler.prototype.isPanningEnabled=function(){return this.panningEnabled};mxPanningHandler.prototype.setPanningEnabled=function(a){this.panningEnabled=a};mxPanningHandler.prototype.isPinchEnabled=function(){return this.pinchEnabled};mxPanningHandler.prototype.setPinchEnabled=function(a){this.pinchEnabled=a}; +mxPanningHandler.prototype.isPanningTrigger=function(a){var b=a.getEvent();return this.useLeftButtonForPanning&&null==a.getState()&&mxEvent.isLeftMouseButton(b)||mxEvent.isControlDown(b)&&mxEvent.isShiftDown(b)||this.usePopupTrigger&&mxEvent.isPopupTrigger(b)};mxPanningHandler.prototype.isForcePanningEvent=function(a){return this.ignoreCell||mxEvent.isMultiTouchEvent(a.getEvent())}; +mxPanningHandler.prototype.mouseDown=function(a,b){this.mouseDownEvent=b;!b.isConsumed()&&this.isPanningEnabled()&&!this.active&&this.isPanningTrigger(b)&&(this.start(b),this.consumePanningTrigger(b))};mxPanningHandler.prototype.start=function(a){this.dx0=-this.graph.container.scrollLeft;this.dy0=-this.graph.container.scrollTop;this.startX=a.getX();this.startY=a.getY();this.dy=this.dx=null;this.panningTrigger=!0};mxPanningHandler.prototype.consumePanningTrigger=function(a){a.consume()}; +mxPanningHandler.prototype.mouseMove=function(a,b){this.dx=b.getX()-this.startX;this.dy=b.getY()-this.startY;if(this.active)this.previewEnabled&&(this.useGrid&&(this.dx=this.graph.snap(this.dx),this.dy=this.graph.snap(this.dy)),this.graph.panGraph(this.dx+this.dx0,this.dy+this.dy0)),this.fireEvent(new mxEventObject(mxEvent.PAN,"event",b));else if(this.panningTrigger){var c=this.active;this.active=Math.abs(this.dx)>this.graph.tolerance||Math.abs(this.dy)>this.graph.tolerance;!c&&this.active&&this.fireEvent(new mxEventObject(mxEvent.PAN_START, +"event",b))}(this.active||this.panningTrigger)&&b.consume()};mxPanningHandler.prototype.mouseUp=function(a,b){if(this.active){if(null!=this.dx&&null!=this.dy){if(!this.graph.useScrollbarsForPanning||!mxUtils.hasScrollbars(this.graph.container)){var c=this.graph.getView().scale,d=this.graph.getView().translate;this.graph.panGraph(0,0);this.panGraph(d.x+this.dx/c,d.y+this.dy/c)}b.consume()}this.fireEvent(new mxEventObject(mxEvent.PAN_END,"event",b))}this.reset()}; +mxPanningHandler.prototype.reset=function(){this.panningTrigger=!1;this.mouseDownEvent=null;this.active=!1;this.dy=this.dx=null};mxPanningHandler.prototype.panGraph=function(a,b){this.graph.getView().setTranslate(a,b)};mxPanningHandler.prototype.destroy=function(){this.graph.removeMouseListener(this);this.graph.removeListener(this.forcePanningHandler);this.graph.removeListener(this.gestureHandler);mxEvent.removeListener(document,"mouseup",this.mouseUpListener)}; +function mxPopupMenuHandler(a,b){null!=a&&(this.graph=a,this.factoryMethod=b,this.graph.addMouseListener(this),this.gestureHandler=mxUtils.bind(this,function(a,b){this.inTolerance=!1}),this.graph.addListener(mxEvent.GESTURE,this.gestureHandler),this.init())}mxPopupMenuHandler.prototype=new mxPopupMenu;mxPopupMenuHandler.prototype.constructor=mxPopupMenuHandler;mxPopupMenuHandler.prototype.graph=null;mxPopupMenuHandler.prototype.selectOnPopup=!0; +mxPopupMenuHandler.prototype.clearSelectionOnBackground=!0;mxPopupMenuHandler.prototype.triggerX=null;mxPopupMenuHandler.prototype.triggerY=null;mxPopupMenuHandler.prototype.screenX=null;mxPopupMenuHandler.prototype.screenY=null;mxPopupMenuHandler.prototype.init=function(){mxPopupMenu.prototype.init.apply(this);mxEvent.addGestureListeners(this.div,mxUtils.bind(this,function(a){this.graph.tooltipHandler.hide()}))};mxPopupMenuHandler.prototype.isSelectOnPopup=function(a){return this.selectOnPopup}; +mxPopupMenuHandler.prototype.mouseDown=function(a,b){this.isEnabled()&&!mxEvent.isMultiTouchEvent(b.getEvent())&&(this.hideMenu(),this.triggerX=b.getGraphX(),this.triggerY=b.getGraphY(),this.screenX=mxEvent.getMainEvent(b.getEvent()).screenX,this.screenY=mxEvent.getMainEvent(b.getEvent()).screenY,this.popupTrigger=this.isPopupTrigger(b),this.inTolerance=!0)}; +mxPopupMenuHandler.prototype.mouseMove=function(a,b){this.inTolerance&&null!=this.screenX&&null!=this.screenY&&(Math.abs(mxEvent.getMainEvent(b.getEvent()).screenX-this.screenX)>this.graph.tolerance||Math.abs(mxEvent.getMainEvent(b.getEvent()).screenY-this.screenY)>this.graph.tolerance)&&(this.inTolerance=!1)}; +mxPopupMenuHandler.prototype.mouseUp=function(a,b){if(this.popupTrigger&&this.inTolerance&&null!=this.triggerX&&null!=this.triggerY){var c=this.getCellForPopupEvent(b);this.graph.isEnabled()&&this.isSelectOnPopup(b)&&null!=c&&!this.graph.isCellSelected(c)?this.graph.setSelectionCell(c):this.clearSelectionOnBackground&&null==c&&this.graph.clearSelection();this.graph.tooltipHandler.hide();var d=mxUtils.getScrollOrigin();this.popup(b.getX()+d.x+1,b.getY()+d.y+1,c,b.getEvent());b.consume()}this.inTolerance= +this.popupTrigger=!1};mxPopupMenuHandler.prototype.getCellForPopupEvent=function(a){return a.getCell()};mxPopupMenuHandler.prototype.destroy=function(){this.graph.removeMouseListener(this);this.graph.removeListener(this.gestureHandler);mxPopupMenu.prototype.destroy.apply(this)}; +function mxCellMarker(a,b,c,d){mxEventSource.call(this);null!=a&&(this.graph=a,this.validColor=null!=b?b:mxConstants.DEFAULT_VALID_COLOR,this.invalidColor=null!=b?c:mxConstants.DEFAULT_INVALID_COLOR,this.hotspot=null!=d?d:mxConstants.DEFAULT_HOTSPOT,this.highlight=new mxCellHighlight(a))}mxUtils.extend(mxCellMarker,mxEventSource);mxCellMarker.prototype.graph=null;mxCellMarker.prototype.enabled=!0;mxCellMarker.prototype.hotspot=mxConstants.DEFAULT_HOTSPOT;mxCellMarker.prototype.hotspotEnabled=!1; +mxCellMarker.prototype.validColor=null;mxCellMarker.prototype.invalidColor=null;mxCellMarker.prototype.currentColor=null;mxCellMarker.prototype.validState=null;mxCellMarker.prototype.markedState=null;mxCellMarker.prototype.setEnabled=function(a){this.enabled=a};mxCellMarker.prototype.isEnabled=function(){return this.enabled};mxCellMarker.prototype.setHotspot=function(a){this.hotspot=a};mxCellMarker.prototype.getHotspot=function(){return this.hotspot}; +mxCellMarker.prototype.setHotspotEnabled=function(a){this.hotspotEnabled=a};mxCellMarker.prototype.isHotspotEnabled=function(){return this.hotspotEnabled};mxCellMarker.prototype.hasValidState=function(){return null!=this.validState};mxCellMarker.prototype.getValidState=function(){return this.validState};mxCellMarker.prototype.getMarkedState=function(){return this.markedState};mxCellMarker.prototype.reset=function(){this.validState=null;null!=this.markedState&&(this.markedState=null,this.unmark())}; +mxCellMarker.prototype.process=function(a){var b=null;this.isEnabled()&&(b=this.getState(a),this.setCurrentState(b,a));return b};mxCellMarker.prototype.setCurrentState=function(a,b,c){var d=null!=a?this.isValidState(a):!1;c=null!=c?c:this.getMarkerColor(b.getEvent(),a,d);this.validState=d?a:null;if(a!=this.markedState||c!=this.currentColor)this.currentColor=c,null!=a&&null!=this.currentColor?(this.markedState=a,this.mark()):null!=this.markedState&&(this.markedState=null,this.unmark())}; +mxCellMarker.prototype.markCell=function(a,b){var c=this.graph.getView().getState(a);null!=c&&(this.currentColor=null!=b?b:this.validColor,this.markedState=c,this.mark())};mxCellMarker.prototype.mark=function(){this.highlight.setHighlightColor(this.currentColor);this.highlight.highlight(this.markedState);this.fireEvent(new mxEventObject(mxEvent.MARK,"state",this.markedState))};mxCellMarker.prototype.unmark=function(){this.mark()};mxCellMarker.prototype.isValidState=function(a){return!0}; +mxCellMarker.prototype.getMarkerColor=function(a,b,c){return c?this.validColor:this.invalidColor};mxCellMarker.prototype.getState=function(a){var b=this.graph.getView(),c=this.getCell(a),b=this.getStateToMark(b.getState(c));return null!=b&&this.intersects(b,a)?b:null};mxCellMarker.prototype.getCell=function(a){return a.getCell()};mxCellMarker.prototype.getStateToMark=function(a){return a}; +mxCellMarker.prototype.intersects=function(a,b){return this.hotspotEnabled?mxUtils.intersectsHotspot(a,b.getGraphX(),b.getGraphY(),this.hotspot,mxConstants.MIN_HOTSPOT_SIZE,mxConstants.MAX_HOTSPOT_SIZE):!0};mxCellMarker.prototype.destroy=function(){this.graph.getView().removeListener(this.resetHandler);this.graph.getModel().removeListener(this.resetHandler);this.highlight.destroy()}; +function mxSelectionCellsHandler(a){mxEventSource.call(this);this.graph=a;this.handlers=new mxDictionary;this.graph.addMouseListener(this);this.refreshHandler=mxUtils.bind(this,function(a,c){this.isEnabled()&&this.refresh()});this.graph.getSelectionModel().addListener(mxEvent.CHANGE,this.refreshHandler);this.graph.getModel().addListener(mxEvent.CHANGE,this.refreshHandler);this.graph.getView().addListener(mxEvent.SCALE,this.refreshHandler);this.graph.getView().addListener(mxEvent.TRANSLATE,this.refreshHandler); +this.graph.getView().addListener(mxEvent.SCALE_AND_TRANSLATE,this.refreshHandler);this.graph.getView().addListener(mxEvent.DOWN,this.refreshHandler);this.graph.getView().addListener(mxEvent.UP,this.refreshHandler)}mxUtils.extend(mxSelectionCellsHandler,mxEventSource);mxSelectionCellsHandler.prototype.graph=null;mxSelectionCellsHandler.prototype.enabled=!0;mxSelectionCellsHandler.prototype.refreshHandler=null;mxSelectionCellsHandler.prototype.maxHandlers=100; +mxSelectionCellsHandler.prototype.handlers=null;mxSelectionCellsHandler.prototype.isEnabled=function(){return this.enabled};mxSelectionCellsHandler.prototype.setEnabled=function(a){this.enabled=a};mxSelectionCellsHandler.prototype.getHandler=function(a){return this.handlers.get(a)};mxSelectionCellsHandler.prototype.reset=function(){this.handlers.visit(function(a,b){b.reset.apply(b)})}; +mxSelectionCellsHandler.prototype.refresh=function(){var a=this.handlers;this.handlers=new mxDictionary;for(var b=this.graph.getSelectionCells(),c=0;cthis.graph.tolerance||g>this.graph.tolerance)&&(this.shape=this.createShape(), +null!=this.edgeState&&this.shape.apply(this.edgeState),this.updateCurrentState(b,c));null!=this.shape&&(null!=this.edgeState?this.shape.points=this.edgeState.absolutePoints:(c=[e],null!=this.waypoints&&(c=c.concat(this.waypoints)),c.push(d),this.shape.points=c),this.drawPreview());null!=this.cursor&&(this.graph.container.style.cursor=this.cursor);mxEvent.consume(b.getEvent());b.consume()}else this.isEnabled()&&this.graph.isEnabled()?this.previous!=this.currentState&&null==this.edgeState?(this.destroyIcons(), +null!=this.currentState&&null==this.error&&null==this.constraintHandler.currentConstraint&&(this.icons=this.createIcons(this.currentState),null==this.icons&&(this.currentState.setCursor(mxConstants.CURSOR_CONNECT),b.consume())),this.previous=this.currentState):this.previous!=this.currentState||null==this.currentState||null!=this.icons||this.graph.isMouseDown||b.consume():this.constraintHandler.reset();if(!this.graph.isMouseDown&&null!=this.currentState&&null!=this.icons){c=!1;d=b.getSource();for(e= +0;ethis.graph.tolerance||b>this.graph.tolerance))null==this.waypoints&&(this.waypoints=[]),c=this.graph.view.scale,b=new mxPoint(this.graph.snap(a.getGraphX()/c)*c,this.graph.snap(a.getGraphY()/c)*c),this.waypoints.push(b)}; +mxConnectionHandler.prototype.mouseUp=function(a,b){if(!b.isConsumed()&&this.isConnecting()){if(this.waypointsEnabled&&!this.isStopEvent(b)){this.addWaypointForEvent(b);b.consume();return}if(null==this.error){var c=null!=this.previous?this.previous.cell:null,d=null;null!=this.constraintHandler.currentConstraint&&null!=this.constraintHandler.currentFocus&&(d=this.constraintHandler.currentFocus.cell);null==d&&null!=this.currentState&&(d=this.currentState.cell);this.connect(c,d,b.getEvent(),b.getCell())}else null!= +this.previous&&null!=this.marker.validState&&this.previous.cell==this.marker.validState.cell&&this.graph.selectCellForEvent(this.marker.source,evt),0g||Math.abs(f)>g)null==this.div&&(this.div=this.createShape()),mxUtils.clearSelection(),this.update(d,c),b.consume()}}; +mxRubberband.prototype.createShape=function(){null==this.sharedDiv&&(this.sharedDiv=document.createElement("div"),this.sharedDiv.className="mxRubberband",mxUtils.setOpacity(this.sharedDiv,this.defaultOpacity));this.graph.container.appendChild(this.sharedDiv);var a=this.sharedDiv;mxClient.IS_SVG&&(!mxClient.IS_IE||10<=document.documentMode)&&this.fadeOut&&(this.sharedDiv=null);return a};mxRubberband.prototype.isActive=function(a,b){return null!=this.div&&"none"!=this.div.style.display}; +mxRubberband.prototype.mouseUp=function(a,b){var c=this.isActive();this.reset();c&&(this.execute(b.getEvent()),b.consume())};mxRubberband.prototype.execute=function(a){var b=new mxRectangle(this.x,this.y,this.width,this.height);this.graph.selectRegion(b,a)}; +mxRubberband.prototype.reset=function(){if(null!=this.div)if(mxClient.IS_SVG&&(!mxClient.IS_IE||10<=document.documentMode)&&this.fadeOut){var a=this.div;mxUtils.setPrefixedStyle(a.style,"transition","all 0.2s linear");a.style.pointerEvents="none";a.style.opacity=0;window.setTimeout(function(){a.parentNode.removeChild(a)},200)}else this.div.parentNode.removeChild(this.div);mxEvent.removeGestureListeners(document,null,this.dragHandler,this.dropHandler);this.dropHandler=this.dragHandler=null;this.currentY= +this.currentX=0;this.div=this.first=null};mxRubberband.prototype.update=function(a,b){this.currentX=a;this.currentY=b;this.repaint()}; +mxRubberband.prototype.repaint=function(){if(null!=this.div){var a=this.currentX-this.graph.panDx,b=this.currentY-this.graph.panDy;this.x=Math.min(this.first.x,a);this.y=Math.min(this.first.y,b);this.width=Math.max(this.first.x,a)-this.x;this.height=Math.max(this.first.y,b)-this.y;a=mxClient.IS_VML?this.graph.panDy:0;this.div.style.left=this.x+(mxClient.IS_VML?this.graph.panDx:0)+"px";this.div.style.top=this.y+a+"px";this.div.style.width=Math.max(1,this.width)+"px";this.div.style.height=Math.max(1, +this.height)+"px"}};mxRubberband.prototype.destroy=function(){this.destroyed||(this.destroyed=!0,this.graph.removeMouseListener(this),this.graph.removeListener(this.forceRubberbandHandler),this.graph.removeListener(this.panHandler),this.reset(),null!=this.sharedDiv&&(this.sharedDiv=null))};function mxHandle(a,b,c){this.graph=a.view.graph;this.state=a;this.cursor=null!=b?b:this.cursor;this.image=null!=c?c:this.image;this.init()}mxHandle.prototype.cursor="default";mxHandle.prototype.image=null; +mxHandle.prototype.ignoreGrid=!1;mxHandle.prototype.getPosition=function(a){};mxHandle.prototype.setPosition=function(a,b,c){};mxHandle.prototype.execute=function(){};mxHandle.prototype.copyStyle=function(a){this.graph.setCellStyles(a,this.state.style[a],[this.state.cell])}; +mxHandle.prototype.processEvent=function(a){var b=this.graph.view.scale,c=this.graph.view.translate,c=new mxPoint(a.getGraphX()/b-c.x,a.getGraphY()/b-c.y);null!=this.shape&&null!=this.shape.bounds&&(c.x-=this.shape.bounds.width/b/4,c.y-=this.shape.bounds.height/b/4);var b=-mxUtils.toRadians(this.getRotation()),d=-mxUtils.toRadians(this.getTotalRotation())-b,c=this.flipPoint(this.rotatePoint(this.snapPoint(this.rotatePoint(c,b),this.ignoreGrid||!this.graph.isGridEnabledEvent(a.getEvent())),d));this.setPosition(this.state.getPaintBounds(), +c,a);this.positionChanged();this.redraw()};mxHandle.prototype.positionChanged=function(){null!=this.state.text&&this.state.text.apply(this.state);null!=this.state.shape&&this.state.shape.apply(this.state);this.graph.cellRenderer.redraw(this.state,!0)};mxHandle.prototype.getRotation=function(){return null!=this.state.shape?this.state.shape.getRotation():0};mxHandle.prototype.getTotalRotation=function(){return null!=this.state.shape?this.state.shape.getShapeRotation():0}; +mxHandle.prototype.init=function(){var a=this.isHtmlRequired();null!=this.image?(this.shape=new mxImageShape(new mxRectangle(0,0,this.image.width,this.image.height),this.image.src),this.shape.preserveImageAspect=!1):this.shape=this.createShape(a);this.initShape(a)};mxHandle.prototype.createShape=function(a){a=new mxRectangle(0,0,mxConstants.HANDLE_SIZE,mxConstants.HANDLE_SIZE);return new mxRectangleShape(a,mxConstants.HANDLE_FILLCOLOR,mxConstants.HANDLE_STROKECOLOR)}; +mxHandle.prototype.initShape=function(a){a&&this.shape.isHtmlAllowed()?(this.shape.dialect=mxConstants.DIALECT_STRICTHTML,this.shape.init(this.graph.container)):(this.shape.dialect=this.graph.dialect!=mxConstants.DIALECT_SVG?mxConstants.DIALECT_MIXEDHTML:mxConstants.DIALECT_SVG,null!=this.cursor&&this.shape.init(this.graph.getView().getOverlayPane()));mxEvent.redirectMouseEvents(this.shape.node,this.graph,this.state);this.shape.node.style.cursor=this.cursor}; +mxHandle.prototype.redraw=function(){if(null!=this.shape&&null!=this.state.shape){var a=this.getPosition(this.state.getPaintBounds());if(null!=a){var b=mxUtils.toRadians(this.getTotalRotation()),a=this.rotatePoint(this.flipPoint(a),b),b=this.graph.view.scale,c=this.graph.view.translate;this.shape.bounds.x=Math.floor((a.x+c.x)*b-this.shape.bounds.width/2);this.shape.bounds.y=Math.floor((a.y+c.y)*b-this.shape.bounds.height/2);this.shape.redraw()}}}; +mxHandle.prototype.isHtmlRequired=function(){return null!=this.state.text&&this.state.text.node.parentNode==this.graph.container};mxHandle.prototype.rotatePoint=function(a,b){var c=this.state.getCellBounds(),c=new mxPoint(c.getCenterX(),c.getCenterY());return mxUtils.getRotatedPoint(a,Math.cos(b),Math.sin(b),c)}; +mxHandle.prototype.flipPoint=function(a){if(null!=this.state.shape){var b=this.state.getCellBounds();this.state.shape.flipH&&(a.x=2*b.x+b.width-a.x);this.state.shape.flipV&&(a.y=2*b.y+b.height-a.y)}return a};mxHandle.prototype.snapPoint=function(a,b){b||(a.x=this.graph.snap(a.x),a.y=this.graph.snap(a.y));return a};mxHandle.prototype.setVisible=function(a){null!=this.shape&&null!=this.shape.node&&(this.shape.node.style.display=a?"":"none")}; +mxHandle.prototype.reset=function(){this.setVisible(!0);this.state.style=this.graph.getCellStyle(this.state.cell);this.positionChanged()};mxHandle.prototype.destroy=function(){null!=this.shape&&(this.shape.destroy(),this.shape=null)}; +function mxVertexHandler(a){null!=a&&(this.state=a,this.init(),this.escapeHandler=mxUtils.bind(this,function(a,c){this.livePreview&&null!=this.index&&(this.state.view.graph.cellRenderer.redraw(this.state,!0),this.state.view.invalidate(this.state.cell),this.state.invalid=!1,this.state.view.validate());this.reset()}),this.state.view.graph.addListener(mxEvent.ESCAPE,this.escapeHandler))}mxVertexHandler.prototype.graph=null;mxVertexHandler.prototype.state=null;mxVertexHandler.prototype.singleSizer=!1; +mxVertexHandler.prototype.index=null;mxVertexHandler.prototype.allowHandleBoundsCheck=!0;mxVertexHandler.prototype.handleImage=null;mxVertexHandler.prototype.tolerance=0;mxVertexHandler.prototype.rotationEnabled=!1;mxVertexHandler.prototype.parentHighlightEnabled=!1;mxVertexHandler.prototype.rotationRaster=!0;mxVertexHandler.prototype.rotationCursor="crosshair";mxVertexHandler.prototype.livePreview=!1;mxVertexHandler.prototype.manageSizers=!1;mxVertexHandler.prototype.constrainGroupByChildren=!1; +mxVertexHandler.prototype.rotationHandleVSpacing=-16;mxVertexHandler.prototype.horizontalOffset=0;mxVertexHandler.prototype.verticalOffset=0; +mxVertexHandler.prototype.init=function(){this.graph=this.state.view.graph;this.selectionBounds=this.getSelectionBounds(this.state);this.bounds=new mxRectangle(this.selectionBounds.x,this.selectionBounds.y,this.selectionBounds.width,this.selectionBounds.height);this.selectionBorder=this.createSelectionShape(this.bounds);this.selectionBorder.dialect=this.graph.dialect!=mxConstants.DIALECT_SVG?mxConstants.DIALECT_VML:mxConstants.DIALECT_SVG;this.selectionBorder.pointerEvents=!1;this.selectionBorder.rotation= +Number(this.state.style[mxConstants.STYLE_ROTATION]||"0");this.selectionBorder.init(this.graph.getView().getOverlayPane());mxEvent.redirectMouseEvents(this.selectionBorder.node,this.graph,this.state);this.graph.isCellMovable(this.state.cell)&&this.selectionBorder.setCursor(mxConstants.CURSOR_MOVABLE_VERTEX);if(0>=mxGraphHandler.prototype.maxCells||this.graph.getSelectionCount()this.state.width&&2>this.state.height&&(this.labelShape=this.createSizer(mxConstants.CURSOR_MOVABLE_VERTEX,mxEvent.LABEL_HANDLE, +null,mxConstants.LABEL_HANDLE_FILLCOLOR),this.sizers.push(this.labelShape))}this.isRotationHandleVisible()&&(this.rotationShape=this.createSizer(this.rotationCursor,mxEvent.ROTATION_HANDLE,mxConstants.HANDLE_SIZE+3,mxConstants.HANDLE_FILLCOLOR),this.sizers.push(this.rotationShape));this.customHandles=this.createCustomHandles();this.redraw();this.constrainGroupByChildren&&this.updateMinBounds()}; +mxVertexHandler.prototype.isRotationHandleVisible=function(){return this.graph.isEnabled()&&this.rotationEnabled&&this.graph.isCellRotatable(this.state.cell)&&(0>=mxGraphHandler.prototype.maxCells||this.graph.getSelectionCount()this.graph.tolerance||Math.abs(a.getGraphY()-this.startY)>this.graph.tolerance)&&(this.inTolerance=!1)};mxVertexHandler.prototype.updateHint=function(a){};mxVertexHandler.prototype.removeHint=function(){};mxVertexHandler.prototype.roundAngle=function(a){return Math.round(10*a)/10}; +mxVertexHandler.prototype.roundLength=function(a){return Math.round(a)}; +mxVertexHandler.prototype.mouseMove=function(a,b){b.isConsumed()||null==this.index?this.graph.isMouseDown||null==this.getHandleForEvent(b)||b.consume(!1):(this.checkTolerance(b),this.inTolerance||(this.index<=mxEvent.CUSTOM_HANDLE?null!=this.customHandles&&(this.customHandles[mxEvent.CUSTOM_HANDLE-this.index].processEvent(b),this.customHandles[mxEvent.CUSTOM_HANDLE-this.index].active=!0):this.index==mxEvent.LABEL_HANDLE?this.moveLabel(b):this.index==mxEvent.ROTATION_HANDLE?this.rotateVertex(b):this.resizeVertex(b), +this.updateHint(b)),b.consume())};mxVertexHandler.prototype.moveLabel=function(a){var b=new mxPoint(a.getGraphX(),a.getGraphY()),c=this.graph.view.translate,d=this.graph.view.scale;this.graph.isGridEnabledEvent(a.getEvent())&&(b.x=(this.graph.snap(b.x/d-c.x)+c.x)*d,b.y=(this.graph.snap(b.y/d-c.y)+c.y)*d);this.moveSizerTo(this.sizers[null!=this.rotationShape?this.sizers.length-2:this.sizers.length-1],b.x,b.y)}; +mxVertexHandler.prototype.rotateVertex=function(a){var b=new mxPoint(a.getGraphX(),a.getGraphY()),c=this.state.x+this.state.width/2-b.x,d=this.state.y+this.state.height/2-b.y;this.currentAlpha=0!=c?180*Math.atan(d/c)/Math.PI+90:0>d?180:0;0k.x+k.width&&(this.unscaledBounds.width-=this.unscaledBounds.x+this.unscaledBounds.width-k.x-k.width),this.unscaledBounds.y+this.unscaledBounds.height> +k.y+k.height&&(this.unscaledBounds.height-=this.unscaledBounds.y+this.unscaledBounds.height-k.y-k.height)));this.bounds=new mxRectangle((null!=this.parentState?this.parentState.x:e.x*f)+this.unscaledBounds.x*f,(null!=this.parentState?this.parentState.y:e.y*f)+this.unscaledBounds.y*f,this.unscaledBounds.width*f,this.unscaledBounds.height*f);g.relative&&null!=this.parentState&&(this.bounds.x+=this.state.x-this.parentState.x,this.bounds.y+=this.state.y-this.parentState.y);g=Math.cos(c);k=Math.sin(c); +c=new mxPoint(this.bounds.getCenterX(),this.bounds.getCenterY());l=c.x-b.x;d=c.y-b.y;b=g*l-k*d-l;c=k*l+g*d-d;l=this.bounds.x-this.state.x;d=this.bounds.y-this.state.y;e=g*l-k*d;g=k*l+g*d;this.bounds.x+=b;this.bounds.y+=c;this.unscaledBounds.x=this.roundLength(this.unscaledBounds.x+b/f);this.unscaledBounds.y=this.roundLength(this.unscaledBounds.y+c/f);this.unscaledBounds.width=this.roundLength(this.unscaledBounds.width);this.unscaledBounds.height=this.roundLength(this.unscaledBounds.height);this.graph.isCellCollapsed(this.state.cell)|| +0==b&&0==c?this.childOffsetY=this.childOffsetX=0:(this.childOffsetX=this.state.x-this.bounds.x+e,this.childOffsetY=this.state.y-this.bounds.y+g);this.livePreview&&this.updateLivePreview(a);null!=this.preview&&this.drawPreview()}; +mxVertexHandler.prototype.updateLivePreview=function(a){var b=this.graph.view.scale,c=this.graph.view.translate;a=this.state.clone();this.state.x=this.bounds.x;this.state.y=this.bounds.y;this.state.origin=new mxPoint(this.state.x/b-c.x,this.state.y/b-c.y);this.state.width=this.bounds.width;this.state.height=this.bounds.height;this.state.unscaledWidth=null;b=this.state.absoluteOffset;new mxPoint(b.x,b.y);this.state.absoluteOffset.x=0;this.state.absoluteOffset.y=0;b=this.graph.getCellGeometry(this.state.cell); +null!=b&&(c=b.offset||this.EMPTY_POINT,null==c||b.relative||(this.state.absoluteOffset.x=this.state.view.scale*c.x,this.state.absoluteOffset.y=this.state.view.scale*c.y),this.state.view.updateVertexLabelOffset(this.state));this.state.view.graph.cellRenderer.redraw(this.state,!0);this.state.view.invalidate(this.state.cell);this.state.invalid=!1;this.state.view.validate();this.redrawHandles();this.state.setState(a)}; +mxVertexHandler.prototype.mouseUp=function(a,b){if(null!=this.index&&null!=this.state){var c=new mxPoint(b.getGraphX(),b.getGraphY());this.graph.getModel().beginUpdate();try{if(this.index<=mxEvent.CUSTOM_HANDLE)null!=this.customHandles&&(this.customHandles[mxEvent.CUSTOM_HANDLE-this.index].active=!1,this.customHandles[mxEvent.CUSTOM_HANDLE-this.index].execute());else if(this.index==mxEvent.ROTATION_HANDLE)if(null!=this.currentAlpha){var d=this.currentAlpha-(this.state.style[mxConstants.STYLE_ROTATION]|| +0);0!=d&&this.rotateCell(this.state.cell,d)}else this.rotateClick();else{var e=this.graph.isGridEnabledEvent(b.getEvent()),f=mxUtils.toRadians(this.state.style[mxConstants.STYLE_ROTATION]||"0"),g=Math.cos(-f),k=Math.sin(-f),l=c.x-this.startX,m=c.y-this.startY,c=k*l+g*m,l=g*l-k*m,m=c,n=this.graph.view.scale,p=this.isRecursiveResize(this.state,b);this.resizeCell(this.state.cell,this.roundLength(l/n),this.roundLength(m/n),this.index,e,this.isConstrainedEvent(b),p)}}finally{this.graph.getModel().endUpdate()}b.consume(); +this.reset()}};mxVertexHandler.prototype.isRecursiveResize=function(a,b){return this.graph.isRecursiveResize(this.state)};mxVertexHandler.prototype.rotateClick=function(){}; +mxVertexHandler.prototype.rotateCell=function(a,b,c){if(0!=b){var d=this.graph.getModel();if(d.isVertex(a)||d.isEdge(a)){if(!d.isEdge(a)){var e=this.graph.view.getState(a),e=null!=e?e.style:this.graph.getCellStyle(a);null!=e&&this.graph.setCellStyles(mxConstants.STYLE_ROTATION,(e[mxConstants.STYLE_ROTATION]||0)+b,[a])}e=this.graph.getCellGeometry(a);if(null!=e){var f=this.graph.getCellGeometry(c);null==f||d.isEdge(c)||(e=e.clone(),e.rotate(b,new mxPoint(f.width/2,f.height/2)),d.setGeometry(a,e)); +if(d.isVertex(a)&&!e.relative||d.isEdge(a))for(c=d.getChildCount(a),e=0;ed&&(a+=c,e&&(a=this.graph.snap(a/f)*f));if(0==d||3==d||5==d)p+=b,e&&(p=this.graph.snap(p/f)*f);else if(2==d||4==d||7==d)q+=b,e&&(q=this.graph.snap(q/ +f)*f);e=q-p;c=r-a;k&&(k=this.graph.getCellGeometry(this.state.cell),null!=k&&(k=k.width/k.height,1==d||2==d||7==d||6==d?e=c*k:c=e/k,0==d&&(p=q-e,a=r-c)));l&&(e+=e-m,c+=c-n,p+=t-(p+e/2),a+=u-(a+c/2));0>e&&(p+=e,e=Math.abs(e));0>c&&(a+=c,c=Math.abs(c));d=new mxRectangle(p+g.x*f,a+g.y*f,e,c);null!=this.minBounds&&(d.width=Math.max(d.width,this.minBounds.x*f+this.minBounds.width*f+Math.max(0,this.x0*f-d.x)),d.height=Math.max(d.height,this.minBounds.y*f+this.minBounds.height*f+Math.max(0,this.y0*f-d.y))); +return d};mxVertexHandler.prototype.redraw=function(){this.selectionBounds=this.getSelectionBounds(this.state);this.bounds=new mxRectangle(this.selectionBounds.x,this.selectionBounds.y,this.selectionBounds.width,this.selectionBounds.height);this.redrawHandles();this.drawPreview()}; +mxVertexHandler.prototype.getHandlePadding=function(){var a=new mxPoint(0,0),b=this.tolerance;null!=this.sizers&&0=mxGraphHandler.prototype.maxCells)this.bends=this.createBends(),this.isVirtualBendsEnabled()&&(this.virtualBends=this.createVirtualBends());this.label=new mxPoint(this.state.absoluteOffset.x,this.state.absoluteOffset.y);this.labelShape=this.createLabelHandleShape();this.initBend(this.labelShape);this.labelShape.setCursor(mxConstants.CURSOR_LABEL_HANDLE);this.customHandles=this.createCustomHandles();this.redraw()};mxEdgeHandler.prototype.createCustomHandles=function(){return null}; +mxEdgeHandler.prototype.isVirtualBendsEnabled=function(a){return this.virtualBendsEnabled&&(null==this.state.style[mxConstants.STYLE_EDGE]||this.state.style[mxConstants.STYLE_EDGE]==mxConstants.NONE||1==this.state.style[mxConstants.STYLE_NOEDGESTYLE])&&"arrow"!=mxUtils.getValue(this.state.style,mxConstants.STYLE_SHAPE,null)};mxEdgeHandler.prototype.isAddPointEvent=function(a){return mxEvent.isShiftDown(a)};mxEdgeHandler.prototype.isRemovePointEvent=function(a){return mxEvent.isShiftDown(a)}; +mxEdgeHandler.prototype.getSelectionPoints=function(a){return a.absolutePoints};mxEdgeHandler.prototype.createParentHighlightShape=function(a){a=new mxRectangleShape(a,null,this.getSelectionColor());a.strokewidth=this.getSelectionStrokeWidth();a.isDashed=this.isSelectionDashed();return a};mxEdgeHandler.prototype.createSelectionShape=function(a){a=new this.state.shape.constructor;a.outline=!0;a.apply(this.state);a.isDashed=this.isSelectionDashed();a.stroke=this.getSelectionColor();a.isShadow=!1;return a}; +mxEdgeHandler.prototype.getSelectionColor=function(){return mxConstants.EDGE_SELECTION_COLOR};mxEdgeHandler.prototype.getSelectionStrokeWidth=function(){return mxConstants.EDGE_SELECTION_STROKEWIDTH};mxEdgeHandler.prototype.isSelectionDashed=function(){return mxConstants.EDGE_SELECTION_DASHED};mxEdgeHandler.prototype.isConnectableCell=function(a){return!0};mxEdgeHandler.prototype.getCellAt=function(a,b){return this.outlineConnect?null:this.graph.getCellAt(a,b)}; +mxEdgeHandler.prototype.createMarker=function(){var a=new mxCellMarker(this.graph),b=this;a.getCell=function(a){var c=mxCellMarker.prototype.getCell.apply(this,arguments);c!=b.state.cell&&null!=c||null==b.currentPoint||(c=b.graph.getCellAt(b.currentPoint.x,b.currentPoint.y));if(null!=c&&!this.graph.isCellConnectable(c)){var e=this.graph.getModel().getParent(c);this.graph.getModel().isVertex(e)&&this.graph.isCellConnectable(e)&&(c=e)}e=b.graph.getModel();if(this.graph.isSwimlane(c)&&null!=b.currentPoint&& +this.graph.hitsSwimlaneContent(c,b.currentPoint.x,b.currentPoint.y)||!b.isConnectableCell(c)||c==b.state.cell||null!=c&&!b.graph.connectableEdges&&e.isEdge(c)||e.isAncestor(b.state.cell,c))c=null;this.graph.isCellConnectable(c)||(c=null);return c};a.isValidState=function(a){var c=b.graph.getModel(),c=b.graph.view.getTerminalPort(a,b.graph.view.getState(c.getTerminal(b.state.cell,!b.isSource)),!b.isSource),c=null!=c?c.cell:null;b.error=b.validateConnection(b.isSource?a.cell:c,b.isSource?c:a.cell); +return null==b.error};return a};mxEdgeHandler.prototype.validateConnection=function(a,b){return this.graph.getEdgeValidationError(this.state.cell,a,b)}; +mxEdgeHandler.prototype.createBends=function(){for(var a=this.state.cell,b=[],c=0;c +mxEvent.VIRTUAL_HANDLE&&null!=this.customHandles)for(c=0;cmxEvent.VIRTUAL_HANDLE&&(c[this.index-1]=d)}return null!=e?e:c}; +mxEdgeHandler.prototype.isOutlineConnectEvent=function(a){var b=mxUtils.getOffset(this.graph.container),c=a.getEvent(),d=mxEvent.getClientX(c),c=mxEvent.getClientY(c),e=document.documentElement,f=this.currentPoint.x-this.graph.container.scrollLeft+b.x-((window.pageXOffset||e.scrollLeft)-(e.clientLeft||0)),b=this.currentPoint.y-this.graph.container.scrollTop+b.y-((window.pageYOffset||e.scrollTop)-(e.clientTop||0));return this.outlineConnect&&!mxEvent.isShiftDown(a.getEvent())&&(a.isSource(this.marker.highlight.shape)|| +mxEvent.isAltDown(a.getEvent())&&null!=a.getState()||this.marker.highlight.isHighlightAt(d,c)||(f!=d||b!=c)&&null==a.getState()&&this.marker.highlight.isHighlightAt(f,b))}; +mxEdgeHandler.prototype.updatePreviewState=function(a,b,c,d,e){var f=this.isSource?c:this.state.getVisibleTerminalState(!0),g=this.isTarget?c:this.state.getVisibleTerminalState(!1),k=this.graph.getConnectionConstraint(a,f,!0),l=this.graph.getConnectionConstraint(a,g,!1),m=this.constraintHandler.currentConstraint;null==m&&e&&(null!=c?(d.isSource(this.marker.highlight.shape)&&(b=new mxPoint(d.getGraphX(),d.getGraphY())),m=this.graph.getOutlineConstraint(b,c,d),this.constraintHandler.setFocus(d,c,this.isSource), +this.constraintHandler.currentConstraint=m,this.constraintHandler.currentPoint=b):m=new mxConnectionConstraint);if(this.outlineConnect&&null!=this.marker.highlight&&null!=this.marker.highlight.shape){var n=this.graph.view.scale;null!=this.constraintHandler.currentConstraint&&null!=this.constraintHandler.currentFocus?(this.marker.highlight.shape.stroke=e?mxConstants.OUTLINE_HIGHLIGHT_COLOR:"transparent",this.marker.highlight.shape.strokewidth=mxConstants.OUTLINE_HIGHLIGHT_STROKEWIDTH/n/n,this.marker.highlight.repaint()): +this.marker.hasValidState()&&(this.marker.highlight.shape.stroke=this.marker.getValidState()==d.getState()?mxConstants.DEFAULT_VALID_COLOR:"transparent",this.marker.highlight.shape.strokewidth=mxConstants.HIGHLIGHT_STROKEWIDTH/n/n,this.marker.highlight.repaint())}this.isSource?k=m:this.isTarget&&(l=m);if(this.isSource||this.isTarget)null!=m&&null!=m.point?(a.style[this.isSource?mxConstants.STYLE_EXIT_X:mxConstants.STYLE_ENTRY_X]=m.point.x,a.style[this.isSource?mxConstants.STYLE_EXIT_Y:mxConstants.STYLE_ENTRY_Y]= +m.point.y):(delete a.style[this.isSource?mxConstants.STYLE_EXIT_X:mxConstants.STYLE_ENTRY_X],delete a.style[this.isSource?mxConstants.STYLE_EXIT_Y:mxConstants.STYLE_ENTRY_Y]);a.setVisibleTerminalState(f,!0);a.setVisibleTerminalState(g,!1);this.isSource&&null==f||a.view.updateFixedTerminalPoint(a,f,!0,k);this.isTarget&&null==g||a.view.updateFixedTerminalPoint(a,g,!1,l);(this.isSource||this.isTarget)&&null==c&&(a.setAbsoluteTerminalPoint(b,this.isSource),null==this.marker.getMarkedState()&&(this.error= +this.graph.allowDanglingEdges?null:""));a.view.updatePoints(a,this.points,f,g);a.view.updateFloatingTerminalPoints(a,f,g)}; +mxEdgeHandler.prototype.mouseMove=function(a,b){if(null!=this.index&&null!=this.marker){this.currentPoint=this.getPointForEvent(b);this.error=null;!this.graph.isIgnoreTerminalEvent(b.getEvent())&&mxEvent.isShiftDown(b.getEvent())&&null!=this.snapPoint&&(Math.abs(this.snapPoint.x-this.currentPoint.x)mxEvent.VIRTUAL_HANDLE)null!= +this.customHandles&&this.customHandles[mxEvent.CUSTOM_HANDLE-this.index].processEvent(b);else if(this.isLabel)this.label.x=this.currentPoint.x,this.label.y=this.currentPoint.y;else{this.points=this.getPreviewPoints(this.currentPoint,b);var c=this.isSource||this.isTarget?this.getPreviewTerminalState(b):null;if(null!=this.constraintHandler.currentConstraint&&null!=this.constraintHandler.currentFocus&&null!=this.constraintHandler.currentPoint)this.currentPoint=this.constraintHandler.currentPoint.clone(); +else if(this.outlineConnect){var d=this.isSource||this.isTarget?this.isOutlineConnectEvent(b):!1;d?c=this.marker.highlight.state:null!=c&&c!=b.getState()&&null!=this.marker.highlight.shape&&(this.marker.highlight.shape.stroke="transparent",this.marker.highlight.repaint(),c=null)}null!=c&&this.graph.isCellLocked(c.cell)&&(c=null,this.marker.reset());var e=this.clonePreviewState(this.currentPoint,null!=c?c.cell:null);this.updatePreviewState(e,this.currentPoint,c,b,d);this.setPreviewColor(null==this.error? +this.marker.validColor:this.marker.invalidColor);this.abspoints=e.absolutePoints;this.active=!0}this.updateHint(b,this.currentPoint);this.drawPreview();mxEvent.consume(b.getEvent());b.consume()}else mxClient.IS_IE&&null!=this.getHandleForEvent(b)&&b.consume(!1)}; +mxEdgeHandler.prototype.mouseUp=function(a,b){if(null!=this.index&&null!=this.marker){var c=this.state.cell;if(b.getX()!=this.startX||b.getY()!=this.startY){var d=!this.graph.isIgnoreTerminalEvent(b.getEvent())&&this.graph.isCloneEvent(b.getEvent())&&this.cloneEnabled&&this.graph.isCellsCloneable();if(null!=this.error)0mxEvent.VIRTUAL_HANDLE){if(null!=this.customHandles){var e=this.graph.getModel(); +e.beginUpdate();try{this.customHandles[mxEvent.CUSTOM_HANDLE-this.index].execute()}finally{e.endUpdate()}}}else if(this.isLabel)this.moveLabel(this.state,this.label.x,this.label.y);else if(this.isSource||this.isTarget){var f=null;null!=this.constraintHandler.currentConstraint&&null!=this.constraintHandler.currentFocus&&(f=this.constraintHandler.currentFocus.cell);null==f&&this.marker.hasValidState()&&null!=this.marker.highlight&&null!=this.marker.highlight.shape&&"transparent"!=this.marker.highlight.shape.stroke&& +"white"!=this.marker.highlight.shape.stroke&&(f=this.marker.validState.cell);if(null!=f){var e=this.graph.getModel(),g=e.getParent(c);e.beginUpdate();try{if(d){var k=e.getGeometry(c),d=this.graph.cloneCells([c])[0];e.add(g,d,e.getChildCount(g));null!=k&&(k=k.clone(),e.setGeometry(d,k));var l=e.getTerminal(c,!this.isSource);this.graph.connectCell(d,l,!this.isSource);c=d}c=this.connect(c,f,this.isSource,d,b)}finally{e.endUpdate()}}else this.graph.isAllowDanglingEdges()&&(e=this.abspoints[this.isSource? +0:this.abspoints.length-1],e.x=this.roundLength(e.x/this.graph.view.scale-this.graph.view.translate.x),e.y=this.roundLength(e.y/this.graph.view.scale-this.graph.view.translate.y),f=this.graph.getView().getState(this.graph.getModel().getParent(c)),null!=f&&(e.x-=f.origin.x,e.y-=f.origin.y),e.x-=this.graph.panDx/this.graph.view.scale,e.y-=this.graph.panDy/this.graph.view.scale,c=this.changeTerminalPoint(c,e,this.isSource,d))}else this.active?c=this.changePoints(c,this.points,d):(this.graph.getView().invalidate(this.state.cell), +this.graph.getView().validate(this.state.cell))}null!=this.marker&&(this.reset(),c!=this.state.cell&&this.graph.setSelectionCell(c));b.consume()}}; +mxEdgeHandler.prototype.reset=function(){this.active&&this.refresh();this.snapPoint=this.points=this.label=this.index=this.error=null;this.active=this.isTarget=this.isSource=this.isLabel=!1;if(this.livePreview&&null!=this.sizers)for(var a=0;a");this.div.style.visibility="";mxUtils.fit(this.div)}}; +mxTooltipHandler.prototype.destroy=function(){this.destroyed||(this.graph.removeMouseListener(this),mxEvent.release(this.div),null!=this.div&&null!=this.div.parentNode&&this.div.parentNode.removeChild(this.div),this.destroyed=!0,this.div=null)};function mxCellTracker(a,b,c){mxCellMarker.call(this,a,b);this.graph.addMouseListener(this);null!=c&&(this.getCell=c);mxClient.IS_IE&&mxEvent.addListener(window,"unload",mxUtils.bind(this,function(){this.destroy()}))}mxUtils.extend(mxCellTracker,mxCellMarker); +mxCellTracker.prototype.mouseDown=function(a,b){};mxCellTracker.prototype.mouseMove=function(a,b){this.isEnabled()&&this.process(b)};mxCellTracker.prototype.mouseUp=function(a,b){};mxCellTracker.prototype.destroy=function(){this.destroyed||(this.destroyed=!0,this.graph.removeMouseListener(this),mxCellMarker.prototype.destroy.apply(this))}; +function mxCellHighlight(a,b,c,d){null!=a&&(this.graph=a,this.highlightColor=null!=b?b:mxConstants.DEFAULT_VALID_COLOR,this.strokeWidth=null!=c?c:mxConstants.HIGHLIGHT_STROKEWIDTH,this.dashed=null!=d?d:!1,this.opacity=mxConstants.HIGHLIGHT_OPACITY,this.repaintHandler=mxUtils.bind(this,function(){if(null!=this.state){var a=this.graph.view.getState(this.state.cell);null==a?this.hide():(this.state=a,this.repaint())}}),this.graph.getView().addListener(mxEvent.SCALE,this.repaintHandler),this.graph.getView().addListener(mxEvent.TRANSLATE, +this.repaintHandler),this.graph.getView().addListener(mxEvent.SCALE_AND_TRANSLATE,this.repaintHandler),this.graph.getModel().addListener(mxEvent.CHANGE,this.repaintHandler),this.resetHandler=mxUtils.bind(this,function(){this.hide()}),this.graph.getView().addListener(mxEvent.DOWN,this.resetHandler),this.graph.getView().addListener(mxEvent.UP,this.resetHandler))}mxCellHighlight.prototype.keepOnTop=!1;mxCellHighlight.prototype.graph=!0;mxCellHighlight.prototype.state=null; +mxCellHighlight.prototype.spacing=2;mxCellHighlight.prototype.resetHandler=null;mxCellHighlight.prototype.setHighlightColor=function(a){this.highlightColor=a;null!=this.shape&&(this.shape.stroke=a)};mxCellHighlight.prototype.drawHighlight=function(){this.shape=this.createShape();this.repaint();this.keepOnTop||this.shape.node.parentNode.firstChild==this.shape.node||this.shape.node.parentNode.insertBefore(this.shape.node,this.shape.node.parentNode.firstChild)}; +mxCellHighlight.prototype.createShape=function(){var a=this.graph.cellRenderer.createShape(this.state);a.svgStrokeTolerance=this.graph.tolerance;a.points=this.state.absolutePoints;a.apply(this.state);a.stroke=this.highlightColor;a.opacity=this.opacity;a.isDashed=this.dashed;a.isShadow=!1;a.dialect=this.graph.dialect!=mxConstants.DIALECT_SVG?mxConstants.DIALECT_VML:mxConstants.DIALECT_SVG;a.init(this.graph.getView().getOverlayPane());mxEvent.redirectMouseEvents(a.node,this.graph,this.state);this.graph.dialect!= +mxConstants.DIALECT_SVG?a.pointerEvents=!1:a.svgPointerEvents="stroke";return a};mxCellHighlight.prototype.getStrokeWidth=function(a){return this.strokeWidth}; +mxCellHighlight.prototype.repaint=function(){if(null!=this.state&&null!=this.shape){this.shape.scale=this.state.view.scale;this.graph.model.isEdge(this.state.cell)?(this.shape.strokewidth=this.getStrokeWidth(),this.shape.points=this.state.absolutePoints,this.shape.outline=!1):(this.shape.bounds=new mxRectangle(this.state.x-this.spacing,this.state.y-this.spacing,this.state.width+2*this.spacing,this.state.height+2*this.spacing),this.shape.rotation=Number(this.state.style[mxConstants.STYLE_ROTATION]|| +"0"),this.shape.strokewidth=this.getStrokeWidth()/this.state.view.scale,this.shape.outline=!0);null!=this.state.shape&&this.shape.setCursor(this.state.shape.getCursor());if(mxClient.IS_QUIRKS||8==document.documentMode)"transparent"==this.shape.stroke?(this.shape.stroke="white",this.shape.opacity=1):this.shape.opacity=this.opacity;this.shape.redraw()}};mxCellHighlight.prototype.hide=function(){this.highlight(null)}; +mxCellHighlight.prototype.highlight=function(a){this.state!=a&&(null!=this.shape&&(this.shape.destroy(),this.shape=null),this.state=a,null!=this.state&&this.drawHighlight())};mxCellHighlight.prototype.isHighlightAt=function(a,b){var c=!1;if(null!=this.shape&&null!=document.elementFromPoint&&!mxClient.IS_QUIRKS)for(var d=document.elementFromPoint(a,b);null!=d;){if(d==this.shape.node){c=!0;break}d=d.parentNode}return c}; +mxCellHighlight.prototype.destroy=function(){this.graph.getView().removeListener(this.resetHandler);this.graph.getView().removeListener(this.repaintHandler);this.graph.getModel().removeListener(this.repaintHandler);null!=this.shape&&(this.shape.destroy(),this.shape=null)}; +function mxDefaultKeyHandler(a){if(null!=a){this.editor=a;this.handler=new mxKeyHandler(a.graph);var b=this.handler.escape;this.handler.escape=function(c){b.apply(this,arguments);a.hideProperties();a.fireEvent(new mxEventObject(mxEvent.ESCAPE,"event",c))}}}mxDefaultKeyHandler.prototype.editor=null;mxDefaultKeyHandler.prototype.handler=null; +mxDefaultKeyHandler.prototype.bindAction=function(a,b,c){var d=mxUtils.bind(this,function(){this.editor.execute(b)});c?this.handler.bindControlKey(a,d):this.handler.bindKey(a,d)};mxDefaultKeyHandler.prototype.destroy=function(){this.handler.destroy();this.handler=null};function mxDefaultPopupMenu(a){this.config=a}mxDefaultPopupMenu.prototype.imageBasePath=null;mxDefaultPopupMenu.prototype.config=null; +mxDefaultPopupMenu.prototype.createMenu=function(a,b,c,d){if(null!=this.config){var e=this.createConditions(a,c,d);this.addItems(a,b,c,d,e,this.config.firstChild,null)}}; +mxDefaultPopupMenu.prototype.addItems=function(a,b,c,d,e,f,g){for(var k=!1;null!=f;){if("add"==f.nodeName){var l=f.getAttribute("if");if(null==l||e[l]){var l=f.getAttribute("as"),l=mxResources.get(l)||l,m=mxUtils.eval(mxUtils.getTextContent(f)),n=f.getAttribute("action"),p=f.getAttribute("icon"),q=f.getAttribute("iconCls"),r=f.getAttribute("enabled-if"),r=null==r||e[r];k&&(b.addSeparator(g),k=!1);null!=p&&this.imageBasePath&&(p=this.imageBasePath+p);l=this.addAction(b,a,l,p,m,n,c,g,q,r);this.addItems(a, +b,c,d,e,f.firstChild,l)}}else"separator"==f.nodeName&&(k=!0);f=f.nextSibling}};mxDefaultPopupMenu.prototype.addAction=function(a,b,c,d,e,f,g,k,l,m){return a.addItem(c,d,function(a){"function"==typeof e&&e.call(b,b,g,a);null!=f&&b.execute(f,g,a)},k,l,m)}; +mxDefaultPopupMenu.prototype.createConditions=function(a,b,c){var d=a.graph.getModel(),e=d.getChildCount(b),f=[];f.nocell=null==b;f.ncells=1 "+b.convertValueToString(c)+a),c=b.getModel().getParent(c);return this.getRootTitle()+a};mxEditor.prototype.getRootTitle=function(){var a=this.graph.getModel().getRoot();return this.graph.convertValueToString(a)};mxEditor.prototype.undo=function(){this.undoManager.undo()};mxEditor.prototype.redo=function(){this.undoManager.redo()}; +mxEditor.prototype.groupCells=function(){var a=null!=this.groupBorderSize?this.groupBorderSize:this.graph.gridSize;return this.graph.groupCells(this.createGroup(),a)};mxEditor.prototype.createGroup=function(){return this.graph.getModel().cloneCell(this.defaultGroup)};mxEditor.prototype.open=function(a){if(null!=a){var b=mxUtils.load(a).getXml();this.readGraphModel(b.documentElement);this.filename=a;this.fireEvent(new mxEventObject(mxEvent.OPEN,"filename",a))}}; +mxEditor.prototype.readGraphModel=function(a){(new mxCodec(a.ownerDocument)).decode(a,this.graph.getModel());this.resetHistory()};mxEditor.prototype.save=function(a,b){a=a||this.getUrlPost();if(null!=a&&0n&&(c-=c+k-n);n=l.y+l.height;d+m>n&&(d-=d+m-n)}}else null!=k&&(c-=k.x*f,d-=k.y*f)}}g=g.clone();g.x=this.graph.snap(c/f-this.graph.getView().translate.x-this.graph.gridSize/2);g.y=this.graph.snap(d/f-this.graph.getView().translate.y-this.graph.gridSize/2);b.setGeometry(g);null==a&&(a=this.graph.getDefaultParent());this.cycleAttribute(b);this.fireEvent(new mxEventObject(mxEvent.BEFORE_ADD_VERTEX,"vertex",b,"parent",a));e.beginUpdate();try{b=this.graph.addCell(b, +a),null!=b&&(this.graph.constrainChild(b),this.fireEvent(new mxEventObject(mxEvent.ADD_VERTEX,"vertex",b)))}finally{e.endUpdate()}null!=b&&(this.graph.setSelectionCell(b),this.graph.scrollCellToVisible(b),this.fireEvent(new mxEventObject(mxEvent.AFTER_ADD_VERTEX,"vertex",b)));return b}; +mxEditor.prototype.destroy=function(){this.destroyed||(this.destroyed=!0,null!=this.tasks&&this.tasks.destroy(),null!=this.outline&&this.outline.destroy(),null!=this.properties&&this.properties.destroy(),null!=this.keyHandler&&this.keyHandler.destroy(),null!=this.rubberband&&this.rubberband.destroy(),null!=this.toolbar&&this.toolbar.destroy(),null!=this.graph&&this.graph.destroy(),this.templates=this.status=null)}; +var mxCodecRegistry={codecs:[],aliases:[],register:function(a){if(null!=a){var b=a.getName();mxCodecRegistry.codecs[b]=a;var c=mxUtils.getFunctionName(a.template.constructor);c!=b&&mxCodecRegistry.addAlias(c,b)}return a},addAlias:function(a,b){mxCodecRegistry.aliases[a]=b},getCodec:function(a){var b=null;if(null!=a){var b=mxUtils.getFunctionName(a),c=mxCodecRegistry.aliases[b];null!=c&&(b=c);b=mxCodecRegistry.codecs[b];if(null==b)try{b=new mxObjectCodec(new a),mxCodecRegistry.register(b)}catch(d){}}return b}}; +function mxCodec(a){this.document=a||mxUtils.createXmlDocument();this.objects=[]}mxCodec.prototype.document=null;mxCodec.prototype.objects=null;mxCodec.prototype.elements=null;mxCodec.prototype.encodeDefaults=!1;mxCodec.prototype.putObject=function(a,b){return this.objects[a]=b};mxCodec.prototype.getObject=function(a){var b=null;null!=a&&(b=this.objects[a],null==b&&(b=this.lookup(a),null==b&&(a=this.getElementById(a),null!=a&&(b=this.decode(a)))));return b};mxCodec.prototype.lookup=function(a){return null}; +mxCodec.prototype.getElementById=function(a){if(null==this.elements){if(null==this.document.documentElement)throw Error("mxCodec constructor needs document parameter");this.elements={};this.addElement(this.document.documentElement)}return this.elements[a]};mxCodec.prototype.addElement=function(a){if(a.nodeType==mxConstants.NODETYPE_ELEMENT){var b=a.getAttribute("id");null!=b&&null==this.elements[b]&&(this.elements[b]=a)}for(a=a.firstChild;null!=a;)this.addElement(a),a=a.nextSibling}; +mxCodec.prototype.getId=function(a){var b=null;null!=a&&(b=this.reference(a),null==b&&a instanceof mxCell&&(b=a.getId(),null==b&&(b=mxCellPath.create(a),0==b.length&&(b="root"))));return b};mxCodec.prototype.reference=function(a){return null};mxCodec.prototype.encode=function(a){var b=null;if(null!=a&&null!=a.constructor){var c=mxCodecRegistry.getCodec(a.constructor);null!=c?b=c.encode(this,a):mxUtils.isNode(a)?b=mxUtils.importNode(this.document,a,!0):mxLog.warn("mxCodec.encode: No codec for "+mxUtils.getFunctionName(a.constructor))}return b}; +mxCodec.prototype.decode=function(a,b){var c=null;if(null!=a&&a.nodeType==mxConstants.NODETYPE_ELEMENT){c=null;try{c=window[a.nodeName]}catch(d){}c=mxCodecRegistry.getCodec(c);null!=c?c=c.decode(this,a,b):(c=a.cloneNode(!0),c.removeAttribute("as"))}return c};mxCodec.prototype.encodeCell=function(a,b,c){b.appendChild(this.encode(a));if(null==c||c){c=a.getChildCount();for(var d=0;d +function edit_booking(pk){ + var csrf = $('input[name="csrfmiddlewaretoken"]').val(); + $.ajax({ + type: "POST", + url: "/", + data: { "target": pk, "create": 0, "csrfmiddlewaretoken": csrf}, + beforeSend: function(request) { + request.setRequestHeader("X-CSFRToken", csrf); + } + }).done(function(){ + window.location.replace("/wf/"); + }).fail(function(){}) +} + +

Bookings I Own

+ {% for booking in bookings %} +
+
    +
  • id: {{booking.id}}
  • +
  • lab: {{booking.resource.template.lab.lab_user.username}}
  • +
  • resource: {{booking.resource.template.name}}
  • +
  • start: {{booking.start}}
  • +
  • end: {{booking.end}}
  • +
  • purpose: {{booking.purpose}}
  • +
+
+ + +
+
+ {% endfor %} +

Bookings I Collaborate On

+ {% for booking in collab_bookings %} +
+
    +
  • id: {{booking.id}}
  • +
  • lab: {{booking.lab}}
  • +
  • resource: {{booking.resource_name}}
  • +
  • start: {{booking.start}}
  • +
  • end: {{booking.end}}
  • +
  • purpose: {{booking.purpose}}
  • +
+
+ + +
+
+ {% endfor %} +{% endblock %} diff --git a/dashboard/src/templates/account/configuration_list.html b/dashboard/src/templates/account/configuration_list.html new file mode 100644 index 0000000..ee61e97 --- /dev/null +++ b/dashboard/src/templates/account/configuration_list.html @@ -0,0 +1,28 @@ +{% extends "base.html" %} +{% block content %} + + {% for config in configurations %} +
+
    +
  • id: {{config.id}}
  • +
  • name: {{config.name}}
  • +
  • description: {{config.description}}
  • +
+ +
+ {% endfor %} +{% endblock %} diff --git a/dashboard/src/templates/account/details.html b/dashboard/src/templates/account/details.html new file mode 100644 index 0000000..5641064 --- /dev/null +++ b/dashboard/src/templates/account/details.html @@ -0,0 +1,9 @@ +{% extends "base.html" %} +{% load staticfiles %} +{% block content %} +

Account Details

+ + + + +{% endblock content %} diff --git a/dashboard/src/templates/account/image_list.html b/dashboard/src/templates/account/image_list.html new file mode 100644 index 0000000..fb436df --- /dev/null +++ b/dashboard/src/templates/account/image_list.html @@ -0,0 +1,27 @@ +{% extends "base.html" %} +{% block content %} +

Images I Own

+ {% for image in images %} +
+
    +
  • id: {{image.id}}
  • +
  • lab: {{image.from_lab.name}}
  • +
  • name: {{image.name}}
  • +
  • description: {{image.description}}
  • +
  • host profile: {{image.host_type.name}}
  • +
+
+ {% endfor %} +

Public Images

+ {% for image in public_images %} +
+
    +
  • id: {{image.id}}
  • +
  • lab: {{image.from_lab.name}}
  • +
  • name: {{image.name}}
  • +
  • description: {{image.description}}
  • +
  • host profile: {{image.host_type.name}}
  • +
+
+ {% endfor %} +{% endblock %} diff --git a/dashboard/src/templates/account/resource_list.html b/dashboard/src/templates/account/resource_list.html new file mode 100644 index 0000000..482a000 --- /dev/null +++ b/dashboard/src/templates/account/resource_list.html @@ -0,0 +1,28 @@ +{% extends "base.html" %} +{% block content %} + + {% for resource in resources %} +
+
    +
  • id: {{resource.id}}
  • +
  • name: {{resource.name}}
  • +
  • description: {{resource.description}}
  • +
+ +
+ {% endfor %} +{% endblock %} diff --git a/dashboard/src/templates/account/user_list.html b/dashboard/src/templates/account/user_list.html index 58ddda6..e564524 100644 --- a/dashboard/src/templates/account/user_list.html +++ b/dashboard/src/templates/account/user_list.html @@ -47,7 +47,7 @@ + + +{% endblock %} {% block basecontent %}
@@ -54,36 +120,61 @@ @@ -93,14 +184,15 @@
+ {% if title %}

{{ title }}

- - {% bootstrap_messages %} + {% endif %} +
{% bootstrap_messages %}
{% block content %} diff --git a/dashboard/src/templates/booking/booking_calendar.html b/dashboard/src/templates/booking/booking_calendar.html index b60db3c..349cb0a 100644 --- a/dashboard/src/templates/booking/booking_calendar.html +++ b/dashboard/src/templates/booking/booking_calendar.html @@ -4,6 +4,8 @@ {% load bootstrap3 %} {% block extrahead %} + {{ block.super }} + + {% bootstrap_field form.opsys %} {% bootstrap_field form.purpose %} {% bootstrap_field form.installer %} {% bootstrap_field form.scenario %} @@ -95,6 +98,15 @@ {% endbuttons %}
+ {% else %}

Please @@ -132,8 +144,61 @@ var booking_detail_prefix = "{% url 'booking:detail_prefix' %}"; var booking_delete_prefix = "{% url 'booking:delete_prefix' %}"; var user_timezone = "{{ request.user.userprofile.timezone }}" + {% autoescape off %} + var sup_installer_dict = {{ installer_filter }} + var sup_scenario_dict = {{ scenario_filter }} + {% endautoescape %} + + - -

- Resource: - - {{ booking.resource.name }} - -

-

- User: {{ booking.user.username }} -

-

- Start: {{ booking.start }} -

-

- End: {{ booking.end }} -

-

- Purpose: {{ booking.purpose }} -

-

- Operating System: {{ booking.opsys }} -

-

- Installer: {{ booking.installer }} -

-

- Scenario: {{ booking.scenario }} -

-

- Extensions Remaining: {{ booking.ext_count }} -

- -{% if user.is_authenticated %} -{% if user.get_username == booking.user.username %} -

- - Edit Booking - - - Delete Booking - -