Blame view

src/pages/Gallery/gallery.vue 31.1 KB
8bb178441   Neeraj Sharma   implemnt api in s...
1
  <template>
68d742034   Neeraj Sharma   implement new des...
2
3
4
5
6
7
    <v-container fluid class="body-color">
      <!-- ****** EDITS  Gallery  ****** -->
      <v-dialog v-model="editGalleryDialog" max-width="1000px" scrollable>
        <v-card class="card-style pa-2" dark>
          <v-layout>
            <v-flex xs12>
8c3acf4a9   Shikha Mishra   improve details
8
              <label class="title text-xs-center">Edit Gallery</label>
68d742034   Neeraj Sharma   implement new des...
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
              <v-icon size="24" class="right" @click="editGalleryDialog = false">cancel</v-icon>
            </v-flex>
          </v-layout>
          <v-card-text>
            <v-layout row>
              <v-flex xs12 class="text-xs-center text-sm-center text-md-center text-lg-center my-4">
                <input
                  type="file"
                  style="display: none"
                  ref="editImage"
                  accept="image/*"
                  multiple
                  @change="editFilePicked"
                />
                <v-layout justify-center>
f4df757fe   Neeraj Sharma   responsive vie in...
24
                  <v-flex
68d742034   Neeraj Sharma   implement new des...
25
26
27
28
29
30
31
                    xs6
                    sm12
                    md3
                    v-for="Image in editedItem.imageUrl"
                    :key="Image._id"
                    v-if="editedItem.imageUrl"
                    class="profile-image-wrapper imgNews"
f4df757fe   Neeraj Sharma   responsive vie in...
32
                  >
68d742034   Neeraj Sharma   implement new des...
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
                    <img :src="Image.imageLink" height="160" width="160" alt="Gallery" class="pa-2" />
                    <v-icon
                      class="red edit-profile-icon"
                      dark
                      @click="deleteImage(Image._id,editedItem._id)"
                    >close</v-icon>
                  </v-flex>
                  <v-flex v-for="(file, index) in editFiles" :key="index">
                    <img :src="file" height="160" width="160" class="pa-2" />
                  </v-flex>
                </v-layout>
                <img
                  src="/static/icon/user.png"
                  v-if="editedItem.imageUrl == '' && editFiles == ''"
                  height="160"
                  width="160"
                  alt="Gallery"
                />
              </v-flex>
            </v-layout>
            <v-layout wrap>
              <v-flex xs12 sm12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Title:</label>
                  </v-flex>
                  <v-flex xs8 sm6 class="ml-3">
                    <v-text-field
                      v-model="editedItem.title"
                      placeholder="fill your Title"
                      name="name"
                      type="text"
                      required
                    ></v-text-field>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12 sm12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Description:</label>
                  </v-flex>
                  <v-flex xs8 sm6 class="ml-3">
                    <v-text-field
                      placeholder="fill your Description"
                      v-model="editedItem.description"
                      type="text"
                      name="email"
                      required
                    ></v-text-field>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-layout>
                <v-flex xs4 class="pt-4 subheading">
                  <label class="right hidden-xs-only hidden-sm-only">Select Class:</label>
                  <label class="right hidden-lg-only hidden-md-only hidden-xl-only">Class:</label>
                </v-flex>
                <v-flex xs8 sm6 class="ml-3">
                  <v-select
                    :items="addclass"
                    label="Select Class"
                    v-model="editedItem.classNum"
                    item-text="classNum"
                    item-value="_id"
                    name="Select Class"
                    required
                  ></v-select>
                </v-flex>
              </v-layout>
              <v-flex xs12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right hidden-xs-only hidden-sm-only">Add New Images:</label>
                    <label class="right hidden-lg-only hidden-md-only hidden-xl-only">Upload:</label>
                  </v-flex>
                  <v-flex xs8 sm6 class="ml-3">
                    <v-text-field
                      label="Select Image"
                      @click="editPickFile"
                      v-model="editImageName"
                      append-icon="attach_file"
f4df757fe   Neeraj Sharma   responsive vie in...
115
                      multiple
68d742034   Neeraj Sharma   implement new des...
116
                    ></v-text-field>
f4df757fe   Neeraj Sharma   responsive vie in...
117
118
                  </v-flex>
                </v-layout>
68d742034   Neeraj Sharma   implement new des...
119
120
121
122
123
124
125
126
              </v-flex>
            </v-layout>
            <v-flex xs12>
              <div
                v-for="(editImage,index) in editedItem.youTubeLinkUrl"
                :key="index"
                v-if="editImage.youTubeLink !=[]"
              >
f4df757fe   Neeraj Sharma   responsive vie in...
127
                <v-layout wrap>
68d742034   Neeraj Sharma   implement new des...
128
129
130
                  <v-flex xs12 sm12 md4 class="pt-4 subheading">
                    <label class="right hidden-xs-only hidden-sm-only">You Tube Link Url:</label>
                    <label class="hidden-md-only hidden-lg-only hidden-xl-only">You Tube Link Url:</label>
f4df757fe   Neeraj Sharma   responsive vie in...
131
132
                  </v-flex>
                  <v-layout>
68d742034   Neeraj Sharma   implement new des...
133
134
                    <v-flex xs10 sm10 sm5 md9 class="ml-3">
                      <v-text-field v-model="editImage.youTubeLink" type="text" name="link" required></v-text-field>
a17c68a03   Neeraj Sharma   implement two rou...
135
                    </v-flex>
68d742034   Neeraj Sharma   implement new des...
136
137
                    <v-flex xs2 class="pt-4">
                      <v-icon @click="deleteUrl(index,editImage._id,editedItem._id)">cancel</v-icon>
a17c68a03   Neeraj Sharma   implement two rou...
138
                    </v-flex>
