Jelajahi Sumber

实现了Guest系统icon展现

James Iter 9 tahun lalu
induk
melakukan
7ec45be804
3 mengubah file dengan 19 tambahan dan 6 penghapusan
  1. 2 2
      templates/guest.html
  2. 3 0
      templates/layout.html
  3. 14 4
      views/guest.py

+ 2 - 2
templates/guest.html

@@ -89,7 +89,7 @@
                 </tr>
                 </tr>
                 </thead>
                 </thead>
                 <tbody>
                 <tbody>
-                {% for item in data %}
+                {% for item in guests_data %}
                 <tr role="row" class="odd">
                 <tr role="row" class="odd">
                     <td><input type="checkbox"></td>
                     <td><input type="checkbox"></td>
                     <td>
                     <td>
@@ -97,7 +97,7 @@
                         <br />
                         <br />
                         {{ item.remark }}
                         {{ item.remark }}
                     </td>
                     </td>
-                    <td>{{ item.os_template_id }}</td>
+                    <td><span class="{{ os_template_mapping_by_id[item.os_template_id].icon }}"></span></td>
                     <td>{{ format_guest_status(item.status)|safe }}</td>
                     <td>{{ format_guest_status(item.status)|safe }}</td>
                     <td>{{ item.on_host }}</td>
                     <td>{{ item.on_host }}</td>
                     <td>CPU :&nbsp;&nbsp;{{ item.cpu }}&nbsp;核<br />内存 :&nbsp;&nbsp;{{ item.memory }}&nbsp;GB</td>
                     <td>CPU :&nbsp;&nbsp;{{ item.cpu }}&nbsp;核<br />内存 :&nbsp;&nbsp;{{ item.memory }}&nbsp;GB</td>

+ 3 - 0
templates/layout.html

@@ -151,6 +151,9 @@
     <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='helpers/responsive-elements.css') }}">
     <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='helpers/responsive-elements.css') }}">
     <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='helpers/admin-responsive.css') }}">
     <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='helpers/admin-responsive.css') }}">
 
 
+    <!-- JimV -->
+    <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/icons.css') }}">
+
     <!-- JS Core -->
     <!-- JS Core -->
     <script type="text/javascript" src="{{ url_for('static', filename='js-core-min/jquery-core.js') }}"></script>
     <script type="text/javascript" src="{{ url_for('static', filename='js-core-min/jquery-core.js') }}"></script>
     <script type="text/javascript" src="{{ url_for('static', filename='js-core-min/jquery-ui-widget.js') }}"></script>
     <script type="text/javascript" src="{{ url_for('static', filename='js-core-min/jquery-ui-widget.js') }}"></script>

+ 14 - 4
views/guest.py

@@ -26,9 +26,19 @@ blueprints = Blueprint(
 
 
 def show():
 def show():
     host_url = request.host_url.rstrip('/')
     host_url = request.host_url.rstrip('/')
-    url = host_url + url_for('api_guests.r_get_by_filter')
-    ret = requests.get(url=url)
-    ret = json.loads(ret.content)
-    return render_template('guest.html', data=ret['data'])
+    guests_url = host_url + url_for('api_guests.r_get_by_filter')
+    os_template_url = host_url + url_for('api_os_templates.r_get_by_filter')
+
+    guests_ret = requests.get(url=guests_url)
+    guests_ret = json.loads(guests_ret.content)
+
+    os_template_ret = requests.get(url=os_template_url)
+    os_template_ret = json.loads(os_template_ret.content)
+    os_template_mapping_by_id = dict()
+    for os_template in os_template_ret['data']:
+        os_template_mapping_by_id[os_template['id']] = os_template
+
+    return render_template('guest.html', guests_data=guests_ret['data'],
+                           os_template_mapping_by_id=os_template_mapping_by_id)