//-/////////////////////////////////////////////////////////////////////////////
//-                                                                           //
//-               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#wifi-connect-template(type="text/x-template")
  dialog.wifi-connect(v-ref:dialog, width="1000px", @closed="closed",
    :header="'Connect ' + (net.usb ? 'USB' : 'internal') + ' WiFi'",
    buttons="Cancel")

    div(slot="body")
      table.pure-table.wifi-aps
        tr
          th SSID
          th Channel
          th Rate
          th Signal
          th Security
          th Connect

        tr(v-for="e in net.scan")
          td.ssid {{e.ssid}}
          td.channel {{e.chan}}
          td.rate {{e.rate}}
          td.signal(:title="'Signal strength ' + e.signal")
            .signal-bars
              .bar(v-for="i in [1, 2, 3, 4, 5]",
                :style="{height: i * 4 + 'px'}",
                :class="{active: i < (e.signal + 10) / 20}")

          td.security {{e.security}}
          td.actions
            bbutton(primary, @click="connect(e)", icon="wifi",
              text="Connect")

            bbutton(v-if="e.connection", primary, @click="forget(e)",
              icon="ban", text="Forget")
