Skip to content

Commit 01a6628

Browse files
committed
chore: wip
1 parent d6962d3 commit 01a6628

File tree

1 file changed

+96
-60
lines changed
  • storage/framework/defaults/views/dashboard/cloud

1 file changed

+96
-60
lines changed

storage/framework/defaults/views/dashboard/cloud/index.vue

Lines changed: 96 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ const operatingSystems = [
103103
'amazon-linux-2-x86_64',
104104
]
105105
106+
// Update default values
107+
const defaultServerOS = 'ubuntu-24-lts-x86_64'
108+
const defaultBunVersion = 'v1.2.3'
109+
110+
// Update server types descriptions
106111
const serverTypes: ServerType[] = [
107112
{
108113
value: 'app',
@@ -114,11 +119,11 @@ const serverTypes: ServerType[] = [
114119
value: 'web',
115120
label: 'Web Server',
116121
badges: ['Bun', 'Nginx'],
117-
description: 'A secured web server with Nginx and PHP.'
122+
description: 'A secured web server with Nginx.'
118123
},
119124
{
120125
value: 'worker',
121-
label: 'Dedicated Worker Server',
126+
label: 'Worker Server',
122127
badges: ['Bun'],
123128
description: 'Connect to your local database / cache server to keep your queued jobs processing quickly.'
124129
},
@@ -149,7 +154,15 @@ const serverTypes: ServerType[] = [
149154
]
150155
151156
const bunVersions = [
152-
'v1.0.30',
157+
'v1.2.3',
158+
'v1.2.2',
159+
'v1.2.1',
160+
'v1.2.0',
161+
'v1.1.20',
162+
'v1.1.15',
163+
'v1.1.10',
164+
'v1.1.5',
165+
'v1.1.0',
153166
'v1.0.25',
154167
'v1.0.20',
155168
'v1.0.15',
@@ -268,6 +281,14 @@ const hasUnsavedChanges = ref(false)
268281
const initialWorkerConfig = ref({ ...workerConfig.value })
269282
const initialCloudConfig = ref({ ...cloudConfig.value })
270283
284+
// Add edit mode state
285+
const editMode = ref<Record<string, boolean>>({})
286+
287+
// Add toggle edit mode function
288+
const toggleEditMode = (key: string) => {
289+
editMode.value[key] = !editMode.value[key]
290+
}
291+
271292
// Function to update worker specs when size changes
272293
const updateWorkerSpecs = () => {
273294
workerConfig.value.specs = workerSizes[workerConfig.value.size]
@@ -630,15 +651,19 @@ export class StacksInfrastructureStack extends cdk.Stack {
630651
// Methods
631652
const addServer = () => {
632653
const id = Object.keys(cloudConfig.value.servers).length + 1
633-
cloudConfig.value.servers[`app${id}`] = {
654+
const key = `app${id}`
655+
cloudConfig.value.servers[key] = {
634656
name: `app-server-${id}`,
635657
domain: 'stacksjs.org',
636658
region: 'us-east-1',
637659
type: 'app',
638660
size: 't3.micro',
639661
diskSize: 20,
640-
serverOS: 'ubuntu-20-lts-x86_64',
662+
serverOS: defaultServerOS,
663+
bunVersion: defaultBunVersion,
641664
}
665+
// Set edit mode for new server
666+
editMode.value[key] = true
642667
}
643668
644669
const removeServer = (key: string) => {
@@ -700,6 +725,11 @@ const saveWorkerConfig = async () => {
700725
isSaving.value = false
701726
}
702727
}
728+
729+
// Add field name formatter
730+
const formatFieldName = (field: string) => {
731+
return field.charAt(0).toUpperCase() + field.slice(1)
732+
}
703733
</script>
704734

705735
<template>
@@ -956,9 +986,26 @@ const saveWorkerConfig = async () => {
956986
<div
957987
v-for="(server, key) in cloudConfig.servers"
958988
:key="key"
959-
class="relative border dark:border-gray-600 rounded-lg p-6 transition-all duration-200 hover:border-blue-200 dark:hover:border-blue-500"
989+
class="relative border dark:border-gray-600 rounded-lg p-6 transition-all duration-200"
990+
:class="{ 'hover:border-blue-200 dark:hover:border-blue-500': editMode[key] }"
960991
>
961-
<div class="absolute top-4 right-4">
992+
<div class="absolute top-4 right-4 flex items-center gap-2">
993+
<button
994+
v-if="!editMode[key]"
995+
@click="toggleEditMode(key)"
996+
class="inline-flex items-center gap-1 px-2.5 py-1.5 text-sm font-medium text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-300 transition-colors duration-200"
997+
>
998+
<span class="i-heroicons-pencil-square w-5 h-5"></span>
999+
Edit
1000+
</button>
1001+
<button
1002+
v-else
1003+
@click="toggleEditMode(key)"
1004+
class="inline-flex items-center gap-1 px-2.5 py-1.5 text-sm font-medium text-green-600 hover:text-green-800 dark:text-green-400 dark:hover:text-green-300 transition-colors duration-200"
1005+
>
1006+
<span class="i-heroicons-check w-5 h-5"></span>
1007+
Save
1008+
</button>
9621009
<button
9631010
@click="removeServer(key)"
9641011
class="inline-flex items-center gap-1 px-2.5 py-1.5 text-sm font-medium text-red-600 hover:text-red-800 dark:text-red-400 dark:hover:text-red-300 transition-colors duration-200"
@@ -968,12 +1015,49 @@ const saveWorkerConfig = async () => {
9681015
</button>
9691016
</div>
9701017

1018+
<!-- Server Header -->
9711019
<div class="mb-6">
972-
<h5 class="text-lg font-medium text-gray-900 dark:text-gray-100">{{ server.name }}</h5>
973-
<p class="mt-1 text-sm text-gray-500 dark:text-gray-400">{{ server.domain }}</p>
1020+
<div class="flex items-center gap-4 mb-2">
1021+
<h5 class="text-lg font-medium text-gray-900 dark:text-gray-100">{{ server.name }}</h5>
1022+
<div class="flex flex-wrap gap-2">
1023+
<span
1024+
v-for="badge in serverTypes.find((t: ServerType) => t.value === server.type)?.badges"
1025+
:key="badge"
1026+
class="inline-flex items-center px-2 py-1 rounded-md text-xs font-medium bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300"
1027+
>
1028+
{{ badge }}
1029+
</span>
1030+
</div>
1031+
</div>
1032+
<div class="flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400">
1033+
<div class="i-heroicons-link w-4 h-4"></div>
1034+
<p>{{ server.domain }}</p>
1035+
</div>
1036+
<p class="mt-2 text-sm text-gray-500 dark:text-gray-400">
1037+
{{ serverTypes.find((t: ServerType) => t.value === server.type)?.description }}
1038+
</p>
9741039
</div>
9751040

976-
<div class="grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3">
1041+
<!-- Server Configuration -->
1042+
<div v-if="!editMode[key]" class="mt-4">
1043+
<div class="flex items-center gap-2">
1044+
<div class="i-heroicons-server w-4 h-4 text-gray-400"></div>
1045+
<span class="text-sm text-gray-900 dark:text-gray-100">
1046+
{{ (workerSizes[server.size as keyof typeof workerSizes].ram / 1024).toFixed(0) }}GB RAM ({{ server.size }})
1047+
</span>
1048+
<span class="text-sm text-gray-500 dark:text-gray-400">•</span>
1049+
<span class="text-sm text-gray-900 dark:text-gray-100">
1050+
{{ workerSizes[server.size as keyof typeof workerSizes].vcpu }} vCPUs
1051+
</span>
1052+
<span class="text-sm text-gray-500 dark:text-gray-400">•</span>
1053+
<span class="text-sm text-gray-900 dark:text-gray-100">
1054+
64-bit {{ server.size.includes('g.') ? 'ARM' : 'x86' }}
1055+
</span>
1056+
</div>
1057+
</div>
1058+
1059+
<!-- Edit Form -->
1060+
<div v-else class="grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3">
9771061
<div>
9781062
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Name</label>
9791063
<input
@@ -982,7 +1066,6 @@ const saveWorkerConfig = async () => {
9821066
class="block w-full h-10 text-sm border-0 rounded-md bg-gray-50 dark:bg-blue-gray-600 py-2 px-3 text-gray-900 dark:text-gray-100 ring-1 ring-inset ring-gray-300 dark:ring-gray-600 focus:ring-2 focus:ring-blue-600 transition-colors duration-200"
9831067
>
9841068
</div>
985-
9861069
<div>
9871070
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Domain</label>
9881071
<input
@@ -991,7 +1074,6 @@ const saveWorkerConfig = async () => {
9911074
class="block w-full h-10 text-sm border-0 rounded-md bg-gray-50 dark:bg-blue-gray-600 py-2 px-3 text-gray-900 dark:text-gray-100 ring-1 ring-inset ring-gray-300 dark:ring-gray-600 focus:ring-2 focus:ring-blue-600 transition-colors duration-200"
9921075
>
9931076
</div>
994-
9951077
<div>
9961078
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Region</label>
9971079
<select
@@ -1003,42 +1085,20 @@ const saveWorkerConfig = async () => {
10031085
</option>
10041086
</select>
10051087
</div>
1006-
10071088
<div>
10081089
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Type</label>
10091090
<div class="relative">
10101091
<select
10111092
v-model="server.type"
1012-
class="block w-full h-10 text-sm border-0 rounded-md bg-gray-50 dark:bg-blue-gray-600 py-2 pl-3 pr-10 text-gray-900 dark:text-gray-100 ring-1 ring-inset ring-gray-300 dark:ring-gray-600 focus:ring-2 focus:ring-blue-600 transition-colors duration-200"
1093+
:disabled="!editMode[key]"
1094+
class="block w-full h-10 text-sm border-0 rounded-md bg-gray-50 dark:bg-blue-gray-600 py-2 px-3 text-gray-900 dark:text-gray-100 ring-1 ring-inset ring-gray-300 dark:ring-gray-600 focus:ring-2 focus:ring-blue-600 transition-colors duration-200 disabled:opacity-50 disabled:cursor-not-allowed"
10131095
>
10141096
<option v-for="type in serverTypes" :key="type.value" :value="type.value">
10151097
{{ type.label }}
10161098
</option>
10171099
</select>
10181100
</div>
1019-
<div v-if="server.type" class="mt-2">
1020-
<div class="flex flex-wrap gap-2">
1021-
<span
1022-
v-for="badge in serverTypes.find((t: ServerType) => t.value === server.type)?.badges"
1023-
:key="badge"
1024-
class="inline-flex items-center px-2 py-1 rounded-md text-xs font-medium"
1025-
:class="{
1026-
'bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300': badge === 'Bun',
1027-
'bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300': badge === 'Nginx',
1028-
'bg-purple-100 text-purple-700 dark:bg-purple-900 dark:text-purple-300': badge === 'Database',
1029-
'bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300': badge === 'Redis' || badge === 'Memcached',
1030-
'bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300': badge === 'Search Engine'
1031-
}"
1032-
>
1033-
{{ badge }}
1034-
</span>
1035-
</div>
1036-
<p class="mt-1 text-sm text-gray-500 dark:text-gray-400">
1037-
{{ serverTypes.find((t: ServerType) => t.value === server.type)?.description }}
1038-
</p>
1039-
</div>
10401101
</div>
1041-
10421102
<div>
10431103
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Bun Version</label>
10441104
<select
@@ -1050,7 +1110,6 @@ const saveWorkerConfig = async () => {
10501110
</option>
10511111
</select>
10521112
</div>
1053-
10541113
<div>
10551114
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Database</label>
10561115
<select
@@ -1064,7 +1123,6 @@ const saveWorkerConfig = async () => {
10641123
<option value="mongodb">MongoDB</option>
10651124
</select>
10661125
</div>
1067-
10681126
<div v-if="server.database">
10691127
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Database Name</label>
10701128
<input
@@ -1074,26 +1132,6 @@ const saveWorkerConfig = async () => {
10741132
placeholder="my_database"
10751133
>
10761134
</div>
1077-
1078-
<div>
1079-
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Size</label>
1080-
<div class="relative">
1081-
<select
1082-
v-model="server.size"
1083-
class="block w-full h-10 text-sm border-0 rounded-md bg-gray-50 dark:bg-blue-gray-600 py-2 px-3 text-gray-900 dark:text-gray-100 ring-1 ring-inset ring-gray-300 dark:ring-gray-600 focus:ring-2 focus:ring-blue-600 transition-colors duration-200"
1084-
>
1085-
<option v-for="size in instanceTypes" :key="size" :value="size">
1086-
{{ (workerSizes[size as keyof typeof workerSizes].ram / 1024).toFixed(0) }}GB RAM ({{ size }}) (64-bit {{ size.includes('g.') ? 'arm' : 'x86' }}) - {{ workerSizes[size as keyof typeof workerSizes].vcpu }} vCPUs
1087-
</option>
1088-
</select>
1089-
<div class="absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none">
1090-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5 text-gray-400">
1091-
<path stroke-linecap="round" stroke-linejoin="round" d="M8.25 15L12 18.75 15.75 15m-7.5-6L12 5.25 15.75 9" />
1092-
</svg>
1093-
</div>
1094-
</div>
1095-
</div>
1096-
10971135
<div>
10981136
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Operating System</label>
10991137
<select
@@ -1105,7 +1143,6 @@ const saveWorkerConfig = async () => {
11051143
</option>
11061144
</select>
11071145
</div>
1108-
11091146
<div>
11101147
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Disk Size (GB)</label>
11111148
<input
@@ -1115,7 +1152,6 @@ const saveWorkerConfig = async () => {
11151152
class="block w-full h-10 text-sm border-0 rounded-md bg-gray-50 dark:bg-blue-gray-600 py-2 px-3 text-gray-900 dark:text-gray-100 ring-1 ring-inset ring-gray-300 dark:ring-gray-600 focus:ring-2 focus:ring-blue-600 transition-colors duration-200"
11161153
>
11171154
</div>
1118-
11191155
<div class="sm:col-span-2 lg:col-span-3">
11201156
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">User Data Script</label>
11211157
<textarea

0 commit comments

Comments
 (0)