Blame view

src/pages/News/news.vue 20.9 KB
6566e8f29   Neeraj Sharma   design and functi...
1
  <template>
68d742034   Neeraj Sharma   implement new des...
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
    <v-container fluid class="body-color">
      <!-- ****** EDIT NEWS  ****** -->
      <v-dialog v-model="editNewsDialog" max-width="600px">
        <v-card flat class="card-style pa-2" dark>
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">Edit News</label>
              <v-icon size="24" class="right" @click="editNewsDialog = false">cancel</v-icon>
            </v-flex>
          </v-layout>
          <v-card-text>
            <v-layout row>
              <v-flex xs12 class="text-xs-center text-sm-center text-md-center text-lg-center my-4">
                <input
                  type="file"
                  style="display: none"
                  ref="image"
                  accept="image/*"
                  multiple
                  @change="onFilePicked"
                />
                <v-layout justify-center>
f4df757fe   Neeraj Sharma   responsive vie in...
24
25
                  <v-flex
                    xs12
68d742034   Neeraj Sharma   implement new des...
26
27
28
29
30
31
                    sm12
                    md3
                    v-for="Image in editedItem.newsImageUrl"
                    :key="Image._id"
                    v-if="editedItem.newsImageUrl"
                    class="profile-image-wrapper"
f4df757fe   Neeraj Sharma   responsive vie in...
32
                  >
68d742034   Neeraj Sharma   implement new des...
33
34
35
36
37
38
                    <img
                      :src="Image.imageUrl"
                      height="100"
                      width="100"
                      alt="News"
                      class="pa-2 imgNews"
f4df757fe   Neeraj Sharma   responsive vie in...
39
                    />
68d742034   Neeraj Sharma   implement new des...
40
41
42
43
44
                    <v-icon
                      class="red edit-profile-icon"
                      dark
                      @click="deleteImage(Image._id,editedItem._id)"
                    >close</v-icon>
f4df757fe   Neeraj Sharma   responsive vie in...
45
                  </v-flex>
68d742034   Neeraj Sharma   implement new des...
46
47
48
49
50
51
52
53
54
55
                  <v-flex v-for="(file, index) in files" :key="index">
                    <img :src="file" height="100" width="100" class="pa-2" />
                  </v-flex>
                  <img
                    src="/static/icon/user.png"
                    v-if="files == '' && editedItem.newsImageUrl == ''"
                    height="100"
                    width="100"
                    alt="News"
                  />
f4df757fe   Neeraj Sharma   responsive vie in...
56
                </v-layout>
68d742034   Neeraj Sharma   implement new des...
57
58
59
60
61
62
63
64
              </v-flex>
            </v-layout>
            <!-- </v-layout> -->
            <v-layout wrap>
              <v-flex xs12 sm12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Title:</label>
f4df757fe   Neeraj Sharma   responsive vie in...
65
                  </v-flex>
68d742034   Neeraj Sharma   implement new des...
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
                  <v-flex sm6 xs8 class="ml-3">
                    <v-text-field
                      v-model="editedItem.title"
                      placeholder="fill your Title"
                      name="name"
                      type="text"
                      required
                    ></v-text-field>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12 sm12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Description:</label>
f4df757fe   Neeraj Sharma   responsive vie in...
81
                  </v-flex>
68d742034   Neeraj Sharma   implement new des...
82
83
84
85
86
87
88
89
                  <v-flex sm6 xs8 class="ml-3">
                    <v-text-field
                      placeholder="fill your Description"
                      v-model="editedItem.description"
                      type="text"
                      name="email"
                      required
                    ></v-text-field>
f4df757fe   Neeraj Sharma   responsive vie in...
90
91
                  </v-flex>
                </v-layout>
68d742034   Neeraj Sharma   implement new des...
92
93
              </v-flex>
              <v-flex xs12>
f4df757fe   Neeraj Sharma   responsive vie in...
94
                <v-layout>
