Blame view

src/pages/Gallery/gallery.vue 30.9 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
207
208
209
210
211
212
                  </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>
                      <v-btn round dark @click="save">Save</v-btn>
                    </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 ******  -->
1571e40b5   Neeraj Sharma   gallery and socia...
218
          <v-dialog v-model="dialog1" max-width="940px">
8bb178441   Neeraj Sharma   implemnt api in s...
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
            <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>
              <v-flex align-center justify-center layout text-xs-center>
                <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"
                >
f4df757fe   Neeraj Sharma   responsive vie in...
238
                  <img :src="image.imageLink" alt="Gallery" width="240" height="180" class="imgNews" />
8bb178441   Neeraj Sharma   implemnt api in s...
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
                </span>
              </v-flex>
              <v-card-text>
                <v-container grid-list-md>
                  <v-layout wrap>
                    <v-flex>
                      <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...
265
266
267
268
269
270
271
                      <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...
272
273
274
275
                          <h5 class="my-1 ml-3">
                            <ul v-for="youTubeLinkUrl in editedItem.youTubeLinkUrl">
                              <li>{{ youTubeLinkUrl.youTubeLink }}</li>
                            </ul>
a17c68a03   Neeraj Sharma   implement two rou...
276
277
278
                          </h5>
                        </v-flex>
                      </v-layout>
8bb178441   Neeraj Sharma   implemnt api in s...
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
                    </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...
303
              <td class="text-xs-center">{{ props.index + 1}}</td>
8bb178441   Neeraj Sharma   implemnt api in s...
304
305
              <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...
306
                  <img :src="image.imageLink" alt="newsImage" width="100" height="70" />
8bb178441   Neeraj Sharma   implemnt api in s...
307
308
309
310
                </span>
              </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...
311
              <td id="td" class="text-xs-center">
8bb178441   Neeraj Sharma   implemnt api in s...
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
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
360
361
                <span>
                  <img
                    style="cursor:pointer; width:25px; height:18px; "
                    class="mr-5"
                    @click="profile(props.item)"
                    src="/static/icon/eye1.png"
                  />
                  <img
                    style="cursor:pointer; width:20px; height:18px; "
                    class="mr-5"
                    @click="editItem(props.item)"
                    src="/static/icon/edit1.png"
                  />
                  <img
                    style="cursor:pointer;width:20px; height:20px; "
                    class="mr-5"
                    @click="deleteItem(props.item)"
                    src="/static/icon/delete1.png"
                  />
                </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...
362
                        class="text-xs-center text-sm-center text-md-center text-lg-center my-4"
8bb178441   Neeraj Sharma   implemnt api in s...
363
364
365
366
367
368
369
370
371
372
373
                      >
                        <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...
374
                            <img :src="file" height="160" width="160px;" class="imgNews" />
8bb178441   Neeraj Sharma   implemnt api in s...
375
376
377
378
379
380
381
                          </v-flex>
                        </v-layout>
                        <img
                          src="/static/icon/user.png"
                          v-if="files ==''"
                          height="140"
                          width="180px;"
f4df757fe   Neeraj Sharma   responsive vie in...
382
                          class="imgNews"
8bb178441   Neeraj Sharma   implemnt api in s...
383
384
385
386
387
388
389
390
                        />
                      </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...
391
                        <v-flex xs8 sm4 class="ml-3">
8bb178441   Neeraj Sharma   implemnt api in s...
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
                          <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...
408
                        <v-flex xs8 sm4 class="ml-3">
8bb178441   Neeraj Sharma   implemnt api in s...
409
410
411
412
413
414
415
416
417
418
419
420
421
422
                          <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...
423
424
                          <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...
425
                        </v-flex>
aa8fc5033   Neeraj Sharma   implenment all pa...
426
                        <v-flex xs8 sm4 class="ml-3">
8bb178441   Neeraj Sharma   implemnt api in s...
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
                          <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...
442
443
                          <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...
444
                        </v-flex>
aa8fc5033   Neeraj Sharma   implenment all pa...
445
                        <v-flex xs8 sm4 class="ml-3">
