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

View File

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

View File

@@ -25,6 +25,7 @@ interface IComicBookLibraryProps {
export const Library = (data: IComicBookLibraryProps): ReactElement => { export const Library = (data: IComicBookLibraryProps): ReactElement => {
const { searchResults } = data.data; const { searchResults } = data.data;
console.log(searchResults);
// programatically navigate to comic detail // programatically navigate to comic detail
const navigate = useNavigate(); const navigate = useNavigate();
const navigateToComicDetail = (row) => { const navigateToComicDetail = (row) => {
@@ -183,7 +184,6 @@ export const Library = (data: IComicBookLibraryProps): ReactElement => {
), ),
); );
}, []); }, []);
return ( return (
<section className="container"> <section className="container">
<div className="section"> <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 React, { ReactElement, useEffect } from "react";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { searchIssue } from "../../actions/fileops.actions"; import { searchIssue } from "../../actions/fileops.actions";
@@ -25,11 +25,38 @@ const LibraryContainer = () => {
const searchResults = useSelector( const searchResults = useSelector(
(state: RootState) => state.fileOps.librarySearchResults, (state: RootState) => state.fileOps.librarySearchResults,
); );
const searchError = useSelector(
(state: RootState) => state.fileOps.librarySearchError,
);
console.log(searchError);
return !isEmpty(searchResults) ? ( return !isEmpty(searchResults) ? (
<Library data={{ 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"> <article className="message is-danger">
<div className="message-body is-size-6 is-family-secondary"> <div className="message-body is-size-6 is-family-secondary">
Flushing and resetting will clear out: Flushing and resetting will clear out:
<p>
<small>(This action is irreversible)</small>
</p>
<ol> <ol>
<li>The mongo collection that holds library metadata</li> <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>covers</code>, <code>temporary</code> and
<code>expanded</code> subfolders. <code>expanded</code> subfolders.
</li> </li>
<li>
Your <code>Elasticsearch indices</code>
</li>
</ol> </ol>
</div> </div>
</article> </article>

View File

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