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