Blame view

src/pages/Gallery/gallery.vue 32.3 KB
8bb178441   Neeraj Sharma   implemnt api in s...
1
2
  <template>
    <v-app id="pages-dasboard">
687e0b929   Neeraj Sharma   add user,attenden...
3
      <v-tabs grow slider-color="gray">
8bb178441   Neeraj Sharma   implemnt api in s...
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
        <v-tab
          ripple
          @click="activeTab('existing')"
          v-bind:class="{ active: isActive }"
          id="tab"
          class="subheading"
        >Existing Gallery</v-tab>
        <v-tab
          ripple
          @click="activeTab('new')"
          v-bind:class="{ active: newActive }"
          id="tab1"
          User
          class="subheading"
        >Add Gallery</v-tab>
  
        <!-- ****** EDITS ALL Gallery DETAILS ****** -->
  
        <v-tab-item>
          <v-snackbar
            :timeout="timeout"
            :top="y === 'top'"
            :right="x === 'right'"
            :vertical="mode === 'vertical'"
            v-model="snackbar"
            color="success"
          >{{ text }}</v-snackbar>
          <v-dialog v-model="dialog" max-width="1000px" scrollable>
            <v-card flat>
              <v-toolbar class="grey lighten-2" flat>
                <v-spacer></v-spacer>
                <v-toolbar-title>
                  <h3>Edit Gallery</h3>
                </v-toolbar-title>
                <v-spacer></v-spacer>
              </v-toolbar>
a17c68a03   Neeraj Sharma   implement two rou...
40
              <v-card-text style="height:700px;">
f4df757fe   Neeraj Sharma   responsive vie in...
41
42
43
44
45
46
47
48
49
50
51
52
53
54
                <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>
8bb178441   Neeraj Sharma   implemnt api in s...
55
                      <v-flex
f4df757fe   Neeraj Sharma   responsive vie in...
56
57
58
59
60
61
62
                        xs6
                        sm12
                        md3
                        v-for="Image in editedItem.imageUrl"
                        :key="Image._id"
                        v-if="editedItem.imageUrl"
                        class="profile-image-wrapper imgNews"
8bb178441   Neeraj Sharma   implemnt api in s...
63
                      >
8bb178441   Neeraj Sharma   implemnt api in s...
64
                        <img
f4df757fe   Neeraj Sharma   responsive vie in...
65
                          :src="Image.imageLink"
8bb178441   Neeraj Sharma   implemnt api in s...
66
67
68
                          height="160"
                          width="160"
                          alt="Gallery"
f4df757fe   Neeraj Sharma   responsive vie in...
69
                          class="pa-2 imgNews"
8bb178441   Neeraj Sharma   implemnt api in s...
70
                        />
f4df757fe   Neeraj Sharma   responsive vie in...
71
72
73
74
75
76
77
78
                        <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 imgNews" />
8bb178441   Neeraj Sharma   implemnt api in s...
79
80
                      </v-flex>
                    </v-layout>
f4df757fe   Neeraj Sharma   responsive vie in...
81
82
83
84
85
86
87
88
89
90
91
                    <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>
8bb178441   Neeraj Sharma   implemnt api in s...
92
                    <v-layout>
f4df757fe   Neeraj Sharma   responsive vie in...
93
94
                      <v-flex xs4 class="pt-4 subheading">
                        <label class="right">Title:</label>
8bb178441   Neeraj Sharma   implemnt api in s...
95
                      </v-flex>
f4df757fe   Neeraj Sharma   responsive vie in...
96
97
98
99
100
101
102
103
                      <v-flex xs8 sm5 class="ml-3">
                        <v-text-field
                          v-model="editedItem.title"
                          placeholder="fill your Title"
                          name="name"
                          type="text"
                          required
                        ></v-text-field>
8bb178441   Neeraj Sharma   implemnt api in s...
104
                      </v-flex>
f4df757fe   Neeraj Sharma   responsive vie in...
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
                    </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 sm5 class="ml-3">
                        <v-text-field
                          placeholder="fill your Description"
                          v-model="editedItem.description"
                          type="text"
                          name="email"
                          required
                        ></v-text-field>
