mirror of https://git.48k.eu/ogcp
views: show MAC as lowercase with colon separators
Define a function to format the MAC string for every view in the web. Example of formatted MAC address: aa:bb:cc:dd:ee:aa Show MAC address in client pills in that same format.master
parent
9ea8a74c63
commit
b510d625b2
|
@ -99,6 +99,9 @@ class ServerErrorCode(Exception):
|
|||
def normalize_mac(mac):
|
||||
return mac.replace(':', '').replace('-', '').replace('.', '').lower()
|
||||
|
||||
def prettify_mac(mac):
|
||||
return (':'.join(mac[i:i+2] for i in range(0, 12, 2))).lower()
|
||||
|
||||
def ogserver_down(view):
|
||||
flash(_('Cannot talk to ogserver. Is ogserver down?'), category='error')
|
||||
return redirect(url_for(view))
|
||||
|
@ -494,7 +497,7 @@ def get_client_mac():
|
|||
resp = server.get('/client/info', payload)
|
||||
client_info = resp.json()
|
||||
mac = client_info.get('mac')
|
||||
pretty_mac = (':'.join(mac[i:i+2] for i in range(0, 12, 2))).upper()
|
||||
pretty_mac = prettify_mac(mac)
|
||||
return jsonify(pretty_mac)
|
||||
|
||||
|
||||
|
@ -1216,7 +1219,7 @@ def action_client_info():
|
|||
form.name.render_kw = {'readonly': True}
|
||||
form.ip.data = db_client['ip']
|
||||
form.ip.render_kw = {'readonly': True}
|
||||
form.mac.data = db_client['mac']
|
||||
form.mac.data = prettify_mac(db_client['mac'])
|
||||
form.mac.render_kw = {'readonly': True}
|
||||
form.serial_number.data = db_client['serial_number']
|
||||
form.serial_number.render_kw = {'readonly': True}
|
||||
|
@ -1340,7 +1343,7 @@ def action_client_update():
|
|||
form.ip.data = db_client['ip']
|
||||
form.ip.render_kw = {'readonly': True}
|
||||
form.name.data = db_client['name']
|
||||
form.mac.data = db_client['mac']
|
||||
form.mac.data = prettify_mac(db_client['mac'])
|
||||
form.serial_number.data = db_client['serial_number']
|
||||
form.livedir.render_kw = {'readonly': True}
|
||||
form.remote.data = db_client['remote']
|
||||
|
@ -1590,7 +1593,7 @@ def action_client_add():
|
|||
available_modes.extend([(mode, mode) for mode in r.json()['modes'] if mode != 'pxe'])
|
||||
|
||||
form.boot.choices = list(available_modes)
|
||||
form.mac.render_kw = {'placeholder': 'aabbccddeeaa'}
|
||||
form.mac.render_kw = {'placeholder': 'aa:bb:cc:dd:ee:aa'}
|
||||
|
||||
r = server.get('/scopes')
|
||||
if not r:
|
||||
|
|
Loading…
Reference in New Issue