<commit_before><!--
Copyright (c) 2008,2020 Silicon Labs.

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

    http://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>
  <div id="q-app">
    <q-ajax-bar />
    <router-view />
  </div>
</template>

<script>
import Vue from 'vue'
import { QSpinnerGears } from 'quasar'
const util = require('./util/util.js')

function initLoad(store) {
  store.dispatch('zap/loadInitialData')
  store.dispatch('zap/loadOptions', {
    key: 'defaultResponsePolicy',
    type: 'string',
  })
  store.dispatch('zap/loadOptions', {
    key: 'manufacturerCodes',
    type: 'object',
  })
  store.dispatch('zap/loadSessionKeyValues')

  let promises = []
  promises.push(
    Vue.prototype.$serverGet('/zcl/cluster/all').then((response) => {
      let arg = response.data
      store.dispatch('zap/updateClusters', arg.data)
    })
  )
  promises.push(
    Vue.prototype.$serverGet('/zcl/deviceType/all').then((response) => {
      let arg = response.data
      store.dispatch('zap/updateZclDeviceTypes', arg.data || [])
    })
  )
  promises.push(store.dispatch(`zap/getProjectPackages`))
  return Promise.all(promises)
}

export default {
  name: 'App',
  methods: {
    setThemeMode() {
      const theme = document.documentElement.getAttribute('data-theme')
      if (theme === 'com.silabs.ss.platform.theme.dark') {
        this.$q.dark.set(true)
      } else {
        this.$q.dark.set(false)
      }
    },
  },
  mounted() {
    this.$q.loading.show({
      spinner: QSpinnerGears,
      spinnerColor: 'red-8',
      spinnerSize: 300,
    })

    // Parse the query string into the front end.
    const querystring = require('querystring')
    let search = global.location.search

    if (search[0] === '?') {
      search = search.substring(1)
    }

    let query = querystring.parse(search)
    if (query[`uiMode`]) {
      this.$store.dispatch('zap/setDefaultUiMode', query[`uiMode`])
    }

    if (`embeddedMode` in query) {
      this.$store.dispatch('zap/setEmbeddedMode', query[`embeddedMode`])
    }

    if (query['studioProject']) {
      this.$store.dispatch('zap/setStudioConfigPath', query['studioProject'])
    }

    this.zclDialogTitle = 'ZCL tab!'
    this.zclDialogText = 'Welcome to ZCL tab. This is just a test of a dialog.'
    this.zclDialogFlag = false

    util.observeAttribute('data-theme', () => {
      this.setThemeMode()
    })
<commit_msg>show loading UI when generation is in progress in Studio<commit_after><!--
Copyright (c) 2008,2020 Silicon Labs.

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

    http://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>
  <div id="q-app">
    <q-ajax-bar />
    <router-view />
  </div>
</template>

<script>
import Vue from 'vue'
import { QSpinnerGears } from 'quasar'
const util = require('./util/util.js')

function initLoad(store) {
  store.dispatch('zap/loadInitialData')
  store.dispatch('zap/loadOptions', {
    key: 'defaultResponsePolicy',
    type: 'string',
  })
  store.dispatch('zap/loadOptions', {
    key: 'manufacturerCodes',
    type: 'object',
  })
  store.dispatch('zap/loadSessionKeyValues')

  let promises = []
  promises.push(
    Vue.prototype.$serverGet('/zcl/cluster/all').then((response) => {
      let arg = response.data
      store.dispatch('zap/updateClusters', arg.data)
    })
  )
  promises.push(
    Vue.prototype.$serverGet('/zcl/deviceType/all').then((response) => {
      let arg = response.data
      store.dispatch('zap/updateZclDeviceTypes', arg.data || [])
    })
  )
  promises.push(store.dispatch(`zap/getProjectPackages`))
  return Promise.all(promises)
}

export default {
  name: 'App',
  methods: {
    setThemeMode() {
      const theme = document.documentElement.getAttribute('data-theme')
      if (theme === 'com.silabs.ss.platform.theme.dark') {
        this.$q.dark.set(true)
      } else {
        this.$q.dark.set(false)
      }
    },
    setGenerationInProgress() {
      const pending = document.documentElement.getAttribute(
        'generation-in-progress'
      )
      console.log(`pending: ${pending}`)
      if (pending === 'true') {
        console.log('true')
        this.$q.loading.show({
          spinner: QSpinnerGears,
          messageColor: 'white',
          message: 'Generation in progress...',
          spinnerSize: 300,
        })
      } else {
        console.log('false')
        this.$q.loading.hide()
      }
    },
  },
  mounted() {
    this.$q.loading.show({
      spinner: QSpinnerGears,
      spinnerSize: 300,
    })

    // Parse the query string into the front end.
    const querystring = require('querystring')
    let search = global.location.search

    if (search[0] === '?') {
      search = search.substring(1)
    }

    let query = querystring.parse(search)
    if (query[`uiMode`]) {
      this.$store.dispatch('zap/setDefaultUiMode', query[`uiMode`])
    }

    if (`embeddedMode` in query) {
      this.$store.dispatch('zap/setEmbeddedMode', query[`embeddedMode`])
    }

    if (query['studioProject']) {
      this.$store.dispatch('zap/setStudioConfigPath', query['studioProject'])
    }

    this.zclDialogTitle = 'ZCL tab!'
    this.zclDialogText = 'Welcome to ZCL tab. This is just a test of a dialog.'
    this.zclDialogFlag = false

    util.observeAttribute('data-theme', () => {
      this.setThemeMode()
    })

    util.observeAttribute('generation-in-progress', () => {
      this.setGenerationInProgress()
    })

{'fraction_non_alphanumeric': 0.14104394732666983, 'fraction_numerical': 0.006028875138822783, 'mean_word_length': 3.054019292604502, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, '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': '167314', 'n_tokens_mistral': 2027, 'n_tokens_neox': 1959, 'n_words': 462}