8bb178441   Neeraj Sharma   implemnt api in s...
120
121
                      </v-flex>
                    </v-layout>
f4df757fe   Neeraj Sharma   responsive vie in...
122
123
124
125
126
                  </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>
a17c68a03   Neeraj Sharma   implement two rou...
127
                    </v-flex>
f4df757fe   Neeraj Sharma   responsive vie in...
128
129
130
131
132
133
134
135
136
137
                    <v-flex xs8 sm5 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>
a17c68a03   Neeraj Sharma   implement two rou...
138
                    </v-flex>
f4df757fe   Neeraj Sharma   responsive vie in...
139
140
                  </v-layout>
                  <v-flex xs12>
8bb178441   Neeraj Sharma   implemnt api in s...
141
                    <v-layout>
f4df757fe   Neeraj Sharma   responsive vie in...
142
143
144
145
146
147
148
149
150
151
152
153
                      <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 sm5 class="ml-3">
                        <v-text-field
                          label="Select Image"
                          @click="editPickFile"
                          v-model="editImageName"
                          append-icon="attach_file"
                          multiple
                        ></v-text-field>
8bb178441   Neeraj Sharma   implemnt api in s...
154
155
                      </v-flex>
                    </v-layout>
f4df757fe   Neeraj Sharma   responsive vie in...
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
                  </v-flex>
                </v-layout>
                <v-flex xs12>
                  <div
                    v-for="(editImage,index) in editedItem.youTubeLinkUrl"
                    :key="index"
                    v-if="editImage.youTubeLink !=[]"
                  >
                    <v-layout>
                      <v-flex xs4 class="pt-4 subheading">
                        <label class="right">You Tube Link Url:</label>
                      </v-flex>
                      <v-flex xs8 sm5 class="ml-3">
                        <v-text-field
                          v-model="editImage.youTubeLink"
                          type="text"
                          name="link"
                          required
                        ></v-text-field>
                      </v-flex>
                      <v-flex xs2 class="pt-4">
                        <v-icon @click="deleteUrl(index,editImage._id,editedItem._id)">cancel</v-icon>
                      </v-flex>
                    </v-layout>
                  </div>
                </v-flex>
                <v-flex xs12>
                  <div v-for="(updateImage,index) in updates" :key="index">
                    <v-layout>
                      <v-flex xs4 class="pt-4 subheading">
                        <label class="right">You Tube Url:</label>
                      </v-flex>
                      <v-flex xs5 sm5 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>
                  </div>
                </v-flex>
                <v-layout>
                  <v-flex xs12 sm8 offset-sm2>
                    <v-card-actions>
                      <v-btn round dark @click.native="close">Cancel</v-btn>
                      <v-spacer></v-spacer>
c39f609df   Neeraj Sharma   fixed validation ...
207
                      <v-btn round dark @click="save" :loading="editGalleryLoading">Save</v-btn>
f4df757fe   Neeraj Sharma   responsive vie in...
208
209
210
211
212
                    </v-card-actions>
                  </v-flex>
                </v-layout>
                <!-- </v-container>
                </v-form>-->
8bb178441   Neeraj Sharma   implemnt api in s...
213
214
215
216
217
              </v-card-text>
            </v-card>
          </v-dialog>
  
          <!-- ****** PROFILE VIEW Gallery ******  -->
c39f609df   Neeraj Sharma   fixed validation ...
218
          <v-dialog v-model="dialog1" max-width="940px" scrollable>
8bb178441   Neeraj Sharma   implemnt api in s...
219
220
221
222
223
224
225
226
227
            <v-card>
              <v-toolbar color="grey lighten-2" flat>
                <v-spacer></v-spacer>
                <v-toolbar-title>
                  <h3>Gallery</h3>
                </v-toolbar-title>
                <v-spacer></v-spacer>
                <v-icon @click="close1">close</v-icon>
              </v-toolbar>
895062f9a   Neeraj Sharma   add loader on sub...
228
              <v-card-text>
