SHARE
TWEET

Untitled

a guest Jan 24th, 2020 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <template>
  2.   <div id="app">
  3.     <div id="nav">
  4.       <nav class="navbar navbar-expand-lg  navbar-dark bg-dark">
  5.     <router-link to="/" v-if="authenticated==true">
  6.     <img src="https://i.imgur.com/fppyrbC.png" height="40" width="60"></router-link>
  7.      <router-link v-else to="/pocetna" ><img src="https://i.imgur.com/fppyrbC.png" height="40" width="60"></router-link>
  8.   <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
  9.     <span class="navbar-toggler-icon"></span>
  10.   </button>
  11.   <div class="collapse navbar-collapse" id="navbarSupportedContent">
  12.     <ul class="navbar-nav mr-auto">
  13.       <li class="nav-item active" >
  14.         <div v-if="authenticated">
  15.          <router-link  v-if="tipKorisnika=='Korisnik'" to="/" class="nav-link">Home</router-link>
  16.         <div v-if="tipKorisnika=='Mehaničar'">
  17.           <router-link to="/admin" class="nav-link">Home</router-link>
  18.           </div></div>
  19.       </li>
  20.       <li class="nav-item active">
  21.         <router-link v-if="!authenticated" to="/Prijava" class="nav-link">Prijava</router-link>
  22.         <span v-if="authenticated">
  23.                   <router-link v-if="tipKorisnika=='Korisnik'" class="btn btn-info my-2 my-sm-0 mr-2" to="/stanje">Provjera narudžbe</router-link>
  24.                   <router-link v-if="tipKorisnika=='Mehaničar'" class="btn btn-info my-2 my-sm-0 mr-2" to="/admin">Admin</router-link>
  25.                   <router-link v-if="tipKorisnika=='Mehaničar'" class="btn btn-info my-2 my-sm-0 mr-2" to="/rijeseno">Riješene prijave</router-link>
  26.                   <router-link v-if="tipKorisnika=='Mehaničar'" class="btn btn-info my-2 my-sm-0 mr-2" to="/recenzije">Recenzije</router-link>
  27.                   <div class="btn-group my-2 my-sm-0 mr-2">
  28.   <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  29.     {{ userEmail }}
  30.   </button>
  31.   <div class="dropdown-menu">
  32.     <router-link class="dropdown-item btn btn-info my-2 my-sm-0 mr-2" to="/promjenalozinke">Promjena lozinke</router-link>
  33.     <router-link v-if="tipKorisnika=='Mehaničar'" class="dropdown-item btn btn-info my-2 my-sm-0 mr-2" to="/useradd">Dodavanje korisnika</router-link>
  34.     <div class="dropdown-divider"></div>
  35.     <a @click="logout(); " class="dropdown-item btn btn-danger my-2 my-sm-0 mr-2" href="/" style="color:red;">Logout</a>
  36.   </div>
  37. </div>
  38. </span>
  39.       </li>
  40.       <li class="nav-item active">
  41.         <router-link v-if="!authenticated" to="/Registracija" class="nav-link">Registracija</router-link>
  42.       </li>
  43.     </ul>
  44.   </div>
  45.   <ul class="navbar-nav nav-link ml-auto" style="color: white;">{{tipKorisnika}}</ul>
  46. </nav>
  47.     </div>
  48.     <router-view/>
  49.      <div id="footer" class="text-center mt-5 fixed-bottom" style="background-color: #a6a6a6;">Ovo je footer 2020 | <i class="far fa-copyright"></i> DS Team.</div>
  50.   </div>
  51. </template>
  52.  
  53. <style lang="scss">
  54. #app {
  55.   font-family: 'Avenir', Helvetica, Arial, sans-serif;
  56.   -webkit-font-smoothing: antialiased;
  57.   -moz-osx-font-smoothing: grayscale;
  58.   text-align: center;
  59.   color: #2c3e50;
  60. }
  61. body{
  62.   background-image:url("~@/assets/pozadina.jpeg");
  63.   background-repeat: no-repeat;
  64.   background-attachment: fixed;
  65.   background-size: cover;
  66. }
  67. </style>
  68. <script>
  69. import store from '@/store.js'
  70. import promjenalozinke from '@/components/promjenalozinke.vue'
  71. import useradd from '@/components/useradd.vue'
  72. import stanje from '@/components/stanje.vue'
  73. import admin from '@/views/admin.vue'
  74. import registracija from '@/views/registracija.vue'
  75. import pocetna from '@/components/pocetna.vue'
  76. import recenzije from '@/components/recenzije.vue'
  77. export default {
  78.   data () {
  79.     return store;
  80.   },
  81.   methods: {
  82.     logout() {
  83.      firebase.auth().signOut().then(function() {
  84.      this.$router.push({name: 'pocetna'})
  85.           console.log("Odjavljen!");
  86.         })
  87.     }
  88.  
  89.   },
  90.   mounted(){
  91.     firebase.auth().onAuthStateChanged(user => {
  92.  if (user) {
  93.    this.authenticated=true
  94.    this.userEmail=user.email
  95.  
  96. db.collection("korisnici")
  97.           .doc(this.userEmail)
  98.           .get()
  99.           .then(doc => {
  100.             if (doc.exists) {
  101.               console.log("Document data:", doc.data());
  102.               this.tipKorisnika = doc.data().tipKorisnika;
  103.             if (this.$route.name !== 'home')
  104.           this.$router.push({name: 'home'}).catch(err => console.log(err))
  105.             }
  106.           });
  107.   db.collection("noviobrazac2").orderBy("posted_at").onSnapshot(snapshot => {
  108.         snapshot.docChanges().forEach(change => {
  109.               const data = change.doc.data()
  110.               if (data.email==this.userEmail) {
  111.                 this.stanjepodaci.unshift(change.doc.data())
  112.               }
  113.         });
  114.     });
  115. }
  116.  else {
  117.  this.authenticated=false
  118.  console.log("No user");
  119.  }
  120. });
  121.  
  122.     db.collection("noviobrazac2").orderBy("posted_at").onSnapshot(snapshot => {
  123.         snapshot.docChanges().forEach(change => {
  124.             if (change.type === "added") {
  125.               const data = change.doc.data()
  126.           if(data.status=="odobreno" || data.status=="odbijeno" || data.status=="promjenatermina" || data.status=="nerješeno"){
  127.                 this.korisnickipodaci.unshift(Object.assign({}, data, {
  128.             id: change.doc.id
  129.           }));
  130.  
  131.               }
  132.             if (change.type === "modified") {
  133.               for (let [i, k] of this.korisnickipodaci.entries()) {
  134.                 let counter=0
  135.                 counter++
  136.                 if (k.id == change.doc.id) {
  137.                   k.comment = change.doc.data().comment;
  138.                   k.status=change.doc.data().status;
  139.                   if(k.status=="rijeseno"){
  140.                     this.korisnickipodaci.splice(i, 1)
  141.                   }
  142.                   break;
  143.                 }
  144.               }
  145.       }
  146.         }});
  147.     });
  148.  
  149.  
  150.     db.collection("recenzije2").onSnapshot(snapshot => {
  151.         snapshot.docChanges().forEach(change => {
  152.             if (change.type === "added") {
  153.               const data = change.doc.data()
  154.               this.recenzije.push({
  155.                 id:change.doc.id,
  156.                 email:data.email,
  157.                 ime:data.ime,
  158.                 ocjena:data.star,
  159.                 opis:data.text,
  160.                 komentar:data.komentar,
  161.                 posted_at:data.posted_at
  162.               })
  163.             }
  164.         });
  165.     });
  166.   }
  167. }
  168. $(function () {
  169.   $('[data-toggle="tooltip"]').tooltip()
  170. })
  171. </script>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top