index show assets, need discussion

pull/26/head
liuzheng712 9 years ago
parent 246e8770ac
commit 09de12c02a

@ -16,7 +16,7 @@ from jumpserver.models import Setting
from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.decorators import login_required
from jlog.models import Log
from jperm.perm_api import get_group_user_perm
def getDaysByNum(num):
"""
@ -80,6 +80,17 @@ def index_cu(request):
login_types = {'L': 'LDAP', 'M': 'MAP'}
username = request.user.username
# TODO: need fix,liuzheng need Asset help
asset = get_group_user_perm(request.user)
print asset
assets = asset.get('asset')
# idc = []
# for i in assets:
# idc.append(i.idc.id)
# idc_all = IDC.objects.filter(id__in=idc)
idc_all = []
for i in assets:
idc_all.append(i.idc)
asset_group_all = asset.get('asset_group')
# posts = Asset.object.all()
# host_count = len(posts)
#

@ -12,7 +12,7 @@ from juser.user_api import *
MAIL_FROM = EMAIL_HOST_USER
@login_required(login_url='/login')
def chg_role(request):
role = {'SU': 2, 'GA': 1, 'CU': 0}
if request.session['role_id'] > 0:

@ -53,18 +53,147 @@
</div>
<div class="ibox-content">
<table class="table table-striped">
{% for host_five in new_posts %}
<tr>
{% for host in host_five %}
<td>{{ host.ip }}</td>
<form id="asset_form">
<div class="col-sm-2" style="padding-left: 0px">
<label>
<select name="idc" class="form-control m-b" onchange="change_info()">
<option value="">IDC机房</option>
{% for idc in idc_all %}
{% ifequal idc.name idc_name %}
<option value="{{ idc.name }}" selected> {{ idc.name }}</option>
{% else %}
<option value="{{ idc.name }}"> {{ idc.name }}</option>
{% endifequal %}
{% endfor %}
</select>
</label>
</div>
<div class="col-sm-2">
<label>
<select name="group" class="form-control m-b" onchange="change_info()">
<option value="">主机组</option>
{% for asset_group in asset_group_all %}
{% ifequal asset_group.name group_name %}
<option value="{{ asset_group.name }}"
selected> {{ asset_group.name }} </option>
{% else %}
<option value="{{ asset_group.name }}"> {{ asset_group.name }} </option>
{% endifequal %}
{% endfor %}
</select>
</label>
</div>
<div class="col-sm-2">
<label>
<select name="asset_type" class="form-control m-b" onchange="change_info()">
<option value="">所有类型</option>
{% for type in asset_types %}
{% ifequal type.0|int2str asset_type %}
<option value="{{ type.0 }}" selected> {{ type.1 }}</option>
{% else %}
<option value="{{ type.0 }}"> {{ type.1 }}</option>
{% endifequal %}
{% endfor %}
</select>
</label>
</div>
<div class="col-sm-2">
<label>
<select name="status" class="form-control m-b" onchange="change_info()">
<option value="">所有状态</option>
{% for s in asset_status %}
{% ifequal s.0|int2str status %}
<option value="{{ s.0 }}" selected> {{ s.1 }}</option>
{% else %}
<option value="{{ s.0 }}"> {{ s.1 }}</option>
{% endifequal %}
{% endfor %}
</select>
</label>
</div>
<div class="col-sm-4">
<div class="input-group">
<input type="text" class="form-control m-b" id="search_input" name="keyword"
value="{{ keyword }}" placeholder="Search">
<input type="text" style="display: none">
<div class="input-group-btn">
<button id='search_btn' href="/jasset/asset_list/?search=true" type="button"
class="btn btn-xm btn-primary search-btn" onclick="change_info()">
- 搜索 -
</button>
<button type="button" href="/jasset/asset_list/?export=true" name="export"
class="btn btn-xm btn-success search-btn-excel" onclick="return false">
- 导出 -
</button>
</div>
</div>
</div>
<div id="export"></div>
<table class="table table-striped table-bordered table-hover " id="editable" name="editable">
<thead>
<tr>
<th class="text-center">
<input id="checkall" type="checkbox" class="i-checks" name="checkall"
value="checkall" data-editable='false' onclick="check_all('asset_form')">
</th>
<th class="text-center"> 主机名</th>
<th class="text-center" name="ip"> IP地址</th>
<th class="text-center"> IDC</th>
<th class="text-center"> 所属主机组</th>
{# <th class="text-center"> 配置信息 </th>#}
<th class="text-center"> 操作系统</th>
<th class="text-center"> 使用默认管理</th>
<th class="text-center"> 操作</th>
</tr>
</thead>
<tbody>
{% for asset in assets %}
<tr class="gradeX">
<td class="text-center" name="id" value="{{ asset.id }}" data-editable='false'>
<input name="id" value="{{ asset.id }}" type="checkbox" class="i-checks">
</td>
<td class="text-center"> {{ asset.hostname|default_if_none:"" }} </td>
<td class="text-center"> {{ asset.ip|default_if_none:"" }} </td>
<td class="text-center"> {{ asset.idc.name|default_if_none:"" }} </td>
<td class="text-center">{{ asset.group.all|group_str2 }}</td>
{# <td class="text-center">{{ asset.cpu }}|{{ asset.memory }}|{{ asset.disk }}</td>#}
<td class="text-center">
{{ asset.system_type|default_if_none:"" }}{{ asset.system_version|default_if_none:"" }}</td>
<td class="text-center"> {{ asset.use_default_auth|bool2str }} </td>
<td class="text-center" data-editable='false'>
<a href="/jasset/asset_detail/?id={{ asset.id }}"
class="btn btn-xs btn-primary">详情</a>
{% ifnotequal session_role_id 0 %}
{% if user.role == 'admin' %}
<a href="/jasset/asset_edit/?id={{ asset.id }}"
class="btn btn-xs btn-info">编辑</a>
<a href="/jasset/asset_update/?id={{ asset.id }}"
class="btn btn-xs btn-info">更新</a>
<a value="/jasset/asset_del/?id={{ asset.id }}"
class="btn btn-xs btn-danger asset_del">删除</a>
{% endif %}
{% endifnotequal %}
</td>
</tr>
{% endfor %}
</tr>
{% endfor %}
</table>
{% ifequal host_count 0 %}
(空)
{% endifequal %}
</tbody>
</table>
<div class="row">
<div class="col-sm-6">
{% if user.role == 'admin' %}
<input type="button" id="asset_del" class="btn btn-danger btn-sm" name="del_button"
value="删除"/>
<a value="/jasset/asset_edit_batch/" type="button"
class="btn btn-sm btn-warning iframe">修改</a>
{% endif %}
</div>
{% include 'paginator.html' %}
</div>
</form>
</div>
</div>
</div>

Loading…
Cancel
Save