/* * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ define(["dojo/_base/xhr", "dojo/parser", "dojo/query", "dijit/registry", "dojo/_base/connect", "dojo/_base/event", "dojo/json", "qpid/common/properties", "qpid/common/updater", "qpid/common/util", "qpid/common/formatter", "qpid/common/UpdatableStore", "qpid/management/addBinding", "qpid/management/moveCopyMessages", "qpid/management/showMessage", "qpid/management/UserPreferences", "qpid/management/editQueue", "dojo/store/JsonRest", "dojox/grid/EnhancedGrid", "dojo/data/ObjectStore", "dojox/html/entities", "dojox/grid/enhanced/plugins/Pagination", "dojox/grid/enhanced/plugins/IndirectSelection", "dojo/domReady!"], function (xhr, parser, query, registry, connect, event, json, properties, updater, util, formatter, UpdatableStore, addBinding, moveMessages, showMessage, UserPreferences, editQueue, JsonRest, EnhancedGrid, ObjectStore, entities) { function Queue(name, parent, controller) { this.name = name; this.controller = controller; this.modelObj = { type: "queue", name: name, parent: parent }; } Queue.prototype.getQueueName = function() { return this.name; }; Queue.prototype.getVirtualHostName = function() { return this.modelObj.parent.name; }; Queue.prototype.getVirtualHostNodeName = function() { return this.modelObj.parent.parent.name; }; Queue.prototype.getTitle = function() { return "Queue: " + this.name; }; Queue.prototype.open = function(contentPane) { var that = this; this.contentPane = contentPane; xhr.get({url: "showQueue.html", sync: true, load: function(data) { contentPane.containerNode.innerHTML = data; parser.parse(contentPane.containerNode); that.queueUpdater = new QueueUpdater(contentPane.containerNode, that, that.controller); updater.add( that.queueUpdater ); that.queueUpdater.update(); var myStore = new JsonRest({target:"service/message/"+ encodeURIComponent(that.getVirtualHostName()) + "/" + encodeURIComponent(that.getQueueName())}); var messageGridDiv = query(".messages",contentPane.containerNode)[0]; that.dataStore = new ObjectStore({objectStore: myStore}); that.grid = new EnhancedGrid({ store: that.dataStore, autoHeight: 10, keepSelection: true, structure: [ {name:"Size", field:"size", width: "40%"}, {name:"State", field:"state", width: "30%"}, {name:"Arrival", field:"arrivalTime", width: "30%", formatter: function(val) { return UserPreferences.formatDateTime(val, {addOffset: true, appendTimeZone: true}); } } ], plugins: { pagination: { pageSizes: ["10", "25", "50", "100"], description: true, sizeSwitch: true, pageStepper: true, gotoButton: true, maxPageStep: 4, position: "bottom" }, indirectSelection: true } }, messageGridDiv); connect.connect(that.grid, "onRowDblClick", that.grid, function(evt){ var idx = evt.rowIndex, theItem = this.getItem(idx); var id = that.dataStore.getValue(theItem,"id"); showMessage.show({ messageNumber: id, queue: that.getQueueName(), virtualhost: that.getVirtualHostName(), virtualhostnode: that.getVirtualHostNodeName()}); }); var deleteMessagesButton = query(".deleteMessagesButton", contentPane.containerNode)[0]; var deleteWidget = registry.byNode(deleteMessagesButton); connect.connect(deleteWidget, "onClick", function(evt){ event.stop(evt); that.deleteMessages(); }); var clearQueueButton = query(".clearQueueButton", contentPane.containerNode)[0]; var clearQueueWidget = registry.byNode(clearQueueButton); connect.connect(clearQueueWidget, "onClick", function(evt){ event.stop(evt); that.clearQueue(); }); var moveMessagesButton = query(".moveMessagesButton", contentPane.containerNode)[0]; connect.connect(registry.byNode(moveMessagesButton), "onClick", function(evt){ event.stop(evt); that.moveOrCopyMessages({move: true}); }); var copyMessagesButton = query(".copyMessagesButton", contentPane.containerNode)[0]; connect.connect(registry.byNode(copyMessagesButton), "onClick", function(evt){ event.stop(evt); that.moveOrCopyMessages({move: false}); }); var addBindingButton = query(".addBindingButton", contentPane.containerNode)[0]; connect.connect(registry.byNode(addBindingButton), "onClick", function(evt){ event.stop(evt); addBinding.show({ virtualhost: that.getVirtualHostName(), queue: that.getQueueName(), virtualhostnode: that.getVirtualHostNodeName()}); }); var deleteQueueButton = query(".deleteQueueButton", contentPane.containerNode)[0]; connect.connect(registry.byNode(deleteQueueButton), "onClick", function(evt){ event.stop(evt); that.deleteQueue(); }); var editQueueButton = query(".editQueueButton", contentPane.containerNode)[0]; connect.connect(registry.byNode(editQueueButton), "onClick", function(evt){ event.stop(evt); editQueue.show({nodeName:that.modelObj.parent.parent.name, hostName:that.modelObj.parent.name,queueName:that.name}); }); UserPreferences.addListener(that); }}); }; Queue.prototype.deleteMessages = function() { var data = this.grid.selection.getSelected(); if(data.length) { var that = this; if(confirm("Delete " + data.length + " messages?")) { var i, queryParam; for(i = 0; i