VirtualHost.prototype.open = function()

in broker-plugins/management-http/src/main/java/resources/js/qpid/management/VirtualHost.js [91:259]


        VirtualHost.prototype.open = function (contentPane)
        {
            var that = this;
            this.contentPane = contentPane;

            var containerNode = contentPane.containerNode;
            containerNode.innerHTML = template;
            parser.parse(containerNode)
                .then(function (instances)
                {
                    that.vhostUpdater = new Updater(that);

                    var addQueueButton = query(".addQueueButton", containerNode)[0];
                    registry.byNode(addQueueButton).on("click", function (evt)
                    {
                        addQueue.show(that.management, that.modelObj)
                    });

                    var deleteQueueButton = query(".deleteQueueButton", containerNode)[0];
                    registry.byNode(deleteQueueButton).on("click", function (evt)
                    {
                        that._deleteSelectedItems(that.vhostUpdater.queuesGrid,
                            {type: "queue", parent: that.modelObj},
                            "delete", "queue");
                    });

                    const clearQueueButton = query(".clearQueueButton", containerNode)[0];
                    registry.byNode(clearQueueButton).on("click", function (evt)
                    {
                        that._clearQueues(that.vhostUpdater.queuesGrid);
                    });

                    var addExchangeButton = query(".addExchangeButton", containerNode)[0];
                    registry.byNode(addExchangeButton).on("click", function (evt)
                    {
                        addExchange.show(that.management, that.modelObj);
                    });

                    var deleteExchangeButton = query(".deleteExchangeButton", containerNode)[0];
                    registry.byNode(deleteExchangeButton).on("click", function (evt)
                    {
                        that._deleteSelectedItems(that.vhostUpdater.exchangesGrid,
                            {type: "exchange", parent: that.modelObj},
                            "delete", "exchange");
                    });

                    var closeConnectionButton = query(".closeConnectionButton", containerNode)[0];
                    registry.byNode(closeConnectionButton).on("click", function (evt)
                    {
                        that._deleteSelectedItems(that.vhostUpdater.connectionsGrid,
                            {type: "connection"},
                            "close", "connection");
                    });

                    var addLoggerButtonNode = query(".addVirtualHostLogger", contentPane.containerNode)[0];
                    var addLoggerButton = registry.byNode(addLoggerButtonNode);
                    addLoggerButton.on("click", function (evt)
                    {
                        addLogger.show(that.management, that.modelObj, "VirtualHostLogger");
                    });

                    var deleteLoggerButtonNode = query(".deleteVirtualHostLogger", contentPane.containerNode)[0];
                    var deleteLoggerButton = registry.byNode(deleteLoggerButtonNode);
                    deleteLoggerButton.on("click", function (evt)
                    {
                        that._deleteSelectedItems(that.vhostUpdater.virtualHostLoggersGrid,
                            {type: "virtualhostlogger", parent: that.modelObj},
                            "delete", "virtual host logger");
                    });

                    that.stopButton = registry.byNode(query(".stopButton", containerNode)[0]);
                    that.startButton = registry.byNode(query(".startButton", containerNode)[0]);
                    that.editButton = registry.byNode(query(".editButton", containerNode)[0]);
                    that.downloadButton = registry.byNode(query(".downloadButton", containerNode)[0]);
                    that.downloadButton.on("click", function (e)
                    {
                        var suggestedAttachmentName = encodeURIComponent(that.name + ".json");
                        that.management.download(that.modelObj, {
                            contentDispositionAttachmentFilename: suggestedAttachmentName
                        }, "extractConfig");
                    });

                    that.deleteButton = registry.byNode(query(".deleteButton", containerNode)[0]);
                    that.deleteButton.on("click", function (e)
                    {
                        if (confirm("Deletion of virtual host will delete message data.\n\n"
                            + "Are you sure you want to delete virtual host  '"
                            + entities.encode(String(that.name)) + "'?"))
                        {
                            that.management.remove(that.modelObj)
                                .then(function (result)
                                {
                                    that.destroy();
                                });
                        }
                    });
                    that.startButton.on("click", function (event)
                    {
                        that.startButton.set("disabled", true);
                        that.management.update(that.modelObj, {desiredState: "ACTIVE"})
                            .then();
                    });

                    that.stopButton.on("click", function (event)
                    {
                        if (confirm("Stopping the virtual host will also stop its children. "
                            + "Are you sure you want to stop virtual host '"
                            + entities.encode(String(that.name)) + "'?"))
                        {
                            that.stopButton.set("disabled", true);
                            that.management.update(that.modelObj, {desiredState: "STOPPED"})
                                .then();
                        }
                    });

                    that.editButton.on("click", function (event)
                    {
                        editVirtualHost.show(that.management, that.modelObj);
                    });

                    var addVirtualHostAccessControlProviderButton = registry.byNode(query(
                        ".addVirtualHostAccessControlProvider",
                        contentPane.containerNode)[0]);
                    addVirtualHostAccessControlProviderButton.on("click", function () {
                        require(["qpid/management/addAccessControlProvider"],
                            function (addAccessControlProvider) {
                                addAccessControlProvider.show(that.management, that.modelObj);
                            });
                    });

                    var deleteVirtualHostAccessControlProviderButton = registry.byNode(query(
                        ".deleteVirtualHostAccessControlProvider",
                        contentPane.containerNode)[0]);
                    deleteVirtualHostAccessControlProviderButton.on("click", function () {
                        that._deleteSelectedItems(that.vhostUpdater.virtualHostAccessControlProviderGrid,
                            {
                                type: "virtualhostaccesscontrolprovider",
                                parent: that.modelObj
                            },
                            "delete", "virtual host access control provider");
                    });

                    const addConnectionLimitProviderButton = registry.byNode(
                        query(".addVirtualHostConnectionLimitProvider", contentPane.containerNode)[0]);
                    addConnectionLimitProviderButton.on("click", function () {
                        require(["qpid/management/addConnectionLimitProvider"],
                            function (addConnectionLimitProvider)
                            {
                                addConnectionLimitProvider.show(that.management, that.modelObj);
                            });
                    });

                    const deleteConnectionLimitProviderButton = registry.byNode(
                        query(".deleteVirtualHostConnectionLimitProvider", contentPane.containerNode)[0]);
                    deleteConnectionLimitProviderButton.on("click", function () {
                        that._deleteSelectedItems(that.vhostUpdater.virtualHostConnectionLimitProviderGrid,
                            {
                                type: "virtualhostconnectionlimitprovider",
                                parent: that.modelObj
                            },
                            "delete", "virtual host connection limit provider");
                    });

                    that.vhostUpdater.update(function ()
                    {
                        updater.add(that.vhostUpdater);
                    });
                });
        };