Skip to content

Commit

Permalink
quick but not fully
Browse files Browse the repository at this point in the history
  • Loading branch information
huangjien committed Sep 16, 2024
1 parent 2fe1211 commit a64125c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 15 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "jenkins-log-reader",
"displayName": "jenkins-log-reader",
"description": "read jenkins log, analyse with local AI.",
"version": "0.3.32",
"version": "0.3.33",
"engines": {
"vscode": "^1.93.0"
},
Expand Down Expand Up @@ -155,17 +155,17 @@
},
"devDependencies": {
"@types/glob": "^8.1.0",
"@types/mocha": "^10.0.7",
"@types/node": "22.5.4",
"@types/mocha": "^10.0.8",
"@types/node": "22.5.5",
"@types/vscode": "^1.93.0",
"@types/vscode-webview": "^1.57.5",
"auto-changelog": "^2.4.0",
"auto-changelog": "^2.5.0",
"esbuild": "^0.23.1",
"esbuild-plugin-copy": "^2.1.1",
"glob": "^11.0.0",
"husky": "^9.1.5",
"husky": "^9.1.6",
"normalize.css": "^8.0.1",
"postcss": "^8.4.45",
"postcss": "^8.4.47",
"prettier": "^3.3.3",
"react": "18.3.1",
"react-dom": "18.3.1",
Expand All @@ -179,7 +179,7 @@
"axios": "^1.7.7",
"crypto": "^1.0.1",
"marked": "^14.1.2",
"openai": "^4.58.2",
"openai": "^4.61.0",
"react-markdown": "^9.0.1",
"rehype-highlight": "^7.0.0",
"rehype-raw": "^7.0.0",
Expand Down
28 changes: 20 additions & 8 deletions src/JenkinsPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@ import {
} from "vscode";
import { getUri } from "./getUri";
import { getNonce } from "./getNonce";
import {
digest,
getAllBuild,
getLog,
getAnalysis,
readExistedResult,
} from "./getInfoFromJenkins";
import { digest, getAllBuild, getLog, getAnalysis, readExistedResult } from "./getInfoFromJenkins";
import "./extension.css";
import JenkinsSettings from "./JenkinsSettings";
import * as fs from "fs";
Expand Down Expand Up @@ -160,8 +154,9 @@ export class JenkinsPanel {
<section id="analysis-container" class="flex-wrap gap-1 h-full hidden" >
<details class="w-full" >
<summary class="flex flex-wrap m-1 p-1 list-none">
<p id="instruct" class="m2 w-10/12 p-2" ></p>
<p id="instruct" class="m2 w-9/12 p-2" ></p>
<vscode-button class="text-xs text-center h-6 w-1/12 self-center ml-4 rounded" id="analyse">Analyse</vscode-button>
<vscode-button class="text-xs text-center h-6 w-1/12 self-center ml-4 rounded" id="showResult">Show Result</vscode-button>
</summary>
<details class="w-full">
<summary class="text-xl font-bold text-white-600 list-none">Jenkins Build Log</summary>
Expand Down Expand Up @@ -221,6 +216,23 @@ export class JenkinsPanel {
const longRunTask_analysis = this.handleAnalysis(build_url, webView, token);
showStatusBarProgress(longRunTask_analysis, "analysing the log...");
break;
case "showResult":
const job_url = message.build_url;
const nameHash = digest(build_url);
const jsonContent = fs
.readFileSync(JenkinsPanel.storagePath + "/analysed/" + nameHash)
.toString();
const jsonObject = JSON.parse(jsonContent);
const fileContent =
nameHash +
"\n\n### " +
job_url +
"\n\n <details>\n<summary>Jenkins Log</summary>\n<pre>\n" +
jsonObject["input"]?.replace(/(?:\r\n|\r|\n)/g, "\n\n") +
"\n</pre></details>\n\n" +
jsonObject["output"];
commands.executeCommand("jenkins-log-reader.showResult", fileContent);
break;
case "batch":
message.url.forEach((build_url: string) => {
const longRunTask_analysis = this.handleAnalysis(build_url, webView, token);
Expand Down
11 changes: 11 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ function analyse() {
});
}

function showResult() {
const instruct = document.getElementById("instruct");
const url = instruct?.innerText;
vscode.postMessage({
command: "showResult",
build_url: url,
});
}

function resolve() {
const instruct = document.getElementById("instruct");
const url = instruct?.textContent;
Expand Down Expand Up @@ -145,6 +154,8 @@ function handleRowFocused(e: Event) {
}
const analyse_button = document.getElementById("analyse");
analyse_button?.addEventListener("click", analyse);
const showResult_button = document.getElementById("showResult");
showResult_button?.addEventListener("click", showResult);
const build_log = document.getElementById("build_log");
if (build_log) {
build_log.textContent = focused_data[0]["input"];
Expand Down

0 comments on commit a64125c

Please sign in to comment.