Blame view

src/pages/Gallery/gallery.vue 30.4 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>
612b79bb4   Amber Dev   made serch auto f...
295
            <v-text-field autofocus  v-model="search" label="Search" prepend-inner-icon="search" color="primary"></v-text-field>
68d742034   Neeraj Sharma   implement new des...
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
            <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...
319
                    src="/static/icon/view.png"
68d742034   Neeraj Sharma   implement new des...
320
321
322
323
324
325
326
327
328
                  />
                  <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...
329
                    src="/static/icon/edit.png"
68d742034   Neeraj Sharma   implement new des...
330
331
332
333
334
335
336
337
338
                  />
                  <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...
339
                    src="/static/icon/delete.png"
68d742034   Neeraj Sharma   implement new des...
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
                  />
                  <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  ****** -->
      <v-dialog v-model="addGalleryDialog" max-width="600px">
        <v-card flat class="card-style pa-2" dark>
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">Add Gallery</label>
              <v-icon size="24" class="right" @click="addGalleryDialog = false">cancel</v-icon>
            </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...
381
                </v-flex>
68d742034   Neeraj Sharma   implement new des...
382
383
384
385
386
387
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
              </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...
454
                <v-flex xs12>
68d742034   Neeraj Sharma   implement new des...
455
                  <div v-for="(youTubeLink,index) in finds" :key="index">
f4df757fe   Neeraj Sharma   responsive vie in...
456
457
458
459
                    <v-layout>
                      <v-flex xs4 class="pt-4 subheading">
                        <label class="right">You Tube Url:</label>
                      </v-flex>
68d742034   Neeraj Sharma   implement new des...
460
                      <v-flex xs8 sm8 md6 class="ml-3">
f4df757fe   Neeraj Sharma   responsive vie in...
461
                        <v-text-field
68d742034   Neeraj Sharma   implement new des...
462
463
464
465
                          placeholder="fill your youtube link"
                          v-model="youTubeLink.value"
                          type="text"
                          name="link"
f4df757fe   Neeraj Sharma   responsive vie in...
466
467
468
469
                          required
                        ></v-text-field>
                      </v-flex>
                      <v-flex xs2 class="pt-4">
68d742034   Neeraj Sharma   implement new des...
470
471
                        <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...
472
473
474
475
                      </v-flex>
                    </v-layout>
                  </div>
                </v-flex>
68d742034   Neeraj Sharma   implement new des...
476
477
478
479
480
481
              </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...
482
                  </v-layout>
68d742034   Neeraj Sharma   implement new des...
483
484
485
486
487
488
489
490
491
492
493
494
495
496
                </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...
497
498
499
      <div class="loader" v-if="showLoader">
        <v-progress-circular indeterminate color="white"></v-progress-circular>
      </div>
68d742034   Neeraj Sharma   implement new des...
500
    </v-container>
8bb178441   Neeraj Sharma   implemnt api in s...
501
502
503
504
  </template>
  
  <script>
  import http from "@/Services/http.js";