68d742034   Neeraj Sharma   implement new des...
95
96
97
98
99
100
101
102
103
104
105
106
                  <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">Uplaod :</label>
                  </v-flex>
                  <v-flex sm6 xs8 class="ml-3">
                    <v-text-field
                      label="Select Image"
                      @click="pickFile"
                      v-model="imageName"
                      append-icon="attach_file"
                      multiple
                    ></v-text-field>
f4df757fe   Neeraj Sharma   responsive vie in...
107
108
                  </v-flex>
                </v-layout>
68d742034   Neeraj Sharma   implement new des...
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
              </v-flex>
            </v-layout>
            <v-layout>
              <v-flex xs12 sm9 offset-sm2 class="hidden-xs-only hidden-sm-only">
                <v-card-actions>
                  <v-spacer></v-spacer>
                  <v-btn round dark @click="save" class="add-button">Save</v-btn>
                </v-card-actions>
              </v-flex>
              <v-flex xs12 class="hidden-lg-only hidden-md-only hidden-xl-only">
                <v-card-actions>
                  <v-spacer></v-spacer>
                  <v-btn round dark @click="save" class="add-button">Save</v-btn>
                  <v-spacer></v-spacer>
                </v-card-actions>
              </v-flex>
            </v-layout>
          </v-card-text>
        </v-card>
      </v-dialog>
      <!-- ****** PROFILE  NEWS  ******  -->
      <v-dialog v-model="dialog1" max-width="500px">
        <v-card flat class="card-style pa-3" dark>
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">View News</label>
              <v-icon size="24" class="right" @click="dialog1 = false">cancel</v-icon>
            </v-flex>
          </v-layout>
          <v-card-text>
            <v-flex align-center justify-center layout text-xs-center>
              <span v-for="(image,i) in editedItem.newsImageUrl" :key="i" class="pa-2">
                <img :src="image.imageUrl" alt="News" width="100" height="100" class="imgNews" />
              </span>
              <img
                src="/static/icon/user.png"
                v-if="editedItem.newsImageUrl == ''"
                height="80"
                width="80"
                alt="News"
              />
            </v-flex>
            <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>
6566e8f29   Neeraj Sharma   design and functi...
159
                    </v-flex>
68d742034   Neeraj Sharma   implement new des...
160
161
                    <v-flex sm6 xs8>
                      <h5 class="my-1">{{ editedItem.title }}</h5>
5b841b043   Neeraj Sharma   fix upload dyanm...
162
                    </v-flex>
68d742034   Neeraj Sharma   implement new des...
163
164
165
166
167
168
                  </v-layout>
                  <v-layout>
                    <v-flex xs5 sm6>
                      <h5 class="right my-1">
                        <b>Description:</b>
                      </h5>
5b841b043   Neeraj Sharma   fix upload dyanm...
169
                    </v-flex>
68d742034   Neeraj Sharma   implement new des...
170
171
                    <v-flex sm6 xs8>
                      <h5 class="my-1">{{ editedItem.description }}</h5>
5b841b043   Neeraj Sharma   fix upload dyanm...
172
                    </v-flex>
68d742034   Neeraj Sharma   implement new des...
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
                  </v-layout>
                </v-flex>
              </v-layout>
            </v-container>
          </v-card-text>
        </v-card>
      </v-dialog>
      <!-- ****** EXISTING-USERS NEWS TABLE ****** -->
      <v-toolbar color="transparent" flat>
        <v-btn
          fab
          dark
          class="open-dialog-button hidden-xl-only hidden-md-only hidden-lg-only"
          small
          @click="addNewsDialog = true"
        >
          <v-icon dark>add</v-icon>
        </v-btn>
        <v-btn
          round
          class="open-dialog-button hidden-sm-only hidden-xs-only"
          dark
          @click="addNewsDialog = true"
        >
          <v-icon class="white--text pr-1" size="20">add</v-icon>Add News
        </v-btn>
        <v-spacer></v-spacer>
        <v-card-title class="body-1" v-show="show">
          <v-btn icon large flat @click="displaySearch">
            <v-avatar size="27">
aa310d61a   Shikha Mishra   added functionali...
203
              <img src="/static/icon/search.png" alt="icon" />
