Adding admin toolbar to refresh ES seed data within UI
This commit is contained in:
parent
9f71e388ce
commit
1613101594
|
@ -8,10 +8,6 @@ import setup
|
|||
|
||||
sys.path.insert(0,'..')
|
||||
|
||||
# TODO: Figure out which dependency tries to encode input to ascii
|
||||
reload(sys)
|
||||
sys.setdefaultencoding("utf-8")
|
||||
|
||||
if config.ENVIRONMENT == 'local':
|
||||
es = Elasticsearch(config.ELASTICSEARCH_LOCAL_HOST)
|
||||
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
from flask import Blueprint, render_template, abort, redirect
|
||||
import os
|
||||
import json
|
||||
|
||||
import config
|
||||
|
||||
joyce = Blueprint('joyce', __name__)
|
||||
|
||||
manifest_path = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, config.MANIFEST_PATH))
|
||||
with joyce.open_resource(manifest_path, 'r') as assets_json:
|
||||
assets = json.load(assets_json)
|
||||
|
||||
@joyce.route('/', defaults={'path': ''})
|
||||
@joyce.route('/<path:path>')
|
||||
def show_joyce(path):
|
||||
return render_template('joyce.html', assets=assets)
|
||||
with joyce.open_resource(manifest_path, 'r') as assets_json:
|
||||
assets = json.load(assets_json)
|
||||
print(assets['joyce.js'])
|
||||
return render_template('joyce.html', assets=assets)
|
|
@ -12,6 +12,7 @@ import 'bootstrap'
|
|||
import Navbar from './components/navbar'
|
||||
import reduceJoyce from './reducers/reduceJoyce'
|
||||
import actions from './actions'
|
||||
import api from './modules/api'
|
||||
import { logger, joyceAPI, joyceInterface, joyceRouter } from './middleware/'
|
||||
import ReaderPageContainer from './containers/readerPageContainer'
|
||||
import EditorPageContainer from './containers/editorPageContainer'
|
||||
|
@ -22,7 +23,12 @@ const router = routerMiddleware(history)
|
|||
const store = createStore(reduceJoyce,
|
||||
applyMiddleware(logger, router, joyceAPI, joyceInterface, joyceRouter))
|
||||
const state = store.getState()
|
||||
// TODO: Modal container should probably be connected to Redux if possible
|
||||
|
||||
const refreshElasticsearch = () => {
|
||||
api.HTTPGetRefreshList().then(response =>
|
||||
location.reload()
|
||||
)
|
||||
}
|
||||
|
||||
store.dispatch(actions.getDocumentList({docType: 'chapters'}))
|
||||
store.dispatch(actions.getDocumentList({docType: 'notes'}))
|
||||
|
@ -32,6 +38,7 @@ ReactDOM.render(
|
|||
<Provider store={store}>
|
||||
<ConnectedRouter history={history}>
|
||||
<div>
|
||||
<div id='admin_toolbar'><button type='button' className='btn btn-sm btn-outline-primary' onClick={refreshElasticsearch}>Refresh</button></div>
|
||||
<Navbar />
|
||||
<Switch>
|
||||
<Route exact path='/' render={() =>
|
||||
|
|
|
@ -38,7 +38,14 @@ const api = {
|
|||
return {status: 'success', data: res.data}
|
||||
}).catch(error => {
|
||||
return {status: 'error', data: res.data}
|
||||
})
|
||||
}),
|
||||
HTTPGetRefreshList: (docType) =>
|
||||
axios.get(apiRoute + 'refresh/').then(res => {
|
||||
return {status: 'success', data: res.data}
|
||||
}).catch(error => {
|
||||
console.log(error)
|
||||
return {status: 'error', data: error}
|
||||
}),
|
||||
}
|
||||
|
||||
export default api
|
|
@ -0,0 +1,5 @@
|
|||
@import "variables";
|
||||
|
||||
#admin_toolbar {
|
||||
padding: .3rem;
|
||||
}
|
|
@ -6,6 +6,7 @@
|
|||
@import "texteditor";
|
||||
@import "button";
|
||||
@import "modal";
|
||||
@import "dev";
|
||||
@import "node_modules/bootstrap/scss/bootstrap";
|
||||
|
||||
$fa-font-path: "../../node_modules/font-awesome/fonts";
|
||||
|
|
Loading…
Reference in New Issue