Blame view
src/pages/School/appVersion.vue
5.78 KB
8233c5dd6
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 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 197 198 199 200 |
<template> <v-container fluid class="body-color"> <!-- SHOW TABLE --> <v-data-table :headers="headers" :items="versionList"> <template slot="items" slot-scope="props"> <tr class="tr"> <td class="text-xs-center td td-row">{{ props.index + 1}}</td> <td class="text-xs-center td td-row">{{ props.item.androidAppVersion}}</td> <td class="text-xs-center td td-row">{{ props.item.iosAppVersion}}</td> <td class="text-xs-center td td-row"> <span> <v-tooltip top> <img slot="activator" style="cursor:pointer; width:20px; height:18px; " @click="editAppVersion(props.item)" src="/static/icon/edit.png" class="mr-3" /> <span>Edit</span> </v-tooltip> </span> </td> </tr> </template> </v-data-table> <!-- EDIT VERSION DILAOG --> <v-dialog v-model="editVerionDilaog" max-width="600px" scrollable> <v-card flat class="card-style pa-2" dark> <v-layout> <v-flex xs12> <label class="title text-xs-center">Edit Version</label> <v-icon size="24" class="right" @click="editVerionDilaog = false">cancel</v-icon> </v-flex> </v-layout> <v-card-text class="hidden-xs-only hidden-sm-only"> <v-form ref="editAppVersionForm" v-model="validEditVersion" lazy-validation> <v-flex xs12> <v-layout> <v-flex xs3 sm4 class="pt-4 subheading"> <label class="right">App Version:</label> </v-flex> <v-flex xs8 sm6 class="ml-3"> <v-text-field placeholder="fill app version" v-model="editedItem.androidAppVersion" required ></v-text-field> </v-flex> </v-layout> </v-flex> <v-flex xs12> <v-layout> <v-flex xs3 sm4 class="pt-4 subheading"> <label class="right">IOS Version:</label> </v-flex> <v-flex xs8 sm6 class="ml-3"> <v-text-field placeholder="fill ios version" v-model="editedItem.iosAppVersion" required ></v-text-field> </v-flex> </v-layout> </v-flex> <v-layout> <v-flex xs12 sm12> <v-card-actions> <v-spacer></v-spacer> <v-btn round dark @click="update" class="add-button">Update</v-btn> <v-spacer></v-spacer> </v-card-actions> </v-flex> </v-layout> </v-form> </v-card-text> </v-card> </v-dialog> <div class="loader" v-if="showLoader"> <v-progress-circular indeterminate color="white"></v-progress-circular> </div> <v-snackbar :timeout="timeout" :top="y === 'top'" :right="x === 'right'" :vertical="mode === 'vertical'" v-model="snackbar" color="success" >{{ text }}</v-snackbar> </v-container> </template> <script> import http from "@/Services/http.js"; import Util from "@/util"; import moment from "moment"; export default { data: () => ({ //SNACKBAR snackbar: false, y: "top", x: "right", color: "", mode: "", timeout: 3000, text: "", headers: [ { text: "No", align: "center", sortable: false, value: "No", }, { text: "Android App Version", value: "", sortable: false, align: "center", }, { text: "IOS App Version", value: "", sortable: false, align: "center", }, { text: "Action", value: "", sortable: false, align: "center" }, ], versionList: [], editedItem: { androidAppVersion: "", iosAppVersion: "", }, editVerionDilaog: false, validEditVersion: true, showLoader: false, }), methods: { editAppVersion(item) { this.editedIndex = this.versionList.indexOf(item); this.editedItem = Object.assign({}, item); this.editVerionDilaog = true; }, getAppVersion() { http() .get("getAppVersion", { headers: { Authorization: "Bearer " + this.schoolToken, }, }) .then((response) => { this.versionList = [response.data.data]; }) .catch((error) => { this.showLoader = false; this.snackbar = true; this.color = "error"; this.text = error.response.data.message; }); }, update() { if (this.$refs.editAppVersionForm.validate()) { let editVersion = { appVersionId: this.editedItem._id, androidAppVersion: this.editedItem.androidAppVersion, iosAppVersion: this.editedItem.iosAppVersion, }; http() .put("/updateAppVersion", editVersion, { headers: { Authorization: "Bearer " + this.schoolToken }, }) .then((response) => { this.snackbar = true; this.color = "success"; this.text = response.data.message; this.getAppVersion(); this.editVerionDilaog = false; }) .catch((error) => { this.snackbar = true; this.color = "error"; this.text = error.response.data.message; }); } }, }, mounted() { this.getAppVersion(); this.role = this.$store.state.role; this.token = this.$store.state.token; this.schoolToken = this.$store.state.schoolToken; }, }; </script> |