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

1
LICENSE.md Normal file
View File

@ -0,0 +1 @@
soak

View File

@ -2,13 +2,17 @@
"name": "vscodestat", "name": "vscodestat",
"displayName": "vscodestat", "displayName": "vscodestat",
"description": "", "description": "",
"version": "0.0.2", "version": "1.0.1",
"engines": { "engines": {
"vscode": "^1.87.0" "vscode": "^1.87.0"
}, },
"categories": [ "categories": [
"Other" "Other"
], ],
"repository": {
"type": "git",
"url": "ssh://git@gitea.raphaelpiccolo.com:10022/root/vscodestat.git"
},
"activationEvents": [ "activationEvents": [
"onStartupFinished" "onStartupFinished"
], ],

View File

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