//-/////////////////////////////////////////////////////////////////////////////
//-                                                                           //
//-               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             //
//-                                                                           //
//-/////////////////////////////////////////////////////////////////////////////

script#settings-admin-template(type="text/x-template")
  #settings-admin
    h1 Admin
    em(v-if="!authorized") Login to make changes.

    h2 Authentication for Settings & Remote Access
    .pure-form.pure-form-aligned
      .pure-control-group
        label(for="pass1") New Password
        input.password(name="pass1", v-model="password", focus,
          autocomplete="new-password")

      .pure-control-group
        label(for="pass2") Repeat Password
        input.password(name="pass2", v-model="password2", autocomplete="off")
        bbutton(@click="set_password", primary, text="Set",
          :disabled="!authorized")

      .pure-control-group
        label(for="username") Username
        input(name="username", v-model="username")
        bbutton(@click="set_username", primary, text="Set",
          :disabled="!authorized")

    h2 Configuration
    bbutton(primary, :disabled="!authorized", @click="backup",  text="Backup",
      icon="save")
    bbutton(primary, :disabled="!authorized", @click="restore", text="Restore",
      icon="refresh")
    bbutton(primary, :disabled="!authorized", @click="reset",   text="Reset"
      icon="eraser")

    h2 Firmware
    bbutton(primary, @click="check", text="Check")
    bbutton(primary, :disabled="!authorized", @click="upgrade", text="Upgrade",
      icon="cloud-download")
    bbutton(primary, :disabled="!authorized", @click="upload",  text="Upload")

    p
      input(type="checkbox", v-model="autoCheckUpgrade",
        @change="change_auto_check_upgrade")
      label(for="auto-check-upgrade") &nbsp; Automatically check for upgrades

    h2 Debugging
    a(href="/api/log", target="_blank")
      bbutton(primary, icon="file-text-o", text="View Log")
    a(href="/api/bugreport", download)
      bbutton(primary, icon="bug", text="Bug Report")

    h2 Virtual Keyboard
    p
      input(type="checkbox", v-model="enableKeyboard",
        @change="change_enable_keyboard")
      label &nbsp; Enable automatic virtual keyboard on local screen.


    dialog(v-ref:upgrade, header="Upgrade Firmware?", buttons="Cancel Upgrade")
      div(slot="body")
        p
          | Are you sure you want to upgrade the firmware to version
          | {{latestVersion}}?

    dialog.upgrading(v-ref:upgrading, :click-away="false", :buttons="[]",
      header="Firmware upgrading")
      div(slot="body")
        h3 Please wait...
        p Loss of power during an upgrade may damage the controller.
