Skip to content

Commit

Permalink
Merge GOTO dashboards.
Browse files Browse the repository at this point in the history
  • Loading branch information
pchote committed Sep 21, 2023
1 parent 09f3597 commit 43fafc8
Show file tree
Hide file tree
Showing 7 changed files with 427 additions and 615 deletions.
79 changes: 10 additions & 69 deletions dashboard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,22 +277,13 @@ def halfmetre_generated_data(path):
return send_from_directory(GENERATED_DATA_DIR, HALFMETRE_GENERATED_DATA[path])
abort(404)

@app.route('/goto1/')
def goto1_dashboard():
@app.route('/goto/')
def goto_dashboard():
account = get_user_account()
if 'goto' not in account['permissions']:
return redirect(url_for('site_overview'))

return render_template('goto1/dashboard.html', user_account=get_user_account())


@app.route('/goto2/')
def goto2_dashboard():
account = get_user_account()
if 'goto' not in account['permissions']:
return redirect(url_for('site_overview'))

return render_template('goto2/dashboard.html', user_account=get_user_account())
return render_template('goto.html', user_account=get_user_account())


@app.route('/environment/')
Expand Down Expand Up @@ -668,71 +659,21 @@ def w1m_generated_data(path):
abort(404)


@app.route('/data/goto1/')
def goto1_dashboard_data():
data = json.load(open(GENERATED_DATA_DIR + '/goto-public.json'))

# Some private data is needed for the public info
private = json.load(open(GENERATED_DATA_DIR + '/goto-dome1-private.json'))

@app.route('/data/goto/')
def goto_dashboard_data():
account = get_user_account()
if 'goto' in account['permissions']:
data.update(private)
else:
data['goto_dome1_conditions'] = private['goto_dome1_conditions']

data['goto_dome1_dome'] = {
'mode': private['goto_dome1_dome']['mode'],
'dome': private['goto_dome1_dome']['dome'],
'lockdown': private['goto_dome1_dome']['lockdown'],
'dehumidifier_on': private['goto_dome1_dome']['dehumidifier_on'],
'hatch': private['goto_dome1_dome']['hatch']
}

data['goto_dome1_power'] = {
'status_PDU1': {
'leds2': private['goto_dome1_power']['status_PDU1']['leds2'],
},
'status_PDU2': {
'leds1': private['goto_dome1_power']['status_PDU2']['leds1'],
}
}

response = jsonify(**data)
response.headers['Access-Control-Allow-Origin'] = '*'
return response
if 'goto' not in account['permissions']:
abort(404)

@app.route('/data/goto2/')
def goto2_dashboard_data():
data = json.load(open(GENERATED_DATA_DIR + '/goto-public.json'))

# Some private data is needed for the public info
private = json.load(open(GENERATED_DATA_DIR + '/goto-dome2-private.json'))

account = get_user_account()
if 'goto' in account['permissions']:
data.update(private)
else:
data['goto_dome2_conditions'] = private['goto_dome2_conditions']

data['goto_dome2_dome'] = {
'mode': private['goto_dome2_dome']['mode'],
'dome': private['goto_dome2_dome']['dome'],
'lockdown': private['goto_dome2_dome']['lockdown'],
'dehumidifier_on': private['goto_dome2_dome']['dehumidifier_on'],
'hatch': private['goto_dome2_dome']['hatch']
}

data['goto_dome2_power'] = {
'status_PDU1': {
'leds': private['goto_dome2_power']['status_PDU1']['leds'],
}
}
data.update(json.load(open(GENERATED_DATA_DIR + '/goto-dome1-private.json')))
data.update(json.load(open(GENERATED_DATA_DIR + '/goto-dome2-private.json')))

response = jsonify(**data)
response.headers['Access-Control-Allow-Origin'] = '*'
return response


@app.route('/data/superwasp/')
def superwasp_dashboard_data():
account = get_user_account()
Expand Down
Loading

0 comments on commit 43fafc8

Please sign in to comment.