//-/////////////////////////////////////////////////////////////////////////////
//-                                                                           //
//-               This file is part of the Buildbotics firmware.              //
//-                                                                           //
//-      Copyright (c) 2015 - 2021, Buildbotics LLC, All rights reserved.     //
//-                                                                           //
//-       This Source describes Open Hardware and is licensed under the       //
//-                               CERN-OHL-S v2.                              //
//-                                                                           //
//-       You may redistribute and modify this Source and make products       //
//-  using it under the terms of the CERN-OHL-S v2 (https:/cern.ch/cern-ohl). //
//-         This Source is distributed WITHOUT ANY EXPRESS OR IMPLIED         //
//-  WARRANTY, INCLUDING OF MERCHANTABILITY, SATISFACTORY QUALITY AND FITNESS //
//-   FOR A PARTICULAR PURPOSE. Please see the CERN-OHL-S v2 for applicable   //
//-                                conditions.                                //
//-                                                                           //
//-              Source location: https://github.com/buildbotics              //
//-                                                                           //
//-    As per CERN-OHL-S v2 section 4, should You produce hardware based on   //
//-  these sources, You must maintain the Source Location clearly visible on  //
//-  the external case of the CNC Controller or other product you make using  //
//-                                this Source.                               //
//-                                                                           //
//-              For more information, email info@buildbotics.com             //
//-                                                                           //
//-/////////////////////////////////////////////////////////////////////////////

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

    title Buildbotics Controller - Web interface

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

    style: include ../static/css/font-awesome.min.css
    style: include ../static/css/Audiowide.css
    style: include ../static/css/codemirror.css
    style: include:stylus ../stylus/style.styl


  body(v-cloak)
    #overlay(v-if="status != 'connected'")
      span {{status}}
    #layout(:class="'view-' + currentView + '-page'")
      #menuLink.menu-link(href="#menu"): span

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

            li.pure-menu-heading(v-if="$root.webGLSupported")
              a.pure-menu-link(href="#viewer") 3D View

            li.pure-menu-heading
              a.pure-menu-link(href="#editor") Editor

            li.pure-menu-heading
              a.pure-menu-link(href="#camera") Camera

            li.pure-menu-heading
              a.pure-menu-link(href="#files") Files

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

            li.pure-menu-heading
              a.pure-menu-link(href="#docs") Docs

      #main
        .header
          .header-content
            .banner
              img(src="/images/buildbotics_logo.png")
              .title
                span.left Build
                span.right botics
                .fa.fa-thermometer-full(class="error",
                  v-if="80 <= state.rpi_temp",
                  title="Raspberry Pi temperature too high.")
              .subtitle
                | CNC Controller #[b {{state.demo ? 'Demo ' : ''}}]
                | v{{config.version}}
                a.upgrade-version(v-if="show_upgrade", href="#settings:admin")
                  | Upgrade to v{{latestVersion}}
                .fa.fa-check(v-if="!show_upgrade && latestVersion",
                  title="Firmware up to date")
                .copyright Copyright © 2015 - 2023, Buildbotics LLC


            .header-tools
              a(href="#camera"): video
              .estop(:class="{active: state.es}"): estop(@click="estop")

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

    file-dialog(v-ref:file-dialog, :locations="state.locations")
    upload-dialog(v-ref:uploader)
    dialog(v-ref:dialog)

    dialog.error-message(v-ref:error-message, width="800px")
      div(slot="header")
        .estop(:class="{active: state.es}"): estop(@click="estop")
        h3 ERROR: {{errorMessage}}

      div(slot="body")
        console

        bbutton(@click="block_error_dialog", icon="ban", text="Stop")
        label showing errors for
        input(style="width: 50px", v-model="errorTimeout", number)
        label seconds.

    dialog(v-show="popupMessages.length", v-ref:popup-messages,
      header="GCode messages", :click-away="false")
      div(slot="body")
        p(v-for="msg in popupMessages", track-by="$index") {{msg}}

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

        div(v-if="state.xx == 'HOLDING'")
          bbutton(@click="close_messages('stop')", icon="stop", text="Stop")
          bbutton(@click="close_messages('continue')", icon="play",
            text="Continue")

    dialog(v-ref:login-dialog, header="Login", icon="question", width="400px",
      buttons="Login")

      div(slot="body")
        .pure-form.pure-form-aligned
          .pure-control-group
            label(for="password") Password
            input.password(name="password", v-model="password", focus,
              @keyup.enter="$refs.loginDialog.close('login')",
              autocomplete="current-password")

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

    script: include ../static/js/jquery-1.11.3.min.js
    script: include ../static/js/vue.js
    script: include ../static/js/sockjs.min.js
    script: include ../static/js/three.min.js
    script: include ../static/js/chart-2.9.3.min.js
    script: include ../static/js/chart.bundle-2.9.3.min.js
    script: include:browserify ../js/main.js
    script: include ../static/js/codemirror.js
    script: include ../static/js/codemirror-javascript.js
    script: include ../static/js/jscolor.min.js