8bb178441   Neeraj Sharma   implemnt api in s...
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
                          <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...
461
                              <label class="right">You Tube Url:</label>
8bb178441   Neeraj Sharma   implemnt api in s...
462
                            </v-flex>
f4df757fe   Neeraj Sharma   responsive vie in...
463
                            <v-flex xs6 sm4 class="ml-3">
8bb178441   Neeraj Sharma   implemnt api in s...
464
465
466
467
468
469
470
                              <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...
471
472
                            </v-flex>
                            <v-flex xs2 class="pt-4">
a17c68a03   Neeraj Sharma   implement two rou...
473
                              <v-icon @click="deleteFind(index)" v-if="index !=0 ">cancel</v-icon>
8bb178441   Neeraj Sharma   implemnt api in s...
474
475
476
477
478
                              <v-icon @click="addFind">add_circle</v-icon>
                            </v-flex>
                          </v-layout>
                        </div>
                      </v-flex>
f4df757fe   Neeraj Sharma   responsive vie in...
479
480
481
482
483
484
485
486
487
488
489
490
                      <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...
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
                    </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,
      addclass: [],
      addSection: [],
      finds: [{ value: "" }],
a17c68a03   Neeraj Sharma   implement two rou...
529
530
      updates: [{ youTubeLink: "" }],
      youTubeLink: {},
8bb178441   Neeraj Sharma   implemnt api in s...
531
532
533
534
535
536
537
538
539
540
541
      addGallery: {
        youTubeLinkUrl: []
      },
      pagination: {
        rowsPerPage: 15
      },
      imageName: "",
      imageUrl: "",
      imageFile: "",
      image: [],
      upload: "",
a17c68a03   Neeraj Sharma   implement two rou...
542
543
      editImageName: "",
      editFiles: [],
8bb178441   Neeraj Sharma   implemnt api in s...
544
      files: [],
8bb178441   Neeraj Sharma   implemnt api in s...
545
546
547
548
549
550
551
552
      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...
553
          value: "index"
8bb178441   Neeraj Sharma   implemnt api in s...
554
555
556
557
558
559
560
561
562
563
564
565
566
        },
        { 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...
567
568
      editedItem: {},
      index: ""
8bb178441   Neeraj Sharma   implemnt api in s...
569
570
    }),
    methods: {
8bb178441   Neeraj Sharma   implemnt api in s...
571
572
573
      pickFile() {
        this.$refs.image.click();
      },
a17c68a03   Neeraj Sharma   implement two rou...
574
575
576
      editPickFile() {
        this.$refs.editImage.click();
      },
8bb178441   Neeraj Sharma   implemnt api in s...
577
      onFilePicked(e) {
8bb178441   Neeraj Sharma   implemnt api in s...
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
        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...
597
              console.log("uploadImage=======>", this.files);
8bb178441   Neeraj Sharma   implemnt api in s...
598
599
600
601
602
603
604
605
606
607
            });
            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...
608
609
610
611
612
613
614
          });
        } else {
          this.imageName = "";
          this.imageFile = "";
          this.imageUrl = "";
        }
      },
a17c68a03   Neeraj Sharma   implement two rou...
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
      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
                );
              };
              console.log("uploadImage=======>", this.files);
            });
            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 = "";
          this.editFiles = "";
        }
      },
8bb178441   Neeraj Sharma   implemnt api in s...
650
651
652
653
654
655
656
657
658
659
      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...
660
          .catch(error => {
8bb178441   Neeraj Sharma   implemnt api in s...
661
662
            // console.log("err====>", err);
            this.showLoader = false;
a17c68a03   Neeraj Sharma   implement two rou...
663
664
665
666
667
            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...
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
          });
      },
      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...
683
          galleryId: item._id
