<commit_before><!-- 
  Copyright 2018 Flight Lab authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
 -->

<template lang="pug">
main.pb-5
  img.logo(src="../assets/flightlablogo.png")
  h1.mt-0.display-3 Flight Lab
  p.headline.my-3 A simulation & learning experience at Google
  v-dialog(v-model='showDialog', :persistent="true", max-width='400')
    v-btn.my-3(large, slot='activator', color='primary') Let's fly!
    v-card
      v-card-text
        p.title Flight Lab rules
        rules.markdown
        p.title.mt-4 Known issues
        known-issues.ml-4
      v-card-actions
        v-spacer
        v-btn(@click.native='showDialog = false') Cancel
        v-btn(color="primary", to='/user') Agree
  p Powered by Google Flight Lab.
  bug-button
  .calendar-container
    calendar

</template>


<script>
import Rules from '../../docs/rules.md'
import BugButton from '../components/BugButton.vue'
import Calendar from '../components/Calendar.vue'
import KnownIssues from '../components/KnownIssues.vue'

export default {
  components: {Rules, BugButton, Calendar, KnownIssues},
  data(){
    return {
      showDialog: false,
    }
  },
};
</script>


<style scoped>
.logo {
  height: 100px;
}

main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background-image: linear-gradient(rgba(50,50,50,.8), rgba(50,50,50,.8)), url(../assets/bg.jpg);
  background-size: cover;
  background-position: 50% 50%;
  padding: 1em;
}

.calendar-container {
  position: fixed;<commit_msg>add badge reader support<commit_after><!-- 
  Copyright 2018 Flight Lab authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
 -->

<template lang="pug">
main.pb-5
  img.logo(src="../assets/flightlablogo.png")
  h1.mt-0.display-3 Flight Lab
  p.title.my-3 A simulation & learning experience at Google
  p.headline.my-4.warning--text Swipe badge to start!
  v-dialog(v-model='showAuthorizedDialog', :persistent="true", max-width='400')
    v-card
      v-card-text
        p.title Flight Lab rules
        rules.markdown
        p.title.mt-4 Known issues
        known-issues.ml-4
      v-card-actions
        v-spacer
        v-btn(@click.native='showAuthorizedDialog = false') Cancel
        v-btn(color="primary", to='/user') Agree
  v-dialog(v-model='showUnauthorizedDialog', :persistent="true", max-width='400')
    v-card
      v-card-text
        p Unauthorized. Please contact the team to get access.
      v-card-actions
        v-spacer
        v-btn(@click.native='showUnauthorizedDialog = false') Close
  p Powered by Google Flight Lab.
  bug-button
  .calendar-container
    calendar

</template>


<script>
import Rules from '../../docs/rules.md'
import BugButton from '../components/BugButton.vue'
import Calendar from '../components/Calendar.vue'
import KnownIssues from '../components/KnownIssues.vue'

const axios = require("axios");
export default {
  components: {Rules, BugButton, Calendar, KnownIssues},
  data(){
    return {
      showUnauthorizedDialog: false,
      showAuthorizedDialog: false,
    }
  },
  created() {
    this.getBadgeStatus();
    this.interval = setInterval(() => {this.getBadgeStatus()}, 1000);
  },
  beforeDestroy() {
    clearInterval(this.interval);
  },
  methods: {
    getBadgeStatus(){
      axios.get('http://192.168.1.5:8080/config').then((response) => {
        const status = response.data.machines
            .find(machine => machine.name === 'Badger').components
            .find(component => component.name === 'BadgeReader')
            .badger.status;
        this.badgeState = status;
        switch(status) {
          case 'AUTHORIZED':
            this.showAuthorizedDialog = true;
            this.showUnauthorizedDialog = false;
            break;
          case 'UNAUTHORIZED':
            this.showUnauthorizedDialog = true;
            this.showAuthorizedDialog = false;
            break;
          default:
            this.showAuthorizedDialog = false;
            this.showUnauthorizedDialog = false;
        }
      })
      .catch(console.error);
    },
  },
};
</script>


<style scoped>
.logo {
  height: 100px;
}

main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background-image: linear-gradient(rgba(50,50,50,.8), rgba(50,50,50,.8)), url(../assets/bg.jpg);
  background-size: cover;
  background-position: 50% 50%;
  padding: 1em;
}

.calendar-container {
  position: fixed;
{'fraction_non_alphanumeric': 0.12362030905077263, 'fraction_numerical': 0.019683590875643857, 'mean_word_length': 2.9977941176470586, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5286796', 'n_tokens_mistral': 1729, 'n_tokens_neox': 1627, 'n_words': 458}