<!DOCTYPE html>
<html>
  <head>
    <title>Shell Example</title>
    <link href="https://compose.cachefly.net/stylesheets/megatron.css" rel="stylesheet" type="text/css">
    <script src="https://compose.cachefly.net/javascripts/megatron.js"></script>
    <link rel="stylesheet" href="dist/shell.css">
    <script src="dist/compose-shell.js"></script>
    <style type="text/css">
      body, html {background: white;}
      body {padding: .5em;}
    </style>
    <!--script src="bower_components/webcomponentsjs/webcomponents.js"></script>
    <link rel="import" href="./compose-shell-param.html">
    <link rel="import" href="./compose-shell-button.html">
    <link rel="import" href="./compose-shell.html"-->
  </head>
  <body>
    <!-- Query a MongoDB collection -->
    <compose-shell method="get">
      <input type="hidden" value="blah">
      <compose-shell-param name="find" before="find(" after=")">
        <compose-shell-param name="find[query]" required="true" focus="true" before="{" after="}" type="hash" parser="bson"></compose-shell-param>
        <compose-shell-param name="find[fields]" before=",{" after="}" type="hash" hint="Fields" parser="bson"></compose-shell-param>
      </compose-shell-param>
      <compose-shell-param name="sort" before=".sort({" after="})" type="hash" parser="bson"></compose-shell-param>
      <compose-shell-param name="skip" before=".skip(" after=")" type="number"></compose-shell-param>
      <compose-shell-param name="limit" before=".limit(" after=")" type="number" value="10"></compose-shell-param>
      <compose-shell-param name="explain" type="boolean">.explain()</compose-shell-param>

      <compose-shell-button toggle="find[fields]">fields{}</compose-shell-button>
      <compose-shell-button toggle="sort">sort()</compose-shell-button>
      <compose-shell-button toggle="skip">skip()</compose-shell-button>
      <compose-shell-button toggle="explain">explain()</compose-shell-button>

      <compose-shell-button type="submit">Run</compose-shell-button>
    </compose-shell>
    
    <br>
    
    <!-- Query a MongoDB collection -->
    <compose-shell method="get" action="receive.html">
      <compose-shell-param name="find" required="true" before="find(" after=")">
        <compose-shell-param name="find[query]" before="{" after="}" type="hash" parser="bson" value='{"_id": {"$oid": "4f6f21ed8b1e02ff593bdeb1"}}'></compose-shell-param>
        <compose-shell-param name="find[fields]" before=",{" after="}" type="hash" hint="Fields" parser="bson" value='{"yo": 1}'></compose-shell-param>
      </compose-shell-param>
      <compose-shell-param name="sort" before=".sort({" after="})" type="hash" parser="bson"></compose-shell-param>
      <compose-shell-param name="skip" before=".skip(" after=")" type="number" value="5"></compose-shell-param>
      <compose-shell-param name="limit" before=".limit(" after=")" type="number" value="10"></compose-shell-param>
      <compose-shell-param name="explain" type="boolean" value="1">.explain()</compose-shell-param>

      <compose-shell-button toggle="find[fields]">fields{}</compose-shell-button>
      <compose-shell-button toggle="sort">sort()</compose-shell-button>
      <compose-shell-button toggle="skip">skip()</compose-shell-button>
      <compose-shell-button toggle="explain">explain()</compose-shell-button>

      <compose-shell-button type="submit">Run</compose-shell-button>
    </compose-shell>
    
    <br>

    <!-- Create a MongoDB collection -->
    <compose-shell method="get" on-notify="Megatron.notify">
      <compose-shell-param name="name" required="true" before="createCollection(" placeholder="name" type="string"></compose-shell-param>
      <compose-shell-param name="options[capped]" before=", { capped: true" after="}" optional>
        <compose-shell-param name="options[size]" before=", size: " type="number"></compose-shell-param>
        <compose-shell-param name="options[max]" before=", max: " type="number" dependency="options[size]"></compose-shell-param>
      </compose-shell-param>
      <compose-shell-param type="text">)</compose-shell-param>
      
      <compose-shell-button toggle="options[size]">size</compose-shell-button>
      <compose-shell-button toggle="options[max]">max</compose-shell-button>

      <compose-shell-button type="submit">Create collection</compose-shell-button>
    </compose-shell>

    <br>
    
    <!-- Create a MongoDB index -->
    <compose-shell method="get" action="receive.html">
      <compose-shell-param name="key" required="true" before="ensureIndex({" after="}," type="hash" parser="bson"></compose-shell-param>
      <compose-shell-param name="options" before="{ " after=" })">
        <compose-shell-param name="options[background]" type="boolean" required="true">background: true</compose-shell-param>
        <compose-shell-param name="options[sparse]" before=", " type="boolean">sparse: true</compose-shell-param>
        <compose-shell-param name="options[unique]" before=", " type="boolean">unique: true</compose-shell-param>
        <compose-shell-param name="options[dropDups]" before=", " type="boolean" dependency="options[unique]">dropDups: true</compose-shell-param>
        <compose-shell-param name="options[expireAfterSeconds]" before=", expireAfterSeconds: " type="number"></compose-shell-param>
      </compose-shell-param>
      
      <compose-shell-button toggle="options[sparse]">sparse</compose-shell-button>
      <compose-shell-button toggle="options[unique]">unique</compose-shell-button>
      <compose-shell-button toggle="options[dropDups]">dropDups</compose-shell-button>
      <compose-shell-button toggle="options[expireAfterSeconds]">expireAfterSeconds</compose-shell-button>
      
      <compose-shell-button type="submit">Create index</compose-shell-button>
    </compose-shell>
  </body>
</html>