Skip to content

Commit

Permalink
everything works, implement security and make the app installble next
Browse files Browse the repository at this point in the history
  • Loading branch information
Nickbahson committed Mar 22, 2021
1 parent 7f09b37 commit 670fbbf
Show file tree
Hide file tree
Showing 38 changed files with 403 additions and 295 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/node_modules
/.idea
/engine/.idea
/engine/.idea
debug.log
yarn-error.log
/engine/db_id/.idea
/engine/db_id/ex
19 changes: 19 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
###This is a react app
To get started the easy way see the read me at `/engine/` folder.
To continue and start both react and flask app, read along.

* Run `yarn install` to install the app dependencies.
* Run `yarn start` to run the dev server at `http://localhost:8080` or
`yarn build` to build a production bundle at `/engine/db_id/static/libs/build/`

NB:: if you start the dev server without first starting the flask app, you wil get
a blank page, see step one above

From the app page you can search for titles and get a list with ids (unique)
of all items that match the search term.
You can also edit/update items on this dashboard.

![reactapp](react_app.PNG)

Below app at `/engine/`
![flaskapp](engine/flask_app.PNG)
1 change: 1 addition & 0 deletions debug.log
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
[1017/185010.682:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
[1018/155515.286:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
[1018/221144.916:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
[1129/111314.274:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
2 changes: 1 addition & 1 deletion engine/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ flask-msearch = "*"
flask-cors = "*"

[requires]
python_version = "3.7"
python_version = "3.9"
28 changes: 14 additions & 14 deletions engine/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions engine/README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
* Install all the app dependencies as defined in the Pipfile in the root of
this dir.

* Run `python eng.py` to start the app at `http://127.0.0.1:5000/`

From the app page you can search for titles and get a list with ids (unique)
of all items that match the search term.

You can also edit/update, add new items on this dashboard.
//TODO:: features/security
![flaskapp](flask_app.PNG)
Binary file modified engine/app_data.db
Binary file not shown.
Empty file removed engine/company_data.db
Empty file.
1 change: 1 addition & 0 deletions engine/db_id/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def create_app(config_class=Config):
#search.init_app(app)

#Cors support
# TODO:: do better
ORIGINS = [
'http://localhost:8080', # React
'http://127.0.0.1:8080', # React
Expand Down
7 changes: 0 additions & 7 deletions engine/db_id/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,9 @@
class Config:
basedir = os.path.abspath(os.path.dirname(__file__))
db_path = os.path.join(os.path.dirname(__file__), '../app_data.db')
company_data_db_path = os.path.join(os.path.dirname(__file__), '../company_data.db')
test_data_db_path = os.path.join(os.path.dirname(__file__), '../test_data.db')
search = os.path.join(os.path.dirname(__file__), '../searchdata.db')
db_uri = 'sqlite:///{}'.format(db_path)
SECRET_KEY = '8c354020b6123bc8a8ffdeba488ae749'
SQLALCHEMY_DATABASE_URI = db_uri # specify any other
SQLALCHEMY_BINDS = {
'company_data': 'sqlite:///{}'.format(company_data_db_path),
'test_data': 'sqlite:///{}'.format(test_data_db_path)
}
SQLALCHEMY_TRACK_MODIFICATIONS = True #for full text search changes

# flask-msearch will use table name as elasticsearch index name unless set __msearch_index__
Expand Down
24 changes: 3 additions & 21 deletions engine/db_id/items/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,35 +112,17 @@ def api_search_results():
data = json.loads(request.data)
search_value = "%{}%".format(data.get('text'))
page = data.get('page')
print(page)
print(page)
print(page)
print(page)
print(page)
print(page)
print(page)
print(page)
print(page)
print(page)
print(page)
print(page)
print(page)
print(page)
print(page)
print(page)
results = Item.query.order_by(Item.updated_on.desc()).filter(Item.title.like(search_value)).paginate(per_page=50, page=page)
items_pp: int = 50
results = Item.query.order_by(Item.id.asc()).filter(Item.title.like(search_value)).paginate(per_page=items_pp, page=page)
result = items_schema.dump(results.items)

item_l = {
'page': results.per_page,
'pages': list(results.iter_pages()),
'pages': list(results.iter_pages(left_edge=1, right_edge=1, left_current=1, right_current=2)),
'items': result,
'items_pp': results.per_page
}

response = jsonify(item_l)
print(response)


response.headers.add('Access-Control-Allow-Origin', '*')
return response
44 changes: 44 additions & 0 deletions engine/db_id/static/libs/build/create_item_form.bundle.js

Large diffs are not rendered by default.

32 changes: 27 additions & 5 deletions engine/db_id/static/libs/build/home_search.bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion engine/db_id/static/libs/build/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>Document</title><link href="main.css" rel="stylesheet"></head><body class="container"><p><a class="btn btn-primary" data-toggle="collapse" href="#multiCollapseExample1" role="button" aria-expanded="false" aria-controls="multiCollapseExample1">Toggle first element</a> <button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#multiCollapseExample2" aria-expanded="false" aria-controls="multiCollapseExample2">Toggle second element</button> <button class="btn btn-primary" type="button" data-toggle="collapse" data-target=".multi-collapse" aria-expanded="false" aria-controls="multiCollapseExample1 multiCollapseExample2">Toggle both elements</button></p><div class="row"><div class="col"><div class="collapse multi-collapse" id="multiCollapseExample1"><div class="card card-body">Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.</div></div></div><div class="col"><div class="collapse multi-collapse" id="multiCollapseExample2"><div class="card card-body">Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.</div></div></div></div><div id="home_search"><h2>Loading data...............</h2></div><script src="main.bundle.js"></script><script src="vendor.bundle.js"></script><script src="home_search.bundle.js"></script></body></html>
<!doctype html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>Document</title><link href="main.css" rel="stylesheet"></head><body class="container"><div id="home_search"><h2>Loading data...............</h2></div><script src="main.bundle.js"></script><script src="vendor.bundle.js"></script><script src="home_search.bundle.js"></script><script src="create_item_form.bundle.js"></script></body></html>
7 changes: 6 additions & 1 deletion engine/db_id/static/libs/build/main.bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion engine/db_id/static/libs/build/main.css

Large diffs are not rendered by default.

56 changes: 1 addition & 55 deletions engine/db_id/static/libs/build/vendor.bundle.js

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion engine/db_id/templates/create_item.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% extends 'layout.html' %}
{% block content %}
<div class="content-section">
<div id="create_item_form"> Loading form ....</div>
<form method="POST" action="">
{{ form.hidden_tag() }}
<fieldset class="form-group">
Expand Down Expand Up @@ -38,4 +39,10 @@
</form>
</div>

{% endblock content %}
{% endblock content %}

{% block javascript %}
<script src="{{ url_for('static', filename='libs/build/create_item_form.bundle.js') }}">

</script>
{% endblock javascript %}
9 changes: 8 additions & 1 deletion engine/db_id/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{% block content %}

<h1> App Home !!</h1>
<div id="home_search"> Loading app .....</div>
{% for item in items.items %}
<article class="media content-section">
<div class="media-body">
Expand All @@ -24,4 +25,10 @@ <h2><a class="article-title" href="{{ url_for('items.item', item_id=item.id) }}"
...
{% endif %}
{% endfor %}
{% endblock content %}
{% endblock content %}

{% block javascript %}
<script src="{{ url_for('static', filename='libs/build/home_search.bundle.js') }}">

</script>
{% endblock javascript %}
11 changes: 9 additions & 2 deletions engine/db_id/templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
<a class="nav-item nav-link" href="{{ url_for('items.new_item') }}">Add Item</a>
<a class="nav-item nav-link" href="{{ url_for('main.about') }}">Import</a>
<a class="nav-item nav-link" href="{{ url_for('main.about') }}">About</a>
<button class="glossy-button glossy-button--red">Don&rsquo;t click, naughty</button>
</div>
</header>
</div>
Expand All @@ -49,7 +48,6 @@
<h3>Our Sidebar</h3>
<p class='text-muted'>You can put any information here you'd like.
<ul class="list-group">
<li class="list-group-item list-group-item-light">Latest Posts</li>
<li class="list-group-item list-group-item-light">Announcements</li>
<li class="list-group-item list-group-item-light">Calendars</li>
<li class="list-group-item list-group-item-light">etc</li>
Expand All @@ -61,5 +59,14 @@ <h3>Our Sidebar</h3>
</main>

</div>

<footer>
{% block javascript %}
<script src="{{ url_for('static', filename='libs/build/main.bundle.js') }}">

</script>

{% endblock %}
</footer>
</body>
</html>
2 changes: 1 addition & 1 deletion engine/eng.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@

if __name__ == "__main__":
logger.info('HELLO DEBUG LOGGIN!!!!!!!!!!!')
#Generate().generate(1000)
#-Generate().generate(1000)
app.run(debug=True)
Binary file added engine/flask_app.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file removed engine/test_data.db
Empty file.
33 changes: 33 additions & 0 deletions engine/testing.log
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,36 @@
2020-11-04 15:21:14,117:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2020-11-05 18:48:14,867:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2020-11-05 18:48:15,968:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2020-11-06 19:06:09,897:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2020-11-06 19:06:11,034:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2020-11-06 19:10:11,014:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2020-11-06 20:20:20,649:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2020-11-06 20:21:49,032:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2020-11-06 20:22:13,991:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2020-11-06 20:22:31,701:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2020-11-06 20:22:32,923:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2020-11-08 12:07:05,328:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2020-11-08 12:07:06,457:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2020-11-08 12:11:26,800:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2020-11-08 12:11:50,461:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2020-11-21 12:04:17,345:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2020-11-21 12:04:18,472:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2020-11-21 12:25:12,036:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2020-11-21 12:25:51,222:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2020-11-21 12:26:28,306:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2020-11-21 15:00:03,261:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2020-11-21 15:00:04,442:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2020-11-21 20:43:39,700:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2020-11-21 20:43:40,824:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2020-11-29 12:30:37,985:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2020-11-29 12:30:39,019:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2020-12-01 19:22:56,828:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2020-12-01 19:22:57,916:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2020-12-02 18:58:45,156:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2020-12-02 18:58:46,178:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2021-03-22 18:52:17,002:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2021-03-22 18:52:17,995:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2021-03-22 19:04:35,738:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2021-03-22 19:06:33,705:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2021-03-22 19:06:59,647:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
2021-03-22 19:07:00,646:INFO:HELLO DEBUG LOGGIN!!!!!!!!!!!
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@
"webpack-merge": "^5.1.2"
},
"dependencies": {
"@fortawesome/fontawesome-free": "^5.15.1",
"axios": "^0.20.0",
"date-fns": "^2.16.1",
"react": "^16.13.1",
"react-data-table-component": "^6.11.5",
"react-dom": "^16.13.1",
"react-hook-form": "^6.10.1",
"styled-components": "^5.2.0"
"styled-components": "^5.2.0",
"uuid": "^8.3.1"
}
}
Binary file added react_app.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 1 addition & 9 deletions src/apps/CreateItemForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,11 @@ const CreateItemForm = () => {

const created = await createItemRq(data)

console.log(created)
console.log('|||||||||||||| THE CREATED |||||||||||||||||||')
console.log('|||||||||||||| THE CREATED |||||||||||||||||||')
console.log('|||||||||||||| THE CREATED |||||||||||||||||||')
console.log('|||||||||||||| THE CREATED |||||||||||||||||||')



}


return (
<div>
<div className="create-item-form">

<form style={{display: 'grid', width:'auto', padding: '.3em'}} onSubmit={handleSubmit(handleCreateItem)}>
<div>
Expand Down
Loading

0 comments on commit 670fbbf

Please sign in to comment.