doctype html
html(lang="en")
  head
    meta(charset="utf-8")
    meta(name="viewport", content="width=device-width, initial-scale=1.0")

    title Onefinity CNC - Web interface


    style: include ../static/css/pure-min.css
    style: include ../static/css/side-menu.css

    style: include ../static/css/font-awesome.min.css
    style: include ../static/css/Audiowide.css
    style: include ../static/css/clusterize.css
    style: include ../svelte-components/node_modules/svelte-material-ui/bare.css
    style: include ../../build/http/svelte-components/smui.css
    style: include ../../build/http/svelte-components/style.css
    style: include:stylus ../stylus/style.styl

  body(v-cloak)
    #svelte-dialog-host

    #overlay(v-if="status != 'connected'")
      span {{status}}
    
    #layout
      a#menuLink.menu-link(href="#menu"): span

      #menu
        button.save.pure-button.button-success(:disabled="!modified",
          @click="save") Save

        .pure-menu
          ul.pure-menu-list
            li.pure-menu-heading
              a.pure-menu-link(href="#control") Control

            li.pure-menu-heading
              a.pure-menu-link(href="#macros") Macros

            li.pure-menu-heading
              a.pure-menu-link(href="#settings") Settings

            li.pure-menu-heading
              a.pure-menu-link(href="#motor:0") Motors

            li.pure-menu-item(v-for="motor in config.motors")
              a.pure-menu-link(:href="'#motor:' + $index") Motor {{$index}}

            li.pure-menu-heading
              a.pure-menu-link(href="#tool") Tool

            li.pure-menu-heading
              a.pure-menu-link(href="#io") I/O

            li.pure-menu-heading
              a.pure-menu-link(href="#admin-general") Admin

            li.pure-menu-item
              a.pure-menu-link(href="#admin-general") General

            li.pure-menu-item
              a.pure-menu-link(href="#admin-network") Network

            li.pure-menu-heading
              a.pure-menu-link(href="#cheat-sheet") Cheat Sheet

            li.pure-menu-heading
              a.pure-menu-link(href="#help") Help
              
            button.pure-button.pure-button-primary(@click="showShutdownDialog", style="width: 100%")
              .fa.fa-power-off              

      #main
        .nav-header
          .brand
            img(src="/images/onefinity_logo.png")
            .version
              div  Version: v{{config.full_version}} Beta 2
              div  IP Address: {{config.ip}}
              div  WiFi: {{config.wifiName}}
            a.upgrade-link(v-if="show_upgrade()", href="#admin-general")
                | Upgrade to v{{latestVersion}}
                .fa.fa-exclamation-circle.upgrade-attention(v-if="show_upgrade()")

          .pi-temp-warning
            .fa.fa-thermometer-full(class="error",
              v-if="80 <= state.rpi_temp",
              title="Raspberry Pi temperature too high.")

          .whitespace

          .video(title="Plug camera into USB.\n" +
            "Left click to toggle video size.\n" +
            "Right click to toggle crosshair.", @click="toggle_video",
            @contextmenu="toggle_crosshair", :class="video_size")
            .crosshair(v-if="crosshair")
              .vertical
              .horizontal
              .box
            img(src="/api/video")

          .estop(:class="{active: state.es}")
            estop(@click="estop")

        .content(class="{{currentView}}-view")
          component(:is="currentView + '-view'", :index="index",
            :config="config", :template="template", :state="state", keep-alive)

    message.error-message(:show.sync="errorShow")
      div(slot="header")
        .estop(:class="{active: state.es}"): estop(@click="estop")
        h3 ERROR: {{errorMessage}}

      div(slot="body")
        console

        button.pure-button(@click="block_error_dialog")
          .fa.fa-ban
          | &nbsp;Stop
        label showing errors for
        input(style="width: 50px", v-model="errorTimeout", number)
        label seconds.

      div(slot="footer")
        button.pure-button.pure-button-primary(@click="errorShow = false") Ok

    message(:show.sync="confirmUpgrade")
      h3(slot="header") Upgrade Firmware?
      div(slot="body")
        p
          | Are you sure you want to upgrade the firmware to version
          | {{latestVersion}}?

      div(slot="footer")
        button.pure-button(@click="confirmUpgrade=false") Cancel
        button.pure-button.pure-button-primary(@click="upgrade_confirmed")
          | Upgrade

    message(:show.sync="confirmUpload")
      h3(slot="header") Upload Firmware?
      div(slot="body")
        p Are you sure you want to upload firmware #[em {{firmwareName}}]?

      div(slot="footer")
        button.pure-button(@click="confirmUpload=false") Cancel
        button.pure-button.pure-button-primary(@click="upload_confirmed")
          | Upload

    message(:show.sync="firmwareUpgrading")
      h3(slot="header") Firmware upgrading
      div(slot="body")
        h3 Please wait...
        p This process should take less than 5 minutes.  If it takes longer than this, please restart the controller and try via USB.
      div(slot="footer")

    message(v-if="popupMessages.length", show=true)
      h3(slot="header") GCode message

      div(slot="body")
        ul
          li(v-for="msg in popupMessages", track-by="$index") {{msg}}

      div(slot="footer")
        button.pure-button.button-success(v-if="state.xx != 'HOLDING'",
          @click="close_messages('ok')") OK

        div(v-if="state.xx == 'HOLDING'")
          button.pure-button(@click="close_messages('stop')")
            | Stop
            .fa.fa-stop

          button.pure-button(@click="close_messages('continue')")
            | Continue
            .fa.fa-play

    #templates: include ../../build/templates.pug
    iframe#download-target(style="display:none")


    script: include ../static/js/vue.js
    script: include ../static/js/sockjs.min.js
    script: include ../static/js/clusterize.min.js
    script: include ../static/js/three.min.js
    script: include:browserify ../js/main.js
    script: include ../../build/http/svelte-components/index.js
    script: include ../static/js/ui.js