68d742034   Neeraj Sharma   implement new des...
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
            </v-avatar>
          </v-btn>
        </v-card-title>
        <v-flex xs8 sm8 md3 lg2 v-show="showSearch">
          <v-layout>
            <v-text-field v-model="search" label="Search" prepend-inner-icon="search" color="primary"></v-text-field>
            <v-icon @click="closeSearch" color="error">close</v-icon>
          </v-layout>
        </v-flex>
      </v-toolbar>
      <v-data-table
        :headers="headers"
        :items="desserts"
        :pagination.sync="pagination"
        :search="search"
      >
        <template slot="items" slot-scope="props">
          <tr class="tr">
            <td class="td td-row">{{ props.index + 1}}</td>
            <td class="td td-row text-xs-center">
              <span v-for="(image,_id) in props.item.newsImageUrl" class="pa-2">
                <img :src="image.imageUrl" alt="newsImage" width="40" height="40" />
              </span>
              <img
                src="/static/icon/user.png"
                v-if="props.item.newsImageUrl == ''"
                width="40"
                alt="News"
              />
            </td>
            <td class="td td-row text-xs-center">{{ props.item.title}}</td>
            <td class="td td-row text-xs-center">{{ props.item.description}}</td>
  
            <td class="td td-row text-xs-center">
              <span>
                <v-tooltip top>
                  <img
                    slot="activator"
                    style="cursor:pointer; width:25px; height:25px; "
                    class="mr-3"
                    @click="profile(props.item)"
aa310d61a   Shikha Mishra   added functionali...
245
                    src="/static/icon/view.png"
68d742034   Neeraj Sharma   implement new des...
246
247
248
249
250
251
252
253
254
                  />
                  <span>View</span>
                </v-tooltip>
                <v-tooltip top>
                  <img
                    slot="activator"
                    style="cursor:pointer; width:20px; height:18px; "
                    class="mr-3"
                    @click="editItem(props.item)"
aa310d61a   Shikha Mishra   added functionali...
255
                    src="/static/icon/edit.png"
68d742034   Neeraj Sharma   implement new des...
256
257
258
259
260
261
262
263
                  />
                  <span>Edit</span>
                </v-tooltip>
                <v-tooltip top>
                  <img
                    slot="activator"
                    style="cursor:pointer; width:20px; height:20px; "
                    @click="deleteItem(props.item)"
aa310d61a   Shikha Mishra   added functionali...
264
                    src="/static/icon/delete.png"
68d742034   Neeraj Sharma   implement new des...
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
                  />
                  <span>Delete</span>
                </v-tooltip>
              </span>
            </td>
          </tr>
        </template>
        <v-alert
          slot="no-results"
          :value="true"
          color="error"
          icon="warning"
        >Your search for "{{ search }}" found no results.</v-alert>
      </v-data-table>
      <!-- ****** ADD  NEWS ****** -->
      <v-dialog v-model="addNewsDialog" max-width="600px">
        <v-card flat class="card-style pa-2" dark>
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">Add News</label>
              <v-icon size="24" class="right" @click="addNewsDialog = false">cancel</v-icon>
6566e8f29   Neeraj Sharma   design and functi...
286
            </v-flex>
