feat(Instances): add instance creation modal with form and validation
Implement a modal dialog for creating new instances with comprehensive form fields for different authentication methods (token/OIDC). Includes form validation, loading states, and success/error handling. Also adds consistent card styling across views and updates the add user button with an icon. Add api-backend.md to gitignore to prevent accidental commits of local documentation.
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -25,4 +25,5 @@ test/
|
|||||||
|
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|
||||||
agent.md
|
agent.md
|
||||||
|
api-backend.md
|
||||||
@@ -54,6 +54,109 @@
|
|||||||
<div v-if="filteredInstances.length === 0" class="empty-state">
|
<div v-if="filteredInstances.length === 0" class="empty-state">
|
||||||
<p>No instances available</p>
|
<p>No instances available</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div v-if="showAddModal" class="modal-overlay" @click="closeAddModal">
|
||||||
|
<div class="modal" @click.stop>
|
||||||
|
<h3>Add Instance</h3>
|
||||||
|
<form @submit.prevent="handleAddInstance" class="form">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Instance Name</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
v-model="formData.name"
|
||||||
|
required
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Authentication Method</label>
|
||||||
|
<select v-model="formData.auth_method" required>
|
||||||
|
<option value="token">Token</option>
|
||||||
|
<option value="oidc">OIDC</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Server Address</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
v-model="formData.serverAddr"
|
||||||
|
required
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Server Port</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
v-model="formData.serverPort"
|
||||||
|
required
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="form-group" v-if="formData.auth_method === 'token'">
|
||||||
|
<label>Token</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
v-model="formData.token"
|
||||||
|
required
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div v-if="formData.auth_method === 'oidc'">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Client ID</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
v-model="formData.clientId"
|
||||||
|
required
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Client Secret</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
v-model="formData.clientSecret"
|
||||||
|
required
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Audience</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
v-model="formData.audience"
|
||||||
|
required
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Token Endpoint URL</label>
|
||||||
|
<input
|
||||||
|
type="url"
|
||||||
|
v-model="formData.tokenEndpoint"
|
||||||
|
required
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group checkbox-group">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
id="bootAtStart"
|
||||||
|
v-model="formData.bootAtStart"
|
||||||
|
>
|
||||||
|
<label for="bootAtStart">Boot at Start</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Run User</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
v-model="formData.runUser"
|
||||||
|
placeholder="Default: root"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="form-actions">
|
||||||
|
<button type="button" class="cancel-btn" @click="closeAddModal">Cancel</button>
|
||||||
|
<button type="submit" class="submit-btn" :disabled="loading">
|
||||||
|
{{ loading ? 'Processing...' : 'Submit' }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -74,6 +177,21 @@ export default {
|
|||||||
setup(props) {
|
setup(props) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const instances = ref([]);
|
const instances = ref([]);
|
||||||
|
const showAddModal = ref(false);
|
||||||
|
const loading = ref(false);
|
||||||
|
const formData = ref({
|
||||||
|
name: '',
|
||||||
|
auth_method: 'token',
|
||||||
|
serverAddr: '',
|
||||||
|
serverPort: '',
|
||||||
|
token: '',
|
||||||
|
clientId: '',
|
||||||
|
clientSecret: '',
|
||||||
|
audience: '',
|
||||||
|
tokenEndpoint: '',
|
||||||
|
bootAtStart: false,
|
||||||
|
runUser: ''
|
||||||
|
});
|
||||||
|
|
||||||
const filteredInstances = computed(() => {
|
const filteredInstances = computed(() => {
|
||||||
if (!props.searchQuery) return instances.value;
|
if (!props.searchQuery) return instances.value;
|
||||||
@@ -118,6 +236,60 @@ export default {
|
|||||||
router.push(`/instances/${instanceName}`);
|
router.push(`/instances/${instanceName}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleAddInstance = async () => {
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
const instanceInfo = {
|
||||||
|
name: formData.value.name,
|
||||||
|
serverAddr: formData.value.serverAddr,
|
||||||
|
serverPort: formData.value.serverPort,
|
||||||
|
auth_method: formData.value.auth_method
|
||||||
|
};
|
||||||
|
|
||||||
|
const additionalProperties = {};
|
||||||
|
if (formData.value.auth_method === 'token') {
|
||||||
|
additionalProperties.auth_token = formData.value.token;
|
||||||
|
} else if (formData.value.auth_method === 'oidc') {
|
||||||
|
additionalProperties.oidc_client_id = formData.value.clientId;
|
||||||
|
additionalProperties.oidc_client_secret = formData.value.clientSecret;
|
||||||
|
additionalProperties.oidc_audience = formData.value.audience;
|
||||||
|
additionalProperties.oidc_token_endpoint = formData.value.tokenEndpoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
await instanceApi.createInstance(
|
||||||
|
instanceInfo,
|
||||||
|
formData.value.bootAtStart,
|
||||||
|
formData.value.runUser || 'root',
|
||||||
|
additionalProperties
|
||||||
|
);
|
||||||
|
|
||||||
|
showNotification('Instance created successfully', 'success');
|
||||||
|
closeAddModal();
|
||||||
|
await loadInstances();
|
||||||
|
} catch (error) {
|
||||||
|
showNotification(error.message || 'Failed to create instance', 'error');
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const closeAddModal = () => {
|
||||||
|
showAddModal.value = false;
|
||||||
|
formData.value = {
|
||||||
|
name: '',
|
||||||
|
auth_method: 'token',
|
||||||
|
serverAddr: '',
|
||||||
|
serverPort: '',
|
||||||
|
token: '',
|
||||||
|
clientId: '',
|
||||||
|
clientSecret: '',
|
||||||
|
audience: '',
|
||||||
|
tokenEndpoint: '',
|
||||||
|
bootAtStart: false,
|
||||||
|
runUser: ''
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
loadInstances();
|
loadInstances();
|
||||||
});
|
});
|
||||||
@@ -129,7 +301,12 @@ export default {
|
|||||||
stopInstance,
|
stopInstance,
|
||||||
goToDetail,
|
goToDetail,
|
||||||
formatDate,
|
formatDate,
|
||||||
highlightText
|
highlightText,
|
||||||
|
showAddModal,
|
||||||
|
loading,
|
||||||
|
formData,
|
||||||
|
handleAddInstance,
|
||||||
|
closeAddModal
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -138,6 +315,12 @@ export default {
|
|||||||
<style scoped>
|
<style scoped>
|
||||||
@import '../styles/common.css';
|
@import '../styles/common.css';
|
||||||
|
|
||||||
|
.page-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
.instances-page {
|
.instances-page {
|
||||||
padding: 24px;
|
padding: 24px;
|
||||||
}
|
}
|
||||||
@@ -151,6 +334,9 @@ export default {
|
|||||||
.instance-card {
|
.instance-card {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: all 0.3s;
|
transition: all 0.3s;
|
||||||
|
background-color: var(--card-bg);
|
||||||
|
padding: 16px;
|
||||||
|
border-radius: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.instance-card:hover {
|
.instance-card:hover {
|
||||||
@@ -158,6 +344,12 @@ export default {
|
|||||||
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
|
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.card-footer {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
.instance-name {
|
.instance-name {
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
@@ -165,4 +357,110 @@ export default {
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
transition: color 0.3s;
|
transition: color 0.3s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.modal-overlay {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background: rgba(0, 0, 0, 0.5);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
z-index: 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal {
|
||||||
|
background: var(--card-bg);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 24px;
|
||||||
|
width: 90%;
|
||||||
|
max-width: 500px;
|
||||||
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal h3 {
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group label {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group input,
|
||||||
|
.form-group select {
|
||||||
|
padding: 10px;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 14px;
|
||||||
|
background: var(--input-bg);
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group.checkbox-group {
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group.checkbox-group input {
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-actions {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: 12px;
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cancel-btn {
|
||||||
|
padding: 10px 20px;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 4px;
|
||||||
|
background: transparent;
|
||||||
|
color: var(--text-color);
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cancel-btn:hover {
|
||||||
|
background: var(--hover-bg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.submit-btn {
|
||||||
|
padding: 10px 20px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 4px;
|
||||||
|
background: var(--primary-color);
|
||||||
|
color: white;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.submit-btn:hover {
|
||||||
|
background: var(--primary-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.submit-btn:disabled {
|
||||||
|
background: var(--disabled-bg);
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -97,6 +97,9 @@ export default {
|
|||||||
|
|
||||||
.session-card {
|
.session-card {
|
||||||
transition: background-color 0.3s;
|
transition: background-color 0.3s;
|
||||||
|
background-color: var(--card-bg);
|
||||||
|
padding: 16px;
|
||||||
|
border-radius: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.session-icon {
|
.session-icon {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h2>User Management</h2>
|
<h2>User Management</h2>
|
||||||
<button class="add-btn" @click="showAddModal = true">
|
<button class="add-btn" @click="showAddModal = true">
|
||||||
+ Add User
|
<i class="fas fa-plus" aria-hidden="true"></i> Add User
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="users-list">
|
<div class="users-list">
|
||||||
|
|||||||
Reference in New Issue
Block a user