fix(InstanceDetail): improve error handling and success messages
- Display actual error messages from API responses instead of generic messages - Include instance name in success messages where applicable - Add success notifications for previously silent operations
This commit is contained in:
@@ -359,14 +359,14 @@ export default {
|
|||||||
'Created At': formatDate(result.data.createdAt)
|
'Created At': formatDate(result.data.createdAt)
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showNotification('Load instance information failed', 'error');
|
showNotification(error.message || 'Load instance information failed', 'error');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const startInstance = async () => {
|
const startInstance = async () => {
|
||||||
try {
|
try {
|
||||||
await instanceApi.startInstance(instanceID.value);
|
const result = await instanceApi.startInstance(instanceID.value);
|
||||||
showNotification('Instance started successfully', 'success');
|
showNotification(result.message || `Instance ${instanceName.value} started successfully`, 'success');
|
||||||
await loadInstanceInfo();
|
await loadInstanceInfo();
|
||||||
// Clear logs && reconnect to websocket
|
// Clear logs && reconnect to websocket
|
||||||
logs.value = [];
|
logs.value = [];
|
||||||
@@ -379,8 +379,8 @@ export default {
|
|||||||
|
|
||||||
const stopInstance = async () => {
|
const stopInstance = async () => {
|
||||||
try {
|
try {
|
||||||
await instanceApi.stopInstance(instanceID.value);
|
const result = await instanceApi.stopInstance(instanceID.value);
|
||||||
showNotification('Instance stopped successfully', 'success');
|
showNotification(result.message || 'Instance stopped successfully', 'success');
|
||||||
await loadInstanceInfo();
|
await loadInstanceInfo();
|
||||||
// Clear logs && reconnect to websocket
|
// Clear logs && reconnect to websocket
|
||||||
logs.value = [];
|
logs.value = [];
|
||||||
@@ -393,8 +393,8 @@ export default {
|
|||||||
|
|
||||||
const deleteInstance = async () => {
|
const deleteInstance = async () => {
|
||||||
try {
|
try {
|
||||||
await instanceApi.deleteInstance(instanceID.value);
|
const result = await instanceApi.deleteInstance(instanceID.value);
|
||||||
showNotification('Instance deleted successfully', 'success');
|
showNotification(result.message || 'Instance deleted successfully', 'success');
|
||||||
router.push('/instances');
|
router.push('/instances');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showNotification(error.message || 'Delete instance failed', 'error');
|
showNotification(error.message || 'Delete instance failed', 'error');
|
||||||
@@ -403,8 +403,8 @@ export default {
|
|||||||
|
|
||||||
const restartInstance = async () => {
|
const restartInstance = async () => {
|
||||||
try {
|
try {
|
||||||
await instanceApi.restartInstance(instanceID.value);
|
const result = await instanceApi.restartInstance(instanceID.value);
|
||||||
showNotification('Instance restarted successfully', 'success');
|
showNotification(result.message || 'Instance restarted successfully', 'success');
|
||||||
await loadInstanceInfo();
|
await loadInstanceInfo();
|
||||||
// Clear logs && reconnect to websocket
|
// Clear logs && reconnect to websocket
|
||||||
logs.value = [];
|
logs.value = [];
|
||||||
@@ -435,7 +435,7 @@ export default {
|
|||||||
remotePort: proxy.remotePort
|
remotePort: proxy.remotePort
|
||||||
}));
|
}));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showNotification('Load proxy list failed', 'error');
|
showNotification(error.message || 'Load proxy list failed', 'error');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -493,8 +493,9 @@ export default {
|
|||||||
level: log.level,
|
level: log.level,
|
||||||
message: log.content
|
message: log.content
|
||||||
})) : [];
|
})) : [];
|
||||||
|
showNotification(result.message || 'Logs loaded successfully', 'success');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showNotification('Load logs failed', 'error');
|
showNotification(error.message || 'Load logs failed', 'error');
|
||||||
}
|
}
|
||||||
connectLogWebSocket();
|
connectLogWebSocket();
|
||||||
};
|
};
|
||||||
@@ -520,8 +521,9 @@ export default {
|
|||||||
bootAtStart: result.data.bootAtStart || false,
|
bootAtStart: result.data.bootAtStart || false,
|
||||||
runUser: result.data.runUser || 'root'
|
runUser: result.data.runUser || 'root'
|
||||||
};
|
};
|
||||||
|
showNotification(result.message || 'Instance data loaded successfully', 'success');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showNotification('Load instance data failed', 'error');
|
showNotification(error.message || 'Load instance data failed', 'error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
showEditConfigModal.value = true;
|
showEditConfigModal.value = true;
|
||||||
@@ -593,8 +595,8 @@ export default {
|
|||||||
const confirmDeleteProxy = async () => {
|
const confirmDeleteProxy = async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
await instanceApi.deleteProxy(instanceID.value, selectedProxyName.value);
|
const result = await instanceApi.deleteProxy(instanceID.value, selectedProxyName.value);
|
||||||
showNotification('Proxy deleted successfully', 'success');
|
showNotification(result.message || 'Proxy deleted successfully', 'success');
|
||||||
closeDeleteProxyModal();
|
closeDeleteProxyModal();
|
||||||
await loadProxies();
|
await loadProxies();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -615,12 +617,13 @@ export default {
|
|||||||
remotePort: formData.value.remotePort
|
remotePort: formData.value.remotePort
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let result;
|
||||||
if (isEditProxy.value) {
|
if (isEditProxy.value) {
|
||||||
await instanceApi.modifyProxy(instanceID.value, proxyInfo);
|
result = await instanceApi.modifyProxy(instanceID.value, proxyInfo);
|
||||||
showNotification('Proxy updated successfully', 'success');
|
showNotification(result.message || 'Proxy updated successfully', 'success');
|
||||||
} else {
|
} else {
|
||||||
await instanceApi.createProxy(instanceID.value, proxyInfo);
|
result = await instanceApi.createProxy(instanceID.value, proxyInfo);
|
||||||
showNotification('Proxy created successfully', 'success');
|
showNotification(result.message || 'Proxy created successfully', 'success');
|
||||||
}
|
}
|
||||||
|
|
||||||
closeAddProxyModal();
|
closeAddProxyModal();
|
||||||
@@ -690,9 +693,9 @@ export default {
|
|||||||
remotePort: formData.value.remotePort.toString()
|
remotePort: formData.value.remotePort.toString()
|
||||||
};
|
};
|
||||||
|
|
||||||
await instanceApi.createProxy(instanceID.value, proxyInfo);
|
const result = await instanceApi.createProxy(instanceID.value, proxyInfo);
|
||||||
|
|
||||||
showNotification('Proxy created successfully', 'success');
|
showNotification(result.message || 'Proxy created successfully', 'success');
|
||||||
closeAddProxyModal();
|
closeAddProxyModal();
|
||||||
await loadProxies();
|
await loadProxies();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user