質問編集履歴
2
誤字の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -322,10 +322,12 @@
|
|
322
322
|
|
323
323
|
### 追記
|
324
324
|
|
325
|
-
|
325
|
+
|
326
326
|
|
327
327
|
* JavaScript
|
328
328
|
|
329
|
+
```
|
330
|
+
|
329
331
|
<template>
|
330
332
|
|
331
333
|
<b-card :header="caption">
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -317,3 +317,263 @@
|
|
317
317
|
|
318
318
|
|
319
319
|
```
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
### 追記
|
324
|
+
|
325
|
+
```
|
326
|
+
|
327
|
+
* JavaScript
|
328
|
+
|
329
|
+
<template>
|
330
|
+
|
331
|
+
<b-card :header="caption">
|
332
|
+
|
333
|
+
<b-table
|
334
|
+
|
335
|
+
:hover="hover"
|
336
|
+
|
337
|
+
:striped="striped"
|
338
|
+
|
339
|
+
:bordered="bordered"
|
340
|
+
|
341
|
+
:small="small"
|
342
|
+
|
343
|
+
:fixed="fixed"
|
344
|
+
|
345
|
+
:items="items"
|
346
|
+
|
347
|
+
:fields="fields"
|
348
|
+
|
349
|
+
:current-page="currentPage"
|
350
|
+
|
351
|
+
:per-page="perPage"
|
352
|
+
|
353
|
+
responsive="sm"
|
354
|
+
|
355
|
+
>
|
356
|
+
|
357
|
+
<template
|
358
|
+
|
359
|
+
slot="切断"
|
360
|
+
|
361
|
+
slot-scope="data"
|
362
|
+
|
363
|
+
>
|
364
|
+
|
365
|
+
<button v-on:click="deleteSession('aiueo');">
|
366
|
+
|
367
|
+
{{ data.value }}
|
368
|
+
|
369
|
+
</button>
|
370
|
+
|
371
|
+
<form method="POST" @submit.prevent="deleteSession('aiueo')">
|
372
|
+
|
373
|
+
<input name="_method" type="hidden" value="DELETE">
|
374
|
+
|
375
|
+
<button type="button" @click="deleteSession">切断する</button>
|
376
|
+
|
377
|
+
</form>
|
378
|
+
|
379
|
+
</template>
|
380
|
+
|
381
|
+
</b-table>
|
382
|
+
|
383
|
+
<nav>
|
384
|
+
|
385
|
+
<b-pagination
|
386
|
+
|
387
|
+
v-model="currentPage"
|
388
|
+
|
389
|
+
:total-rows="getRowCount(items)"
|
390
|
+
|
391
|
+
:per-page="perPage"
|
392
|
+
|
393
|
+
prev-text="Prev"
|
394
|
+
|
395
|
+
next-text="Next"
|
396
|
+
|
397
|
+
hide-goto-end-buttons
|
398
|
+
|
399
|
+
/>
|
400
|
+
|
401
|
+
</nav>
|
402
|
+
|
403
|
+
</b-card>
|
404
|
+
|
405
|
+
</template>
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
<script>
|
410
|
+
|
411
|
+
import axios from 'axios'
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
/**
|
416
|
+
|
417
|
+
* Randomize array element order in-place.
|
418
|
+
|
419
|
+
* Using Durstenfeld shuffle algorithm.
|
420
|
+
|
421
|
+
*/
|
422
|
+
|
423
|
+
const shuffleArray = (array) => {
|
424
|
+
|
425
|
+
for (let i = array.length - 1; i > 0; i--) {
|
426
|
+
|
427
|
+
const j = Math.floor(Math.random() * (i + 1))
|
428
|
+
|
429
|
+
const temp = array[i]
|
430
|
+
|
431
|
+
array[i] = array[j]
|
432
|
+
|
433
|
+
array[j] = temp
|
434
|
+
|
435
|
+
}
|
436
|
+
|
437
|
+
return array
|
438
|
+
|
439
|
+
}
|
440
|
+
|
441
|
+
|
442
|
+
|
443
|
+
export default {
|
444
|
+
|
445
|
+
name : 'CTable',
|
446
|
+
|
447
|
+
props: {
|
448
|
+
|
449
|
+
caption: {
|
450
|
+
|
451
|
+
type : String,
|
452
|
+
|
453
|
+
default: 'Table',
|
454
|
+
|
455
|
+
},
|
456
|
+
|
457
|
+
hover: {
|
458
|
+
|
459
|
+
type : Boolean,
|
460
|
+
|
461
|
+
default: false,
|
462
|
+
|
463
|
+
},
|
464
|
+
|
465
|
+
striped: {
|
466
|
+
|
467
|
+
type : Boolean,
|
468
|
+
|
469
|
+
default: false,
|
470
|
+
|
471
|
+
},
|
472
|
+
|
473
|
+
bordered: {
|
474
|
+
|
475
|
+
type : Boolean,
|
476
|
+
|
477
|
+
default: false,
|
478
|
+
|
479
|
+
},
|
480
|
+
|
481
|
+
small: {
|
482
|
+
|
483
|
+
type : Boolean,
|
484
|
+
|
485
|
+
default: false,
|
486
|
+
|
487
|
+
},
|
488
|
+
|
489
|
+
fixed: {
|
490
|
+
|
491
|
+
type : Boolean,
|
492
|
+
|
493
|
+
default: false,
|
494
|
+
|
495
|
+
},
|
496
|
+
|
497
|
+
fields: {
|
498
|
+
|
499
|
+
type : Array,
|
500
|
+
|
501
|
+
default: false
|
502
|
+
|
503
|
+
},
|
504
|
+
|
505
|
+
sessions: {
|
506
|
+
|
507
|
+
type : Array,
|
508
|
+
|
509
|
+
default: false
|
510
|
+
|
511
|
+
}
|
512
|
+
|
513
|
+
},
|
514
|
+
|
515
|
+
data: () => {
|
516
|
+
|
517
|
+
return {
|
518
|
+
|
519
|
+
currentPage: 1,
|
520
|
+
|
521
|
+
perPage : 20,
|
522
|
+
|
523
|
+
totalRows : 0,
|
524
|
+
|
525
|
+
}
|
526
|
+
|
527
|
+
},
|
528
|
+
|
529
|
+
computed: {
|
530
|
+
|
531
|
+
items() {
|
532
|
+
|
533
|
+
return shuffleArray(
|
534
|
+
|
535
|
+
this.sessions
|
536
|
+
|
537
|
+
)
|
538
|
+
|
539
|
+
}
|
540
|
+
|
541
|
+
},
|
542
|
+
|
543
|
+
methods: {
|
544
|
+
|
545
|
+
getRowCount (items) {
|
546
|
+
|
547
|
+
return items.length
|
548
|
+
|
549
|
+
},
|
550
|
+
|
551
|
+
deleteSession ($sessionName) {
|
552
|
+
|
553
|
+
const params = new URLSearchParams()
|
554
|
+
|
555
|
+
params.append('sessionName', $sessionName)
|
556
|
+
|
557
|
+
axios
|
558
|
+
|
559
|
+
.delete('http://localhost/api/hub/session', { data: params }, {
|
560
|
+
|
561
|
+
headers: {
|
562
|
+
|
563
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
564
|
+
|
565
|
+
},
|
566
|
+
|
567
|
+
})
|
568
|
+
|
569
|
+
.then(response => (console.log(response)))
|
570
|
+
|
571
|
+
}
|
572
|
+
|
573
|
+
},
|
574
|
+
|
575
|
+
}
|
576
|
+
|
577
|
+
</script>
|
578
|
+
|
579
|
+
```
|