|
152 | 152 | </div>
|
153 | 153 | <div class="flex items-center pb-4 justify-between">
|
154 | 154 | <span
|
155 |
| - @click.prevent="followLogs = !followLogs" |
| 155 | + @click.prevent="setFollowLogs(!followLogs)" |
156 | 156 | class="mr-3 cursor-pointer" id="annual-billing-label">
|
157 | 157 | <span class="text-sm font-medium dark:text-gray-200 text-gray-900">Follow Requests:</span>
|
158 | 158 | </span>
|
|
161 | 161 | 'bg-pink-500': followLogs,
|
162 | 162 | 'dark:bg-gray-700 bg-gray-200': ! followLogs,
|
163 | 163 | }"
|
164 |
| - @click.prevent="followLogs = !followLogs" |
| 164 | + @click.prevent="setFollowLogs(!followLogs)" |
165 | 165 | class=" relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-pink-500" role="switch" aria-checked="false" aria-labelledby="annual-billing-label">
|
166 | 166 | <span class="sr-only">Follow Request</span>
|
167 | 167 | <!-- Enabled: "translate-x-5", Not Enabled: "translate-x-0" -->
|
|
175 | 175 | </div>
|
176 | 176 | <div class="flex items-center pb-4 justify-between">
|
177 | 177 | <span
|
178 |
| - @click.prevent="sideBySide = !sideBySide" |
| 178 | + @click.prevent="setSideBySide(!sideBySide)" |
179 | 179 | class="mr-3 cursor-pointer" id="annual-billing-label">
|
180 | 180 | <span class="text-sm font-medium dark:text-gray-200 text-gray-900">Show Request/Response in individual tabs:</span>
|
181 | 181 | </span>
|
|
184 | 184 | 'bg-pink-500': sideBySide,
|
185 | 185 | 'dark:bg-gray-700 bg-gray-200': ! sideBySide,
|
186 | 186 | }"
|
187 |
| - @click.prevent="sideBySide = !sideBySide" |
| 187 | + @click.prevent="setSideBySide(!sideBySide)" |
188 | 188 | class=" relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-pink-500" role="switch" aria-checked="false" aria-labelledby="annual-billing-label">
|
189 | 189 | <span class="sr-only">Follow Request</span>
|
190 | 190 | <span aria-hidden="true"
|
|
393 | 393 | <div class="flex">
|
394 | 394 | <svg
|
395 | 395 | v-if="postParametersVisible"
|
396 |
| - @click="postParametersVisible = false" |
| 396 | + @click="setPostParametersVisible(false)" |
397 | 397 | xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="cursor-pointer w-6 h-6 mr-4">
|
398 | 398 | <path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5" />
|
399 | 399 | </svg>
|
400 | 400 | <svg
|
401 | 401 | v-if="! postParametersVisible"
|
402 |
| - @click="postParametersVisible = true" |
| 402 | + @click="setPostParametersVisible(true)" |
403 | 403 | xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="cursor-pointer w-6 h-6 mr-4">
|
404 | 404 | <path stroke-linecap="round" stroke-linejoin="round" d="M8.25 4.5l7.5 7.5-7.5 7.5" />
|
405 | 405 | </svg>
|
|
434 | 434 | <div class="flex">
|
435 | 435 | <svg
|
436 | 436 | v-if="requestHeadersVisible"
|
437 |
| - @click="requestHeadersVisible = false" |
| 437 | + @click="setRequestHeadersVisible(false)" |
438 | 438 | xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="cursor-pointer w-6 h-6 mr-4">
|
439 | 439 | <path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5" />
|
440 | 440 | </svg>
|
441 | 441 | <svg
|
442 | 442 | v-if="! requestHeadersVisible"
|
443 |
| - @click="requestHeadersVisible = true" |
| 443 | + @click="setRequestHeadersVisible(true)" |
444 | 444 | xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="cursor-pointer w-6 h-6 mr-4">
|
445 | 445 | <path stroke-linecap="round" stroke-linejoin="round" d="M8.25 4.5l7.5 7.5-7.5 7.5" />
|
446 | 446 | </svg>
|
|
458 | 458 | </span>
|
459 | 459 | </div>
|
460 | 460 | <div
|
461 |
| - v-if="requestHeadersVisible" |
| 461 | + v-if="requestHeadersVisible && currentLog.request" |
462 | 462 | v-for="(value, header) in currentLog.request.headers"
|
463 | 463 | :key="header"
|
464 | 464 | class="even:bg-gray-50 bg-gray-50 dark:even:bg-gray-700 dark:bg-gray-800 px-4 py-3 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
|
512 | 512 |
|
513 | 513 | <svg
|
514 | 514 | v-if="responseHeadersVisible"
|
515 |
| - @click="responseHeadersVisible = false" |
| 515 | + @click="setResponseHeadersVisible(false)" |
516 | 516 | xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="cursor-pointer w-6 h-6 mr-4">
|
517 | 517 | <path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5" />
|
518 | 518 | </svg>
|
519 | 519 | <svg
|
520 | 520 | v-if="! responseHeadersVisible"
|
521 |
| - @click="responseHeadersVisible = true" |
| 521 | + @click="setResponseHeadersVisible(true)" |
522 | 522 | xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="cursor-pointer w-6 h-6 mr-4">
|
523 | 523 | <path stroke-linecap="round" stroke-linejoin="round" d="M8.25 4.5l7.5 7.5-7.5 7.5" />
|
524 | 524 | </svg>
|
|
530 | 530 | </div>
|
531 | 531 | <div
|
532 | 532 | v-if="responseHeadersVisible"
|
533 |
| - v-for="(value, header) in currentLog.response.headers" |
| 533 | + v-for="(value, header) in responseHeaders" |
534 | 534 | :key="header"
|
535 | 535 | class="even:bg-gray-50 odd:bg-gray-50 dark:even:bg-gray-700 dark:odd:bg-gray-800 px-4 py-3 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
536 | 536 | <dt class="text-sm leading-5 font-medium dark:text-gray-200 text-gray-700">
|
|
586 | 586 | </nav>
|
587 | 587 | </h3>
|
588 | 588 | </div>
|
589 |
| - <div v-if="activeTab === 'raw'"> |
| 589 | + <div v-if="activeTab === 'raw' && currentLog.response"> |
590 | 590 | <json-viewer
|
591 | 591 | v-if="responseIsJson()"
|
592 | 592 | :expand-depth="2"
|
|
598 | 598 | class="p-6 text-sm whitespace-pre-wrap break-all">@{ currentLog.response.body }</pre>
|
599 | 599 | </div>
|
600 | 600 | <div v-if="activeTab === 'preview'">
|
601 |
| - <iframe v-else :srcdoc="currentLog.response.body" style="height: 500px;" class="w-full h-full"></iframe> |
| 601 | + <iframe :srcdoc="currentLog.response.body" style="height: 500px;" class="w-full h-full"></iframe> |
602 | 602 | </div>
|
603 | 603 | </div>
|
604 | 604 | </div>
|
|
627 | 627 | logs: [],
|
628 | 628 | maxLogs: {{ max_logs }},
|
629 | 629 | highlightNextLog: false,
|
630 |
| - followLogs: true, |
631 |
| - sideBySide: false, |
632 |
| - useDarkMode: window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches, |
633 |
| - postParametersVisible: true, |
634 |
| - requestHeadersVisible: true, |
635 |
| - responseHeadersVisible: true, |
| 630 | + followLogs: window.localStorage.getItem('followLogs') !== null ? window.localStorage.getItem('followLogs') === 'true' : true, |
| 631 | + sideBySide: window.localStorage.getItem('sideBySide') === 'true', |
| 632 | + useDarkMode: window.localStorage.getItem('useDarkMode') !== null ? window.localStorage.getItem('useDarkMode') === 'true' : (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches), |
| 633 | + postParametersVisible: window.localStorage.getItem('postParametersVisible') !== null ? window.localStorage.getItem('postParametersVisible') === 'true' : true, |
| 634 | + requestHeadersVisible: window.localStorage.getItem('requestHeadersVisible') !== null ? window.localStorage.getItem('requestHeadersVisible') === 'true' : true, |
| 635 | + responseHeadersVisible: window.localStorage.getItem('responseHeadersVisible') !== null ? window.localStorage.getItem('responseHeadersVisible') === 'true' : true, |
636 | 636 | },
|
637 | 637 |
|
638 | 638 | watch: {
|
639 | 639 | useDarkMode: {
|
640 | 640 | handler: function(value) {
|
641 | 641 | if (value) {
|
642 | 642 | document.querySelector('html').classList.add('dark')
|
| 643 | + window.localStorage.setItem('useDarkMode', 'true') |
643 | 644 | } else {
|
644 | 645 | document.querySelector('html').classList.remove('dark')
|
| 646 | + window.localStorage.setItem('useDarkMode', 'false') |
645 | 647 | }
|
646 | 648 | },
|
647 | 649 | immediate: true,
|
|
654 | 656 | return log.id === this.currentLogId;
|
655 | 657 | });
|
656 | 658 | },
|
| 659 | +
|
| 660 | + responseHeaders: function() { |
| 661 | + if (this.currentLog && this.currentLog.response) { |
| 662 | + return this.currentLog.response.headers; |
| 663 | + } |
| 664 | +
|
| 665 | + return []; |
| 666 | + }, |
| 667 | +
|
657 | 668 | filteredLogs: function() {
|
658 | 669 | if (this.search === '') {
|
659 | 670 | return this.logs;
|
|
665 | 676 | },
|
666 | 677 |
|
667 | 678 | methods: {
|
| 679 | + setFollowLogs: function(value) { |
| 680 | + this.followLogs = value; |
| 681 | + window.localStorage.setItem('followLogs', value); |
| 682 | + }, |
| 683 | +
|
| 684 | + setSideBySide: function(value) { |
| 685 | + this.sideBySide = value; |
| 686 | + window.localStorage.setItem('sideBySide', value); |
| 687 | + }, |
| 688 | +
|
| 689 | + setPostParametersVisible: function(value) { |
| 690 | + this.postParametersVisible = value; |
| 691 | + window.localStorage.setItem('postParametersVisible', value); |
| 692 | + }, |
| 693 | +
|
| 694 | + setRequestHeadersVisible: function(value) { |
| 695 | + this.requestHeadersVisible = value; |
| 696 | + window.localStorage.setItem('requestHeadersVisible', value); |
| 697 | + }, |
| 698 | +
|
| 699 | + setResponseHeadersVisible: function(value) { |
| 700 | + this.responseHeadersVisible = value; |
| 701 | + window.localStorage.setItem('responseHeadersVisible', value); |
| 702 | + }, |
| 703 | +
|
668 | 704 | setActiveTab: function(tab) {
|
669 | 705 | this.activeTab = tab;
|
670 | 706 | },
|
| 707 | +
|
671 | 708 | clearLogs: function() {
|
672 | 709 | fetch('/api/logs/clear');
|
673 | 710 | this.logs = []
|
674 | 711 | this.currentLog = null;
|
675 | 712 | },
|
| 713 | +
|
676 | 714 | responseIsJson: function() {
|
677 | 715 | if (! this.currentLog || ! this.currentLog.response || ! this.currentLog.response.headers) {
|
678 | 716 | return false;
|
|
0 commit comments