This commit is contained in:
2024-04-04 12:30:39 +02:00
parent 293b8ebedf
commit 44d71cc184
3 changed files with 13 additions and 8 deletions

View File

@ -40,7 +40,7 @@ export function activate(context: vscode.ExtensionContext) {
const filePath = editor.document.fileName;
console.log('Opened file:', filePath);
vscode.window.showInformationMessage(`Opened file: ${filePath}`);
// vscode.window.showInformationMessage(`Opened file: ${filePath}`);
await makeHttpRequest({ event: 'open', project: extractProjectName(filePath) });
}
});
@ -50,7 +50,7 @@ export function activate(context: vscode.ExtensionContext) {
const filePath = document.fileName;
console.log('Saved file:', filePath);
vscode.window.showInformationMessage(`Saved file: ${filePath}`);
// vscode.window.showInformationMessage(`Saved file: ${filePath}`);
await makeHttpRequest({ event: 'save', project: extractProjectName(filePath) });
});
@ -68,9 +68,9 @@ export function deactivate() { }
* /root/docker/monitoringserver/controller/homeController.js
* => monitoringserver
*/
function extractProjectName(path) {
function extractProjectName(path: string) {
const match = path.match(/\/root\/(docker|projects)\/([^/]+)/);
return match?.[1];
return match?.[2];
}
/*
@ -83,7 +83,7 @@ async function makeHttpRequest(json: Object) {
return;
}
vscode.window.showInformationMessage('Calling URL: ' + url);
// vscode.window.showInformationMessage('Calling URL: ' + url);
const rawResponse = await fetch(url, {
method: 'POST',
headers: {
@ -95,9 +95,9 @@ async function makeHttpRequest(json: Object) {
const content = await rawResponse.json();
console.log(content);
vscode.window.showInformationMessage('HTTP request successful.');
// vscode.window.showInformationMessage('HTTP request successful.');
} catch (error:any) {
console.error('Error making HTTP request:', error);
vscode.window.showErrorMessage('Error making HTTP request: ' + error.message);
// vscode.window.showErrorMessage('Error making HTTP request: ' + error.message);
}
}