c39f609df   Neeraj Sharma   fixed validation ...
229
                <v-layout row wrap>
895062f9a   Neeraj Sharma   add loader on sub...
230
231
232
233
                  <v-flex
                    xs12
                    class="text-xs-center text-sm-center text-md-center text-lg-center my-4"
                  >
c39f609df   Neeraj Sharma   fixed validation ...
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
                    <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>
8bb178441   Neeraj Sharma   implemnt api in s...
253
254
                <v-container grid-list-md>
                  <v-layout wrap>
c39f609df   Neeraj Sharma   fixed validation ...
255
                    <v-flex xs12>
8bb178441   Neeraj Sharma   implemnt api in s...
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
                      <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>
a17c68a03   Neeraj Sharma   implement two rou...
276
277
278
279
280
281
282
                      <v-layout>
                        <v-flex xs5 sm6>
                          <h5 class="right my-1">
                            <b>You Tube Link Url:</b>
                          </h5>
                        </v-flex>
                        <v-flex sm6 xs8>
1571e40b5   Neeraj Sharma   gallery and socia...
283
284
285
286
                          <h5 class="my-1 ml-3">
                            <ul v-for="youTubeLinkUrl in editedItem.youTubeLinkUrl">
                              <li>{{ youTubeLinkUrl.youTubeLink }}</li>
                            </ul>
a17c68a03   Neeraj Sharma   implement two rou...
287
288
289
                          </h5>
                        </v-flex>
                      </v-layout>
8bb178441   Neeraj Sharma   implemnt api in s...
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
                    </v-flex>
                  </v-layout>
                </v-container>
              </v-card-text>
            </v-card>
          </v-dialog>
  
          <v-snackbar
            :timeout="timeout"
            :top="y === 'top'"
            :right="x === 'right'"
            :vertical="mode === 'vertical'"
            v-model="snackbar"
            color="success"
          >{{ text }}</v-snackbar>
  
          <!-- ****** EXISTING-USERS Gallery TABLE ****** -->
          <v-data-table
            :headers="headers"
            :items="desserts"
            :pagination.sync="pagination"
            :search="search"
          >
            <template slot="items" slot-scope="props">
aa8fc5033   Neeraj Sharma   implenment all pa...
314
              <td class="text-xs-center">{{ props.index + 1}}</td>
8bb178441   Neeraj Sharma   implemnt api in s...
315
316
              <td id="td" class="text-xs-center">
                <span v-for="(image,_id) in props.item.imageUrl" class="pa-2">
a17c68a03   Neeraj Sharma   implement two rou...
317
                  <img :src="image.imageLink" alt="newsImage" width="100" height="70" />
8bb178441   Neeraj Sharma   implemnt api in s...
318
                </span>
c39f609df   Neeraj Sharma   fixed validation ...
319
320
321
322
323
324
                <img
                  src="/static/icon/user.png"
                  v-if="props.item.imageUrl == '' && editFiles == ''"
                  width="60"
                  alt="Gallery"
                />
8bb178441   Neeraj Sharma   implemnt api in s...
325
326
327
              </td>
              <td id="td" class="text-xs-center">{{ props.item.title}}</td>
              <td id="td" class="text-xs-center">{{ props.item.description}}</td>
a17c68a03   Neeraj Sharma   implement two rou...
328
              <td id="td" class="text-xs-center">
c39f609df   Neeraj Sharma   fixed validation ...
329
                <span>
495e4037c   Neeraj Sharma   update
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
                  <v-tooltip top>
                    <img
                      slot="activator"
                      style="cursor:pointer; width:25px; height:18px; "
                      class="mr5"
                      @click="profile(props.item)"
                      src="/static/icon/eye1.png"
                    />
                    <span>View</span>
                  </v-tooltip>
                  <v-tooltip top>
                    <img
                      slot="activator"
                      style="cursor:pointer; width:20px; height:18px; "
                      class="mr5"
                      @click="editItem(props.item)"
                      src="/static/icon/edit1.png"
                    />
                    <span>Edit</span>
                  </v-tooltip>
                  <v-tooltip top>
                    <img
                      slot="activator"
                      style="cursor:pointer; width:20px; height:20px; "
                      class="mr5"
                      @click="deleteItem(props.item)"
                      src="/static/icon/delete1.png"
                    />
                    <span>Delete</span>
                  </v-tooltip>
