Skip to content

Commit

Permalink
admin area updated:
Browse files Browse the repository at this point in the history
- required fields added
- errors fixed for empty database
- compatibility added for mysql database
  • Loading branch information
seiferta committed May 10, 2015
1 parent f782324 commit 596398c
Show file tree
Hide file tree
Showing 31 changed files with 599 additions and 522 deletions.
3 changes: 3 additions & 0 deletions emonitor/admin/web/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ div.subnavigationeast{width:200px;background-color:#ddd/*rgb(171, 171, 171)*/;bo
div.maincontainer div.pane div.ui-layout-resizer-east{border-left:1px solid #bbb}

p button.save, p button.cancel{padding:5px 40px;}
button:disabled {color: #bbb;}
select:required, input:required {border: 1px solid #97070b !important;}
select:required, input:required:valid {border: 1px solid black !important;}

div.headrow{background-color: #ababab;font-weight:bolder;overflow:hidden;padding:10px 4px;}
div.headcell{float:left;}
Expand Down
2 changes: 1 addition & 1 deletion emonitor/admin/web/css/admin.min.css

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

2 changes: 1 addition & 1 deletion emonitor/modules/alarmkeys/content_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def getAdminContent(self, **params):
alarmkeycar.cars1 = request.form.get('cars1')
alarmkeycar.cars2 = request.form.get('cars2')
alarmkeycar.materials = request.form.get('material')
if request.form.get('cars1') == request.form.get('cars2') == request.form.get('material') == '': # remove
if alarmkeycar.kid != 0 and request.form.get('cars1') == request.form.get('cars2') == request.form.get('material') == '': # remove
db.session.delete(alarmkeycar)
db.session.commit()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ <h2>{{ _('alarmkeys.header.edit') }}</h2>
{%- if type>0 or type==-2 %}
<p>
<label>{{ _('alarmkeys.category') }}:<br/>
<input type="text" name="category" value="{{ alarmkey.category }}" style="width:99%;"/>
<input type="text" name="category" value="{{ alarmkey.category }}" style="width:99%;" autofocus required/>
</label>
</p>
<p>
<label>{{ _('alarmkeys.key') }}:<br/>
<input type="text" name="key" value="{{ alarmkey.key }}" style="width:99%;"/>
<input type="text" name="key" value="{{ alarmkey.key }}" style="width:99%;" required/>
</label>
</p>
<p>
Expand Down Expand Up @@ -83,17 +83,19 @@ <h2>{{ _('alarmkeys.header.edit') }}</h2>
{{ car.dept.shortname }}<br/>{{ car.name }}
</li>
{%- endif %}
{% else %}
<p style="text-align:center;padding-top:10px;">{{ _('alarmkeys.nocars') }}</p>
{%- endfor %}
</ul>
</div>

<p>
{%- if type in [0, -1] %}
<button type="submit" name="action" value="savedefault" class="save" onclick="return getCars()"><i class="fa fa-check"></i> {{ _('alarmkey.savedefault') }}</button>
<button type="submit" name="action" value="savedefault" class="save" onclick="return getCars()"{%- if car|length == 0 %} disabled{%- endif %}><i class="fa fa-check"></i> {{ _('alarmkey.savedefault') }}</button>
{%- else %}
<button type="submit" name="action" value="savekey" class="save" onclick="return getCars()"><i class="fa fa-check"></i> {{ _('alarmkey.save') }}</button>
<button type="submit" name="action" value="savekey" class="save" onclick="return getCars()"{%- if car|length == 0 %} disabled{%- endif %}><i class="fa fa-check"></i> {{ _('alarmkey.save') }}</button>
{%- endif %}
<button type="submit" class="cancel" name="action" value="cancel"><i class="fa fa-times fa-lg"></i> {{ _('alarmkey.cancel') }}</button>
<button type="button" class="cancel" onClick="history.go(-1);return true;"><i class="fa fa-times fa-lg"></i> {{ _('alarmkey.cancel') }}</button>
</p>
<input type="hidden" name="deptid" value="{{ depid }}"/>
<input type="hidden" name="cars1" id="val_cars1"/>
Expand Down
5 changes: 4 additions & 1 deletion emonitor/modules/alarmobjects/alarmobjecttype.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ def getAlarmObjectTypes(id=0):
if id != 0:
return AlarmObjectType.query.filter_by(id=id).first()
else:
return AlarmObjectType.query.order_by(collate(AlarmObjectType.name, 'NOCASE')).all()
try:
return AlarmObjectType.query.order_by(collate(AlarmObjectType.name, 'NOCASE')).all()
except:
return AlarmObjectType.query.order_by(AlarmObjectType.name).all()
10 changes: 5 additions & 5 deletions emonitor/modules/alarmobjects/content_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from emonitor.modules.alarmobjects.alarmobjectfile import AlarmObjectFile



def getAdminContent(self, **params):
"""
Deliver admin content of module alarmobjects
Expand Down Expand Up @@ -99,10 +98,11 @@ def chunks(l, n):

elif request.form.get('action') == 'savealarmobjectaao': # save aao
alarmobject = AlarmObject.getAlarmObjects(id=request.form.get('alarmobject_id'))
alarmobject.set('cars1', [c for c in request.form.get('cars1').split(';') if c != ''])
alarmobject.set('cars2', [c for c in request.form.get('cars2').split(';') if c != ''])
alarmobject.set('material', [c for c in request.form.get('material').split(';') if c != ''])
db.session.commit()
if alarmobject:
alarmobject.set('cars1', [c for c in request.form.get('cars1').split(';') if c != ''])
alarmobject.set('cars2', [c for c in request.form.get('cars2').split(';') if c != ''])
alarmobject.set('material', [c for c in request.form.get('material').split(';') if c != ''])
db.session.commit()

elif request.form.get('action').startswith('editalarmobject_'): # edit alarmobject
alarmobject = AlarmObject.getAlarmObjects(id=int(request.form.get('action').split('_')[-1]))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h2>{{ _('alarmobjects.type.edittitle') }}</h2>
<p>
<label>
{{ _('alarmobjects.type.name') }}:<br/>
<input type="text" name="alarmobjecttype_name" value="{{ alarmobjecttype.name }}" style="width:99%;"/>
<input type="text" name="alarmobjecttype_name" value="{{ alarmobjecttype.name }}" style="width:99%;" required/>
</label>
</p>
<p>
Expand All @@ -27,7 +27,7 @@ <h2>{{ _('alarmobjects.type.edittitle') }}</h2>
<p>&nbsp;</p>
<p>
<button type="submit" name="action" value="savealarmobjecttype" class="save"><i class="fa fa-check"></i> {{ _('alarmobjects.type.save') }}</button>
<button type="submit" name="action" value="cancel" class="cancel"><i class="fa fa-times"></i> {{ _('alarmobjects.type.cancel') }}</button>
<button type="button" class="cancel" onClick="history.go(-1);return true;"><i class="fa fa-times"></i> {{ _('alarmobjects.type.cancel') }}</button>
</p>
<input type="hidden" name="alarmobjecttype_id" value="{{ alarmobjecttype.id }}"/>
<input type="hidden" name="form_id" value="alarmobjects.type.edit"/>
Expand Down
Loading

0 comments on commit 596398c

Please sign in to comment.