f4df757fe   Neeraj Sharma   responsive vie in...
139
                  </v-layout>
68d742034   Neeraj Sharma   implement new des...
140
141
142
143
144
145
146
147
148
                </v-layout>
              </div>
            </v-flex>
            <v-flex xs12>
              <div v-for="(updateImage,index) in updates" :key="index">
                <v-layout wrap>
                  <v-flex xs12 sm12 md4 class="pt-4 subheading">
                    <label class="right hidden-xs-only hidden-sm-only">You Tube Url:</label>
                    <label class="hidden-md-only hidden-lg-only hidden-xl-only">You Tube Url:</label>
f4df757fe   Neeraj Sharma   responsive vie in...
149
                  </v-flex>
68d742034   Neeraj Sharma   implement new des...
150
151
152
153
154
155
156
157
158
159
160
161
162
                  <v-layout>
                    <v-flex xs10 sm12 md9 class="ml-3">
                      <v-text-field
                        v-model="updateImage.youTubeLink"
                        label="Upload new you tube link url"
                        required
                      ></v-text-field>
                    </v-flex>
                    <v-flex xs2 class="pt-4">
                      <v-icon @click="deleteUpdate(index)" v-if="index !=0">cancel</v-icon>
                      <v-icon @click="update">add_circle</v-icon>
                    </v-flex>
                  </v-layout>
f4df757fe   Neeraj Sharma   responsive vie in...
163
                </v-layout>
68d742034   Neeraj Sharma   implement new des...
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
              </div>
            </v-flex>
            <v-layout>
              <v-flex xs12 sm12 md11 lg11>
                <v-card-actions class="hidden-xs-only hidden-sm-only">
                  <v-spacer></v-spacer>
                  <v-btn
                    round
                    dark
                    @click="save"
                    :loading="editGalleryLoading"
                    class="add-button mr-4"
                  >Save</v-btn>
                </v-card-actions>
                <v-card-actions class="hidden-md-only hidden-lg-only hidden-xl-only">
                  <v-spacer></v-spacer>
                  <v-btn
                    round
                    dark
                    @click="save"
                    :loading="editGalleryLoading"
                    class="add-button"
                  >Save</v-btn>
                  <v-spacer></v-spacer>
                </v-card-actions>
              </v-flex>
            </v-layout>
          </v-card-text>
        </v-card>
      </v-dialog>
  
      <!-- ****** PROFILE Gallery ******  -->
  
      <v-dialog v-model="viewProfileGallery" max-width="1000" scrollable>
        <v-card flat class="card-style pa-3" dark>
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">View Gallery</label>
              <v-icon size="24" class="right" @click="closeProfileGallery">cancel</v-icon>
            </v-flex>
          </v-layout>
          <v-card-text>
            <v-layout row wrap>
              <v-flex xs12 class="text-xs-center text-sm-center text-md-center text-lg-center my-4">
                <v-avatar size="100" v-if="editedItem.imageUrl == ''" class="mt-4 pa-2">
                  <img src="/static/icon/user.png" width="240" height="180" />
                </v-avatar>
                <span
                  v-for="(image,i) in editedItem.imageUrl"
                  :key="i"
                  class="mt-4 pa-2"
                  v-if="editedItem.imageUrl"
                >
                  <img :src="image.imageLink" alt="Gallery" width="240" height="180" class="imgNews" />
                </span>
              </v-flex>
            </v-layout>
            <v-container grid-list-md>
              <v-layout wrap>
f4df757fe   Neeraj Sharma   responsive vie in...
223
                <v-flex xs12>
68d742034   Neeraj Sharma   implement new des...
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
                  <v-layout>
                    <v-flex xs5 sm6>
                      <h5 class="right my-1">
                        <b>Title:</b>
                      </h5>
                    </v-flex>
                    <v-flex sm6 xs8>
                      <h5 class="my-1">{{ editedItem.title }}</h5>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs5 sm6>
                      <h5 class="right my-1">
                        <b>Description:</b>
                      </h5>
                    </v-flex>
                    <v-flex sm6 xs8>
                      <h5 class="my-1">{{ editedItem.description }}</h5>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs5 sm6>
                      <h5 class="right my-1">
                        <b>You Tube Link Url:</b>
                      </h5>
                    </v-flex>
                    <v-flex sm6 xs8>
                      <h5 class="my-1 ml-3">
                        <ul v-for="youTubeLinkUrl in editedItem.youTubeLinkUrl">
                          <li>{{ youTubeLinkUrl.youTubeLink }}</li>
                        </ul>
                      </h5>
                    </v-flex>
                  </v-layout>
                </v-flex>
              </v-layout>
            </v-container>
          </v-card-text>
        </v-card>
      </v-dialog>
  
      <!-- ****** Gallery TABLE ****** -->
  
      <v-toolbar color="transparent" flat>
        <v-btn
          fab
          dark
          class="open-dialog-button hidden-xl-only hidden-md-only hidden-lg-only"
          small
          @click="addGalleryDialog = true"
        >
          <v-icon dark>add</v-icon>
        </v-btn>
        <v-btn
          round
          class="open-dialog-button hidden-sm-only hidden-xs-only"
          dark
          @click="addGalleryDialog = true"
        >
          <v-icon class="white--text pr-1" size="20">add</v-icon>Add Gallery
        </v-btn>
        <v-spacer></v-spacer>
        <v-card-title class="body-1" v-show="show">
          <v-btn icon large flat @click="displaySearch">
            <v-avatar size="27">
aa310d61a   Shikha Mishra   added functionali...
289
              <img src="/static/icon/search.png" alt="icon" />
68d742034   Neeraj Sharma   implement new des...
290
291
292
            </v-avatar>
          </v-btn>
        </v-card-title>