8bb178441   Neeraj Sharma   implemnt api in s...
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
                </span>
              </td>
            </template>
            <v-alert
              slot="no-results"
              :value="true"
              color="error"
              icon="warning"
            >Your search for "{{ search }}" found no results.</v-alert>
          </v-data-table>
        </v-tab-item>
  
        <!-- ****** ADD MULTIPLE Gallery Data ****** -->
  
        <v-tab-item>
          <v-container>
            <v-snackbar
              :timeout="timeout"
              :top="y === 'top'"
              :right="x === 'right'"
              :vertical="mode === 'vertical'"
              v-model="snackbar"
              color="success"
            >{{ text }}</v-snackbar>
            <v-flex xs12 sm12 class="my-4">
              <v-card flat>
                <v-form ref="form" v-model="valid" lazy-validation>
                  <v-container fluid>
                    <v-layout>
                      <v-flex
                        xs12
f4df757fe   Neeraj Sharma   responsive vie in...
391
                        class="text-xs-center text-sm-center text-md-center text-lg-center my-4"
8bb178441   Neeraj Sharma   implemnt api in s...
392
393
394
395
396
397
398
399
400
401
402
                      >
                        <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">
f4df757fe   Neeraj Sharma   responsive vie in...
403
                            <img :src="file" height="160" width="160px;" class="imgNews" />
8bb178441   Neeraj Sharma   implemnt api in s...
404
405
406
407
408
409
410
                          </v-flex>
                        </v-layout>
                        <img
                          src="/static/icon/user.png"
                          v-if="files ==''"
                          height="140"
                          width="180px;"
f4df757fe   Neeraj Sharma   responsive vie in...
411
                          class="imgNews"
8bb178441   Neeraj Sharma   implemnt api in s...
412
413
414
415
416
417
418
419
                        />
                      </v-flex>
                    </v-layout>
                    <v-flex xs12>
                      <v-layout>
                        <v-flex xs4 class="pt-4 subheading">
                          <label class="right">Title:</label>
                        </v-flex>
aa8fc5033   Neeraj Sharma   implenment all pa...
420
                        <v-flex xs8 sm4 class="ml-3">
8bb178441   Neeraj Sharma   implemnt api in s...
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
                          <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>
aa8fc5033   Neeraj Sharma   implenment all pa...
437
                        <v-flex xs8 sm4 class="ml-3">
8bb178441   Neeraj Sharma   implemnt api in s...
438
439
440
441
442
443
444
445
446
447
448
449
450
451
                          <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">
aa8fc5033   Neeraj Sharma   implenment all pa...
452
453
                          <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>
8bb178441   Neeraj Sharma   implemnt api in s...
454
                        </v-flex>
aa8fc5033   Neeraj Sharma   implenment all pa...
455
                        <v-flex xs8 sm4 class="ml-3">
8bb178441   Neeraj Sharma   implemnt api in s...
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
                          <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">
aa8fc5033   Neeraj Sharma   implenment all pa...
471
472
                          <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>
8bb178441   Neeraj Sharma   implemnt api in s...
473
                        </v-flex>
aa8fc5033   Neeraj Sharma   implenment all pa...
474
                        <v-flex xs8 sm4 class="ml-3">
8bb178441   Neeraj Sharma   implemnt api in s...
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
                          <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>
                      <v-flex xs12>
                        <div v-for="(youTubeLink,index) in finds" :key="index">
                          <v-layout>
                            <v-flex xs4 class="pt-4 subheading">
f4df757fe   Neeraj Sharma   responsive vie in...
490
                              <label class="right">You Tube Url:</label>
8bb178441   Neeraj Sharma   implemnt api in s...
491
                            </v-flex>
f4df757fe   Neeraj Sharma   responsive vie in...
492
                            <v-flex xs6 sm4 class="ml-3">
