diff --git a/jasset/urls.py b/jasset/urls.py index bf108e16b..280ed090c 100644 --- a/jasset/urls.py +++ b/jasset/urls.py @@ -4,8 +4,16 @@ from jasset.views import * urlpatterns = patterns('', url(r'^$', index), - url(r'jadd', jadd), - url(r'jlist', jlist), - url(r'jadd_idc', jadd_idc), - url(r'jlist_idc', jlist_idc), + url(r'^host_add/$', jadd_host), + url(r'^host_list/$', jlist_host), + url(r"^(\d+.\d+.\d+.\d+)/$",jlist_ip), + url(r'^idc_add/$', jadd_idc), + url(r'^idc_list/$', jlist_idc), + url(r'^idc_del/(\d+)/$', idc_del), + url(r'^group_add/$', jadd_group), + url(r'^group_list/$', jlist_group), + url(r'^group_del/(\d+)/$', group_del), + url(r'^host_del/(\d+.\d+.\d+.\d+)/$', host_del), + url(r'^host_edit/(\d+.\d+.\d+.\d+)/$', host_edit), + url(r'^test/$', test), ) \ No newline at end of file diff --git a/jasset/views.py b/jasset/views.py index a0d7e1c73..02f887b69 100644 --- a/jasset/views.py +++ b/jasset/views.py @@ -1,28 +1,25 @@ # coding:utf-8 -import datetime -from django.shortcuts import render -from django.http import HttpResponse +from django.http import HttpResponseRedirect from django.template import RequestContext from django.shortcuts import render_to_response -from django.http import HttpResponseRedirect -from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger +from django.core.paginator import Paginator, EmptyPage -from models import IDC, Asset, UserGroup +from models import IDC, Asset, BisGroup from connect import PyCrypt, KEY +cryptor = PyCrypt(KEY) + def index(request): return render_to_response('jasset/jasset.html', ) -def jadd(request): - global j_passwd +def jadd_host(request): + login_types = {'L': 'LDAP', 'S': 'SSH_KEY', 'P': 'PASSWORD', 'M': 'MAP'} + header_title, path1, path2 = u'添加主机 | Add Host', u'资产管理', u'添加主机' groups = [] - cryptor = PyCrypt(KEY) eidc = IDC.objects.all() - egroup = UserGroup.objects.all() - is_actived = {'active': 1, 'no_active': 0} - login_typed = {'LDAP': 'L', 'SSH_KEY': 'S', 'PASSWORD': 'P', 'MAP': 'M'} + egroup = BisGroup.objects.all() if request.method == 'POST': j_ip = request.POST.get('j_ip') @@ -32,56 +29,48 @@ def jadd(request): j_group = request.POST.getlist('j_group') j_active = request.POST.get('j_active') j_comment = request.POST.get('j_comment') - if j_type == 'MAP': - j_user = request.POST.get('j_user') - j_password = cryptor.encrypt(request.POST.get('j_password')) - j_root = request.POST.get('j_root') - j_passwd = cryptor.encrypt(request.POST.get('j_passwd')) - j_idc = IDC.objects.get(name=j_idc) + for group in j_group: - c = UserGroup.objects.get(name=group) + c = BisGroup.objects.get(name=group) groups.append(c) if Asset.objects.filter(ip=str(j_ip)): emg = u'该IP已存在!' - return render_to_response('jasset/jadd.html', {'emg': emg, 'j_ip': j_ip}) + return render_to_response('jasset/host_add.html', locals(), context_instance=RequestContext(request)) - elif j_type == 'MAP': - a = Asset(ip=j_ip, - port=j_port, - login_type=login_typed[j_type], - idc=j_idc, - is_active=int(is_actived[j_active]), + if j_type == 'M': + j_user = request.POST.get('j_user') + j_password = cryptor.encrypt(request.POST.get('j_password')) + j_root = request.POST.get('j_root') + j_passwd = cryptor.encrypt(request.POST.get('j_passwd')) + a = Asset(ip=j_ip, port=j_port, + login_type=j_type, idc=j_idc, + is_active=int(j_active), comment=j_comment, username_common=j_user, password_common=j_password, username_super=j_root, password_super=j_passwd,) else: - a = Asset(ip=j_ip, - port=j_port, - login_type=login_typed[j_type], - idc=j_idc, - is_active=int(is_actived[j_active]), + a = Asset(ip=j_ip, port=j_port, + login_type=j_type, idc=j_idc, + is_active=int(j_active), comment=j_comment) a.save() - a.group = groups + print 'ok' + a.bis_group = groups a.save() - - return render_to_response('jasset/jadd.html', - {'header_title': u'添加主机 | Add Host', - 'path1': '资产管理', - 'path2': '添加主机', - 'eidc': eidc, - 'egroup': egroup, } - ) + smg = u'主机 %s 添加成功' %j_ip + return render_to_response('jasset/host_add.html', locals(), context_instance=RequestContext(request)) -def jlist(request): +def jlist_host(request): + header_title, path1, path2 = u'查看主机 | List Host', u'资产管理', u'查看主机' + login_types = {'L': 'LDAP', 'S': 'SSH_KEY', 'P': 'PASSWORD', 'M': 'MAP'} posts = contact_list = Asset.objects.all().order_by('ip') print posts - paginator = Paginator(contact_list, 5) + p = paginator = Paginator(contact_list, 5) try: page = int(request.GET.get('page', '1')) except ValueError: @@ -92,19 +81,125 @@ def jlist(request): except (EmptyPage, InvalidPage): contacts = paginator.page(paginator.num_pages) - return render_to_response('jasset/jlist.html', - {"contacts": contacts, - 'p': paginator, - 'posts': posts, - 'header_title': u'查看主机 | List Host', - 'path1': '资产管理', - 'path2': '查看主机', }, - context_instance=RequestContext(request)) + return render_to_response('jasset/host_list.html', locals(), context_instance=RequestContext(request)) +def host_del(request, offset): + Asset.objects.filter(ip=str(offset)).delete() + return HttpResponseRedirect('/jasset/host_list/') + +def host_edit(request, offset): + actives = {1: u'激活', 0: u'禁用'} + login_types = {'L': 'LDAP', 'S': 'SSH_KEY', 'P': 'PASSWORD', 'M': 'MAP'} + header_title, path1, path2 = u'修改主机 | Edit Host', u'资产管理', u'修改主机' + groups, e_group = [], [] + eidc = IDC.objects.all() + egroup = BisGroup.objects.all() + for g in Asset.objects.get(ip=offset).bis_group.all(): + e_group.append(g) + post = Asset.objects.get(ip = str(offset)) + if request.method == 'POST': + j_ip = request.POST.get('j_ip') + j_idc = request.POST.get('j_idc') + j_port = request.POST.get('j_port') + j_type = request.POST.get('j_type') + j_group = request.POST.getlist('j_group') + j_active = request.POST.get('j_active') + j_comment = request.POST.get('j_comment') + j_idc = IDC.objects.get(name=j_idc) + for group in j_group: + c = BisGroup.objects.get(name=group) + groups.append(c) + + a = Asset.objects.get(ip=str(offset)) + + if j_type == 'M': + j_user = request.POST.get('j_user') + j_password = cryptor.encrypt(request.POST.get('j_password')) + j_root = request.POST.get('j_root') + j_passwd = cryptor.encrypt(request.POST.get('j_passwd')) + a.ip = j_ip + a.port = j_port + a.login_type = j_type + a.idc = j_idc + a.is_active = j_active + a.comment = j_comment + a.username_common = j_user + a.password_common = j_password + a.username_super = j_root + a.password_super = j_passwd + else: + a.ip = j_ip + a.port = j_port + a.idc = j_idc + a.login_type = j_type + a.is_active = j_active + a.comment = j_comment + + a.save() + a.bis_group = groups + a.save() + smg = u'主机 %s 修改成功' %j_ip + return HttpResponseRedirect('/jasset/host_list') + + return render_to_response('jasset/host_edit.html', locals(), context_instance=RequestContext(request)) + + +def jlist_ip(request, offset): + header_title, path1, path2 = u'主机详细信息 | Host Detail.', u'资产管理', u'主机详情' + print offset + post = contact_list = Asset.objects.get(ip = str(offset)) + return render_to_response('jasset/jlist_ip.html', locals(), context_instance=RequestContext(request)) def jadd_idc(request): - pass + header_title, path1, path2 = u'添加IDC | Add IDC', u'资产管理', u'添加IDC' + if request.method == 'POST': + j_idc = request.POST.get('j_idc') + j_comment = request.POST.get('j_comment') + print j_idc,j_comment + + if IDC.objects.filter(name=j_idc): + emg = u'该IDC已存在!' + return render_to_response('jasset/idc_add.html', locals(), context_instance=RequestContext(request)) + else: + smg = u'IDC:%s添加成功' %j_idc + IDC.objects.create(name=j_idc, comment=j_comment) + + return render_to_response('jasset/idc_add.html', locals(), context_instance=RequestContext(request)) def jlist_idc(request): - pass \ No newline at end of file + header_title, path1, path2 = u'查看IDC | List Host', u'资产管理', u'查看IDC' + posts = IDC.objects.all().order_by('id') + return render_to_response('jasset/idc_list.html', locals(), context_instance=RequestContext(request)) + +def idc_del(request, offset): + IDC.objects.filter(id=offset).delete() + return HttpResponseRedirect('/jasset/idc_list/') + +def jadd_group(request): + header_title, path1, path2 = u'添加业务组 | Add Group', u'资产管理', u'添加业务组' + if request.method == 'POST': + j_group = request.POST.get('j_group') + j_comment = request.POST.get('j_comment') + + if BisGroup.objects.filter(name=j_group): + emg = u'该业务组已存在!' + return render_to_response('jasset/group_add.html', locals(), context_instance=RequestContext(request)) + else: + smg = u'业务组%s添加成功' %j_group + BisGroup.objects.create(name=j_group, comment=j_comment) + + return render_to_response('jasset/group_add.html', locals(), context_instance=RequestContext(request)) + + +def jlist_group(request): + header_title, path1, path2 = u'查看业务组 | Add Group', u'资产管理', u'查看业务组' + posts = BisGroup.objects.all().order_by('id') + return render_to_response('jasset/group_list.html', locals(), context_instance=RequestContext(request)) + +def group_del(request, offset): + BisGroup.objects.filter(id=offset).delete() + return HttpResponseRedirect('/jasset/group_list/') + +def test(request): + return render_to_response('jasset/test.html', locals()) \ No newline at end of file diff --git a/jumpserver.conf b/jumpserver.conf index 3a7d59784..18364c398 100644 --- a/jumpserver.conf +++ b/jumpserver.conf @@ -8,7 +8,11 @@ password = mysql234 database = jumpserver [ldap] -ldap_enable = 1 +host_url = ldap://192.168.8.60:389 +base_dn = dc=fengxing,dc=org +root_dn = cn=admin,dc=fengxing,dc=org +root_pw = 123456 +ldap_enable = 0 host_url = ldap://127.0.0.1:389 base_dn = dc=jumpserver,dc=org root_dn = cn=admin,dc=jumpserver,dc=org diff --git a/jumpserver/templatetags/mytags.py b/jumpserver/templatetags/mytags.py index ceb215464..86f978571 100644 --- a/jumpserver/templatetags/mytags.py +++ b/jumpserver/templatetags/mytags.py @@ -33,4 +33,8 @@ def groups_str(username): user = User.objects.get(username=username) for group in user.user_group.all(): groups.append(group.name) - return ','.join(groups) \ No newline at end of file + return ','.join(groups) + +@register.filter(name='get_item') +def get_item(dictionary, key): + return dictionary.get(key) diff --git a/juser/views.py b/juser/views.py index 6a101488a..31b838293 100644 --- a/juser/views.py +++ b/juser/views.py @@ -107,7 +107,6 @@ class LDAPMgmt(): except ldap.LDAPError, e: print e - def gen_sha512(salt, password): return crypt.crypt(password, '$6$%s$' % salt) @@ -161,7 +160,6 @@ def user_list(request): def db_add_user(**kwargs): groups_post = kwargs.pop('groups') user = User(**kwargs) - group_select = [] for group_id in groups_post: group = UserGroup.objects.filter(id=group_id) group_select.extend(group) diff --git a/static/css/colorbox.css b/static/css/colorbox.css new file mode 100755 index 000000000..0a6710404 --- /dev/null +++ b/static/css/colorbox.css @@ -0,0 +1,50 @@ +/* + Colorbox Core Style: + The following CSS is consistent between example themes and should not be altered. +*/ +#colorbox, #cboxOverlay, #cboxWrapper{position:absolute; top:0; left:0; z-index:9999; overflow:hidden;} +#cboxWrapper {max-width:none;} +#cboxOverlay{position:fixed; width:100%; height:100%;} +#cboxMiddleLeft, #cboxBottomLeft{clear:left;} +#cboxContent{position:relative;} +#cboxLoadedContent{overflow:auto; -webkit-overflow-scrolling: touch;} +#cboxTitle{margin:0;} +#cboxLoadingOverlay, #cboxLoadingGraphic{position:absolute; top:0; left:0; width:100%; height:100%;} +#cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow{cursor:pointer;} +.cboxPhoto{float:left; margin:auto; border:0; display:block; max-width:none; -ms-interpolation-mode:bicubic;} +.cboxIframe{width:100%; height:100%; display:block; border:0; padding:0; margin:0;} +#colorbox, #cboxContent, #cboxLoadedContent{box-sizing:content-box; -moz-box-sizing:content-box; -webkit-box-sizing:content-box;} + +/* + User Style: + Change the following styles to modify the appearance of Colorbox. They are + ordered & tabbed in a way that represents the nesting of the generated HTML. +*/ +#cboxOverlay{background:#fff; opacity: 0.9; filter: alpha(opacity = 90);} +#colorbox{outline:0;} + #cboxContent{margin-top:32px; overflow:visible; background:#000;} + .cboxIframe{background:#fff;} + #cboxError{padding:50px; border:1px solid #ccc;} + #cboxLoadedContent{background:#000; padding:1px;} + #cboxLoadingGraphic{background:url(images/loading.gif) no-repeat center center;} + #cboxLoadingOverlay{background:#000;} + #cboxTitle{position:absolute; top:-22px; left:0; color:#000;} + #cboxCurrent{position:absolute; top:-22px; right:205px; text-indent:-9999px;} + + /* these elements are buttons, and may need to have additional styles reset to avoid unwanted base styles */ + #cboxPrevious, #cboxNext, #cboxSlideshow, #cboxClose {border:0; padding:0; margin:0; overflow:visible; text-indent:-9999px; width:20px; height:20px; position:absolute; top:-20px; background:url(images/controls.png) no-repeat 0 0;} + + /* avoid outlines on :active (mouseclick), but preserve outlines on :focus (tabbed navigating) */ + #cboxPrevious:active, #cboxNext:active, #cboxSlideshow:active, #cboxClose:active {outline:0;} + + #cboxPrevious{background-position:0px 0px; right:44px;} + #cboxPrevious:hover{background-position:0px -25px;} + #cboxNext{background-position:-25px 0px; right:22px;} + #cboxNext:hover{background-position:-25px -25px;} + #cboxClose{background-position:-50px 0px; right:0;} + #cboxClose:hover{background-position:-50px -25px;} + .cboxSlideshow_on #cboxPrevious, .cboxSlideshow_off #cboxPrevious{right:66px;} + .cboxSlideshow_on #cboxSlideshow{background-position:-75px -25px; right:44px;} + .cboxSlideshow_on #cboxSlideshow:hover{background-position:-100px -25px;} + .cboxSlideshow_off #cboxSlideshow{background-position:-100px 0px; right:44px;} + .cboxSlideshow_off #cboxSlideshow:hover{background-position:-75px -25px;} diff --git a/static/css/images/controls.png b/static/css/images/controls.png new file mode 100755 index 000000000..36f526992 Binary files /dev/null and b/static/css/images/controls.png differ diff --git a/static/css/images/loading.gif b/static/css/images/loading.gif new file mode 100755 index 000000000..a32df5c08 Binary files /dev/null and b/static/css/images/loading.gif differ diff --git a/static/css/vaildator/images/loading.gif b/static/css/vaildator/images/loading.gif new file mode 100755 index 000000000..6e5bace6e Binary files /dev/null and b/static/css/vaildator/images/loading.gif differ diff --git a/static/css/vaildator/images/validator_default.png b/static/css/vaildator/images/validator_default.png new file mode 100755 index 000000000..5a9564095 Binary files /dev/null and b/static/css/vaildator/images/validator_default.png differ diff --git a/static/css/vaildator/images/validator_simple.png b/static/css/vaildator/images/validator_simple.png new file mode 100755 index 000000000..2470db588 Binary files /dev/null and b/static/css/vaildator/images/validator_simple.png differ diff --git a/static/css/vaildator/jquery.validator.css b/static/css/vaildator/jquery.validator.css new file mode 100755 index 000000000..9de60962f --- /dev/null +++ b/static/css/vaildator/jquery.validator.css @@ -0,0 +1,64 @@ +/*! nice Validator 0.7.3 + * (c) 2012-2014 Jony Zhang , MIT Licensed + * http://niceue.com/validator/ + */ +.n-inline-block,.nice-validator input,.nice-validator select,.nice-validator textarea,.msg-wrap,.n-icon,.n-msg{display:inline-block;*display:inline;*zoom:1} +.msg-box{position:relative;*zoom:1} +.msg-wrap{position:relative;white-space:nowrap} +.msg-wrap,.n-icon,.n-msg{vertical-align:top} +.n-arrow{position:absolute;overflow:hidden;} +.n-arrow b,.n-arrow i{position:absolute;left:0;top:0;border:0;margin:0;padding:0;overflow:hidden;font-weight:400;font-style:normal;font-size:12px;font-family:serif;line-height:14px;_line-height:15px} +.n-arrow i{text-shadow:none} +.n-icon{width:16px;height:16px;overflow:hidden;background-repeat:no-repeat} +.n-msg{display:inline-block;line-height:15px;margin-left:2px;*margin-top:-1px;_margin-top:0;font-size:12px;font-family:simsun} +.n-error{color:#c33} +.n-ok{color:#390} +.n-tip,.n-loading{color:#808080} +.n-error .n-icon{background-position:0 0} +.n-ok .n-icon{background-position:-16px 0} +.n-tip .n-icon{background-position:-32px 0} +.n-loading .n-icon{background:url("images/loading.gif") 0 center no-repeat !important} +.n-top,.n-right,.n-bottom,.n-left{display:inline-block;line-height:0;vertical-align:top;outline:0} +.n-top .n-arrow,.n-bottom .n-arrow{height:6px;width:12px;left:8px} +.n-left .n-arrow,.n-right .n-arrow{width:6px;height:12px;top:6px} +.n-top{vertical-align:top;} +.n-top .msg-wrap{margin-bottom:6px} +.n-top .n-arrow{bottom:-6px;} +.n-top .n-arrow b{top:-6px} +.n-top .n-arrow i{top:-7px} +.n-bottom{vertical-align:bottom;} +.n-bottom .msg-wrap{margin-top:6px} +.n-bottom .n-arrow{top:-6px;} +.n-bottom .n-arrow b{top:-1px} +.n-bottom .n-arrow i{top:0} +.n-left .msg-wrap{right:100%;margin-right:6px} +.n-left .n-arrow{right:-6px;} +.n-left .n-arrow b{left:-6px} +.n-left .n-arrow i{left:-7px} +.n-right .msg-wrap{margin-left:6px} +.n-right .n-arrow{left:-6px;} +.n-right .n-arrow b{left:1px} +.n-right .n-arrow i{left:2px} +.n-default .n-left,.n-default .n-right{margin-top:5px} +.n-default .n-top .msg-wrap{bottom:100%} +.n-default .n-bottom .msg-wrap{top:100%} +.n-default .msg-wrap{position:absolute;z-index:1;} +.n-default .msg-wrap .n-icon{background-image:url("images/validator_default.png")} +.n-default .n-tip .n-icon{display:none} +.n-simple .msg-wrap{position:absolute;z-index:1;} +.n-simple .msg-wrap .n-icon{background-image:url("images/validator_simple.png")} +.n-simple .n-top .msg-wrap{bottom:100%} +.n-simple .n-bottom .msg-wrap{top:100%} +.n-simple .n-left,.n-simple .n-right{margin-top:5px} +.n-simple .n-bottom .msg-wrap{margin-top:3px} +.n-simple .n-tip .n-icon{display:none} +.n-yellow .msg-wrap{position:absolute;z-index:1;padding:4px 6px;font-size:12px;border:1px solid transparent;background-color:#fffcef;border-color:#ffbb76;color:#db7c22;box-shadow:0 1px 3px #ccc;border-radius:2px;} +.n-yellow .msg-wrap .n-arrow b{color:#ffbb76;text-shadow:0 0 2px #ccc} +.n-yellow .msg-wrap .n-arrow i{color:#fffcef} +.n-yellow .msg-wrap .n-icon{background-image:url("images/validator_simple.png")} +.n-yellow .n-top .msg-wrap{bottom:100%} +.n-yellow .n-bottom .msg-wrap{top:100%} +.n-yellow .n-tip,.n-yellow .n-ok,.n-yellow .n-loading{background-color:#f8fdff;border-color:#ddd;color:#333;box-shadow:0 1px 3px #ccc;} +.n-yellow .n-tip .n-arrow b,.n-yellow .n-ok .n-arrow b,.n-yellow .n-loading .n-arrow b{color:#ddd;text-shadow:0 0 2px #ccc} +.n-yellow .n-tip .n-arrow i,.n-yellow .n-ok .n-arrow i,.n-yellow .n-loading .n-arrow i{color:#f8fdff} +.n-yellow .n-tip .n-icon{display:none} diff --git a/static/js/jquery.colorbox.js b/static/js/jquery.colorbox.js new file mode 100755 index 000000000..c0348849e --- /dev/null +++ b/static/js/jquery.colorbox.js @@ -0,0 +1,1090 @@ +/*! + Colorbox 1.5.14 + license: MIT + http://www.jacklmoore.com/colorbox +*/ +(function ($, document, window) { + var + // Default settings object. + // See http://jacklmoore.com/colorbox for details. + defaults = { + // data sources + html: false, + photo: false, + iframe: false, + inline: false, + + // behavior and appearance + transition: "elastic", + speed: 300, + fadeOut: 300, + width: false, + initialWidth: "600", + innerWidth: false, + maxWidth: false, + height: false, + initialHeight: "450", + innerHeight: false, + maxHeight: false, + scalePhotos: true, + scrolling: true, + opacity: 0.9, + preloading: true, + className: false, + overlayClose: true, + escKey: true, + arrowKey: true, + top: false, + bottom: false, + left: false, + right: false, + fixed: false, + data: undefined, + closeButton: true, + fastIframe: true, + open: false, + reposition: true, + loop: true, + slideshow: false, + slideshowAuto: true, + slideshowSpeed: 2500, + slideshowStart: "start slideshow", + slideshowStop: "stop slideshow", + photoRegex: /\.(gif|png|jp(e|g|eg)|bmp|ico|webp|jxr|svg)((#|\?).*)?$/i, + + // alternate image paths for high-res displays + retinaImage: false, + retinaUrl: false, + retinaSuffix: '@2x.$1', + + // internationalization + current: "image {current} of {total}", + previous: "previous", + next: "next", + close: "close", + xhrError: "This content failed to load.", + imgError: "This image failed to load.", + + // accessbility + returnFocus: true, + trapFocus: true, + + // callbacks + onOpen: false, + onLoad: false, + onComplete: false, + onCleanup: false, + onClosed: false, + + rel: function() { + return this.rel; + }, + href: function() { + // using this.href would give the absolute url, when the href may have been inteded as a selector (e.g. '#container') + return $(this).attr('href'); + }, + title: function() { + return this.title; + } + }, + + // Abstracting the HTML and event identifiers for easy rebranding + colorbox = 'colorbox', + prefix = 'cbox', + boxElement = prefix + 'Element', + + // Events + event_open = prefix + '_open', + event_load = prefix + '_load', + event_complete = prefix + '_complete', + event_cleanup = prefix + '_cleanup', + event_closed = prefix + '_closed', + event_purge = prefix + '_purge', + + // Cached jQuery Object Variables + $overlay, + $box, + $wrap, + $content, + $topBorder, + $leftBorder, + $rightBorder, + $bottomBorder, + $related, + $window, + $loaded, + $loadingBay, + $loadingOverlay, + $title, + $current, + $slideshow, + $next, + $prev, + $close, + $groupControls, + $events = $(''), // $({}) would be prefered, but there is an issue with jQuery 1.4.2 + + // Variables for cached values or use across multiple functions + settings, + interfaceHeight, + interfaceWidth, + loadedHeight, + loadedWidth, + index, + photo, + open, + active, + closing, + loadingTimer, + publicMethod, + div = "div", + requests = 0, + previousCSS = {}, + init; + + // **************** + // HELPER FUNCTIONS + // **************** + + // Convenience function for creating new jQuery objects + function $tag(tag, id, css) { + var element = document.createElement(tag); + + if (id) { + element.id = prefix + id; + } + + if (css) { + element.style.cssText = css; + } + + return $(element); + } + + // Get the window height using innerHeight when available to avoid an issue with iOS + // http://bugs.jquery.com/ticket/6724 + function winheight() { + return window.innerHeight ? window.innerHeight : $(window).height(); + } + + function Settings(element, options) { + if (options !== Object(options)) { + options = {}; + } + + this.cache = {}; + this.el = element; + + this.value = function(key) { + var dataAttr; + + if (this.cache[key] === undefined) { + dataAttr = $(this.el).attr('data-cbox-'+key); + + if (dataAttr !== undefined) { + this.cache[key] = dataAttr; + } else if (options[key] !== undefined) { + this.cache[key] = options[key]; + } else if (defaults[key] !== undefined) { + this.cache[key] = defaults[key]; + } + } + + return this.cache[key]; + }; + + this.get = function(key) { + var value = this.value(key); + return $.isFunction(value) ? value.call(this.el, this) : value; + }; + } + + // Determine the next and previous members in a group. + function getIndex(increment) { + var + max = $related.length, + newIndex = (index + increment) % max; + + return (newIndex < 0) ? max + newIndex : newIndex; + } + + // Convert '%' and 'px' values to integers + function setSize(size, dimension) { + return Math.round((/%/.test(size) ? ((dimension === 'x' ? $window.width() : winheight()) / 100) : 1) * parseInt(size, 10)); + } + + // Checks an href to see if it is a photo. + // There is a force photo option (photo: true) for hrefs that cannot be matched by the regex. + function isImage(settings, url) { + return settings.get('photo') || settings.get('photoRegex').test(url); + } + + function retinaUrl(settings, url) { + return settings.get('retinaUrl') && window.devicePixelRatio > 1 ? url.replace(settings.get('photoRegex'), settings.get('retinaSuffix')) : url; + } + + function trapFocus(e) { + if ('contains' in $box[0] && !$box[0].contains(e.target) && e.target !== $overlay[0]) { + e.stopPropagation(); + $box.focus(); + } + } + + function setClass(str) { + if (setClass.str !== str) { + $box.add($overlay).removeClass(setClass.str).addClass(str); + setClass.str = str; + } + } + + function getRelated(rel) { + index = 0; + + if (rel && rel !== false && rel !== 'nofollow') { + $related = $('.' + boxElement).filter(function () { + var options = $.data(this, colorbox); + var settings = new Settings(this, options); + return (settings.get('rel') === rel); + }); + index = $related.index(settings.el); + + // Check direct calls to Colorbox. + if (index === -1) { + $related = $related.add(settings.el); + index = $related.length - 1; + } + } else { + $related = $(settings.el); + } + } + + function trigger(event) { + // for external use + $(document).trigger(event); + // for internal use + $events.triggerHandler(event); + } + + var slideshow = (function(){ + var active, + className = prefix + "Slideshow_", + click = "click." + prefix, + timeOut; + + function clear () { + clearTimeout(timeOut); + } + + function set() { + if (settings.get('loop') || $related[index + 1]) { + clear(); + timeOut = setTimeout(publicMethod.next, settings.get('slideshowSpeed')); + } + } + + function start() { + $slideshow + .html(settings.get('slideshowStop')) + .unbind(click) + .one(click, stop); + + $events + .bind(event_complete, set) + .bind(event_load, clear); + + $box.removeClass(className + "off").addClass(className + "on"); + } + + function stop() { + clear(); + + $events + .unbind(event_complete, set) + .unbind(event_load, clear); + + $slideshow + .html(settings.get('slideshowStart')) + .unbind(click) + .one(click, function () { + publicMethod.next(); + start(); + }); + + $box.removeClass(className + "on").addClass(className + "off"); + } + + function reset() { + active = false; + $slideshow.hide(); + clear(); + $events + .unbind(event_complete, set) + .unbind(event_load, clear); + $box.removeClass(className + "off " + className + "on"); + } + + return function(){ + if (active) { + if (!settings.get('slideshow')) { + $events.unbind(event_cleanup, reset); + reset(); + } + } else { + if (settings.get('slideshow') && $related[1]) { + active = true; + $events.one(event_cleanup, reset); + if (settings.get('slideshowAuto')) { + start(); + } else { + stop(); + } + $slideshow.show(); + } + } + }; + + }()); + + + function launch(element) { + var options; + + if (!closing) { + + options = $(element).data(colorbox); + + settings = new Settings(element, options); + + getRelated(settings.get('rel')); + + if (!open) { + open = active = true; // Prevents the page-change action from queuing up if the visitor holds down the left or right keys. + + setClass(settings.get('className')); + + // Show colorbox so the sizes can be calculated in older versions of jQuery + $box.css({visibility:'hidden', display:'block', opacity:''}); + + $loaded = $tag(div, 'LoadedContent', 'width:0; height:0; overflow:hidden; visibility:hidden'); + $content.css({width:'', height:''}).append($loaded); + + // Cache values needed for size calculations + interfaceHeight = $topBorder.height() + $bottomBorder.height() + $content.outerHeight(true) - $content.height(); + interfaceWidth = $leftBorder.width() + $rightBorder.width() + $content.outerWidth(true) - $content.width(); + loadedHeight = $loaded.outerHeight(true); + loadedWidth = $loaded.outerWidth(true); + + // Opens inital empty Colorbox prior to content being loaded. + var initialWidth = setSize(settings.get('initialWidth'), 'x'); + var initialHeight = setSize(settings.get('initialHeight'), 'y'); + var maxWidth = settings.get('maxWidth'); + var maxHeight = settings.get('maxHeight'); + + settings.w = (maxWidth !== false ? Math.min(initialWidth, setSize(maxWidth, 'x')) : initialWidth) - loadedWidth - interfaceWidth; + settings.h = (maxHeight !== false ? Math.min(initialHeight, setSize(maxHeight, 'y')) : initialHeight) - loadedHeight - interfaceHeight; + + $loaded.css({width:'', height:settings.h}); + publicMethod.position(); + + trigger(event_open); + settings.get('onOpen'); + + $groupControls.add($title).hide(); + + $box.focus(); + + if (settings.get('trapFocus')) { + // Confine focus to the modal + // Uses event capturing that is not supported in IE8- + if (document.addEventListener) { + + document.addEventListener('focus', trapFocus, true); + + $events.one(event_closed, function () { + document.removeEventListener('focus', trapFocus, true); + }); + } + } + + // Return focus on closing + if (settings.get('returnFocus')) { + $events.one(event_closed, function () { + $(settings.el).focus(); + }); + } + } + + var opacity = parseFloat(settings.get('opacity')); + $overlay.css({ + opacity: opacity === opacity ? opacity : '', + cursor: settings.get('overlayClose') ? 'pointer' : '', + visibility: 'visible' + }).show(); + + if (settings.get('closeButton')) { + $close.html(settings.get('close')).appendTo($content); + } else { + $close.appendTo('
'); // replace with .detach() when dropping jQuery < 1.4 + } + + load(); + } + } + + // Colorbox's markup needs to be added to the DOM prior to being called + // so that the browser will go ahead and load the CSS background images. + function appendHTML() { + if (!$box) { + init = false; + $window = $(window); + $box = $tag(div).attr({ + id: colorbox, + 'class': $.support.opacity === false ? prefix + 'IE' : '', // class for optional IE8 & lower targeted CSS. + role: 'dialog', + tabindex: '-1' + }).hide(); + $overlay = $tag(div, "Overlay").hide(); + $loadingOverlay = $([$tag(div, "LoadingOverlay")[0],$tag(div, "LoadingGraphic")[0]]); + $wrap = $tag(div, "Wrapper"); + $content = $tag(div, "Content").append( + $title = $tag(div, "Title"), + $current = $tag(div, "Current"), + $prev = $('
- {% include 'script.html' %} + diff --git a/templates/css_js.html b/templates/css_js.html new file mode 100644 index 000000000..9004ffc1e --- /dev/null +++ b/templates/css_js.html @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/templates/jasset/group_add.html b/templates/jasset/group_add.html new file mode 100644 index 000000000..f610d740f --- /dev/null +++ b/templates/jasset/group_add.html @@ -0,0 +1,80 @@ +{% extends 'base.html' %} +{% block content %} +{% include 'nav_cat_bar.html' %} +
+
+
+
+ + +
+ {% if emg %} +
{{ emg }}
+ {% endif %} + {% if smg %} +
{{ smg }}
+ {% endif %} +
+
+
+
+ +
+
+
+
+ +
+
+
+ + +
+
+
+
+
+
+
+
+ + + +{% endblock %} \ No newline at end of file diff --git a/templates/jasset/group_list.html b/templates/jasset/group_list.html new file mode 100644 index 000000000..8f707d213 --- /dev/null +++ b/templates/jasset/group_list.html @@ -0,0 +1,65 @@ +{% extends 'base.html' %} +{% block content %} +{% include 'nav_cat_bar.html' %} + +
+
+
+
+
+
IDC详细信息列表
+ +
+ +
+ + + + + + + + + + + + + {% for post in posts %} + + + + + + + {% endfor %} + +
ID 机房名 备注 操作
{{ post.id }} {{ post.name }} {{ post.comment }} + 详情 + 编辑 + 删除 +
+
+
+
+
+
+ +{% endblock %} \ No newline at end of file diff --git a/templates/jasset/jadd.html b/templates/jasset/host_add.html similarity index 63% rename from templates/jasset/jadd.html rename to templates/jasset/host_add.html index 6d3985beb..dc862a315 100644 --- a/templates/jasset/jadd.html +++ b/templates/jasset/host_add.html @@ -5,7 +5,13 @@
-
+
+ 请选择添加内容: + 添加主机 + 添加IDC + 添加业务组 +
+
填写主机基本信息
- - - diff --git a/templates/jasset/host_edit.html b/templates/jasset/host_edit.html new file mode 100644 index 000000000..d3a3f2f00 --- /dev/null +++ b/templates/jasset/host_edit.html @@ -0,0 +1,215 @@ +{% extends 'base.html' %} +{% load mytags %} +{% block content %} +{% include 'nav_cat_bar.html' %} +
+
+
+
+ + +
+ {% if emg %} +
{{ emg }}
+ {% endif %} + {% if smg %} +
{{ smg }}
+ {% endif %} + +
+
+
+ +
+
+
+
+ +
+
+
+ {% for t, type in login_types.items %} + {% ifequal t post.login_type %} +
+ {% else %} +
+ {% endifequal %} + {% endfor %} +
+ + +
+ +
+
+ +
+ +
+
+ +
+
+ +
+ {% for g in egroup %} + {% if g in e_group %} + + {% else %} + + {% endif %} + {% endfor %} +
+
+ +
+
+
+ {% for a,active in actives.items %} + {% ifequal a post.is_active %} +
+ {% else %} +
+ {% endifequal %} + {% endfor %} +
+
+ +
+
+
+
+ +
+
+
+ + +
+
+ +
+
+
+
+
+ + + +{% endblock %} \ No newline at end of file diff --git a/templates/jasset/jlist.html b/templates/jasset/host_list.html similarity index 56% rename from templates/jasset/jlist.html rename to templates/jasset/host_list.html index 67ff7b909..eae48d9e4 100644 --- a/templates/jasset/jlist.html +++ b/templates/jasset/host_list.html @@ -1,10 +1,11 @@ {% extends 'base.html' %} +{% load mytags %} {% block content %} {% include 'nav_cat_bar.html' %}
-
+
主机详细信息列表
@@ -29,35 +30,43 @@
- - - - - - - + + + + + + + + + {% for post in contacts.object_list %} - - - - - + + + + + - - + + + {% endfor %} @@ -85,4 +94,10 @@ + + {% endblock %} \ No newline at end of file diff --git a/templates/jasset/idc_add.html b/templates/jasset/idc_add.html new file mode 100644 index 000000000..32ba1e8b8 --- /dev/null +++ b/templates/jasset/idc_add.html @@ -0,0 +1,79 @@ +{% extends 'base.html' %} +{% block content %} +{% include 'nav_cat_bar.html' %} +
+
+
+
+
+
填写IDC基本信息
+ +
+ +
+ {% if emg %} +
{{ emg }}
+ {% endif %} + {% if smg %} +
{{ smg }}
+ {% endif %} +
+
+
+
+ +
+
+
+
+ +
+
+
+ + +
+
+ +
+
+
+
+
+ + + +{% endblock %} \ No newline at end of file diff --git a/templates/jasset/idc_list.html b/templates/jasset/idc_list.html new file mode 100644 index 000000000..05087e030 --- /dev/null +++ b/templates/jasset/idc_list.html @@ -0,0 +1,65 @@ +{% extends 'base.html' %} +{% block content %} +{% include 'nav_cat_bar.html' %} + +
+
+
+
+
+
IDC详细信息列表
+ +
+ +
+ + +
IP地址 端口号 登录方式 所属IDC 所属业务组 添加时间 备注 IP地址 端口号 登录方式 所属IDC 所属业务组 添加时间 备注 操作
{{ post.ip }} {{ post.port }} {{ post.login_type}} {{ post.idc.name }} - {% for group in post.group.all %} + {{ post.ip }} {{ post.port }} {{ login_types|get_item:post.login_type }} {{ post.idc.name }} + {% for group in post.bis_group.all %} {{ group }} {% endfor %} {{ post.date_added }} {{ post.comment }} {{ post.date_added }} {{ post.comment }} + 详情 + 编辑 + 删除 +
+ + + + + + + + + + {% for post in posts %} + + + + + + + {% endfor %} + +
ID 机房名 备注 操作
{{ post.id }} {{ post.name }} {{ post.comment }} + 详情 + 编辑 + 删除 +
+
+
+
+
+
+ +{% endblock %} \ No newline at end of file diff --git a/templates/jasset/jlist_ip.html b/templates/jasset/jlist_ip.html new file mode 100644 index 000000000..11f975edb --- /dev/null +++ b/templates/jasset/jlist_ip.html @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + +
+
+

