script#admin-general-view-template(type="text/x-template")
  #admin-general
    h2 Firmware
    button.pure-button.pure-button-primary(@click="check") Check
    button.pure-button.pure-button-primary(@click="upgrade") Upgrade via Web
    label.pure-button.pure-button-primary(@click="upload_firmware") Upgrade via File
    form.upload-firmware.file-upload
      input(type="file", accept=".bz2", @change="upload")

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

    h2 Configuration
    button.pure-button.pure-button-primary(@click="backup") Backup

    label.pure-button.pure-button-primary(@click="restore_config") Restore
    form.restore-config.file-upload
      input(type="file", accept=".zip", @change="restore")

    button.pure-button.pure-button-primary(@click="confirmReset = true") Reset    
    message(:show.sync="confirmReset")
      h3(slot="header") Reset to default configuration?
      p(slot="body") Non-network configuration changes will be lost.
      p(slot="body") Select defaults to restore:
      p.reset-variants(slot="body")
        input#tab1(type="radio", name="reset_variant" @click="reset_variant = 'machinist_x35'")
        label(for="tab1", title="Machinist X-35") Machinist X-35 / Original (16x16")

        input#tab2(type="radio", name="reset_variant" @click="reset_variant = 'woodworker_x35'")
        label(for="tab2", title="Woodworker X-35") Woodworker X-35 / Original (32x32")

        input#tab3(type="radio", name="reset_variant" @click="reset_variant = 'woodworker_x50'")
        label(for="tab3", title="Woodworker X-50") Woodworker X-50 / Pro (32x32")

        input#tab4(type="radio", name="reset_variant" @click="reset_variant = 'journeyman_x50'")
        label(for="tab4", title="Journeyman X-50") Journeyman X-50 / Pro (48x32")

        input#tab5(type="radio", name="reset_variant" @click="reset_variant = 'foreman_pro'")
        label(for="tab5", title="Foreman Pro") Foreman Pro (48x48")
      div(slot="footer")
        button.pure-button(@click="confirmReset = false") Cancel
        button.pure-button.pure-button-primary(@click="next") Next
        
    message(:show.sync="z_slider")
      h3(slot="header") Pick your Z Slider Type
      p(slot="body") Non-network configuration changes will be lost.
      p(slot="body") Select defaults to restore:
      p.reset-variants(slot="body")
        input#tab1(type="radio", name="z_slider_variant" @click="z_slider_variant = 'Z-16 Original'")
        label(for="tab1", title="Z-16 Original") Z-16 Original

        input#tab2(type="radio", name="z_slider_variant" @click="z_slider_variant = 'Z-20 Heavy Duty'")
        label(for="tab2", title="Z-20 Heavy Duty") Z-20 Heavy Duty
                
      div(slot="footer")
        button.pure-button(@click="z_slider = false") Cancel
        button.pure-button.pure-button-primary(@click="set_z_slider") Set Z slider
        
    h2 Debugging
    a(href="/api/log", target="_blank")
      button.pure-button.pure-button-primary View Log
    a(href="/api/bugreport")
      button.pure-button.pure-button-primary Bug Report
    
    h2 Date/Time
    p
      strong Current Date/Time: 
      span(v-if="isLoadingTime") Loading...
      span(v-else) {{ get_current_time }}
    
    label
      input(type="checkbox" v-model="config.admin.time_format" @change="change_time_format") 
      |  Use 24-hour format

    .pure-form
      input(id="date" type="date" v-model="selected_date" required)

      input(
          id="hours" 
          type="number" 
          v-model="selected_hours" 
          placeholder="HH" 
          maxlength="2" 
          :min="config.admin.time_format ? 0 : 1" 
          :max="config.admin.time_format ? 23 : 12" 
          style="width:45px" 
          required
      )

      input(
        id="minutes" 
        type="number" 
        v-model="selected_minutes" 
        placeholder="MM" 
        maxlength="2" 
        min="0" 
        max="59" 
        style="width:48px" 
        required
      )
      
      select(:disabled="config.admin.time_format" v-model="selected_meridiem" style="width:65px")
        option(value="AM" selected) AM
        option(value="PM") PM

      button.pure-button.pure-button-primary(@click="change_date_time", style="margin:5px") Update Date/Time 
      
      .tip
        strong Note:
        br
        | Internet connected controllers time is set automatically.
        | Non-internet connected controllers will need to set time manually on every boot up.
