|
| 1 | +<!doctype html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="utf-8"> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 6 | + <title>Route List Web</title> |
| 7 | + |
| 8 | + <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous"> |
| 9 | + <link href="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;500;700&display=swap" rel="stylesheet"> |
| 10 | + |
| 11 | + <style> |
| 12 | + [x-cloak] { |
| 13 | + display: none !important; |
| 14 | + } |
| 15 | +
|
| 16 | + .font-monospace { |
| 17 | + font-family: 'Roboto Mono', var(--bs-font-monospace) !important; |
| 18 | + } |
| 19 | +
|
| 20 | + .fw-medium { |
| 21 | + font-weight: 500; |
| 22 | + } |
| 23 | +
|
| 24 | + .nowrap { |
| 25 | + white-space: nowrap; |
| 26 | + } |
| 27 | +
|
| 28 | + .text-indigo { |
| 29 | + color: #6610f2; |
| 30 | + } |
| 31 | +
|
| 32 | + .text-orange { |
| 33 | + color: #fd7e14; |
| 34 | + } |
| 35 | +
|
| 36 | + .bg-green { |
| 37 | + background-color: #28a745; |
| 38 | + } |
| 39 | +
|
| 40 | + .bg-orange { |
| 41 | + background-color: #fd7e14; |
| 42 | + } |
| 43 | + </style> |
| 44 | +</head> |
| 45 | + |
| 46 | +<body> |
| 47 | + <div class="container-fluid" x-data="RouteList()"> |
| 48 | + <div class="row mt-3 mb-2"> |
| 49 | + <div class="col-md-2"> |
| 50 | + <select class="form-select" x-model="search.column"> |
| 51 | + <option value="all">All</option> |
| 52 | + @foreach ($columns as $column => $label) |
| 53 | + <option value="{{ $column }}">{{ $label }}</option> |
| 54 | + @endforeach |
| 55 | + </select> |
| 56 | + </div> |
| 57 | + <div class="col-md-10"> |
| 58 | + <input type="text" class="form-control" placeholder="Search here..." x-model="search.value" x-on:keydown.escape="search.value = ''"> |
| 59 | + </div> |
| 60 | + </div> |
| 61 | + |
| 62 | + <div class="row mb-2"> |
| 63 | + <div class="col-md-10"> |
| 64 | + @foreach ($columns as $column => $label) |
| 65 | + <div class="form-check form-check-inline"> |
| 66 | + <input class="form-check-input" type="checkbox" id="columns.{{ $column }}" x-model="columns.{{ $column }}"> |
| 67 | + <label class="form-check-label" for="columns.{{ $column }}"> |
| 68 | + {{ $label }} |
| 69 | + </label> |
| 70 | + </div> |
| 71 | + @endforeach |
| 72 | + </div> |
| 73 | + <div class="col-md-2"> |
| 74 | + <div class="fw-bold float-end"> |
| 75 | + <span x-show="filteredCount !== routes.length" x-cloak><span x-text="filteredCount"></span> of</span> {{ $routes->count() }} routes |
| 76 | + </div> |
| 77 | + </div> |
| 78 | + </div> |
| 79 | + |
| 80 | + <div class="table-responsive"> |
| 81 | + <table class="table table-sm"> |
| 82 | + <thead> |
| 83 | + <tr class="table-dark"> |
| 84 | + <th x-show="columns.method">Method</th> |
| 85 | + <th x-show="columns.uri || columns.name" style="width: 120px"> |
| 86 | + <span x-show="columns.uri">URI</span> |
| 87 | + <span x-show="columns.uri && columns.name">&</span> |
| 88 | + <span x-show="columns.name">Name</span> |
| 89 | + </th> |
| 90 | + <th x-show="columns.action || columns.middleware"> |
| 91 | + <span x-show="columns.action">Action</span> |
| 92 | + <span x-show="columns.action && columns.middleware">&</span> |
| 93 | + <span x-show="columns.middleware">Middleware</span> |
| 94 | + </th> |
| 95 | + </tr> |
| 96 | + </thead> |
| 97 | + <tbody style="font-size: 90%"> |
| 98 | + <template x-for="route in getRoutes()"> |
| 99 | + <tr> |
| 100 | + <td x-show="columns.method" style="width: 120px"> |
| 101 | + <template x-for="method in route.method"> |
| 102 | + <span> |
| 103 | + <span class="badge" x-bind:class="getMethodColor(method)" x-text="method"></span> |
| 104 | + </span> |
| 105 | + </template> |
| 106 | + </td> |
| 107 | + <td class="font-monospace" x-show="columns.uri || columns.name"> |
| 108 | + <div class="fw-medium nowrap" x-html="stylizeUri(route.domain, route.uri)" x-show="columns.uri"></div> |
| 109 | + <div x-text="route.name" x-show="columns.name"></div> |
| 110 | + </td> |
| 111 | + <td class="font-monospace" x-show="columns.action || columns.middleware"> |
| 112 | + <div class="fw-medium" x-html="stylizeAction(route.action)" x-show="columns.action"></div> |
| 113 | + <template x-if="columns.middleware"> |
| 114 | + <div class="small"> |
| 115 | + <template x-for="item in route.middleware"> |
| 116 | + <div x-text="item"></div> |
| 117 | + </template> |
| 118 | + </div> |
| 119 | + </template> |
| 120 | + </td> |
| 121 | + </tr> |
| 122 | + </template> |
| 123 | + </tbody> |
| 124 | + </table> |
| 125 | + </div> |
| 126 | + </div> |
| 127 | + |
| 128 | + <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script> |
| 129 | + <script> |
| 130 | + window.RouteList = function () { |
| 131 | + return { |
| 132 | + routes: @json($routes), |
| 133 | + filteredCount: @json($routes->count()), |
| 134 | +
|
| 135 | + search: { |
| 136 | + column: 'all', |
| 137 | + value: '', |
| 138 | + }, |
| 139 | +
|
| 140 | + columns: { |
| 141 | + @foreach ($columns as $column => $label) |
| 142 | + {{ $column }}: true, |
| 143 | + @endforeach |
| 144 | + }, |
| 145 | +
|
| 146 | + getRoutes: function () { |
| 147 | + let routes = Array.from(this.routes); |
| 148 | +
|
| 149 | + if (this.search.value.trim().length > 0) { |
| 150 | + let filteredRoutes = []; |
| 151 | +
|
| 152 | + for (let i = 0; i < routes.length; i++) { |
| 153 | + const route = routes[i]; |
| 154 | + let value; |
| 155 | +
|
| 156 | + if (this.search.column === 'all') { |
| 157 | + value = JSON.stringify(route); |
| 158 | + } else if (this.search.column === 'middleware') { |
| 159 | + value = JSON.stringify(route.middleware); |
| 160 | + } else { |
| 161 | + value = route[this.search.column]; |
| 162 | + } |
| 163 | +
|
| 164 | + if (value !== null && value.length > 0 && value.toLowerCase().includes(this.search.value.trim().toLowerCase())) { |
| 165 | + filteredRoutes.push(route); |
| 166 | + } |
| 167 | + } |
| 168 | +
|
| 169 | + routes = filteredRoutes; |
| 170 | + } |
| 171 | +
|
| 172 | + this.filteredCount = routes.length; |
| 173 | +
|
| 174 | + return routes; |
| 175 | + }, |
| 176 | +
|
| 177 | + getMethodColor: function (method) { |
| 178 | + return 'bg-' + ({ |
| 179 | + get: 'green', |
| 180 | + head: 'secondary', |
| 181 | + options: 'info', |
| 182 | + post: 'primary', |
| 183 | + put: 'orange', |
| 184 | + patch: 'orange', |
| 185 | + delete: 'danger', |
| 186 | + any: 'dark', |
| 187 | + })[method.toLowerCase()]; |
| 188 | + }, |
| 189 | +
|
| 190 | + stylizeUri: function (domain, uri) { |
| 191 | + uri = (domain ? domain + '/' : '') + uri; |
| 192 | + uri = uri.replaceAll('{', '<span class="text-orange">{').replaceAll('}', '}</span>'); |
| 193 | +
|
| 194 | + return uri; |
| 195 | + }, |
| 196 | +
|
| 197 | + stylizeAction: function (action) { |
| 198 | + if (action.includes('@')) { |
| 199 | + action = action.replace('@', '<span class="text-primary">@') + '</span>'; |
| 200 | + } |
| 201 | +
|
| 202 | + return action; |
| 203 | + } |
| 204 | + }; |
| 205 | + }; |
| 206 | + </script> |
| 207 | + <script src="https://cdn.jsdelivr.net/npm/alpinejs@3.9.0/dist/cdn.min.js" integrity="sha256-vjjhKuttMeUQkvpbjLT6aaRy4DNzz76FnPD44vKkxWk=" crossorigin="anonymous"></script> |
| 208 | +</body> |
| 209 | +</html> |
0 commit comments