8bb178441   Neeraj Sharma   implemnt api in s...
493
494
495
496
497
498
499
                              <v-text-field
                                placeholder="fill your youtube link"
                                v-model="youTubeLink.value"
                                type="text"
                                name="link"
                                required
                              ></v-text-field>
8bb178441   Neeraj Sharma   implemnt api in s...
500
501
                            </v-flex>
                            <v-flex xs2 class="pt-4">
a17c68a03   Neeraj Sharma   implement two rou...
502
                              <v-icon @click="deleteFind(index)" v-if="index !=0 ">cancel</v-icon>
8bb178441   Neeraj Sharma   implemnt api in s...
503
504
505
506
507
                              <v-icon @click="addFind">add_circle</v-icon>
                            </v-flex>
                          </v-layout>
                        </div>
                      </v-flex>
f4df757fe   Neeraj Sharma   responsive vie in...
508
509
510
511
512
513
514
515
516
517
518
519
                      <v-layout>
                        <v-flex xs12 sm5 offset-sm3>
                          <v-layout>
                            <v-flex xs6>
                              <v-btn @click="clear" round class="ml-3" dark>clear</v-btn>
                            </v-flex>
                            <v-flex xs6>
                              <v-btn @click="submit" round dark :loading="loading" class="right">Add</v-btn>
                            </v-flex>
                          </v-layout>
                        </v-flex>
                      </v-layout>
8bb178441   Neeraj Sharma   implemnt api in s...
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
                    </v-layout>
                  </v-container>
                </v-form>
              </v-card>
            </v-flex>
          </v-container>
        </v-tab-item>
      </v-tabs>
      <div class="loader" v-if="showLoader">
        <v-progress-circular indeterminate color="white"></v-progress-circular>
      </div>
    </v-app>
  </template>
  
  <script>
  import http from "@/Services/http.js";
  import Util from "@/util";
  
  export default {
    data: () => ({
      snackbar: false,
      y: "top",
      x: "right",
      mode: "",
      timeout: 3000,
      text: "",
      loading: false,
      date: null,
      search: "",
      showLoader: false,
      dialog: false,
      dialog1: false,
      valid: true,
      isActive: true,
      newActive: false,
c39f609df   Neeraj Sharma   fixed validation ...
555
      editGalleryLoading: false,
8bb178441   Neeraj Sharma   implemnt api in s...
556
557
558
      addclass: [],
      addSection: [],
      finds: [{ value: "" }],
a17c68a03   Neeraj Sharma   implement two rou...
559
560
      updates: [{ youTubeLink: "" }],
      youTubeLink: {},
8bb178441   Neeraj Sharma   implemnt api in s...
561
562
563
564
565
566
567
568
569
570
571
      addGallery: {
        youTubeLinkUrl: []
      },
      pagination: {
        rowsPerPage: 15
      },
      imageName: "",
      imageUrl: "",
      imageFile: "",
      image: [],
      upload: "",
a17c68a03   Neeraj Sharma   implement two rou...
572
573
      editImageName: "",
      editFiles: [],
8bb178441   Neeraj Sharma   implemnt api in s...
574
      files: [],
8bb178441   Neeraj Sharma   implemnt api in s...
575
576
577
578
579
580
581
582
      token: "",
      titleRules: [v => !!v || " Tilte is required"],
      descriptionRules: [v => !!v || " Description is required"],
      headers: [
        {
          align: "justify-center",
          text: "No",
          sortable: false,
1571e40b5   Neeraj Sharma   gallery and socia...
583
          value: "index"
8bb178441   Neeraj Sharma   implemnt api in s...
584
585
586
587
588
589
590
591
592
593
594
595
596
        },
        { text: "Image", vaue: "image", sortable: false, align: "center" },
        { 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...
597
598
      editedItem: {},
      index: ""
8bb178441   Neeraj Sharma   implemnt api in s...
599
600
    }),
    methods: {
8bb178441   Neeraj Sharma   implemnt api in s...
601
602
603
      pickFile() {
        this.$refs.image.click();
      },
a17c68a03   Neeraj Sharma   implement two rou...
604
605
606
      editPickFile() {
        this.$refs.editImage.click();
      },
8bb178441   Neeraj Sharma   implemnt api in s...
607
      onFilePicked(e) {
8bb178441   Neeraj Sharma   implemnt api in s...
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
        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...
627
              console.log("uploadImage=======>", this.files);
8bb178441   Neeraj Sharma   implemnt api in s...
628
629
630
631
632
633
634
635
636
637
            });
            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...
638
639
640
641
642
643
644
          });
        } else {
          this.imageName = "";
          this.imageFile = "";
          this.imageUrl = "";
        }
      },