8bb178441   Neeraj Sharma   implemnt api in s...
505
506
507
508
509
510
511
512
513
514
  
  export default {
    data: () => ({
      snackbar: false,
      y: "top",
      x: "right",
      mode: "",
      timeout: 3000,
      text: "",
      loading: false,
68d742034   Neeraj Sharma   implement new des...
515
      color: "",
8bb178441   Neeraj Sharma   implemnt api in s...
516
517
      date: null,
      search: "",
68d742034   Neeraj Sharma   implement new des...
518
519
520
      show: true,
      addGalleryDialog: false,
      showSearch: false,
8bb178441   Neeraj Sharma   implemnt api in s...
521
      showLoader: false,
68d742034   Neeraj Sharma   implement new des...
522
523
      editGalleryDialog: false,
      viewProfileGallery: false,
8bb178441   Neeraj Sharma   implemnt api in s...
524
      valid: true,
c39f609df   Neeraj Sharma   fixed validation ...
525
      editGalleryLoading: false,
8bb178441   Neeraj Sharma   implemnt api in s...
526
527
528
      addclass: [],
      addSection: [],
      finds: [{ value: "" }],
a17c68a03   Neeraj Sharma   implement two rou...
529
530
      updates: [{ youTubeLink: "" }],
      youTubeLink: {},
8bb178441   Neeraj Sharma   implemnt api in s...
531
532
533
534
      addGallery: {
        youTubeLinkUrl: []
      },
      pagination: {
68d742034   Neeraj Sharma   implement new des...
535
        rowsPerPage: 10
8bb178441   Neeraj Sharma   implemnt api in s...
536
537
538
539
540
541
      },
      imageName: "",
      imageUrl: "",
      imageFile: "",
      image: [],
      upload: "",
a17c68a03   Neeraj Sharma   implement two rou...
542
543
      editImageName: "",
      editFiles: [],
8bb178441   Neeraj Sharma   implemnt api in s...
544
      files: [],
8bb178441   Neeraj Sharma   implemnt api in s...
545
546
547
548
549
      token: "",
      titleRules: [v => !!v || " Tilte is required"],
      descriptionRules: [v => !!v || " Description is required"],
      headers: [
        {
68d742034   Neeraj Sharma   implement new des...
550
          align: "",
8bb178441   Neeraj Sharma   implemnt api in s...
551
552
          text: "No",
          sortable: false,
1571e40b5   Neeraj Sharma   gallery and socia...
553
          value: "index"
8bb178441   Neeraj Sharma   implemnt api in s...
554
        },
8bb178441   Neeraj Sharma   implemnt api in s...
555
556
557
558
559
560
561
562
563
564
565
        { text: "Title", value: "title", sortable: false, align: "center" },
        {
          text: "Description",
          value: "description",
          sortable: false,
          align: "center"
        },
        { text: "Action", value: "", sortable: false, align: "center" }
      ],
      desserts: [],
      editedIndex: -1,
1571e40b5   Neeraj Sharma   gallery and socia...
566
567
      editedItem: {},
      index: ""
8bb178441   Neeraj Sharma   implemnt api in s...
568
569
    }),
    methods: {
8bb178441   Neeraj Sharma   implemnt api in s...
570
571
572
      pickFile() {
        this.$refs.image.click();
      },
a17c68a03   Neeraj Sharma   implement two rou...
573
574
575
      editPickFile() {
        this.$refs.editImage.click();
      },
8bb178441   Neeraj Sharma   implemnt api in s...
576
      onFilePicked(e) {
8bb178441   Neeraj Sharma   implemnt api in s...
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
        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();
            const getResult = new Promise(resolve => {
              fr.onload = e => {
                this.files.push(
                  // id: idx,
                  e.target.result
                );
              };
a17c68a03   Neeraj Sharma   implement two rou...
596
              console.log("uploadImage=======>", this.files);
8bb178441   Neeraj Sharma   implemnt api in s...
597
598
599
600
601
602
603
604
605
606
            });
            fr.readAsDataURL(file);
            return getResult.then(file => {
              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...
607
608
609
610
611
612
613
          });
        } else {
          this.imageName = "";
          this.imageFile = "";
          this.imageUrl = "";
        }
      },
a17c68a03   Neeraj Sharma   implement two rou...
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
      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();
            const getResult = new Promise(resolve => {
              fr.onload = e => {
                this.editFiles.push(
                  // id: idx,
                  e.target.result
                );
              };
c39f609df   Neeraj Sharma   fixed validation ...
632
              console.log("uploadeditFilesImage=======>", this.editFiles);
a17c68a03   Neeraj Sharma   implement two rou...
633
634
635
636
637
638
639
640
641
642
643
644
645
            });
            fr.readAsDataURL(file);
            return getResult.then(file => {
              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 ...
646
          this.editFiles = [];
a17c68a03   Neeraj Sharma   implement two rou...
647
648
        }
      },
8bb178441   Neeraj Sharma   implemnt api in s...
649
650
651
652
653
654
655
656
657
658
      getGalleryList() {
        this.showLoader = true;
        http()
          .get("/getGalleryList", {
            headers: { Authorization: "Bearer " + this.token }
          })
          .then(response => {
            this.desserts = response.data.data;
            this.showLoader = false;
          })
1571e40b5   Neeraj Sharma   gallery and socia...
659
          .catch(error => {
8bb178441   Neeraj Sharma   implemnt api in s...
660
661
            // console.log("err====>", err);
            this.showLoader = false;
a17c68a03   Neeraj Sharma   implement two rou...
662
663
664
665
666
            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...
667
668
669
670
671
672
          });
      },
      editItem(item) {
        this.files = [];
        this.editedIndex = this.desserts.indexOf(item);
        this.editedItem = Object.assign({}, item);
68d742034   Neeraj Sharma   implement new des...
673
        this.editGalleryDialog = true;
8bb178441   Neeraj Sharma   implemnt api in s...
674
675
676
677
      },
      profile(item) {
        this.editedIndex = this.desserts.indexOf(item);
        this.editedItem = Object.assign({}, item);
68d742034   Neeraj Sharma   implement new des...
678
        this.viewProfileGallery = true;
8bb178441   Neeraj Sharma   implemnt api in s...
679
680
681
      },
      deleteItem(item) {
        let deleteGallery = {
a17c68a03   Neeraj Sharma   implement two rou...
682
          galleryId: item._id
8bb178441   Neeraj Sharma   implemnt api in s...
683
684
685
        };
        http()
          .delete(
a17c68a03   Neeraj Sharma   implement two rou...
686
            "/deleteGallery",
8bb178441   Neeraj Sharma   implemnt api in s...
687
            confirm("Are you sure you want to delete this?") && {
a17c68a03   Neeraj Sharma   implement two rou...
688
689
690
691
              params: deleteGallery,
              headers: {
                Authorization: "Bearer " + this.token
              }
8bb178441   Neeraj Sharma   implemnt api in s...
692
693
694
            }
          )
          .then(response => {
c39f609df   Neeraj Sharma   fixed validation ...
695
696
            this.snackbar = true;
            this.text = "Successfully delete Existing Gallery";
68d742034   Neeraj Sharma   implement new des...
697
            this.color = "green";
a17c68a03   Neeraj Sharma   implement two rou...
698
            this.getGalleryList();
8bb178441   Neeraj Sharma   implemnt api in s...
699
700
701
          })
          .catch(error => {
            // console.log(error);
c39f609df   Neeraj Sharma   fixed validation ...
702
703
            this.snackbar = true;
            this.text = error.response.data.message;
68d742034   Neeraj Sharma   implement new des...
704
            this.color = "error";
8bb178441   Neeraj Sharma   implemnt api in s...
705
706
          });
      },
a17c68a03   Neeraj Sharma   implement two rou...
707
      deleteImage(imageId, id) {
8bb178441   Neeraj Sharma   implemnt api in s...
708
        let deleteImages = {
a17c68a03   Neeraj Sharma   implement two rou...
709
          galleryId: id,
8bb178441   Neeraj Sharma   implemnt api in s...
710
711
712
          imageId: imageId
        };
        http()
a17c68a03   Neeraj Sharma   implement two rou...
713
          .put("/deleteImage", deleteImages)
8bb178441   Neeraj Sharma   implemnt api in s...
714
          .then(response => {
a17c68a03   Neeraj Sharma   implement two rou...
715
716
            this.snackbar = true;
            this.text = response.data.message;
68d742034   Neeraj Sharma   implement new des...
717
            this.color = "green";
a17c68a03   Neeraj Sharma   implement two rou...
718
            this.getGalleryList();
8bb178441   Neeraj Sharma   implemnt api in s...
719
720
721
            this.close();
          })
          .catch(error => {
68d742034   Neeraj Sharma   implement new des...
722
723
724
            this.snackbar = true;
            this.text = error.response.data.message;
            this.color = "error";
8bb178441   Neeraj Sharma   implemnt api in s...
725
726
          });
      },
8bb178441   Neeraj Sharma   implemnt api in s...
727
      close() {
68d742034   Neeraj Sharma   implement new des...
728
        this.editGalleryDialog = false;
8bb178441   Neeraj Sharma   implemnt api in s...
729
      },
68d742034   Neeraj Sharma   implement new des...
730
731
      closeProfileGallery() {
        this.viewProfileGallery = false;
8bb178441   Neeraj Sharma   implemnt api in s...
732
733
      },
      submit() {
a17c68a03   Neeraj Sharma   implement two rou...
734
735
736
        for (let i = 0; i < this.finds.length; i++) {
          this.addGallery.youTubeLinkUrl.push(this.finds[i].value);
        }
8bb178441   Neeraj Sharma   implemnt api in s...
737
738
739
740
741
742
743
744
745
746
747
        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...
748
749
750
751
752
753
754
          if (this.addGallery.youTubeLinkUrl == "") {
            var galleryData = {
              classId: this.addGallery.classNum,
              title: this.addGallery.title,
              description: this.addGallery.description,
              upload: this.addGallery.upload
            };
895062f9a   Neeraj Sharma   add loader on sub...
755
            this.loading = true;
2ddcef1ce   Neeraj Sharma   solve issue empty...
756
757
758
759
            http()
              .post("/createGallery", galleryData)
              .then(response => {
                this.getGalleryList();
fe0d05d29   Neeraj Sharma   complete design a...
760
                this.addGalleryDialog = false;
2ddcef1ce   Neeraj Sharma   solve issue empty...
761
762
763
                this.loading = false;
                this.snackbar = true;
                this.text = response.data.message;
68d742034   Neeraj Sharma   implement new des...
764
                this.color = "green";
2ddcef1ce   Neeraj Sharma   solve issue empty...
765
766
767
768
                this.clear();
                this.files = "";
              })
              .catch(error => {
c39f609df   Neeraj Sharma   fixed validation ...
769
770
                this.snackbar = true;
                this.text = error.response.data.message;
68d742034   Neeraj Sharma   implement new des...
771
                this.color = "error";
c39f609df   Neeraj Sharma   fixed validation ...
772
                this.loading = false;
2ddcef1ce   Neeraj Sharma   solve issue empty...
773
774
              });
          } else if (this.addGallery.youTubeLinkUrl) {
895062f9a   Neeraj Sharma   add loader on sub...
775
            this.loading = true;
2ddcef1ce   Neeraj Sharma   solve issue empty...
776
777
778
779
            http()
              .post("/createGallery", this.addGallery)
              .then(response => {
                this.getGalleryList();
fe0d05d29   Neeraj Sharma   complete design a...
780
781
                this.addGalleryDialog = false;
                this.files = "nmn";
2ddcef1ce   Neeraj Sharma   solve issue empty...
782
783
                this.loading = false;
                this.snackbar = true;
68d742034   Neeraj Sharma   implement new des...
784
                this.color = "green";
2ddcef1ce   Neeraj Sharma   solve issue empty...
785
786
                this.text = response.data.message;
                this.clear();
fe0d05d29   Neeraj Sharma   complete design a...
787
                this.removeAddFind();
2ddcef1ce   Neeraj Sharma   solve issue empty...
788
789
790
                this.files = "";
              })
              .catch(error => {
895062f9a   Neeraj Sharma   add loader on sub...
791
792
793
                this.snackbar = true;
                this.text = error.response.data.message;
                this.loading = false;
68d742034   Neeraj Sharma   implement new des...
794
                this.color = "error";
2ddcef1ce   Neeraj Sharma   solve issue empty...
795
796
              });
          }
8bb178441   Neeraj Sharma   implemnt api in s...
797
798
799
800
        }
      },
      clear() {
        this.$refs.form.reset();
0551a0f15   Neeraj Sharma   implemnet functio...
801
        this.files = [];
8bb178441   Neeraj Sharma   implemnt api in s...
802
803
804
      },
      save() {
        this.editedItem.gelleryId = this.editedItem._id;
1571e40b5   Neeraj Sharma   gallery and socia...
805
        var linkUrl = [];
a17c68a03   Neeraj Sharma   implement two rou...
806
        for (let i = 0; i < this.updates.length; i++) {
1571e40b5   Neeraj Sharma   gallery and socia...
807
          linkUrl.push(this.updates[i].youTubeLink);
a17c68a03   Neeraj Sharma   implement two rou...
808
        }
1571e40b5   Neeraj Sharma   gallery and socia...
809
        if (this.editFiles) {
8bb178441   Neeraj Sharma   implemnt api in s...
810
811
          var ary = [];
          var imageData = [];
1571e40b5   Neeraj Sharma   gallery and socia...
812
          ary = this.editFiles;
8bb178441   Neeraj Sharma   implemnt api in s...
813
814
815
          for (let i = 0; i < ary.length; i++) {
            const [baseUrl, imageUrl] = ary[i].split(/,/);
            imageData.push(imageUrl);
1571e40b5   Neeraj Sharma   gallery and socia...
816
            this.editedItem.editFiles = imageData;
8bb178441   Neeraj Sharma   implemnt api in s...
817
818
          }
        }
1571e40b5   Neeraj Sharma   gallery and socia...
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
        if (linkUrl != "") {
          var updateData = {
            galleryId: this.editedItem._id,
            description: this.editedItem.description,
            classId: this.editedItem.classNum,
            uploadImage: this.editedItem.editFiles,
            title: this.editedItem.title,
            updateYouTubeLinkUrl: linkUrl
          };
        } else if (linkUrl == "") {
          var updateData = {
            galleryId: this.editedItem._id,
            description: this.editedItem.description,
            classId: this.editedItem.classNum,
            uploadImage: this.editedItem.editFiles,
            title: this.editedItem.title
          };
        }
c39f609df   Neeraj Sharma   fixed validation ...
837
        this.editGalleryLoading = true;
1571e40b5   Neeraj Sharma   gallery and socia...
838
839
840
841
842
843
844
        http()
          .put("/updateGallery", updateData)
          .then(response => {
            this.getGalleryList();
            this.close();
            this.snackbar = true;
            this.text = response.data.message;
68d742034   Neeraj Sharma   implement new des...
845
            this.color = "green";
c39f609df   Neeraj Sharma   fixed validation ...
846
            this.editGalleryLoading = false;
fe0d05d29   Neeraj Sharma   complete design a...
847
848
            this.editImageName = "";
            this.editFiles = [];
1571e40b5   Neeraj Sharma   gallery and socia...
849
850
          })
          .catch(error => {
c39f609df   Neeraj Sharma   fixed validation ...
851
852
853
            this.editGalleryLoading = false;
            this.snackbar = true;
            this.text = error.response.data.message;
68d742034   Neeraj Sharma   implement new des...
854
            this.color = "error";
1571e40b5   Neeraj Sharma   gallery and socia...
855
          });
8bb178441   Neeraj Sharma   implemnt api in s...
856
857
858
859
860
861
862
863
864
865
866
      },
      getAllClasses() {
        http()
          .get("/getClassesList", {
            headers: { Authorization: "Bearer " + this.token }
          })
          .then(response => {
            this.addclass = response.data.data;
          })
          .catch(err => {
            // console.log("err====>", err);
8bb178441   Neeraj Sharma   implemnt api in s...
867
868
          });
      },
