doctype html html ng-app=“browser”

head
  title Redis Browser

  script type="text/javascript" src="#{root_path}js/angular.min.js"
  script type="text/javascript" src="#{root_path}js/ui-bootstrap-tpls-0.2.0.min.js"
  script type="text/javascript" src="#{root_path}js/localStorageModule.js"
  script type="text/javascript" src="#{root_path}js/app.js"
  script type="text/javascript" src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"

  link rel="stylesheet" href="#{root_path}css/bootstrap.min.css"
  link rel="stylesheet" href="#{root_path}css/app.css"
  link rel="stylesheet" href="#{root_path}css/github.css"

  script type="text/javascript"
    == js_env

  script type="text/ng-template" id="nav-tree-item.html"
    span ng-show="key.count > 1"
      button.btn.tree-toggle ng-hide="key.open" ng-click="keyOpen(key)" +
      button.btn.tree-toggle ng-show="key.open" ng-click="keyClose(key)" -
    span ng-show="key.count == 1" - 

    a href="\#{{key.full}}" ng-click="show(key)"
      ' {{ key.name }}
      small ng-show="key.count > 1"
        | ({{ key.count }})

    ul.tree ng-show="key.open"
      li ng-repeat="key in key.children" ng-include="'nav-tree-item.html'"

body ng-controller="BrowserCtrl"
  #http-loader Loading...
  div modal="config.show" close="config.close()" options="config.modalOpts"
    .form-horizontal
      .modal-header
        button.close type="button" ng-click="config.close()" ×
        h4 Configure Redis Connection
      .modal-body
        .control-group
          label.control-label for="config-connection" Connection
          .controls
            select id="config-connection" ng-model="config.connection" ng-options="name as name for (name, opts) in connections" ng-required="required"

      .modal-footer
        span.alert.alert-error.pull-left ng-show="config.error"
          ' {{ config.error }}
        button.btn.btn-success type="submit" ng-click="config.save()" Save

  .navbar.navbar-inverse.navbar-fixed-top
    .navbar-inner
      .container-fluid
        button.btn.btn-navbar type="button" data-toggle="collapse" data-target=".nav-collapse"
          span.icon-bar
          span.icon-bar
        a.brand href="/" Redis Browser

        .nav-collapse.collapse
          p.pull-right
            button.btn.btn-success ng-click="config.open()" Configure
          p.navbar-text.pull-right.connection-info
            ' Connected to
            strong
              ' {{ config.connection }}

  .container-fluid
    .row-fluid
      .span3
        .well.sidebar-nav
          ul.nav.nav-list
            li.nav-header
              ' Keys
              button.btn.btn-mini.pull-right ng-click="fetchKeys()" Reload
          ul.tree
            li ng-repeat="key in keys" ng-include="'nav-tree-item.html'"
      .span9
        h4
          ' {{ key.full }}
          small
          ' {{ key.type }}

        div ng-switch="key.type"
          pre ng-switch-when="string" prettyprint="key.value"

          pre ng-switch-when="json"
            ' {{ key.value | json }}

          div ng-switch-when="set"
            table.table.table-striped.table-bordered.value-list
              tr ng-repeat="e in key.values"
                td ng-switch="e.type"
                  pre ng-switch-when="json"
                    ' {{ e.value | json }}
                  pre ng-switch-default="" prettyprint="e.value"
                    ' {{ e.value }}

          div ng-switch-when="zset"
            table.table.table-striped.table-bordered.value-list
              tr
                th Value
                th.value-zset-score Score
              tr ng-repeat="e in key.values"
                td ng-switch="e.type"
                  pre ng-switch-when="json"
                    ' {{ e.value | json }}
                  pre ng-switch-default="" prettyprint="e.value"
                td
                  ' {{ e.score }}

          div ng-switch-when="hash"

            div ng-show="config.hashView == 'json'"
              div
                button.btn.btn-primary.pull-right ng-click="config.setHashView('table')" Switch to Table view
              pre
                ' {{ key.json | json }}

            div ng-show="config.hashView == 'table'"
              table.table.table-striped.table-bordered.value-list
                tr
                  th Key
                  th
                    ' Value
                    button.btn.btn-primary.pull-right ng-click="config.setHashView('json')" Switch to JSON view
                tr ng-repeat="(k,e) in key.value"
                  td
                    ' {{ k }}
                  td ng-switch="e.type"
                    pre ng-switch-when="json"
                      ' {{ e.value | json }}
                    pre ng-switch-default="" prettyprint="e.value"

          div ng-switch-when="list"
            .alert
              ' Showing
              strong
                ' {{ list.per_page }}
              ' items from
              strong
                ' {{ list.start }}
              ' to
              strong
                ' {{ list.stop }}
              ' out of
              strong
                ' {{ key.length }}
              ' ( {{ list.pages }} pages )

            .row-fluid
              .span8
                pagination boundary-links="true" num-pages="list.pages" current-page="list.current" max-size="list.max"

              .span4
                .dropdown.per-page
                  a.dropdown-toggle
                    | {{ list.per_page }} per page
                  ul.dropdown-menu
                    li ng-repeat="i in [10,20,50,100,200]"
                      a ng-click="setPerPage(i)" {{ i }}

            table.table.table-striped.table-bordered.value-list
              tr
                th.value-list-index Index
                th Value
              tr ng-repeat="e in key.values"
                td
                  ' {{ e.index }}
                td ng-switch="e.type"
                  pre ng-switch-when="json"
                    ' {{ e.value | json }}
                  pre ng-switch-default="" prettyprint="e.value"

            pagination boundary-links="true" num-pages="list.pages" current-page="list.current" max-size="list.max"

          span.alert.alert-success ng-switch-when="empty" Select something on the left

          div ng-switch-default=""
            table.table.table-striped.table-bordered
              tr
                th Keys
                th.keys-search
                  input.input-medium.search-query type="text" ng-model="query" placeholder="Search"
              tr ng-repeat="e in key.values | filter:query"
                td
                  a href="\#{{e.full}}" ng-click="show(e)"
                    ' {{ e.name }}
                td
                  button.btn.btn-danger ng-click="deleteKey(e)" Delete
              tr
                td
                td
                  button.btn.btn-danger ng-click="deleteAll()" Delete ALL

            / span.alert.alert-danger Key not found