@kwirthmagnify/kwirth-plugin-pinocchio 0.2.3 → 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 +58 -0
  2. package/package.json +1 -1
package/front.js CHANGED
@@ -31,6 +31,7 @@
31
31
  "kwirth-globals:react"(exports, module) {
32
32
  var _m = window.__kwirth__.React;
33
33
  var _d = _m != null && "default" in Object(_m) ? _m.default : _m;
34
+ if (typeof _d !== "function" && _d != null && typeof _d.default !== "undefined") _d = _d.default;
34
35
  module.exports = Object.assign({}, typeof _m === "object" && _m !== null ? _m : {}, { default: _d, __esModule: true });
35
36
  }
36
37
  });
@@ -40,6 +41,7 @@
40
41
  "kwirth-globals:@mui/icons-material"(exports, module) {
41
42
  var _m = window.__kwirth__.MUI.icons;
42
43
  var _d = _m != null && "default" in Object(_m) ? _m.default : _m;
44
+ if (typeof _d !== "function" && _d != null && typeof _d.default !== "undefined") _d = _d.default;
43
45
  module.exports = Object.assign({}, typeof _m === "object" && _m !== null ? _m : {}, { default: _d, __esModule: true });
44
46
  }
45
47
  });
@@ -49,6 +51,7 @@
49
51
  "kwirth-globals:@kwirthmagnify/kwirth-common"(exports, module) {
50
52
  var _m = window.__kwirth__.kwirthCommon;
51
53
  var _d = _m != null && "default" in Object(_m) ? _m.default : _m;
54
+ if (typeof _d !== "function" && _d != null && typeof _d.default !== "undefined") _d = _d.default;
52
55
  module.exports = Object.assign({}, typeof _m === "object" && _m !== null ? _m : {}, { default: _d, __esModule: true });
53
56
  }
54
57
  });
@@ -58,6 +61,7 @@
58
61
  "kwirth-globals:@mui/material"(exports, module) {
59
62
  var _m = window.__kwirth__.MUI.material;
60
63
  var _d = _m != null && "default" in Object(_m) ? _m.default : _m;
64
+ if (typeof _d !== "function" && _d != null && typeof _d.default !== "undefined") _d = _d.default;
61
65
  module.exports = Object.assign({}, typeof _m === "object" && _m !== null ? _m : {}, { default: _d, __esModule: true });
62
66
  }
63
67
  });
@@ -67,6 +71,7 @@
67
71
  "kwirth-globals:@kwirthmagnify/kwirth-common-front"(exports, module) {
68
72
  var _m = window.__kwirth__.kwirthCommonFront;
69
73
  var _d = _m != null && "default" in Object(_m) ? _m.default : _m;
74
+ if (typeof _d !== "function" && _d != null && typeof _d.default !== "undefined") _d = _d.default;
70
75
  module.exports = Object.assign({}, typeof _m === "object" && _m !== null ? _m : {}, { default: _d, __esModule: true });
71
76
  }
72
77
  });
@@ -117,6 +122,15 @@
117
122
  var react_1 = __importStar(require_react());
118
123
  var material_1 = require_material();
119
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
+ };
120
134
  var LlmSelector = ({ llms, value, onChange, label = "LLM", size = "small", fullWidth = true }) => {
121
135
  return react_1.default.createElement(
122
136
  material_1.FormControl,
@@ -138,6 +152,7 @@
138
152
  var AiConfigLlm2 = (props) => {
139
153
  var _a;
140
154
  const [llms, setLlms] = (0, react_1.useState)(JSON.parse(JSON.stringify(props.llms)));
155
+ const importLlmRef = (0, react_1.useRef)(null);
141
156
  const [selectedIndex, setSelectedIndex] = (0, react_1.useState)(null);
142
157
  const [showPassword, setShowPassword] = (0, react_1.useState)(false);
143
158
  const [id, setId] = (0, react_1.useState)("");
@@ -275,6 +290,27 @@
275
290
  react_1.default.createElement(
276
291
  material_1.DialogActions,
277
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 }),
278
314
  react_1.default.createElement(material_1.Button, { onClick: () => props.onClose(llms), variant: "contained" }, "OK"),
279
315
  react_1.default.createElement(material_1.Button, { onClick: () => props.onClose(void 0), color: "inherit" }, "Cancel")
280
316
  )
@@ -284,6 +320,7 @@
284
320
  var AiConfigProvider2 = (props) => {
285
321
  var _a;
286
322
  const [providers, setProviders] = (0, react_1.useState)(JSON.parse(JSON.stringify(props.providers)));
323
+ const importProvRef = (0, react_1.useRef)(null);
287
324
  const [selectedIndex, setSelectedIndex] = (0, react_1.useState)(null);
288
325
  const [showPassword, setShowPassword] = (0, react_1.useState)(false);
289
326
  const [providerName, setProviderName] = (0, react_1.useState)("");
@@ -382,6 +419,27 @@
382
419
  react_1.default.createElement(
383
420
  material_1.DialogActions,
384
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 }),
385
443
  react_1.default.createElement(material_1.Button, { onClick: () => props.onClose(providers), color: "primary", variant: "contained" }, "Save"),
386
444
  react_1.default.createElement(material_1.Button, { onClick: () => props.onClose(void 0), color: "inherit" }, "Cancel")
387
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.3",
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"