add length option to template

This commit is contained in:
Andras Bacsai
2022-10-17 14:55:28 +00:00
parent 8f660c0276
commit 9afb713df1
3 changed files with 45 additions and 41 deletions

View File

@@ -159,6 +159,9 @@ export default [
"label": "Secret Key Base", "label": "Secret Key Base",
"defaultValue": "$$generate_passphrase", "defaultValue": "$$generate_passphrase",
"description": "", "description": "",
"details": {
"length":64
}
}, },
{ {
"id": "$$config_disable_auth", "id": "$$config_disable_auth",

View File

@@ -221,9 +221,11 @@ export async function saveServiceType(request: FastifyRequest<SaveServiceType>,
let { id: variableId } = variable; let { id: variableId } = variable;
if (variableId.startsWith('$$secret_')) { if (variableId.startsWith('$$secret_')) {
if (variable.defaultValue === '$$generate_password') { if (variable.defaultValue === '$$generate_password') {
variable.value = generatePassword({}); const length = variable?.details['length'] || null
variable.value = generatePassword({length});
} else if (variable.defaultValue === '$$generate_passphrase') { } else if (variable.defaultValue === '$$generate_passphrase') {
variable.value = cuid(); const length = variable?.details['length'] || null
variable.value = generatePassword({length});
} }
} }
if (variableId.startsWith('$$config_')) { if (variableId.startsWith('$$config_')) {

View File

@@ -135,47 +135,46 @@
<div class="text-xl font-bold tracking-tighter">Container not found / exited.</div> <div class="text-xl font-bold tracking-tighter">Container not found / exited.</div>
{/if} {/if}
{:else} {:else}
<div class="relative w-full"></div> <div class="relative w-full" />
<div class="flex justify-start sticky space-x-2 pb-2"> <div class="flex justify-start sticky space-x-2 pb-2">
<button <button
on:click={followBuild} on:click={followBuild}
class="btn btn-sm bg-coollabs" class="btn btn-sm bg-coollabs"
class:bg-coolgray-300={followingLogs} class:bg-coolgray-300={followingLogs}
class:text-applications={followingLogs} class:text-applications={followingLogs}
>
<svg
xmlns="http://www.w3.org/2000/svg"
class="w-6 h-6 mr-2"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
> >
<svg <path stroke="none" d="M0 0h24v24H0z" fill="none" />
xmlns="http://www.w3.org/2000/svg" <circle cx="12" cy="12" r="9" />
class="w-6 h-6 mr-2" <line x1="8" y1="12" x2="12" y2="16" />
viewBox="0 0 24 24" <line x1="12" y1="8" x2="12" y2="16" />
stroke-width="1.5" <line x1="16" y1="12" x2="12" y2="16" />
stroke="currentColor" </svg>
fill="none" {followingLogs ? 'Following Logs...' : 'Follow Logs'}
stroke-linecap="round" </button>
stroke-linejoin="round" {#if loadLogsInterval}
>
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<circle cx="12" cy="12" r="9" />
<line x1="8" y1="12" x2="12" y2="16" />
<line x1="12" y1="8" x2="12" y2="16" />
<line x1="16" y1="12" x2="12" y2="16" />
</svg>
{followingLogs ? 'Following Logs...' : 'Follow Logs'}
</button>
{#if loadLogsInterval}
<button id="streaming" class="btn btn-sm bg-transparent border-none loading" <button id="streaming" class="btn btn-sm bg-transparent border-none loading"
>Streaming logs</button >Streaming logs</button
> >
{/if} {/if}
</div> </div>
<div <div
bind:this={logsEl} bind:this={logsEl}
on:scroll={detect} on:scroll={detect}
class="font-mono w-full bg-coolgray-100 border border-coolgray-200 p-5 overflow-x-auto overflox-y-auto max-h-[80vh] rounded mb-20 flex flex-col scrollbar-thumb-coollabs scrollbar-track-coolgray-200 scrollbar-w-1" class="font-mono w-full bg-coolgray-100 border border-coolgray-200 p-5 overflow-x-auto overflox-y-auto max-h-[80vh] rounded mb-20 flex flex-col scrollbar-thumb-coollabs scrollbar-track-coolgray-200 scrollbar-w-1"
> >
{#each logs as log} {#each logs as log}
<p>{log + '\n'}</p> <p>{log + '\n'}</p>
{/each} {/each}
</div>
</div> </div>
{/if} {/if}
</div> </div>