<template>
  <b-row class="justify-content-center">
    <b-col lg="7" sm="12" xs="12">
      <b-row>
        <b-col cols="12">
          <b-button size="sm" variant="warning" class="restart-app" v-b-modal.restartApp>
            <i class="fa fa-refresh"></i>
            Restart Application
          </b-button>
        </b-col>
      </b-row>
      <b-modal id="restartApp"
             ref="modal"
             title="Restart Application"
             @ok="restartApplication"
             >
      Do you approve restarting the application ?
    </b-modal>
    </b-col>
  </b-row>

  
</template>

<script>
import { mapState, mapActions } from "vuex";
import types from "../store/mutation-types";

export default {
  name: "Settings",

  computed: {
    ...mapState("settings", ["startedRefreshed"])
  },

  methods: {
    ...mapActions("settings", ["restartApplication"])
  },

  watch: {
    startedRefreshed(newValue, oldValue) {
      if (newValue) {
        app.Toasted("Settings", "Application restart started", "success");
        this.$store.commit(
          `${types.settings.namespace}/${
            types.settings.events.startedRefreshed
          }`
        );
      }
    }
  }
};
</script>

<style scoped lang="scss">
@import "../styles/sass/variables";

button.btn {
  &.restart-app {
    color: $white;
  }
}
</style>