|
35 | 35 | { label: "Memory", symbol: 'memory', placeholder: 'Your Memory in MB', type: 'number'},
|
36 | 36 | { label: "Public IP", symbol: "publicIp", placeholder: "", type: 'checkbox' },
|
37 | 37 | { label: "Planetary Network", symbol: "planetary", placeholder: "", type: 'checkbox' },
|
38 |
| - { label: "Node ID", symbol: 'nodeId', placeholder: 'Your Node ID', type: 'number', link: { label: "Grid Explorer", url: "https://library.threefold.me/info/threefold#/manual_tfgrid3/threefold__grid3_explorer"}}, |
| 38 | + // { label: "Node ID", symbol: 'nodeId', placeholder: 'Your Node ID', type: 'number', link: { label: "Grid Explorer", url: "https://library.threefold.me/info/threefold#/manual_tfgrid3/threefold__grid3_explorer"}}, |
39 | 39 | ];
|
40 | 40 |
|
41 | 41 | // prettier-ignore
|
|
130 | 130 | { label: "MRU Filter", symbol: "mru", type: "number" },
|
131 | 131 | { label: "SRU Filter", symbol: "sru", type: "number" },
|
132 | 132 | ];
|
| 133 | +
|
| 134 | + let nodeSelection: string; |
| 135 | + let nodes: number[] = []; |
| 136 | + let loadingNodes: boolean = false; |
| 137 | + function onLoadNodesHandler() { |
| 138 | + loadingNodes = true; |
| 139 | + findNodes(nodeFilters, profile) |
| 140 | + .then((_nodes) => { |
| 141 | + nodes = _nodes; |
| 142 | + }) |
| 143 | + .finally(() => (loadingNodes = false)); |
| 144 | + } |
133 | 145 | </script>
|
134 | 146 |
|
135 | 147 | <div style="padding: 15px;">
|
|
267 | 279 | </div>
|
268 | 280 | {/each}
|
269 | 281 |
|
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} |
| 282 | + <p class="label">Node Selection</p> |
| 283 | + <div class="select mb-2"> |
| 284 | + <select bind:value={nodeSelection}> |
| 285 | + <option selected disabled>Choose a way to select node</option> |
| 286 | + <option value="automatic">Automatic</option> |
| 287 | + <option value="manual">Manual</option> |
| 288 | + </select> |
| 289 | + </div> |
291 | 290 |
|
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 |
| - /> |
| 291 | + {#if nodeSelection === "automatic"} |
| 292 | + <section style="width: 50%;"> |
| 293 | + <h5 class="is-size-3 has-text-weight-bold">Nodes Filter</h5> |
| 294 | + {#each filtersFields as field (field.symbol)} |
| 295 | + {#if field.type === "checkbox"} |
| 296 | + <div style="display: flex; align-items: center;" class="mb-2"> |
| 297 | + <label class="switch"> |
| 298 | + <input |
| 299 | + type="checkbox" |
| 300 | + bind:checked={nodeFilters[field.symbol]} |
| 301 | + id={field.symbol} |
| 302 | + /> |
| 303 | + <span class="slider" /> |
| 304 | + </label> |
| 305 | + <label |
| 306 | + for={field.symbol} |
| 307 | + class="label ml-2" |
| 308 | + style="cursor: pointer;" |
| 309 | + > |
| 310 | + {field.label} |
| 311 | + </label> |
302 | 312 | </div>
|
303 |
| - </div> |
304 |
| - {/if} |
| 313 | + {/if} |
305 | 314 |
|
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 |
| - /> |
| 315 | + {#if field.type === "text"} |
| 316 | + <div class="field"> |
| 317 | + <p class="label">{field.label}</p> |
| 318 | + <div class="control"> |
| 319 | + <input |
| 320 | + class="input" |
| 321 | + type="text" |
| 322 | + placeholder={field.label} |
| 323 | + bind:value={nodeFilters[field.symbol]} |
| 324 | + /> |
| 325 | + </div> |
316 | 326 | </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> |
| 327 | + {/if} |
| 328 | + |
| 329 | + {#if field.type === "number"} |
| 330 | + <div class="field"> |
| 331 | + <p class="label">{field.label}</p> |
| 332 | + <div class="control"> |
| 333 | + <input |
| 334 | + class="input" |
| 335 | + type="number" |
| 336 | + placeholder={field.label} |
| 337 | + bind:value={nodeFilters[field.symbol]} |
| 338 | + /> |
| 339 | + </div> |
| 340 | + </div> |
| 341 | + {/if} |
| 342 | + {/each} |
| 343 | + |
| 344 | + <button |
| 345 | + class={"button is-primary mt-2 " + |
| 346 | + (loadingNodes ? "is-loading" : "")} |
| 347 | + disabled={loadingNodes} |
| 348 | + type="button" |
| 349 | + on:click={onLoadNodesHandler} |
| 350 | + > |
| 351 | + Apply Filters |
| 352 | + </button> |
| 353 | + |
| 354 | + <div class="select mt-4"> |
| 355 | + <p class="label">Node ID</p> |
| 356 | + <select bind:value={data.nodeId}> |
| 357 | + <option selected disabled> |
| 358 | + {#if loadingNodes} |
| 359 | + Loading... |
| 360 | + {:else} |
| 361 | + Please select a node ID |
| 362 | + {/if} |
| 363 | + </option> |
| 364 | + {#each nodes as node (node)} |
| 365 | + <option value={node}> |
| 366 | + {node} |
| 367 | + </option> |
| 368 | + {/each} |
| 369 | + </select> |
| 370 | + </div> |
| 371 | + </section> |
| 372 | + {:else if nodeSelection === "manual"} |
| 373 | + <div class="field"> |
| 374 | + <p class="label">Node ID</p> |
| 375 | + <div class="control"> |
| 376 | + <input |
| 377 | + class="input" |
| 378 | + type="number" |
| 379 | + placeholder="Your Node ID" |
| 380 | + bind:value={data.nodeId} |
| 381 | + /> |
| 382 | + </div> |
| 383 | + </div> |
| 384 | + {/if} |
333 | 385 | {/if}
|
334 | 386 |
|
335 | 387 | {#if active === "Environment Variables"}
|
|
521 | 573 | transform: translateX(26px);
|
522 | 574 | }
|
523 | 575 | }
|
| 576 | +
|
| 577 | + .select, |
| 578 | + .select > select { |
| 579 | + width: 100%; |
| 580 | + } |
524 | 581 | </style>
|
0 commit comments