🤯 Added ES index delete option in the UI

This commit is contained in:
2022-04-04 22:57:02 -07:00
parent ff47e3d590
commit 89ca89752c
6 changed files with 60 additions and 10 deletions

View File

@@ -29,6 +29,7 @@ import {
FILEOPS_STATE_RESET,
LS_IMPORT_CALL_IN_PROGRESS,
LS_TOGGLE_IMPORT_QUEUE,
SS_SEARCH_FAILED,
} from "../constants/action-types";
import { success } from "react-notification-system-redux";
import { isNil, map } from "lodash";
@@ -288,6 +289,13 @@ export const searchIssue = (query, options) => async (dispatch) => {
method: "POST",
data: { ...query, ...options },
});
if (response.data.code === 404) {
dispatch({
type: SS_SEARCH_FAILED,
data: response.data,
});
}
dispatch({
type: SS_SEARCH_RESULTS_FETCHED,
data: response.data.body,

View File

@@ -69,7 +69,7 @@ pre {
.volumes-container {
.stack {
display: inline-block;
border-radius: 0.3rem;
border-radius: 0.5rem;
box-shadow:
/* The top layer shadow */ 0 -1px 1px rgba(0, 0, 0, 0.15),
/* The second layer */ 0 -10px 0 -5px #eee,
@@ -78,8 +78,8 @@ pre {
/* The third layer shadow */ 0 -20px 1px -9px rgba(0, 0, 0, 0.15);
img {
height: auto;
border-top-left-radius: 0.3rem;
border-top-right-radius: 0.3rem;
border-top-left-radius: 0.5rem;
border-top-right-radius: 0.5rem;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
@@ -160,8 +160,8 @@ pre {
figure {
display: flex;
img {
border-top-left-radius: 0.3rem;
border-top-right-radius: 0.3rem;
border-top-left-radius: 0.4rem;
border-top-right-radius: 0.4rem;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
@@ -171,7 +171,7 @@ pre {
figure {
display: flex;
img {
border-radius: 0.3rem;
border-radius: 0.4rem;
}
}
}

View File

@@ -25,6 +25,7 @@ interface IComicBookLibraryProps {
export const Library = (data: IComicBookLibraryProps): ReactElement => {
const { searchResults } = data.data;
console.log(searchResults);
// programatically navigate to comic detail
const navigate = useNavigate();
const navigateToComicDetail = (row) => {
@@ -183,7 +184,6 @@ export const Library = (data: IComicBookLibraryProps): ReactElement => {
),
);
}, []);
return (
<section className="container">
<div className="section">

View File

@@ -1,4 +1,4 @@
import { isEmpty } from "lodash";
import { isEmpty, isUndefined } from "lodash";
import React, { ReactElement, useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
import { searchIssue } from "../../actions/fileops.actions";
@@ -25,11 +25,38 @@ const LibraryContainer = () => {
const searchResults = useSelector(
(state: RootState) => state.fileOps.librarySearchResults,
);
const searchError = useSelector(
(state: RootState) => state.fileOps.librarySearchError,
);
console.log(searchError);
return !isEmpty(searchResults) ? (
<Library data={{ searchResults }} />
) : (
"No data found."
<div className="container">
<section className="section is-small">
<div className="columns">
<div className="column is-two-thirds">
<article className="message is-link">
<div className="message-body">
No comics were found in the library, Elasticsearch reports no
indices. Try importing a few comics into the library and come
back.
</div>
</article>
<pre>
{!isUndefined(searchError.data) &&
JSON.stringify(
searchError.data.meta.body.error.root_cause,
null,
4,
)}
</pre>
</div>
</div>
</section>
</div>
);
};

View File

@@ -23,6 +23,9 @@ export const SystemSettingsForm = (settingsObject): ReactElement => {
<article className="message is-danger">
<div className="message-body is-size-6 is-family-secondary">
Flushing and resetting will clear out:
<p>
<small>(This action is irreversible)</small>
</p>
<ol>
<li>The mongo collection that holds library metadata</li>
@@ -31,6 +34,9 @@ export const SystemSettingsForm = (settingsObject): ReactElement => {
<code>covers</code>, <code>temporary</code> and
<code>expanded</code> subfolders.
</li>
<li>
Your <code>Elasticsearch indices</code>
</li>
</ol>
</div>
</article>

View File

@@ -23,6 +23,7 @@ import {
SS_SEARCH_IN_PROGRESS,
FILEOPS_STATE_RESET,
LS_IMPORT_CALL_IN_PROGRESS,
SS_SEARCH_FAILED,
} from "../constants/action-types";
const initialState = {
IMSCallInProgress: false,
@@ -41,6 +42,7 @@ const initialState = {
wantedComics: [],
librarySearchResultCount: 0,
libraryQueueResults: [],
librarySearchError: {},
};
function fileOpsReducer(state = initialState, action) {
@@ -181,13 +183,20 @@ function fileOpsReducer(state = initialState, action) {
}
case SS_SEARCH_RESULTS_FETCHED: {
console.log(action.data);
return {
...state,
librarySearchResults: action.data,
SSCallInProgress: false,
};
}
case SS_SEARCH_FAILED: {
console.log(action.data);
return {
...state,
librarySearchError: action.data,
SSCallInProgress: false,
};
}
case FILEOPS_STATE_RESET: {
return {