612b79bb4   Amber Dev   made serch auto f...
293
        <v-flex xs8 sm8 md3 lg2 v-if="showSearch">
68d742034   Neeraj Sharma   implement new des...
294
          <v-layout>
8e8d14254   Shikha Mishra   Cleared data whil...
295
296
297
298
299
300
301
            <v-text-field
              autofocus
              v-model="search"
              label="Search"
              prepend-inner-icon="search"
              color="primary"
            ></v-text-field>
68d742034   Neeraj Sharma   implement new des...
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
            <v-icon @click="closeSearch" color="error">close</v-icon>
          </v-layout>
        </v-flex>
      </v-toolbar>
      <v-data-table
        :headers="headers"
        :items="desserts"
        :pagination.sync="pagination"
        :search="search"
      >
        <template slot="items" slot-scope="props">
          <tr class="tr">
            <td class="td td-row">{{ props.index + 1}}</td>
            <td class="td td-row text-xs-center">{{ props.item.title}}</td>
            <td class="td td-row text-xs-center">{{ props.item.description}}</td>
            <td class="td td-row text-xs-center">
              <span>
                <v-tooltip top>
                  <img
                    slot="activator"
                    style="cursor:pointer; width:25px; height:25px; "
                    class="mr-3"
                    @click="profile(props.item)"
aa310d61a   Shikha Mishra   added functionali...
325
                    src="/static/icon/view.png"
68d742034   Neeraj Sharma   implement new des...
326
327
328
329
330
331
332
333
334
                  />
                  <span>View</span>
                </v-tooltip>
                <v-tooltip top>
                  <img
                    slot="activator"
                    style="cursor:pointer; width:20px; height:18px; "
                    class="mr-3"
                    @click="editItem(props.item)"
aa310d61a   Shikha Mishra   added functionali...
335
                    src="/static/icon/edit.png"
68d742034   Neeraj Sharma   implement new des...
336
337
338
339
340
341
342
343
344
                  />
                  <span>Edit</span>
                </v-tooltip>
                <v-tooltip top>
                  <img
                    slot="activator"
                    style="cursor:pointer; width:20px; height:20px; "
                    class="mr-3"
                    @click="deleteItem(props.item)"
aa310d61a   Shikha Mishra   added functionali...
345
                    src="/static/icon/delete.png"
68d742034   Neeraj Sharma   implement new des...
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
                  />
                  <span>Delete</span>
                </v-tooltip>
              </span>
            </td>
          </tr>
        </template>
        <v-alert
          slot="no-results"
          :value="true"
          color="error"
          icon="warning"
        >Your search for "{{ search }}" found no results.</v-alert>
      </v-data-table>
      <!-- ****** ADD Gallery  ****** -->
8e8d14254   Shikha Mishra   Cleared data whil...
361
      <v-dialog v-model="addGalleryDialog" max-width="600px" v-if="addGalleryDialog">
68d742034   Neeraj Sharma   implement new des...
362
363
364
365
        <v-card flat class="card-style pa-2" dark>
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">Add Gallery</label>
8e8d14254   Shikha Mishra   Cleared data whil...
366
              <v-icon size="24" class="right" @click="closeAddGalleryModel">cancel</v-icon>
68d742034   Neeraj Sharma   implement new des...
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
            </v-flex>
          </v-layout>
          <v-form ref="form" v-model="valid" lazy-validation>
            <v-container fluid>
              <v-layout>
                <v-flex xs12 class="text-xs-center text-sm-center text-md-center text-lg-center">
                  <input
                    type="file"
                    style="display: none"
                    ref="image"
                    accept="image/*"
                    multiple
                    @change="onFilePicked"
                  />
                  <v-layout justify-center>
                    <v-flex v-for="(file,index) in files" :key="index" v-if="files">
                      <img :src="file" height="150" width="150" />
                    </v-flex>
                  </v-layout>
                  <img src="/static/icon/user.png" v-if="files ==''" height="100" width="100;" />
f4df757fe   Neeraj Sharma   responsive vie in...
387
                </v-flex>
68d742034   Neeraj Sharma   implement new des...
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
              </v-layout>
              <v-flex xs12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Title:</label>
                  </v-flex>
                  <v-flex xs8 sm8 md7 class="ml-3">
                    <v-text-field
                      v-model="addGallery.title"
                      placeholder="fill your Title"
                      name="name"
                      type="text"
                      :rules="titleRules"
                      required
                    ></v-text-field>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Description:</label>
                  </v-flex>
                  <v-flex xs8 sm8 md7 class="ml-3">
                    <v-text-field
                      placeholder="fill your Description"
                      :rules="descriptionRules"
                      v-model="addGallery.description"
                      type="text"
                      name="email"
                      required
                    ></v-text-field>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right hidden-xs-only hidden-sm-only">Select Class:</label>
                    <label class="right hidden-lg-only hidden-md-only hidden-xl-only">Class:</label>
                  </v-flex>
                  <v-flex xs8 sm8 md7 class="ml-3">
                    <v-select
                      :items="addclass"
                      label="Select Class"
                      v-model="addGallery.classNum"
                      item-text="classNum"
                      item-value="_id"
                      name="Select Class"
                      required
                    ></v-select>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right hidden-xs-only hidden-sm-only">Uplaod Image:</label>
                    <label class="right hidden-lg-only hidden-md-only hidden-xl-only">Uplaod:</label>
                  </v-flex>
                  <v-flex xs8 sm8 md7 class="ml-3">
                    <v-text-field
                      label="Select Image"
                      @click="pickFile"
                      v-model="imageName"
                      append-icon="attach_file"
                      multiple
                    ></v-text-field>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-layout>
f4df757fe   Neeraj Sharma   responsive vie in...
460
                <v-flex xs12>