{{ offset }}主机详情

+ + + + + + + + + + + + + + + + + + + + + + + +
IP地址 端口号 登录方式 所属IDC 所属业务组 添加时间 备注
{{ post.ip }} {{ post.port }} {{ post.get_login_type}} {{ post.idc.name }} + {% for group in post.bis_group.all %} + {{ group }} + {% endfor %} + {{ post.date_added }} {{ post.comment }}
+ 是否激活: {{ post.is_active }} +
+
+ + \ No newline at end of file diff --git a/templates/jasset/test.html b/templates/jasset/test.html new file mode 100644 index 000000000..6ece5b502 --- /dev/null +++ b/templates/jasset/test.html @@ -0,0 +1,30 @@ + + \ No newline at end of file diff --git a/templates/link_css.html b/templates/link_css.html index 26fd0e087..057f788be 100644 --- a/templates/link_css.html +++ b/templates/link_css.html @@ -3,3 +3,5 @@ + + \ No newline at end of file diff --git a/templates/nav.html b/templates/nav.html index 32d3b3165..0b830731d 100644 --- a/templates/nav.html +++ b/templates/nav.html @@ -23,10 +23,12 @@
  • 资产管理
  • diff --git a/templates/script.html b/templates/script.html index 490d4eb88..f730bb65e 100644 --- a/templates/script.html +++ b/templates/script.html @@ -17,12 +17,19 @@ - + + + + + + + +