diff --git a/device_management/templates/device_management/index.html b/device_management/templates/device_management/index.html index 31a8d06..baabfe9 100644 --- a/device_management/templates/device_management/index.html +++ b/device_management/templates/device_management/index.html @@ -1,3 +1,4 @@ +{% load device_tags %} @@ -102,10 +103,45 @@ {% for device in devices %} -
+
+ + {% with icon_type=device.device_name|device_icon %} + {% if icon_type == 'nvr' %} + + {% elif icon_type == 'codec' %} + + {% elif icon_type == 'matrix' %} + + {% elif icon_type == 'amplifier' %} + + {% elif icon_type == 'mixer' %} + + {% elif icon_type == 'microphone' %} + + {% elif icon_type == 'camera' %} + + {% elif icon_type == 'screen' %} + + {% elif icon_type == 'processor' %} + + {% elif icon_type == 'controller' %} + + {% elif icon_type == 'cast' %} + + {% elif icon_type == 'power' %} + + {% elif icon_type == 'player' %} + + {% elif icon_type == 'switch' %} + + {% else %} + + {% endif %} + {% endwith %} + {{ device.device_name }}
-
{{ device.brand|default:"" }}
+
{{ device.brand|default:"" }}
{{ device.model|default:"-" }} diff --git a/device_management/templatetags/__init__.py b/device_management/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/device_management/templatetags/device_tags.py b/device_management/templatetags/device_tags.py new file mode 100644 index 0000000..de5b4ca --- /dev/null +++ b/device_management/templatetags/device_tags.py @@ -0,0 +1,41 @@ +from django import template + +register = template.Library() + + +@register.filter +def device_icon(name): + if not name: + return 'default' + name = name.lower() + if any(k in name for k in ['nvr', '硬盘刻录', '刻录机', '录像']): + return 'nvr' + if any(k in name for k in ['编码器', '解码器', '终端', '视频会议']): + return 'codec' + if any(k in name for k in ['矩阵']): + return 'matrix' + if any(k in name for k in ['功放']): + return 'amplifier' + if any(k in name for k in ['调音台']): + return 'mixer' + if any(k in name for k in ['麦克', '话筒']): + return 'microphone' + if any(k in name for k in ['摄像头', '相机', '摄像机']): + return 'camera' + if any(k in name for k in ['屏幕', '显示器', '大屏']): + return 'screen' + if any(k in name for k in ['处理器', '音频处理']): + return 'processor' + if any(k in name for k in ['中控']): + return 'controller' + if any(k in name for k in ['投屏']): + return 'cast' + if any(k in name for k in ['放大器']): + return 'amplifier' + if any(k in name for k in ['电源', '时序']): + return 'power' + if any(k in name for k in ['播放器', '音乐']): + return 'player' + if any(k in name for k in ['交换机']): + return 'switch' + return 'default'