Menu.vue 4.73 KB
Newer Older
gick's avatar
gick committed
1
2
<template>
  <v-ons-page modifier="white">
3
    <v-ons-list-title>{{ $t('access') }}</v-ons-list-title>
gick's avatar
gick committed
4
5
6
7
8
9
10
11
12
13
14
15
    <v-ons-list>
      <v-ons-list-item
        v-for="(item, index) in access"
        :key="item.title"
        :modifier="md ? 'nodivider' : ''"
        @click="loadView(index)"
      >
        <div class="left">
          <v-ons-icon fixed-width class="list-item__icon" :icon="item.icon"></v-ons-icon>
        </div>
        <div class="center">{{ item.title }}</div>
      </v-ons-list-item>
gick's avatar
gick committed
16
      <v-ons-list-item @click="logout">{{ $t('logout') }}</v-ons-list-item>
gick's avatar
gick committed
17
      <v-ons-list-item @click="flore">Flore</v-ons-list-item>     
gick's avatar
key    
gick committed
18
      <v-ons-list-item @click="key">Clef</v-ons-list-item>     
gick's avatar
gick committed
19
      <v-ons-list-item @click="settings">Settings</v-ons-list-item>
gick's avatar
gick committed
20
      <v-ons-list-item @click="admin">Admin</v-ons-list-item>
gick's avatar
gick committed
21
      <v-ons-list-item>{{ $t('language') }} &nbsp;
gick's avatar
gick committed
22
23
24
25
26
27
28
29
30
31
32
33
        <select v-model="$i18n.locale">
          <option v-for="(lang, i) in langs" :key="`Lang${i}`" :value="lang">
            {{ lang }}
          </option>
        </select>
      </v-ons-list-item>
    </v-ons-list>
  </v-ons-page>
</template>

<script>
import Admin from "./Admin.vue";
gick's avatar
gick committed
34
import Settings from "./Settings.vue";
gick's avatar
gick committed
35
import Flore from "./Flore.vue"
gick's avatar
key    
gick committed
36
import Key from "./Key.vue"
gick's avatar
gick committed
37
38
export default {
  methods: {
gick's avatar
key    
gick committed
39

gick's avatar
gick committed
40
41
42
43
44
45
46
47
48
49
50
    loadView(index) {
      this.$store.commit("tabbar/set", index + 1);
      this.$store.commit("splitter/toggle");
    },
    loadLink(url) {
      window.open(url, "_blank");
    },
    logout() {
      this.$store.dispatch("user/logout");
         window.location.reload()
    },
gick's avatar
gick committed
51
52
53
54
55
56
57
58
59
60
61
62
63
64
    settings(){
      this.$store.commit("navigator/push", {
              extends: Settings,
              data() {
                return {
                  toolbarInfo: {
                    backLabel: "Home",
                    title: "key"
                  }
                };
              }
            });

    },
gick's avatar
key    
gick committed
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
    key(){
      this.$store.commit("navigator/push", {
              extends: Key,
              data() {
                return {
                  toolbarInfo: {
                    backLabel: "Home",
                    title: "key"
                  }
                };
              }
            });

    },

gick's avatar
gick committed
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
    flore(){
      this.$store.commit("navigator/push", {
              extends: Flore,
              data() {
                return {
                  toolbarInfo: {
                    backLabel: "Home",
                    title: "key"
                  }
                };
              }
            });

    },

gick's avatar
gick committed
95
    admin() {
gick's avatar
gick committed
96
      if(this.isAdmin){
gick's avatar
gick committed
97
      this.$store.commit("navigator/push", {
gick's avatar
gick committed
98
99
100
101
102
103
104
105
106
107
108
109
              extends: Admin,
              data() {
                return {
                  toolbarInfo: {
                    backLabel: "Home",
                    title: "key"
                  }
                };
              }
            });
       return
      }
gick's avatar
gick committed
110
      this.$ons.notification
elplauto's avatar
elplauto committed
111
        .prompt(this.$t('password'), {})
gick's avatar
gick committed
112
        .then(function(response) {
gick's avatar
gick committed
113
          if (response == "kraken") {
gick's avatar
gick committed
114
115
116
117
118
119
120
121
122
123
124
            this.$store.commit("navigator/push", {
              extends: Admin,
              data() {
                return {
                  toolbarInfo: {
                    backLabel: "Home",
                    title: "key"
                  }
                };
              }
            });
gick's avatar
gick committed
125
            this.$store.commit('user/setAdmin',true)
gick's avatar
gick committed
126
127
            this.$store.commit("splitter/toggle");
          } else {
elplauto's avatar
elplauto committed
128
            this.$ons.notification.alert(this.$t('attemptIntrusion'))
gick's avatar
gick committed
129
          }
gick's avatar
gick committed
130
131
    }.bind(this))
  }},
gick's avatar
gick committed
132
133
134
135
  data() {
    return {langs: ['fr', 'en']};
  },
  computed: {
gick's avatar
gick committed
136
137
138
    isAdmin(){
return this.$store.state.user.isAdmin
    },
gick's avatar
gick committed
139
140
141
142
143
144
145
146
147
148
    gamificationMode() {
      return this.$store.state.user.gamificationMode;
    },
    access() {
      var access = [
        {
          title: this.$t('missionMenu'),
          icon: "ion-home"
        },
        {
elplauto's avatar
elplauto committed
149
          title: this.$t('recordsMenu'),
gick's avatar
gick committed
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
          icon: "ion-edit"
        },
        {
          title: "Folia",
          icon: "ion-search"
        }
      ];
      if (this.gamificationMode) {
        var profil = {
          title: this.$t('scoreMenu'),
          icon: "ion-trophy"
        };
        var arboretum = {
          title: this.$t('arboretumMenu'),
          icon: "ion-leaf"
        };
        access.splice(1, 0, profil, arboretum);
      }
      return access;
    }
  }
};
</script>

<style scoped>
.profile-pic {
  width: 100%;
  background-color: #fff;
  border-bottom: 1px solid #ddd;
  color: rgba(0, 0, 0, 0.56);
  padding-bottom: 8px;
}
.page--material .profile-pic {
  background-color: #f6f6f6;
}

.profile-pic > img {
  display: block;
  max-width: 100%;
}
</style>

<style>
.page--material__background.page--white__background {
  background-color: #fff;
}
</style>