a17c68a03   Neeraj Sharma   implement two rou...
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
      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 ...
663
              console.log("uploadeditFilesImage=======>", this.editFiles);
a17c68a03   Neeraj Sharma   implement two rou...
664
665
666
667
668
669
670
671
672
673
674
675
676
            });
            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 ...
677
          this.editFiles = [];
a17c68a03   Neeraj Sharma   implement two rou...
678
679
        }
      },
8bb178441   Neeraj Sharma   implemnt api in s...
680
681
682
683
684
685
686
687
688
689
      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...
690
          .catch(error => {
8bb178441   Neeraj Sharma   implemnt api in s...
691
692
            // console.log("err====>", err);
            this.showLoader = false;
a17c68a03   Neeraj Sharma   implement two rou...
693
694
695
696
697
            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...
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
          });
      },
      editItem(item) {
        this.files = [];
        this.editedIndex = this.desserts.indexOf(item);
        this.editedItem = Object.assign({}, item);
        this.dialog = true;
      },
      profile(item) {
        this.editedIndex = this.desserts.indexOf(item);
        this.editedItem = Object.assign({}, item);
        this.dialog1 = true;
      },
      deleteItem(item) {
        let deleteGallery = {
a17c68a03   Neeraj Sharma   implement two rou...
713
          galleryId: item._id
8bb178441   Neeraj Sharma   implemnt api in s...
714
715
716
        };
        http()
          .delete(
a17c68a03   Neeraj Sharma   implement two rou...
717
            "/deleteGallery",
8bb178441   Neeraj Sharma   implemnt api in s...
718
            confirm("Are you sure you want to delete this?") && {
a17c68a03   Neeraj Sharma   implement two rou...
719
720
721
722
              params: deleteGallery,
              headers: {
                Authorization: "Bearer " + this.token
              }
8bb178441   Neeraj Sharma   implemnt api in s...
723
724
725
            }
          )
          .then(response => {
c39f609df   Neeraj Sharma   fixed validation ...
726
727
            this.snackbar = true;
            this.text = "Successfully delete Existing Gallery";
a17c68a03   Neeraj Sharma   implement two rou...
728
            this.getGalleryList();
8bb178441   Neeraj Sharma   implemnt api in s...
729
730
731
          })
          .catch(error => {
            // console.log(error);
c39f609df   Neeraj Sharma   fixed validation ...
732
733
            this.snackbar = true;
            this.text = error.response.data.message;
8bb178441   Neeraj Sharma   implemnt api in s...
734
735
          });
      },
