dashboard.vue 10.4 KB
<template>
  <v-app id="pages-dasboard">
    <v-container fluid grid-list-xl>
      <!-- <v-card flat class="dashCard"> -->
      <v-layout row wrap class="pt-3">
        <!-- ***** Total Students ***** -->
        <v-flex xs12 class="pt-2">
          <v-layout row wrap>
            <v-flex xs12 sm12 lg3 md4>
              <v-card width="90" height="90" class="ml-3 pa-1 white iconCard" dark>
                <img
                  src="/static/schoolIcons/Students.png"
                  class="iconOfDashboard"
                  width="80"
                  alt="Students"
                />
              </v-card>
              <v-card class="pa-3" style="margin-top: -44px;">
                <div class="body-2 grey--text text-xs-right">Students</div>
                <br />
                <h3 class="headline text-xs-right pb-4">{{ students.length }}</h3>
              </v-card>
            </v-flex>
            <!-- ***** Total Parents ***** -->
            <v-flex xs12 sm12 lg3 md4>
              <v-card width="90" height="90" class="ml-3 pa-1 white agentIcon" dark>
                <img
                  src="/static/schoolIcons/Parents.png"
                  width="80"
                  class="iconOfDashboard"
                  alt="Parents"
                />
              </v-card>
              <v-card class="pa-3" style="margin-top: -44px;">
                <div class="body-2 grey--text text-xs-right">Parents</div>
                <br />
                <h3 class="headline text-xs-right pb-4">{{ parents.length }}</h3>
              </v-card>
            </v-flex>
            <!-- ***** Total Teachers***** -->
            <v-flex xs12 sm12 lg3 md4>
              <v-card width="90" height="90" class="ml-3 pa-1 white farmerIcon" dark>
                <img
                  src="/static/schoolIcons/Teachers.png"
                  width="80"
                  class="iconOfDashboard"
                  alt="Teachers"
                />
              </v-card>
              <v-card class="pa-3" style="margin-top: -44px;">
                <div class="body-2 grey--text text-xs-right">Teachers</div>
                <br />
                <h3 class="headline text-xs-right pb-4">{{ teachers.length }}</h3>
              </v-card>
            </v-flex>
            <!-- ***** Total Class***** -->
            <v-flex xs12 sm12 lg3 md4>
              <v-card width="90" height="90" class="ml-3 pa-1 white khasraIcon" dark>
                <img src="/static/schoolIcons/Class.png" width="80" class="iconOfDashboard" alt="class" />
              </v-card>
              <v-card class="pa-3" style="margin-top: -44px;">
                <div class="body-2 grey--text text-xs-right">Class</div>
                <br />
                <h3 class="headline text-xs-right pb-4">{{ classes.length}}</h3>
              </v-card>
            </v-flex>
          </v-layout>
        </v-flex>
      </v-layout>
      <v-card class="pt-4 mt-3" flat>
        <full-calendar
          ref="calendar"
          defaultView="month"
          droppable="false"
          :events="events"
          :config="config"
        ></full-calendar>
      </v-card>
    </v-container>
    <v-dialog v-model="dialog" max-width="500">
      <v-card color="grey lighten-4" flat>
        <v-toolbar dark color="fixcolors">
          <!-- <v-toolbar-title class="white--text">Title</v-toolbar-title> -->
          <v-spacer></v-spacer>
          <v-btn icon @click="dialog= false">
            <v-icon>close</v-icon>
          </v-btn>
        </v-toolbar>
        <v-flex class="py-4">
          <v-list-tile>
            <v-list-tile-action>
              <v-icon>edit</v-icon>
            </v-list-tile-action>
            <v-list-tile-content>
              <v-list-tile-title>{{ selected.title }}</v-list-tile-title>
            </v-list-tile-content>
          </v-list-tile>
          <v-list-tile>
            <v-list-tile-action>
              <v-icon>access_time</v-icon>
            </v-list-tile-action>
            <v-list-tile-content>
              <v-list-tile-title>{{ date(selected.start)}}</v-list-tile-title>
              <!-- <v-list-tile-sub-title>{{ date(selected.end) }}</v-list-tile-sub-title> -->
            </v-list-tile-content>
          </v-list-tile>
        </v-flex>
      </v-card>
    </v-dialog>
    <div class="loader" v-if="showLoader">
      <v-progress-circular indeterminate color="white"></v-progress-circular>
    </div>
  </v-app>
</template>

<script>
import http from "@/Services/http.js";
import Util from "@/util";
import moment from "moment";

