diff --git a/test/home.html b/test/home.html
index bad52c0..3d58019 100644
--- a/test/home.html
+++ b/test/home.html
@@ -537,7 +537,7 @@ header("Allow: GET, POST, OPTIONS, PUT, DELETE");
cell1.textContent = repoFullName;
cell2.textContent = repoURL;
cell3.innerHTML = `
-
+
`;
});
@@ -618,22 +618,27 @@ header("Allow: GET, POST, OPTIONS, PUT, DELETE");
// ===================================== Projects ===========================
async function openProject(repoId) {
- // TODO: check if container exist
+ var newCreated = false;
+ // check if container exist
await hasDevContainer(repoId)
.then(async hasDevContainer => {
if (!hasDevContainer) {
showAlert("正在创建开发容器...", 1500)
await createDevContainer(repoId)
.then(res => {
+ newCreated = true;
+ showAlert("创建容器成功!", 1500)
console.log(`Succeed to create dev container for repo ${repoId}`)
})
.catch(error => {
showAlert("创建容器失败!", 1500)
console.log(`Fail to create dev container for repo ${repoId}: `, error)
+ return;
})
}
}).catch(error => {
console.log("There has a problem when check if the repo has devContainer:", error)
+ return;
})
console.log("opening project")
@@ -676,10 +681,10 @@ header("Allow: GET, POST, OPTIONS, PUT, DELETE");
// default: open with key
communicateVSCodeByWebview('firstOpenRemoteFolder', {host: `${devContainerHost}`, username: `${devContainerUsername}`, port: `${devContainerPort}`, path: `${devContainerWorkDir}`})
} else {
- // TODO: show Error to User
+ // show Error to User
showAlert("打开容器失败!", 1500)
const responseErrorMsg = data.data.ErrorMsg
- console.log("Error happen when starting dev container", responseErrorMsg)
+ console.error("Error happen when starting dev container", responseErrorMsg)
}
})
.catch(error => {
@@ -723,7 +728,6 @@ header("Allow: GET, POST, OPTIONS, PUT, DELETE");
})
}
- // TODO: create container
async function createDevContainer(repoId) {
return new Promise(async (resolve, reject) => {
// request creating container
@@ -777,7 +781,6 @@ header("Allow: GET, POST, OPTIONS, PUT, DELETE");
}
}
- // TODO: delete container
function deleteDevContainer(repoId) {
var url = DEVSTAR_HOME + "/api/devcontainer"
var token = USERTOKEN
@@ -804,12 +807,14 @@ header("Allow: GET, POST, OPTIONS, PUT, DELETE");
const respCode = data.code;
if (0 == respCode) {
console.log('Successfully delete dev container belong to repoId:', repoId, data)
+ showAlert("删除容器成功!", 1500)
} else {
const errorMsg = data.data.ErrorMsg
throw new Error(errorMsg)
}
})
.catch(error => {
+ showAlert(`删除容器失败\n${error}`, 3000)
console.error(`Failed to delete dev container belong to repoId: ${repoId}\n`, error)
})
}