a17c68a03   Neeraj Sharma   implement two rou...
736
      deleteImage(imageId, id) {
8bb178441   Neeraj Sharma   implemnt api in s...
737
        let deleteImages = {
a17c68a03   Neeraj Sharma   implement two rou...
738
          galleryId: id,
8bb178441   Neeraj Sharma   implemnt api in s...
739
740
741
          imageId: imageId
        };
        http()
a17c68a03   Neeraj Sharma   implement two rou...
742
          .put("/deleteImage", deleteImages)
8bb178441   Neeraj Sharma   implemnt api in s...
743
          .then(response => {
a17c68a03   Neeraj Sharma   implement two rou...
744
745
746
            this.snackbar = true;
            this.text = response.data.message;
            this.getGalleryList();
8bb178441   Neeraj Sharma   implemnt api in s...
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
            this.close();
          })
          .catch(error => {
            console.log(error);
          });
      },
      activeTab(type) {
        switch (type) {
          case "existing":
            this.newActive = false;
            this.isActive = true;
            break;
  
          default:
            this.newActive = true;
            this.isActive = false;
            break;
        }
      },
      close() {
        this.dialog = false;
        setTimeout(() => {
          this.editedItem = Object.assign({}, this.defaultItem);
          this.editedIndex = -1;
        }, 300);
      },
      close1() {
        this.dialog1 = false;
      },
      submit() {
a17c68a03   Neeraj Sharma   implement two rou...
777
778
779
        for (let i = 0; i < this.finds.length; i++) {
          this.addGallery.youTubeLinkUrl.push(this.finds[i].value);
        }
8bb178441   Neeraj Sharma   implemnt api in s...
780
781
782
783
784
785
786
787
788
789
790
        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...
791
792
793
794
795
796
797
          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...
798
            this.loading = true;
2ddcef1ce   Neeraj Sharma   solve issue empty...
799
800
801
802
803
804
805
806
807
808
809
            http()
              .post("/createGallery", galleryData)
              .then(response => {
                this.getGalleryList();
                this.loading = false;
                this.snackbar = true;
                this.text = response.data.message;
                this.clear();
                this.files = "";
              })
              .catch(error => {
c39f609df   Neeraj Sharma   fixed validation ...
810
811
812
                this.snackbar = true;
                this.text = error.response.data.message;
                this.loading = false;
2ddcef1ce   Neeraj Sharma   solve issue empty...
813
814
              });
          } else if (this.addGallery.youTubeLinkUrl) {
895062f9a   Neeraj Sharma   add loader on sub...
815
            this.loading = true;
2ddcef1ce   Neeraj Sharma   solve issue empty...
816
817
818
819
            http()
              .post("/createGallery", this.addGallery)
              .then(response => {
                this.getGalleryList();
0551a0f15   Neeraj Sharma   implemnet functio...
820
                this.files = [];
2ddcef1ce   Neeraj Sharma   solve issue empty...
821
822
823
824
825
826
827
                this.loading = false;
                this.snackbar = true;
                this.text = response.data.message;
                this.clear();
                this.files = "";
              })
              .catch(error => {
895062f9a   Neeraj Sharma   add loader on sub...
828
829
830
                this.snackbar = true;
                this.text = error.response.data.message;
                this.loading = false;
2ddcef1ce   Neeraj Sharma   solve issue empty...
831
832
              });
          }
8bb178441   Neeraj Sharma   implemnt api in s...
833
834
835
836
        }
      },
      clear() {
        this.$refs.form.reset();
0551a0f15   Neeraj Sharma   implemnet functio...
837
        this.files = [];
8bb178441   Neeraj Sharma   implemnt api in s...
838
839
840
      },
      save() {
        this.editedItem.gelleryId = this.editedItem._id;
1571e40b5   Neeraj Sharma   gallery and socia...
841
        var linkUrl = [];
a17c68a03   Neeraj Sharma   implement two rou...
842
        for (let i = 0; i < this.updates.length; i++) {
1571e40b5   Neeraj Sharma   gallery and socia...
843
          linkUrl.push(this.updates[i].youTubeLink);
a17c68a03   Neeraj Sharma   implement two rou...
844
        }
c39f609df   Neeraj Sharma   fixed validation ...
845
        console.log("uploadeditFilesImage--BBBBBBBBB", this.editFiles);
1571e40b5   Neeraj Sharma   gallery and socia...
846
        if (this.editFiles) {
8bb178441   Neeraj Sharma   implemnt api in s...
847
848
          var ary = [];
          var imageData = [];
1571e40b5   Neeraj Sharma   gallery and socia...
849
          ary = this.editFiles;
8bb178441   Neeraj Sharma   implemnt api in s...
850
851
852
          for (let i = 0; i < ary.length; i++) {
            const [baseUrl, imageUrl] = ary[i].split(/,/);
            imageData.push(imageUrl);
1571e40b5   Neeraj Sharma   gallery and socia...
853
            this.editedItem.editFiles = imageData;
8bb178441   Neeraj Sharma   implemnt api in s...
854
855
          }
        }
1571e40b5   Neeraj Sharma   gallery and socia...
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
        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 ...
874
        this.editGalleryLoading = true;
1571e40b5   Neeraj Sharma   gallery and socia...
875
876
877
878
879
880
881
        http()
          .put("/updateGallery", updateData)
          .then(response => {
            this.getGalleryList();
            this.close();
            this.snackbar = true;
            this.text = response.data.message;
c39f609df   Neeraj Sharma   fixed validation ...
882
883
            this.editGalleryLoading = false;
            (this.editImageName = ""), (this.editFiles = []);
1571e40b5   Neeraj Sharma   gallery and socia...
884
885
          })
          .catch(error => {
c39f609df   Neeraj Sharma   fixed validation ...
886
887
888
            this.editGalleryLoading = false;
            this.snackbar = true;
            this.text = error.response.data.message;
1571e40b5   Neeraj Sharma   gallery and socia...
889
          });
8bb178441   Neeraj Sharma   implemnt api in s...
890
891
892
893
894
895
896
897
898
899
900
      },
      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...