export default {
  data() {
    return {
      showLoader: false,
      dialog: false,
      HolidaysList: [],
      EventsList: [],
      events: [],
      config: {
        eventClick: event => {
          this.selected = event;
          this.dialog = true;
        }
      },
      selected: {},
      students: "",
      parents: "",
      teachers: "",
      classes: ""
    };
  },
  mounted() {
    this.token = this.$store.state.token;
    this.getData();
    this.getStudents();
    this.getTeachers();
    this.getParents();
    this.getClasses();
  },
  methods: {
    date: function(date) {
      return moment(date).format("MMMM DD, YYYY  HH:mm:ss");
    },
    refreshEvents() {
      this.$refs.calendar.$emit("refetch-events");
    },
    removeEvent() {
      this.$refs.calendar.$emit("remove-event", this.selected);
      this.selected = {};
    },
    eventSelected(event) {
      this.selected = event;
      console.log("this.selected", this.selected);
    },
    // eventDropStart: function(event) {
    //   event.editable = false;
    // },
    eventCreated(...test) {
      console.log(test);
    },
    getData() {
      this.showLoader = true;
      var token = this.$store.state.token;
      http()
        .get("/getHolidaysList", {
          headers: { Authorization: "Bearer " + token }
        })
        .then(response => {
          this.HolidaysList = response.data.data;
          // this.events = response.data.data;
          this.showLoader = false;
        })
        .catch(err => {
          // console.log("err====>", err);
          this.showLoader = false;
          if (error.response.status === 401) {
            this.$router.replace({ path: "/" });
            this.$store.dispatch("setToken", null);
            this.$store.dispatch("Id", null);
          }
        });
      http()
        .get("/getSchoolEventsList", {
          headers: { Authorization: "Bearer " + token }
        })
        .then(response => {
          this.EventsList = response.data.data;
          let allData = [];
          allData = this.HolidaysList.concat(this.EventsList);
          this.events = allData;
          this.showLoader = false;
        })
        .catch(error => {
          // console.log("err====>", err);
          this.showLoader = false;
          if (error.response.status === 401) {
            this.$router.replace({ path: "/" });
            this.$store.dispatch("setToken", null);
            this.$store.dispatch("Id", null);
          }
        });
    },
    getStudents() {
      http()
        .get("/getStudentsList", {
          headers: { Authorization: "Bearer " + this.token }
        })
        .then(response => {
          this.students = response.data.data;
          this.showLoader = false;
        })
        .catch(err => {
          // console.log("err====>", err);
          this.showLoader = false;
          if (error.response.status === 401) {
            this.$router.replace({ path: "/" });
            this.$store.dispatch("setToken", null);
            this.$store.dispatch("Id", null);
          }
        });
    },
    getParents() {
      http()
        .get("/getParentsList", {
          headers: { Authorization: "Bearer " + this.token }
        })
        .then(response => {
          this.parents = response.data.data;
          this.showLoader = false;
        })
        .catch(err => {
          // console.log("err====>", err);
          this.showLoader = false;
          if (error.response.status === 401) {
            this.$router.replace({ path: "/" });
            this.$store.dispatch("setToken", null);
            this.$store.dispatch("Id", null);
          }
        });
    },
    getTeachers() {
      http()
        .get("/getTeachersList", {
          headers: { Authorization: "Bearer " + this.token }
        })
        .then(response => {
          this.teachers = response.data.data;
          this.showLoader = false;
        })
        .catch(err => {
          // console.log("err====>", err);
          this.showLoader = false;
          if (error.response.status === 401) {
            this.$router.replace({ path: "/" });
            this.$store.dispatch("setToken", null);
            this.$store.dispatch("Id", null);
          }
        });
    },
    getClasses() {
      http()
        .get("/getClassesList", {
          headers: { Authorization: "Bearer " + this.token }
        })
        .then(response => {
          this.classes = response.data.data;
          this.showLoader = false;
        })
        .catch(err => {
          // console.log("err====>", err);
          this.showLoader = false;
          if (error.response.status === 401) {
            this.$router.replace({ path: "/" });
            this.$store.dispatch("setToken", null);
            this.$store.dispatch("Id", null);
          }
        });
    }
    // eventSources() {
    //   const self = this;
    //   return [
    //     {
    //       events(start, end, timezone, callback) {
    //         setTimeout(() => {
    //           callback(self.events.filter(() => Math.random() > 0.5));
    //         }, 1000);
    //       }
    //     }
    //   ];
    // }
  }
};
</script>

<style>
@import "fullcalendar/dist/fullcalendar.css";
.fc button {
  background: grey !important;
  border: none;
  border-radius: 4px;
  color: white;
  padding: 6px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 18px;
  margin: 8px 2px !important;
  cursor: pointer;
  -webkit-transition-duration: 0.4s;
  transition-duration: 0.4s;
  box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
.iconCard {
  position: relative !important;
  border-radius: 4px;
  z-index: 1;
}
.agentIcon {
  position: relative !important;
  border-radius: 4px;
  z-index: 1;
}
.farmerIcon {
  position: relative !important;
  border-radius: 4px;
  z-index: 1;
}
.khasraIcon {
  position: relative !important;
  border-radius: 4px;
  z-index: 1;
}
.maleFarmerIcon {
  position: relative !important;
  border-radius: 4px;
  z-index: 1;
}
</style>