-
Notifications
You must be signed in to change notification settings - Fork 0
/
issues.py
52 lines (45 loc) · 1.39 KB
/
issues.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import dash
import dash_core_components as dcc
import dash_html_components as html
import dash_bootstrap_components as dbc
from dash.dependencies import Input, Output, State
import pymongo
from global_vars import app, db
layout = html.Div([
html.H1("Submit an issue", id="issues_title"),
dbc.FormGroup([
dbc.Textarea(id="bug_text", placeholder="Submit a suggestion or describe how to reproduce bug", className="mb-3"),
dbc.Button("Submit", id="bug_submit", type="submit")
]),
html.H1("Active Issues"),
html.Div(id="issues")
])
def get_issues_cards():
issues = db.bugs.find().sort("_id", pymongo.DESCENDING)
issue_cards = []
for issue in issues:
issue_cards.append(
dbc.Card(
dbc.CardBody(issue["bug"]),
className="mb-3")
)
return issue_cards
@app.callback(
Output("bug_text", "value"),
Output("issues", "children"),
Input("bug_submit", "n_clicks"),
State("bug_text", "value")
)
def submit_issue(clicks, bug_text):
if bug_text is None or len(bug_text) == 0:
return dash.no_update, get_issues_cards()
doc = {"bug": bug_text}
db.bugs.insert_one(doc)
return "", get_issues_cards()
# @app.callback(
# Output("issues", "children"),
# Input("issues_title", "n_clicks"),
# Input("bug_text", "value")
# )
# def show_issues(clicks):
# return issue_cards