68d742034   Neeraj Sharma   implement new des...
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
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
362
363
364
365
366
367
368
369
370
371
          </v-layout>
          <v-form ref="form" v-model="valid" lazy-validation>
            <v-container fluid>
              <v-layout>
                <v-flex xs12 class="text-xs-center text-sm-center text-md-center text-lg-center my-4">
                  <input
                    type="file"
                    style="display: none"
                    ref="image"
                    accept="image/*"
                    multiple
                    @change="onFilePicked"
                  />
                  <v-layout justify-center>
                    <v-flex v-for="(file,index) in files" :key="index" v-if="files">
                      <img :src="file" height="100" width="100;" class="imgNews" />
                    </v-flex>
                  </v-layout>
                  <img src="/static/icon/user.png" v-if="files ==''" height="80" width="80" />
                </v-flex>
              </v-layout>
              <v-flex xs12>
                <v-layout>
                  <v-flex xs4 sm4 class="pt-4 subheading">
                    <label class="right">Title:</label>
                  </v-flex>
                  <v-flex sm6 xs8 class="ml-3">
                    <v-text-field
                      v-model="addNews.title"
                      placeholder="fill your Title"
                      name="name"
                      type="text"
                      :rules="titleRules"
                      required
                    ></v-text-field>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Description:</label>
                  </v-flex>
                  <v-flex sm6 xs8 class="ml-3">
                    <v-text-field
                      placeholder="fill your Description"
                      :rules="descriptionRules"
                      v-model="addNews.description"
                      type="text"
                      name="email"
                      required
                    ></v-text-field>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right hidden-xs-only hidden-sm-only">Uplaod Image:</label>
                    <label class="right hidden-lg-only hidden-md-only hidden-xl-only">Uplaod :</label>
                  </v-flex>
                  <v-flex xs8 sm6 class="ml-3">
                    <v-text-field
                      label="Select Image"
                      @click="pickFile"
                      v-model="imageName"
                      append-icon="attach_file"
                      multiple
                    ></v-text-field>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-layout>
                <v-flex xs11>
                  <v-layout>
                    <v-spacer></v-spacer>
                    <v-btn @click="clear" round class="clear-button" dark>clear</v-btn>
                    <v-btn @click="submit" round dark :loading="loading" class="add-button">Add</v-btn>
                  </v-layout>
                </v-flex>
              </v-layout>
            </v-container>
          </v-form>
        </v-card>
      </v-dialog>
4b169b574   Neeraj Sharma   add loader in all...
372
373
374
      <div class="loader" v-if="showLoader">
        <v-progress-circular indeterminate color="white"></v-progress-circular>
      </div>
68d742034   Neeraj Sharma   implement new des...
375
    </v-container>
6566e8f29   Neeraj Sharma   design and functi...
376
377
378
379
  </template>
  
  <script>
  import http from "@/Services/http.js";
