Commit ab4a9d6ee47b672b90b8fc5b393b31cd90b48b63

Authored by Shikha Mishra
1 parent e5699315cd

file name issue solved in syllabus and assignment screen

src/pages/Academic/assignment.vue
1 <template> 1 <template>
2 <v-container fluid class="body-color"> 2 <v-container fluid class="body-color">
3 <!-- ****** EDIT Assignment ****** --> 3 <!-- ****** EDIT Assignment ****** -->
4 <v-dialog v-model="editAssignmentDialog" max-width="400px"> 4 <v-dialog v-model="editAssignmentDialog" max-width="400px">
5 <v-card flat class="card-style pa-2" dark> 5 <v-card flat class="card-style pa-2" dark>
6 <v-layout> 6 <v-layout>
7 <v-flex xs12> 7 <v-flex xs12>
8 <label class="title text-xs-center">Edit Assignment</label> 8 <label class="title text-xs-center">Edit Assignment</label>
9 <v-icon size="24" class="right" @click="editAssignmentDialog = false">cancel</v-icon> 9 <v-icon size="24" class="right" @click="editAssignmentDialog = false">cancel</v-icon>
10 </v-flex> 10 </v-flex>
11 </v-layout> 11 </v-layout>
12 <v-container fluid> 12 <v-container fluid>
13 <v-form ref="formEditAssignment" v-model="validEditAssignment" lazy-validation> 13 <v-form ref="formEditAssignment" v-model="validEditAssignment" lazy-validation>
14 <v-layout> 14 <v-layout>
15 <v-flex xs4 class="pt-4 subheading"> 15 <v-flex xs4 class="pt-4 subheading">
16 <label class="right">Title:</label> 16 <label class="right">Title:</label>
17 </v-flex> 17 </v-flex>
18 <v-flex xs8 class="ml-3"> 18 <v-flex xs8 class="ml-3">
19 <v-text-field v-model="editedItem.title" type="text" :rules="titleRules" required></v-text-field> 19 <v-text-field v-model="editedItem.title" type="text" :rules="titleRules" required></v-text-field>
20 </v-flex> 20 </v-flex>
21 </v-layout> 21 </v-layout>
22 <v-layout> 22 <v-layout>
23 <v-flex xs4 class="pt-4 subheading"> 23 <v-flex xs4 class="pt-4 subheading">
24 <label class="right">Description:</label> 24 <label class="right">Description:</label>
25 </v-flex> 25 </v-flex>
26 <v-flex xs8 class="ml-3"> 26 <v-flex xs8 class="ml-3">
27 <v-text-field 27 <v-text-field
28 v-model="editedItem.description" 28 v-model="editedItem.description"
29 type="text" 29 type="text"
30 :rules="deadlineRules" 30 :rules="deadlineRules"
31 required 31 required
32 ></v-text-field> 32 ></v-text-field>
33 </v-flex> 33 </v-flex>
34 </v-layout> 34 </v-layout>
35 <v-layout> 35 <v-layout>
36 <v-flex xs4 class="pt-4 subheading"> 36 <v-flex xs4 class="pt-4 subheading">
37 <label class="right">Deadline:</label> 37 <label class="right">Deadline:</label>
38 </v-flex> 38 </v-flex>
39 <v-flex xs8 class="ml-3"> 39 <v-flex xs8 class="ml-3">
40 <v-menu 40 <v-menu
41 ref="menu1" 41 ref="menu1"
42 :close-on-content-click="false" 42 :close-on-content-click="false"
43 v-model="menu1" 43 v-model="menu1"
44 :nudge-right="40" 44 :nudge-right="40"
45 :return-value.sync="menu1" 45 :return-value.sync="menu1"
46 lazy 46 lazy
47 transition="scale-transition" 47 transition="scale-transition"
48 offset-y 48 offset-y
49 full-width 49 full-width
50 min-width="290px" 50 min-width="290px"
51 > 51 >
52 <v-text-field 52 <v-text-field
53 slot="activator" 53 slot="activator"
54 v-model="editedItem.deadline" 54 v-model="editedItem.deadline"
55 placeholder="Select Date" 55 placeholder="Select Date"
56 :rules="deadlineRules" 56 :rules="deadlineRules"
57 append-icon="event" 57 append-icon="event"
58 required 58 required
59 ></v-text-field> 59 ></v-text-field>
60 <v-date-picker v-model="editedItem.date" @input="menu1 = false"></v-date-picker> 60 <v-date-picker v-model="editedItem.date" @input="menu1 = false"></v-date-picker>
61 </v-menu> 61 </v-menu>
62 </v-flex> 62 </v-flex>
63 </v-layout> 63 </v-layout>
64 <v-layout> 64 <v-layout>
65 <v-flex xs4 class="pt-4 subheading"> 65 <v-flex xs4 class="pt-4 subheading">
66 <label class="right">Class:</label> 66 <label class="right">Class:</label>
67 </v-flex> 67 </v-flex>
68 <v-flex xs8 class="ml-3"> 68 <v-flex xs8 class="ml-3">
69 <v-select 69 <v-select
70 :items="classList" 70 :items="classList"
71 item-text="classNum" 71 item-text="classNum"
72 item-value="_id" 72 item-value="_id"
73 :rules="classRules" 73 :rules="classRules"
74 v-model="editedItem.classId" 74 v-model="editedItem.classId"
75 @change="getSections(editedItem.classId)" 75 @change="getSections(editedItem.classId)"
76 required 76 required
77 ></v-select> 77 ></v-select>
78 </v-flex> 78 </v-flex>
79 </v-layout> 79 </v-layout>
80 <v-layout> 80 <v-layout>
81 <v-flex xs4 class="pt-4 subheading"> 81 <v-flex xs4 class="pt-4 subheading">
82 <label class="right">Section:</label> 82 <label class="right">Section:</label>
83 </v-flex> 83 </v-flex>
84 <v-flex xs8 class="ml-3"> 84 <v-flex xs8 class="ml-3">
85 <v-select 85 <v-select
86 :items="addSection" 86 :items="addSection"
87 item-text="name" 87 item-text="name"
88 item-value="_id" 88 item-value="_id"
89 v-model="editedItem.sectionId" 89 v-model="editedItem.sectionId"
90 :rules="sectionRules" 90 :rules="sectionRules"
91 @change="getClassSubject(editedItem.classId)" 91 @change="getClassSubject(editedItem.classId)"
92 required 92 required
93 ></v-select> 93 ></v-select>
94 </v-flex> 94 </v-flex>
95 </v-layout> 95 </v-layout>
96 <v-layout> 96 <v-layout>
97 <v-flex xs4 class="pt-4 subheading"> 97 <v-flex xs4 class="pt-4 subheading">
98 <label class="right">Subject</label> 98 <label class="right">Subject</label>
99 </v-flex> 99 </v-flex>
100 <v-flex xs8 class="ml-3"> 100 <v-flex xs8 class="ml-3">
101 <v-select 101 <v-select
102 :items="subjectList.subjects" 102 :items="subjectList.subjects"
103 v-model="editedItem.subjectName" 103 v-model="editedItem.subjectName"
104 item-text="subjectName" 104 item-text="subjectName"
105 item-value="_id" 105 item-value="_id"
106 :rules="subjectRules" 106 :rules="subjectRules"
107 required 107 required
108 ></v-select> 108 ></v-select>
109 </v-flex> 109 </v-flex>
110 </v-layout> 110 </v-layout>
111 <v-layout> 111 <v-layout>
112 <v-flex xs4 class="pt-4 subheading"> 112 <v-flex xs4 class="pt-4 subheading">
113 <label class="right hidden-xs-only hidden-sm-only">Uplaod File:</label> 113 <label class="right hidden-xs-only hidden-sm-only">Uplaod File:</label>
114 <label class="right hidden-lg-only hidden-md-only hidden-xl-only">File :</label> 114 <label class="right hidden-lg-only hidden-md-only hidden-xl-only">File :</label>
115 </v-flex> 115 </v-flex>
116 <v-flex xs8 sm8 class="ml-3"> 116 <v-flex xs8 sm8 class="ml-3">
117 <v-text-field 117 <v-text-field
118 label="Select File" 118 label="Select File"
119 @click="pickFile" 119 @click="pickFile"
120 v-model="imageName" 120 v-model="imageName"
121 append-icon="attach_file" 121 append-icon="attach_file"
122 ></v-text-field> 122 ></v-text-field>
123 <input 123 <input
124 type="file" 124 type="file"
125 style="display:none" 125 style="display:none"
126 ref="image" 126 ref="image"
127 accept="image/*" 127 accept="image/*"
128 @change="onFilePicked" 128 @change="onFilePicked"
129 /> 129 />
130 </v-flex> 130 </v-flex>
131 </v-layout> 131 </v-layout>
132 <v-flex xs12 sm12> 132 <v-flex xs12 sm12>
133 <v-card-actions> 133 <v-card-actions>
134 <v-spacer></v-spacer> 134 <v-spacer></v-spacer>
135 <v-btn round dark @click="save" :loading="editLoading" class="add-button">Save</v-btn> 135 <v-btn round dark @click="save" :loading="editLoading" class="add-button">Save</v-btn>
136 </v-card-actions> 136 </v-card-actions>
137 </v-flex> 137 </v-flex>
138 </v-form> 138 </v-form>
139 </v-container> 139 </v-container>
140 </v-card> 140 </v-card>
141 </v-dialog> 141 </v-dialog>
142 142
143 <!-- ****** VIEW PROFIL NOTICE BOARD ****** --> 143 <!-- ****** VIEW PROFIL NOTICE BOARD ****** -->
144 <v-dialog v-model="viewAssignmentDialog" max-width="500px"> 144 <v-dialog v-model="viewAssignmentDialog" max-width="500px">
145 <v-card flat class="card-style pa-3" dark> 145 <v-card flat class="card-style pa-3" dark>
146 <v-layout> 146 <v-layout>
147 <v-flex xs12> 147 <v-flex xs12>
148 <label class="title text-xs-center">View Attendence</label> 148 <label class="title text-xs-center">View Attendence</label>
149 <v-icon size="24" class="right" @click="viewAssignmentDialog = false">cancel</v-icon> 149 <v-icon size="24" class="right" @click="viewAssignmentDialog = false">cancel</v-icon>
150 </v-flex> 150 </v-flex>
151 </v-layout> 151 </v-layout>
152 <v-card-text> 152 <v-card-text>
153 <v-container grid-list-md> 153 <v-container grid-list-md>
154 <v-layout wrap> 154 <v-layout wrap>
155 <v-flex> 155 <v-flex>
156 <v-layout> 156 <v-layout>
157 <v-flex xs6 sm4> 157 <v-flex xs6 sm4>
158 <h5 class="right my-1"> 158 <h5 class="right my-1">
159 <b>Title:</b> 159 <b>Title:</b>
160 </h5> 160 </h5>
161 </v-flex> 161 </v-flex>
162 <v-flex sm8 xs6> 162 <v-flex sm8 xs6>
163 <h5 class="my-1">{{ editedItem.title }}</h5> 163 <h5 class="my-1">{{ editedItem.title }}</h5>
164 </v-flex> 164 </v-flex>
165 </v-layout> 165 </v-layout>
166 <v-layout> 166 <v-layout>
167 <v-flex xs6 sm4> 167 <v-flex xs6 sm4>
168 <h5 class="right my-1"> 168 <h5 class="right my-1">
169 <b>Description:</b> 169 <b>Description:</b>
170 </h5> 170 </h5>
171 </v-flex> 171 </v-flex>
172 <v-flex sm8 xs6> 172 <v-flex sm8 xs6>
173 <h5 class="my-1">{{ editedItem.description }}</h5> 173 <h5 class="my-1">{{ editedItem.description }}</h5>
174 </v-flex> 174 </v-flex>
175 </v-layout> 175 </v-layout>
176 <v-layout> 176 <v-layout>
177 <v-flex xs6 sm4> 177 <v-flex xs6 sm4>
178 <h5 class="right my-1"> 178 <h5 class="right my-1">
179 <b>Deadline:</b> 179 <b>Deadline:</b>
180 </h5> 180 </h5>
181 </v-flex> 181 </v-flex>
182 <v-flex sm8 xs6> 182 <v-flex sm8 xs6>
183 <h5 class="my-1">{{ dates(editedItem.deadline) }}</h5> 183 <h5 class="my-1">{{ dates(editedItem.deadline) }}</h5>
184 </v-flex> 184 </v-flex>
185 </v-layout> 185 </v-layout>
186 </v-flex> 186 </v-flex>
187 </v-layout> 187 </v-layout>
188 </v-container> 188 </v-container>
189 </v-card-text> 189 </v-card-text>
190 </v-card> 190 </v-card>
191 </v-dialog> 191 </v-dialog>
192 192
193 <!-- ****** EXISTING ASSIGNMENT TABLE ****** --> 193 <!-- ****** EXISTING ASSIGNMENT TABLE ****** -->
194 <v-toolbar color="transparent" flat> 194 <v-toolbar color="transparent" flat>
195 <v-btn 195 <v-btn
196 fab 196 fab
197 dark 197 dark
198 class="open-dialog-button hidden-xl-only hidden-md-only hidden-lg-only" 198 class="open-dialog-button hidden-xl-only hidden-md-only hidden-lg-only"
199 small 199 small
200 @click="addAssignmentDialog = true" 200 @click="addAssignmentDialog = true"
201 > 201 >
202 <v-icon dark>add</v-icon> 202 <v-icon dark>add</v-icon>
203 </v-btn> 203 </v-btn>
204 <v-flex xs1 class="hidden-sm-only hidden-xs-only"> 204 <v-flex xs1 class="hidden-sm-only hidden-xs-only">
205 <v-btn round class="open-dialog-button" dark @click="addAssignmentDialog = true"> 205 <v-btn round class="open-dialog-button" dark @click="addAssignmentDialog = true">
206 <v-icon class="white--text pr-1" size="20">add</v-icon>Add Assignment 206 <v-icon class="white--text pr-1" size="20">add</v-icon>Add Assignment
207 </v-btn> 207 </v-btn>
208 </v-flex> 208 </v-flex>
209 <v-spacer></v-spacer> 209 <v-spacer></v-spacer>
210 <v-flex lg2 md2 xs12 v-show="show"> 210 <v-flex lg2 md2 xs12 v-show="show">
211 <v-select 211 <v-select
212 :items="classList" 212 :items="classList"
213 placeholder="Select Your Class" 213 placeholder="Select Your Class"
214 v-model="showAssignment.classId" 214 v-model="showAssignment.classId"
215 item-text="classNum" 215 item-text="classNum"
216 item-value="_id" 216 item-value="_id"
217 name="Select Class" 217 name="Select Class"
218 :rules="classRules" 218 :rules="classRules"
219 @change="getAssignmentList()" 219 @change="getAssignmentList()"
220 class="pl-2" 220 class="pl-2"
221 required 221 required
222 ></v-select> 222 ></v-select>
223 </v-flex> 223 </v-flex>
224 <v-card-title class="body-1" v-show="show"> 224 <v-card-title class="body-1" v-show="show">
225 <v-btn icon flat @click="displaySearch"> 225 <v-btn icon flat @click="displaySearch">
226 <v-avatar size="27"> 226 <v-avatar size="27">
227 <img src="/static/icon/search.png" alt="icon" /> 227 <img src="/static/icon/search.png" alt="icon" />
228 </v-avatar> 228 </v-avatar>
229 </v-btn> 229 </v-btn>
230 </v-card-title> 230 </v-card-title>
231 <v-flex xs9 sm9 md2 lg2 xl2 v-if="showSearch"> 231 <v-flex xs9 sm9 md2 lg2 xl2 v-if="showSearch">
232 <v-layout> 232 <v-layout>
233 <v-text-field 233 <v-text-field
234 v-model="search" 234 v-model="search"
235 placeholder="Search" 235 placeholder="Search"
236 prepend-inner-icon="search" 236 prepend-inner-icon="search"
237 color="primary" 237 color="primary"
238 autofocus 238 autofocus
239 style="transition: 0.8s cubic-bezier(0.25, 0.8, 0.25, 1); !important" 239 style="transition: 0.8s cubic-bezier(0.25, 0.8, 0.25, 1); !important"
240 ></v-text-field> 240 ></v-text-field>
241 <v-icon @click="closeSearch" color="error">close</v-icon> 241 <v-icon @click="closeSearch" color="error">close</v-icon>
242 </v-layout> 242 </v-layout>
243 </v-flex> 243 </v-flex>
244 </v-toolbar> 244 </v-toolbar>
245 <v-data-table 245 <v-data-table
246 :headers="headers" 246 :headers="headers"
247 :items="assignmentData" 247 :items="assignmentData"
248 :pagination.sync="pagination" 248 :pagination.sync="pagination"
249 :search="search" 249 :search="search"
250 > 250 >
251 <template slot="items" slot-scope="props"> 251 <template slot="items" slot-scope="props">
252 <tr class="tr"> 252 <tr class="tr">
253 <td class="td-row td">{{ props.index + 1 }}</td> 253 <td class="td-row td">{{ props.index + 1 }}</td>
254 <td class="text-xs-center td td-row">{{ props.item.title }}</td> 254 <td class="text-xs-center td td-row">{{ props.item.title }}</td>
255 <td class="text-xs-center td td-row">{{ props.item.description }}</td> 255 <td class="text-xs-center td td-row">{{ props.item.description }}</td>
256 <td class="text-xs-center td td-row">{{ props.item.deadline }}</td> 256 <td class="text-xs-center td td-row">{{ props.item.deadline }}</td>
257 <td class="text-xs-center td td-row">{{ props.item.sectionId.name }}</td> 257 <td class="text-xs-center td td-row">{{ props.item.sectionId.name }}</td>
258 <td 258 <td
259 class="text-xs-center td td-row" 259 class="text-xs-center td td-row"
260 v-if="role === 'TEACHER'" 260 v-if="role === 'TEACHER'"
261 >{{ props.item.teacherId.name }}</td> 261 >{{ props.item.teacherId.name }}</td>
262 <td 262 <td
263 class="text-xs-center td td-row" 263 class="text-xs-center td td-row"
264 v-if="role === 'ADMIN'" 264 v-if="role === 'ADMIN'"
265 >{{ props.item.schoolId.name }}</td> 265 >{{ props.item.schoolId.name }}</td>
266 <td class="text-xs-center td td-row"> 266 <td class="text-xs-center td td-row">
267 <v-btn 267 <a :href="props.item.fileName" target="_blank" style="text-decoration: none!important;">
268 class="add-button" 268 <v-btn flat block @click="generatePDF2Canvas(props.item)" :loading="loadingPdf">
269 @click="generatePDF2Canvas(props.item)" 269 <span>
270 :loading="loadingPdf" 270 <h5>{{props.item.fileName}}</h5>
271 dark 271 </span>
272 >{{ props.item.fileType }}</v-btn> 272 </v-btn>
273 </a>
273 </td> 274 </td>
274 <td class="text-xs-center td td-row"> 275 <td class="text-xs-center td td-row">
275 <span> 276 <span>
276 <v-tooltip top> 277 <v-tooltip top>
277 <img 278 <img
278 slot="activator" 279 slot="activator"
279 style="cursor:pointer; width:25px; height:25px; " 280 style="cursor:pointer; width:25px; height:25px; "
280 class="mr-3" 281 class="mr-3"
281 @click="profile(props.item)" 282 @click="profile(props.item)"
282 src="/static/icon/view.png" 283 src="/static/icon/view.png"
283 /> 284 />
284 <span>View</span> 285 <span>View</span>
285 </v-tooltip> 286 </v-tooltip>
286 <v-tooltip top> 287 <v-tooltip top>
287 <img 288 <img
288 slot="activator" 289 slot="activator"
289 style="cursor:pointer; width:20px; height:18px; " 290 style="cursor:pointer; width:20px; height:18px; "
290 class="mr-3" 291 class="mr-3"
291 @click="editItem(props.item)" 292 @click="editItem(props.item)"
292 src="/static/icon/edit.png" 293 src="/static/icon/edit.png"
293 /> 294 />
294 <span>Edit</span> 295 <span>Edit</span>
295 </v-tooltip> 296 </v-tooltip>
296 <v-tooltip top> 297 <v-tooltip top>
297 <img 298 <img
298 slot="activator" 299 slot="activator"
299 style="cursor:pointer; width:20px; height:20px; " 300 style="cursor:pointer; width:20px; height:20px; "
300 class="mr-3" 301 class="mr-3"
301 @click="deleteItem(props.item)" 302 @click="deleteItem(props.item)"
302 src="/static/icon/delete.png" 303 src="/static/icon/delete.png"
303 /> 304 />
304 <span>Delete</span> 305 <span>Delete</span>
305 </v-tooltip> 306 </v-tooltip>
306 </span> 307 </span>
307 </td> 308 </td>
308 </tr> 309 </tr>
309 </template> 310 </template>
310 <v-alert 311 <v-alert
311 slot="no-results" 312 slot="no-results"
312 :value="true" 313 :value="true"
313 color="error" 314 color="error"
314 icon="warning" 315 icon="warning"
315 >Your search for "{{ search }}" found no results.</v-alert> 316 >Your search for "{{ search }}" found no results.</v-alert>
316 </v-data-table> 317 </v-data-table>
317 <!-- ****** ADD MULTIPLE Subject ****** --> 318 <!-- ****** ADD MULTIPLE Subject ****** -->
318 <v-snackbar 319 <v-snackbar
319 :timeout="timeout" 320 :timeout="timeout"
320 :top="y === 'top'" 321 :top="y === 'top'"
321 :right="x === 'right'" 322 :right="x === 'right'"
322 :vertical="mode === 'vertical'" 323 :vertical="mode === 'vertical'"
323 v-model="snackbar" 324 v-model="snackbar"
324 :color="color" 325 :color="color"
325 >{{ text }}</v-snackbar> 326 >{{ text }}</v-snackbar>
326 <v-dialog v-model="addAssignmentDialog" max-width="400px" v-if="addAssignmentDialog"> 327 <v-dialog v-model="addAssignmentDialog" max-width="400px" v-if="addAssignmentDialog">
327 <v-card flat class="card-style pa-2" dark> 328 <v-card flat class="card-style pa-2" dark>
328 <v-layout> 329 <v-layout>
329 <v-flex xs12> 330 <v-flex xs12>
330 <label class="title text-xs-center">Add Assignment</label> 331 <label class="title text-xs-center">Add Assignment</label>
331 <v-icon size="24" class="right" @click="closeAddAssignmentModel">cancel</v-icon> 332 <v-icon size="24" class="right" @click="closeAddAssignmentModel">cancel</v-icon>
332 </v-flex> 333 </v-flex>
333 </v-layout> 334 </v-layout>
334 <v-container fluid fill-height> 335 <v-container fluid fill-height>
335 <v-layout align-center> 336 <v-layout align-center>
336 <v-flex xs12> 337 <v-flex xs12>
337 <v-form ref="form" v-model="valid" lazy-validation> 338 <v-form ref="form" v-model="valid" lazy-validation>
338 <v-layout> 339 <v-layout>
339 <v-flex xs4 sm4 class="pt-4 subheading"> 340 <v-flex xs4 sm4 class="pt-4 subheading">
340 <label class="right">Title :</label> 341 <label class="right">Title :</label>
341 </v-flex> 342 </v-flex>
342 <v-flex xs8 sm8 class="ml-3"> 343 <v-flex xs8 sm8 class="ml-3">
343 <v-text-field 344 <v-text-field
344 name="name" 345 name="name"
345 type="text" 346 type="text"
346 placeholder="Select Title" 347 placeholder="Select Title"
347 :rules="titleRules" 348 :rules="titleRules"
348 v-model="addAssignment.title" 349 v-model="addAssignment.title"
349 required 350 required
350 ></v-text-field> 351 ></v-text-field>
351 </v-flex> 352 </v-flex>
352 </v-layout> 353 </v-layout>
353 <v-layout> 354 <v-layout>
354 <v-flex xs4 sm4 class="pt-4 subheading"> 355 <v-flex xs4 sm4 class="pt-4 subheading">
355 <label class="right">Description :</label> 356 <label class="right">Description :</label>
356 </v-flex> 357 </v-flex>
357 <v-flex xs8 sm8 class="ml-3"> 358 <v-flex xs8 sm8 class="ml-3">
358 <v-text-field 359 <v-text-field
359 name="name" 360 name="name"
360 type="text" 361 type="text"
361 placeholder="Select Description" 362 placeholder="Select Description"
362 :rules="descriptionRules" 363 :rules="descriptionRules"
363 v-model="addAssignment.description" 364 v-model="addAssignment.description"
364 required 365 required
365 ></v-text-field> 366 ></v-text-field>
366 </v-flex> 367 </v-flex>
367 </v-layout> 368 </v-layout>
368 <v-layout> 369 <v-layout>
369 <v-flex xs4 sm4 class="pt-4 subheading"> 370 <v-flex xs4 sm4 class="pt-4 subheading">
370 <label class="right">Deadline :</label> 371 <label class="right">Deadline :</label>
371 </v-flex> 372 </v-flex>
372 <v-flex xs8 sm7 class="ml-3"> 373 <v-flex xs8 sm7 class="ml-3">
373 <v-menu 374 <v-menu
374 ref="menu2" 375 ref="menu2"
375 :close-on-content-click="false" 376 :close-on-content-click="false"
376 v-model="menu2" 377 v-model="menu2"
377 :nudge-right="40" 378 :nudge-right="40"
378 :return-value.sync="addAssignment.date" 379 :return-value.sync="addAssignment.date"
379 lazy 380 lazy
380 transition="scale-transition" 381 transition="scale-transition"
381 offset-y 382 offset-y
382 full-width 383 full-width
383 min-width="290px" 384 min-width="290px"
384 > 385 >
385 <v-text-field 386 <v-text-field
386 slot="activator" 387 slot="activator"
387 v-model="addAssignment.deadline" 388 v-model="addAssignment.deadline"
388 :rules="deadlineRules" 389 :rules="deadlineRules"
389 placeholder="Select Date" 390 placeholder="Select Date"
390 append-icon="event" 391 append-icon="event"
391 readonly 392 readonly
392 ></v-text-field> 393 ></v-text-field>
393 <v-date-picker 394 <v-date-picker
394 v-model="addAssignment.deadline" 395 v-model="addAssignment.deadline"
395 @input="$refs.menu2.save(addAssignment.date)" 396 @input="$refs.menu2.save(addAssignment.date)"
396 ></v-date-picker> 397 ></v-date-picker>
397 </v-menu> 398 </v-menu>
398 </v-flex> 399 </v-flex>
399 </v-layout> 400 </v-layout>
400 <v-layout> 401 <v-layout>
401 <v-flex xs4 sm4 class="pt-4 subheading"> 402 <v-flex xs4 sm4 class="pt-4 subheading">
402 <label class="right">Class :</label> 403 <label class="right">Class :</label>
403 </v-flex> 404 </v-flex>
404 <v-flex xs8 sm8 class="ml-3"> 405 <v-flex xs8 sm8 class="ml-3">
405 <v-select 406 <v-select
406 :items="classList" 407 :items="classList"
407 placeholder="Select Class" 408 placeholder="Select Class"
408 item-text="classNum" 409 item-text="classNum"
409 item-value="_id" 410 item-value="_id"
410 v-model="addAssignment.classId" 411 v-model="addAssignment.classId"
411 name="Select Class" 412 name="Select Class"
412 :rules="classRules" 413 :rules="classRules"
413 @change="getSections(addAssignment.classId)" 414 @change="getSections(addAssignment.classId)"
414 class="pl-2" 415 class="pl-2"
415 required 416 required
416 ></v-select> 417 ></v-select>
417 </v-flex> 418 </v-flex>
418 </v-layout> 419 </v-layout>
419 <v-layout> 420 <v-layout>
420 <v-flex xs4 sm4 class="pt-4 subheading"> 421 <v-flex xs4 sm4 class="pt-4 subheading">
421 <label class="right">Section :</label> 422 <label class="right">Section :</label>
422 </v-flex> 423 </v-flex>
423 <v-flex xs8 sm8 class="ml-3"> 424 <v-flex xs8 sm8 class="ml-3">
424 <v-select 425 <v-select
425 :items="addSection" 426 :items="addSection"
426 placeholder="Select Section" 427 placeholder="Select Section"
427 item-text="name" 428 item-text="name"
428 item-value="_id" 429 item-value="_id"
429 v-model="addAssignment.sectionId" 430 v-model="addAssignment.sectionId"
430 name="Select Section" 431 name="Select Section"
431 :rules="sectionRules" 432 :rules="sectionRules"
432 @change="getClassSubject(addAssignment.classId)" 433 @change="getClassSubject(addAssignment.classId)"
433 class="px-2" 434 class="px-2"
434 required 435 required
435 ></v-select> 436 ></v-select>
436 </v-flex> 437 </v-flex>
437 </v-layout> 438 </v-layout>
438 <v-layout> 439 <v-layout>
439 <v-flex xs3 sm4 class="pt-4 subheading"> 440 <v-flex xs3 sm4 class="pt-4 subheading">
440 <label class="right">Subject :</label> 441 <label class="right">Subject :</label>
441 </v-flex> 442 </v-flex>
442 <v-flex xs8 sm8 class="ml-2"> 443 <v-flex xs8 sm8 class="ml-2">
443 <v-select 444 <v-select
444 :items="subjectList.subjects" 445 :items="subjectList.subjects"
445 placeholder="Select your subject" 446 placeholder="Select your subject"
446 v-model="addAssignment.subjectName" 447 v-model="addAssignment.subjectName"
447 item-text="subjectName" 448 item-text="subjectName"
448 item-value="_id" 449 item-value="_id"
449 :rules="subjectRules" 450 :rules="subjectRules"
450 required 451 required
451 ></v-select> 452 ></v-select>
452 </v-flex> 453 </v-flex>
453 </v-layout> 454 </v-layout>
454 <v-layout> 455 <v-layout>
455 <v-flex xs4 class="pt-4 subheading"> 456 <v-flex xs4 class="pt-4 subheading">
456 <label class="right hidden-xs-only hidden-sm-only">Uplaod File:</label> 457 <label class="right hidden-xs-only hidden-sm-only">Uplaod File:</label>
457 <label class="right hidden-lg-only hidden-md-only hidden-xl-only">File:</label> 458 <label class="right hidden-lg-only hidden-md-only hidden-xl-only">File:</label>
458 </v-flex> 459 </v-flex>
459 <v-flex xs8 class="ml-3"> 460 <v-flex xs8 class="ml-3">
460 <v-text-field 461 <v-text-field
461 placeholder="Select File" 462 placeholder="Select File"
462 @click="pickFile" 463 @click="pickFile"
463 v-model="imageName" 464 v-model="imageName"
464 append-icon="attach_file" 465 append-icon="attach_file"
465 ></v-text-field> 466 ></v-text-field>
466 <input 467 <input
467 type="file" 468 type="file"
468 style="display:none" 469 style="display:none"
469 ref="image" 470 ref="image"
470 accept="image/*" 471 accept="image/*"
471 @change="onFilePicked" 472 @change="onFilePicked"
472 /> 473 />
473 </v-flex> 474 </v-flex>
474 </v-layout> 475 </v-layout>
475 <v-layout> 476 <v-layout>
476 <v-flex xs12 sm12> 477 <v-flex xs12 sm12>
477 <v-card-actions> 478 <v-card-actions>
478 <v-spacer></v-spacer> 479 <v-spacer></v-spacer>
479 <v-btn 480 <v-btn
480 @click="submit" 481 @click="submit"
481 round 482 round
482 dark 483 dark
483 :loading="loading" 484 :loading="loading"
484 class="add-button" 485 class="add-button"
485 >Add Assignment</v-btn> 486 >Add Assignment</v-btn>
486 </v-card-actions> 487 </v-card-actions>
487 </v-flex> 488 </v-flex>
488 </v-layout> 489 </v-layout>
489 </v-form> 490 </v-form>
490 </v-flex> 491 </v-flex>
491 </v-layout> 492 </v-layout>
492 </v-container> 493 </v-container>
493 </v-card> 494 </v-card>
494 </v-dialog> 495 </v-dialog>
495 <div class="loader" v-if="showLoader"> 496 <div class="loader" v-if="showLoader">
496 <v-progress-circular indeterminate color="white"></v-progress-circular> 497 <v-progress-circular indeterminate color="white"></v-progress-circular>
497 </div> 498 </div>
498 </v-container> 499 </v-container>
499 </template> 500 </template>
500 501
501 <script> 502 <script>
502 import http from "@/Services/http.js"; 503 import http from "@/Services/http.js";
503 import Util from "@/util"; 504 import Util from "@/util";
504 import moment from "moment"; 505 import moment from "moment";
505 import jsPDF from "jspdf"; 506 import jsPDF from "jspdf";
506 import { saveAs } from "file-saver"; 507 import { saveAs } from "file-saver";
507 508
508 export default { 509 export default {
509 data: () => ({ 510 data: () => ({
510 snackbar: false, 511 snackbar: false,
511 role: "", 512 role: "",
512 menu1: false, 513 menu1: false,
513 menu2: false, 514 menu2: false,
514 y: "top", 515 y: "top",
515 x: "right", 516 x: "right",
516 mode: "", 517 mode: "",
517 timeout: 3000, 518 timeout: 3000,
518 text: "", 519 text: "",
519 color: "", 520 color: "",
520 show: true, 521 show: true,
521 showSearch: false, 522 showSearch: false,
522 showLoader: false, 523 showLoader: false,
523 loading: false, 524 loading: false,
524 editLoading: false, 525 editLoading: false,
525 date: null, 526 date: null,
526 search: "", 527 search: "",
527 viewAssignmentDialog: false, 528 viewAssignmentDialog: false,
528 editAssignmentDialog: false, 529 editAssignmentDialog: false,
529 valid: true, 530 valid: true,
530 validEditAssignment: true, 531 validEditAssignment: true,
531 addAssignmentDialog: false, 532 addAssignmentDialog: false,
532 533
533 pagination: { 534 pagination: {
534 rowsPerPage: 10, 535 rowsPerPage: 10,
535 }, 536 },
536 token: "", 537 token: "",
537 headers: [ 538 headers: [
538 { 539 {
539 text: "No", 540 text: "No",
540 align: "", 541 align: "",
541 sortable: false, 542 sortable: false,
542 value: "No", 543 value: "No",
543 }, 544 },
544 { 545 {
545 text: "Title", 546 text: "Title",
546 value: "title", 547 value: "title",
547 sortable: false, 548 sortable: false,
548 align: "center", 549 align: "center",
549 }, 550 },
550 { 551 {
551 text: "Description", 552 text: "Description",
552 value: "description", 553 value: "description",
553 sortable: false, 554 sortable: false,
554 align: "center", 555 align: "center",
555 }, 556 },
556 { 557 {
557 text: "Deadline", 558 text: "Deadline",
558 value: "deadline", 559 value: "deadline",
559 sortable: false, 560 sortable: false,
560 align: "center", 561 align: "center",
561 }, 562 },
562 { 563 {
563 text: "Section", 564 text: "Section",
564 value: "name", 565 value: "name",
565 sortable: false, 566 sortable: false,
566 align: "center", 567 align: "center",
567 }, 568 },
568 { 569 {
569 text: "Uploader", 570 text: "Uploader",
570 value: "name", 571 value: "name",
571 sortable: false, 572 sortable: false,
572 align: "center", 573 align: "center",
573 }, 574 },
574 { 575 {
575 text: "File", 576 text: "File",
576 value: "file", 577 value: "file",
577 sortable: false, 578 sortable: false,
578 align: "center", 579 align: "center",
579 }, 580 },
580 { text: "Action", value: "", sortable: false, align: "center" }, 581 { text: "Action", value: "", sortable: false, align: "center" },
581 ], 582 ],
582 583
583 showPdfData: false, 584 showPdfData: false,
584 loadingPdf: false, 585 loadingPdf: false,
585 hideData: true, 586 hideData: true,
586 587
587 assignmentData: [], 588 assignmentData: [],
588 subjectList: [], 589 subjectList: [],
589 classList: [], 590 classList: [],
590 addSection: [], 591 addSection: [],
591 editedIndex: -1, 592 editedIndex: -1,
592 addSubject: {}, 593 addSubject: {},
593 594
594 editedItem: { 595 editedItem: {
595 title: "", 596 title: "",
596 description: "", 597 description: "",
597 deadline: "", 598 deadline: "",
598 classId: "", 599 classId: "",
599 sectionId: "", 600 sectionId: "",
600 subjectName: "", 601 subjectName: "",
601 fileType: "", 602 fileType: "",
602 }, 603 },
603 addAssignment: {}, 604 addAssignment: {},
604 showAssignment: {}, 605 showAssignment: {},
605 606
606 imageData: {}, 607 imageData: {},
607 imageName: "", 608 imageName: "",
608 imageUrl: "", 609 imageUrl: "",
609 imageFile: "", 610 imageFile: "",
610 611
611 titleRules: [(v) => !!v || " Title is required"], 612 titleRules: [(v) => !!v || " Title is required"],
612 descriptionRules: [(v) => !!v || " Description is required"], 613 descriptionRules: [(v) => !!v || " Description is required"],
613 deadlineRules: [(v) => !!v || " Deadline is required"], 614 deadlineRules: [(v) => !!v || " Deadline is required"],
614 classRules: [(v) => !!v || "Class is required"], 615 classRules: [(v) => !!v || "Class is required"],
615 sectionRules: [(v) => !!v || "Section is required"], 616 sectionRules: [(v) => !!v || "Section is required"],
616 subjectRules: [(v) => !!v || "Student is required"], 617 subjectRules: [(v) => !!v || "Student is required"],
617 fileRules: [(v) => !!v || "File is required"], 618 fileRules: [(v) => !!v || "File is required"],
618 }), 619 }),
619 watch: { 620 watch: {
620 addAssignmentDialog: function (val) { 621 addAssignmentDialog: function (val) {
621 if (!val) { 622 if (!val) {
622 this.addAssignment = []; 623 this.addAssignment = [];
623 this.imageName = ""; 624 this.imageName = "";
624 } 625 }
625 }, 626 },
626 }, 627 },
627 methods: { 628 methods: {
628 dates: function (date) { 629 dates: function (date) {
629 return moment(date).format("MMMM DD, YYYY"); 630 return moment(date).format("MMMM DD, YYYY");
630 }, 631 },
631 pickFile() { 632 pickFile() {
632 this.$refs.image.click(); 633 this.$refs.image.click();
633 }, 634 },
634 editItem(item) { 635 editItem(item) {
635 this.editedIndex = this.assignmentData; 636 this.editedIndex = this.assignmentData;
636 this.editedItem = Object.assign({}, item); 637 this.editedItem = Object.assign({}, item);
637 this.dialog = true; 638 this.dialog = true;
638 this.editAssignmentDialog = true; 639 this.editAssignmentDialog = true;
639 }, 640 },
640 profile(item) { 641 profile(item) {
641 this.editedIndex = this.assignmentData; 642 this.editedIndex = this.assignmentData;
642 this.editedItem = Object.assign({}, item); 643 this.editedItem = Object.assign({}, item);
643 this.dialog1 = true; 644 this.dialog1 = true;
644 this.viewAssignmentDialog = true; 645 this.viewAssignmentDialog = true;
645 }, 646 },
646 deleteItem(item) { 647 deleteItem(item) {
647 let deleteAssignment = { 648 let deleteAssignment = {
648 assignmentId: item._id, 649 assignmentId: item._id,
649 }; 650 };
650 http() 651 http()
651 .delete( 652 .delete(
652 "/deleteAssignment", 653 "/deleteAssignment",
653 confirm("Are you sure you want to delete this?") && { 654 confirm("Are you sure you want to delete this?") && {
654 params: deleteAssignment, 655 params: deleteAssignment,
655 }, 656 },
656 { 657 {
657 headers: { Authorization: "Bearer " + this.token }, 658 headers: { Authorization: "Bearer " + this.token },
658 } 659 }
659 ) 660 )
660 .then((response) => { 661 .then((response) => {
661 this.getAssignmentList(); 662 this.getAssignmentList();
662 this.snackbar = true; 663 this.snackbar = true;
663 this.text = "Successfully delete Existing Assignment"; 664 this.text = "Successfully delete Existing Assignment";
664 this.color = "green"; 665 this.color = "green";
665 }) 666 })
666 .catch((error) => { 667 .catch((error) => {
667 this.snackbar = true; 668 this.snackbar = true;
668 this.text = error.response.data.message; 669 this.text = error.response.data.message;
669 this.color = "error"; 670 this.color = "error";
670 }); 671 });
671 }, 672 },
672 close() { 673 close() {
673 this.editAssignmentDialog = false; 674 this.editAssignmentDialog = false;
674 }, 675 },
675 close1() { 676 close1() {
676 this.viewAssignmentDialog = false; 677 this.viewAssignmentDialog = false;
677 }, 678 },
678 closeAddAssignmentModel() { 679 closeAddAssignmentModel() {
679 this.addAssignmentDialog = false; 680 this.addAssignmentDialog = false;
680 // this.assignmentData = []; 681 // this.assignmentData = [];
681 this.addAssignment = []; 682 this.addAssignment = [];
682 this.imageName = ""; 683 this.imageName = "";
683 }, 684 },
684 submit() { 685 submit() {
685 var addAssignment = { 686 var addAssignment = {
686 title: this.addAssignment.title, 687 title: this.addAssignment.title,
687 description: this.addAssignment.description, 688 description: this.addAssignment.description,
688 deadline: this.addAssignment.deadline, 689 deadline: this.addAssignment.deadline,
689 classId: this.addAssignment.classId, 690 classId: this.addAssignment.classId,
690 sectionId: this.addAssignment.sectionId, 691 sectionId: this.addAssignment.sectionId,
691 subjectName: this.addAssignment.subjectName, 692 subjectName: this.addAssignment.subjectName,
692 file: this.addAssignment.imageName, 693 file: this.addAssignment.imageName,
693 fileName: this.imageName, 694 fileName: this.imageName,
694 }; 695 };
695 var signatures = { 696 var signatures = {
696 JVBERi0: "other", 697 JVBERi0: "other",
697 iVBORw0KGgo: "image", 698 iVBORw0KGgo: "image",
698 UEsDBBQ: "other", 699 UEsDBBQ: "other",
699 "/": "image", 700 "/": "image",
700 AAABAA: "image", 701 AAABAA: "image",
701 IywiV2hhdC: "other", 702 IywiV2hhdC: "other",
702 bmFtZSxl: "other", 703 bmFtZSxl: "other",
703 }; 704 };
704 function detectMimeType(b64) { 705 function detectMimeType(b64) {
705 for (var s in signatures) { 706 for (var s in signatures) {
706 if (b64.indexOf(s) === 0) { 707 if (b64.indexOf(s) === 0) {
707 return signatures[s]; 708 return signatures[s];
708 } 709 }
709 } 710 }
710 } 711 }
711 if (this.$refs.form.validate()) { 712 if (this.$refs.form.validate()) {
712 if (this.imageUrl) { 713 if (this.imageUrl) {
713 var str = this.imageUrl; 714 var str = this.imageUrl;
714 const [baseUrl, imageUrl] = str.split(/,/); 715 const [baseUrl, imageUrl] = str.split(/,/);
715 addAssignment.upload = imageUrl; 716 addAssignment.upload = imageUrl;
716 addAssignment.fileType = detectMimeType(imageUrl); 717 addAssignment.fileType = detectMimeType(imageUrl);
717 } 718 }
718 console.log("data===>", addAssignment); 719 // console.log("data===>", addAssignment);
719 http() 720 http()
720 .post("/createAssignment", addAssignment) 721 .post("/createAssignment", addAssignment)
721 .then((response) => { 722 .then((response) => {
722 this.getAssignmentList(); 723 this.getAssignmentList();
723 this.snackbar = true; 724 this.snackbar = true;
724 this.text = "Syllabus added successfully"; 725 this.text = "Assignment added successfully";
725 this.color = "green"; 726 this.color = "green";
726 this.addAssignmentDialog = false; 727 this.addAssignmentDialog = false;
727 this.clear(); 728 this.clear();
728 }) 729 })
729 .catch((error) => { 730 .catch((error) => {
730 // console.log(error); 731 // console.log(error);
731 this.snackbar = true; 732 this.snackbar = true;
732 this.text = error.response.data.message; 733 this.text = error.response.data.message;
733 this.color = "red"; 734 this.color = "red";
734 }); 735 });
735 } 736 }
736 }, 737 },
737 getAssignmentList() { 738 getAssignmentList() {
738 if (this.addAssignment.classId) { 739 if (this.addAssignment.classId) {
739 this.addAssignment.classId = this.addAssignment.classId; 740 this.addAssignment.classId = this.addAssignment.classId;
740 } 741 }
741 this.showLoader = true; 742 this.showLoader = true;
742 http() 743 http()
743 .get( 744 .get(
744 "/getAssignmentList", 745 "/getAssignmentList",
745 { 746 {
746 params: { classId: this.showAssignment.classId }, 747 params: { classId: this.showAssignment.classId },
747 }, 748 },
748 { 749 {
749 headers: { Authorization: "Bearer " + this.token }, 750 headers: { Authorization: "Bearer " + this.token },
750 } 751 }
751 ) 752 )
752 .then((response) => { 753 .then((response) => {
753 this.assignmentData = response.data.data; 754 this.assignmentData = response.data.data;
754 this.showLoader = false; 755 this.showLoader = false;
755 this.loadingSearch = false; 756 this.loadingSearch = false;
756 }) 757 })
757 .catch((error) => { 758 .catch((error) => {
758 // console.log("err====>", err); 759 // console.log("err====>", err);
759 this.showLoader = false; 760 this.showLoader = false;
760 this.loadingSearch = false; 761 this.loadingSearch = false;
761 this.snackbar = true; 762 this.snackbar = true;
762 this.text = error.response.data.message; 763 this.text = error.response.data.message;
763 if (error.response.status === 401) { 764 if (error.response.status === 401) {
764 this.$router.replace({ path: "/" }); 765 this.$router.replace({ path: "/" });
765 this.$store.dispatch("setToken", null); 766 this.$store.dispatch("setToken", null);
766 this.$store.dispatch("Id", null); 767 this.$store.dispatch("Id", null);
767 } 768 }
768 }); 769 });
769 }, 770 },
770 clear() { 771 clear() {
771 this.$refs.form.reset(); 772 this.$refs.form.reset();
772 }, 773 },
773 save() { 774 save() {
774 if (this.$refs.formEditAssignment.validate()) { 775 if (this.$refs.formEditAssignment.validate()) {
775 let editAssignment = { 776 let editAssignment = {
776 assignmentId: this.editedItem._id, 777 assignmentId: this.editedItem._id,
777 title: this.addAssignment.title, 778 title: this.addAssignment.title,
778 description: this.addAssignment.description, 779 description: this.addAssignment.description,
779 deadline: this.addAssignment.deadline, 780 deadline: this.addAssignment.deadline,
780 classId: this.addAssignment.classId, 781 classId: this.addAssignment.classId,
781 sectionId: this.addAssignment.sectionId, 782 sectionId: this.addAssignment.sectionId,
782 subjectName: this.addAssignment.subjectName, 783 subjectName: this.addAssignment.subjectName,
783 file: this.addAssignment.imageName, 784 file: this.addAssignment.imageName,
784 fileName: this.imageName, 785 fileName: this.imageName,
785 }; 786 };
786 this.editLoading = true; 787 this.editLoading = true;
787 var signatures = { 788 var signatures = {
788 JVBERi0: "other", 789 JVBERi0: "other",
789 iVBORw0KGgo: "image", 790 iVBORw0KGgo: "image",
790 UEsDBBQ: "other", 791 UEsDBBQ: "other",
791 "/": "image", 792 "/": "image",
792 AAABAA: "image", 793 AAABAA: "image",
793 IywiV2hhdC: "other", 794 IywiV2hhdC: "other",
794 bmFtZSxl: "other", 795 bmFtZSxl: "other",
795 }; 796 };
796 function detectMimeType(b64) { 797 function detectMimeType(b64) {
797 for (var s in signatures) { 798 for (var s in signatures) {
798 if (b64.indexOf(s) === 0) { 799 if (b64.indexOf(s) === 0) {
799 return signatures[s]; 800 return signatures[s];
800 } 801 }
801 } 802 }
802 } 803 }
803 if (this.imageUrl) { 804 if (this.imageUrl) {
804 var str = this.imageUrl; 805 var str = this.imageUrl;
805 const [baseUrl, imageUrl] = str.split(/,/); 806 const [baseUrl, imageUrl] = str.split(/,/);
806 editAssignment.upload = imageUrl; 807 editAssignment.upload = imageUrl;
807 editAssignment.fileType = detectMimeType(imageUrl); 808 editAssignment.fileType = detectMimeType(imageUrl);
808 } 809 }
809 http() 810 http()
810 .put("/updateAssignment", editAssignment) 811 .put("/updateAssignment", editAssignment)
811 .then((response) => { 812 .then((response) => {
812 this.snackbar = true; 813 this.snackbar = true;
813 this.text = "Successfully Edit Existing Assignment"; 814 this.text = "Successfully Edit Existing Assignment";
814 this.color = "green"; 815 this.color = "green";
815 this.getAssignmentList(); 816 this.getAssignmentList();
816 this.editLoading = false; 817 this.editLoading = false;
817 this.editAssignmentDialog = false; 818 this.editAssignmentDialog = false;
818 }) 819 })
819 .catch((error) => { 820 .catch((error) => {
820 this.editLoading = false; 821 this.editLoading = false;
821 // console.log(error); 822 // console.log(error);
822 }); 823 });
823 } 824 }
824 }, 825 },
825 getClass() { 826 getClass() {
826 http() 827 http()
827 .get("/getClassesList", { 828 .get("/getClassesList", {
828 headers: { Authorization: "Bearer " + this.token }, 829 headers: { Authorization: "Bearer " + this.token },
829 }) 830 })
830 .then((response) => { 831 .then((response) => {
831 this.classList = response.data.data; 832 this.classList = response.data.data;
832 }) 833 })
833 .catch((error) => { 834 .catch((error) => {
834 if (error.response.status === 401) { 835 if (error.response.status === 401) {
835 this.$router.replace({ path: "/" }); 836 this.$router.replace({ path: "/" });
836 this.$store.dispatch("setToken", null); 837 this.$store.dispatch("setToken", null);
837 this.$store.dispatch("Id", null); 838 this.$store.dispatch("Id", null);
838 } 839 }
839 }); 840 });
840 }, 841 },
841 getSections(_id) { 842 getSections(_id) {
842 var token = this.$store.state.token; 843 var token = this.$store.state.token;
843 this.showLoader = true; 844 this.showLoader = true;
844 http() 845 http()
845 .get( 846 .get(
846 "/getSectionsList", 847 "/getSectionsList",
847 { params: { classId: _id } }, 848 { params: { classId: _id } },
848 { 849 {
849 headers: { Authorization: "Bearer " + token }, 850 headers: { Authorization: "Bearer " + token },
850 } 851 }
851 ) 852 )
852 .then((response) => { 853 .then((response) => {
853 this.addSection = response.data.data; 854 this.addSection = response.data.data;
854 this.showLoader = false; 855 this.showLoader = false;
855 }) 856 })
856 .catch((err) => { 857 .catch((err) => {
857 this.showLoader = false; 858 this.showLoader = false;
858 }); 859 });
859 }, 860 },
860 getClassSubject(_id) { 861 getClassSubject(_id) {
861 this.showLoader = true; 862 this.showLoader = true;
862 // this.classId = this.classId; 863 // this.classId = this.classId;
863 http() 864 http()
864 .get( 865 .get(
865 "/getParticularClass", 866 "/getParticularClass",
866 { params: { classId: _id } }, 867 { params: { classId: _id } },
867 { 868 {
868 headers: { Authorization: "Bearer " + this.token }, 869 headers: { Authorization: "Bearer " + this.token },
869 } 870 }
870 ) 871 )
871 .then((response) => { 872 .then((response) => {
872 this.subjectList = response.data.data; 873 this.subjectList = response.data.data;
873 this.showLoader = false; 874 this.showLoader = false;
874 }) 875 })
875 .catch((err) => { 876 .catch((err) => {
876 this.showLoader = false; 877 this.showLoader = false;
877 }); 878 });
878 }, 879 },
879 onFilePicked(e) { 880 onFilePicked(e) {
880 const files = e.target.files; 881 const files = e.target.files;
881 this.upload = e.target.files[0]; 882 this.upload = e.target.files[0];
882 if (files[0] !== undefined) { 883 if (files[0] !== undefined) {
883 this.imageName = files[0].name; 884 this.imageName = files[0].name;
884 if (this.imageName.lastIndexOf(".") <= 0) { 885 if (this.imageName.lastIndexOf(".") <= 0) {
885 return; 886 return;
886 } 887 }
887 const fr = new FileReader(); 888 const fr = new FileReader();
888 fr.readAsDataURL(files[0]); 889 fr.readAsDataURL(files[0]);
889 fr.addEventListener("load", () => { 890 fr.addEventListener("load", () => {
890 this.imageUrl = fr.result; 891 this.imageUrl = fr.result;
891 this.imageFile = files[0]; // this is an image file that can be sent to server... 892 this.imageFile = files[0]; // this is an image file that can be sent to server...
892 this.imageData.imageUrl = URL.createObjectURL(this.imageFile); 893 this.imageData.imageUrl = URL.createObjectURL(this.imageFile);
893 }); 894 });
894 // console.log("this.imageName", this.imageName); 895 // console.log("this.imageName", this.imageName);
895 } else { 896 } else {
896 this.imageName = ""; 897 this.imageName = "";
897 this.imageFile = ""; 898 this.imageFile = "";
898 this.imageUrl = ""; 899 this.imageUrl = "";
899 } 900 }
900 }, 901 },
901 displaySearch() { 902 displaySearch() {
902 (this.show = false), (this.showSearch = true); 903 (this.show = false), (this.showSearch = true);
903 }, 904 },
904 closeSearch() { 905 closeSearch() {
905 this.showSearch = false; 906 this.showSearch = false;
906 this.show = true; 907 this.show = true;
907 this.search = ""; 908 this.search = "";
908 }, 909 },
909 910
910 async generatePDF2Canvas(item) { 911 async generatePDF2Canvas(item) {
911 var dataType = ""; 912 var dataType = "";
912 var type = ""; 913 var type = "";
913 if (item.fileType == "image") { 914 if (item.fileType == "image") {
914 dataType = "file.jpg"; 915 dataType = "file.jpg";
915 } else if (item.fileType == "other") { 916 } else if (item.fileType == "other") {
916 dataType = "file.pdf"; 917 dataType = "file.pdf";
917 type = "application/pdf"; 918 type = "application/pdf";
918 } 919 }
919 var FileSaver = require("file-saver"); 920 var FileSaver = require("file-saver");
920 FileSaver.saveAs(item.file, "image.jpg"); 921 FileSaver.saveAs(item.file, "image.jpg");
921 }, 922 },
922 }, 923 },
923 mounted() { 924 mounted() {
924 this.token = this.$store.state.token; 925 this.token = this.$store.state.token;
925 this.role = this.$store.state.role; 926 this.role = this.$store.state.role;
926 this.getClass(); 927 this.getClass();
927 }, 928 },
928 }; 929 };
929 </script> 930 </script>
src/pages/Academic/syllabus.vue
1 <template> 1 <template>
2 <v-container fluid class="body-color"> 2 <v-container fluid class="body-color">
3 <!-- ****** EDIT Syllabus ****** --> 3 <!-- ****** EDIT Syllabus ****** -->
4 <v-dialog v-model="editSyllabusDialog" max-width="400px"> 4 <v-dialog v-model="editSyllabusDialog" max-width="400px">
5 <v-card flat class="card-style pa-2" dark> 5 <v-card flat class="card-style pa-2" dark>
6 <v-layout> 6 <v-layout>
7 <v-flex xs12> 7 <v-flex xs12>
8 <label class="title text-xs-center">Edit Syllabus</label> 8 <label class="title text-xs-center">Edit Syllabus</label>
9 <v-icon size="24" class="right" @click="editSyllabusDialog = false">cancel</v-icon> 9 <v-icon size="24" class="right" @click="editSyllabusDialog = false">cancel</v-icon>
10 </v-flex> 10 </v-flex>
11 </v-layout> 11 </v-layout>
12 <v-container fluid> 12 <v-container fluid>
13 <v-form ref="formEditSyllabus" v-model="validEditSyllabus" lazy-validation> 13 <v-form ref="formEditSyllabus" v-model="validEditSyllabus" lazy-validation>
14 <v-layout> 14 <v-layout>
15 <v-flex xs4 sm4 class="pt-4 subheading"> 15 <v-flex xs4 sm4 class="pt-4 subheading">
16 <label class="right">Title :</label> 16 <label class="right">Title :</label>
17 </v-flex> 17 </v-flex>
18 <v-flex xs8 sm8 class="ml-3"> 18 <v-flex xs8 sm8 class="ml-3">
19 <v-text-field v-model="editedItem.title"></v-text-field> 19 <v-text-field v-model="editedItem.title"></v-text-field>
20 </v-flex> 20 </v-flex>
21 </v-layout> 21 </v-layout>
22 <v-layout> 22 <v-layout>
23 <v-flex xs4 class="pt-4 subheading"> 23 <v-flex xs4 class="pt-4 subheading">
24 <label class="right">Description:</label> 24 <label class="right">Description:</label>
25 </v-flex> 25 </v-flex>
26 <v-flex xs8 class="ml-3"> 26 <v-flex xs8 class="ml-3">
27 <v-text-field v-model="editedItem.description"></v-text-field> 27 <v-text-field v-model="editedItem.description"></v-text-field>
28 </v-flex> 28 </v-flex>
29 </v-layout> 29 </v-layout>
30 <v-layout> 30 <v-layout>
31 <v-flex xs4 class="pt-4 subheading"> 31 <v-flex xs4 class="pt-4 subheading">
32 <label class="right">Class:</label> 32 <label class="right">Class:</label>
33 </v-flex> 33 </v-flex>
34 <v-flex xs8 class="ml-3"> 34 <v-flex xs8 class="ml-3">
35 <v-select 35 <v-select
36 :items="classList" 36 :items="classList"
37 v-model="editedItem.classId" 37 v-model="editedItem.classId"
38 label="Select Class" 38 label="Select Class"
39 item-text="classNum" 39 item-text="classNum"
40 item-value="_id" 40 item-value="_id"
41 name="Select Class" 41 name="Select Class"
42 @change="getSections(addSyllabus.classId)" 42 @change="getSections(addSyllabus.classId)"
43 required 43 required
44 ></v-select> 44 ></v-select>
45 </v-flex> 45 </v-flex>
46 </v-layout> 46 </v-layout>
47 <!-- <v-layout> 47 <!-- <v-layout>
48 <v-flex xs4 sm4 class="pt-4 subheading"> 48 <v-flex xs4 sm4 class="pt-4 subheading">
49 <label class="right">Section :</label> 49 <label class="right">Section :</label>
50 </v-flex> 50 </v-flex>
51 <v-flex xs8 sm8 class="ml-3"> 51 <v-flex xs8 sm8 class="ml-3">
52 <v-select 52 <v-select
53 :items="addSection" 53 :items="addSection"
54 label="Select Section" 54 label="Select Section"
55 item-text="name" 55 item-text="name"
56 item-value="_id" 56 item-value="_id"
57 v-model="editedItem.sectionId" 57 v-model="editedItem.sectionId"
58 name="Select Section" 58 name="Select Section"
59 class="px-2" 59 class="px-2"
60 required 60 required
61 ></v-select> 61 ></v-select>
62 </v-flex> 62 </v-flex>
63 </v-layout>--> 63 </v-layout>-->
64 <v-layout> 64 <v-layout>
65 <v-flex xs4 class="pt-4 subheading"> 65 <v-flex xs4 class="pt-4 subheading">
66 <label class="right">File:</label> 66 <label class="right">File:</label>
67 </v-flex> 67 </v-flex>
68 <v-flex xs8 sm6 class="ml-3"> 68 <v-flex xs8 sm6 class="ml-3">
69 <v-text-field 69 <v-text-field
70 label="Select file" 70 label="Select file"
71 @click="pickFile" 71 @click="pickFile"
72 v-model="imageName" 72 v-model="imageName"
73 append-icon="attach_file" 73 append-icon="attach_file"
74 ></v-text-field> 74 ></v-text-field>
75 </v-flex> 75 </v-flex>
76 <input 76 <input
77 type="file" 77 type="file"
78 style="display:none" 78 style="display:none"
79 ref="image" 79 ref="image"
80 accept="image/*" 80 accept="image/*"
81 @change="onFilePicked" 81 @change="onFilePicked"
82 /> 82 />
83 </v-layout> 83 </v-layout>
84 <v-flex xs12 sm12> 84 <v-flex xs12 sm12>
85 <v-card-actions> 85 <v-card-actions>
86 <v-spacer></v-spacer> 86 <v-spacer></v-spacer>
87 <v-btn 87 <v-btn
88 round 88 round
89 dark 89 dark
90 @click="save" 90 @click="save"
91 :loading="editLoading" 91 :loading="editLoading"
92 class="add-button" 92 class="add-button"
93 >Update Syllabus</v-btn> 93 >Update Syllabus</v-btn>
94 </v-card-actions> 94 </v-card-actions>
95 </v-flex> 95 </v-flex>
96 </v-form> 96 </v-form>
97 </v-container> 97 </v-container>
98 </v-card> 98 </v-card>
99 </v-dialog> 99 </v-dialog>
100 100
101 <!-- ****** VIEW PROFIL NOTICE BOARD ****** --> 101 <!-- ****** VIEW PROFIL NOTICE BOARD ****** -->
102 102
103 <!-- <v-dialog v-model="viewSubjectDialog" max-width="600px"> 103 <!-- <v-dialog v-model="viewSubjectDialog" max-width="600px">
104 <v-toolbar flat class="card-style pa-3" dark> 104 <v-toolbar flat class="card-style pa-3" dark>
105 <v-spacer></v-spacer> 105 <v-spacer></v-spacer>
106 <v-toolbar-title> 106 <v-toolbar-title>
107 <h3>Subject</h3> 107 <h3>Subject</h3>
108 </v-toolbar-title> 108 </v-toolbar-title>
109 <v-spacer></v-spacer> 109 <v-spacer></v-spacer>
110 <v-icon @click="close1">close</v-icon> 110 <v-icon @click="close1">close</v-icon>
111 </v-toolbar> 111 </v-toolbar>
112 <v-card> 112 <v-card>
113 <v-card-text> 113 <v-card-text>
114 <v-container grid-list-md> 114 <v-container grid-list-md>
115 <v-layout wrap> 115 <v-layout wrap>
116 <v-flex> 116 <v-flex>
117 <v-layout> 117 <v-layout>
118 <v-flex xs7 sm6> 118 <v-flex xs7 sm6>
119 <h5 class="right my-1"> 119 <h5 class="right my-1">
120 <b>Subject Name:</b> 120 <b>Subject Name:</b>
121 </h5> 121 </h5>
122 </v-flex> 122 </v-flex>
123 <v-flex sm6 xs5> 123 <v-flex sm6 xs5>
124 <h5 class="my-1">{{ editedItem.subjectName }}</h5> 124 <h5 class="my-1">{{ editedItem.subjectName }}</h5>
125 </v-flex> 125 </v-flex>
126 </v-layout> 126 </v-layout>
127 </v-flex> 127 </v-flex>
128 </v-layout> 128 </v-layout>
129 </v-container> 129 </v-container>
130 </v-card-text> 130 </v-card-text>
131 </v-card> 131 </v-card>
132 </v-dialog>--> 132 </v-dialog>-->
133 133
134 <!-- ****** EXISTING SYLLABUS TABLE ****** --> 134 <!-- ****** EXISTING SYLLABUS TABLE ****** -->
135 <v-toolbar color="transparent" flat> 135 <v-toolbar color="transparent" flat>
136 <v-btn 136 <v-btn
137 fab 137 fab
138 dark 138 dark
139 class="open-dialog-button hidden-xl-only hidden-md-only hidden-lg-only" 139 class="open-dialog-button hidden-xl-only hidden-md-only hidden-lg-only"
140 small 140 small
141 @click="addSyllabusDialog = true" 141 @click="addSyllabusDialog = true"
142 > 142 >
143 <v-icon dark>add</v-icon> 143 <v-icon dark>add</v-icon>
144 </v-btn> 144 </v-btn>
145 <v-flex xs1 class="hidden-sm-only hidden-xs-only"> 145 <v-flex xs1 class="hidden-sm-only hidden-xs-only">
146 <v-btn round class="open-dialog-button" dark @click="addSyllabusDialog = true"> 146 <v-btn round class="open-dialog-button" dark @click="addSyllabusDialog = true">
147 <v-icon class="white--text pr-1" size="20">add</v-icon>Add Syllabus 147 <v-icon class="white--text pr-1" size="20">add</v-icon>Add Syllabus
148 </v-btn> 148 </v-btn>
149 </v-flex> 149 </v-flex>
150 <v-spacer></v-spacer> 150 <v-spacer></v-spacer>
151 <v-flex lg2 md2 xs12 v-show="show"> 151 <v-flex lg2 md2 xs12 v-show="show">
152 <v-select 152 <v-select
153 :items="classList" 153 :items="classList"
154 label="Select Class" 154 label="Select Class"
155 v-model="showSyllabus.classId" 155 v-model="showSyllabus.classId"
156 item-text="classNum" 156 item-text="classNum"
157 item-value="_id" 157 item-value="_id"
158 name="Select Class" 158 name="Select Class"
159 :rules="classRules" 159 :rules="classRules"
160 @change="getSyallabusList" 160 @change="getSyallabusList"
161 class="pl-2" 161 class="pl-2"
162 required 162 required
163 ></v-select> 163 ></v-select>
164 </v-flex> 164 </v-flex>
165 <v-card-title class="body-1" v-show="show"> 165 <v-card-title class="body-1" v-show="show">
166 <v-btn icon flat @click="displaySearch"> 166 <v-btn icon flat @click="displaySearch">
167 <v-avatar size="27"> 167 <v-avatar size="27">
168 <img src="/static/icon/search.png" alt="icon" /> 168 <img src="/static/icon/search.png" alt="icon" />
169 </v-avatar> 169 </v-avatar>
170 </v-btn> 170 </v-btn>
171 </v-card-title> 171 </v-card-title>
172 <v-flex xs9 sm9 md2 lg2 xl2 v-if="showSearch"> 172 <v-flex xs9 sm9 md2 lg2 xl2 v-if="showSearch">
173 <v-layout> 173 <v-layout>
174 <v-text-field 174 <v-text-field
175 autofocus 175 autofocus
176 v-model="search" 176 v-model="search"
177 label="Search" 177 label="Search"
178 prepend-inner-icon="search" 178 prepend-inner-icon="search"
179 color="primary" 179 color="primary"
180 style="transition: 0.8s cubic-bezier(0.25, 0.8, 0.25, 1); !important" 180 style="transition: 0.8s cubic-bezier(0.25, 0.8, 0.25, 1); !important"
181 ></v-text-field> 181 ></v-text-field>
182 <v-icon @click="closeSearch" color="error">close</v-icon> 182 <v-icon @click="closeSearch" color="error">close</v-icon>
183 </v-layout> 183 </v-layout>
184 </v-flex> 184 </v-flex>
185 </v-toolbar> 185 </v-toolbar>
186 <v-data-table 186 <v-data-table
187 :headers="headers" 187 :headers="headers"
188 :items="syllabusList" 188 :items="syllabusList"
189 :pagination.sync="pagination" 189 :pagination.sync="pagination"
190 :search="search" 190 :search="search"
191 > 191 >
192 <template slot="items" slot-scope="props"> 192 <template slot="items" slot-scope="props">
193 <tr class="tr"> 193 <tr class="tr">
194 <td class="td-row td">{{ props.index + 1 }}</td> 194 <td class="td-row td">{{ props.index + 1 }}</td>
195 <td class="text-xs-center td td-row">{{ props.item.title }}</td> 195 <td class="text-xs-center td td-row">{{ props.item.title }}</td>
196 <td class="text-xs-center td td-row">{{ props.item.description }}</td> 196 <td class="text-xs-center td td-row">{{ props.item.description }}</td>
197 <td class="text-xs-center td td-row">{{ dates(props.item.created) }}</td> 197 <td class="text-xs-center td td-row">{{ dates(props.item.created) }}</td>
198 <td 198 <td
199 class="text-xs-center td td-row" 199 class="text-xs-center td td-row"
200 v-if="props.item.teacherId" 200 v-if="props.item.teacherId"
201 >{{ props.item.teacherId.name }}</td> 201 >{{ props.item.teacherId.name }}</td>
202 <td class="text-xs-center td td-row" v-else>{{ props.item.schoolId.name }}</td> 202 <td class="text-xs-center td td-row" v-else>{{ props.item.schoolId.name }}</td>
203 <td class="text-xs-center td td-row"> 203 <td class="text-xs-center td td-row">
204 <v-btn 204 <!-- <v-btn
205 class="add-button" 205 class="add-button"
206 @click="generatePDF2Canvas(props.item)" 206 @click="generatePDF2Canvas(props.item)"
207 :loading="loadingPdf" 207 :loading="loadingPdf"
208 dark 208 dark
209 >{{ props.item.fileType }}</v-btn> 209 >{{ props.item.fileName }}</v-btn>-->
210 <a :href="props.item.fileName" target="_blank" style="text-decoration: none!important;">
211 <v-btn flat block @click="generatePDF2Canvas(props.item)" :loading="loadingPdf">
212 <span>
213 <h5>{{props.item.fileName}}</h5>
214 </span>
215 </v-btn>
216 </a>
210 </td> 217 </td>
211 <td class="text-xs-center td td-row"> 218 <td class="text-xs-center td td-row">
212 <span> 219 <span>
213 <v-tooltip top> 220 <v-tooltip top>
214 <img 221 <img
215 slot="activator" 222 slot="activator"
216 style="cursor:pointer; width:20px; height:18px; " 223 style="cursor:pointer; width:20px; height:18px; "
217 class="mr-3" 224 class="mr-3"
218 @click="editItem(props.item)" 225 @click="editItem(props.item)"
219 src="/static/icon/edit.png" 226 src="/static/icon/edit.png"
220 /> 227 />
221 <span>Edit</span> 228 <span>Edit</span>
222 </v-tooltip> 229 </v-tooltip>
223 <v-tooltip top> 230 <v-tooltip top>
224 <img 231 <img
225 slot="activator" 232 slot="activator"
226 style="cursor:pointer; width:20px; height:20px; " 233 style="cursor:pointer; width:20px; height:20px; "
227 class="mr-3" 234 class="mr-3"
228 @click="deleteItem(props.item)" 235 @click="deleteItem(props.item)"
229 src="/static/icon/delete.png" 236 src="/static/icon/delete.png"
230 /> 237 />
231 <span>Delete</span> 238 <span>Delete</span>
232 </v-tooltip> 239 </v-tooltip>
233 </span> 240 </span>
234 </td> 241 </td>
235 </tr> 242 </tr>
236 </template> 243 </template>
237 <v-alert 244 <v-alert
238 slot="no-results" 245 slot="no-results"
239 :value="true" 246 :value="true"
240 color="error" 247 color="error"
241 icon="warning" 248 icon="warning"
242 >Your search for "{{ search }}" found no results.</v-alert> 249 >Your search for "{{ search }}" found no results.</v-alert>
243 </v-data-table> 250 </v-data-table>
244 <!-- ****** ADD SYLLABUS ****** --> 251 <!-- ****** ADD SYLLABUS ****** -->
245 <v-snackbar 252 <v-snackbar
246 :timeout="timeout" 253 :timeout="timeout"
247 :top="y === 'top'" 254 :top="y === 'top'"
248 :right="x === 'right'" 255 :right="x === 'right'"
249 :vertical="mode === 'vertical'" 256 :vertical="mode === 'vertical'"
250 v-model="snackbar" 257 v-model="snackbar"
251 :color="color" 258 :color="color"
252 >{{ text }}</v-snackbar> 259 >{{ text }}</v-snackbar>
253 <v-dialog v-model="addSyllabusDialog" max-width="400px" v-if="addSyllabusDialog"> 260 <v-dialog v-model="addSyllabusDialog" max-width="400px" v-if="addSyllabusDialog">
254 <v-card flat class="card-style pa-2" dark> 261 <v-card flat class="card-style pa-2" dark>
255 <v-layout> 262 <v-layout>
256 <v-flex xs12> 263 <v-flex xs12>
257 <label class="title text-xs-center">Add Syllabus</label> 264 <label class="title text-xs-center">Add Syllabus</label>
258 <v-icon size="24" class="right" @click="closeAddStudentModel">cancel</v-icon> 265 <v-icon size="24" class="right" @click="closeAddStudentModel">cancel</v-icon>
259 </v-flex> 266 </v-flex>
260 </v-layout> 267 </v-layout>
261 <v-container fluid fill-height> 268 <v-container fluid fill-height>
262 <v-layout align-center> 269 <v-layout align-center>
263 <v-flex xs12> 270 <v-flex xs12>
264 <v-form ref="form" v-model="valid" lazy-validation> 271 <v-form ref="form" v-model="valid" lazy-validation>
265 <v-layout> 272 <v-layout>
266 <v-flex xs4 sm4 class="pt-4 subheading"> 273 <v-flex xs4 sm4 class="pt-4 subheading">
267 <label class="right">Title :</label> 274 <label class="right">Title :</label>
268 </v-flex> 275 </v-flex>
269 <v-flex xs8 sm8 class="ml-3"> 276 <v-flex xs8 sm8 class="ml-3">
270 <v-text-field 277 <v-text-field
271 v-model="addSyllabus.title" 278 v-model="addSyllabus.title"
272 name="name" 279 name="name"
273 type="text" 280 type="text"
274 placeholder="Add Title" 281 placeholder="Add Title"
275 :rules="titleRules" 282 :rules="titleRules"
276 required 283 required
277 ></v-text-field> 284 ></v-text-field>
278 </v-flex> 285 </v-flex>
279 </v-layout> 286 </v-layout>
280 <v-layout> 287 <v-layout>
281 <v-flex xs4 sm4 class="pt-4 subheading"> 288 <v-flex xs4 sm4 class="pt-4 subheading">
282 <label class="right">Description :</label> 289 <label class="right">Description :</label>
283 </v-flex> 290 </v-flex>
284 <v-flex xs8 sm8 class="ml-3"> 291 <v-flex xs8 sm8 class="ml-3">
285 <v-text-field 292 <v-text-field
286 v-model="addSyllabus.description" 293 v-model="addSyllabus.description"
287 name="name" 294 name="name"
288 type="text" 295 type="text"
289 placeholder="Add Description" 296 placeholder="Add Description"
290 :rules="descriptionRules" 297 :rules="descriptionRules"
291 required 298 required
292 ></v-text-field> 299 ></v-text-field>
293 </v-flex> 300 </v-flex>
294 </v-layout> 301 </v-layout>
295 <v-layout> 302 <v-layout>
296 <v-flex xs4 class="pt-4 subheading"> 303 <v-flex xs4 class="pt-4 subheading">
297 <label class="right">Class:</label> 304 <label class="right">Class:</label>
298 </v-flex> 305 </v-flex>
299 <v-flex xs8 class="ml-3"> 306 <v-flex xs8 class="ml-3">
300 <v-select 307 <v-select
301 :items="classList" 308 :items="classList"
302 v-model="addSyllabus.classId" 309 v-model="addSyllabus.classId"
303 label="Select Class" 310 label="Select Class"
304 item-text="classNum" 311 item-text="classNum"
305 item-value="_id" 312 item-value="_id"
306 name="Select Class" 313 name="Select Class"
307 @change="getSections(addSyllabus.classId)" 314 @change="getSections(addSyllabus.classId)"
308 required 315 required
309 ></v-select> 316 ></v-select>
310 </v-flex> 317 </v-flex>
311 </v-layout> 318 </v-layout>
312 <!-- <v-layout> 319 <!-- <v-layout>
313 <v-flex xs4 sm4 class="pt-4 subheading"> 320 <v-flex xs4 sm4 class="pt-4 subheading">
314 <label class="right">Section :</label> 321 <label class="right">Section :</label>
315 </v-flex> 322 </v-flex>
316 <v-flex xs8 sm8 class="ml-3"> 323 <v-flex xs8 sm8 class="ml-3">
317 <v-select 324 <v-select
318 :items="addSection" 325 :items="addSection"
319 label="Select Section" 326 label="Select Section"
320 item-text="name" 327 item-text="name"
321 item-value="_id" 328 item-value="_id"
322 v-model="addSyllabus.sectionId" 329 v-model="addSyllabus.sectionId"
323 name="Select Section" 330 name="Select Section"
324 class="px-2" 331 class="px-2"
325 required 332 required
326 ></v-select> 333 ></v-select>
327 </v-flex> 334 </v-flex>
328 </v-layout>--> 335 </v-layout>-->
329 <v-layout> 336 <v-layout>
330 <v-flex xs4 class="pt-4 subheading"> 337 <v-flex xs4 class="pt-4 subheading">
331 <label class="right">File:</label> 338 <label class="right">File:</label>
332 </v-flex> 339 </v-flex>
333 <v-flex xs8 sm6 class="ml-3"> 340 <v-flex xs8 sm6 class="ml-3">
334 <v-text-field 341 <v-text-field
335 label="Select file" 342 label="Select file"
336 @click="pickFile" 343 @click="pickFile"
337 v-model="imageName" 344 v-model="imageName"
338 append-icon="attach_file" 345 append-icon="attach_file"
339 ></v-text-field> 346 ></v-text-field>
340 <input 347 <input
341 type="file" 348 type="file"
342 style="display:none" 349 style="display:none"
343 ref="image" 350 ref="image"
344 accept="image/*" 351 accept="image/*"
345 @change="onFilePicked" 352 @change="onFilePicked"
346 /> 353 />
347 </v-flex> 354 </v-flex>
348 </v-layout> 355 </v-layout>
349 <v-layout> 356 <v-layout>
350 <v-flex xs12 sm12> 357 <v-flex xs12 sm12>
351 <v-card-actions> 358 <v-card-actions>
352 <v-spacer></v-spacer> 359 <v-spacer></v-spacer>
353 <v-btn 360 <v-btn
354 @click="submit" 361 @click="submit"
355 round 362 round
356 dark 363 dark
357 :loading="loading" 364 :loading="loading"
358 class="add-button" 365 class="add-button"
359 >Add Syllabus</v-btn> 366 >Add Syllabus</v-btn>
360 </v-card-actions> 367 </v-card-actions>
361 </v-flex> 368 </v-flex>
362 </v-layout> 369 </v-layout>
363 </v-form> 370 </v-form>
364 </v-flex> 371 </v-flex>
365 </v-layout> 372 </v-layout>
366 </v-container> 373 </v-container>
367 </v-card> 374 </v-card>
368 </v-dialog> 375 </v-dialog>
369 <div class="loader" v-if="showLoader"> 376 <div class="loader" v-if="showLoader">
370 <v-progress-circular indeterminate color="white"></v-progress-circular> 377 <v-progress-circular indeterminate color="white"></v-progress-circular>
371 </div> 378 </div>
372 </v-container> 379 </v-container>
373 </template> 380 </template>
374 381
375 <script> 382 <script>
376 import http from "@/Services/http.js"; 383 import http from "@/Services/http.js";
377 import Util from "@/util"; 384 import Util from "@/util";
378 import moment from "moment"; 385 import moment from "moment";
379 import jsPDF from "jspdf"; 386 import jsPDF from "jspdf";
380 import { saveAs } from "file-saver"; 387 import { saveAs } from "file-saver";
381 388
382 export default { 389 export default {
383 data: () => ({ 390 data: () => ({
384 snackbar: false, 391 snackbar: false,
385 y: "top", 392 y: "top",
386 x: "right", 393 x: "right",
387 mode: "", 394 mode: "",
388 timeout: 3000, 395 timeout: 3000,
389 text: "", 396 text: "",
390 color: "", 397 color: "",
391 show: true, 398 show: true,
392 showSearch: false, 399 showSearch: false,
393 showLoader: false, 400 showLoader: false,
394 loading: false, 401 loading: false,
395 editLoading: false, 402 editLoading: false,
396 date: null, 403 date: null,
397 search: "", 404 search: "",
398 editSyllabusDialog: false, 405 editSyllabusDialog: false,
399 valid: true, 406 valid: true,
400 validEditSyllabus: true, 407 validEditSyllabus: true,
401 addSyllabusDialog: false, 408 addSyllabusDialog: false,
402 loadingPdf: false, 409 loadingPdf: false,
403 410
404 pagination: { 411 pagination: {
405 rowsPerPage: 10, 412 rowsPerPage: 10,
406 }, 413 },
407 token: "", 414 token: "",
408 upload: "", 415 upload: "",
409 titleRules: [(v) => !!v || " Title is required"], 416 titleRules: [(v) => !!v || " Title is required"],
410 descriptionRules: [(v) => !!v || " Description is required"], 417 descriptionRules: [(v) => !!v || " Description is required"],
411 classRules: [(v) => !!v || " Class Name is required"], 418 classRules: [(v) => !!v || " Class Name is required"],
412 fileRules: [(v) => !!v || " File is required"], 419 fileRules: [(v) => !!v || " File is required"],
413 headers: [ 420 headers: [
414 { 421 {
415 text: "No", 422 text: "No",
416 align: "", 423 align: "",
417 sortable: false, 424 sortable: false,
418 value: "No", 425 value: "No",
419 }, 426 },
420 { 427 {
421 text: "Title", 428 text: "Title",
422 value: "title", 429 value: "title",
423 sortable: false, 430 sortable: false,
424 align: "center", 431 align: "center",
425 }, 432 },
426 { 433 {
427 text: "Description", 434 text: "Description",
428 value: "description", 435 value: "description",
429 sortable: false, 436 sortable: false,
430 align: "center", 437 align: "center",
431 }, 438 },
432 { 439 {
433 text: "Date", 440 text: "Date",
434 value: "created", 441 value: "created",
435 sortable: false, 442 sortable: false,
436 align: "center", 443 align: "center",
437 }, 444 },
438 { 445 {
439 text: "Uploader", 446 text: "Uploader",
440 value: "upload", 447 value: "upload",
441 sortable: false, 448 sortable: false,
442 align: "center", 449 align: "center",
443 }, 450 },
444 { 451 {
445 text: "File", 452 text: "File",
446 value: "documentUrl", 453 value: "documentUrl",
447 sortable: false, 454 sortable: false,
448 align: "center", 455 align: "center",
449 }, 456 },
450 { text: "Action", value: "", sortable: false, align: "center" }, 457 { text: "Action", value: "", sortable: false, align: "center" },
451 ], 458 ],
452 syllabusList: [], 459 syllabusList: [],
453 classList: [], 460 classList: [],
454 addSection: [], 461 addSection: [],
455 editedIndex: -1, 462 editedIndex: -1,
456 addSyllabus: {}, 463 addSyllabus: {},
457 showSyllabus: {}, 464 showSyllabus: {},
458 465
459 editedItem: { 466 editedItem: {
460 subjectName: "", 467 subjectName: "",
461 }, 468 },
462 imageData: {}, 469 imageData: {},
463 imageName: "", 470 imageName: "",
464 imageUrl: "", 471 imageUrl: "",
465 imageFile: "", 472 imageFile: "",
466 }), 473 }),
467 474
468 watch: { 475 watch: {
469 addSyllabusDialog: function (val) { 476 addSyllabusDialog: function (val) {
470 if (!val) { 477 if (!val) {
471 this.addSyllabus = []; 478 this.addSyllabus = [];
472 this.imageName = ""; 479 this.imageName = "";
473 } 480 }
474 }, 481 },
475 }, 482 },
476 483
477 methods: { 484 methods: {
478 pickFile() { 485 pickFile() {
479 this.$refs.image.click(); 486 this.$refs.image.click();
480 }, 487 },
481 dates: function (date) { 488 dates: function (date) {
482 return moment(date).format("MMMM DD, YYYY"); 489 return moment(date).format("MMMM DD, YYYY");
483 }, 490 },
484 editItem(item) { 491 editItem(item) {
485 this.editedIndex = this.syllabusList; 492 this.editedIndex = this.syllabusList;
486 this.editedItem = Object.assign({}, item); 493 this.editedItem = Object.assign({}, item);
487 this.dialog = true; 494 this.dialog = true;
488 this.editSyllabusDialog = true; 495 this.editSyllabusDialog = true;
489 }, 496 },
490 download(item) { 497 download(item) {
491 this.editedIndex = this.syllabusList; 498 this.editedIndex = this.syllabusList;
492 this.editedItem = Object.assign({}, item); 499 this.editedItem = Object.assign({}, item);
493 this.dialog1 = true; 500 this.dialog1 = true;
494 }, 501 },
495 deleteItem(item) { 502 deleteItem(item) {
496 let deleteSyallabus = { 503 let deleteSyallabus = {
497 syallabusId: item._id, 504 syallabusId: item._id,
498 }; 505 };
499 http() 506 http()
500 .delete( 507 .delete(
501 "/deleteSyallabus", 508 "/deleteSyallabus",
502 confirm("Are you sure you want to delete this?") && { 509 confirm("Are you sure you want to delete this?") && {
503 params: deleteSyallabus, 510 params: deleteSyallabus,
504 } 511 }
505 ) 512 )
506 .then((response) => { 513 .then((response) => {
507 this.getSyallabusList(); 514 this.getSyallabusList();
508 this.snackbar = true; 515 this.snackbar = true;
509 this.color = "green"; 516 this.color = "green";
510 this.text = "Successfully delete Existing Syllabus"; 517 this.text = "Successfully delete Existing Syllabus";
511 }) 518 })
512 .catch((error) => { 519 .catch((error) => {
513 this.snackbar = true; 520 this.snackbar = true;
514 this.text = error.response.data.message; 521 this.text = error.response.data.message;
515 this.color = "error"; 522 this.color = "error";
516 }); 523 });
517 }, 524 },
518 close() { 525 close() {
519 this.editSyllabusDialog = false; 526 this.editSyllabusDialog = false;
520 }, 527 },
521 closeAddStudentModel() { 528 closeAddStudentModel() {
522 this.addSyllabusDialog = false; 529 this.addSyllabusDialog = false;
523 // this.syllabusList = []; 530 // this.syllabusList = [];
524 this.addSyllabus = []; 531 this.addSyllabus = [];
525 this.imageName = ""; 532 this.imageName = "";
526 }, 533 },
527 534
528 submit() { 535 submit() {
529 // var addSyllabus = { 536 // var addSyllabus = {
530 // classId: this.addSyllabus.classId, 537 // classId: this.addSyllabus.classId,
531 // title: this.addSyllabus.title, 538 // title: this.addSyllabus.title,
532 // description: this.addSyllabus.description, 539 // description: this.addSyllabus.description,
533 // upload: this.addSyllabus.upload, 540 // upload: this.addSyllabus.upload,
534 // fileType: this.addSyllabus.fileType 541 // fileType: this.addSyllabus.fileType
535 // }; 542 // };
536 var signatures = { 543 var signatures = {
537 JVBERi0: "other", 544 // JVBERi0: "other",
538 iVBORw0KGgo: "image", 545 // iVBORw0KGgo: "image",
539 UEsDBBQ: "other", 546 // UEsDBBQ: "other",
540 "/": "image", 547 // "/": "image",
541 AAABAA: "image", 548 // AAABAA: "image",
542 IywiV2hhdC: "other", 549 // IywiV2hhdC: "other",
543 bmFtZSxl: "other", 550 // bmFtZSxl: "other",
544 }; 551 };
545 function detectMimeType(b64) { 552 function detectMimeType(b64) {
546 for (var s in signatures) { 553 for (var s in signatures) {
547 if (b64.indexOf(s) === 0) { 554 if (b64.indexOf(s) === 0) {
548 return signatures[s]; 555 return signatures[s];
549 } 556 }
550 } 557 }
551 } 558 }
552 if (this.$refs.form.validate()) { 559 if (this.$refs.form.validate()) {
553 if (this.imageUrl) { 560 if (this.imageUrl) {
554 var str = this.imageUrl; 561 var str = this.imageUrl;
555 const [baseUrl, imageUrl] = str.split(/,/); 562 const [baseUrl, imageUrl] = str.split(/,/);
556 this.addSyllabus.upload = imageUrl; 563 this.addSyllabus.upload = imageUrl;
557 this.addSyllabus.fileType = detectMimeType(imageUrl); 564 this.addSyllabus.fileType = detectMimeType(imageUrl);
558 this.addSyllabus.fileName = this.imageName; 565 this.addSyllabus.fileName = this.imageName;
559 } 566 }
560 http() 567 http()
561 .post("/createSyallabus", this.addSyllabus) 568 .post("/createSyallabus", this.addSyllabus)
562 .then((response) => { 569 .then((response) => {
563 this.getSyallabusList(); 570 this.getSyallabusList();
564 this.snackbar = true; 571 this.snackbar = true;
565 this.text = "Syllabus added successfully"; 572 this.text = "Syllabus added successfully";
566 this.clear(); 573 this.clear();
567 this.color = "green"; 574 this.color = "green";
568 this.addSyllabusDialog = false; 575 this.addSyllabusDialog = false;
569 }) 576 })
570 .catch((error) => { 577 .catch((error) => {
571 // console.log(error); 578 // console.log(error);
572 this.snackbar = true; 579 this.snackbar = true;
573 this.text = error.response.data.message; 580 this.text = error.response.data.message;
574 this.color = "error"; 581 this.color = "error";
575 }); 582 });
576 } 583 }
577 }, 584 },
578 onFilePicked(e) { 585 onFilePicked(e) {
579 const files = e.target.files; 586 const files = e.target.files;
580 this.upload = e.target.files[0]; 587 this.upload = e.target.files[0];
581 if (files[0] !== undefined) { 588 if (files[0] !== undefined) {
582 this.imageName = files[0].name; 589 this.imageName = files[0].name;
583 if (this.imageName.lastIndexOf(".") <= 0) { 590 if (this.imageName.lastIndexOf(".") <= 0) {
584 return; 591 return;
585 } 592 }
586 const fr = new FileReader(); 593 const fr = new FileReader();
587 fr.readAsDataURL(files[0]); 594 fr.readAsDataURL(files[0]);
588 fr.addEventListener("load", () => { 595 fr.addEventListener("load", () => {
589 this.imageUrl = fr.result; 596 this.imageUrl = fr.result;
590 this.imageFile = files[0]; // this is an image file that can be sent to server... 597 this.imageFile = files[0]; // this is an image file that can be sent to server...
591 this.imageData.imageUrl = URL.createObjectURL(this.imageFile); 598 this.imageData.imageUrl = URL.createObjectURL(this.imageFile);
592 }); 599 });
593 } else { 600 } else {
594 this.imageName = ""; 601 this.imageName = "";
595 this.imageFile = ""; 602 this.imageFile = "";
596 this.imageUrl = ""; 603 this.imageUrl = "";
597 } 604 }
598 }, 605 },
599 clear() { 606 clear() {
600 this.$refs.form.reset(); 607 this.$refs.form.reset();
601 }, 608 },
602 save() { 609 save() {
603 if (this.$refs.formEditSyllabus.validate()) { 610 if (this.$refs.formEditSyllabus.validate()) {
604 let syllabusData = { 611 let syllabusData = {
605 syallabusId: this.editedItem._id, 612 syallabusId: this.editedItem._id,
606 classId: this.editedItem.classId._id, 613 classId: this.editedItem.classId._id,
607 // sectionId: this.editedItem.sectionId, 614 // sectionId: this.editedItem.sectionId,
608 title: this.editedItem.title, 615 title: this.editedItem.title,
609 description: this.editedItem.description, 616 description: this.editedItem.description,
610 upload: this.editedItem.upload, 617 upload: this.editedItem.upload,
611 fileType: this.editedItem.fileType, 618 fileType: this.editedItem.fileType,
612 fileName: this.imageName, 619 fileName: this.imageName,
613 }; 620 };
614 this.editLoading = true; 621 this.editLoading = true;
615 var signatures = { 622 var signatures = {
616 JVBERi0: "other", 623 // JVBERi0: "other",
617 iVBORw0KGgo: "image", 624 // iVBORw0KGgo: "image",
618 UEsDBBQ: "other", 625 // UEsDBBQ: "other",
619 "/": "image", 626 // "/": "image",
620 AAABAA: "image", 627 // AAABAA: "image",
621 IywiV2hhdC: "other", 628 // IywiV2hhdC: "other",
622 }; 629 };
623 function detectMimeType(b64) { 630 function detectMimeType(b64) {
624 for (var s in signatures) { 631 for (var s in signatures) {
625 if (b64.indexOf(s) === 0) { 632 if (b64.indexOf(s) === 0) {
626 return signatures[s]; 633 return signatures[s];
627 } 634 }
628 } 635 }
629 } 636 }
630 if (this.imageUrl) { 637 if (this.imageUrl) {
631 var str = this.imageUrl; 638 var str = this.imageUrl;
632 const [baseUrl, imageUrl] = str.split(/,/); 639 const [baseUrl, imageUrl] = str.split(/,/);
633 syllabusData.upload = imageUrl; 640 syllabusData.upload = imageUrl;
634 syllabusData.fileType = detectMimeType(imageUrl); 641 syllabusData.fileType = detectMimeType(imageUrl);
635 } 642 }
636 http() 643 http()
637 .put("/updateSyallabus", syllabusData) 644 .put("/updateSyallabus", syllabusData)
638 .then((response) => { 645 .then((response) => {
639 this.snackbar = true; 646 this.snackbar = true;
640 this.text = "Successfully Edit Existing Syllabus"; 647 this.text = "Successfully Edit Existing Syllabus";
641 this.color = "green"; 648 this.color = "green";
642 this.editLoading = false; 649 this.editLoading = false;
643 this.editSyllabusDialog = false; 650 this.editSyllabusDialog = false;
644 http() 651 http()
645 .get( 652 .get(
646 "/getSyallabusList", 653 "/getSyallabusList",
647 { params: { classId: this.addSyllabus.classId } }, 654 { params: { classId: this.addSyllabus.classId } },
648 { 655 {
649 headers: { Authorization: "Bearer " + this.token }, 656 headers: { Authorization: "Bearer " + this.token },
650 } 657 }
651 ) 658 )
652 .then((response) => { 659 .then((response) => {
653 this.syllabusList = response.data.data; 660 this.syllabusList = response.data.data;
654 this.getSyallabusList(); 661 this.getSyallabusList();
655 this.snackbar = true; 662 this.snackbar = true;
656 this.color = "green"; 663 this.color = "green";
657 this.close(); 664 this.close();
658 }) 665 })
659 .catch((err) => { 666 .catch((err) => {
660 console.log("err====>", err); 667 console.log("err====>", err);
661 this.text = error.response.data.message; 668 this.text = error.response.data.message;
662 this.color = "error"; 669 this.color = "error";
663 }); 670 });
664 }) 671 })
665 .catch((error) => { 672 .catch((error) => {
666 this.editLoading = false; 673 this.editLoading = false;
667 }); 674 });
668 } 675 }
669 }, 676 },
670 getSyallabusList() { 677 getSyallabusList() {
671 this.showLoader = true; 678 this.showLoader = true;
672 http() 679 http()
673 .get( 680 .get(
674 "/getSyallabusList", 681 "/getSyallabusList",
675 { params: { classId: this.showSyllabus.classId } }, 682 { params: { classId: this.showSyllabus.classId } },
676 { 683 {
677 headers: { Authorization: "Bearer " + this.token }, 684 headers: { Authorization: "Bearer " + this.token },
678 } 685 }
679 ) 686 )
680 .then((response) => { 687 .then((response) => {
681 this.syllabusList = response.data.data; 688 this.syllabusList = response.data.data;
682 this.showLoader = false; 689 this.showLoader = false;
683 }) 690 })
684 .catch((err) => { 691 .catch((err) => {
685 this.showLoader = false; 692 this.showLoader = false;
686 }); 693 });
687 }, 694 },
688 getClass() { 695 getClass() {
689 http() 696 http()
690 .get("/getClassesList", { 697 .get("/getClassesList", {
691 headers: { Authorization: "Bearer " + this.token }, 698 headers: { Authorization: "Bearer " + this.token },
692 }) 699 })
693 .then((response) => { 700 .then((response) => {
694 this.classList = response.data.data; 701 this.classList = response.data.data;
695 }) 702 })
696 .catch((error) => { 703 .catch((error) => {
697 if (error.response.status === 401) { 704 if (error.response.status === 401) {
698 this.$router.replace({ path: "/" }); 705 this.$router.replace({ path: "/" });
699 this.$store.dispatch("setToken", null); 706 this.$store.dispatch("setToken", null);
700 this.$store.dispatch("Id", null); 707 this.$store.dispatch("Id", null);
701 } 708 }
702 }); 709 });
703 }, 710 },
704 getSections(_id) { 711 getSections(_id) {
705 var token = this.$store.state.token; 712 var token = this.$store.state.token;
706 this.showLoader = true; 713 this.showLoader = true;
707 http() 714 http()
708 .get( 715 .get(
709 "/getSectionsList", 716 "/getSectionsList",
710 { params: { classId: _id } }, 717 { params: { classId: _id } },
711 { 718 {
712 headers: { Authorization: "Bearer " + token }, 719 headers: { Authorization: "Bearer " + token },
713 } 720 }
714 ) 721 )
715 .then((response) => { 722 .then((response) => {
716 this.addSection = response.data.data; 723 this.addSection = response.data.data;
717 this.showLoader = false; 724 this.showLoader = false;
718 }) 725 })
719 .catch((err) => { 726 .catch((err) => {
720 this.showLoader = false; 727 this.showLoader = false;
721 }); 728 });
722 }, 729 },
723 displaySearch() { 730 displaySearch() {
724 (this.show = false), (this.showSearch = true); 731 (this.show = false), (this.showSearch = true);
725 }, 732 },
726 closeSearch() { 733 closeSearch() {
727 this.showSearch = false; 734 this.showSearch = false;
728 this.show = true; 735 this.show = true;
729 this.search = ""; 736 this.search = "";
730 }, 737 },
731 738
732 async generatePDF2Canvas(item) { 739 async generatePDF2Canvas(item) {
733 // console.log("documentUrl", documentUrl); 740 // console.log("documentUrl", documentUrl);
734 // this.loadingPdf = true; 741 // this.loadingPdf = true;
735 // const el = this.$refs.printMe; 742 // const el = this.$refs.printMe;
736 // add option type to get the image version 743 // add option type to get the image version
737 // if not provided the promise will return 744 // if not provided the promise will return
738 // the canvas. 745 // the canvas.
739 // const options = { 746 // const options = {
740 // type: "dataURL" 747 // type: "dataURL"
741 // }; 748 // };
742 // this.output = await this.$html2canvas(el, options); 749 // this.output = await this.$html2canvas(el, options);
743 // console.log("el,option", this.output); 750 // console.log("el,option", this.output);
744 // if (this.output) { 751 // if (this.output) {
745 // this.loadingPdf = false; 752 // this.loadingPdf = false;
746 // } 753 // }
747 // let doc = new jsPDF(); 754 // let doc = new jsPDF();
748 // doc.addImage(this.output,"JPEG", 5, 10, 200, 280); 755 // doc.addImage(this.output,"JPEG", 5, 10, 200, 280);
749 // doc.save("File.pdf"); 756 // doc.save("File.pdf");
750 757
751 // function download(documentUrl, filename) { 758 // function download(documentUrl, filename) {
752 // fetch(documentUrl).then(function(t) { 759 // fetch(documentUrl).then(function(t) {
753 // return t.blob().then(b => { 760 // return t.blob().then(b => {
754 // var a = document.createElement("a"); 761 // var a = document.createElement("a");
755 // a.href = URL.createObjectURL(b); 762 // a.href = URL.createObjectURL(b);
756 // a.setAttribute("download", "filename"); 763 // a.setAttribute("download", "filename");
757 // a.click(); 764 // a.click();
758 // }); 765 // });
759 // }); 766 // });
760 // } 767 // }
761 var dataType = ""; 768 var dataType = "";
762 var type = ""; 769 var type = "";
763 if (item.fileType == "image") { 770 if (item.fileType == "image") {
764 dataType = "file.jpg"; 771 dataType = "file.jpg";
765 } else if (item.fileType == "other") { 772 } else if (item.fileType == "other") {
766 dataType = "file.pdf"; 773 dataType = "file.pdf";
767 type = "application/pdf"; 774 type = "application/pdf";
768 } 775 }
769 var FileSaver = require("file-saver"); 776 var FileSaver = require("file-saver");
770 FileSaver.saveAs(item.documentUrl, "image.jpg"); 777 FileSaver.saveAs(item.documentUrl, "image.jpg");
771 778
772 // var blob = new Blob([item.documentUrl], { 779 // var blob = new Blob([item.documentUrl], {
773 // type: type 780 // type: type
774 // }); 781 // });
775 // FileSaver.saveAs(blob, dataType); 782 // FileSaver.saveAs(blob, dataType);
776 // const url = window.URL.createObjectURL(new Blob([item.documentUrl],{ type: type } )); 783 // const url = window.URL.createObjectURL(new Blob([item.documentUrl],{ type: type } ));
777 // console.log("document", item.documentUrl); 784 // console.log("document", item.documentUrl);
778 // const link = document.createElement("a"); 785 // const link = document.createElement("a");
779 // link.href = url; 786 // link.href = url;
780 // link.setAttribute("download", dataType); //or any other extension 787 // link.setAttribute("download", dataType); //or any other extension
781 // document.body.appendChild(link); 788 // document.body.appendChild(link);
782 // link.click(); 789 // link.click();
783 790
784 // const blob = window.URL.createObjectURL(new Blob([item.documentUrl],{ type: type } )); 791 // const blob = window.URL.createObjectURL(new Blob([item.documentUrl],{ type: type } ));
785 // const link = document.createElement('a') 792 // const link = document.createElement('a')
786 // link.href = URL.createObjectURL(blob) 793 // link.href = URL.createObjectURL(blob)
787 // link.download = dataType 794 // link.download = dataType
788 // link.click() 795 // link.click()
789 // URL.revokeObjectURL(link.href) 796 // URL.revokeObjectURL(link.href)
790 }, 797 },
791 }, 798 },
792 mounted() { 799 mounted() {
793 this.token = this.$store.state.token; 800 this.token = this.$store.state.token;
794 this.role = this.$store.state.role; 801 this.role = this.$store.state.role;
795 this.getClass(); 802 this.getClass();
796 }, 803 },
797 }; 804 };
798 </script> 805 </script>