fe0d05d29   Neeraj Sharma   complete design a...
869
870
871
      removeAddFind: function() {
        this.finds = [{ value: "" }];
      },
8bb178441   Neeraj Sharma   implemnt api in s...
872
873
874
      addFind: function() {
        this.finds.push({ value: "" });
      },
a17c68a03   Neeraj Sharma   implement two rou...
875
876
877
      update: function() {
        this.updates.push({ youTubeLink: "" });
      },
8bb178441   Neeraj Sharma   implemnt api in s...
878
879
880
      deleteFind: function(index) {
        this.finds.splice(index, 1);
        if (index === 0) this.addFind();
a17c68a03   Neeraj Sharma   implement two rou...
881
882
883
884
885
      },
      deleteUpdate: function(index) {
        this.updates.splice(index, 1);
        if (index === 0) this.update();
      },
1571e40b5   Neeraj Sharma   gallery and socia...
886
      deleteUrl: function(index, youTubelinkId, id) {
a17c68a03   Neeraj Sharma   implement two rou...
887
888
        this.editedItem.youTubeLinkUrl.splice(index, 1);
        if (index === 0) this.update();
a17c68a03   Neeraj Sharma   implement two rou...
889
890
891
892
893
894
895
896
897
        let deleteYouTubeUrl = {
          galleryId: id,
          youTubeId: youTubelinkId
        };
        http()
          .put("/deleteYoutubeLink", deleteYouTubeUrl)
          .then(response => {
            this.snackbar = true;
            this.text = response.data.message;
68d742034   Neeraj Sharma   implement new des...
898
            this.color = "green";
a17c68a03   Neeraj Sharma   implement two rou...
899
900
901
902
            this.getGalleryList();
            this.close();
          })
          .catch(error => {
68d742034   Neeraj Sharma   implement new des...
903
904
905
            this.snackbar = true;
            this.text = error.response.data.message;
            this.color = "error";
a17c68a03   Neeraj Sharma   implement two rou...
906
          });
68d742034   Neeraj Sharma   implement new des...
907
908
      },
      displaySearch() {
fe0d05d29   Neeraj Sharma   complete design a...
909
910
        this.show = false;
        this.showSearch = true;
68d742034   Neeraj Sharma   implement new des...
911
912
913
914
915
      },
      closeSearch() {
        this.showSearch = false;
        this.show = true;
        this.search = "";
8bb178441   Neeraj Sharma   implemnt api in s...
916
917
918
919
920
921
      }
    },
    mounted() {
      this.token = this.$store.state.token;
      this.getAllClasses();
      this.getGalleryList();
8bb178441   Neeraj Sharma   implemnt api in s...
922
923
    }
  };
68d742034   Neeraj Sharma   implement new des...
924
  </script>