6566e8f29   Neeraj Sharma   design and functi...
380
381
382
383
384
385
386
  
  export default {
    data: () => ({
      snackbar: false,
      y: "top",
      x: "right",
      mode: "",
68d742034   Neeraj Sharma   implement new des...
387
388
      timeout: 5000,
      color: "",
6566e8f29   Neeraj Sharma   design and functi...
389
390
391
392
      text: "",
      loading: false,
      date: null,
      search: "",
68d742034   Neeraj Sharma   implement new des...
393
394
      show: true,
      showSearch: false,
5b841b043   Neeraj Sharma   fix upload dyanm...
395
      showLoader: false,
68d742034   Neeraj Sharma   implement new des...
396
397
      editNewsDialog: false,
      addNewsDialog: false,
6566e8f29   Neeraj Sharma   design and functi...
398
399
      dialog1: false,
      valid: true,
6566e8f29   Neeraj Sharma   design and functi...
400
401
      addclass: [],
      addSection: [],
6566e8f29   Neeraj Sharma   design and functi...
402
      pagination: {
68d742034   Neeraj Sharma   implement new des...
403
        rowsPerPage: 10
6566e8f29   Neeraj Sharma   design and functi...
404
      },
6566e8f29   Neeraj Sharma   design and functi...
405
406
407
      imageName: "",
      imageUrl: "",
      imageFile: "",
2b0e316ee   Neeraj Sharma   upload mytiple im...
408
      image: [],
5b841b043   Neeraj Sharma   fix upload dyanm...
409
410
      upload: "",
      files: [],
6566e8f29   Neeraj Sharma   design and functi...
411
412
413
414
      titleRules: [v => !!v || " Tilte is required"],
      descriptionRules: [v => !!v || " Description is required"],
      headers: [
        {
5f1d4b444   Neeraj Sharma   fix design and fi...
415
          align: "justify-center",
506be6fd7   Neeraj Sharma   implemet dyamic i...
416
          text: "No",
6566e8f29   Neeraj Sharma   design and functi...
417
418
419
          sortable: false,
          value: "No"
        },
5b841b043   Neeraj Sharma   fix upload dyanm...
420
        { text: "Image", vaue: "image", sortable: false, align: "center" },
6566e8f29   Neeraj Sharma   design and functi...
421
        { text: "Title", value: "title", sortable: false, align: "center" },
5b841b043   Neeraj Sharma   fix upload dyanm...
422
423
424
425
426
427
        {
          text: "Description",
          value: "description",
          sortable: false,
          align: "center"
        },
6566e8f29   Neeraj Sharma   design and functi...
428
429
        { text: "Action", value: "", sortable: false, align: "center" }
      ],
8bb178441   Neeraj Sharma   implemnt api in s...
430
      desserts: [],
6566e8f29   Neeraj Sharma   design and functi...
431
432
433
      editedIndex: -1,
      addNews: {
        title: "",
5b841b043   Neeraj Sharma   fix upload dyanm...
434
        description: ""
6566e8f29   Neeraj Sharma   design and functi...
435
436
437
      },
      editedItem: {
        title: "",
5b841b043   Neeraj Sharma   fix upload dyanm...
438
        description: ""
6566e8f29   Neeraj Sharma   design and functi...
439
440
441
442
      },
      defaultItem: {
        title: "",
        description: ""
aa8fc5033   Neeraj Sharma   implenment all pa...
443
      }
6566e8f29   Neeraj Sharma   design and functi...
444
    }),
6566e8f29   Neeraj Sharma   design and functi...
445
446
447
448
449
450
451
452
453
454
455
456
457
    methods: {
      getSections(_id) {
        var token = this.$store.state.token;
        http()
          .get(
            "/getSectionsList",
            { params: { classId: _id } },
            {
              headers: { Authorization: "Bearer " + token }
            }
          )
          .then(response => {
            this.addSection = response.data.data;
6566e8f29   Neeraj Sharma   design and functi...
458
459
          })
          .catch(err => {
5f1d4b444   Neeraj Sharma   fix design and fi...
460
            console.log("err====>", err);
6566e8f29   Neeraj Sharma   design and functi...
461
462
463
464
465
          });
      },
      pickFile() {
        this.$refs.image.click();
      },
6566e8f29   Neeraj Sharma   design and functi...
466
467
468
      onFilePicked(e) {
        // console.log(e)
        const files = e.target.files;
5b841b043   Neeraj Sharma   fix upload dyanm...
469
        /** fetch Image Name **/
6566e8f29   Neeraj Sharma   design and functi...
470
471
472
473
        if (files[0] !== undefined) {
          this.imageName = files[0].name;
          if (this.imageName.lastIndexOf(".") <= 0) {
            return;
5b841b043   Neeraj Sharma   fix upload dyanm...
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
          }
          this.files = [];
          // console.log("files", this.files);
          /** Select many image and showing many image add to news 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
                );
              };
            });
            fr.readAsDataURL(file);
            return getResult.then(file => {
              return file;
            });
6566e8f29   Neeraj Sharma   design and functi...
492
          });
5b841b043   Neeraj Sharma   fix upload dyanm...
493
494
495
496
497
          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...
            // console.log("uploadImage=======>", this.imageFile );
2b0e316ee   Neeraj Sharma   upload mytiple im...
498
          });
6566e8f29   Neeraj Sharma   design and functi...
499
500
501
502
503
504
505
        } else {
          this.imageName = "";
          this.imageFile = "";
          this.imageUrl = "";
        }
      },
      getNewsList() {
4b169b574   Neeraj Sharma   add loader in all...
506
        this.showLoader = true;
6566e8f29   Neeraj Sharma   design and functi...
507
508
509
510
511
512
513
        var token = this.$store.state.token;
        http()
          .get("/getNewsList", {
            headers: { Authorization: "Bearer " + token }
          })
          .then(response => {
            this.desserts = response.data.data;
4b169b574   Neeraj Sharma   add loader in all...
514
            this.showLoader = false;
6566e8f29   Neeraj Sharma   design and functi...
515
          })
00e4bc4e1   Neeraj Sharma   fixed auntentication
516
          .catch(error => {
4b169b574   Neeraj Sharma   add loader in all...
517
            this.showLoader = false;
aa8fc5033   Neeraj Sharma   implenment all pa...
518
            if (error.response.status === 401) {
a17c68a03   Neeraj Sharma   implement two rou...
519
520
521
522
              this.$router.replace({ path: "/" });
              this.$store.dispatch("setToken", null);
              this.$store.dispatch("Id", null);
            }
6566e8f29   Neeraj Sharma   design and functi...
523
524
525
          });
      },
      editItem(item) {
8e6d1a7d7   Neeraj Sharma   solve bugs uplaod...
526
        this.files = [];
6566e8f29   Neeraj Sharma   design and functi...
527
528
        this.editedIndex = this.desserts.indexOf(item);
        this.editedItem = Object.assign({}, item);
68d742034   Neeraj Sharma   implement new des...
529
        this.editNewsDialog = true;
6566e8f29   Neeraj Sharma   design and functi...
530
531
532
533
534
535
      },
      profile(item) {
        this.editedIndex = this.desserts.indexOf(item);
        this.editedItem = Object.assign({}, item);
        this.dialog1 = true;
      },
6566e8f29   Neeraj Sharma   design and functi...
536
537
538
539
540
541
542
543
544
545
546
547
      deleteItem(item) {
        let deleteNews = {
          newsId: item._id
        };
        http()
          .delete(
            "/deleteNews",
            confirm("Are you sure you want to delete this?") && {
              params: deleteNews
            }
          )
          .then(response => {
68d742034   Neeraj Sharma   implement new des...
548
549
550
            this.snackbar = true;
            this.text = response.data.message;
            this.color = "green";
6566e8f29   Neeraj Sharma   design and functi...
551
552
553
            this.getNewsList();
          })
          .catch(error => {
68d742034   Neeraj Sharma   implement new des...
554
555
556
            this.snackbar = true;
            this.color = "error";
            this.text = error.response.data.message;
6566e8f29   Neeraj Sharma   design and functi...
557
558
          });
      },
5b841b043   Neeraj Sharma   fix upload dyanm...
559
      deleteImage(imageId, newsId) {
5b841b043   Neeraj Sharma   fix upload dyanm...
560
        let deleteImages = {
79006bdcb   Neeraj Sharma   uplaod images all...
561
562
563
564
565
566
          newsId: newsId,
          imageId: imageId
        };
        http()
          .put("/deleteImages", deleteImages)
          .then(response => {
68d742034   Neeraj Sharma   implement new des...
567
568
569
            this.snackbar = true;
            this.text = response.data.message;
            this.color = "green";
8e6d1a7d7   Neeraj Sharma   solve bugs uplaod...
570
            this.close();
79006bdcb   Neeraj Sharma   uplaod images all...
571
572
          })
          .catch(error => {
68d742034   Neeraj Sharma   implement new des...
573
574
575
            this.snackbar = true;
            this.color = "error";
            this.text = error.response.data.message;
79006bdcb   Neeraj Sharma   uplaod images all...
576
577
          });
      },
6566e8f29   Neeraj Sharma   design and functi...
578
579
      close() {
        this.dialog = false;
6566e8f29   Neeraj Sharma   design and functi...
580
581
582
583
      },
      close1() {
        this.dialog1 = false;
      },
6566e8f29   Neeraj Sharma   design and functi...
584
585
      submit() {
        if (this.$refs.form.validate()) {
5b841b043   Neeraj Sharma   fix upload dyanm...
586
587
588
589
590
591
592
593
594
595
596
597
598
          let newsData = {
            title: this.addNews.title,
            description: this.addNews.description
          };
          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);
              newsData.upload = imageData;
            }
2b0e316ee   Neeraj Sharma   upload mytiple im...
599
          }
9a1e18aba   Neeraj Sharma   display static im...
600
          this.loading = true;
6566e8f29   Neeraj Sharma   design and functi...
601
          http()
2b0e316ee   Neeraj Sharma   upload mytiple im...
602
            .post("/createNews", newsData)
6566e8f29   Neeraj Sharma   design and functi...
603
            .then(response => {
0551a0f15   Neeraj Sharma   implemnet functio...
604
605
              this.files = [];
              this.snackbar = true;
68d742034   Neeraj Sharma   implement new des...
606
              this.text = response.data.message;
6566e8f29   Neeraj Sharma   design and functi...
607
              this.getNewsList();
68d742034   Neeraj Sharma   implement new des...
608
609
              this.color = "green";
              this.addNewsDialog = false;
506be6fd7   Neeraj Sharma   implemet dyamic i...
610
              this.loading = false;
6566e8f29   Neeraj Sharma   design and functi...
611
612
613
              this.clear();
            })
            .catch(error => {
0551a0f15   Neeraj Sharma   implemnet functio...
614
615
              this.snackbar = true;
              this.text = error.response.data.message;
68d742034   Neeraj Sharma   implement new des...
616
              this.color = "error";
6566e8f29   Neeraj Sharma   design and functi...
617
618
619
            });
        }
      },
6566e8f29   Neeraj Sharma   design and functi...
620
621
      clear() {
        this.$refs.form.reset();
0551a0f15   Neeraj Sharma   implemnet functio...
622
        this.files = [];
6566e8f29   Neeraj Sharma   design and functi...
623
624
      },
      save() {
5b841b043   Neeraj Sharma   fix upload dyanm...
625
626
627
        let editNews = {
          title: this.editedItem.title,
          description: this.editedItem.description,
a17c68a03   Neeraj Sharma   implement two rou...
628
          newsId: this.editedItem._id
5b841b043   Neeraj Sharma   fix upload dyanm...
629
630
        };
        if (this.files) {
a17c68a03   Neeraj Sharma   implement two rou...
631
632
633
634
635
636
637
          var ary = [];
          var imageData = [];
          ary = this.files;
          for (let i = 0; i < ary.length; i++) {
            const [baseUrl, imageUrl] = ary[i].split(/,/);
            imageData.push(imageUrl);
            editNews.upload = imageData;
5b841b043   Neeraj Sharma   fix upload dyanm...
638
          }
a17c68a03   Neeraj Sharma   implement two rou...
639
        }
6566e8f29   Neeraj Sharma   design and functi...
640
641
642
        http()
          .put("/updateNews", editNews)
          .then(response => {
68d742034   Neeraj Sharma   implement new des...
643
            this.snackbar = true;
d5fcb1cd1   Shikha Mishra   issues resolved
644
            this.text = "Successfully updated News";
68d742034   Neeraj Sharma   implement new des...
645
            this.color = "green";
d5fcb1cd1   Shikha Mishra   issues resolved
646
            this.editNewsDialog = false;
6566e8f29   Neeraj Sharma   design and functi...
647
            this.getNewsList();
79006bdcb   Neeraj Sharma   uplaod images all...
648
            this.close();
6566e8f29   Neeraj Sharma   design and functi...
649
650
          })
          .catch(error => {
68d742034   Neeraj Sharma   implement new des...
651
652
653
            this.snackbar = true;
            this.color = "error";
            this.text = error.response.data.message;
6566e8f29   Neeraj Sharma   design and functi...
654
          });
68d742034   Neeraj Sharma   implement new des...
655
656
657
658
659
660
661
662
      },
      displaySearch() {
        (this.show = false), (this.showSearch = true);
      },
      closeSearch() {
        this.showSearch = false;
        this.show = true;
        this.search = "";
aa8fc5033   Neeraj Sharma   implenment all pa...
663
      }
6566e8f29   Neeraj Sharma   design and functi...
664
665
666
    },
    mounted() {
      this.getNewsList();
5b841b043   Neeraj Sharma   fix upload dyanm...
667
      this.editItem;
6566e8f29   Neeraj Sharma   design and functi...
668
669
    }
  };
68d742034   Neeraj Sharma   implement new des...
670
  </script>