|
5 | 5 | import type { IFlist, IFormField } from "../../types"; |
6 | 6 | const { events } = window.configs?.grid3_client ?? {}; |
7 | 7 | import deployVM from "../../utils/deployVM"; |
| 8 | + import findNodes from "../../utils/findNodes"; |
8 | 9 |
|
9 | 10 | const configs = window.configs?.baseConfig; |
10 | 11 | const deploymentStore = window.configs?.deploymentStore; |
|
102 | 103 | } |
103 | 104 |
|
104 | 105 | const onSelectProfile = (e: Event) => profileIdx = (e.target as any).selectedIndex; // prettier-ignore |
| 106 | +
|
| 107 | + const nodeFilters = { |
| 108 | + accessNodeV4: false, |
| 109 | + accessNodeV6: true, |
| 110 | + gateway: false, |
| 111 | + city: "", |
| 112 | + country: "", |
| 113 | + farmId: null, |
| 114 | + cru: null, |
| 115 | + hru: null, |
| 116 | + mru: null, |
| 117 | + sru: null, |
| 118 | + }; |
| 119 | +
|
| 120 | + // prettier-ignore |
| 121 | + const filtersFields = [ |
| 122 | + { label: "Access Node V4 Filter", symbol: "accessNodeV4", type: "checkbox" }, |
| 123 | + { label: "Access Node V6 Filter", symbol: "accessNodeV6", type: "checkbox" }, |
| 124 | + { label: "Gateway Filter", symbol: "gateway", type: "checkbox" }, |
| 125 | + { label: "City Filter", symbol: "city", type: "text" }, |
| 126 | + { label: "Country Filter", symbol: "country", type: "text" }, |
| 127 | + { label: "Farm ID Filter", symbol: "farmId", type: "number" }, |
| 128 | + { label: "CRU Filter", symbol: "cru", type: "number" }, |
| 129 | + { label: "HRU Filter", symbol: "hru", type: "number" }, |
| 130 | + { label: "MRU Filter", symbol: "mru", type: "number" }, |
| 131 | + { label: "SRU Filter", symbol: "sru", type: "number" }, |
| 132 | + ]; |
105 | 133 | </script> |
106 | 134 |
|
107 | 135 | <div style="padding: 15px;"> |
|
238 | 266 | </div> |
239 | 267 | </div> |
240 | 268 | {/each} |
| 269 | + |
| 270 | + <section style="width: 50%;"> |
| 271 | + {#each filtersFields as field (field.symbol)} |
| 272 | + {#if field.type === "checkbox"} |
| 273 | + <div style="display: flex; align-items: center;" class="mb-2"> |
| 274 | + <label class="switch"> |
| 275 | + <input |
| 276 | + type="checkbox" |
| 277 | + bind:checked={nodeFilters[field.symbol]} |
| 278 | + id={field.symbol} |
| 279 | + /> |
| 280 | + <span class="slider" /> |
| 281 | + </label> |
| 282 | + <label |
| 283 | + for={field.symbol} |
| 284 | + class="label ml-2" |
| 285 | + style="cursor: pointer;" |
| 286 | + > |
| 287 | + {field.label} |
| 288 | + </label> |
| 289 | + </div> |
| 290 | + {/if} |
| 291 | + |
| 292 | + {#if field.type === "text"} |
| 293 | + <div class="field"> |
| 294 | + <p class="label">{field.label}</p> |
| 295 | + <div class="control"> |
| 296 | + <input |
| 297 | + class="input" |
| 298 | + type="text" |
| 299 | + placeholder={field.label} |
| 300 | + bind:value={nodeFilters[field.symbol]} |
| 301 | + /> |
| 302 | + </div> |
| 303 | + </div> |
| 304 | + {/if} |
| 305 | + |
| 306 | + {#if field.type === "number"} |
| 307 | + <div class="field"> |
| 308 | + <p class="label">{field.label}</p> |
| 309 | + <div class="control"> |
| 310 | + <input |
| 311 | + class="input" |
| 312 | + type="number" |
| 313 | + placeholder={field.label} |
| 314 | + bind:value={nodeFilters[field.symbol]} |
| 315 | + /> |
| 316 | + </div> |
| 317 | + </div> |
| 318 | + {/if} |
| 319 | + {/each} |
| 320 | + </section> |
| 321 | + |
| 322 | + <button |
| 323 | + class="button is-primary mt-4" |
| 324 | + type="button" |
| 325 | + on:click={() => { |
| 326 | + findNodes(nodeFilters).then((res) => { |
| 327 | + console.log(res); |
| 328 | + }); |
| 329 | + }} |
| 330 | + > |
| 331 | + Apply Filters |
| 332 | + </button> |
241 | 333 | {/if} |
242 | 334 |
|
243 | 335 | {#if active === "Environment Variables"} |
|
375 | 467 | align-items: center; |
376 | 468 | justify-content: space-between; |
377 | 469 | } |
| 470 | +
|
| 471 | + /* Switch */ |
| 472 | + .switch { |
| 473 | + position: relative; |
| 474 | + display: inline-block; |
| 475 | + width: 60px; |
| 476 | + height: 34px; |
| 477 | +
|
| 478 | + input { |
| 479 | + opacity: 0; |
| 480 | + width: 0; |
| 481 | + height: 0; |
| 482 | + } |
| 483 | +
|
| 484 | + .slider { |
| 485 | + position: absolute; |
| 486 | + cursor: pointer; |
| 487 | + top: 0; |
| 488 | + left: 0; |
| 489 | + right: 0; |
| 490 | + bottom: 0; |
| 491 | + background-color: #ccc; |
| 492 | + -webkit-transition: 0.4s; |
| 493 | + transition: 0.4s; |
| 494 | + border-radius: 34px; |
| 495 | + } |
| 496 | +
|
| 497 | + .slider:before { |
| 498 | + position: absolute; |
| 499 | + content: ""; |
| 500 | + height: 26px; |
| 501 | + width: 26px; |
| 502 | + left: 4px; |
| 503 | + bottom: 4px; |
| 504 | + background-color: white; |
| 505 | + -webkit-transition: 0.4s; |
| 506 | + transition: 0.4s; |
| 507 | + border-radius: 50%; |
| 508 | + } |
| 509 | +
|
| 510 | + input:checked + .slider { |
| 511 | + background-color: #2196f3; |
| 512 | + } |
| 513 | +
|
| 514 | + input:checked + .slider { |
| 515 | + box-shadow: 0 0 1px #2196f3; |
| 516 | + } |
| 517 | +
|
| 518 | + input:checked + .slider:before { |
| 519 | + -webkit-transform: translateX(26px); |
| 520 | + -ms-transform: translateX(26px); |
| 521 | + transform: translateX(26px); |
| 522 | + } |
| 523 | + } |
378 | 524 | </style> |
0 commit comments