8bb178441   Neeraj Sharma   implemnt api in s...
684
685
686
        };
        http()
          .delete(
a17c68a03   Neeraj Sharma   implement two rou...
687
            "/deleteGallery",
8bb178441   Neeraj Sharma   implemnt api in s...
688
            confirm("Are you sure you want to delete this?") && {
a17c68a03   Neeraj Sharma   implement two rou...
689
690
691
692
              params: deleteGallery,
              headers: {
                Authorization: "Bearer " + this.token
              }
8bb178441   Neeraj Sharma   implemnt api in s...
693
694
695
696
            }
          )
          .then(response => {
            if ((this.snackbar = true)) {
2ddcef1ce   Neeraj Sharma   solve issue empty...
697
              this.text = "Successfully delete Existing Gallery";
8bb178441   Neeraj Sharma   implemnt api in s...
698
            }
a17c68a03   Neeraj Sharma   implement two rou...
699
            this.getGalleryList();
8bb178441   Neeraj Sharma   implemnt api in s...
700
701
702
703
704
          })
          .catch(error => {
            // console.log(error);
          });
      },
a17c68a03   Neeraj Sharma   implement two rou...
705
706
      deleteImage(imageId, id) {
        console.log("imageId", imageId, "id", id);
8bb178441   Neeraj Sharma   implemnt api in s...
707
        let deleteImages = {
a17c68a03   Neeraj Sharma   implement two rou...
708
          galleryId: id,
8bb178441   Neeraj Sharma   implemnt api in s...
709
710
711
          imageId: imageId
        };
        http()
a17c68a03   Neeraj Sharma   implement two rou...
712
          .put("/deleteImage", deleteImages)
8bb178441   Neeraj Sharma   implemnt api in s...
713
          .then(response => {
a17c68a03   Neeraj Sharma   implement two rou...
714
715
716
            this.snackbar = true;
            this.text = response.data.message;
            this.getGalleryList();
8bb178441   Neeraj Sharma   implemnt api in s...
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
            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() {
        this.loading = true;
a17c68a03   Neeraj Sharma   implement two rou...
748
749
750
        for (let i = 0; i < this.finds.length; i++) {
          this.addGallery.youTubeLinkUrl.push(this.finds[i].value);
        }
8bb178441   Neeraj Sharma   implemnt api in s...
751
752
753
754
755
756
757
758
759
760
761
        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...
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
          if (this.addGallery.youTubeLinkUrl == "") {
            var galleryData = {
              classId: this.addGallery.classNum,
              title: this.addGallery.title,
              description: this.addGallery.description,
              upload: this.addGallery.upload
            };
            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 => {
                if ((this.snackbar = true)) {
                  this.text = error.response.data.message;
                }
              });
          } else if (this.addGallery.youTubeLinkUrl) {
            http()
              .post("/createGallery", this.addGallery)
              .then(response => {
                this.getGalleryList();
0551a0f15   Neeraj Sharma   implemnet functio...
789
                this.files = [];
2ddcef1ce   Neeraj Sharma   solve issue empty...
790
791
792
793
794
795
796
797
798
799
800
801
                this.loading = false;
                this.snackbar = true;
                this.text = response.data.message;
                this.clear();
                this.files = "";
              })
              .catch(error => {
                if ((this.snackbar = true)) {
                  this.text = error.response.data.message;
                }
              });
          }
8bb178441   Neeraj Sharma   implemnt api in s...
802
803
804
805
        }
      },
      clear() {
        this.$refs.form.reset();
0551a0f15   Neeraj Sharma   implemnet functio...
806
        this.files = [];
8bb178441   Neeraj Sharma   implemnt api in s...
807
808
809
      },
      save() {
        this.editedItem.gelleryId = this.editedItem._id;
1571e40b5   Neeraj Sharma   gallery and socia...
810
        var linkUrl = [];
a17c68a03   Neeraj Sharma   implement two rou...
811
        for (let i = 0; i < this.updates.length; i++) {
1571e40b5   Neeraj Sharma   gallery and socia...
812
          linkUrl.push(this.updates[i].youTubeLink);
a17c68a03   Neeraj Sharma   implement two rou...
813
        }
1571e40b5   Neeraj Sharma   gallery and socia...
814
        if (this.editFiles) {
8bb178441   Neeraj Sharma   implemnt api in s...
815
816
          var ary = [];
          var imageData = [];
1571e40b5   Neeraj Sharma   gallery and socia...
817
          ary = this.editFiles;
8bb178441   Neeraj Sharma   implemnt api in s...
818
819
820
          for (let i = 0; i < ary.length; i++) {
            const [baseUrl, imageUrl] = ary[i].split(/,/);
            imageData.push(imageUrl);
1571e40b5   Neeraj Sharma   gallery and socia...
821
            this.editedItem.editFiles = imageData;
8bb178441   Neeraj Sharma   implemnt api in s...
822
823
          }
        }
1571e40b5   Neeraj Sharma   gallery and socia...
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
        if (linkUrl != "") {
          var updateData = {
            galleryId: this.editedItem._id,
            description: this.editedItem.description,
            classId: this.editedItem.classNum,
            uploadImage: this.editedItem.editFiles,
            title: this.editedItem.title,
            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
          };
        }
        http()
          .put("/updateGallery", updateData)
          .then(response => {
            this.getGalleryList();
            this.close();
            this.snackbar = true;
            this.text = response.data.message;
          })
          .catch(error => {
            console.log(error);
          });
8bb178441   Neeraj Sharma   implemnt api in s...
853
854
855
856
857
858
859
860
861
862
863
      },
      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...
864
865
          });
      },
