<template>
  <f7-page name="specs">
    <f7-navbar :sliding="false" back-link="Back">
      <f7-nav-title sliding>Tech Specs</f7-nav-title>
    </f7-navbar>
    <f7-block style="display: flex; flex-direction: column; align-items: stretch;">
      <div style="display: flex; flex-direction: column; align-items: center;">
        <f7-block-title medium>Details</f7-block-title>
        <f7-list>
          <f7-list-item title="Version" :after="alvinnVersion"></f7-list-item>
        </f7-list>
        <f7-block-title medium>Models</f7-block-title>
        <f7-list style="width: 100%;">
          <f7-list-item :class="otherSettings.mini ? 'unused-model' : ''" title="Thorax" :after="thoraxDetails.version"></f7-list-item>
          <f7-list-item title="Thorax-m" :after="miniThoraxDetails.version"></f7-list-item>
          <f7-list-item :class="otherSettings.mini ? 'unused-model' : ''" title="Abdomen/Pelvis" :after="abdomenDetails.version"></f7-list-item>
          <f7-list-item title="Abd/Pel-m" :after="miniAbdomenDetails.version"></f7-list-item>
          <f7-list-item title="Limbs" :after="limbsDetails.version"></f7-list-item>
          <f7-list-item title="Head/Neck" :after="headneckDetails.version"></f7-list-item>
        </f7-list>
      </div>
    </f7-block>
  </f7-page>
</template>

<style>
  .unused-model {
    opacity: .75;
  }
  .unused-model .item-title {
    color: var(--f7-list-item-after-text-color)
  }
</style>

<script>
  import store from '../js/store'

  export default {
    data () {
      return {
        thoraxDetails: {},
        miniThoraxDetails: {},
        abdomenDetails: {},
        miniAbdomenDetails: {},
        limbsDetails: { "version": "N/A" },
        headneckDetails: { "version": "N/A" },
        alvinnVersion: store().getVersion,
        isCordova: !!window.cordova,
        otherSettings: {}
      }
    },
    setup() {
      return store()
    },
    created () {
      var loadOtherSettings = localStorage.getItem('otherSettings')
      if (loadOtherSettings) this.otherSettings = JSON.parse(loadOtherSettings)
        fetch(`${this.isCordova ? 'https://localhost' : '.'}/models/thorax/descript.json`)
          .then((mod) => { return mod.json() })
          .then((desc) => { this.thoraxDetails = desc })
        fetch(`${this.isCordova ? 'https://localhost' : '.'}/models/thorax-mini/descript.json`)
          .then((mod) => { return mod.json() })
          .then((desc) => { this.miniThoraxDetails = desc })
        fetch(`${this.isCordova ? 'https://localhost' : '.'}/models/abdomen/descript.json`)
          .then((mod) => { return mod.json() })
          .then((desc) => { this.abdomenDetails = desc })
        fetch(`${this.isCordova ? 'https://localhost' : '.'}/models/abdomen-mini/descript.json`)
          .then((mod) => { return mod.json() })
          .then((desc) => { this.miniAbdomenDetails = desc })
    },
    methods: {
    }
  }
</script>