From 293b8ebedf136f72e4797c14e183b5692d4aa827 Mon Sep 17 00:00:00 2001 From: Raphael Piccolo Date: Thu, 4 Apr 2024 10:06:19 +0200 Subject: [PATCH] -up --- src/extension.ts | 61 +++++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index e22bc59..f2f4274 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -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); + } +}