@kwirthmagnify/kwirth-plugin-pinocchio 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/front.js +53 -0
  2. package/package.json +1 -1
package/front.js CHANGED
@@ -122,6 +122,15 @@
122
122
  var react_1 = __importStar(require_react());
123
123
  var material_1 = require_material();
124
124
  var icons_material_1 = require_icons_material();
125
+ var downloadJson = (data, filename) => {
126
+ const blob = new Blob([JSON.stringify(data, null, 2)], { type: "application/json" });
127
+ const url = URL.createObjectURL(blob);
128
+ const a = document.createElement("a");
129
+ a.href = url;
130
+ a.download = filename;
131
+ a.click();
132
+ URL.revokeObjectURL(url);
133
+ };
125
134
  var LlmSelector = ({ llms, value, onChange, label = "LLM", size = "small", fullWidth = true }) => {
126
135
  return react_1.default.createElement(
127
136
  material_1.FormControl,
@@ -143,6 +152,7 @@
143
152
  var AiConfigLlm2 = (props) => {
144
153
  var _a;
145
154
  const [llms, setLlms] = (0, react_1.useState)(JSON.parse(JSON.stringify(props.llms)));
155
+ const importLlmRef = (0, react_1.useRef)(null);
146
156
  const [selectedIndex, setSelectedIndex] = (0, react_1.useState)(null);
147
157
  const [showPassword, setShowPassword] = (0, react_1.useState)(false);
148
158
  const [id, setId] = (0, react_1.useState)("");
@@ -280,6 +290,27 @@
280
290
  react_1.default.createElement(
281
291
  material_1.DialogActions,
282
292
  null,
293
+ react_1.default.createElement("input", { ref: importLlmRef, type: "file", accept: ".json", style: { display: "none" }, onChange: (e) => {
294
+ var _a2;
295
+ const f = (_a2 = e.target.files) === null || _a2 === void 0 ? void 0 : _a2[0];
296
+ if (!f)
297
+ return;
298
+ const reader = new FileReader();
299
+ reader.onload = (ev) => {
300
+ try {
301
+ setLlms(JSON.parse(ev.target.result));
302
+ } catch (_a3) {
303
+ }
304
+ };
305
+ reader.readAsText(f);
306
+ e.target.value = "";
307
+ } }),
308
+ react_1.default.createElement(material_1.Button, { startIcon: react_1.default.createElement(icons_material_1.FileUpload, { fontSize: "small" }), onClick: () => {
309
+ var _a2;
310
+ return (_a2 = importLlmRef.current) === null || _a2 === void 0 ? void 0 : _a2.click();
311
+ } }, "Import"),
312
+ react_1.default.createElement(material_1.Button, { startIcon: react_1.default.createElement(icons_material_1.FileDownload, { fontSize: "small" }), onClick: () => downloadJson(llms, "kwirth-llms.json") }, "Export"),
313
+ react_1.default.createElement(material_1.Box, { flex: 1 }),
283
314
  react_1.default.createElement(material_1.Button, { onClick: () => props.onClose(llms), variant: "contained" }, "OK"),
284
315
  react_1.default.createElement(material_1.Button, { onClick: () => props.onClose(void 0), color: "inherit" }, "Cancel")
285
316
  )
@@ -289,6 +320,7 @@
289
320
  var AiConfigProvider2 = (props) => {
290
321
  var _a;
291
322
  const [providers, setProviders] = (0, react_1.useState)(JSON.parse(JSON.stringify(props.providers)));
323
+ const importProvRef = (0, react_1.useRef)(null);
292
324
  const [selectedIndex, setSelectedIndex] = (0, react_1.useState)(null);
293
325
  const [showPassword, setShowPassword] = (0, react_1.useState)(false);
294
326
  const [providerName, setProviderName] = (0, react_1.useState)("");
@@ -387,6 +419,27 @@
387
419
  react_1.default.createElement(
388
420
  material_1.DialogActions,
389
421
  { sx: { p: 2 } },
422
+ react_1.default.createElement("input", { ref: importProvRef, type: "file", accept: ".json", style: { display: "none" }, onChange: (e) => {
423
+ var _a2;
424
+ const f = (_a2 = e.target.files) === null || _a2 === void 0 ? void 0 : _a2[0];
425
+ if (!f)
426
+ return;
427
+ const reader = new FileReader();
428
+ reader.onload = (ev) => {
429
+ try {
430
+ setProviders(JSON.parse(ev.target.result));
431
+ } catch (_a3) {
432
+ }
433
+ };
434
+ reader.readAsText(f);
435
+ e.target.value = "";
436
+ } }),
437
+ react_1.default.createElement(material_1.Button, { startIcon: react_1.default.createElement(icons_material_1.FileUpload, { fontSize: "small" }), onClick: () => {
438
+ var _a2;
439
+ return (_a2 = importProvRef.current) === null || _a2 === void 0 ? void 0 : _a2.click();
440
+ } }, "Import"),
441
+ react_1.default.createElement(material_1.Button, { startIcon: react_1.default.createElement(icons_material_1.FileDownload, { fontSize: "small" }), onClick: () => downloadJson(providers.map((p) => ({ name: p.name, key: p.key })), "kwirth-providers.json") }, "Export"),
442
+ react_1.default.createElement(material_1.Box, { flex: 1 }),
390
443
  react_1.default.createElement(material_1.Button, { onClick: () => props.onClose(providers), color: "primary", variant: "contained" }, "Save"),
391
444
  react_1.default.createElement(material_1.Button, { onClick: () => props.onClose(void 0), color: "inherit" }, "Cancel")
392
445
  )
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "id": "pinocchio",
3
3
  "name": "@kwirthmagnify/kwirth-plugin-pinocchio",
4
4
  "displayName": "Pinocchio",
5
- "version": "0.2.4",
5
+ "version": "0.2.5",
6
6
  "description": "Pinocchio AI channel plugin for Kwirth - LLM-based Kubernetes event analysis",
7
7
  "icon": "AutoFixHigh",
8
8
  "website": "https://kwirthmagnify.dev"