901
902
          });
      },
8bb178441   Neeraj Sharma   implemnt api in s...
903
904
905
      addFind: function() {
        this.finds.push({ value: "" });
      },
a17c68a03   Neeraj Sharma   implement two rou...
906
907
908
      update: function() {
        this.updates.push({ youTubeLink: "" });
      },
8bb178441   Neeraj Sharma   implemnt api in s...
909
910
911
      deleteFind: function(index) {
        this.finds.splice(index, 1);
        if (index === 0) this.addFind();
a17c68a03   Neeraj Sharma   implement two rou...
912
913
914
915
916
      },
      deleteUpdate: function(index) {
        this.updates.splice(index, 1);
        if (index === 0) this.update();
      },
1571e40b5   Neeraj Sharma   gallery and socia...
917
      deleteUrl: function(index, youTubelinkId, id) {
a17c68a03   Neeraj Sharma   implement two rou...
918
919
        this.editedItem.youTubeLinkUrl.splice(index, 1);
        if (index === 0) this.update();
a17c68a03   Neeraj Sharma   implement two rou...
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
        let deleteYouTubeUrl = {
          galleryId: id,
          youTubeId: youTubelinkId
        };
        http()
          .put("/deleteYoutubeLink", deleteYouTubeUrl)
          .then(response => {
            this.snackbar = true;
            this.text = response.data.message;
            this.getGalleryList();
            this.close();
          })
          .catch(error => {
            console.log(error);
          });
8bb178441   Neeraj Sharma   implemnt api in s...
935
936
937
938
939
940
      }
    },
    mounted() {
      this.token = this.$store.state.token;
      this.getAllClasses();
      this.getGalleryList();
1571e40b5   Neeraj Sharma   gallery and socia...
941
      // console.log("index",index);
8bb178441   Neeraj Sharma   implemnt api in s...
942
    },
a17c68a03   Neeraj Sharma   implement two rou...
943
944
945
946
947
948
949
950
    created() {
      this.$root.$on("app:search", search => {
        this.search = search;
      });
    },
    beforeDestroy() {
      // dont forget to remove the listener
      this.$root.$off("app:search");
8bb178441   Neeraj Sharma   implemnt api in s...
951
952
953
954
    }
  };
  </script>
  <style scoped>
8bb178441   Neeraj Sharma   implemnt api in s...
955
956
957
  #td {
    border: 1px solid #dddddd;
    text-align: left;
a17c68a03   Neeraj Sharma   implement two rou...
958
959
    padding: 2px 0px;
    max-width: 200px;
8bb178441   Neeraj Sharma   implemnt api in s...
960
961
  }
  .active {
687e0b929   Neeraj Sharma   add user,attenden...
962
    background-color: gray;
8bb178441   Neeraj Sharma   implemnt api in s...
963
964
965
966
967
    color: white !important;
  }
  .activebtn {
    color: black !important;
  }
8bb178441   Neeraj Sharma   implemnt api in s...
968
  </style>