This commit is contained in:
Raphael Piccolo 2024-04-04 10:06:19 +02:00
parent 0dc1bb0767
commit 293b8ebedf

View File

@ -34,33 +34,6 @@ export function activate(context: vscode.ExtensionContext) {
});
context.subscriptions.push(disposable3);
// fonction qui envoie un event au serveur
async function makeHttpRequest(json: Object) {
try {
const url = vscode.workspace.getConfiguration().get('vscodestat.url') as string;
if (!url) {
return;
}
vscode.window.showInformationMessage('Calling URL: ' + url);
const rawResponse = await fetch(url, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(json)
});
const content = await rawResponse.json();
console.log(content);
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);
}
}
// detecte une ouverture de fichier / nouvel onglet
vscode.window.onDidChangeActiveTextEditor(async editor => {
if (editor) {
@ -90,7 +63,41 @@ export function activate(context: vscode.ExtensionContext) {
export function deactivate() { }
/*
* extractProjectName will extract a project name from a path
* /root/docker/monitoringserver/controller/homeController.js
* => monitoringserver
*/
function extractProjectName(path) {
const match = path.match(/\/root\/(docker|projects)\/([^/]+)/);
return match?.[1];
}
/*
* fonction qui envoie un event au serveur
*/
async function makeHttpRequest(json: Object) {
try {
const url = vscode.workspace.getConfiguration().get('vscodestat.url') as string;
if (!url) {
return;
}
vscode.window.showInformationMessage('Calling URL: ' + url);
const rawResponse = await fetch(url, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(json)
});
const content = await rawResponse.json();
console.log(content);
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);
}
}