<div ng-controller="ActiveMQ.BrowseQueueController">
  <div class="row-fluid">
    <div class="span6">
      <input class="search-query span12" type="text" ng-model="gridOptions.filterOptions.filterText"
             placeholder="Filter messages">
    </div>
    <div class="span6">
      <div class="pull-right">
        <form class="form-inline">
          <button class="btn" ng-disabled="!gridOptions.selectedItems.length" ng-show="dlq" ng-click="retryMessages()"
                  hawtio-show object-name="{{workspace.selection.objectName}}" method-name="retryMessage" mode="remove"
                  title="Moves the dead letter queue message back to its original destination so it can be retried" data-placement="bottom">
            <i class="icon-reply"></i> Retry
          </button>
          <button class="btn" ng-disabled="gridOptions.selectedItems.length !== 1" ng-click="resendMessage()"
                  hawtio-show object-name="{{workspace.selection.objectName}}" method-name="sendTextMessage" mode="remove"
                  title="Edit the message to resend it" data-placement="bottom">
           <i class="icon-share-alt"></i> Resend
          </button>

          <button class="btn" ng-disabled="!gridOptions.selectedItems.length" ng-click="moveDialog = true"
                  hawtio-show object-name="{{workspace.selection.objectName}}" method-name="moveMessageTo" mode="remove"
                  title="Move the selected messages to another destination" data-placement="bottom">
            <i class="icon-share-alt"></i> Move
          </button>
          <button class="btn" ng-disabled="!gridOptions.selectedItems.length"
                  ng-click="deleteDialog = true"
                  hawtio-show object-name="{{workspace.selection.objectName}}" method-name="removeMessage" mode="remove"
                  title="Delete the selected messages">
            <i class="icon-remove"></i> Delete
          </button>
          <button class="btn" ng-click="refresh()"
                  hawtio-show object-name="{{workspace.selection.objectName}}" method-name="browse" mode="remove"
                  title="Refreshes the list of messages">
            <i class="icon-refresh"></i>
          </button>
        </form>
      </div>
    </div>
  </div>

  <div class="row-fluid">
    <div class="gridStyle" ng-grid="gridOptions"></div>
  </div>

  <div hawtio-slideout="showMessageDetails" title="{{row.JMSMessageID}}">
    <div class="dialog-body">

      <div class="row-fluid">
        <div class="pull-right">
          <form class="form-horizontal no-bottom-margin">

            <div class="btn-group"
                 hawtio-pager="messages"
                 on-index-change="selectRowIndex"
                 row-index="rowIndex"></div>

            <button class="btn" ng-disabled="!gridOptions.selectedItems.length" ng-click="moveDialog = true"
                    hawtio-show object-name="{{workspace.selection.objectName}}" method-name="moveMessageTo" mode="remove"
                    title="Move the selected messages to another destination" data-placement="bottom">
              <i class="icon-share-alt"></i> Move
            </button>

            <button class="btn btn-danger" ng-disabled="!gridOptions.selectedItems.length"
                    ng-click="deleteDialog = true"
                    hawtio-show object-name="{{workspace.selection.objectName}}" method-name="removeMessage" mode="remove"
                    title="Delete the selected messages">
              <i class="icon-remove"></i> Delete
            </button>

            <button class="btn" ng-click="showMessageDetails = !showMessageDetails" title="Close this dialog">
              <i class="icon-remove"></i> Close
            </button>

          </form>
        </div>
      </div>

      <div class="row-fluid">
        <div class="expandable closed">
          <div title="Headers" class="title">
            <i class="expandable-indicator"></i> Headers & Properties
          </div>
          <div class="expandable-body well">
            <table class="table table-condensed table-striped">
              <thead>
              <tr>
                <th>Header</th>
                <th>Value</th>
              </tr>
              </thead>
              <tbody ng-bind-html-unsafe="row.headerHtml">
              </tbody>
              <!--
                            <tr ng-repeat="(key, value) in row.headers">
                              <td class="property-name">{{key}}</td>
                              <td class="property-value">{{value}}</td>
                            </tr>
              -->
            </table>
          </div>
        </div>
      </div>

      <div class="row-fluid">
        <div>Displaying body as <span ng-bind="row.textMode"></span></div>
        <div hawtio-editor="row.bodyText" read-only="true" mode='mode'></div>
      </div>

    </div>
  </div>

  <div hawtio-confirm-dialog="deleteDialog"
       ok-button-text="Delete"
       on-ok="deleteMessages()">
    <div class="dialog-body">
      <p>You are about to delete
        <ng-pluralize count="gridOptions.selectedItems.length"
                      when="{'1': 'a message!', 'other': '{} messages!'}">
        </ng-pluralize>
      </p>
      <p>This operation cannot be undone so please be careful.</p>
    </div>
  </div>

  <div hawtio-confirm-dialog="moveDialog"
       ok-button-text="Move"
       on-ok="moveMessages()">
    <div class="dialog-body">
      <p>Move
        <ng-pluralize count="gridOptions.selectedItems.length"
                      when="{'1': 'message', 'other': '{} messages'}"></ng-pluralize>
        to: <input type="text" ng-model="queueName" placeholder="Queue name"
                   typeahead="title.unescapeHTML() for title in queueNames($viewValue) | filter:$viewValue" typeahead-editable='true'></p>
      <p>
        You cannot undo this operation.<br>
        Though after the move you can always move the
        <ng-pluralize count="gridOptions.selectedItems.length"
                      when="{'1': 'message', 'other': 'messages'}"></ng-pluralize>
        back again.
      </p>
    </div>
  </div>

</div>