68d742034   Neeraj Sharma   implement new des...
461
                  <div v-for="(youTubeLink,index) in finds" :key="index">
f4df757fe   Neeraj Sharma   responsive vie in...
462
463
464
465
                    <v-layout>
                      <v-flex xs4 class="pt-4 subheading">
                        <label class="right">You Tube Url:</label>
                      </v-flex>
68d742034   Neeraj Sharma   implement new des...
466
                      <v-flex xs8 sm8 md6 class="ml-3">
f4df757fe   Neeraj Sharma   responsive vie in...
467
                        <v-text-field
68d742034   Neeraj Sharma   implement new des...
468
469
470
471
                          placeholder="fill your youtube link"
                          v-model="youTubeLink.value"
                          type="text"
                          name="link"
f4df757fe   Neeraj Sharma   responsive vie in...
472
473
474
475
                          required
                        ></v-text-field>
                      </v-flex>
                      <v-flex xs2 class="pt-4">
68d742034   Neeraj Sharma   implement new des...
476
477
                        <v-icon @click="deleteFind(index)" v-if="index !=0 ">cancel</v-icon>
                        <v-icon @click="addFind">add_circle</v-icon>
f4df757fe   Neeraj Sharma   responsive vie in...
478
479
480
481
                      </v-flex>
                    </v-layout>
                  </div>
                </v-flex>
68d742034   Neeraj Sharma   implement new des...
482
483
484
485
486
487
              </v-layout>
              <v-layout>
                <v-flex xs12 sm12>
                  <v-layout class="right">
                    <v-btn @click="clear" round dark class="clear-button">Clear</v-btn>
                    <v-btn @click="submit" round dark :loading="loading" class="add-button">Add</v-btn>
8bb178441   Neeraj Sharma   implemnt api in s...
488
                  </v-layout>
68d742034   Neeraj Sharma   implement new des...
489
490
491
492
493
494
495
496
497
498
499
500
501
502
                </v-flex>
              </v-layout>
            </v-container>
          </v-form>
        </v-card>
      </v-dialog>
      <v-snackbar
        :timeout="timeout"
        :top="y === 'top'"
        :right="x === 'right'"
        :vertical="mode === 'vertical'"
        v-model="snackbar"
        :color="color"
      >{{ text }}</v-snackbar>
8bb178441   Neeraj Sharma   implemnt api in s...
503
504
505
      <div class="loader" v-if="showLoader">
        <v-progress-circular indeterminate color="white"></v-progress-circular>
      </div>
68d742034   Neeraj Sharma   implement new des...
506
    </v-container>
8bb178441   Neeraj Sharma   implemnt api in s...
507
508
509
510
  </template>
  
  <script>
  import http from "@/Services/http.js";
