Commit 3b07198b authored by ibuler's avatar ibuler

merge with cmdb

parents 0862ffef 0f29745b
...@@ -37,6 +37,7 @@ nosetests.xml ...@@ -37,6 +37,7 @@ nosetests.xml
.mr.developer.cfg .mr.developer.cfg
.project .project
.pydevproject .pydevproject
*.xlsx
node_modules node_modules
logs logs
keys keys
......
This diff is collapsed.
# coding: utf-8 # coding: utf-8
import xlrd
import xlsxwriter
from django.db.models import AutoField
from jumpserver.api import * from jumpserver.api import *
from jasset.models import ASSET_STATUS, ASSET_TYPE, ASSET_ENV, IDC, AssetRecord
def group_add_asset(group, asset_id=None, asset_ip=None): def group_add_asset(group, asset_id=None, asset_ip=None):
...@@ -32,6 +36,21 @@ def db_add_group(**kwargs): ...@@ -32,6 +36,21 @@ def db_add_group(**kwargs):
group_add_asset(group, asset_id) group_add_asset(group, asset_id)
def db_update_group(**kwargs):
"""
add a asset group in database
数据库中更新资产
"""
group_id = kwargs.pop('id')
asset_id_list = kwargs.pop('asset_select')
group = get_object(AssetGroup, id=group_id)
for asset_id in asset_id_list:
group_add_asset(group, asset_id)
AssetGroup.objects.filter(id=group_id).update(**kwargs)
def db_asset_add(**kwargs): def db_asset_add(**kwargs):
""" """
add asset to db add asset to db
...@@ -80,11 +99,12 @@ def db_asset_update(**kwargs): ...@@ -80,11 +99,12 @@ def db_asset_update(**kwargs):
asset_id = kwargs.pop('id') asset_id = kwargs.pop('id')
Asset.objects.filter(id=asset_id).update(**kwargs) Asset.objects.filter(id=asset_id).update(**kwargs)
# #
# #
# def batch_host_edit(host_info, j_user='', j_password=''): # def batch_host_edit(host_alter_dic, j_user='', j_password=''):
# """ 批量修改主机函数 """ # """ 批量修改主机函数 """
# j_id, j_ip, j_idc, j_port, j_type, j_group, j_dept, j_active, j_comment = host_info # j_id, j_ip, j_idc, j_port, j_type, j_group, j_dept, j_active, j_comment = host_alter_dic
# groups, depts = [], [] # groups, depts = [], []
# is_active = {u'是': '1', u'否': '2'} # is_active = {u'是': '1', u'否': '2'}
# login_types = {'LDAP': 'L', 'MAP': 'M'} # login_types = {'LDAP': 'L', 'MAP': 'M'}
...@@ -156,3 +176,230 @@ def db_asset_update(**kwargs): ...@@ -156,3 +176,230 @@ def db_asset_update(**kwargs):
# else: # else:
# return httperror(request, '删除失败, 没有这个IDC!') # return httperror(request, '删除失败, 没有这个IDC!')
def sort_ip_list(ip_list):
""" ip地址排序 """
ip_list.sort(key=lambda s: map(int, s.split('.')))
return ip_list
def get_tuple_name(asset_tuple, value):
""""""
for t in asset_tuple:
if t[0] == value:
return t[1]
return ''
def get_tuple_diff(asset_tuple, field_name, value):
""""""
old_name = get_tuple_name(asset_tuple, int(value[0])) if value[0] else u''
new_name = get_tuple_name(asset_tuple, int(value[1])) if value[1] else u''
alert_info = [field_name, old_name, new_name]
return alert_info
def asset_diff(before, after):
"""
asset change before and after
"""
alter_dic = {}
before_dic, after_dic = before, dict(after.iterlists())
for k, v in before_dic.items():
after_dic_values = after_dic.get(k, [])
if k == 'group':
after_dic_value = after_dic_values if len(after_dic_values) > 0 else u''
uv = v if v is not None else u''
else:
after_dic_value = after_dic_values[0] if len(after_dic_values) > 0 else u''
uv = unicode(v) if v is not None else u''
if uv != after_dic_value:
alter_dic.update({k: [uv, after_dic_value]})
for k, v in alter_dic.items():
if v == [None, u'']:
alter_dic.pop(k)
return alter_dic
def asset_diff_one(before, after):
print before.__dict__, after.__dict__
fields = Asset._meta.get_all_field_names()
for field in fields:
print before.field, after.field
def db_asset_alert(asset, username, alert_dic):
"""
asset alert info to db
"""
alert_list = []
asset_tuple_dic = {'status': ASSET_STATUS, 'env': ASSET_ENV, 'asset_type': ASSET_TYPE}
for field, value in alert_dic.iteritems():
print field
field_name = Asset._meta.get_field_by_name(field)[0].verbose_name
if field == 'idc':
old = IDC.objects.filter(id=value[0]) if value[0] else u''
new = IDC.objects.filter(id=value[1]) if value[1] else u''
old_name = old[0].name if old else u''
new_name = new[0].name if new else u''
alert_info = [field_name, old_name, new_name]
elif field in ['status', 'env', 'asset_type']:
alert_info = get_tuple_diff(asset_tuple_dic.get(field), field_name, value)
elif field == 'group':
old, new = [], []
for group_id in value[0]:
group_name = AssetGroup.objects.get(id=int(group_id)).name
old.append(group_name)
for group_id in value[1]:
group_name = AssetGroup.objects.get(id=int(group_id)).name
new.append(group_name)
if old == new:
continue
else:
alert_info = [field_name, ','.join(old), ','.join(new)]
elif field == 'use_default_auth':
if unicode(value[0]) == 'True' and unicode(value[1]) == 'on' or \
unicode(value[0]) == 'False' and unicode(value[1]) == '':
continue
else:
name = asset.username
alert_info = [field_name, u'默认', name] if unicode(value[0]) == 'True' else \
[field_name, name, u'默认']
elif field in ['username', 'password']:
continue
elif field == 'is_active':
if unicode(value[0]) == 'True' and unicode(value[1]) == '1' or \
unicode(value[0]) == 'False' and unicode(value[1]) == '0':
continue
else:
alert_info = [u'是否激活', u'激活', u'禁用'] if unicode(value[0]) == 'True' else \
[u'是否激活', u'禁用', u'激活']
else:
alert_info = [field_name, unicode(value[0]), unicode(value[1])]
if 'alert_info' in dir():
alert_list.append(alert_info)
if alert_list:
AssetRecord.objects.create(asset=asset, username=username, content=alert_list)
def write_excel(asset_all):
data = []
now = datetime.datetime.now().strftime('%Y_%m_%d_%H_%M')
file_name = 'cmdb_excel_' + now + '.xlsx'
workbook = xlsxwriter.Workbook('static/files/excels/%s' % file_name)
worksheet = workbook.add_worksheet(u'CMDB数据')
worksheet.set_first_sheet()
worksheet.set_column('A:Z', 14)
title = [u'主机名', u'IP', u'IDC', u'MAC', u'远控IP', u'CPU', u'内存', u'硬盘', u'操作系统', u'机柜位置',
u'所属主机组', u'机器状态', u'备注']
for asset in asset_all:
group_list = []
for p in asset.group.all():
group_list.append(p.name)
group_all = '/'.join(group_list)
status = asset.get_status_display()
idc_name = asset.idc.name if asset.idc else u''
alter_dic = [asset.hostname, asset.ip, idc_name, asset.mac, asset.remote_ip, asset.cpu, asset.memory,
asset.disk, (asset.system_type + asset.system_version), asset.cabinet, group_all, status,
asset.comment]
data.append(alter_dic)
format = workbook.add_format()
format.set_border(1)
format.set_align('center')
format_title = workbook.add_format()
format_title.set_border(1)
format_title.set_bg_color('#cccccc')
format_title.set_align('center')
format_title.set_bold()
format_ave = workbook.add_format()
format_ave.set_border(1)
format_ave.set_num_format('0.00')
worksheet.write_row('A1', title, format_title)
i = 2
for alter_dic in data:
location = 'A' + str(i)
worksheet.write_row(location, alter_dic, format)
i += 1
workbook.close()
ret = (True, file_name)
return ret
def copy_model_instance(obj):
initial = dict([(f.name, getattr(obj, f.name))
for f in obj._meta.fields
if not isinstance(f, AutoField) and \
not f in obj._meta.parents.values()])
return obj.__class__(**initial)
def ansible_record(asset, ansible_dic, username):
alert_dic = {}
asset_dic = asset.__dict__
for field, value in ansible_dic.items():
old = asset_dic.get(field)
new = ansible_dic.get(field)
if unicode(old) != unicode(new):
print old, new, type(old), type(new)
setattr(asset, field, value)
asset.save()
alert_dic[field] = [old, new]
db_asset_alert(asset, username, alert_dic)
def excel_to_db(excel_file):
"""
Asset add batch function
"""
try:
data = xlrd.open_workbook(filename=None, file_contents=excel_file.read())
except Exception, e:
return False
else:
table = data.sheets()[0]
rows = table.nrows
group_instance = []
for row_num in range(1, rows):
row = table.row_values(row_num)
if row:
ip, port, hostname, use_default_auth, username, password, group = row
print ip
use_default_auth = 1 if use_default_auth == u'默认' else 0
if get_object(Asset, ip=ip):
continue
if ip and port:
asset = Asset(ip=ip,
port=port,
use_default_auth=use_default_auth,
username=username,
password=password
)
asset.save()
group_list = group.split('/')
for group_name in group_list:
group = get_object(AssetGroup, name=group_name)
if group:
group_instance.append(group)
if group_instance:
print group_instance
asset.group = group_instance
asset.save()
return True
# coding:utf-8
from django import forms
from jasset.models import IDC, Asset, AssetGroup
class AssetForm(forms.ModelForm):
class Meta:
model = Asset
fields = [
"ip", "other_ip", "hostname", "port", "group", "username", "password", "use_default_auth",
"idc", "mac", "remote_ip", "brand", "cpu", "memory", "disk", "system_type", "system_version",
"cabinet", "position", "number", "status", "asset_type", "env", "sn", "is_active", "comment"
]
class AssetGroupForm(forms.ModelForm):
class Meta:
model = AssetGroup
fields = [
"name", "comment"
]
class IdcForm(forms.ModelForm):
class Meta:
model = IDC
fields = ['name', "bandwidth", "operator", 'linkman', 'phone', 'address', 'network', 'comment']
# coding: utf-8
import datetime import datetime
from django.db import models from django.db import models
# from juser.models import User, UserGroup from juser.models import User, UserGroup
ASSET_ENV = (
(1, U'生产环境'),
(2, U'测试环境')
)
ASSET_STATUS = (
(1, u"已使用"),
(2, u"未使用"),
(3, u"报废")
)
ASSET_TYPE = (
(1, u"服务器"),
(2, u"网络设备"),
(3, u"其他")
)
class AssetGroup(models.Model): class AssetGroup(models.Model):
...@@ -14,86 +33,74 @@ class AssetGroup(models.Model): ...@@ -14,86 +33,74 @@ class AssetGroup(models.Model):
def __unicode__(self): def __unicode__(self):
return self.name return self.name
# def get_asset(self):
# return self.asset_set.all() class IDC(models.Model):
# name = models.CharField(max_length=32, verbose_name=u'机房名称')
# def get_asset_info(self, printable=False): bandwidth = models.CharField(max_length=32, blank=True, null=True, verbose_name=u'机房带宽')
# assets = self.get_asset() linkman = models.CharField(max_length=16, null=True, verbose_name=u'联系人')
# ip_comment = {} phone = models.CharField(max_length=32, verbose_name=u'联系电话')
# for asset in assets: address = models.CharField(max_length=128, blank=True, null=True, verbose_name=u"机房地址")
# ip_comment[asset.ip] = asset.comment network = models.TextField(blank=True, null=True, verbose_name=u"IP地址段")
# date_added = models.DateField(auto_now=True, default=datetime.datetime.now(), null=True)
# for ip in sorted(ip_comment): operator = models.IntegerField(max_length=32, blank=True, null=True, verbose_name=u"运营商")
# if ip_comment[ip]: comment = models.CharField(max_length=128, blank=True, null=True, verbose_name=u"备注")
# print '%-15s -- %s' % (ip, ip_comment[ip])
# else: def __unicode__(self):
# print '%-15s' % ip return self.name
# print ''
# class Meta:
# def get_asset_num(self): verbose_name = u"IDC机房"
# return len(self.get_asset()) verbose_name_plural = verbose_name
#
# def get_user_group(self):
# perm_list = self.perm_set.all()
# user_group_list = []
# for perm in perm_list:
# user_group_list.append(perm.user_group)
# return user_group_list
#
# def get_user(self):
# user_list = []
# user_group_list = self.get_user_group()
# for user_group in user_group_list:
# user_list.extend(user_group.user_set.all())
# return user_list
#
# def is_permed(self, user=None, user_group=None):
# if user:
# if user in self.get_user():
# return True
#
# if user_group:
# if user_group in self.get_user_group():
# return True
# return False
class Asset(models.Model): class Asset(models.Model):
ip = models.GenericIPAddressField(unique=True) """
port = models.IntegerField() asset modle
group = models.ManyToManyField(AssetGroup) """
username = models.CharField(max_length=20, blank=True, null=True) ip = models.IPAddressField(unique=True, verbose_name=u"主机IP")
password = models.CharField(max_length=80, blank=True, null=True) other_ip = models.CharField(max_length=255, blank=True, null=True, verbose_name=u"其他IP")
use_default_auth = models.BooleanField(default=True) hostname = models.CharField(max_length=64, blank=True, null=True, verbose_name=u"主机名")
date_added = models.DateTimeField(auto_now_add=True) port = models.IntegerField(max_length=6, verbose_name=u"端口号")
is_active = models.BooleanField(default=True) group = models.ManyToManyField(AssetGroup, blank=True, null=True, verbose_name=u"所属主机组")
comment = models.CharField(max_length=100, blank=True, null=True) username = models.CharField(max_length=16, blank=True, null=True, verbose_name=u"管理用户名")
password = models.CharField(max_length=64, blank=True, null=True, verbose_name=u"密码")
use_default_auth = models.BooleanField(default=True, verbose_name=u"使用默认管理账号")
idc = models.ForeignKey(IDC, blank=True, null=True, on_delete=models.SET_NULL, verbose_name=u'机房')
mac = models.CharField(max_length=20, blank=True, null=True, verbose_name=u"MAC地址")
remote_ip = models.CharField(max_length=16, blank=True, null=True, verbose_name=u'远控卡')
brand = models.CharField(max_length=64, blank=True, null=True, verbose_name=u'硬件厂商型号')
cpu = models.CharField(max_length=64, blank=True, null=True, verbose_name=u'CPU')
memory = models.CharField(max_length=128, blank=True, null=True, verbose_name=u'内存')
disk = models.CharField(max_length=128, blank=True, null=True, verbose_name=u'硬盘')
system_type = models.CharField(max_length=32, blank=True, null=True, verbose_name=u"系统类型")
system_version = models.CharField(max_length=8, blank=True, null=True, verbose_name=u"版本号")
cabinet = models.CharField(max_length=32, blank=True, null=True, verbose_name=u'机柜号')
position = models.IntegerField(max_length=2, blank=True, null=True, verbose_name=u'机器位置')
number = models.CharField(max_length=32, blank=True, null=True, verbose_name=u'资产编号')
status = models.IntegerField(max_length=2, choices=ASSET_STATUS, blank=True, null=True, default=1, verbose_name=u"机器状态")
asset_type = models.IntegerField(max_length=2, choices=ASSET_TYPE, blank=True, null=True, verbose_name=u"主机类型")
env = models.IntegerField(max_length=2, choices=ASSET_ENV, blank=True, null=True, verbose_name=u"运行环境")
sn = models.CharField(max_length=128, blank=True, null=True, verbose_name=u"SN编号")
date_added = models.DateTimeField(auto_now=True, default=datetime.datetime.now(), null=True)
is_active = models.BooleanField(default=True, verbose_name=u"是否激活")
comment = models.CharField(max_length=128, blank=True, null=True, verbose_name=u"备注")
def __unicode__(self): def __unicode__(self):
return self.ip return self.ip
# def get_user(self):
# perm_list = [] class AssetRecord(models.Model):
# asset_group_all = self.bis_group.all() asset = models.ForeignKey(Asset)
# for asset_group in asset_group_all: username = models.CharField(max_length=30, null=True)
# perm_list.extend(asset_group.perm_set.all()) alert_time = models.DateTimeField(auto_now_add=True)
# content = models.TextField(null=True, blank=True)
# user_group_list = [] comment = models.TextField(null=True, blank=True)
# for perm in perm_list:
# user_group_list.append(perm.user_group)
#
# user_permed_list = []
# for user_group in user_group_list:
# user_permed_list.extend(user_group.user_set.all())
# user_permed_list = list(set(user_permed_list))
# return user_permed_list
class AssetAlias(models.Model): class AssetAlias(models.Model):
pass user = models.ForeignKey(User)
# user = models.ForeignKey(User) asset = models.ForeignKey(Asset)
# asset = models.ForeignKey(Asset) alias = models.CharField(max_length=100, blank=True, null=True)
# alias = models.CharField(max_length=100, blank=True, null=True)
# def __unicode__(self):
# def __unicode__(self): return self.alias
# return self.alias
...@@ -4,23 +4,27 @@ from jasset.views import * ...@@ -4,23 +4,27 @@ from jasset.views import *
urlpatterns = patterns('', urlpatterns = patterns('',
url(r'^asset_add/$', asset_add), url(r'^asset_add/$', asset_add),
# url(r"^host_add_multi/$", host_add_batch), url(r"^asset_add_batch/$", asset_add_batch),
url(r'^group_add/$', group_add),
url(r'^group_list/$', group_list),
url(r'^group_del/$', group_del), url(r'^group_del/$', group_del),
url(r'^asset_list/$', asset_list), url(r'^asset_list/$', asset_list),
url(r'^asset_del/$', asset_del), url(r'^asset_del/$', asset_del),
url(r"^asset_detail/$", asset_detail), url(r"^asset_detail/$", asset_detail),
url(r'^asset_edit/$', asset_edit), url(r'^asset_edit/$', asset_edit),
url(r'^asset_update/$', asset_update),
# url(r'^search/$', host_search), # url(r'^search/$', host_search),
# url(r"^host_detail/$", host_detail),
# url(r"^dept_host_ajax/$", dept_host_ajax),
# url(r"^show_all_ajax/$", show_all_ajax), # url(r"^show_all_ajax/$", show_all_ajax),
# url(r'^group_edit/$', group_edit), url(r'^group_add/$', group_add),
# url(r'^group_list/$', group_list), url(r'^group_list/$', group_list),
# url(r'^group_detail/$', group_detail), url(r'^group_edit/$', group_edit),
url(r'^group_list/$', group_list),
url(r'^group_detail/$', group_detail),
# url(r'^group_del_host/$', group_del_host), # url(r'^group_del_host/$', group_del_host),
url(r'^asset_edit_batch/$', asset_edit_batch),
# url(r'^host_edit/batch/$', host_edit_batch),
# url(r'^host_edit_common/batch/$', host_edit_common_batch), # url(r'^host_edit_common/batch/$', host_edit_common_batch),
url(r'^idc_add/$', idc_add),
url(r'^idc_list/$', idc_list),
url(r'^idc_detail/$', idc_detail),
url(r'^idc_edit/$', idc_edit),
url(r'^idc_del/$', idc_del),
url(r'^upload/$', asset_upload),
) )
\ No newline at end of file
This diff is collapsed.
...@@ -15,8 +15,6 @@ database = jumpserver ...@@ -15,8 +15,6 @@ database = jumpserver
[websocket] [websocket]
web_socket_host = 127.0.0.1:3000 web_socket_host = 127.0.0.1:3000
[mail] [mail]
mail_enable = 1 mail_enable = 1
email_host = smtp.exmail.qq.com email_host = smtp.exmail.qq.com
......
...@@ -65,12 +65,12 @@ INSTALLED_APPS = ( ...@@ -65,12 +65,12 @@ INSTALLED_APPS = (
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'django.contrib.humanize', 'django.contrib.humanize',
'bootstrapform',
'jumpserver', 'jumpserver',
'juser', 'juser',
'jasset', 'jasset',
'jperm', 'jperm',
'jlog', 'jlog',
) )
MIDDLEWARE_CLASSES = ( MIDDLEWARE_CLASSES = (
...@@ -146,3 +146,5 @@ USE_TZ = False ...@@ -146,3 +146,5 @@ USE_TZ = False
# https://docs.djangoproject.com/en/1.7/howto/static-files/ # https://docs.djangoproject.com/en/1.7/howto/static-files/
STATIC_URL = '/static/' STATIC_URL = '/static/'
BOOTSTRAP_COLUMN_COUNT = 10
...@@ -182,3 +182,132 @@ def asset_which_group(asset, member): ...@@ -182,3 +182,132 @@ def asset_which_group(asset, member):
names = [members.name for members in member.all()] names = [members.name for members in member.all()]
return ','.join(names) return ','.join(names)
#
#
# @register.filter(name='get_user_asset_group')
# def get_user_asset_group(user):
# return user.get_asset_group()
#
#
# @register.filter(name='group_asset_list')
# def group_asset_list(group):
# return group.asset_set.all()
#
#
# @register.filter(name='group_asset_list_count')
# def group_asset_list_count(group):
# return group.asset_set.all().count()
#
#
# @register.filter(name='time_delta')
# def time_delta(time_before):
# delta = datetime.datetime.now() - time_before
# days = delta.days
# if days:
# return "%s 天前" % days
# else:
# hours = delta.seconds/3600
# if hours:
# return "%s 小时前" % hours
# else:
# mins = delta.seconds/60
# if mins:
# return '%s 分钟前' % mins
# else:
# return '%s 秒前' % delta.seconds
#
#
# @register.filter(name='sudo_cmd_list')
# def sudo_cmd_list(cmd_group_id):
# cmd_group = CmdGroup.objects.filter(id=cmd_group_id)
# if cmd_group:
# cmd_group = cmd_group[0]
# return cmd_group.cmd.split(',')
#
#
# @register.filter(name='sudo_cmd_count')
# def sudo_cmd_count(user_group_id):
# user_group = UserGroup.objects.filter(id=user_group_id)
# cmds = []
# if user_group:
# user_group = user_group[0]
# cmd_groups = []
#
# for perm in user_group.sudoperm_set.all():
# cmd_groups.extend(perm.cmd_group.all())
#
# for cmd_group in cmd_groups:
# cmds.extend(cmd_group.cmd.split(','))
# return len(set(cmds))
#
# else:
# return 0
#
#
# @register.filter(name='sudo_cmd_count')
# def sudo_cmd_count(user_group_id):
# user_group = UserGroup.objects.filter(id=user_group_id)
# cmds = []
# if user_group:
# user_group = user_group[0]
# cmd_groups = []
# for perm in user_group.sudoperm_set.all():
# cmd_groups.extend(perm.cmd_group.all())
#
# for cmd_group in cmd_groups:
# cmds.extend(cmd_group.cmd.split(','))
# return len(set(cmds))
# else:
# return 0
#
#
# @register.filter(name='sudo_cmd_ids')
# def sudo_cmd_ids(user_group_id):
# user_group = UserGroup.objects.filter(id=user_group_id)
# if user_group:
# user_group = user_group[0]
# cmd_groups = []
# for perm in user_group.sudoperm_set.all():
# cmd_groups.extend(perm.cmd_group.all())
# cmd_ids = [str(cmd_group.id) for cmd_group in cmd_groups]
# return ','.join(cmd_ids)
# else:
# return '0'
#
#
# @register.filter(name='cmd_group_split')
# def cmd_group_split(cmd_group):
# return cmd_group.cmd.split(',')
@register.filter(name='str_to_list')
def str_to_list(info):
"""
str to list
"""
print ast.literal_eval(info), type(ast.literal_eval(info))
return ast.literal_eval(info)
@register.filter(name='str_to_dic')
def str_to_dic(info):
"""
str to list
"""
return ast.literal_eval(info).iteritems()
@register.filter(name='str_to_code')
def str_to_code(char_str):
if char_str:
return char_str
else:
return u'空'
@register.filter(name='ip_str_to_list')
def ip_str_to_list(ip_str):
"""
ip str to list
"""
return ip_str.split(',')
...@@ -4562,3 +4562,8 @@ body.skin-3 { ...@@ -4562,3 +4562,8 @@ body.skin-3 {
.red-fonts { .red-fonts {
color: #ed5565; color: #ed5565;
} }
.form-group.required .control-label:after {
content: " *";
color: red;
}
\ No newline at end of file
...@@ -135,3 +135,11 @@ function selectAll(){ ...@@ -135,3 +135,11 @@ function selectAll(){
// }) // })
//} //}
function getIDall() {
var check_array = [];
$(".gradeX input:checked").each(function () {
var id = $(this).attr("value");
check_array.push(id);
});
return check_array.join(",");
}
\ No newline at end of file
{% extends 'base.html' %} {% extends 'base.html' %}
{% load mytags %} {% load mytags %}
{% load bootstrap %}
{% block content %} {% block content %}
{% include 'nav_cat_bar.html' %} {% include 'nav_cat_bar.html' %}
<div class="wrapper wrapper-content animated fadeInRight"> <div class="wrapper wrapper-content animated fadeInRight">
...@@ -26,7 +27,7 @@ ...@@ -26,7 +27,7 @@
<div class="panel-options"> <div class="panel-options">
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li class="active"><a href="/jasset/asset_add/" class="text-center"><i class="fa fa-laptop"></i> 单台添加 </a></li> <li class="active"><a href="/jasset/asset_add/" class="text-center"><i class="fa fa-laptop"></i> 单台添加 </a></li>
<li><a href="/jasset/host_add_multi" class="text-center"><i class="fa fa-bar-chart-o"></i> 批量添加 </a></li> <li><a href="/jasset/asset_add_batch" class="text-center"><i class="fa fa-bar-chart-o"></i> 批量添加 </a></li>
</ul> </ul>
</div> </div>
<div class="panel-body"> <div class="panel-body">
...@@ -38,17 +39,23 @@ ...@@ -38,17 +39,23 @@
{% if msg %} {% if msg %}
<div class="alert alert-success text-center">{{ msg }}</div> <div class="alert alert-success text-center">{{ msg }}</div>
{% endif %} {% endif %}
<form id="assetForm" method="post" class="form-horizontal"> <form id="assetForm" method="post" class="form-horizontal">
<div class="form-group"><label class="col-sm-2 control-label"> IP地址<span class="red-fonts">*</span> </label> {{ af.ip|bootstrap_horizontal }}
<div class="col-sm-8"><input type="text" name="ip" placeholder="IP" class="form-control"></div>
</div> <div class="hr-line-dashed"></div>
{{ af.port|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.idc|bootstrap_horizontal }}
<div class="hr-line-dashed"></div> <div class="hr-line-dashed"></div>
<div class="form-group"> <div class="form-group">
<label for="j_group" class="col-sm-2 control-label">使用默认</label> <label for="j_group" class="col-sm-2 control-label">管理账号<span class="red-fonts"> *</span></label>
<div class="col-sm-1"> <div class="col-sm-2">
<div class="radio i-checks"> <div class="radio i-checks">
<label> <label>
<input type="checkbox" checked="" value="1" id="use_default" name="use_default"> <input type="checkbox" checked="" id="id_use_default_auth" name="use_default_auth"><span> 使用默认 </span>
</label> </label>
</div> </div>
</div> </div>
...@@ -73,19 +80,12 @@ ...@@ -73,19 +80,12 @@
</div> </div>
<div class="hr-line-dashed"></div> <div class="hr-line-dashed"></div>
<div class="form-group"> {{ af.group|bootstrap_horizontal }}
<label for="groups" class="col-sm-2 control-label">所属主机组</label>
<div class="col-sm-8"> {# {{ af.is_active|bootstrap_horizontal }}#}
<select id="groups" name="groups" class="form-control m-b" multiple size="10">
{% for asset_group in asset_group_all %}
<option type="checkbox" value="{{ asset_group.id }}">{{ asset_group.name }} {% if asset_group.comment %} --- {{ asset_group.comment }} {% endif %}</option>
{% endfor %}
</select>
</div>
</div>
<div class="hr-line-dashed"></div> <div class="hr-line-dashed"></div>
<div class="form-group"><label class="col-sm-2 control-label"> 是否激活<span class="red-fonts">*</span> </label> <div class="form-group"><label class="col-sm-2 control-label"> 是否激活<span class="red-fonts"> *</span> </label>
<div class="col-sm-8"> <div class="col-sm-8">
<div class="radio i-checks"> <div class="radio i-checks">
<label> <input type="radio" checked="" value="1" name="is_active">激活 </label> <label> <input type="radio" checked="" value="1" name="is_active">激活 </label>
...@@ -94,11 +94,6 @@ ...@@ -94,11 +94,6 @@
</div> </div>
</div> </div>
<div class="hr-line-dashed"></div>
<div class="form-group"><label class="col-sm-2 control-label"> 备注 </label>
<div class="col-sm-8"><input type="text" placeholder="comment" name="comment" class="form-control"></div>
</div>
<div class="hr-line-dashed"></div> <div class="hr-line-dashed"></div>
<div class="form-group"> <div class="form-group">
<div class="col-sm-4 col-sm-offset-2"> <div class="col-sm-4 col-sm-offset-2">
...@@ -120,7 +115,18 @@ ...@@ -120,7 +115,18 @@
{% block self_footer_js %} {% block self_footer_js %}
<script> <script>
$('document').ready(function(){
$('#id_use_default_auth').click(function(){
if ($(this).is(':checked')){
$('#admin_account').css('display', 'none')
}
else {
$('#admin_account').css('display', 'block')
}
})
});
<<<<<<< HEAD
$('document').ready(function(){ $('document').ready(function(){
$('#use_default').click(function(){ $('#use_default').click(function(){
if ($(this).is(':checked')){ if ($(this).is(':checked')){
...@@ -147,12 +153,38 @@ $('#assetForm').validator({ ...@@ -147,12 +153,38 @@ $('#assetForm').validator({
tip: "输入IP", tip: "输入IP",
ok: "", ok: "",
msg: {required: "必须填写!"} msg: {required: "必须填写!"}
=======
var required_fields = ["id_hostname", "id_ip", "id_port"];
required_fields.forEach(function(field) {
$('label[for="' + field + '"]').parent().addClass("required");
});
$('#assetForm').validator({
timely: 2,
theme: "yellow_right_effect",
rules: {
check_ip: [/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])){3}$/, 'ip地址不正确'],
check_port: [/^\d{1,5}$/, '端口号不正确'],
},
fields: {
"ip": {
rule: "required;check_ip",
tip: "输入IP",
ok: "",
msg: {required: "必须填写!"}
},
"port": {
rule: "required;check_port",
tip: "输入端口号",
ok: "",
msg: {required: "必须填写!"}
} }
}, },
valid: function(form) { valid: function(form) {
form.submit(); form.submit();
>>>>>>> cmdb
} }
}); });
</script> </script>
......
{% extends 'base.html' %}
{% load mytags %}
{% block content %}
{% include 'nav_cat_bar.html' %}
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-lg-10">
<div class="ibox float-e-margins">
<div id="ibox-content" class="ibox-title">
<h5> 填写资产基本信息 </h5>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<i class="fa fa-wrench"></i>
</a>
<a class="close-link">
<i class="fa fa-times"></i>
</a>
</div>
</div>
<div class="ibox-content">
<div class="panel blank-panel">
<div class="panel-options">
<ul class="nav nav-tabs">
<li class="active"><a href="/jasset/asset_add/" class="text-center"><i class="fa fa-laptop"></i> 单台添加 </a></li>
<li><a href="/jasset/host_add_multi" class="text-center"><i class="fa fa-bar-chart-o"></i> 批量添加 </a></li>
</ul>
</div>
<div class="panel-body">
<div class="tab-content">
<div id="tab-1" class="ibox float-e-margins tab-pane active">
{% if error %}
<div class="alert alert-warning text-center">{{ error }}</div>
{% endif %}
{% if msg %}
<div class="alert alert-success text-center">{{ msg }}</div>
{% endif %}
<form id="assetForm" method="post" class="form-horizontal">
<div class="form-group"><label class="col-sm-2 control-label"> IP地址<span class="red-fonts">*</span> </label>
<div class="col-sm-8"><input type="text" name="ip" placeholder="IP" class="form-control"></div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group">
<label class="col-sm-2 control-label"> 端口号<span class="red-fonts">*</span> </label>
<div class="col-sm-8">
<input type="text" placeholder="Port" name="port" class="form-control">
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group">
<label for="j_group" class="col-sm-2 control-label">管理账号</label>
<div class="col-sm-2">
<div class="radio i-checks">
<label>
<input type="checkbox" checked="" value="1" id="use_default_auth" name="use_default_auth"><span> 使用默认 </span>
</label>
</div>
</div>
</div>
<div class="form-group" id="admin_account" style="display: none">
<label class="col-sm-2 control-label"> 管理用户名<span class="red-fonts">*</span> </label>
<div class="col-sm-3">
<input type="text" placeholder="Username" name="username" class="form-control">
</div>
<label class="col-sm-1 control-label"> 密码<span class="red-fonts">*</span> </label>
<div class="col-sm-4">
<input type="password" placeholder="Password" name="password" class="form-control">
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group">
<label for="groups" class="col-sm-2 control-label">所属主机组</label>
<div class="col-sm-8">
<select id="groups" name="groups" class="form-control m-b" multiple size="10">
{% for asset_group in asset_group_all %}
<option type="checkbox" value="{{ asset_group.id }}">{{ asset_group.name }} {% if asset_group.comment %} --- {{ asset_group.comment }} {% endif %}</option>
{% endfor %}
</select>
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group"><label class="col-sm-2 control-label"> 是否激活<span class="red-fonts">*</span> </label>
<div class="col-sm-8">
<div class="radio i-checks">
<label> <input type="radio" checked="" value="1" name="is_active">激活 </label>
<label> <input type="radio" value="0" name="is_active"> 禁用</label>
</div>
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group"><label class="col-sm-2 control-label"> 备注 </label>
<div class="col-sm-8"><input type="text" placeholder="comment" name="comment" class="form-control"></div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-2">
<button class="btn btn-white" type="reset"> 重置 </button>
<button class="btn btn-primary" type="submit"> 提交 </button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block self_footer_js %}
<script>
$('document').ready(function(){
$('#use_default_auth').click(function(){
if ($(this).is(':checked')){
$('#admin_account').css('display', 'none')
}
else {
$('#admin_account').css('display', 'block')
}
})
});
$('#assetForm').validator({
timely: 2,
theme: "yellow_right_effect",
rules: {
check_ip: [/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])){3}$/, 'ip地址不正确'],
check_port: [/^\d{1,5}$/, '端口号不正确'],
},
fields: {
"ip": {
rule: "required;check_ip",
tip: "输入IP",
ok: "",
msg: {required: "必须填写!"}
},
"port": {
rule: "required;check_port",
tip: "输入端口号",
ok: "",
msg: {required: "必须填写!"}
}
},
valid: function(form) {
form.submit();
}
});
</script>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block content %}
{% include 'nav_cat_bar.html' %}
<style>
.file-box{ position:relative;width:340px}
.txt{ height:22px; border:1px solid #cdcdcd; width:180px;}
.file{ position:absolute; top:0; right:80px; height:24px; filter:alpha(opacity:0);opacity: 0;width:260px }
</style>
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-lg-10">
<div class="ibox float-e-margins">
<div id="ibox-content" class="ibox-title">
<h5> 填写主机基本信息 </h5>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<i class="fa fa-wrench"></i>
</a>
<ul class="dropdown-menu dropdown-user">
</ul>
<a class="close-link">
<i class="fa fa-times"></i>
</a>
</div>
</div>
<div class="ibox-content">
<div class="panel blank-panel">
<div class="panel-options">
<ul class="nav nav-tabs">
<li><a href="/jasset/asset_add/" class="text-center"><i class="fa fa-laptop"></i> 单台添加 </a></li>
<li class="active"><a href="/jasset/asset_add_batch/" class="text-center"><i class="fa fa-bar-chart-o"></i> 批量添加 </a></li>
</ul>
</div>
<div class="panel-body">
<div id="tab-2" class="ibox float-e-margins tab-pane active">
{% if emg %}
<div class="alert alert-warning text-center">{{ emg }}</div>
{% endif %}
{% if smg %}
<div class="alert alert-success text-center">{{ smg }}</div>
{% endif %}
<p>请下载Excel文件, 按照格式填写主机信息, 上传导入. <a href="/static/files/excels/asset.xlsx">点击下载模板</a></p>
<form action="/jasset/upload/" method="POST" enctype="multipart/form-data">
<div class="file-box">
<input id='textfield' />
<input type="button" class="btn btn-info btn-sm" name="file_name" value="点击选择文件">
<input type="file" name="file_name" class="file" id="fileField" size="28" onchange="document.getElementById('textfield').value=this.value" />
<button class="btn btn-primary btn-sm" type="submit">上传文件</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
\ No newline at end of file
This diff is collapsed.
{% extends 'base.html' %} {% extends 'base.html' %}
{% load mytags %} {% load mytags %}
{% load bootstrap %}
{% block content %} {% block content %}
{% include 'nav_cat_bar.html' %} {% include 'nav_cat_bar.html' %}
<div class="wrapper wrapper-content animated fadeInRight"> <div class="wrapper wrapper-content animated fadeInRight">
...@@ -32,53 +33,86 @@ ...@@ -32,53 +33,86 @@
<div class="alert alert-success text-center">{{ msg }}</div> <div class="alert alert-success text-center">{{ msg }}</div>
{% endif %} {% endif %}
<form id="assetForm" method="post" class="form-horizontal"> <form id="assetForm" method="post" class="form-horizontal">
<div class="form-group"><label class="col-sm-2 control-label"> IP地址<span class="red-fonts">*</span> </label>
<div class="col-sm-8"><input type="text" name="ip" value="{{ asset.ip }}" class="form-control"></div> {{ af.ip|bootstrap_horizontal }}
</div>
<div class="hr-line-dashed"></div> <div class="hr-line-dashed"></div>
<div class="form-group"> {{ af.hostname|bootstrap_horizontal }}
<label class="col-sm-2 control-label"> 端口号<span class="red-fonts">*</span> </label>
<div class="col-sm-8"> <div class="hr-line-dashed"></div>
<input type="text" value="{{ asset.port }}" name="port" class="form-control"> {{ af.other_ip|bootstrap_horizontal }}
</div>
</div> <div class="hr-line-dashed"></div>
{{ af.remote_ip|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.port|bootstrap_horizontal }}
<div class="hr-line-dashed"></div> <div class="hr-line-dashed"></div>
<div class="form-group"> <div class="form-group">
<label for="j_group" class="col-sm-2 control-label">使用默认管理账号</label> <label for="j_group" class="col-sm-2 control-label">管理账号 <span class="red-fonts">*</span></label>
<div class="col-sm-1"> <div class="col-sm-2">
<div class="radio i-checks"> <div class="radio i-checks">
<label> <label>
<input type="checkbox" {% ifequal asset.use_default 1 %} checked="" {% endifequal %} value="1" id="use_default" name="use_default"> <input type="checkbox" {% if asset.use_default_auth %} checked="" {% endif %} id="id_use_default_auth" name="use_default_auth"><span> 使用默认 </span>
</label> </label>
</div> </div>
</div> </div>
</div> </div>
<div class="form-group" id="admin_account" {% if asset.use_default_auth %} style="display: none" {% endif %}>
<div class="form-group" id="admin_account" {% ifequal asset.use_default 1 %} style="display: none" {% endifequal %}> <label class="col-sm-2 control-label"> 管理用户名 <span class="red-fonts">*</span> </label>
<label class="col-sm-2 control-label"> 管理用户名<span class="red-fonts">*</span> </label>
<div class="col-sm-3"> <div class="col-sm-3">
<input type="text" {% ifnotequal asset.use_default 1 %} value="{{ asset.username }}" {% endifnotequal %} name="username" class="form-control"> <input type="text" value="{{ asset.username }}" name="username" class="form-control">
</div> </div>
<label class="col-sm-1 control-label"> 密码<span class="red-fonts">*</span> </label> <label class="col-sm-1 control-label"> 密码<span class="red-fonts">*</span> </label>
<div class="col-sm-4"> <div class="col-sm-4">
<input type="password" {% ifnotequal asset.use_default 1 %} value="{{ asset.password }}" {% endifnotequal %} name="password" class="form-control"> <input type="password" value="{{ asset.password }}" name="password" class="form-control">
</div> </div>
</div> </div>
<div class="hr-line-dashed"></div> <div class="hr-line-dashed"></div>
<div class="form-group"> {{ af.group|bootstrap_horizontal }}
<label for="groups" class="col-sm-2 control-label">所属主机组</label>
<div class="col-sm-8"> <div class="hr-line-dashed"></div>
<select id="groups" name="groups" class="form-control m-b" multiple size="10"> {{ af.idc|bootstrap_horizontal }}
{% for g in egroup %}
<option type="checkbox" value="{{ g.id }}">{{ g.name }} {% if g.comment %} --- {{ g.comment }} {% endif %}</option> <div class="hr-line-dashed"></div>
{% endfor %} {{ af.brand|bootstrap_horizontal }}
</select>
</div> <div class="hr-line-dashed"></div>
</div> {{ af.cpu|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.memory|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.disk|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.number|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.sn|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.cabinet|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.position|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.asset_type|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.env|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.status|bootstrap_horizontal }}
{# <div class="hr-line-dashed"></div>#}
{# {{ af.is_active|bootstrap_horizontal }}#}
<div class="hr-line-dashed"></div> <div class="hr-line-dashed"></div>
<div class="form-group"><label class="col-sm-2 control-label"> 是否激活<span class="red-fonts">*</span> </label> <div class="form-group"><label class="col-sm-2 control-label"> 是否激活<span class="red-fonts">*</span> </label>
...@@ -96,9 +130,7 @@ ...@@ -96,9 +130,7 @@
</div> </div>
<div class="hr-line-dashed"></div> <div class="hr-line-dashed"></div>
<div class="form-group"><label class="col-sm-2 control-label"> 备注 </label> {{ af.comment|bootstrap_horizontal }}
<div class="col-sm-8"><input type="text" value="{{ asset.comment }}" name="comment" class="form-control"></div>
</div>
<div class="hr-line-dashed"></div> <div class="hr-line-dashed"></div>
<div class="form-group"> <div class="form-group">
...@@ -121,9 +153,8 @@ ...@@ -121,9 +153,8 @@
{% block self_footer_js %} {% block self_footer_js %}
<script> <script>
$('document').ready(function(){
$('document').ready(function(){ $('#id_use_default_auth').click(function(){
$('#use_default').click(function(){
if ($(this).is(':checked')){ if ($(this).is(':checked')){
$('#admin_account').css('display', 'none') $('#admin_account').css('display', 'none')
} }
...@@ -131,9 +162,14 @@ $('document').ready(function(){ ...@@ -131,9 +162,14 @@ $('document').ready(function(){
$('#admin_account').css('display', 'block') $('#admin_account').css('display', 'block')
} }
}) })
}); });
var required_fields = ["id_ip", "id_port"];
required_fields.forEach(function(field) {
$('label[for="' + field + '"]').parent().addClass("required");
});
$('#assetForm').validator({ $('#assetForm').validator({
timely: 2, timely: 2,
theme: "yellow_right_effect", theme: "yellow_right_effect",
rules: { rules: {
...@@ -157,7 +193,7 @@ $('#assetForm').validator({ ...@@ -157,7 +193,7 @@ $('#assetForm').validator({
valid: function(form) { valid: function(form) {
form.submit(); form.submit();
} }
}); });
</script> </script>
......
<html>
<head>
<link href="/static/css/bootstrap.min.css" rel="stylesheet">
<link href="/static/font-awesome/css/font-awesome.css" rel="stylesheet">
<link href="/static/css/plugins/iCheck/custom.css" rel="stylesheet">
<link href="/static/css/animate.css" rel="stylesheet">
<link href="/static/css/style.css" rel="stylesheet">
<script src="/static/js/jquery-2.1.1.js"></script>
{# <style>#}
{# body {background: #ffffff;}#}
{# </style>#}
</head>
{% load bootstrap %}
{% block content %}
<body>
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-lg-10">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5 class="text-center"> 填写修改主机信息. </h5>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<i class="fa fa-wrench"></i>
</a>
<ul class="dropdown-menu dropdown-user"></ul>
<a class="close-link">
<i class="fa fa-times"></i>
</a>
</div>
</div>
<div class="ibox-content">
<form class="form-horizontal" action="" id="signupForm" method="post" name="horizontal" role="form" autocomplete="off">
{% csrf_token %}
<input id="ids" style="display: none">
{{ af.env|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.idc|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.port|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
<div class="form-group">
<label for="j_group" class="col-sm-2 control-label">管理账号</label>
<div class="col-sm-2">
<div class="radio i-checks">
<label>
<input type="radio" checked="" value="no_action" name="use_default_auth"><span> 不修改 </span>
</label>
</div>
<div class="radio i-checks">
<label>
<input type="radio" name="use_default_auth"><span> 使用默认 </span>
</label>
</div>
<div class="radio i-checks">
<label>
<input type="radio" id="id_use_default_auth" name="use_default_auth"><span> 用户名密码 </span>
</label>
</div>
</div>
</div>
<div class="form-group" id="admin_account" style="display: none">
<label class="col-sm-2 control-label"> 管理用户名<span class="red-fonts"> *</span></label>
<div class="col-sm-3">
<input type="text" placeholder="Username" name="username" class="form-control">
</div>
<label class="col-sm-1 control-label"> 密码<span class="red-fonts">*</span> </label>
<div class="col-sm-4">
<input type="password" placeholder="Password" name="password" class="form-control">
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group">
<label for="groups" class="col-sm-2 control-label">所属主机组</label>
<div class="col-sm-3">
<select id="groups" size="10" class="form-control m-b" multiple>
{% for asset_group in asset_group_all %}
<option value="{{ asset_group.id }}">{{ asset_group.name }}</option>
{% endfor %}
</select>
</div>
<div class="col-sm-1">
<div class="btn-group" style="margin-top: 50px;">
<button type="button" class="btn btn-white" onclick="move_right('groups', 'groups_selected')"><i class="fa fa-chevron-right"></i></button>
<button type="button" class="btn btn-white" onclick="move_left('groups_selected', 'groups')"><i class="fa fa-chevron-left"></i> </button>
</div>
</div>
<div class="col-sm-3">
<div>
<select id="groups_selected" name="project" class="form-control m-b" size="10" multiple>
</select>
</div>
</div>
</div>
<div class="hr-line-dashed"></div>
{{ af.cabinet|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ af.comment|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-5">
<button class="btn btn-white" type="submit"> 重置 </button>
<button class="btn btn-primary" id="host_edit"> 提交 </button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function() {
$('#host_edit').click(function () {
var args = {};
var match = null;
var uuid = decodeURIComponent(location.search.substring(1));
var reg = /(?:([^&amp;]+)=([^&amp;]+))/g;
while((match = reg.exec(uuid))!==null){
args[match[1]] = match[2];
}
var ids = args['uuid'];
$('#uuid').val(ids)
});
$('#id_use_default_auth').click(function(){
if ($(this).is(':checked')){
$('#admin_account').css('display', 'block')
}
else {
$('#admin_account').css('display', 'none')
}
})
});
function move_left(from, to) {
$("#"+from+" option").each(function(){
if ( $(this).prop("selected") == true ) {
$("#"+to).append(this);
$(this).attr("selected",'false');
}
$(this).attr("selected",'true');
});
}
function move_right(from, to) {
$("#"+from+" option").each(function(){
if ( $(this).prop("selected") == true ) {
$("#"+to).append(this);
}
});
}
function move_all(from, to){
$("#"+from).children().each(function(){
$("#"+to).append(this);
});
}
</script>
{% endblock content %}
</body>
</html>
<div class="col-md-12 column">
<div class="alert alert-success alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<h4>
</h4> <strong>Nice!</strong> excel文件已生成请点击 <a href="/static/files/excels/{{ file_name }}" target="_blank" class="alert-link">下载</a>
</div>
</div>
\ No newline at end of file
This diff is collapsed.
{% for field in af %}
<div class="alert alert-warning text-center"> {{ field.errors }}</div>
{{ field.label_tag }}: {{ field }}
{% endfor %}
{% if af.errors %}
<ul>
{% for error in af.errors %}
<li><strong>{{ error }}</strong></li>
{% endfor %}
</ul>
{% endif %}
\ No newline at end of file
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<div class="col-lg-10"> <div class="col-lg-10">
<div class="ibox float-e-margins"> <div class="ibox float-e-margins">
<div id="ibox-content" class="ibox-title"> <div id="ibox-content" class="ibox-title">
<h5> 填写资产组基本信息 </h5> <h5> 填写主机组基本信息 </h5>
<div class="ibox-tools"> <div class="ibox-tools">
<a class="collapse-link"> <a class="collapse-link">
<i class="fa fa-chevron-up"></i> <i class="fa fa-chevron-up"></i>
...@@ -30,37 +30,34 @@ ...@@ -30,37 +30,34 @@
<a class="dropdown-toggle" data-toggle="dropdown" href="#"> <a class="dropdown-toggle" data-toggle="dropdown" href="#">
<i class="fa fa-wrench"></i> <i class="fa fa-wrench"></i>
</a> </a>
<ul class="dropdown-menu dropdown-user">
<li><a href="#">未启用 1</a>
</li>
<li><a href="#">未启用 2</a>
</li>
</ul>
<a class="close-link"> <a class="close-link">
<i class="fa fa-times"></i> <i class="fa fa-times"></i>
</a> </a>
</div> </div>
</div> </div>
{# <select id="assets_total" name="assets" class="form-control m-b" size="12" multiple style="display: none">#} <select id="assets_total" name="assets" class="form-control m-b" size="12" multiple style="display: none">
{# {% for asset in assets_all %}#} {% for asset in asset_all %}
{# <option value="{{ asset.id }}">{{ asset.ip }}</option>#} <option value="{{ asset.id }}">{{ asset.ip }}</option>
{# {% endfor %}#} {% endfor %}
{# </select>#} </select>
{##}
{# <select id="asset_select_total" name="j_hosts" class="form-control m-b" size="12" multiple style="display: none">#}
{# {% for asset in eposts %}#}
{# <option value="{{ asset.id }}">{{ asset.ip }}</option>#}
{# {% endfor %}#}
{# </select>#}
<div class="ibox-content"> <div class="ibox-content">
{% if error %} {% if emg %}
<div class="alert alert-warning text-center">{{ error }}</div> <div class="alert alert-warning text-center">{{ emg }}</div>
{% endif %} {% endif %}
{% if msg %} {% if smg %}
<div class="alert alert-success text-center">{{ msg }}</div> <div class="alert alert-success text-center">{{ smg }}</div>
{% endif %} {% endif %}
<form id="assetForm" method="post" class="form-horizontal"> <form id="assetForm" method="post" class="form-horizontal">
<div class="form-group"> <div class="form-group"><label class="col-sm-2 control-label"> 主机组名<span class="red-fonts">*</span></label>
<label class="col-sm-2 control-label"> 主机组名<span class="red-fonts">*</span></label> <div class="col-sm-8" name="group_id" value="{{ post.id }}"><input type="text" value="{{ group.name }}" placeholder="Name" name="name" class="form-control"></div>
<div class="col-sm-8">
<input type="text" placeholder="Name" name="name" class="form-control">
</div>
</div> </div>
<div class="hr-line-dashed"></div> <div class="hr-line-dashed"></div>
...@@ -92,7 +89,7 @@ ...@@ -92,7 +89,7 @@
<div class="col-sm-1"> <div class="col-sm-1">
<div class="btn-group" style="margin-top: 60px;"> <div class="btn-group" style="margin-top: 60px;">
<button type="button" class="btn btn-white" onclick="move('assets', 'asset_select', 'assets_total', 'asset_select_total' )"><i class="fa fa-chevron-right"></i></button> <button type="button" class="btn btn-white" onclick="move('assets', 'asset_select', 'assets_total', 'asset_select_total' )"><i class="fa fa-chevron-right"></i></button>
<button type="button" class="btn btn-white" onclick="move('asset_select', 'assets', 'asset_select_total', 'assets_total')"><i class="fa fa-chevron-left"></i> </button> <button type="button" class="btn btn-white" onclick="move_left('asset_select', 'assets', 'asset_select_total', 'assets_total')"><i class="fa fa-chevron-left"></i> </button>
</div> </div>
</div> </div>
...@@ -104,18 +101,15 @@ ...@@ -104,18 +101,15 @@
</div> </div>
<div class="hr-line-dashed"></div> <div class="hr-line-dashed"></div>
<div class="form-group"> <div class="form-group"><label class="col-sm-2 control-label"> 备注 </label>
<label class="col-sm-2 control-label"> 备注 </label> <div class="col-sm-8"><input type="text" value="" placeholder="comment" name="comment" class="form-control"></div>
<div class="col-sm-8">
<input type="text" placeholder="Comment" name="comment" class="form-control">
</div>
</div> </div>
<div class="hr-line-dashed"></div> <div class="hr-line-dashed"></div>
<div class="form-group"> <div class="form-group">
<div class="col-sm-4 col-sm-offset-2"> <div class="col-sm-4 col-sm-offset-5">
<button class="btn btn-white" type="reset"> 重置 </button> <button class="btn btn-white" type="submit"> 重置 </button>
<button class="btn btn-primary" type="submit" onclick="on_submit('groups_selected') "> 提交 </button> <button class="btn btn-primary" id="submit_button" type="submit" onclick="on_submit('groups_selected') "> 提交 </button>
</div> </div>
</div> </div>
</form> </form>
...@@ -159,16 +153,6 @@ ...@@ -159,16 +153,6 @@
}) })
} }
// $('#search').keyup(function() {
// var $rows = $('#hosts option');
// var val = $.trim($(this).val()).replace(/ +/g, ' ').toLowerCase();
//
// $rows.show().filter(function() {
// var text = $(this).text().replace(/\s+/g, ' ').toLowerCase();
// return !~text.indexOf(val);
// }).hide();
// });
function change_dept(dept_id){ function change_dept(dept_id){
$.get('/jasset/dept_host_ajax/', $.get('/jasset/dept_host_ajax/',
{'id': dept_id}, {'id': dept_id},
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
<div class="ibox-content"> <div class="ibox-content">
<div class=""> <div class="">
<a target="_blank" href="/jasset/host_add" class="btn btn-sm btn-primary"> 添加主机 </a> <a target="_blank" href="/jasset/asset_add" class="btn btn-sm btn-primary"> 添加主机 </a>
<b class="pull-right">提示: 此页面删除只从本主机组中剔除主机 </b> <b class="pull-right">提示: 此页面删除只从本主机组中剔除主机 </b>
</div> </div>
...@@ -41,9 +41,8 @@ ...@@ -41,9 +41,8 @@
<th class="text-center"><input id="checkall" type="checkbox" class="i-checks" name="checkall" value="checkall" data-editable='false' onclick="check_all('contents_form')"></th> <th class="text-center"><input id="checkall" type="checkbox" class="i-checks" name="checkall" value="checkall" data-editable='false' onclick="check_all('contents_form')"></th>
<th class="text-center" name="j_ip"> IP地址 </th> <th class="text-center" name="j_ip"> IP地址 </th>
<th class="text-center"> 端口号 </th> <th class="text-center"> 端口号 </th>
<th class="text-center" name="j_type"> 登录方式 </th>
<th class="text-center" name="j_idc"> 所属IDC </th> <th class="text-center" name="j_idc"> 所属IDC </th>
<th class="text-center" id="group_id" value="{{ group.id }}"> 所属业务</th> <th class="text-center" id="group_id" value="{{ group.id }}"> 所属主机</th>
<th class="text-center"> 是否激活 </th> <th class="text-center"> 是否激活 </th>
<th class="text-center" name="j_time"> 添加时间 </th> <th class="text-center" name="j_time"> 添加时间 </th>
<th class="text-center" name="j_comment"> 备注 </th> <th class="text-center" name="j_comment"> 备注 </th>
...@@ -51,21 +50,20 @@ ...@@ -51,21 +50,20 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for post in contacts.object_list %} {% for asset in contacts.object_list %}
<tr class="gradeX"> <tr class="gradeX">
<td class="text-center" name="j_id" value="{{ post.id }}" data-editable='false'><input name="id" value="{{ post.id }}" type="checkbox" class="i-checks"></td> <td class="text-center" name="j_id" value="{{ asset.id }}" data-editable='false'><input name="id" value="{{ asset.id }}" type="checkbox" class="i-checks"></td>
<td class="text-center" name="j_ip"> {{ post.ip }} </td> <td class="text-center" name="j_ip"> {{ asset.ip }} </td>
<td class="text-center" name="j_port"> {{ post.port }} </td> <td class="text-center" name="j_port"> {{ asset.port }} </td>
<td class="text-center" name="j_type"> {{ post.login_type|get_login_type }} </td> <td class="text-center" name="j_idc"> {{ asset.idc.name }} </td>
<td class="text-center" name="j_idc"> {{ post.idc.name }} </td> <td class="text-center" name="j_group">{{ asset.bis_group.all | group_str2 }}</td>
<td class="text-center" name="j_group">{{ post.bis_group.all | group_str2 }}</td> <td class="text-center" name="j_active"> {{ asset.is_active|bool2str }} </td>
<td class="text-center" name="j_active"> {{ post.is_active|bool2str }} </td> <td class="text-center"> {{ asset.date_added|date:"Y-m-d H:i:s" }} </td>
<td class="text-center"> {{ post.date_added|date:"Y-m-d H:i:s" }} </td> <td class="text-center" name="j_comment"> {{ asset.comment }} </td>
<td class="text-center" name="j_comment"> {{ post.comment }} </td>
<td class="text-center" data-editable='false'> <td class="text-center" data-editable='false'>
<a href="/jasset/host_detail/?id={{ post.id }}" class="iframe btn btn-xs btn-primary">详情</a> <a href="/jasset/host_detail/?id={{ asset.id }}" class="iframe btn btn-xs btn-primary">详情</a>
<a href="/jasset/host_edit/?id={{ post.id }}" class="btn btn-xs btn-info">编辑</a> <a href="/jasset/host_edit/?id={{ asset.id }}" class="btn btn-xs btn-info">编辑</a>
<a href="/jasset/group_del_host/?id={{ post.id }}&gid={{ group.id }}" class="btn btn-xs btn-danger">删除</a> <a href="/jasset/group_del_host/?id={{ asset.id }}&gid={{ group.id }}" class="btn btn-xs btn-danger">删除</a>
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
...@@ -165,7 +163,7 @@ ...@@ -165,7 +163,7 @@
selectData = GetTableDataBox(); selectData = GetTableDataBox();
if (selectData[1] != 0) { if (selectData[1] != 0) {
$.ajax({ $.ajax({
type: "post", type: "asset",
url: "/jasset/host_edit/batch/", url: "/jasset/host_edit/batch/",
data: {"editable": selectData[0], "len_table": selectData[1]}, data: {"editable": selectData[0], "len_table": selectData[1]},
success: function (data) { success: function (data) {
......
...@@ -43,13 +43,13 @@ ...@@ -43,13 +43,13 @@
</div> </div>
<select id="assets_total" name="assets" class="form-control m-b" size="12" multiple style="display: none"> <select id="assets_total" name="assets" class="form-control m-b" size="12" multiple style="display: none">
{% for asset in posts %} {% for asset in asset_all %}
<option value="{{ asset.id }}">{{ asset.ip }}</option> <option value="{{ asset.id }}">{{ asset.ip }}</option>
{% endfor %} {% endfor %}
</select> </select>
<select id="asset_select_total" name="j_hosts" class="form-control m-b" size="12" multiple style="display: none"> <select id="asset_select_total" name="asset_select" class="form-control m-b" size="12" multiple style="display: none">
{% for asset in eposts %} {% for asset in asset_select %}
<option value="{{ asset.id }}">{{ asset.ip }}</option> <option value="{{ asset.id }}">{{ asset.ip }}</option>
{% endfor %} {% endfor %}
</select> </select>
...@@ -63,14 +63,7 @@ ...@@ -63,14 +63,7 @@
{% endif %} {% endif %}
<form id="assetForm" method="post" class="form-horizontal"> <form id="assetForm" method="post" class="form-horizontal">
<div class="form-group"><label class="col-sm-2 control-label"> 主机组名<span class="red-fonts">*</span></label> <div class="form-group"><label class="col-sm-2 control-label"> 主机组名<span class="red-fonts">*</span></label>
<div class="col-sm-8" name="group_id" value="{{ post.id }}"><input type="text" value="{{ group.name }}" placeholder="网站" name="j_group" class="form-control"></div> <div class="col-sm-8" name="group_id" value="{{ group.id }}"><input type="text" value="{{ group.name }}" placeholder="Name" name="name" class="form-control"></div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group">
<label for="j_dept" class="col-lg-2 control-label">所属部门<span class="red-fonts" style="">*</span></label>
<input type="text" name="j_dept" value="{{ group.dept.id }}" style="display: none">
<div class="col-sm-8"><input type="text" value="{{ group.dept.name }}" class="form-control" readonly="readonly"></div>
</div> </div>
<div class="hr-line-dashed"></div> <div class="hr-line-dashed"></div>
...@@ -92,8 +85,8 @@ ...@@ -92,8 +85,8 @@
<div class="col-sm-4"> <div class="col-sm-4">
<div> <div>
<select id="assets" name="assets" class="form-control m-b" size="12" multiple> <select id="assets" name="assets" class="form-control m-b" size="12" multiple>
{% for post in posts %} {% for asset in asset_no_select %}
<option value="{{ post.id }}">{{ post.ip }}</option> <option value="{{ asset.id }}">{{ asset.ip }}</option>
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
...@@ -108,8 +101,8 @@ ...@@ -108,8 +101,8 @@
<div class="col-sm-3"> <div class="col-sm-3">
<div> <div>
<select id="asset_select" name="j_hosts" class="form-control m-b" size="12" multiple> <select id="asset_select" name="asset_select" class="form-control m-b" size="12" multiple>
{% for asset in eposts %} {% for asset in asset_select %}
<option value="{{ asset.id }}">{{ asset.ip }}</option> <option value="{{ asset.id }}">{{ asset.ip }}</option>
{% endfor %} {% endfor %}
</select> </select>
...@@ -119,7 +112,7 @@ ...@@ -119,7 +112,7 @@
<div class="hr-line-dashed"></div> <div class="hr-line-dashed"></div>
<div class="form-group"><label class="col-sm-2 control-label"> 备注 </label> <div class="form-group"><label class="col-sm-2 control-label"> 备注 </label>
<div class="col-sm-8"><input type="text" value="{{ group.comment }}" placeholder=包括web组所有主机 name="j_comment" class="form-control"></div> <div class="col-sm-8"><input type="text" value="{{ group.comment }}" name="comment" class="form-control"></div>
</div> </div>
<div class="hr-line-dashed"></div> <div class="hr-line-dashed"></div>
......
{% extends 'base.html' %}
{% block content %}
{% load bootstrap %}
{% include 'nav_cat_bar.html' %}
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-lg-10">
<div class="ibox float-e-margins">
<div id="ibox-content" class="ibox-title">
<h5> 填写IDC基本信息 </h5>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<i class="fa fa-wrench"></i>
</a>
<ul class="dropdown-menu dropdown-user">
</ul>
<a class="close-link">
<i class="fa fa-times"></i>
</a>
</div>
</div>
<div class="ibox-content">
{% if emg %}
<div class="alert alert-warning text-center">{{ emg }}</div>
{% endif %}
{% if smg %}
<div class="alert alert-success text-center">{{ smg }}</div>
{% endif %}
<form id="assetForm" method="post" class="form-horizontal">
{{ idc_form.name|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ idc_form.bandwidth|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ idc_form.operator|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ idc_form.linkman|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ idc_form.phone|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ idc_form.address|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ idc_form.network|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ idc_form.comment|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-5">
<button class="btn btn-white" type="submit"> 重置 </button>
<button class="btn btn-primary" type="sumbit"> 提交 </button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script>
var required_fields = ["id_name"];
required_fields.forEach(function(field) {
$('label[for="' + field + '"]').parent().addClass("required");
});
$('#assetForm').validator({
timely: 2,
theme: "yellow_right_effect",
fields: {
"j_idc": {
rule: "required",
tip: "输入IDC名",
ok: "",
msg: {required: "IDC名必须填写!"},
data: {'data-ok':"主机名可以使用", 'data-msg-required': '主机名已正确'}
}
},
valid: function(form) {
form.submit();
}
});
</script>
{% endblock %}
\ No newline at end of file
This diff is collapsed.
{% extends 'base.html' %}
{% block content %}
{% load bootstrap %}
{% include 'nav_cat_bar.html' %}
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-lg-10">
<div class="ibox float-e-margins">
<div id="ibox-content" class="ibox-title">
<h5> 填写IDC基本信息 </h5>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<i class="fa fa-wrench"></i>
</a>
<ul class="dropdown-menu dropdown-user">
<li><a href="#">未启用 1</a>
</li>
<li><a href="#">未启用 2</a>
</li>
</ul>
<a class="close-link">
<i class="fa fa-times"></i>
</a>
</div>
</div>
<div class="ibox-content">
{% if emg %}
<div class="alert alert-warning text-center">{{ emg }}</div>
{% endif %}
{% if smg %}
<div class="alert alert-success text-center">{{ smg }}</div>
{% endif %}
<form id="assetForm" method="post" class="form-horizontal">
{{ idc_form.name|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ idc_form.bandwidth|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ idc_form.operator|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ idc_form.linkman|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ idc_form.phone|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ idc_form.address|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ idc_form.network|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ idc_form.comment|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-5">
<button class="btn btn-white" type="submit"> 重置 </button>
<button class="btn btn-primary" type="sumbit"> 提交 </button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script>
var required_fields = ["id_name"];
required_fields.forEach(function(field) {
$('label[for="' + field + '"]').parent().addClass("required");
});
$('#assetForm').validator({
timely: 2,
theme: "yellow_right_effect",
fields: {
"j_idc": {
rule: "required",
tip: "输入IDC名",
ok: "",
msg: {required: "IDC名必须填写!"},
data: {'data-ok':"主机名可以使用", 'data-msg-required': '主机名已正确'}
}
},
valid: function(form) {
form.submit();
}
});
</script>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load mytags %}
{% block content %}
{% include 'nav_cat_bar.html' %}
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-lg-10">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5> IDC详细信息列表</h5>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<i class="fa fa-wrench"></i>
</a>
<ul class="dropdown-menu dropdown-user">
<li><a href="#">未启用 1</a>
</li>
<li><a href="#">未启用 2</a>
</li>
</ul>
<a class="close-link">
<i class="fa fa-times"></i>
</a>
</div>
</div>
<div class="ibox-content">
<div class="">
<a target="_blank" href="/jasset/idc_add" class="btn btn-sm btn-primary "> 添加IDC </a>
<form id="search_form" method="get" action="" class="pull-right mail-search">
<div class="input-group">
<input type="text" class="form-control input-sm" id="search_input" name="keyword" placeholder="Search">
<input type="text" style="display: none">
<div class="input-group-btn">
<button id='search_btn' type="submit" class="btn btn-sm btn-primary">
Search
</button>
</div>
</div>
</form>
</div>
<form id="contents_form" name="contents_form">
<table class="table table-striped table-bordered table-hover " id="editable" >
<thead>
<tr>
{% ifequal session_role_id 2 %}
<th class="text-center"><input id="checkall" type="checkbox" class="i-checks" name="checkall" value="checkall" data-editable='false' onclick="check_all('contents_form')"></th>
{% endifequal %}
<th class="text-center"> 机房名 </th>
<th class="text-center"> 主机数量 </th>
<th class="text-center"> 备注 </th>
<th class="text-center"> 操作 </th>
</tr>
</thead>
<tbody>
{% for post in contacts.object_list %}
<tr class="gradeX">
<td class="text-center" name="j_id" value="{{ post.id }}" data-editable='false'><input name="id" value="{{ post.id }}" type="checkbox" class="i-checks"></td>
<td class="text-center"> {{ post.name }} </td>
<td class="text-center"> <a href="/jasset/idc_detail/?id={{ post.id }}">{{ post.asset_set.count }}</a> </td>
<td class="text-center"> {{ post.comment }} </td>
<td class="text-center">
<a href="/jasset/idc_detail/?id={{ post.id }}" class="iframe btn btn-xs btn-primary">详情</a>
<a href="/jasset/idc_edit/?id={{ post.id }}" class="btn btn-xs btn-info">编辑</a>
<a href="/jasset/idc_del/?id={{ post.id }}" class="btn btn-xs btn-danger">删除</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="row">
<div class="col-sm-6">
{% ifequal session_role_id 2 %}
<input type="button" id="del_button" class="btn btn-danger btn-sm" name="del_button" value="删除" onclick="del('contents_form')" />
<!--<input type="button" id="alter_button" class="btn btn-warning btn-sm" name="alter_button" value="修改" onclick="alter('contents_form')" />-->
{% endifequal %}
</div>
{% include 'paginator.html' %}
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script>
function del(form) {
var checkboxes = document.getElementById(form);
var id_list = {};
var j = 0;
for (var i = 0; i < checkboxes.elements.length; i++) {
if (checkboxes.elements[i].type == "checkbox" && checkboxes.elements[i].checked == true && checkboxes.elements[i].value != "checkall") {
id_list[j] = checkboxes.elements[i].value;
j++;
}
}
if (confirm("确定删除")) {
$.ajax({
type: "POST",
url: "/jasset/idc_del/?id=multi",
data: {"id_list": id_list, "len_list": j},
success: function (data) {
window.open("/jasset/idc_list/", "_self");
}
});
}
}
</script>
{% endblock %}
\ No newline at end of file
...@@ -21,7 +21,9 @@ ...@@ -21,7 +21,9 @@
<li class="group_add"><a href="/jasset/group_add/">添加资产组</a></li> <li class="group_add"><a href="/jasset/group_add/">添加资产组</a></li>
<li class="group_list group_detail group_edit"><a href="/jasset/group_list/">查看资产组</a></li> <li class="group_list group_detail group_edit"><a href="/jasset/group_list/">查看资产组</a></li>
<li class="asset_add asset_add_multi"><a href="/jasset/asset_add/">添加资产</a></li> <li class="asset_add asset_add_multi"><a href="/jasset/asset_add/">添加资产</a></li>
<li class="host_list host_detail host_edit"><a href="/jasset/asset_list/">查看资产<span class="label label-info pull-right">{{ host_active_num }}/{{ host_total_num}}</span></a></li> <li class="asset_list asset_detail asset_edit"><a href="/jasset/asset_list/">查看资产<span class="label label-info pull-right">{{ host_active_num }}/{{ host_total_num}}</span></a></li>
<li class="idc_add"><a href="/jasset/idc_add/">添加机房</a></li>
<li class="idc_list idc_detail idc_edit"><a href="/jasset/idc_list/">查看机房</a></li>
</ul> </ul>
</li> </li>
<li id="jperm"> <li id="jperm">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment