@vegan-friendly/strapi-plugin-elasticsearch 0.1.0-alpha.2 → 0.1.0-alpha.3
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.
- package/dist/admin/components/Initializer/index.d.ts +15 -0
- package/dist/admin/components/Initializer/index.js +25 -0
- package/dist/admin/components/PluginIcon/index.d.ts +8 -0
- package/dist/admin/components/PluginIcon/index.js +14 -0
- package/dist/admin/components/SubNavigation/index.d.ts +4 -0
- package/dist/admin/components/SubNavigation/index.js +40 -0
- package/dist/admin/index.d.ts +8 -0
- package/dist/admin/index.js +92 -0
- package/dist/admin/pages/App/index.d.ts +9 -0
- package/dist/admin/pages/App/index.js +29 -0
- package/dist/admin/pages/ConfigureCollection/index.d.ts +3 -0
- package/dist/admin/pages/ConfigureCollection/index.js +193 -0
- package/dist/admin/pages/ConfigureCollectionList/index.d.ts +3 -0
- package/dist/admin/pages/ConfigureCollectionList/index.js +228 -0
- package/dist/admin/pages/Homepage/index.d.ts +3 -0
- package/dist/admin/pages/Homepage/index.js +155 -0
- package/dist/admin/pages/ViewIndexingRunLog/index.d.ts +3 -0
- package/dist/admin/pages/ViewIndexingRunLog/index.js +125 -0
- package/dist/admin/pluginId.d.ts +2 -0
- package/dist/admin/pluginId.js +8 -0
- package/dist/admin/utils/apiUrls.d.ts +10 -0
- package/dist/admin/utils/apiUrls.js +20 -0
- package/dist/admin/utils/axiosInstance.d.ts +5 -0
- package/dist/admin/utils/axiosInstance.js +33 -0
- package/dist/admin/utils/getTrad.d.ts +2 -0
- package/dist/admin/utils/getTrad.js +8 -0
- package/package.json +1 -1
@@ -0,0 +1,15 @@
|
|
1
|
+
/**
|
2
|
+
*
|
3
|
+
* Initializer
|
4
|
+
*
|
5
|
+
*/
|
6
|
+
import PropTypes from 'prop-types';
|
7
|
+
declare const Initializer: {
|
8
|
+
({ setPlugin }: {
|
9
|
+
setPlugin: any;
|
10
|
+
}): null;
|
11
|
+
propTypes: {
|
12
|
+
setPlugin: PropTypes.Validator<(...args: any[]) => any>;
|
13
|
+
};
|
14
|
+
};
|
15
|
+
export default Initializer;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
"use strict";
|
2
|
+
/**
|
3
|
+
*
|
4
|
+
* Initializer
|
5
|
+
*
|
6
|
+
*/
|
7
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
8
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
9
|
+
};
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
11
|
+
const react_1 = require("react");
|
12
|
+
const prop_types_1 = __importDefault(require("prop-types"));
|
13
|
+
const pluginId_1 = __importDefault(require("../../pluginId"));
|
14
|
+
const Initializer = ({ setPlugin }) => {
|
15
|
+
const ref = (0, react_1.useRef)();
|
16
|
+
ref.current = setPlugin;
|
17
|
+
(0, react_1.useEffect)(() => {
|
18
|
+
ref.current(pluginId_1.default);
|
19
|
+
}, []);
|
20
|
+
return null;
|
21
|
+
};
|
22
|
+
Initializer.propTypes = {
|
23
|
+
setPlugin: prop_types_1.default.func.isRequired,
|
24
|
+
};
|
25
|
+
exports.default = Initializer;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
/**
|
3
|
+
*
|
4
|
+
* PluginIcon
|
5
|
+
*
|
6
|
+
*/
|
7
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
8
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
9
|
+
};
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
11
|
+
const react_1 = __importDefault(require("react"));
|
12
|
+
const icons_1 = require("@strapi/icons");
|
13
|
+
const PluginIcon = () => react_1.default.createElement(icons_1.Search, null);
|
14
|
+
exports.default = PluginIcon;
|
@@ -0,0 +1,40 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.SubNavigation = void 0;
|
7
|
+
const react_1 = __importDefault(require("react"));
|
8
|
+
const icons_1 = require("@strapi/icons");
|
9
|
+
const design_system_1 = require("@strapi/design-system");
|
10
|
+
const v2_1 = require("@strapi/design-system/v2");
|
11
|
+
const react_router_dom_1 = require("react-router-dom");
|
12
|
+
const pluginId_1 = __importDefault(require("../../pluginId"));
|
13
|
+
const SubNavigation = ({ activeUrl }) => {
|
14
|
+
const links = [{
|
15
|
+
id: 1,
|
16
|
+
label: 'Setup Information',
|
17
|
+
icon: icons_1.Connector,
|
18
|
+
to: `/plugins/${pluginId_1.default}/home`,
|
19
|
+
},
|
20
|
+
{
|
21
|
+
id: 2,
|
22
|
+
label: 'Configure Collections',
|
23
|
+
icon: icons_1.Connector,
|
24
|
+
to: `/plugins/${pluginId_1.default}/configure-collections`,
|
25
|
+
},
|
26
|
+
{
|
27
|
+
id: 3,
|
28
|
+
label: 'Indexing Run Logs',
|
29
|
+
icon: icons_1.Connector,
|
30
|
+
to: `/plugins/${pluginId_1.default}/view-indexing-logs`,
|
31
|
+
}];
|
32
|
+
return (react_1.default.createElement(design_system_1.Box, { style: {
|
33
|
+
height: '100vh'
|
34
|
+
}, background: "neutral200" },
|
35
|
+
react_1.default.createElement(v2_1.SubNav, { ariaLabel: "Settings sub nav" },
|
36
|
+
react_1.default.createElement(v2_1.SubNavHeader, { label: "Strapi Elasticsearch" }),
|
37
|
+
react_1.default.createElement(v2_1.SubNavSections, null,
|
38
|
+
react_1.default.createElement(v2_1.SubNavSection, null, links.map(link => link.icon && react_1.default.createElement(v2_1.SubNavLink, { as: react_router_dom_1.NavLink, to: link.to, icon: link.icon, key: link.id }, link.label)))))));
|
39
|
+
};
|
40
|
+
exports.SubNavigation = SubNavigation;
|
@@ -0,0 +1,92 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
19
|
+
var ownKeys = function(o) {
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
21
|
+
var ar = [];
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
23
|
+
return ar;
|
24
|
+
};
|
25
|
+
return ownKeys(o);
|
26
|
+
};
|
27
|
+
return function (mod) {
|
28
|
+
if (mod && mod.__esModule) return mod;
|
29
|
+
var result = {};
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
31
|
+
__setModuleDefault(result, mod);
|
32
|
+
return result;
|
33
|
+
};
|
34
|
+
})();
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
37
|
+
};
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
39
|
+
const helper_plugin_1 = require("@strapi/helper-plugin");
|
40
|
+
const package_json_1 = __importDefault(require("../../package.json"));
|
41
|
+
const pluginId_1 = __importDefault(require("./pluginId"));
|
42
|
+
const Initializer_1 = __importDefault(require("./components/Initializer"));
|
43
|
+
const PluginIcon_1 = __importDefault(require("./components/PluginIcon"));
|
44
|
+
const name = package_json_1.default.strapi.name;
|
45
|
+
exports.default = {
|
46
|
+
register(app) {
|
47
|
+
app.addMenuLink({
|
48
|
+
to: `/plugins/${pluginId_1.default}`,
|
49
|
+
icon: PluginIcon_1.default,
|
50
|
+
intlLabel: {
|
51
|
+
id: `${pluginId_1.default}.plugin.name`,
|
52
|
+
defaultMessage: 'Elasticsearch',
|
53
|
+
},
|
54
|
+
Component: async () => {
|
55
|
+
const component = await Promise.resolve().then(() => __importStar(require(/* webpackChunkName: "[request]" */ './pages/App')));
|
56
|
+
return component;
|
57
|
+
},
|
58
|
+
permissions: [
|
59
|
+
// Uncomment to set the permissions of the plugin here
|
60
|
+
// {
|
61
|
+
// action: '', // the action name should be plugin::plugin-name.actionType
|
62
|
+
// subject: null,
|
63
|
+
// },
|
64
|
+
],
|
65
|
+
});
|
66
|
+
app.registerPlugin({
|
67
|
+
id: pluginId_1.default,
|
68
|
+
initializer: Initializer_1.default,
|
69
|
+
isReady: false,
|
70
|
+
name,
|
71
|
+
});
|
72
|
+
},
|
73
|
+
bootstrap(app) { },
|
74
|
+
async registerTrads({ locales }) {
|
75
|
+
const importedTrads = await Promise.all(locales.map((locale) => {
|
76
|
+
return Promise.resolve(`${
|
77
|
+
/* webpackChunkName: "translation-[request]" */ `./translations/${locale}.json`}`).then(s => __importStar(require(s))).then(({ default: data }) => {
|
78
|
+
return {
|
79
|
+
data: (0, helper_plugin_1.prefixPluginTranslations)(data, pluginId_1.default),
|
80
|
+
locale,
|
81
|
+
};
|
82
|
+
})
|
83
|
+
.catch(() => {
|
84
|
+
return {
|
85
|
+
data: {},
|
86
|
+
locale,
|
87
|
+
};
|
88
|
+
});
|
89
|
+
}));
|
90
|
+
return Promise.resolve(importedTrads);
|
91
|
+
},
|
92
|
+
};
|
@@ -0,0 +1,29 @@
|
|
1
|
+
"use strict";
|
2
|
+
/**
|
3
|
+
*
|
4
|
+
* This component is the skeleton around the actual pages, and should only
|
5
|
+
* contain code that should be seen on all pages. (e.g. navigation bar)
|
6
|
+
*
|
7
|
+
*/
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
const react_1 = __importDefault(require("react"));
|
13
|
+
const react_router_dom_1 = require("react-router-dom");
|
14
|
+
const helper_plugin_1 = require("@strapi/helper-plugin");
|
15
|
+
const pluginId_1 = __importDefault(require("../../pluginId"));
|
16
|
+
const ConfigureCollectionList_1 = __importDefault(require("../ConfigureCollectionList"));
|
17
|
+
const ConfigureCollection_1 = __importDefault(require("../ConfigureCollection"));
|
18
|
+
const ViewIndexingRunLog_1 = __importDefault(require("../ViewIndexingRunLog"));
|
19
|
+
const Homepage_1 = __importDefault(require("../Homepage"));
|
20
|
+
const App = () => {
|
21
|
+
return (react_1.default.createElement(react_router_dom_1.Switch, null,
|
22
|
+
react_1.default.createElement(react_router_dom_1.Route, { path: `/plugins/${pluginId_1.default}`, render: () => (react_1.default.createElement(react_router_dom_1.Redirect, { to: `/plugins/${pluginId_1.default}/home` })), exact: true }),
|
23
|
+
react_1.default.createElement(react_router_dom_1.Route, { path: `/plugins/${pluginId_1.default}/home`, component: Homepage_1.default, exact: true }),
|
24
|
+
react_1.default.createElement(react_router_dom_1.Route, { path: `/plugins/${pluginId_1.default}/configure-collections`, component: ConfigureCollectionList_1.default, exact: true }),
|
25
|
+
react_1.default.createElement(react_router_dom_1.Route, { path: `/plugins/${pluginId_1.default}/configure-collections/:collectionName`, component: ConfigureCollection_1.default, exact: true }),
|
26
|
+
react_1.default.createElement(react_router_dom_1.Route, { path: `/plugins/${pluginId_1.default}/view-indexing-logs`, component: ViewIndexingRunLog_1.default }),
|
27
|
+
react_1.default.createElement(react_router_dom_1.Route, { component: helper_plugin_1.AnErrorOccurred })));
|
28
|
+
};
|
29
|
+
exports.default = App;
|
@@ -0,0 +1,193 @@
|
|
1
|
+
"use strict";
|
2
|
+
/*
|
3
|
+
*
|
4
|
+
* HomePage
|
5
|
+
*
|
6
|
+
*/
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
8
|
+
if (k2 === undefined) k2 = k;
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
12
|
+
}
|
13
|
+
Object.defineProperty(o, k2, desc);
|
14
|
+
}) : (function(o, m, k, k2) {
|
15
|
+
if (k2 === undefined) k2 = k;
|
16
|
+
o[k2] = m[k];
|
17
|
+
}));
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
20
|
+
}) : function(o, v) {
|
21
|
+
o["default"] = v;
|
22
|
+
});
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
24
|
+
var ownKeys = function(o) {
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
26
|
+
var ar = [];
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
28
|
+
return ar;
|
29
|
+
};
|
30
|
+
return ownKeys(o);
|
31
|
+
};
|
32
|
+
return function (mod) {
|
33
|
+
if (mod && mod.__esModule) return mod;
|
34
|
+
var result = {};
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
36
|
+
__setModuleDefault(result, mod);
|
37
|
+
return result;
|
38
|
+
};
|
39
|
+
})();
|
40
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
41
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
42
|
+
};
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
44
|
+
const react_1 = __importStar(require("react"));
|
45
|
+
const react_router_dom_1 = require("react-router-dom");
|
46
|
+
const axiosInstance_1 = __importDefault(require("../../utils/axiosInstance"));
|
47
|
+
const SubNavigation_1 = require("../../components/SubNavigation");
|
48
|
+
;
|
49
|
+
const design_system_1 = require("@strapi/design-system");
|
50
|
+
const design_system_2 = require("@strapi/design-system");
|
51
|
+
const helper_plugin_1 = require("@strapi/helper-plugin");
|
52
|
+
const pluginId_1 = __importDefault(require("../../pluginId"));
|
53
|
+
const apiUrls_1 = require("../../utils/apiUrls");
|
54
|
+
const design_system_3 = require("@strapi/design-system");
|
55
|
+
const icons_1 = require("@strapi/icons");
|
56
|
+
const design_system_4 = require("@strapi/design-system");
|
57
|
+
const design_system_5 = require("@strapi/design-system");
|
58
|
+
const helper_plugin_2 = require("@strapi/helper-plugin");
|
59
|
+
const loadConfigForCollection = (collectionName) => {
|
60
|
+
return axiosInstance_1.default.get((0, apiUrls_1.apiGetCollectionConfig)(collectionName))
|
61
|
+
.then((resp) => resp.data);
|
62
|
+
};
|
63
|
+
const saveConfigForCollection = (collectionName, data) => {
|
64
|
+
return axiosInstance_1.default.post((0, apiUrls_1.apiSaveCollectionConfig)(collectionName), {
|
65
|
+
data
|
66
|
+
});
|
67
|
+
};
|
68
|
+
const ConfigureField = ({ config, index, setFieldConfig }) => {
|
69
|
+
const validateSubfieldsConfig = (conf) => {
|
70
|
+
if (conf && conf.length > 0) {
|
71
|
+
try {
|
72
|
+
JSON.parse(conf);
|
73
|
+
return true;
|
74
|
+
}
|
75
|
+
catch (e) {
|
76
|
+
return false;
|
77
|
+
}
|
78
|
+
}
|
79
|
+
else
|
80
|
+
return true;
|
81
|
+
};
|
82
|
+
const updateIndex = (checked) => {
|
83
|
+
setFieldConfig({ index, config: { ...config, index: checked } });
|
84
|
+
};
|
85
|
+
const updateSubfieldConfig = (subfields) => {
|
86
|
+
const subfieldsConfigValid = validateSubfieldsConfig(subfields);
|
87
|
+
setFieldConfig({ index, config: { ...config, subfields, subfieldsConfigValid } });
|
88
|
+
};
|
89
|
+
const updateMappedFieldName = (mappedName) => {
|
90
|
+
setFieldConfig({ index, config: { ...config, searchFieldName: mappedName } });
|
91
|
+
};
|
92
|
+
return (react_1.default.createElement(design_system_1.Box, { background: "neutral100", borderColor: "neutral200", hasRadius: true, index: index, padding: 4 },
|
93
|
+
react_1.default.createElement(design_system_1.Box, { paddingTop: 2, paddingBottom: 2 },
|
94
|
+
react_1.default.createElement(design_system_4.Typography, { fontWeight: "bold", textColor: "neutral600" }, config.name)),
|
95
|
+
react_1.default.createElement(design_system_1.Box, { paddingTop: 2, paddingBottom: 2 },
|
96
|
+
react_1.default.createElement(design_system_2.ToggleInput, { label: "Index", onLabel: "Yes", offLabel: "No", checked: config.index, onChange: (e) => updateIndex(e.target.checked) })),
|
97
|
+
react_1.default.createElement(design_system_1.Box, { width: "50%", paddingTop: 2, paddingBottom: 2 },
|
98
|
+
react_1.default.createElement(design_system_5.TextInput, { label: "Maps to search field", placeholder: "Enter field name", name: "Search field", onChange: e => updateMappedFieldName(e.target.value), value: config.searchFieldName || "" })),
|
99
|
+
config.index && config.type && config.type === "dynamiczone" ? (react_1.default.createElement(design_system_1.Box, { paddingTop: 2, paddingBottom: 2 },
|
100
|
+
react_1.default.createElement(design_system_5.Textarea, { label: "Dynamic zone fields to index", error: config.subfieldsConfigValid === false ? 'Invalid indexing configuration' : undefined, onChange: e => updateSubfieldConfig(e.target.value) }, config.subfields || ""))) : null,
|
101
|
+
config.index && config.type && config.type === "component" ? (react_1.default.createElement(design_system_1.Box, { paddingTop: 2, paddingBottom: 2 },
|
102
|
+
react_1.default.createElement(design_system_5.Textarea, { label: "Component fields to index", error: config.subfieldsConfigValid === false ? 'Invalid indexing configuration' : undefined, onChange: e => updateSubfieldConfig(e.target.value) }, config.subfields || ""))) : null));
|
103
|
+
};
|
104
|
+
const ConfigureCollection = () => {
|
105
|
+
const [isInProgress, setIsInProgress] = (0, react_1.useState)(false);
|
106
|
+
const [selectedCollection, setSelectedCollection] = (0, react_1.useState)(null);
|
107
|
+
const [collectionConfig, setCollectionConfig] = (0, react_1.useState)(null);
|
108
|
+
const params = (0, react_router_dom_1.useParams)();
|
109
|
+
const toggleNotification = (0, helper_plugin_2.useNotification)();
|
110
|
+
const updateCollectionsConfig = ({ index, config }) => {
|
111
|
+
setCollectionConfig({
|
112
|
+
collectionName: collectionConfig.collectionName,
|
113
|
+
attributes: collectionConfig.attributes.map((e, idx) => index === idx ? config : e)
|
114
|
+
});
|
115
|
+
};
|
116
|
+
const saveCollectionConfig = () => {
|
117
|
+
if (collectionConfig && collectionConfig.collectionName) {
|
118
|
+
const data = {};
|
119
|
+
data[collectionConfig.collectionName] = {};
|
120
|
+
for (let k = 0; k < collectionConfig.attributes.length; k++) {
|
121
|
+
const { name, ...attribs } = collectionConfig.attributes[k];
|
122
|
+
data[collectionConfig.collectionName][name] = attribs;
|
123
|
+
}
|
124
|
+
setIsInProgress(true);
|
125
|
+
saveConfigForCollection(collectionConfig.collectionName, data)
|
126
|
+
.then((resp) => {
|
127
|
+
toggleNotification({
|
128
|
+
type: "success", message: "The collection configuration is saved.", timeout: 5000
|
129
|
+
});
|
130
|
+
})
|
131
|
+
.catch((err) => {
|
132
|
+
toggleNotification({
|
133
|
+
type: "warning", message: err.message || "An error was encountered.", timeout: 5000
|
134
|
+
});
|
135
|
+
console.log(err);
|
136
|
+
})
|
137
|
+
.finally(() => setIsInProgress(false));
|
138
|
+
}
|
139
|
+
};
|
140
|
+
(0, react_1.useEffect)(() => {
|
141
|
+
if (params && params.collectionName)
|
142
|
+
setSelectedCollection(params.collectionName);
|
143
|
+
}, [params]);
|
144
|
+
(0, react_1.useEffect)(() => {
|
145
|
+
if (selectedCollection) {
|
146
|
+
loadConfigForCollection(selectedCollection)
|
147
|
+
.then((resp) => {
|
148
|
+
if (Object.keys(resp).length === 0) {
|
149
|
+
toggleNotification({
|
150
|
+
type: "warning", message: 'No collection with the selected name exists.', timeout: 5000
|
151
|
+
});
|
152
|
+
}
|
153
|
+
else {
|
154
|
+
const collectionName = Object.keys(resp)[0];
|
155
|
+
const attributeNames = Object.keys(resp[collectionName]);
|
156
|
+
const attributes = [];
|
157
|
+
for (let s = 0; s < attributeNames.length; s++)
|
158
|
+
attributes.push({ name: attributeNames[s], ...resp[collectionName][attributeNames[s]] });
|
159
|
+
const item = { collectionName, attributes };
|
160
|
+
setCollectionConfig(item);
|
161
|
+
}
|
162
|
+
})
|
163
|
+
.catch((err) => {
|
164
|
+
toggleNotification({
|
165
|
+
type: "warning", message: err.message || "An error was encountered.", timeout: 5000
|
166
|
+
});
|
167
|
+
console.log(err);
|
168
|
+
});
|
169
|
+
}
|
170
|
+
}, [selectedCollection]);
|
171
|
+
if (collectionConfig === null)
|
172
|
+
return react_1.default.createElement(helper_plugin_2.LoadingIndicatorPage, null);
|
173
|
+
else
|
174
|
+
return (react_1.default.createElement(design_system_1.Flex, { alignItems: "stretch", gap: 4 },
|
175
|
+
react_1.default.createElement(SubNavigation_1.SubNavigation, null),
|
176
|
+
react_1.default.createElement(design_system_1.Box, { padding: 8, background: "neutral100", width: "100%" },
|
177
|
+
react_1.default.createElement(design_system_1.Box, { paddingBottom: 4 },
|
178
|
+
react_1.default.createElement(helper_plugin_1.Link, { startIcon: react_1.default.createElement(icons_1.ArrowLeft, null), to: `/plugins/${pluginId_1.default}/configure-collections/` }, "Back")),
|
179
|
+
selectedCollection && (react_1.default.createElement(design_system_1.Box, { paddingBottom: 4 },
|
180
|
+
react_1.default.createElement(design_system_4.Typography, { variant: "alpha" }, selectedCollection))),
|
181
|
+
collectionConfig && (react_1.default.createElement(react_1.default.Fragment, null,
|
182
|
+
react_1.default.createElement(design_system_1.Flex, { alignItems: "stretch", gap: 4, width: "100%" },
|
183
|
+
react_1.default.createElement(design_system_1.Box, { padding: 8, background: "neutral0", width: "100%" },
|
184
|
+
react_1.default.createElement(design_system_1.Box, { paddingBottom: 2 },
|
185
|
+
react_1.default.createElement(design_system_4.Typography, { variant: "beta" }, "Attributes"),
|
186
|
+
collectionConfig.attributes.map((a, idx) => {
|
187
|
+
return react_1.default.createElement(design_system_1.Box, { paddingTop: 4, paddingBottom: 4 },
|
188
|
+
react_1.default.createElement(ConfigureField, { index: idx, config: a, setFieldConfig: updateCollectionsConfig }));
|
189
|
+
})))),
|
190
|
+
react_1.default.createElement(design_system_1.Box, { paddingTop: 4 },
|
191
|
+
react_1.default.createElement(design_system_3.Button, { loading: isInProgress, variant: "default", onClick: saveCollectionConfig }, "Save Configuration Changes")))))));
|
192
|
+
};
|
193
|
+
exports.default = ConfigureCollection;
|
@@ -0,0 +1,228 @@
|
|
1
|
+
"use strict";
|
2
|
+
/*
|
3
|
+
*
|
4
|
+
* HomePage
|
5
|
+
*
|
6
|
+
*/
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
8
|
+
if (k2 === undefined) k2 = k;
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
12
|
+
}
|
13
|
+
Object.defineProperty(o, k2, desc);
|
14
|
+
}) : (function(o, m, k, k2) {
|
15
|
+
if (k2 === undefined) k2 = k;
|
16
|
+
o[k2] = m[k];
|
17
|
+
}));
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
20
|
+
}) : function(o, v) {
|
21
|
+
o["default"] = v;
|
22
|
+
});
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
24
|
+
var ownKeys = function(o) {
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
26
|
+
var ar = [];
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
28
|
+
return ar;
|
29
|
+
};
|
30
|
+
return ownKeys(o);
|
31
|
+
};
|
32
|
+
return function (mod) {
|
33
|
+
if (mod && mod.__esModule) return mod;
|
34
|
+
var result = {};
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
36
|
+
__setModuleDefault(result, mod);
|
37
|
+
return result;
|
38
|
+
};
|
39
|
+
})();
|
40
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
41
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
42
|
+
};
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
44
|
+
const react_1 = __importStar(require("react"));
|
45
|
+
// import PropTypes from 'prop-types';
|
46
|
+
const pluginId_1 = __importDefault(require("../../pluginId"));
|
47
|
+
const SubNavigation_1 = require("../../components/SubNavigation");
|
48
|
+
;
|
49
|
+
const design_system_1 = require("@strapi/design-system");
|
50
|
+
const react_2 = require("react");
|
51
|
+
const apiUrls_1 = require("../../utils/apiUrls");
|
52
|
+
const axiosInstance_1 = __importDefault(require("../../utils/axiosInstance"));
|
53
|
+
const design_system_2 = require("@strapi/design-system");
|
54
|
+
const design_system_3 = require("@strapi/design-system");
|
55
|
+
const icons_1 = require("@strapi/icons");
|
56
|
+
const design_system_4 = require("@strapi/design-system");
|
57
|
+
const react_router_dom_1 = require("react-router-dom");
|
58
|
+
const design_system_5 = require("@strapi/design-system");
|
59
|
+
const design_system_6 = require("@strapi/design-system");
|
60
|
+
const design_system_7 = require("@strapi/design-system");
|
61
|
+
const helper_plugin_1 = require("@strapi/helper-plugin");
|
62
|
+
const exportContentConfig = () => {
|
63
|
+
return axiosInstance_1.default.get(apiUrls_1.apiGetContentConfig, {
|
64
|
+
responseType: 'blob'
|
65
|
+
})
|
66
|
+
.then((response) => {
|
67
|
+
const href = URL.createObjectURL(response.data);
|
68
|
+
const link = document.createElement('a');
|
69
|
+
link.href = href;
|
70
|
+
link.setAttribute('download', 'strapi-plugin-elasticsearch-contentconfig.json');
|
71
|
+
document.body.appendChild(link);
|
72
|
+
link.click();
|
73
|
+
document.body.removeChild(link);
|
74
|
+
URL.revokeObjectURL(href);
|
75
|
+
});
|
76
|
+
};
|
77
|
+
const importContentConfig = (conf) => {
|
78
|
+
return axiosInstance_1.default.post(apiUrls_1.apiImportContentConfig, {
|
79
|
+
data: conf
|
80
|
+
});
|
81
|
+
};
|
82
|
+
const loadContentConfig = () => {
|
83
|
+
return axiosInstance_1.default.get(apiUrls_1.apiGetContentConfig)
|
84
|
+
.then((resp) => resp.data);
|
85
|
+
};
|
86
|
+
const scheduleCollectionIndexing = (collectionName) => {
|
87
|
+
return axiosInstance_1.default.get((0, apiUrls_1.apiRequestCollectionIndexing)(collectionName));
|
88
|
+
};
|
89
|
+
const Configure = () => {
|
90
|
+
const [isInProgress, setIsInProgress] = (0, react_1.useState)(false);
|
91
|
+
const [displayImportModal, setDisplayImportModal] = (0, react_1.useState)(false);
|
92
|
+
const [isEnteredJsonValid, setIsEnteredJsonValid] = (0, react_1.useState)(true);
|
93
|
+
const [importJson, setImportJson] = (0, react_1.useState)(null);
|
94
|
+
const [config, setConfig] = (0, react_1.useState)(null);
|
95
|
+
const history = (0, react_router_dom_1.useHistory)();
|
96
|
+
const toggleNotification = (0, helper_plugin_1.useNotification)();
|
97
|
+
const performImport = () => {
|
98
|
+
const conf = importJson;
|
99
|
+
console.log(conf && conf.length > 0);
|
100
|
+
if (conf && conf.length > 0) {
|
101
|
+
setIsInProgress(true);
|
102
|
+
importContentConfig(conf)
|
103
|
+
.then(() => {
|
104
|
+
toggleNotification({
|
105
|
+
type: "success", message: "Collections configuration imported. Please refresh this view.", timeout: 5000
|
106
|
+
});
|
107
|
+
})
|
108
|
+
.catch((err) => {
|
109
|
+
toggleNotification({
|
110
|
+
type: "warning", message: "Importing collections configuration failed. An error was encountered.", timeout: 5000
|
111
|
+
});
|
112
|
+
console.log(err);
|
113
|
+
})
|
114
|
+
.finally(() => setIsInProgress(false));
|
115
|
+
}
|
116
|
+
};
|
117
|
+
const performExport = () => {
|
118
|
+
setIsInProgress(true);
|
119
|
+
exportContentConfig()
|
120
|
+
.then(() => {
|
121
|
+
toggleNotification({
|
122
|
+
type: "success", message: "Collections configuration exported.", timeout: 5000
|
123
|
+
});
|
124
|
+
})
|
125
|
+
.catch((err) => {
|
126
|
+
toggleNotification({
|
127
|
+
type: "warning", message: "Exporting collections configuration failed. An error was encountered.", timeout: 5000
|
128
|
+
});
|
129
|
+
console.log(err);
|
130
|
+
})
|
131
|
+
.finally(() => setIsInProgress(false));
|
132
|
+
};
|
133
|
+
(0, react_2.useEffect)(() => {
|
134
|
+
if (importJson && importJson.length > 0) {
|
135
|
+
try {
|
136
|
+
JSON.parse(importJson);
|
137
|
+
setIsEnteredJsonValid(true);
|
138
|
+
}
|
139
|
+
catch (e) {
|
140
|
+
setIsEnteredJsonValid(false);
|
141
|
+
}
|
142
|
+
}
|
143
|
+
}, [importJson]);
|
144
|
+
(0, react_2.useEffect)(() => {
|
145
|
+
setIsInProgress(true);
|
146
|
+
loadContentConfig()
|
147
|
+
.then((resp) => {
|
148
|
+
const displayConfig = [];
|
149
|
+
for (let r = 0; r < Object.keys(resp).length; r++) {
|
150
|
+
const item = { collectionName: Object.keys(resp)[r], indexed: [], notIndexed: [] };
|
151
|
+
const collectionName = item.collectionName;
|
152
|
+
for (let k = 0; k < Object.keys(resp[collectionName]).length; k++) {
|
153
|
+
const attribs = resp[collectionName];
|
154
|
+
for (let s = 0; s < Object.keys(attribs).length; s++) {
|
155
|
+
const attrName = Object.keys(attribs)[s];
|
156
|
+
const attr = attribs[attrName];
|
157
|
+
if (attr.index === false && !item.notIndexed.includes(attrName))
|
158
|
+
item.notIndexed.push(attrName);
|
159
|
+
else if (attr.index && !item.indexed.includes(attrName))
|
160
|
+
item.indexed.push(attrName);
|
161
|
+
}
|
162
|
+
}
|
163
|
+
displayConfig.push(item);
|
164
|
+
}
|
165
|
+
setConfig(displayConfig);
|
166
|
+
})
|
167
|
+
.catch((err) => {
|
168
|
+
toggleNotification({
|
169
|
+
type: "warning", message: "An error was encountered while fetching the configuration.", timeout: 5000
|
170
|
+
});
|
171
|
+
console.log(err);
|
172
|
+
})
|
173
|
+
.finally(() => {
|
174
|
+
setIsInProgress(false);
|
175
|
+
});
|
176
|
+
}, []);
|
177
|
+
if (config === null)
|
178
|
+
return react_1.default.createElement(helper_plugin_1.LoadingIndicatorPage, null);
|
179
|
+
else {
|
180
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
181
|
+
react_1.default.createElement(design_system_1.Flex, { alignItems: "stretch", gap: 4 },
|
182
|
+
react_1.default.createElement(SubNavigation_1.SubNavigation, { activeUrl: '/configure-collections/' }),
|
183
|
+
react_1.default.createElement(design_system_1.Box, { padding: 8, background: "neutral100" },
|
184
|
+
react_1.default.createElement(design_system_1.Box, { paddingBottom: 4 },
|
185
|
+
react_1.default.createElement(design_system_3.Typography, { variant: "alpha" }, "Configure Collections")),
|
186
|
+
config && (react_1.default.createElement(design_system_7.TwoColsLayout, { startCol: react_1.default.createElement(design_system_2.Table, { colCount: 4, rowCount: config.length },
|
187
|
+
react_1.default.createElement(design_system_2.Thead, null,
|
188
|
+
react_1.default.createElement(design_system_2.Tr, null,
|
189
|
+
react_1.default.createElement(design_system_2.Th, { style: { width: "250px" } },
|
190
|
+
react_1.default.createElement(design_system_3.Typography, { variant: "sigma" }, "Collection")),
|
191
|
+
react_1.default.createElement(design_system_2.Th, { style: { width: "250px" } },
|
192
|
+
react_1.default.createElement(design_system_3.Typography, { variant: "sigma" }, "Index")),
|
193
|
+
react_1.default.createElement(design_system_2.Th, { style: { width: "250px" } },
|
194
|
+
react_1.default.createElement(design_system_3.Typography, { variant: "sigma" }, "Do not Index")),
|
195
|
+
react_1.default.createElement(design_system_2.Th, null,
|
196
|
+
react_1.default.createElement(design_system_3.Typography, { variant: "sigma" }, "Actions")))),
|
197
|
+
react_1.default.createElement(design_system_2.Tbody, null, config.map((collection, idx) => {
|
198
|
+
return (react_1.default.createElement(design_system_2.Tr, { key: idx },
|
199
|
+
react_1.default.createElement(design_system_2.Td, null,
|
200
|
+
react_1.default.createElement(design_system_3.Typography, { textColor: "neutral600" }, collection.collectionName)),
|
201
|
+
react_1.default.createElement(design_system_2.Td, null, collection.indexed.map((i) => react_1.default.createElement(design_system_1.Box, { paddingBottom: 2 },
|
202
|
+
react_1.default.createElement(design_system_3.Typography, { textColor: "neutral600" }, i)))),
|
203
|
+
react_1.default.createElement(design_system_2.Td, null, collection.notIndexed.map((i) => react_1.default.createElement(design_system_1.Box, { paddingBottom: 2 },
|
204
|
+
react_1.default.createElement(design_system_3.Typography, { textColor: "neutral600" }, i)))),
|
205
|
+
react_1.default.createElement(design_system_2.Td, null,
|
206
|
+
react_1.default.createElement(design_system_4.IconButton, { onClick: () => history.push(`/plugins/${pluginId_1.default}/configure-collections/${collection.collectionName}`), label: "Edit collection configuration", noBorder: true, icon: react_1.default.createElement(icons_1.Pencil, null) }),
|
207
|
+
react_1.default.createElement(design_system_4.IconButton, { onClick: () => scheduleCollectionIndexing(collection.collectionName), label: "Schedule indexing for all items in this collection", noBorder: true, icon: react_1.default.createElement(icons_1.Server, null) }))));
|
208
|
+
}))), endCol: react_1.default.createElement(react_1.default.Fragment, null,
|
209
|
+
react_1.default.createElement(design_system_1.Box, { paddingLeft: 2, paddingRight: 2, paddingTop: 4, paddingBottom: 4 },
|
210
|
+
react_1.default.createElement(design_system_1.Box, { paddingTop: 4, paddingBottom: 4 },
|
211
|
+
react_1.default.createElement(design_system_3.Typography, { variant: "pi", fontWeight: "bold", textColor: "neutral600" }, "CONFIG ACTIONS")),
|
212
|
+
react_1.default.createElement(design_system_7.Divider, null),
|
213
|
+
react_1.default.createElement(design_system_1.Box, { paddingTop: 4, paddingBottom: 4 },
|
214
|
+
react_1.default.createElement(design_system_1.Box, { paddingTop: 2, paddingBottom: 2 },
|
215
|
+
react_1.default.createElement(design_system_5.Button, { loading: isInProgress, fullWidth: true, variant: "secondary", onClick: performExport }, "Export")),
|
216
|
+
react_1.default.createElement(design_system_1.Box, { paddingTop: 2, paddingBottom: 2 },
|
217
|
+
react_1.default.createElement(design_system_5.Button, { loading: isInProgress, fullWidth: true, variant: "secondary", onClick: () => setDisplayImportModal(true) }, "Import"))))) })),
|
218
|
+
displayImportModal &&
|
219
|
+
react_1.default.createElement(design_system_6.ModalLayout, { onClose: () => setDisplayImportModal(false), labelledBy: "title" },
|
220
|
+
react_1.default.createElement(design_system_6.ModalHeader, null,
|
221
|
+
react_1.default.createElement(design_system_3.Typography, { fontWeight: "bold", textColor: "neutral800", as: "h2", id: "title" }, "Import Search Configuration")),
|
222
|
+
react_1.default.createElement(design_system_6.ModalBody, null,
|
223
|
+
react_1.default.createElement(design_system_7.Textarea, { label: "Configuration Json", error: !isEnteredJsonValid ? 'Invalid Json' : undefined, onChange: e => setImportJson(e.target.value) }, importJson)),
|
224
|
+
react_1.default.createElement(design_system_6.ModalFooter, { startActions: react_1.default.createElement(design_system_5.Button, { onClick: () => setDisplayImportModal(false), variant: "tertiary" }, "Cancel"), endActions: react_1.default.createElement(react_1.default.Fragment, null,
|
225
|
+
react_1.default.createElement(design_system_5.Button, { loading: isInProgress, onClick: performImport, disabled: !isEnteredJsonValid && !importJson.length > 0 }, "Import")) }))))));
|
226
|
+
}
|
227
|
+
};
|
228
|
+
exports.default = Configure;
|
@@ -0,0 +1,155 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
19
|
+
var ownKeys = function(o) {
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
21
|
+
var ar = [];
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
23
|
+
return ar;
|
24
|
+
};
|
25
|
+
return ownKeys(o);
|
26
|
+
};
|
27
|
+
return function (mod) {
|
28
|
+
if (mod && mod.__esModule) return mod;
|
29
|
+
var result = {};
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
31
|
+
__setModuleDefault(result, mod);
|
32
|
+
return result;
|
33
|
+
};
|
34
|
+
})();
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
37
|
+
};
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
39
|
+
const react_1 = __importStar(require("react"));
|
40
|
+
const SubNavigation_1 = require("../../components/SubNavigation");
|
41
|
+
;
|
42
|
+
const design_system_1 = require("@strapi/design-system");
|
43
|
+
const design_system_2 = require("@strapi/design-system");
|
44
|
+
const apiUrls_1 = require("../../utils/apiUrls");
|
45
|
+
const axiosInstance_1 = __importDefault(require("../../utils/axiosInstance"));
|
46
|
+
const design_system_3 = require("@strapi/design-system");
|
47
|
+
const design_system_4 = require("@strapi/design-system");
|
48
|
+
const icons_1 = require("@strapi/icons");
|
49
|
+
const design_system_5 = require("@strapi/design-system");
|
50
|
+
const design_system_6 = require("@strapi/design-system");
|
51
|
+
const helper_plugin_1 = require("@strapi/helper-plugin");
|
52
|
+
const loadElasticsearchSetupInfo = () => {
|
53
|
+
return axiosInstance_1.default.get(apiUrls_1.apiGetElasticsearchSetupInfo)
|
54
|
+
.then((resp) => resp.data)
|
55
|
+
.then((data) => {
|
56
|
+
return data;
|
57
|
+
});
|
58
|
+
};
|
59
|
+
const Homepage = () => {
|
60
|
+
const [setupInfo, setSetupInfo] = (0, react_1.useState)(null);
|
61
|
+
const [isInProgress, setIsInProgress] = (0, react_1.useState)(false);
|
62
|
+
const toggleNotification = (0, helper_plugin_1.useNotification)();
|
63
|
+
const displayLabels = { 'connected': 'Connected',
|
64
|
+
'elasticCertificate': 'Certificate',
|
65
|
+
'elasticHost': 'Elasticsearch host',
|
66
|
+
'elasticIndexAlias': 'Elasticsearch index Alias name',
|
67
|
+
'elasticUserName': 'Elasticsearch username',
|
68
|
+
'indexingCronSchedule': 'Indexing cron schedule',
|
69
|
+
'initialized': 'Elasticsearch configuration loaded' };
|
70
|
+
const reloadElasticsearchSetupInfo = ({ showNotification }) => {
|
71
|
+
setIsInProgress(true);
|
72
|
+
loadElasticsearchSetupInfo()
|
73
|
+
.then(setSetupInfo)
|
74
|
+
.then(() => {
|
75
|
+
if (showNotification)
|
76
|
+
toggleNotification({
|
77
|
+
type: "success", message: "Elasticsearch setup information reloaded.", timeout: 5000
|
78
|
+
});
|
79
|
+
})
|
80
|
+
.finally(() => setIsInProgress(false));
|
81
|
+
};
|
82
|
+
const requestFullSiteReindexing = () => {
|
83
|
+
setIsInProgress(true);
|
84
|
+
return axiosInstance_1.default.get(apiUrls_1.apiRequestReIndexing)
|
85
|
+
.then(() => {
|
86
|
+
toggleNotification({
|
87
|
+
type: "success", message: "Rebuilding the index is triggered.", timeout: 5000
|
88
|
+
});
|
89
|
+
})
|
90
|
+
.catch(() => {
|
91
|
+
toggleNotification({
|
92
|
+
type: "warning", message: "An error was encountered.", timeout: 5000
|
93
|
+
});
|
94
|
+
})
|
95
|
+
.finally(() => setIsInProgress(false));
|
96
|
+
};
|
97
|
+
const triggerIndexingRun = () => {
|
98
|
+
setIsInProgress(true);
|
99
|
+
return axiosInstance_1.default.get(apiUrls_1.apiTriggerIndexing)
|
100
|
+
.then(() => {
|
101
|
+
toggleNotification({
|
102
|
+
type: "success", message: "The indexing job to process the pending tasks is started.", timeout: 5000
|
103
|
+
});
|
104
|
+
})
|
105
|
+
.catch(() => {
|
106
|
+
toggleNotification({
|
107
|
+
type: "warning", message: "An error was encountered.", timeout: 5000
|
108
|
+
});
|
109
|
+
})
|
110
|
+
.finally(() => setIsInProgress(false));
|
111
|
+
};
|
112
|
+
(0, react_1.useEffect)(() => {
|
113
|
+
reloadElasticsearchSetupInfo({ showNotification: false });
|
114
|
+
}, []);
|
115
|
+
if (setupInfo === null)
|
116
|
+
return react_1.default.createElement(helper_plugin_1.LoadingIndicatorPage, null);
|
117
|
+
else
|
118
|
+
return (react_1.default.createElement(design_system_1.Flex, { alignItems: "stretch", gap: 4 },
|
119
|
+
react_1.default.createElement(SubNavigation_1.SubNavigation, null),
|
120
|
+
react_1.default.createElement(design_system_1.Box, { padding: 8, background: "neutral100", width: "100%" },
|
121
|
+
react_1.default.createElement(design_system_1.Box, { paddingBottom: 4 },
|
122
|
+
react_1.default.createElement(design_system_2.Typography, { variant: "alpha" }, "Setup Information")),
|
123
|
+
react_1.default.createElement(design_system_1.Box, { width: "100%", paddingBottom: 4 },
|
124
|
+
react_1.default.createElement(design_system_5.TwoColsLayout, { startCol: react_1.default.createElement(react_1.default.Fragment, null,
|
125
|
+
react_1.default.createElement(design_system_4.Table, null, setupInfo && (Object.keys(setupInfo).map((k, idx) => {
|
126
|
+
return (react_1.default.createElement(design_system_4.Tr, { key: idx },
|
127
|
+
react_1.default.createElement(design_system_4.Td, null,
|
128
|
+
react_1.default.createElement(design_system_1.Box, { padding: 2 },
|
129
|
+
react_1.default.createElement(design_system_2.Typography, { textColor: "neutral600" },
|
130
|
+
displayLabels[k],
|
131
|
+
" :"))),
|
132
|
+
react_1.default.createElement(design_system_4.Td, null,
|
133
|
+
react_1.default.createElement(design_system_1.Box, { padding: 2 },
|
134
|
+
react_1.default.createElement(design_system_6.Grid, null,
|
135
|
+
react_1.default.createElement(design_system_6.GridItem, { padding: 2 },
|
136
|
+
k === 'connected' && setupInfo[k] === true &&
|
137
|
+
(react_1.default.createElement(design_system_2.Typography, { fontWeight: "bold", textColor: "success500" }, "Yes")),
|
138
|
+
k === 'connected' && setupInfo[k] === false &&
|
139
|
+
(react_1.default.createElement(design_system_2.Typography, { fontWeight: "bold", textColor: "danger500" }, "No")),
|
140
|
+
k !== 'connected' &&
|
141
|
+
(react_1.default.createElement(design_system_2.Typography, { textColor: "neutral600" }, String(setupInfo[k])))),
|
142
|
+
react_1.default.createElement(design_system_6.GridItem, { padding: 1 }, k === 'connected' ?
|
143
|
+
react_1.default.createElement(design_system_3.IconButton, { disabled: isInProgress, onClick: () => reloadElasticsearchSetupInfo({ showNotification: true }), label: "Refresh", icon: react_1.default.createElement(icons_1.Refresh, null) }) : null))))));
|
144
|
+
})))), endCol: react_1.default.createElement(react_1.default.Fragment, null,
|
145
|
+
react_1.default.createElement(design_system_1.Box, { paddingLeft: 2, paddingRight: 2, paddingTop: 4, paddingBottom: 4 },
|
146
|
+
react_1.default.createElement(design_system_1.Box, { paddingTop: 4, paddingBottom: 4 },
|
147
|
+
react_1.default.createElement(design_system_2.Typography, { variant: "pi", fontWeight: "bold", textColor: "neutral600" }, "ACTIONS")),
|
148
|
+
react_1.default.createElement(design_system_6.Divider, null),
|
149
|
+
react_1.default.createElement(design_system_1.Box, { paddingTop: 4, paddingBottom: 4 },
|
150
|
+
react_1.default.createElement(design_system_1.Box, { paddingTop: 2, paddingBottom: 2 },
|
151
|
+
react_1.default.createElement(design_system_5.Button, { loading: isInProgress, fullWidth: true, variant: "secondary", onClick: requestFullSiteReindexing }, "Rebuild Index")),
|
152
|
+
react_1.default.createElement(design_system_1.Box, { paddingTop: 2, paddingBottom: 2 },
|
153
|
+
react_1.default.createElement(design_system_5.Button, { loading: isInProgress, fullWidth: true, variant: "secondary", onClick: triggerIndexingRun }, "Trigger Indexing"))))) })))));
|
154
|
+
};
|
155
|
+
exports.default = Homepage;
|
@@ -0,0 +1,125 @@
|
|
1
|
+
"use strict";
|
2
|
+
/*
|
3
|
+
*
|
4
|
+
* HomePage
|
5
|
+
*
|
6
|
+
*/
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
8
|
+
if (k2 === undefined) k2 = k;
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
12
|
+
}
|
13
|
+
Object.defineProperty(o, k2, desc);
|
14
|
+
}) : (function(o, m, k, k2) {
|
15
|
+
if (k2 === undefined) k2 = k;
|
16
|
+
o[k2] = m[k];
|
17
|
+
}));
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
20
|
+
}) : function(o, v) {
|
21
|
+
o["default"] = v;
|
22
|
+
});
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
24
|
+
var ownKeys = function(o) {
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
26
|
+
var ar = [];
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
28
|
+
return ar;
|
29
|
+
};
|
30
|
+
return ownKeys(o);
|
31
|
+
};
|
32
|
+
return function (mod) {
|
33
|
+
if (mod && mod.__esModule) return mod;
|
34
|
+
var result = {};
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
36
|
+
__setModuleDefault(result, mod);
|
37
|
+
return result;
|
38
|
+
};
|
39
|
+
})();
|
40
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
41
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
42
|
+
};
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
44
|
+
const react_1 = __importStar(require("react"));
|
45
|
+
const SubNavigation_1 = require("../../components/SubNavigation");
|
46
|
+
;
|
47
|
+
const design_system_1 = require("@strapi/design-system");
|
48
|
+
const apiUrls_1 = require("../../utils/apiUrls");
|
49
|
+
const axiosInstance_1 = __importDefault(require("../../utils/axiosInstance"));
|
50
|
+
const design_system_2 = require("@strapi/design-system");
|
51
|
+
const design_system_3 = require("@strapi/design-system");
|
52
|
+
const helper_plugin_1 = require("@strapi/helper-plugin");
|
53
|
+
const loadRecentIndexingRuns = () => {
|
54
|
+
return axiosInstance_1.default.get(apiUrls_1.apiFetchRecentIndexingRunLog)
|
55
|
+
.then((resp) => resp.data)
|
56
|
+
.then((data) => {
|
57
|
+
return data;
|
58
|
+
});
|
59
|
+
};
|
60
|
+
const formattedDate = (dateString) => {
|
61
|
+
const date = new Date(dateString);
|
62
|
+
const options = {
|
63
|
+
weekday: 'long',
|
64
|
+
year: 'numeric',
|
65
|
+
month: 'numeric',
|
66
|
+
day: 'numeric',
|
67
|
+
hour: 'numeric',
|
68
|
+
minute: 'numeric',
|
69
|
+
};
|
70
|
+
const dateTimeFormat = new Intl.DateTimeFormat('en-US', options);
|
71
|
+
const parts = dateTimeFormat.formatToParts(date);
|
72
|
+
let formattedDate = '';
|
73
|
+
parts.forEach((part) => {
|
74
|
+
if (part.type === "weekday")
|
75
|
+
formattedDate += `${part.value}, `;
|
76
|
+
if (part.type === "day")
|
77
|
+
formattedDate += `${part.value}/`;
|
78
|
+
if (part.type === "month")
|
79
|
+
formattedDate += `${part.value}/`;
|
80
|
+
if (part.type === "year")
|
81
|
+
formattedDate += `${part.value} `;
|
82
|
+
if (part.type === "hour")
|
83
|
+
formattedDate += `${part.value}:`;
|
84
|
+
if (part.type === "minute")
|
85
|
+
formattedDate += `${part.value}`;
|
86
|
+
});
|
87
|
+
return formattedDate;
|
88
|
+
};
|
89
|
+
const ViewIndexingRunLog = () => {
|
90
|
+
const [logTable, setLogTable] = (0, react_1.useState)(null);
|
91
|
+
(0, react_1.useEffect)(() => {
|
92
|
+
loadRecentIndexingRuns()
|
93
|
+
.then(setLogTable);
|
94
|
+
}, []);
|
95
|
+
if (logTable === null)
|
96
|
+
return react_1.default.createElement(helper_plugin_1.LoadingIndicatorPage, null);
|
97
|
+
else
|
98
|
+
return (react_1.default.createElement(design_system_1.Flex, { alignItems: "stretch", gap: 4 },
|
99
|
+
react_1.default.createElement(SubNavigation_1.SubNavigation, null),
|
100
|
+
react_1.default.createElement(design_system_1.Box, { padding: 8, background: "neutral100", width: "100%" },
|
101
|
+
react_1.default.createElement(design_system_1.Box, { paddingBottom: 4 },
|
102
|
+
react_1.default.createElement(design_system_3.Typography, { variant: "alpha" }, "Recent Indexing Run Logs")),
|
103
|
+
logTable && logTable.length > 0 && (react_1.default.createElement(react_1.default.Fragment, null,
|
104
|
+
react_1.default.createElement(design_system_2.Table, { colCount: 3, rowCount: logTable.length },
|
105
|
+
react_1.default.createElement(design_system_2.Thead, null,
|
106
|
+
react_1.default.createElement(design_system_2.Tr, null,
|
107
|
+
react_1.default.createElement(design_system_2.Th, null,
|
108
|
+
react_1.default.createElement(design_system_3.Typography, { variant: "sigma" }, "Date")),
|
109
|
+
react_1.default.createElement(design_system_2.Th, null,
|
110
|
+
react_1.default.createElement(design_system_3.Typography, { variant: "sigma" }, "Status")),
|
111
|
+
react_1.default.createElement(design_system_2.Th, null,
|
112
|
+
react_1.default.createElement(design_system_3.Typography, { variant: "sigma" }, "Details")))),
|
113
|
+
react_1.default.createElement(design_system_2.Tbody, null, logTable.map((data, index) => {
|
114
|
+
return (react_1.default.createElement(design_system_2.Tr, { key: index },
|
115
|
+
react_1.default.createElement(design_system_2.Td, null,
|
116
|
+
react_1.default.createElement(design_system_3.Typography, { textColor: "neutral600" }, formattedDate(data.createdAt))),
|
117
|
+
react_1.default.createElement(design_system_2.Td, null,
|
118
|
+
react_1.default.createElement(design_system_3.Typography, { textColor: "neutral600" }, data.status)),
|
119
|
+
react_1.default.createElement(design_system_2.Td, null,
|
120
|
+
react_1.default.createElement(design_system_3.Typography, { textColor: "neutral600" }, data.details))));
|
121
|
+
}))),
|
122
|
+
react_1.default.createElement(design_system_1.Box, { paddingTop: 2, paddingBottom: 2 },
|
123
|
+
react_1.default.createElement(design_system_3.Typography, { textColor: "neutral600" }, "This view lists the details of the 50 recent-most indexing runs.")))))));
|
124
|
+
};
|
125
|
+
exports.default = ViewIndexingRunLog;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const package_json_1 = __importDefault(require("../../package.json"));
|
7
|
+
const pluginId = package_json_1.default.strapi.name;
|
8
|
+
exports.default = pluginId;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
export declare const apiGetContentConfig: string;
|
2
|
+
export declare const apiGetCollectionConfig: (collectionName: any) => string;
|
3
|
+
export declare const apiSaveCollectionConfig: (collectionName: any) => string;
|
4
|
+
export declare const apiGetElasticsearchSetupInfo: string;
|
5
|
+
export declare const apiFetchRecentIndexingRunLog: string;
|
6
|
+
export declare const apiRequestReIndexing: string;
|
7
|
+
export declare const apiRequestCollectionIndexing: (collectionName: any) => string;
|
8
|
+
export declare const apiTriggerIndexing: string;
|
9
|
+
export declare const apiExportContentConfig: string;
|
10
|
+
export declare const apiImportContentConfig: string;
|
@@ -0,0 +1,20 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.apiImportContentConfig = exports.apiExportContentConfig = exports.apiTriggerIndexing = exports.apiRequestCollectionIndexing = exports.apiRequestReIndexing = exports.apiFetchRecentIndexingRunLog = exports.apiGetElasticsearchSetupInfo = exports.apiSaveCollectionConfig = exports.apiGetCollectionConfig = exports.apiGetContentConfig = void 0;
|
7
|
+
const pluginId_1 = __importDefault(require("../pluginId"));
|
8
|
+
exports.apiGetContentConfig = `/${pluginId_1.default}/content-config/`;
|
9
|
+
const apiGetCollectionConfig = (collectionName) => `/${pluginId_1.default}/collection-config/${collectionName}`;
|
10
|
+
exports.apiGetCollectionConfig = apiGetCollectionConfig;
|
11
|
+
const apiSaveCollectionConfig = (collectionName) => `/${pluginId_1.default}/collection-config/${collectionName}`;
|
12
|
+
exports.apiSaveCollectionConfig = apiSaveCollectionConfig;
|
13
|
+
exports.apiGetElasticsearchSetupInfo = `/${pluginId_1.default}/setup-info`;
|
14
|
+
exports.apiFetchRecentIndexingRunLog = `/${pluginId_1.default}/indexing-run-log`;
|
15
|
+
exports.apiRequestReIndexing = `/${pluginId_1.default}/reindex`;
|
16
|
+
const apiRequestCollectionIndexing = (collectionName) => `/${pluginId_1.default}/collection-reindex/${collectionName}`;
|
17
|
+
exports.apiRequestCollectionIndexing = apiRequestCollectionIndexing;
|
18
|
+
exports.apiTriggerIndexing = `/${pluginId_1.default}/trigger-indexing/`;
|
19
|
+
exports.apiExportContentConfig = `/${pluginId_1.default}/export-content-config/`;
|
20
|
+
exports.apiImportContentConfig = `/${pluginId_1.default}/import-content-config/`;
|
@@ -0,0 +1,33 @@
|
|
1
|
+
"use strict";
|
2
|
+
/**
|
3
|
+
* axios with a custom config.
|
4
|
+
*/
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
7
|
+
};
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
9
|
+
const axios_1 = __importDefault(require("axios"));
|
10
|
+
const helper_plugin_1 = require("@strapi/helper-plugin");
|
11
|
+
const instance = axios_1.default.create({
|
12
|
+
baseURL: process.env.STRAPI_ADMIN_BACKEND_URL,
|
13
|
+
});
|
14
|
+
instance.interceptors.request.use(async (config) => {
|
15
|
+
config.headers = {
|
16
|
+
Authorization: `Bearer ${helper_plugin_1.auth.getToken()}`,
|
17
|
+
Accept: 'application/json',
|
18
|
+
'Content-Type': 'application/json',
|
19
|
+
};
|
20
|
+
return config;
|
21
|
+
}, error => {
|
22
|
+
Promise.reject(error);
|
23
|
+
});
|
24
|
+
instance.interceptors.response.use(response => response, error => {
|
25
|
+
var _a;
|
26
|
+
// whatever you want to do with the error
|
27
|
+
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
|
28
|
+
helper_plugin_1.auth.clearAppStorage();
|
29
|
+
window.location.reload();
|
30
|
+
}
|
31
|
+
throw error;
|
32
|
+
});
|
33
|
+
exports.default = instance;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const pluginId_1 = __importDefault(require("../pluginId"));
|
7
|
+
const getTrad = (id) => `${pluginId_1.default}.${id}`;
|
8
|
+
exports.default = getTrad;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vegan-friendly/strapi-plugin-elasticsearch",
|
3
|
-
"version": "0.1.0-alpha.
|
3
|
+
"version": "0.1.0-alpha.3",
|
4
4
|
"description": "A Strapi plugin to enable using Elasticsearch with Strapi CMS.",
|
5
5
|
"homepage": "https://github.com/vegan-friendly/strapi-plugin-elasticsearch",
|
6
6
|
"strapi": {
|