8bb178441   Neeraj Sharma   implemnt api in s...
511
512
513
514
515
516
517
518
519
520
  
  export default {
    data: () => ({
      snackbar: false,
      y: "top",
      x: "right",
      mode: "",
      timeout: 3000,
      text: "",
      loading: false,
68d742034   Neeraj Sharma   implement new des...
521
      color: "",
8bb178441   Neeraj Sharma   implemnt api in s...
522
523
      date: null,
      search: "",
68d742034   Neeraj Sharma   implement new des...
524
525
526
      show: true,
      addGalleryDialog: false,
      showSearch: false,
8bb178441   Neeraj Sharma   implemnt api in s...
527
      showLoader: false,
68d742034   Neeraj Sharma   implement new des...
528
529
      editGalleryDialog: false,
      viewProfileGallery: false,
8bb178441   Neeraj Sharma   implemnt api in s...
530
      valid: true,
c39f609df   Neeraj Sharma   fixed validation ...
531
      editGalleryLoading: false,
8bb178441   Neeraj Sharma   implemnt api in s...
532
533
534
      addclass: [],
      addSection: [],
      finds: [{ value: "" }],
a17c68a03   Neeraj Sharma   implement two rou...
535
536
      updates: [{ youTubeLink: "" }],
      youTubeLink: {},
8bb178441   Neeraj Sharma   implemnt api in s...
537
      addGallery: {
8e8d14254   Shikha Mishra   Cleared data whil...
538
        youTubeLinkUrl: [],
8bb178441   Neeraj Sharma   implemnt api in s...
539
540
      },
      pagination: {
8e8d14254   Shikha Mishra   Cleared data whil...
541
        rowsPerPage: 10,
8bb178441   Neeraj Sharma   implemnt api in s...
542
543
544
545
546
547
      },
      imageName: "",
      imageUrl: "",
      imageFile: "",
      image: [],
      upload: "",
a17c68a03   Neeraj Sharma   implement two rou...
548
549
      editImageName: "",
      editFiles: [],
8bb178441   Neeraj Sharma   implemnt api in s...
550
      files: [],
8bb178441   Neeraj Sharma   implemnt api in s...
551
      token: "",
8e8d14254   Shikha Mishra   Cleared data whil...
552
553
      titleRules: [(v) => !!v || " Tilte is required"],
      descriptionRules: [(v) => !!v || " Description is required"],
8bb178441   Neeraj Sharma   implemnt api in s...
554
555
      headers: [
        {
68d742034   Neeraj Sharma   implement new des...
556
          align: "",
8bb178441   Neeraj Sharma   implemnt api in s...
557
558
          text: "No",
          sortable: false,
8e8d14254   Shikha Mishra   Cleared data whil...
559
          value: "index",
8bb178441   Neeraj Sharma   implemnt api in s...
560
        },
8bb178441   Neeraj Sharma   implemnt api in s...
561
562
563
564
565
        { text: "Title", value: "title", sortable: false, align: "center" },
        {
          text: "Description",
          value: "description",
          sortable: false,
8e8d14254   Shikha Mishra   Cleared data whil...
566
          align: "center",
8bb178441   Neeraj Sharma   implemnt api in s...
567
        },
8e8d14254   Shikha Mishra   Cleared data whil...
568
        { text: "Action", value: "", sortable: false, align: "center" },
8bb178441   Neeraj Sharma   implemnt api in s...
569
570
571
      ],
      desserts: [],
      editedIndex: -1,
1571e40b5   Neeraj Sharma   gallery and socia...
572
      editedItem: {},
8e8d14254   Shikha Mishra   Cleared data whil...
573
      index: "",
8bb178441   Neeraj Sharma   implemnt api in s...
574
    }),
8e8d14254   Shikha Mishra   Cleared data whil...
575
576
577
578
579
580
581
582
583
584
585
586
    watch: {
      addGalleryDialog: function (val) {
        if (!val) {
          this.addGallery = [];
          this.imageName = "";
          this.youTubeLinkUrl = [];
          this.youTubeLink = {};
          this.index = "";
          this.files = [];
        }
      },
    },
8bb178441   Neeraj Sharma   implemnt api in s...
587
    methods: {
8bb178441   Neeraj Sharma   implemnt api in s...
588
589
590
      pickFile() {
        this.$refs.image.click();
      },
a17c68a03   Neeraj Sharma   implement two rou...
591
592
593
      editPickFile() {
        this.$refs.editImage.click();
      },
8bb178441   Neeraj Sharma   implemnt api in s...
594
      onFilePicked(e) {
8bb178441   Neeraj Sharma   implemnt api in s...
595
596
597
598
599
600
601
602
603
604
605
606
        const files = e.target.files;
        /** fetch Image Name **/
        if (files[0] !== undefined) {
          this.imageName = files[0].name;
          if (this.imageName.lastIndexOf(".") <= 0) {
            return;
          }
          this.files = [];
          // console.log("files", this.files);
          /** Select many image and showing many image add to Gallery card **/
          const test = Array.from(files).forEach((file, idx) => {
            const fr = new FileReader();
8e8d14254   Shikha Mishra   Cleared data whil...
607
608
            const getResult = new Promise((resolve) => {
              fr.onload = (e) => {
8bb178441   Neeraj Sharma   implemnt api in s...
609
610
611
612
613
                this.files.push(
                  // id: idx,
                  e.target.result
                );
              };
a17c68a03   Neeraj Sharma   implement two rou...
614
              console.log("uploadImage=======>", this.files);
8bb178441   Neeraj Sharma   implemnt api in s...
615
616
            });
            fr.readAsDataURL(file);
8e8d14254   Shikha Mishra   Cleared data whil...
617
            return getResult.then((file) => {
8bb178441   Neeraj Sharma   implemnt api in s...
618
619
620
621
622
623
624
              return file;
            });
          });
          const fr = new FileReader();
          fr.readAsDataURL(files[0]);
          fr.addEventListener("load", () => {
            this.imageFile = files; // this is an image file that can be sent to server...
8bb178441   Neeraj Sharma   implemnt api in s...
625
626
627
628
629
630
631
          });
        } else {
          this.imageName = "";
          this.imageFile = "";
          this.imageUrl = "";
        }
      },
a17c68a03   Neeraj Sharma   implement two rou...
632
633
634
635
636
637
638
639
640
641
642
      editFilePicked(e) {
        const files = e.target.files;
        /** fetch Image Name **/
        if (files[0] !== undefined) {
          this.editImageName = files[0].name;
          if (this.editImageName.lastIndexOf(".") <= 0) {
            return;
          }
          /** Select many image and showing many image add to Gallery card **/
          const test = Array.from(files).forEach((file, idx) => {
            const fr = new FileReader();
8e8d14254   Shikha Mishra   Cleared data whil...
643
644
            const getResult = new Promise((resolve) => {
              fr.onload = (e) => {
a17c68a03   Neeraj Sharma   implement two rou...
645
646
647
648
649
                this.editFiles.push(
                  // id: idx,
                  e.target.result
                );
              };
c39f609df   Neeraj Sharma   fixed validation ...
650
              console.log("uploadeditFilesImage=======>", this.editFiles);
a17c68a03   Neeraj Sharma   implement two rou...
651
652
            });
            fr.readAsDataURL(file);
8e8d14254   Shikha Mishra   Cleared data whil...
653
            return getResult.then((file) => {
a17c68a03   Neeraj Sharma   implement two rou...
654
655
656
657
658
659
660
661
662
663
              return file;
            });
          });
          const fr = new FileReader();
          fr.readAsDataURL(files[0]);
          // fr.addEventListener("load", () => {
          //   this.imageFile = files; // this is an image file that can be sent to server...
          // });
        } else {
          this.editImageName = "";
c39f609df   Neeraj Sharma   fixed validation ...
664
          this.editFiles = [];
a17c68a03   Neeraj Sharma   implement two rou...
665
666
        }
      },
8bb178441   Neeraj Sharma   implemnt api in s...
667
668
669
670
      getGalleryList() {
        this.showLoader = true;
        http()
          .get("/getGalleryList", {
8e8d14254   Shikha Mishra   Cleared data whil...
671
            headers: { Authorization: "Bearer " + this.token },
8bb178441   Neeraj Sharma   implemnt api in s...
672
          })
8e8d14254   Shikha Mishra   Cleared data whil...
673
          .then((response) => {
8bb178441   Neeraj Sharma   implemnt api in s...
674
675
676
            this.desserts = response.data.data;
            this.showLoader = false;
          })
8e8d14254   Shikha Mishra   Cleared data whil...
677
          .catch((error) => {
8bb178441   Neeraj Sharma   implemnt api in s...
678
679
            // console.log("err====>", err);
            this.showLoader = false;
a17c68a03   Neeraj Sharma   implement two rou...
680
681
682
683
684
            if (error.response.status === 401) {
              this.$router.replace({ path: "/" });
              this.$store.dispatch("setToken", null);
              this.$store.dispatch("Id", null);
            }
8bb178441   Neeraj Sharma   implemnt api in s...
685
686
687
688
689
690
          });
      },
      editItem(item) {
        this.files = [];
        this.editedIndex = this.desserts.indexOf(item);
        this.editedItem = Object.assign({}, item);
68d742034   Neeraj Sharma   implement new des...
691
        this.editGalleryDialog = true;
8bb178441   Neeraj Sharma   implemnt api in s...
692
693
694
695
      },
      profile(item) {
        this.editedIndex = this.desserts.indexOf(item);
        this.editedItem = Object.assign({}, item);
68d742034   Neeraj Sharma   implement new des...
696
        this.viewProfileGallery = true;
8bb178441   Neeraj Sharma   implemnt api in s...
697
698
699
      },
      deleteItem(item) {
        let deleteGallery = {
8e8d14254   Shikha Mishra   Cleared data whil...
700
          galleryId: item._id,
8bb178441   Neeraj Sharma   implemnt api in s...
701
702
703
        };
        http()
          .delete(
a17c68a03   Neeraj Sharma   implement two rou...
704
            "/deleteGallery",
8bb178441   Neeraj Sharma   implemnt api in s...
705
            confirm("Are you sure you want to delete this?") && {
a17c68a03   Neeraj Sharma   implement two rou...
706
707
              params: deleteGallery,
              headers: {
8e8d14254   Shikha Mishra   Cleared data whil...
708
709
                Authorization: "Bearer " + this.token,
              },
8bb178441   Neeraj Sharma   implemnt api in s...
710
711
            }
          )
8e8d14254   Shikha Mishra   Cleared data whil...
712
          .then((response) => {
c39f609df   Neeraj Sharma   fixed validation ...
713
714
            this.snackbar = true;
            this.text = "Successfully delete Existing Gallery";
68d742034   Neeraj Sharma   implement new des...
715
            this.color = "green";
a17c68a03   Neeraj Sharma   implement two rou...
716
            this.getGalleryList();
8bb178441   Neeraj Sharma   implemnt api in s...
717
          })
8e8d14254   Shikha Mishra   Cleared data whil...
718
          .catch((error) => {
8bb178441   Neeraj Sharma   implemnt api in s...
719
            // console.log(error);
c39f609df   Neeraj Sharma   fixed validation ...
720
721
            this.snackbar = true;
            this.text = error.response.data.message;
68d742034   Neeraj Sharma   implement new des...
722
            this.color = "error";
8bb178441   Neeraj Sharma   implemnt api in s...
723
724
          });
      },
a17c68a03   Neeraj Sharma   implement two rou...
725
      deleteImage(imageId, id) {
8bb178441   Neeraj Sharma   implemnt api in s...
726
        let deleteImages = {
a17c68a03   Neeraj Sharma   implement two rou...
727
          galleryId: id,
8e8d14254   Shikha Mishra   Cleared data whil...
728
          imageId: imageId,
8bb178441   Neeraj Sharma   implemnt api in s...
729
730
        };
        http()
a17c68a03   Neeraj Sharma   implement two rou...
731
          .put("/deleteImage", deleteImages)
8e8d14254   Shikha Mishra   Cleared data whil...
732
          .then((response) => {
a17c68a03   Neeraj Sharma   implement two rou...
733
734
            this.snackbar = true;
            this.text = response.data.message;
68d742034   Neeraj Sharma   implement new des...
735
            this.color = "green";
a17c68a03   Neeraj Sharma   implement two rou...
736
            this.getGalleryList();
8bb178441   Neeraj Sharma   implemnt api in s...
737
738
            this.close();
          })
8e8d14254   Shikha Mishra   Cleared data whil...
739
          .catch((error) => {
68d742034   Neeraj Sharma   implement new des...
740
741
742
            this.snackbar = true;
            this.text = error.response.data.message;
            this.color = "error";
8bb178441   Neeraj Sharma   implemnt api in s...
743
744
          });
      },
8bb178441   Neeraj Sharma   implemnt api in s...
745
      close() {
68d742034   Neeraj Sharma   implement new des...
746
        this.editGalleryDialog = false;
8bb178441   Neeraj Sharma   implemnt api in s...
747
      },
68d742034   Neeraj Sharma   implement new des...
748
749
      closeProfileGallery() {
        this.viewProfileGallery = false;
8bb178441   Neeraj Sharma   implemnt api in s...
750
      },
8e8d14254   Shikha Mishra   Cleared data whil...
751
752
753
754
755
756
757
758
759
      closeAddGalleryModel() {
        this.addGalleryDialog = false;
        this.addGallery = [];
        this.imageName = "";
        this.youTubeLinkUrl = [];
        this.youTubeLink = {};
        this.index = "";
        this.files = [];
      },
8bb178441   Neeraj Sharma   implemnt api in s...
760
      submit() {
a17c68a03   Neeraj Sharma   implement two rou...
761
762
763
        for (let i = 0; i < this.finds.length; i++) {
          this.addGallery.youTubeLinkUrl.push(this.finds[i].value);
        }
8bb178441   Neeraj Sharma   implemnt api in s...
764
765
766
767
768
769
770
771
772
773
774
        if (this.$refs.form.validate()) {
          if (this.files) {
            var ary = [];
            var imageData = [];
            ary = this.files;
            for (let i = 0; i < ary.length; i++) {
              const [baseUrl, imageUrl] = ary[i].split(/,/);
              imageData.push(imageUrl);
              this.addGallery.upload = imageData;
            }
          }
2ddcef1ce   Neeraj Sharma   solve issue empty...
775
776
777
778
779
          if (this.addGallery.youTubeLinkUrl == "") {
            var galleryData = {
              classId: this.addGallery.classNum,
              title: this.addGallery.title,
              description: this.addGallery.description,
8e8d14254   Shikha Mishra   Cleared data whil...
780
              upload: this.addGallery.upload,
2ddcef1ce   Neeraj Sharma   solve issue empty...
781
            };
895062f9a   Neeraj Sharma   add loader on sub...
782
            this.loading = true;
2ddcef1ce   Neeraj Sharma   solve issue empty...
783
784
            http()
              .post("/createGallery", galleryData)
8e8d14254   Shikha Mishra   Cleared data whil...
785
              .then((response) => {
2ddcef1ce   Neeraj Sharma   solve issue empty...
786
                this.getGalleryList();
fe0d05d29   Neeraj Sharma   complete design a...
787
                this.addGalleryDialog = false;
2ddcef1ce   Neeraj Sharma   solve issue empty...
788
789
790
                this.loading = false;
                this.snackbar = true;
                this.text = response.data.message;
68d742034   Neeraj Sharma   implement new des...
791
                this.color = "green";
2ddcef1ce   Neeraj Sharma   solve issue empty...
792
793
794
                this.clear();
                this.files = "";
              })
8e8d14254   Shikha Mishra   Cleared data whil...
795
              .catch((error) => {
c39f609df   Neeraj Sharma   fixed validation ...
796
797
                this.snackbar = true;
                this.text = error.response.data.message;
68d742034   Neeraj Sharma   implement new des...
798
                this.color = "error";
c39f609df   Neeraj Sharma   fixed validation ...
799
                this.loading = false;
2ddcef1ce   Neeraj Sharma   solve issue empty...
800
801
              });
          } else if (this.addGallery.youTubeLinkUrl) {
895062f9a   Neeraj Sharma   add loader on sub...
802
            this.loading = true;
2ddcef1ce   Neeraj Sharma   solve issue empty...
803
804
            http()
              .post("/createGallery", this.addGallery)
8e8d14254   Shikha Mishra   Cleared data whil...
805
              .then((response) => {
2ddcef1ce   Neeraj Sharma   solve issue empty...
806
                this.getGalleryList();
fe0d05d29   Neeraj Sharma   complete design a...
807
808
                this.addGalleryDialog = false;
                this.files = "nmn";
2ddcef1ce   Neeraj Sharma   solve issue empty...
809
810
                this.loading = false;
                this.snackbar = true;
68d742034   Neeraj Sharma   implement new des...
811
                this.color = "green";
2ddcef1ce   Neeraj Sharma   solve issue empty...
812
813
                this.text = response.data.message;
                this.clear();
fe0d05d29   Neeraj Sharma   complete design a...
814
                this.removeAddFind();
2ddcef1ce   Neeraj Sharma   solve issue empty...
815
816
                this.files = "";
              })
8e8d14254   Shikha Mishra   Cleared data whil...
817
              .catch((error) => {
895062f9a   Neeraj Sharma   add loader on sub...
818
819
820
                this.snackbar = true;
                this.text = error.response.data.message;
                this.loading = false;
68d742034   Neeraj Sharma   implement new des...
821
                this.color = "error";
2ddcef1ce   Neeraj Sharma   solve issue empty...
822
823
              });
          }
8bb178441   Neeraj Sharma   implemnt api in s...
824
825
826
827
        }
      },
      clear() {
        this.$refs.form.reset();
0551a0f15   Neeraj Sharma   implemnet functio...
828
        this.files = [];
8bb178441   Neeraj Sharma   implemnt api in s...
829
830
831
      },
      save() {
        this.editedItem.gelleryId = this.editedItem._id;
1571e40b5   Neeraj Sharma   gallery and socia...
832
        var linkUrl = [];
a17c68a03   Neeraj Sharma   implement two rou...
833
        for (let i = 0; i < this.updates.length; i++) {
1571e40b5   Neeraj Sharma   gallery and socia...
834
          linkUrl.push(this.updates[i].youTubeLink);
a17c68a03   Neeraj Sharma   implement two rou...
835
        }
1571e40b5   Neeraj Sharma   gallery and socia...
836
        if (this.editFiles) {
8bb178441   Neeraj Sharma   implemnt api in s...
837
838
          var ary = [];
          var imageData = [];
1571e40b5   Neeraj Sharma   gallery and socia...
839
          ary = this.editFiles;
8bb178441   Neeraj Sharma   implemnt api in s...
840
841
842
          for (let i = 0; i < ary.length; i++) {
            const [baseUrl, imageUrl] = ary[i].split(/,/);
            imageData.push(imageUrl);
1571e40b5   Neeraj Sharma   gallery and socia...
843
            this.editedItem.editFiles = imageData;
8bb178441   Neeraj Sharma   implemnt api in s...
844
845
          }
        }
1571e40b5   Neeraj Sharma   gallery and socia...
846
847
848
849
850
851
852
        if (linkUrl != "") {
          var updateData = {
            galleryId: this.editedItem._id,
            description: this.editedItem.description,
            classId: this.editedItem.classNum,
            uploadImage: this.editedItem.editFiles,
            title: this.editedItem.title,
8e8d14254   Shikha Mishra   Cleared data whil...
853
            updateYouTubeLinkUrl: linkUrl,
1571e40b5   Neeraj Sharma   gallery and socia...
854
855
856
857
858
859
860
          };
        } else if (linkUrl == "") {
          var updateData = {
            galleryId: this.editedItem._id,
            description: this.editedItem.description,
            classId: this.editedItem.classNum,
            uploadImage: this.editedItem.editFiles,
8e8d14254   Shikha Mishra   Cleared data whil...
861
            title: this.editedItem.title,
1571e40b5   Neeraj Sharma   gallery and socia...
862
863
          };
        }
c39f609df   Neeraj Sharma   fixed validation ...
864
        this.editGalleryLoading = true;
1571e40b5   Neeraj Sharma   gallery and socia...
865
866
        http()
          .put("/updateGallery", updateData)
8e8d14254   Shikha Mishra   Cleared data whil...
867
          .then((response) => {
1571e40b5   Neeraj Sharma   gallery and socia...
868
869
870
871
            this.getGalleryList();
            this.close();
            this.snackbar = true;
            this.text = response.data.message;
68d742034   Neeraj Sharma   implement new des...
872
            this.color = "green";
c39f609df   Neeraj Sharma   fixed validation ...
873
            this.editGalleryLoading = false;
fe0d05d29   Neeraj Sharma   complete design a...
874
875
            this.editImageName = "";
            this.editFiles = [];
1571e40b5   Neeraj Sharma   gallery and socia...
876
          })
8e8d14254   Shikha Mishra   Cleared data whil...
877
          .catch((error) => {
c39f609df   Neeraj Sharma   fixed validation ...
878
879
880
            this.editGalleryLoading = false;
            this.snackbar = true;
            this.text = error.response.data.message;
68d742034   Neeraj Sharma   implement new des...
881
            this.color = "error";
1571e40b5   Neeraj Sharma   gallery and socia...
882
          });
8bb178441   Neeraj Sharma   implemnt api in s...
883
884
885
886
      },
      getAllClasses() {
        http()
          .get("/getClassesList", {
8e8d14254   Shikha Mishra   Cleared data whil...
887
            headers: { Authorization: "Bearer " + this.token },
8bb178441   Neeraj Sharma   implemnt api in s...
888
          })
8e8d14254   Shikha Mishra   Cleared data whil...
889
          .then((response) => {
8bb178441   Neeraj Sharma   implemnt api in s...
890
891
            this.addclass = response.data.data;
          })
8e8d14254   Shikha Mishra   Cleared data whil...
892
          .catch((err) => {
8bb178441   Neeraj Sharma   implemnt api in s...
893
            // console.log("err====>", err);
8bb178441   Neeraj Sharma   implemnt api in s...
894
895
          });
      },
8e8d14254   Shikha Mishra   Cleared data whil...
896
      removeAddFind: function () {
fe0d05d29   Neeraj Sharma   complete design a...
897
898
        this.finds = [{ value: "" }];
      },
8e8d14254   Shikha Mishra   Cleared data whil...
899
      addFind: function () {
8bb178441   Neeraj Sharma   implemnt api in s...
900
901
        this.finds.push({ value: "" });
      },
8e8d14254   Shikha Mishra   Cleared data whil...
902
      update: function () {
a17c68a03   Neeraj Sharma   implement two rou...
903
904
        this.updates.push({ youTubeLink: "" });
      },
8e8d14254   Shikha Mishra   Cleared data whil...
905
      deleteFind: function (index) {
8bb178441   Neeraj Sharma   implemnt api in s...
906
907
        this.finds.splice(index, 1);
        if (index === 0) this.addFind();
a17c68a03   Neeraj Sharma   implement two rou...
908
      },
8e8d14254   Shikha Mishra   Cleared data whil...
909
      deleteUpdate: function (index) {
a17c68a03   Neeraj Sharma   implement two rou...
910
911
912
        this.updates.splice(index, 1);
        if (index === 0) this.update();
      },
8e8d14254   Shikha Mishra   Cleared data whil...
913
      deleteUrl: function (index, youTubelinkId, id) {
a17c68a03   Neeraj Sharma   implement two rou...
914
915
        this.editedItem.youTubeLinkUrl.splice(index, 1);
        if (index === 0) this.update();
a17c68a03   Neeraj Sharma   implement two rou...
916
917
        let deleteYouTubeUrl = {
          galleryId: id,
8e8d14254   Shikha Mishra   Cleared data whil...
918
          youTubeId: youTubelinkId,
a17c68a03   Neeraj Sharma   implement two rou...
919
920
921
        };
        http()
          .put("/deleteYoutubeLink", deleteYouTubeUrl)
8e8d14254   Shikha Mishra   Cleared data whil...
922
          .then((response) => {
a17c68a03   Neeraj Sharma   implement two rou...
923
924
            this.snackbar = true;
            this.text = response.data.message;
68d742034   Neeraj Sharma   implement new des...
925
            this.color = "green";
a17c68a03   Neeraj Sharma   implement two rou...
926
927
928
            this.getGalleryList();
            this.close();
          })
8e8d14254   Shikha Mishra   Cleared data whil...
929
          .catch((error) => {
68d742034   Neeraj Sharma   implement new des...
930
931
932
            this.snackbar = true;
            this.text = error.response.data.message;
            this.color = "error";
a17c68a03   Neeraj Sharma   implement two rou...
933
          });
68d742034   Neeraj Sharma   implement new des...
934
935
      },
      displaySearch() {
fe0d05d29   Neeraj Sharma   complete design a...
936
937
        this.show = false;
        this.showSearch = true;
68d742034   Neeraj Sharma   implement new des...
938
939
940
941
942
      },
      closeSearch() {
        this.showSearch = false;
        this.show = true;
        this.search = "";
8e8d14254   Shikha Mishra   Cleared data whil...
943
      },
8bb178441   Neeraj Sharma   implemnt api in s...
944
945
946
947
948
    },
    mounted() {
      this.token = this.$store.state.token;
      this.getAllClasses();
      this.getGalleryList();
8e8d14254   Shikha Mishra   Cleared data whil...
949
    },
8bb178441   Neeraj Sharma   implemnt api in s...
950
  };
68d742034   Neeraj Sharma   implement new des...
951
  </script>