8bb178441   Neeraj Sharma   implemnt api in s...
866
867
868
      addFind: function() {
        this.finds.push({ value: "" });
      },
a17c68a03   Neeraj Sharma   implement two rou...
869
870
871
      update: function() {
        this.updates.push({ youTubeLink: "" });
      },
8bb178441   Neeraj Sharma   implemnt api in s...
872
873
874
      deleteFind: function(index) {
        this.finds.splice(index, 1);
        if (index === 0) this.addFind();
a17c68a03   Neeraj Sharma   implement two rou...
875
876
877
878
879
      },
      deleteUpdate: function(index) {
        this.updates.splice(index, 1);
        if (index === 0) this.update();
      },
1571e40b5   Neeraj Sharma   gallery and socia...
880
      deleteUrl: function(index, youTubelinkId, id) {
a17c68a03   Neeraj Sharma   implement two rou...
881
882
        this.editedItem.youTubeLinkUrl.splice(index, 1);
        if (index === 0) this.update();
a17c68a03   Neeraj Sharma   implement two rou...
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
        let deleteYouTubeUrl = {
          galleryId: id,
          youTubeId: youTubelinkId
        };
        http()
          .put("/deleteYoutubeLink", deleteYouTubeUrl)
          .then(response => {
            this.snackbar = true;
            this.text = response.data.message;
            this.getGalleryList();
            this.close();
          })
          .catch(error => {
            console.log(error);
          });
8bb178441   Neeraj Sharma   implemnt api in s...
898
899
900
901
902
903
      }
    },
    mounted() {
      this.token = this.$store.state.token;
      this.getAllClasses();
      this.getGalleryList();
1571e40b5   Neeraj Sharma   gallery and socia...
904
      // console.log("index",index);
8bb178441   Neeraj Sharma   implemnt api in s...
905
    },
a17c68a03   Neeraj Sharma   implement two rou...
906
907
908
909
910
911
912
913
    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...
914
915
916
917
    }
  };
  </script>
  <style scoped>
8bb178441   Neeraj Sharma   implemnt api in s...
918
919
920
  #td {
    border: 1px solid #dddddd;
    text-align: left;
a17c68a03   Neeraj Sharma   implement two rou...
921
922
    padding: 2px 0px;
    max-width: 200px;
8bb178441   Neeraj Sharma   implemnt api in s...
923
924
  }
  .active {
687e0b929   Neeraj Sharma   add user,attenden...
925
    background-color: gray;
8bb178441   Neeraj Sharma   implemnt api in s...
926
927
928
929
930
    color: white !important;
  }
  .activebtn {
    color: black !important;
  }
8bb178441   Neeraj Sharma   implemnt api in s...
931
  </style>