Skip to content

Commit 0761e29

Browse files
committed
align UI to execute admin changes
1 parent 7501c89 commit 0761e29

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

src/client/src/pages/Admin.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ const styles = theme => ({
3030
});
3131

3232

33+
const executing = "executing"
34+
3335
class Admin extends Component {
3436
constructor(props) {
3537
super(props);
@@ -86,22 +88,21 @@ class Admin extends Component {
8688
this.setState({isLoading: false});
8789
};
8890

89-
handleExecute(event) {
91+
async handleExecute(event) {
9092
event.preventDefault();
9193

9294
this.setState({isLoading: true});
93-
fetch('/api/execute');
9495

95-
setTimeout(() => {
96-
this.refreshPage();
97-
}, 1500);
96+
await fetch('/api/execute');
97+
98+
this.refreshPage();
9899
}
99100

100101
async handleGetStatistics() {
101102
const statsData = await fetch("/api/statistics");
102-
const statsResponse = await statsData.json();
103+
const statsResponse = await statsData.json()
103104

104-
if (statsResponse !== 'Running') {
105+
if (statsResponse !== 'executing') {
105106
this.setState({
106107
statistics: _.toPairsIn(statsResponse.stats),
107108
lastExecution: statsResponse.executionTime

src/server/api/admin_api.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
from sqlalchemy.sql import text
77

88
from sqlalchemy.dialects.postgresql import insert
9-
from sqlalchemy import Table, MetaData
9+
from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey, exc, select
1010
from pipeline import flow_script
1111
from config import engine
12-
from flask import request, redirect, jsonify, current_app
12+
from flask import request, redirect, jsonify, current_app, abort
1313
from api.file_uploader import validate_and_arrange_upload
1414
from config import (
1515
RAW_DATA_PATH,
16-
CURRENT_SOURCE_FILES_PATH
16+
CURRENT_SOURCE_FILES_PATH,
17+
LOGS_PATH,
1718
)
1819

1920
ALLOWED_EXTENSIONS = {"csv", "xlsx"}
@@ -30,9 +31,8 @@ def __allowed_file(filename):
3031
# file upload tutorial
3132
@admin_api.route("/api/file", methods=["POST"])
3233
def uploadCSV():
33-
current_app.logger.info("Uploading CSV")
3434
if "file" not in request.files:
35-
return jsonify({"error": "no file supplied"});
35+
return redirect(request.url)
3636

3737
for file in request.files.getlist("file"):
3838
if __allowed_file(file.filename):
@@ -119,10 +119,8 @@ def list_statistics():
119119
with engine.connect() as connection:
120120
s = text("select valcol from kv_unique where keycol = 'last_execution_time';")
121121
result = connection.execute(s)
122+
last_execution_details = result.fetchone()[0]
122123

123-
fetch_result = result.fetchone()
124-
if fetch_result:
125-
last_execution_details = result.fetchone()[0]
126124

127125
except Exception as e:
128126
current_app.logger.error("Failure reading Last Execution stats from DB")

0 commit comments

Comments
 (0)