首页 文章 精选 留言 我的

精选列表

搜索[搭建],共10000篇文章
优秀的个人博客,低调大师

手把手教你配置阿里云服务器搭建网站

写在前面 出于好奇,我用学生优惠租了一台阿里云服务器,打算做一些Java web的开发,但是毕竟是第一次接触这样的东西,还是比较懵逼,在这个过程中遇到了一些问题(肯定会遇到问题的),但是呢,在网上搜解决办法的时候,总是历经波折才能找到我最后想要的东西,所以我想把我配置阿里云的时候踩过的坑填一下,如果你按照我的方法成功解决的问题,别忘了给我点个赞 不定期续更 购买服务器 学生的话,阿里推出了一个叫云翼计划的产品,通过学生认证之后可以享受超便宜的价格,我的账号是支付宝账号,之前就有过学生认证。云翼计划的入口在这儿云翼计划 配置服务器 如果我是学生,我如何通过¥9.9买到价值¥117的服务?答:用¥9.9购买云服务器ECS是阿里云学生专属活动。首先,你需要在阿里云官网注册账号,然后在阿里云官网首页点击校园扶持 如果我不是学生,我如何通过¥30买到价值

优秀的个人博客,低调大师

手把手带你实现Spring、Spring MVC与Mybatis整合工程的搭建

1.整合的思路 1.在Mybatis3.x与Spring3.x整合的基础上再进行Spring MVC框架的整合。 2.Spring要管理Spring MVC编写的Handler(controller)、Mybatis的SqlSessionFactory、mapper、数据源。 其实整合思路就是下面这三步: 第一步:整合dao(即mapper),完成Spring与Mybatis的整合。 第二步:整合service,Spring管理service接口,service中可以调用Spring容器中的dao(mapper)。 第三步:整合controller,Spring管理controller接口,在controller调用service。 2.导入jar包 mybatis-3.x.jar、spring3.x.jar(包含springmvc的jar包)、mybatis与spring的整合jar、数据库驱动包、log4j.jar、jstl.jar。如下: 3.工程结构 3.1需要创建的配置文件 applicationContext-dao.xml—配置数据源、SqlSessionFactory、mapper扫描器。 applicationContext-service.xml—配置service接口。 applicationContext-transaction.xml–事务管理。 sprintmvc.xml—springmvc的配置,配置处理器映射器、适配器、视图解析器(这里我们统一采用注解的方式进行开发)。 SqlMapConfig.xml—mybatis的配置文件,配置别名、settings、mapper。 工程目录如下: 3.2各个配置文件的内容 applicationContext-dao.xml: <beansxmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd"> <!--加载配置文件--> <context:property-placeholderlocation="classpath:config/db.properties"/> <!--数据库连接池--> <beanid="dataSource"class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <propertyname="driverClassName"value="${jdbc.driver}"/> <propertyname="url"value="${jdbc.url}"/> <propertyname="username"value="${jdbc.username}"/> <propertyname="password"value="${jdbc.password}"/> <propertyname="maxIdle"value="5"/> </bean> <!--SqlsessionFactory--> <beanid="sqlSessionFactory"class="org.mybatis.spring.SqlSessionFactoryBean"> <!--数据源--> <propertyname="dataSource"ref="dataSource"/> <!--mybatis配置文件--> <propertyname="configLocation"value="classpath:config/mybatis/SqlMapConfig.xml"/> </bean> <!-- MapperScannerConfigurer:mapper的扫描器,将包下边的mapper接口自动创建代理对象, 自动创建到spring容器中,bean的id是mapper的类名(首字母小写) --> <beanclass="org.mybatis.spring.mapper.MapperScannerConfigurer"> <!--配置扫描包的路径 如果要扫描多个包,中间使用半角逗号分隔 要求mapper.xml和mapper.java同名且在同一个目录 --> <propertyname="basePackage"value="mapper"/> <!--使用sqlSessionFactoryBeanName--> <propertyname="sqlSessionFactoryBeanName"value="sqlSessionFactory"/> </bean> </beans> applicationContext-service.xml: <beansxmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd"> </beans> applicationContext-transaction.xml:配置事务,在配置文件中使用声明式事务配置 <beansxmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd"> <!--使用声明式的控制配置,可以有效的规范代码--> <!--事务管理器的配置--> <beanid="transactionManager"class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <propertyname="dataSource"ref="dataSource"/> </bean> <!--配置通知--> <tx:adviceid="txAdvice"transaction-manager="transactionManager"> <tx:attributes> <tx:methodname="sava"propagation="REQUIRED"/> <tx:methodname="insert*"propagation="REQUIRED"/> <tx:methodname="update*"propagation="REQUIRED"/> <tx:methodname="delete*"propagation="REQUIRED"/> <tx:methodname="find*"propagation="SUPPORTS"read-only="true"/> <tx:methodname="select*"propagation="SUPPORTS"read-only="true"/> <tx:methodname="get*"propagation="SUPPORTS"read-only="true"/> </tx:attributes> </tx:advice> <!--配置aop--> <aop:config> <aop:advisoradvice-ref="txAdvice"pointcut="execution(*service.impl.*.*(..))"/> </aop:config> </beans> sprintmvc.xml: <beansxmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd"> <!--使用spring组件扫描 一次性配置此包下所有的Handler--> <context:component-scanbase-package="controller"/> <!--注解处理器映射器--> <beanclass="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/> <!--注解的适配器--> <beanclass="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"/> <!--配置视图解析器 要求将jstl的包加到classpath prefix:代表请求url的前缀 suffix:代表请求url的后缀 设置了这两个属性值后我们在Controller中进行代码开发时返回的modelandview对象设置的页面路径值就不用带前缀名和后缀名了--> <beanclass="org.springframework.web.servlet.view.InternalResourceViewResolver"> <propertyname="prefix"value="/WEB-INF/jsp/"/> <propertyname="suffix"value=".jsp"/> </bean> <!DOCTYPEconfiguration PUBLIC"-//mybatis.org//DTDConfig3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration> <!--定义别名--> <typeAliases> <!--批量别名定义指定包路径,自动扫描包下边的pojo,定义别名,别名默认为类名(首字母小写或大写)--> <packagename="po"/> </typeAliases> <!--由于使用了spring和mybatis整合的mapper扫描器,--> <!--这里就不用配置了--> <!--<mappers>--> <!--<packagename="mapper"/>--> <!--</mappers>--> </configuration> 在web.xml文件中加入对前端控制器的配置: <servlet> <servlet-name>springmvc</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <!--加载springmvc配置文件--> <init-param> <param-name>contextConfigLocation</param-name> <!--配置文件的地址 如果不配置contextConfigLocation,默认查找的配置文件名称是classpath下的:servlet名称+"-servlet.xml"即springmvc-servlet.xml--> <param-value>springmvc.xml</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>springmvc</servlet-name> <!--可以配置/:此工程所有的请求全部由springmvc解析,此种方式可以实现RESTful方式,需要特殊处理对静态文件的解析不能由springmvc解析 可以配置*.do或者*.action,所有请求的url扩展名为.do或.action由springmvc解析,此中方法常用 不可以配置/*,如果配置/*,返回jsp也由springmvc解析,这是不对的--> <url-pattern>*.action</url-pattern> </servlet-mapping> 另外还需要添加数据库的配置文件db.properties: jdbc.driver=com.mysql.jdbc.Driver jdbc.url=jdbc:mysql://localhost:3306/mybatis jdbc.username=root jdbc.password=xiaxunwu1996. 在src下创建各个包:mapper、po、controller、service,在web包下创建页面包jsp,工程目录如下: 经过上述步骤,我们便完成了Spring、Spring MVC与Mybatis的整合,是不是很简单?没错就是这么简单。可是整合后又该如何进行web项目的开发呢?接下来我将通过下篇文章一个案例带你快速入门SSM开发介绍利用Spring、Spring MVC与Mybatis的整合项目进行开发一个案例带你快速学会使用SSM框架开发项目。 转自:http://codingxiaxw.cn/2016/11/15/44-ssm%E7%9A%84%E6%95%B4%E5%90%88/

优秀的个人博客,低调大师

阿里云上基于SAP HANA One的数据仓库、BI系统搭建

1规划 (BI系统经典架构) BI系统经典架构,由数据源层、数据仓库层、数据展现层构成,数据源层提供基础数据,数据仓库层存放各种聚合数据,数据展现层按业务场景展示数据。此处的数据仓库层,采用数据分层的设计理念,相对来说实时计算复杂度要求不高的数据放到开源数据库中(如MySQL),实时计算复杂度要求高的数据放到高性能数据库中(如SAPHANAOne)。 注:数据仓库层采用数据分层,主要是基于成本考虑。阿里云上的SAP HANA One 64G版,软件每月要4000多大洋,再加上ECS费用,每月就8000多啦。且HANA One的64G容量,远远不够。 2实现 2.1数据源 数据分析基础数据来源,系统支持多种数据来源,包括外部数据文件(如Excel、TXT、XML等),常用数据库(如Oracle、MySQL、SQLServer、DB2等),其它JDBC、ODBC、JNDI数据源,也支持把Hadoop HDFS中的文件作为数据源,甚至一些常用软件系统(如SAP ERP、SAS、Salesforce)直接作为数据源。 2.2ETL 采用开源软件Kettle作为ETL工具,从数据源抽取原始数据,做数据转换后导入数据模型。数据抽取周期,根据实际需求从几分钟到月不等。实际应用中,最短数据抽取周期我们曾经到30秒,但这种情况对数据源性能压力较大。幸好HANA有SDI,通过SDI建虚拟表,直接访问数据源。 2.3数据建模 直接用HANA计算视图建模,建模基础数据来自HANA One、开源聚合数据层(如MySQL)、甚至直接是业务数据表(业务数据表做读写分离,从只读表中取数)。为实现这种跨系统、跨数据库建模,采用了HANA的虚拟表功能(借助SDI,SDI真是个好东西)。 2.4数据展现 数据展现平台,主要是PC端的浏览器和移动端的微信。Excel方式,对云端应用来说,性能不理想。PC端数据展现基于SAPUI5做专门开发:常规拖拽方式的OLAP灵活分析;保存灵活分析格式,形成固定格式的格式化主题分析;串联多个格式化主题分析,做一定扩展形成管理驾驶舱。 2.5数据挖掘 采用经典的机器学习算法(如:DBSCAN、K-Means、C4.5决策树、逻辑回归、随机森林、朴素贝叶斯等),对数据进行挖掘分析。可应用的实际业务场景,包括地理位置分析、文本分析、相关性分析等。对需进行训练的监督学习,可根据实际训练需求,定制数据训练平台。 3 成果 3.1产品示例 地图应用 OLAP灵活分析 文本分析 格式化分析与驾驶舱

优秀的个人博客,低调大师

Django 搭建CMDB系统完整[10](网络设备、安全设备、存储设备)

cmdb/urls.py from cmdbapp import machinaroomviews,serverviews,networkdeviceviews,securitydeviceviews,storagedeviceviews urlpatterns = [ url(r'^static/(?P<path>.*)',machinaroomviews.main_page,name='main_page'), url(r'^base',machinaroomviews.base,name='base'), url(r'^search_machinaroom.html',machinaroomviews.add_machinaroom,name='add_machinaroom'), url(r'^edit_machinaroom.html',machinaroomviews.edit_machinaroom,name='edit_machinaroom'), url(r'^del_machinaroom.html',machinaroomviews.del_machinaroom,name='del_machinaroom'), url(r'^batdel_machinaroom.html',machinaroomviews.batdel_machinaroom,name='batdel_machinaroom'), url(r'^excel_machinaroom.html',machinaroomviews.excel_machinaroom,name='excel_machinaroom'), url(r'^login/',serverviews.search_server,name='search_server'), url(r'^add_server.html',serverviews.edit_server,name="edit_server"), url(r'^del_server.html',serverviews.del_server,name='del_server'), url(r'^batdel_server.html',serverviews.batdel_server,name='batdel_server'), url(r'^excel_server.html',serverviews.excel_server,name='excel_server'), url(r'^search_networkdevice.html',networkdeviceviews.add_networkdevice,name="add_networkdevice"), url(r'^edit_networkdevice.html',securitydeviceviews.search_securitydevice,name='search_securitydevice'), url(r'^add_securitydevice.html',securitydeviceviews.edit_securitydevice,name="edit_securitydevice"), url(r'^del_securitydevice.html',securitydeviceviews.del_securitydevice,name='del_securitydevice'), url(r'^batdel_securitydevice.html',securitydeviceviews.batdel_securitydevice,name='batdel_securitydevice'), url(r'^excel_securitydevice.html',securitydeviceviews.excel_securitydevice,name='excel_securitydevice'), url(r'^search_storagedevice.html',storagedeviceviews.add_storagedevice,name="add_storagedevice"), url(r'^edit_storagedevice.html$',storagedeviceviews.edit_storagedevice,name="edit_storagedevice"), url(r'^del_storagedevice.html',storagedeviceviews.del_storagedevice,name='del_storagedevice'), url(r'^batdel_storagedevice.html',storagedeviceviews.batdel_storagedevice,name='batdel_storagedevice'), url(r'^excel_storagedevice.html',storagedeviceviews.excel_storagedevice,name='excel_storagedevice'), ] cmdbapp/networkdeviceviews.py securitydeviceviews.py storagedeviceviews.py -- coding: utf-8 -- from future import unicode_literals from django.shortcuts import render,render_to_response from django.core.paginator import Paginator,InvalidPage,EmptyPage from cmdbapp.models import * from django.http import HttpResponse from django.http import HttpResponseRedirect from xlwt import * import StringIO def search_networkdevice(request): error = False each_page = 8 mname=request.GET.get('mname','').strip() sname=request.GET.get('sname','').strip() ip=request.GET.get('ip','').strip() os=request.GET.get('os','').strip() status=int(request.GET.get('status',100)) if mname=='' and sname=='' and ip=='' and os=='' and status==100: record_list = Networkdevice.objects.all() paginator = Paginator(record_list,each_page) try: page = int(request.GET.get('page', '1')) except ValueError: page = 1 try: contacts = paginator.page(page) except (EmptyPage, InvalidPage): contacts = paginator.page(paginator.num_pages) return render_to_response('search_networkdevice.html',{'networkdevicelist':contacts,"mname":mname,"sname":sname,"ip":ip,"os":os,"status":status}) else: q={} if mname!='' and sname=='' and ip=='' and os=='' and status==100: a=Machinaroom.objects.filter(name__icontains=mname).values("id") q['machinaroom__in']=a if sname!='': q['hostname__icontains']=sname if ip!='': q['ip__icontains']=ip if os!='': q['model_icontains']=os if status!=100: q['status']=status record_list = Networkdevice.objects.filter(**q) paginator = Paginator(record_list,each_page) try: page = int(request.GET.get('page', '1')) except ValueError: page = 1 try: contacts = paginator.page(page) except (EmptyPage, InvalidPage): contacts = paginator.page(paginator.num_pages) return render_to_response('search_networkdevice.html',{'networkdevicelist':contacts,"mname":mname,"sname":sname,"ip":ip,"os":os,"status":status}) def add_networkdevice(request): if request.method=='GET': objs=Machinaroom.objects.all() return render_to_response("add_networkdevice.html",{"machinaroomlist":objs}) else: hostname=request.POST.get("networkdevicehostname","") model=request.POST.get("networkdevicemodel","") ip=request.POST.get("networkdeviceip","") memo=request.POST.get("networkdevicememo","") port_num=request.POST.get('networkdeviceport_num','') status=request.POST.get("networkdevicestatus",0) machinaroomid=request.POST.get("networkdevicemachinaroom") machinaroom=Machinaroom.objects.get(id=int(machinaroomid)) uu=Networkdevice(hostname=hostname,model=model,ip=ip,memo=memo,port_num=port_num,status=status,machinaroom=machinaroom) uu.save() return HttpResponseRedirect("add_networkdevice.html") def edit_networkdevice(request): if request.method=='GET': obj=Networkdevice.objects.get(id=int(request.GET.get('id'))) objs=Machinaroom.objects.all() return render_to_response('edit_networkdevice.html',{'networkdevice':obj,'machinaroomlist':objs}) else: id=request.POST.get("id") hostname=request.POST.get("networkdevicehostname","") model=request.POST.get("networkdevicemodel","") ip=request.POST.get("networkdeviceip","") memo=request.POST.get("networkdevicememo","") status=request.POST.get("networkdevicestatus",0) machinaroomid=request.POST.get("networkdevicemachinaroom") machinaroom=Machinaroom.objects.get(id=int(machinaroomid)) uu=Networkdevice.objects.filter(id=id).update(hostname=hostname,model=model,ip=ip,memo=memo,status=status,machinaroom=machinaroom) return HttpResponseRedirect("edit_networkdevice.html?id="+id) def del_networkdevice(request): id=request.GET.get('id') iid=int(id) Networkdevice.objects.filter(id=iid).delete() mname=request.GET.get('mname','').strip() sname=request.GET.get('sname','').strip() ip=request.GET.get('ip','').strip() os=request.GET.get('os','').strip() status=request.GET.get('status',100) page=request.GET.get('page','1') return HttpResponseRedirect('search_networkdevice.html?mname='+mname+"&&page="+page+"&&sname="+sname+"&&ip="+ip+"&&os="+os+"&&status="+status) def batdel_networkdevice(request): ids=request.GET.get('ids') b=ids.split(',') arr = map(int,b) for aaa in arr: Networkdevice.objects.filter(id=aaa).delete() mname=request.GET.get('mname') sname=request.GET.get('sname','').strip() ip=request.GET.get('ip','').strip() os=request.GET.get('os','').strip() status=request.GET.get('status',100) return HttpResponseRedirect('search_networkdevice.html?mname='+mname+"&&sname="+sname+"&&ip="+ip+"&&os="+os+"&&status="+status) def excel_networkdevice(request): mname=request.GET.get('mname','').strip() sname=request.GET.get('sname','').strip() ip=request.GET.get('ip','').strip() os=request.GET.get('os','').strip() status=int(request.GET.get('status',100)) if mname=='' and sname=='' and ip=='' and os=='' and status==100: list_obj = Networkdevice.objects.all() else: q={} if mname!='' and sname=='' and ip=='' and os=='' and status==100: a=Machinaroom.objects.filter(name__icontains=mname).values("id") q['machinaroom__in']=a if sname!='': q['hostname__icontains']=sname if ip!='': q['ip__icontains']=ip if os!='': q['model__icontains']=os if status!=100: q['status']=status list_obj = Networkdevice.objects.filter(**q) if list_obj: # 创建工作薄 ws = Workbook(encoding='utf-8') w = ws.add_sheet(u"网络设备清单") w.write(0, 0, "id") w.write(0, 1, u"设备名字") w.write(0, 2, u"制造商/型号") w.write(0, 3, u"IP") w.write(0, 4, u"端口数量") w.write(0,5,u"备注") w.write(0,6,u"状态") w.write(0,7,u"机房") # 写入数据 excel_row = 1 for obj in list_obj: data_id = obj.id data_hostname = obj.hostname data_model = obj.model data_ip = obj.ip data_port_num = obj.port_num data_memo=obj.memo if obj.status == 0: data_status='在线' elif obj.status == 1: data_status='已下线' elif obj.status == 2: data_status='未知' elif obj.status == 3: data_status='故障' else: data_status='备用' data_machinaroom=obj.machinaroom.name w.write(excel_row, 0, data_id) w.write(excel_row, 1, data_hostname) w.write(excel_row, 2, data_model) w.write(excel_row, 3, data_ip) w.write(excel_row, 4, data_port_num) w.write(excel_row, 5, data_memo) w.write(excel_row, 6, data_status) w.write(excel_row, 7, data_machinaroom) excel_row += 1 sio = StringIO.StringIO() ws.save(sio) sio.seek(0) response = HttpResponse(sio.getvalue(), content_type='application/vnd.ms-excel') response['Content-Disposition'] = 'attachment; filename=服务器清单-'+mname+sname+ip+os+'.xls' response.write(sio.getvalue()) return response -- coding: utf-8 -- from future import unicode_literals from django.shortcuts import render,render_to_response from django.core.paginator import Paginator,InvalidPage,EmptyPage from cmdbapp.models import * from django.http import HttpResponse from django.http import HttpResponseRedirect from xlwt import * import StringIO def search_securitydevice(request): error = False each_page = 8 mname=request.GET.get('mname','').strip() sname=request.GET.get('sname','').strip() ip=request.GET.get('ip','').strip() model=request.GET.get('model','').strip() type=request.GET.get('type','').strip() status=int(request.GET.get('status',100)) if mname=='' and sname=='' and ip=='' and model=='' and type=='' and status==100: record_list = Securitydevice.objects.all() paginator = Paginator(record_list,each_page) try: page = int(request.GET.get('page', '1')) except ValueError: page = 1 try: contacts = paginator.page(page) except (EmptyPage, InvalidPage): contacts = paginator.page(paginator.num_pages) return render_to_response('search_securitydevice.html',{'securitydevicelist':contacts,"mname":mname,"sname":sname,"ip":ip,"model":model,"type":type,"status":status}) else: q={} if mname!='' and sname=='' and ip=='' and model=='' and type=='' and status==100: a=Machinaroom.objects.filter(name__icontains=mname).values("id") q['machinaroom__in']=a if sname!='': q['hostname__icontains']=sname if ip!='': q['ip__icontains']=ip if model!='': q['model_icontains']=model if type!='': q['type_icontains']=type if status!=100: q['status']=status record_list = Securitydevice.objects.filter(**q) paginator = Paginator(record_list,each_page) try: page = int(request.GET.get('page', '1')) except ValueError: page = 1 try: contacts = paginator.page(page) except (EmptyPage, InvalidPage): contacts = paginator.page(paginator.num_pages) return render_to_response('search_securitydevice.html',{'securitydevicelist':contacts,"mname":mname,"sname":sname,"ip":ip,"model":model,"type":type,"status":status}) def add_securitydevice(request): if request.method=='GET': objs=Machinaroom.objects.all() return render_to_response("add_securitydevice.html",{"machinaroomlist":objs}) else: hostname=request.POST.get("securitydevicehostname","") model=request.POST.get("securitydevicemodel","") ip=request.POST.get("securitydeviceip","") memo=request.POST.get("securitydevicememo","") port_num=request.POST.get('securitydeviceport_num',0) status=request.POST.get("securitydevicestatus",0) machinaroomid=request.POST.get("securitydevicemachinaroom") machinaroom=Machinaroom.objects.get(id=int(machinaroomid)) type=request.POST.get("securitydevicetype","") uu=Securitydevice(hostname=hostname,model=model,ip=ip,type=type,memo=memo,port_num=port_num,status=status,machinaroom=machinaroom) uu.save() return HttpResponseRedirect("add_securitydevice.html") def edit_securitydevice(request): if request.method=='GET': obj=Securitydevice.objects.get(id=int(request.GET.get('id'))) objs=Machinaroom.objects.all() return render_to_response('edit_securitydevice.html',{'securitydevice':obj,'machinaroomlist':objs}) else: id=request.POST.get("id") hostname=request.POST.get("securitydevicehostname","") model=request.POST.get("securitydevicemodel","") ip=request.POST.get("securitydeviceip","") memo=request.POST.get("securitydevicememo","") status=request.POST.get("securitydevicestatus",0) port_num=request.POST.get("securitydeviceport_num",0) machinaroomid=request.POST.get("securitydevicemachinaroom") machinaroom=Machinaroom.objects.get(id=int(machinaroomid)) type=request.POST.get("securitydevicetype","") uu=Securitydevice.objects.filter(id=id).update(hostname=hostname,model=model,type=type,ip=ip,port_num=port_num,memo=memo,status=status,machinaroom=machinaroom) return HttpResponseRedirect("edit_securitydevice.html?id="+id) def del_securitydevice(request): id=request.GET.get('id') iid=int(id) Securitydevice.objects.filter(id=iid).delete() mname=request.GET.get('mname','').strip() sname=request.GET.get('sname','').strip() ip=request.GET.get('ip','').strip() model=request.GET.get('model','').strip() type=request.GET.get('type','').strip() status=request.GET.get('status',100) page=request.GET.get('page','1') return HttpResponseRedirect('search_securitydevice.html?mname='+mname+"&&page="+page+"&&sname="+sname+"&&ip="+ip+"&&model="+model+"&&type="+type+"&&status="+status) def batdel_securitydevice(request): ids=request.GET.get('ids') b=ids.split(',') arr = map(int,b) for aaa in arr: Securitydevice.objects.filter(id=aaa).delete() mname=request.GET.get('mname') sname=request.GET.get('sname','').strip() ip=request.GET.get('ip','').strip() model=request.GET.get('model','').strip() type=request.GET.get('type','').strip() status=request.GET.get('status',100) return HttpResponseRedirect('search_securitydevice.html?mname='+mname+"&&sname="+sname+"&&ip="+ip+"&&model="+model+"&&type="+type+"&&status="+status) def excel_securitydevice(request): mname=request.GET.get('mname','').strip() sname=request.GET.get('sname','').strip() ip=request.GET.get('ip','').strip() model=request.GET.get('model','').strip() type=request.GET.get('type','').strip() status=int(request.GET.get('status',100)) if mname=='' and sname=='' and ip=='' and model=='' and type=='' and status==100: list_obj = Securitydevice.objects.all() else: q={} if mname!='' and sname=='' and ip=='' and model=='' and type=='' and status==100: a=Machinaroom.objects.filter(name__icontains=mname).values("id") q['machinaroom__in']=a if sname!='': q['hostname__icontains']=sname if ip!='': q['ip__icontains']=ip if model!='': q['model__icontains']=model if type!='': q['type_icontains']=type if status!=100: q['status']=status list_obj = Securitydevice.objects.filter(**q) if list_obj: # 创建工作薄 ws = Workbook(encoding='utf-8') w = ws.add_sheet(u"网络设备清单") w.write(0, 0, "id") w.write(0, 1, u"设备名字") w.write(0, 2, u"制造商/型号") w.write(0, 3, u"IP") w.write(0, 4, u"端口数量") w.write(0,5,u"类型") w.write(0,6,u"备注") w.write(0,7,u"状态") w.write(0,8,u"机房") # 写入数据 excel_row = 1 for obj in list_obj: data_id = obj.id data_hostname = obj.hostname data_model = obj.model data_ip = obj.ip data_port_num = obj.port_num data_type=obj.type data_memo=obj.memo if obj.status == 0: data_status='在线' elif obj.status == 1: data_status='已下线' elif obj.status == 2: data_status='未知' elif obj.status == 3: data_status='故障' else: data_status='备用' data_machinaroom=obj.machinaroom.name w.write(excel_row, 0, data_id) w.write(excel_row, 1, data_hostname) w.write(excel_row, 2, data_model) w.write(excel_row, 3, data_ip) w.write(excel_row, 4, data_port_num) w.write(excel_row, 5, data_type) w.write(excel_row, 6, data_memo) w.write(excel_row, 7, data_status) w.write(excel_row, 8, data_machinaroom) excel_row += 1 sio = StringIO.StringIO() ws.save(sio) sio.seek(0) response = HttpResponse(sio.getvalue(), content_type='application/vnd.ms-excel') response['Content-Disposition'] = 'attachment; filename=服务器清单-'+mname+sname+ip+'.xls' response.write(sio.getvalue()) return response -- coding: utf-8 -- from future import unicode_literals from django.shortcuts import render,render_to_response from django.core.paginator import Paginator,InvalidPage,EmptyPage from cmdbapp.models import * from django.http import HttpResponse from django.http import HttpResponseRedirect from xlwt import * import StringIO def search_storagedevice(request): error = False each_page = 8 mname=request.GET.get('mname','').strip() sname=request.GET.get('sname','').strip() ip=request.GET.get('ip','').strip() model=request.GET.get('model','').strip() status=int(request.GET.get('status',100)) if mname=='' and sname=='' and ip=='' and model=='' and status==100: record_list = Storagedevice.objects.all() paginator = Paginator(record_list,each_page) try: page = int(request.GET.get('page', '1')) except ValueError: page = 1 try: contacts = paginator.page(page) except (EmptyPage, InvalidPage): contacts = paginator.page(paginator.num_pages) return render_to_response('search_storagedevice.html',{'storagedevicelist':contacts,"mname":mname,"sname":sname,"ip":ip,"model":model,"status":status}) else: q={} if mname!='' and sname=='' and ip=='' and model=='' and type=='' and status==100: a=Machinaroom.objects.filter(name__icontains=mname).values("id") q['machinaroom__in']=a if sname!='': q['hostname__icontains']=sname if ip!='': q['ip__icontains']=ip if model!='': q['model_icontains']=mode if status!=100: q['status']=status record_list = Storagedevice.objects.filter(**q) paginator = Paginator(record_list,each_page) try: page = int(request.GET.get('page', '1')) except ValueError: page = 1 try: contacts = paginator.page(page) except (EmptyPage, InvalidPage): contacts = paginator.page(paginator.num_pages) return render_to_response('search_storagedevice.html',{'storagedevicelist':contacts,"mname":mname,"sname":sname,"ip":ip,"model":model,"status":status}) def add_storagedevice(request): if request.method=='GET': objs=Machinaroom.objects.all() return render_to_response("add_storagedevice.html",{"machinaroomlist":objs}) else: hostname=request.POST.get("storagedevicehostname","") model=request.POST.get("storagedevicemodel","") ip=request.POST.get("storagedeviceip","") memo=request.POST.get("storagedevicememo","") disk=request.POST.get('storagedevicedisk','') status=request.POST.get("storagedevicestatus",0) machinaroomid=request.POST.get("storagedevicemachinaroom") machinaroom=Machinaroom.objects.get(id=int(machinaroomid)) uu=Storagedevice(hostname=hostname,model=model,ip=ip,memo=memo,disk=disk,status=status,machinaroom=machinaroom) uu.save() return HttpResponseRedirect("add_storagedevice.html") def edit_storagedevice(request): if request.method=='GET': obj=Storagedevice.objects.get(id=int(request.GET.get('id'))) objs=Machinaroom.objects.all() return render_to_response('edit_storagedevice.html',{'storagedevice':obj,'machinaroomlist':objs}) else: id=request.POST.get("id") hostname=request.POST.get("storagedevicehostname","") model=request.POST.get("storagedevicemodel","") ip=request.POST.get("storagedeviceip","") memo=request.POST.get("storagedevicememo","") status=request.POST.get("storagedevicestatus",0) machinaroomid=request.POST.get("storagedevicemachinaroom") machinaroom=Machinaroom.objects.get(id=int(machinaroomid)) disk=request.POST.get("storagedevicedisk","") uu=Storagedevice.objects.filter(id=id).update(hostname=hostname,model=model,disk=disk,ip=ip,memo=memo,status=status,machinaroom=machinaroom) return HttpResponseRedirect("edit_storagedevice.html?id="+id) def del_storagedevice(request): id=request.GET.get('id') iid=int(id) Storagedevice.objects.filter(id=iid).delete() mname=request.GET.get('mname','').strip() sname=request.GET.get('sname','').strip() ip=request.GET.get('ip','').strip() model=request.GET.get('model','').strip() status=request.GET.get('status',100) page=request.GET.get('page','1') return HttpResponseRedirect('search_storagedevice.html?mname='+mname+"&&page="+page+"&&sname="+sname+"&&ip="+ip+"&&model="+model+"&&status="+status) def batdel_storagedevice(request): ids=request.GET.get('ids') b=ids.split(',') arr = map(int,b) for aaa in arr: Storagedevice.objects.filter(id=aaa).delete() mname=request.GET.get('mname') sname=request.GET.get('sname','').strip() ip=request.GET.get('ip','').strip() model=request.GET.get('model','').strip() status=request.GET.get('status',100) return HttpResponseRedirect('search_storagedevice.html?mname='+mname+"&&sname="+sname+"&&ip="+ip+"&&model="+model+"&&status="+status) def excel_storagedevice(request): mname=request.GET.get('mname','').strip() sname=request.GET.get('sname','').strip() ip=request.GET.get('ip','').strip() model=request.GET.get('model','').strip() status=int(request.GET.get('status',100)) if mname=='' and sname=='' and ip=='' and model=='' and status==100: list_obj = Storagedevice.objects.all() else: q={} if mname!='' and sname=='' and ip=='' and model=='' and status==100: a=Machinaroom.objects.filter(name__icontains=mname).values("id") q['machinaroom__in']=a if sname!='': q['hostname__icontains']=sname if ip!='': q['ip__icontains']=ip if model!='': q['model__icontains']=model if status!=100: q['status']=status list_obj = Storagedevice.objects.filter(**q) if list_obj: # 创建工作薄 ws = Workbook(encoding='utf-8') w = ws.add_sheet(u"网络设备清单") w.write(0, 0, "id") w.write(0, 1, u"设备名字") w.write(0, 2, u"制造商/型号") w.write(0, 3, u"IP") w.write(0, 4, u"容量信息") w.write(0,5,u"备注") w.write(0,6,u"状态") w.write(0,7,u"机房") # 写入数据 excel_row = 1 for obj in list_obj: data_id = obj.id data_hostname = obj.hostname data_model = obj.model data_ip = obj.ip data_disk = obj.disk data_memo=obj.memo if obj.status == 0: data_status='在线' elif obj.status == 1: data_status='已下线' elif obj.status == 2: data_status='未知' elif obj.status == 3: data_status='故障' else: data_status='备用' data_machinaroom=obj.machinaroom.name w.write(excel_row, 0, data_id) w.write(excel_row, 1, data_hostname) w.write(excel_row, 2, data_model) w.write(excel_row, 3, data_ip) w.write(excel_row, 4, data_disk) w.write(excel_row, 5, data_memo) w.write(excel_row, 6, data_status) w.write(excel_row, 7, data_machinaroom) excel_row += 1 sio = StringIO.StringIO() ws.save(sio) sio.seek(0) response = HttpResponse(sio.getvalue(), content_type='application/vnd.ms-excel') response['Content-Disposition'] = 'attachment; filename=服务器清单-'+mname+sname+ip+'.xls' response.write(sio.getvalue()) return response 修改 models.py -- coding: utf-8 -- from future import unicode_literals from django.db import models class Machinaroom(models.Model): id=models.AutoField(primary_key=True) name=models.CharField(max_length=200,default=u'机房') location=models.CharField(max_length=200,default=u'厦门') vpnurl=models.URLField(default="") memo = models.CharField(u'备注', max_length=200,default="") def unicode(self): return self.name class Server(models.Model): """ 服务器信息 """ machinaroom= models.ForeignKey(Machinaroom) hostname = models.CharField(max_length=128, unique=True) model = models.CharField('制造商/型号', max_length=128, default="") ip = models.CharField('IP', max_length=128, default="") os = models.CharField('操作系统', max_length=128, default="") cpu = models.CharField('CPU', max_length=128, default="") memory=models.CharField('memory', max_length=128, default="") disk=models.CharField('硬盘信息',max_length=200, default="") status_choices = ((0, '在线'), (1, '已下线'), (2, '未知'), (3, '故障'), (4, '备用'), ) status = models.SmallIntegerField(choices=status_choices, default=0) memo = models.CharField(u'备注', max_length=200,default="") id =models.AutoField(primary_key=True) class Meta: verbose_name_plural = "服务器表" def __str__(self): return self.hostname class Networkdevice(models.Model): status_choices = ((0, '在线'), (1, '已下线'), (2, '未知'), (3, '故障'), (4, '备用'), ) status = models.SmallIntegerField(choices=status_choices, default=0) id =models.AutoField(primary_key=True) machinaroom= models.ForeignKey(Machinaroom) hostname = models.CharField(max_length=128, unique=True) port_num = models.SmallIntegerField(u'端口个数', default=0) model = models.CharField(u'型号', max_length=128, default="") ip = models.CharField(max_length=128, default="") memo = models.CharField(u'备注', max_length=200,default="") class Meta: verbose_name = '网络设备' verbose_name_plural = "网络设备" def __str__(self): return self.hostname class Securitydevice(models.Model): status_choices = ((0, '在线'), (1, '已下线'), (2, '未知'), (3, '故障'), (4, '备用'), ) status = models.SmallIntegerField(choices=status_choices, default=0) id =models.AutoField(primary_key=True) machinaroom= models.ForeignKey(Machinaroom) type=models.CharField(u'类型', max_length=128, default="") hostname = models.CharField(max_length=128, unique=True) port_num = models.SmallIntegerField(u'端口个数', default=0) model = models.CharField(u'型号', max_length=128, default="") memo = models.CharField(u'备注', max_length=200,default="") ip = models.CharField(max_length=128, default="") class Meta: verbose_name = '安全设备' verbose_name_plural = "安全设备" def __str__(self): return self.hostname class Storagedevice(models.Model): """存储设备""" machinaroom= models.ForeignKey(Machinaroom) model = models.CharField(u'型号', max_length=128, default="") id =models.AutoField(primary_key=True) hostname = models.CharField(max_length=128, unique=True,default="") ip = models.CharField(max_length=128, default="") status_choices = ((0, '在线'), (1, '已下线'), (2, '未知'), (3, '故障'), (4, '备用'), ) status = models.SmallIntegerField(choices=status_choices, default=0) disk=models.CharField('容量信息',max_length=200, default="") memo = models.TextField(u'备注', default="") class Meta: verbose_name = '存储设备' verbose_name_plural = "存储设备" def __str__(self): return self.model class Software(models.Model): sub_assset_type_choices = ( (0, 'OS'), (1, '办公\开发软件'), (2, '业务软件'), ) sub_asset_type = models.SmallIntegerField(choices=sub_assset_type_choices, verbose_name="服务器类型", default=0) license_num = models.IntegerField(verbose_name="授权数",default=0) version = models.CharField(u'软件/系统版本', max_length=64, help_text=u'eg. CentOS release 6.5 (Final)', unique=True) id =models.AutoField(primary_key=True) def __str__(self): return self.version class Meta: verbose_name = '软件/系统' verbose_name_plural = "软件/系统" class Manufactory(models.Model): """厂商""" id =models.AutoField(primary_key=True) manufactory = models.CharField(u'厂商名称', max_length=64, unique=True) support_num = models.CharField(u'支持电话', max_length=30, default="") memo = models.CharField(u'备注', max_length=128, default="") def __str__(self): return self.manufactory class Meta: verbose_name = '厂商' verbose_name_plural = "厂商" templates/add_networkdevice.html add_securitydevice.html add_storagedevice.html edit_networkdevice.html edit_securitydevice.html edit_storagedevice.html search_networkdevice.html search_securitydevice.html search_storagedevice.html <!DOCTYPE html> <html> <head> <title>CMDB</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script type="text/javascript" src="/static/scripts/jquery/jquery-1.7.1.js"></script> <link href="/static/style/authority/basic_layout.css" rel="stylesheet" type="text/css"> <link href="/static/style/authority/common_style.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="/static/scripts/authority/commonAll.js"></script> <script type="text/javascript" src="/static/scripts/jquery/jquery-1.4.4.min.js"></script> <script src="/static/scripts/My97DatePicker/WdatePicker.js" type="text/javascript" defer="defer"></script> <script type="text/javascript" src="/static/scripts/artDialog/artDialog.js?skin=default"></script> </head> <body> <form id="addnetworkdeviceform" name="addnetworkdeviceform" action="add_networkdevice.html" method="post"> <div id="container"> <div id="nav_links"> 当前位置:服务器资产管理><span style="color: #1A5CC6;">新增网络设备</span> <div id="page_close"> <a href="javascript:parent.$.fancybox.close();"> <img src="/static/images/common/page_close.png" width="20" height="20" style="vertical-align: text-top;"/> </a> </div> </div> <div class="ui_content"> <table cellspacing="0" cellpadding="0" width="100%" align="left" border="0"> <tr> <td class="ui_text_rt">设备名字</td> <td class="ui_text_lt"> <input type="text" id="networkdevicehostname" name="networkdevicehostname" value="" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">制造商/型号</td> <td class="ui_text_lt"> <input type="text" id="networkdevicemodel" name="networkdevicemodel" value="" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">IP</td> <td class="ui_text_lt"> <input type="text" id="networkdeviceip" name="networkdeviceip" value="" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">端口数量</td> <td class="ui_text_lt"> <input type="text" id="networkdeviceport_num" name="networkdeviceport_num" value="" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">备注</td> <td class="ui_text_lt"> <input type="text" id="networkdevicememo" name="networkdevicememo" value="" class="ui_input_txt02" /> </td> </tr> <tr> </tr> <tr> <td class="ui_text_rt">状态</td> <td class="ui_text_lt"> <select name="networkdevicestatus" id="networkdevicestatus" class="ui_select01" > <option value=0>在线</option> <option value=1>已下线</option> <option value=2>未知</option> <option value=3>故障</option> <option value=4>备用</option> </select> </td> </tr> <tr> <td class="ui_text_rt">所属机房</td> <td class="ui_text_lt"> <select name="networkdevicemachinaroom" id="networkdevicemachinaroom" class="ui_select01"> {% for mr in machinaroomlist %} <option value={{ mr.id }}>{{ mr.name }}</option> {% endfor %} </select> </td> </tr> <tr> <td></td> <td class="ui_text_lt"> <input id="submitbutton" type="submit" value="提交" class="ui_input_btn01"/> <input id="cancelbutton" type="cancel" value="取消" class="ui_input_btn01"/> </td> </tr> </table> </div> </div> </form> </body> </html> <!DOCTYPE html> <html> <head> <title>CMDB</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script type="text/javascript" src="/static/scripts/jquery/jquery-1.7.1.js"></script> <link href="/static/style/authority/basic_layout.css" rel="stylesheet" type="text/css"> <link href="/static/style/authority/common_style.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="/static/scripts/authority/commonAll.js"></script> <script type="text/javascript" src="/static/scripts/jquery/jquery-1.4.4.min.js"></script> <script src="/static/scripts/My97DatePicker/WdatePicker.js" type="text/javascript" defer="defer"></script> <script type="text/javascript" src="/static/scripts/artDialog/artDialog.js?skin=default"></script> </head> <body> <form id="addsecuritydeviceform" name="addsecuritydeviceform" action="add_securitydevice.html" method="post"> <div id="container"> <div id="nav_links"> 当前位置:服务器资产管理><span style="color: #1A5CC6;">新增安全设备</span> <div id="page_close"> <a href="javascript:parent.$.fancybox.close();"> <img src="/static/images/common/page_close.png" width="20" height="20" style="vertical-align: text-top;"/> </a> </div> </div> <div class="ui_content"> <table cellspacing="0" cellpadding="0" width="100%" align="left" border="0"> <tr> <td class="ui_text_rt">设备名字</td> <td class="ui_text_lt"> <input type="text" id="securitydevicehostname" name="securitydevicehostname" value="" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">制造商/型号</td> <td class="ui_text_lt"> <input type="text" id="securitydevicemodel" name="securitydevicemodel" value="" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">IP</td> <td class="ui_text_lt"> <input type="text" id="securitydeviceip" name="securitydeviceip" value="" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">端口数量</td> <td class="ui_text_lt"> <input type="text" id="securitydeviceport_num" name="securitydeviceport_num" value="" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">类型</td> <td class="ui_text_lt"> <input type="text" id="securitydevicetype" name="securitydevicetype" value="" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">备注</td> <td class="ui_text_lt"> <input type="text" id="securitydevicememo" name="securitydevicememo" value="" class="ui_input_txt02" /> </td> </tr> <tr> </tr> <tr> <td class="ui_text_rt">状态</td> <td class="ui_text_lt"> <select name="securitydevicestatus" id="securitydevicestatus" class="ui_select01" > <option value=0>在线</option> <option value=1>已下线</option> <option value=2>未知</option> <option value=3>故障</option> <option value=4>备用</option> </select> </td> </tr> <tr> <td class="ui_text_rt">所属机房</td> <td class="ui_text_lt"> <select name="securitydevicemachinaroom" id="securitydevicemachinaroom" class="ui_select01"> {% for mr in machinaroomlist %} <option value={{ mr.id }}>{{ mr.name }}</option> {% endfor %} </select> </td> </tr> <tr> <td></td> <td class="ui_text_lt"> <input id="submitbutton" type="submit" value="提交" class="ui_input_btn01"/> <input id="cancelbutton" type="cancel" value="取消" class="ui_input_btn01"/> </td> </tr> </table> </div> </div> </form> </body> </html> <!DOCTYPE html> <html> <head> <title>CMDB</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script type="text/javascript" src="/static/scripts/jquery/jquery-1.7.1.js"></script> <link href="/static/style/authority/basic_layout.css" rel="stylesheet" type="text/css"> <link href="/static/style/authority/common_style.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="/static/scripts/authority/commonAll.js"></script> <script type="text/javascript" src="/static/scripts/jquery/jquery-1.4.4.min.js"></script> <script src="/static/scripts/My97DatePicker/WdatePicker.js" type="text/javascript" defer="defer"></script> <script type="text/javascript" src="/static/scripts/artDialog/artDialog.js?skin=default"></script> </head> <body> <form id="addstoragedeviceform" name="addstoragedeviceform" action="add_storagedevice.html" method="post"> <div id="container"> <div id="nav_links"> 当前位置:服务器资产管理><span style="color: #1A5CC6;">新增存储设备</span> <div id="page_close"> <a href="javascript:parent.$.fancybox.close();"> <img src="/static/images/common/page_close.png" width="20" height="20" style="vertical-align: text-top;"/> </a> </div> </div> <div class="ui_content"> <table cellspacing="0" cellpadding="0" width="100%" align="left" border="0"> <tr> <td class="ui_text_rt">设备名字</td> <td class="ui_text_lt"> <input type="text" id="storagedevicehostname" name="storagedevicehostname" value="" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">制造商/型号</td> <td class="ui_text_lt"> <input type="text" id="storagedevicemodel" name="storagedevicemodel" value="" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">IP</td> <td class="ui_text_lt"> <input type="text" id="storagedeviceip" name="storagedeviceip" value="" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">容量信息</td> <td class="ui_text_lt"> <input type="text" id="storagedevicedisk" name="storagedevicedisk" value="" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">备注</td> <td class="ui_text_lt"> <input type="text" id="storagedevicememo" name="storagedevicememo" value="" class="ui_input_txt02" /> </td> </tr> <tr> </tr> <tr> <td class="ui_text_rt">状态</td> <td class="ui_text_lt"> <select name="storagedevicestatus" id="storagedevicestatus" class="ui_select01" > <option value=0>在线</option> <option value=1>已下线</option> <option value=2>未知</option> <option value=3>故障</option> <option value=4>备用</option> </select> </td> </tr> <tr> <td class="ui_text_rt">所属机房</td> <td class="ui_text_lt"> <select name="storagedevicemachinaroom" id="storagedevicemachinaroom" class="ui_select01"> {% for mr in machinaroomlist %} <option value={{ mr.id }}>{{ mr.name }}</option> {% endfor %} </select> </td> </tr> <tr> <td></td> <td class="ui_text_lt"> <input id="submitbutton" type="submit" value="提交" class="ui_input_btn01"/> <input id="cancelbutton" type="cancel" value="取消" class="ui_input_btn01"/> </td> </tr> </table> </div> </div> </form> </body> </html> <!DOCTYPE html> <html> <head> <title>CMDB</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script type="text/javascript" src="/static/scripts/jquery/jquery-1.7.1.js"></script> <link href="/static/style/authority/basic_layout.css" rel="stylesheet" type="text/css"> <link href="/static/style/authority/common_style.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="/static/scripts/authority/commonAll.js"></script> <script type="text/javascript" src="/static/scripts/jquery/jquery-1.4.4.min.js"></script> <script src="/static/scripts/My97DatePicker/WdatePicker.js" type="text/javascript" defer="defer"></script> <script type="text/javascript" src="/static/scripts/artDialog/artDialog.js?skin=default"></script> </head> <body> <form id="editnetworkdeviceform" name="editnetworkdeviceform" action="edit_networkdevice.html" method="post"> <div id="container"> <div id="nav_links"> 当前位置:服务器资产管理><span style="color: #1A5CC6;">编辑网络设备</span> <div id="page_close"> <a href="javascript:parent.$.fancybox.close();"> <img src="/static/images/common/page_close.png" width="20" height="20" style="vertical-align: text-top;"/> </a> </div> </div> <div class="ui_content"><input style="visibility:hidden" value={{ networkdevice.id }} type="text" name="id" id="id" /> <table cellspacing="0" cellpadding="0" width="100%" align="left" border="0"> <tr> <td class="ui_text_rt">设备名字</td> <td class="ui_text_lt"> <input type="text" id="networkdevicehostname" name="networkdevicehostname" value="{{ networkdevice.hostname }}" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">制造商/型号</td> <td class="ui_text_lt"> <input type="text" id="networkdevicemodel" name="networkdevicemodel" value="{{ networkdevice.model }}" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">IP</td> <td class="ui_text_lt"> <input type="text" id="networkdeviceip" name="networkdeviceip" value="{{ networkdevice.ip }}" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">端口数量</td> <td class="ui_text_lt"> <input type="text" id="networkdeviceport_num" name="networkdeviceport_num" value="{{ networkdevice.port_num }}" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">备注</td> <td class="ui_text_lt"> <input type="text" id="networkdevicememo" name="networkdevicememo" value="{{ networkdevice.memo }}" class="ui_input_txt02" /> </td> </tr> <tr> </tr> <tr> <td class="ui_text_rt">状态</td> <td class="ui_text_lt"> <select name="networkdevicestatus" id="networkdevicestatus" class="ui_select01" > <option value=0>在线</option> <option value=1>已下线</option> <option value=2>未知</option> <option value=3>故障</option> <option value=4>备用</option> </select> </td> </tr> <tr> <td class="ui_text_rt">所属机房</td> <td class="ui_text_lt"> <select name="networkdevicemachinaroom" id="networkdevicemachinaroom" class="ui_select01"> {% for mr in machinaroomlist %} <option value={{ mr.id }}>{{ mr.name }}</option> {% endfor %} </select> </td> </tr> <tr> <td>&nbsp;</td> <td class="ui_text_lt"> &nbsp;<input id="submitbutton" type="submit" value="提交" class="ui_input_btn01"/> &nbsp;<input id="cancelbutton" type="cancel" value="取消" class="ui_input_btn01"/> </td> </tr> </table> </div> </div> </form> </body> </html> <!DOCTYPE html> <html> <head> <title>CMDB</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script type="text/javascript" src="/static/scripts/jquery/jquery-1.7.1.js"></script> <link href="/static/style/authority/basic_layout.css" rel="stylesheet" type="text/css"> <link href="/static/style/authority/common_style.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="/static/scripts/authority/commonAll.js"></script> <script type="text/javascript" src="/static/scripts/jquery/jquery-1.4.4.min.js"></script> <script src="/static/scripts/My97DatePicker/WdatePicker.js" type="text/javascript" defer="defer"></script> <script type="text/javascript" src="/static/scripts/artDialog/artDialog.js?skin=default"></script> </head> <body> <form id="editsecuritydeviceform" name="editsecuritydeviceform" action="edit_securitydevice.html" method="post"> <div id="container"> <div id="nav_links"> 当前位置:服务器资产管理><span style="color: #1A5CC6;">编辑安全设备</span> <div id="page_close"> <a href="javascript:parent.$.fancybox.close();"> <img src="/static/images/common/page_close.png" width="20" height="20" style="vertical-align: text-top;"/> </a> </div> </div> <div class="ui_content"><input style="visibility:hidden" value={{ securitydevice.id }} type="text" name="id" id="id" /> <table cellspacing="0" cellpadding="0" width="100%" align="left" border="0"> <tr> <td class="ui_text_rt">设备名字</td> <td class="ui_text_lt"> <input type="text" id="securitydevicehostname" name="securitydevicehostname" value="{{ securitydevice.hostname }}" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">制造商/型号</td> <td class="ui_text_lt"> <input type="text" id="securitydevicemodel" name="securitydevicemodel" value="{{ securitydevice.model }}" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">IP</td> <td class="ui_text_lt"> <input type="text" id="securitydeviceip" name="securitydeviceip" value="{{ securitydevice.ip }}" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">端口数量</td> <td class="ui_text_lt"> <input type="text" id="securitydeviceport_num" name="securitydeviceport_num" value="{{ securitydevice.port_num }}" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">类型</td> <td class="ui_text_lt"> <input type="text" id="securitydevicetype" name="securitydevicetype" value="{{ securitydevice.type }}" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">备注</td> <td class="ui_text_lt"> <input type="text" id="securitydevicememo" name="securitydevicememo" value="{{ securitydevice.memo }}" class="ui_input_txt02" /> </td> </tr> <tr> </tr> <tr> <td class="ui_text_rt">状态</td> <td class="ui_text_lt"> <select name="securitydevicestatus" id="securitydevicestatus" class="ui_select01" > <option value=0>在线</option> <option value=1>已下线</option> <option value=2>未知</option> <option value=3>故障</option> <option value=4>备用</option> </select> </td> </tr> <tr> <td class="ui_text_rt">所属机房</td> <td class="ui_text_lt"> <select name="securitydevicemachinaroom" id="securitydevicemachinaroom" class="ui_select01"> {% for mr in machinaroomlist %} <option value={{ mr.id }}>{{ mr.name }}</option> {% endfor %} </select> </td> </tr> <tr> <td>&nbsp;</td> <td class="ui_text_lt"> &nbsp;<input id="submitbutton" type="submit" value="提交" class="ui_input_btn01"/> &nbsp;<input id="cancelbutton" type="cancel" value="取消" class="ui_input_btn01"/> </td> </tr> </table> </div> </div> </form> </body> </html> <!DOCTYPE html> <html> <head> <title>CMDB</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script type="text/javascript" src="/static/scripts/jquery/jquery-1.7.1.js"></script> <link href="/static/style/authority/basic_layout.css" rel="stylesheet" type="text/css"> <link href="/static/style/authority/common_style.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="/static/scripts/authority/commonAll.js"></script> <script type="text/javascript" src="/static/scripts/jquery/jquery-1.4.4.min.js"></script> <script src="/static/scripts/My97DatePicker/WdatePicker.js" type="text/javascript" defer="defer"></script> <script type="text/javascript" src="/static/scripts/artDialog/artDialog.js?skin=default"></script> </head> <body> <form id="editstoragedeviceform" name="editstoragedeviceform" action="edit_storagedevice.html" method="post"> <div id="container"> <div id="nav_links"> 当前位置:服务器资产管理><span style="color: #1A5CC6;">编辑存储设备</span> <div id="page_close"> <a href="javascript:parent.$.fancybox.close();"> <img src="/static/images/common/page_close.png" width="20" height="20" style="vertical-align: text-top;"/> </a> </div> </div> <div class="ui_content"><input style="visibility:hidden" value={{ storagedevice.id }} type="text" name="id" id="id" /> <table cellspacing="0" cellpadding="0" width="100%" align="left" border="0"> <tr> <td class="ui_text_rt">设备名字</td> <td class="ui_text_lt"> <input type="text" id="storagedevicehostname" name="storagedevicehostname" value="{{ storagedevice.hostname }}" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">制造商/型号</td> <td class="ui_text_lt"> <input type="text" id="storagedevicemodel" name="storagedevicemodel" value="{{ storagedevice.model }}" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">IP</td> <td class="ui_text_lt"> <input type="text" id="storagedeviceip" name="storagedeviceip" value="{{ storagedevice.ip }}" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">硬盘信息</td> <td class="ui_text_lt"> <input type="text" id="storagedevicedisk" name="storagedevicedisk" value="{{ storagedevice.disk }}" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">备注</td> <td class="ui_text_lt"> <input type="text" id="storagedevicememo" name="storagedevicememo" value="{{ storagedevice.memo }}" class="ui_input_txt02" /> </td> </tr> <tr> </tr> <tr> <td class="ui_text_rt">状态</td> <td class="ui_text_lt"> <select name="storagedevicestatus" id="storagedevicestatus" class="ui_select01" > <option value=0>在线</option> <option value=1>已下线</option> <option value=2>未知</option> <option value=3>故障</option> <option value=4>备用</option> </select> </td> </tr> <tr> <td class="ui_text_rt">所属机房</td> <td class="ui_text_lt"> <select name="storagedevicemachinaroom" id="storagedevicemachinaroom" class="ui_select01"> {% for mr in machinaroomlist %} <option value={{ mr.id }}>{{ mr.name }}</option> {% endfor %} </select> </td> </tr> <tr> <td>&nbsp;</td> <td class="ui_text_lt"> &nbsp;<input id="submitbutton" type="submit" value="提交" class="ui_input_btn01"/> &nbsp;<input id="cancelbutton" type="cancel" value="取消" class="ui_input_btn01"/> </td> </tr> </table> </div> </div> </form> </body> </html> {% extends 'base.html' %} {% block title %} <script type="text/javascript" src="/static/scripts/jquery/jquery-1.7.1.js"></script> <link href="/static/style/authority/basic_layout.css" rel="stylesheet" type="text/css"> <link href="/static/style/authority/common_style.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="/static/scripts/authority/commonAll.js"></script> <script type="text/javascript" src="/static/scripts/fancybox/jquery.fancybox-1.3.4.js"></script> <script type="text/javascript" src="/static/scripts/fancybox/jquery.fancybox-1.3.4.pack.js"></script> <link rel="stylesheet" type="text/css" href="/static/style/authority/jquery.fancybox-1.3.4.css" media="screen"></link> <script type="text/javascript" src="/static/scripts/artDialog/artDialog.js?skin=default"></script> <div id="container"> <div class="ui_content"> <div class="ui_text_indent"> <div id="box_border"> <div id="box_top">搜索</div> 机房名字<input type="text" id="mname" name="mname" value="{{ mname }}" class="ui_input_txt03" /> 设备名字<input type="text" id="sname" name="sname" value="{{ sname }}" class="ui_input_txt03" /> ip地址<input type="text" id="ip" name="ip" value="{{ ip }}" class="ui_input_txt03" /> 制造商/型号<input type="text" id="os" name="ip" value="{{ os }}" class="ui_input_txt03" /> 状态 <select id="status" name="status" class="ui_select02"> <option value=100 selected = "selected">所有</option> <option value=0 {% if status == 0 %} selected = "selected" {% endif %}>在线</option> <option value=1 {% if status == 1 %} selected = "selected" {% endif %}>已下线</option> <option value=2 {% if status == 2 %} selected = "selected" {% endif %}>未知</option> <option value=3 {% if status == 3 %} selected = "selected" {% endif %}>故障</option> <option value=4 {% if status == 4 %} selected = "selected" {% endif %}>备用</option> </select> </div> <div id="box_bottom"> <div class="pagination"> <span class="current"> {% if networkdevicelist.has_previous %} <a href="javascript:void(0)" onclick="search_networkdevice({{ networkdevicelist.previous_page_number }});">上一页</a> {% endif %} <span class="current"> Page {{ networkdevicelist.number }} of {{ networkdevicelist.paginator.num_pages }}. </span> {% if networkdevicelist.has_next %} <a href="javascript:void(0)" onclick="search_networkdevice({{ networkdevicelist.next_page_number }});">下一页</a> {% endif %} </span> </div> <input type="button" value="查询" class="ui_input_btn01" onclick="search_networkdevice(1);"/> <input type="button" value="新增" class="ui_input_btn01" onclick="add_networkdevice();" /> <input type="button" value="删除" class="ui_input_btn01" onclick="batdel_networkdevice();" /> <input type="button" value="导出EXCEL" class="ui_input_btn01" onclick="excel_networkdevice();" /> </div> </form> </div> </div> {% endblock %} {% block content %} <div class="ui_content"> <div class="ui_tb"> <table class="table" cellspacing="0" cellpadding="0" width="100%" align="center" border="0"> <tr> <th width="30"><input type="checkbox" id="id" name="id" /> </th> <th>设备名字</th> <th>制造商/型号</th> <th>IP</th> <th>端口数</th> <th>备注</th> <th>状态</th> <th>机房</th> <th>操作</th> </tr> {% for s in networkdevicelist.object_list %} <tr> <td><input type="checkbox" name="idcheck" value={{ s.id }} class="acb" /></td> <td>{{ s.hostname }}</td> <td>{{ s.model }}</td> <td>{{ s.ip }}</td> <td>{{ s.port_num }}</td> <td>{{ s.memo }}</td> <td>{% if s.status == 0 %} 在线 {% elif s.status == 1 %} 已下线 {% elif s.status == 2 %} 未知 {% elif s.status == 3 %} 故障 {% elif s.status == 4 %} 备用 {% endif %} </td> <td>{{ s.machinaroom.name }}</td> <td> <a href="javascript:void(0)" onclick="edit_networkdevice('{{ s.id }}')" class="edit">编辑</a> <a href="javascript:void(0)" onclick="del_networkdevice({{ s.id }},{{ networkdevicelist.number }});">删除</a> </td> </tr> {% endfor %} </table> </div> </div> </div> <script type="text/javascript"> function search_networkdevice(page){ var mname = document.getElementById("mname").value; var sname = document.getElementById("sname").value; var ip= document.getElementById("ip").value; var os= document.getElementById("os").value; var status = document.getElementById("status").value; var myurl="search_networkdevice.html"+"?"+"mname="+mname+"&&sname="+sname+"&&ip="+ip+"&&os="+os+"&&status="+status+"&&page="+page; window.location.assign(encodeURI(myurl)) } function add_networkdevice(){ var width = 400; var height = 500; var left = parseInt((screen.availWidth/2) - (width/2));//屏幕居中 var top = parseInt((screen.availHeight/2) - (height/2)); var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top; newWindow = window.open("add_networkdevice.html", "subWind", windowFeatures); } function edit_networkdevice(id){ var width = 400; var height = 500; var left = parseInt((screen.availWidth/2) - (width/2));//屏幕居中 var top = parseInt((screen.availHeight/2) - (height/2)); var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top; newWindow = window.open("edit_networkdevice.html?id="+id, "subWind", windowFeatures); } function del_networkdevice(id,page){ if(window.confirm('确定要删除该记录吗?')){ var text1= document.getElementById("mname").value; var sname=document.getElementById("sname").value; var ip=document.getElementById("ip").value; var os=document.getElementById("os").value; var status=document.getElementById("status").value; var myurl="del_networkdevice.html"+"?"+"id="+id+"&&mname="+text1+"&&page="+page+"&&ip="+ip+"&&os="+os+"&&status="+status+"&&sname="+sname; window.location.assign(encodeURI(myurl)) return true; }else{ //alert("取消"); return false; } } function batdel_networkdevice(){ if(window.confirm('确定要删除记录吗?')){ obj = document.getElementsByName("idcheck"); var text1= document.getElementById("mname").value; var sname=document.getElementById("sname").value; var ip=document.getElementById("ip").value; var os=document.getElementById("os").value; var status=document.getElementById("status").value; check_val = []; for(k in obj){ if(obj[k].checked) check_val.push(obj[k].value); } var myurl="batdel_networkdevice.html"+"?"+"ids="+check_val+"&&mname="+text1+"&&ip="+ip+"&&os="+os+"&&status="+status+"&&sname="+sname; window.location.assign(encodeURI(myurl)) return true; }else{ return false; } } function excel_networkdevice(){ var text1 = document.getElementById("mname").value; var sname=document.getElementById("sname").value; var ip=document.getElementById("ip").value; var os=document.getElementById("os").value; var status=document.getElementById("status").value; var myurl="excel_networkdevice.html"+"?mname="+text1+"&&ip="+ip+"&&os="+os+"&&status="+status+"&&sname="+sname; window.location.assign(encodeURI(myurl)) } </script> {% endblock %} {% extends 'base.html' %} {% block title %} <script type="text/javascript" src="/static/scripts/jquery/jquery-1.7.1.js"></script> <link href="/static/style/authority/basic_layout.css" rel="stylesheet" type="text/css"> <link href="/static/style/authority/common_style.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="/static/scripts/authority/commonAll.js"></script> <script type="text/javascript" src="/static/scripts/fancybox/jquery.fancybox-1.3.4.js"></script> <script type="text/javascript" src="/static/scripts/fancybox/jquery.fancybox-1.3.4.pack.js"></script> <link rel="stylesheet" type="text/css" href="/static/style/authority/jquery.fancybox-1.3.4.css" media="screen"></link> <script type="text/javascript" src="/static/scripts/artDialog/artDialog.js?skin=default"></script> <div id="container"> <div class="ui_content"> <div class="ui_text_indent"> <div id="box_border"> <div id="box_top">搜索</div> 机房名字<input type="text" id="mname" name="mname" value="{{ mname }}" class="ui_input_txt04" /> 设备名字<input type="text" id="sname" name="sname" value="{{ sname }}" class="ui_input_txt04" /> ip地址<input type="text" id="ip" name="ip" value="{{ ip }}" class="ui_input_txt04" /> 制造商/型号<input type="text" id="model" name="model" value="{{ model }}" class="ui_input_txt04" /> 类型<input type="text" id="type" name="type" value="{{ type }}" class="ui_input_txt04" /> 状态 <select id="status" name="status" class="ui_select02"> <option value=100 selected = "selected">所有</option> <option value=0 {% if status == 0 %} selected = "selected" {% endif %}>在线</option> <option value=1 {% if status == 1 %} selected = "selected" {% endif %}>已下线</option> <option value=2 {% if status == 2 %} selected = "selected" {% endif %}>未知</option> <option value=3 {% if status == 3 %} selected = "selected" {% endif %}>故障</option> <option value=4 {% if status == 4 %} selected = "selected" {% endif %}>备用</option> </select> </div> <div id="box_bottom"> <div class="pagination"> <span class="current"> {% if securitydevicelist.has_previous %} <a href="javascript:void(0)" onclick="search_securitydevice({{ securitydevicelist.previous_page_number }});">上一页</a> {% endif %} <span class="current"> Page {{ securitydevicelist.number }} of {{ securitydevicelist.paginator.num_pages }}. </span> {% if securitydevicelist.has_next %} <a href="javascript:void(0)" onclick="search_securitydevice({{ securitydevicelist.next_page_number }});">下一页</a> {% endif %} </span> </div> <input type="button" value="查询" class="ui_input_btn01" onclick="search_securitydevice(1);"/> <input type="button" value="新增" class="ui_input_btn01" onclick="add_securitydevice();" /> <input type="button" value="删除" class="ui_input_btn01" onclick="batdel_securitydevice();" /> <input type="button" value="导出EXCEL" class="ui_input_btn01" onclick="excel_securitydevice();" /> </div> </form> </div> </div> {% endblock %} {% block content %} <div class="ui_content"> <div class="ui_tb"> <table class="table" cellspacing="0" cellpadding="0" width="100%" align="center" border="0"> <tr> <th width="30"><input type="checkbox" id="id" name="id" /> </th> <th>设备名字</th> <th>制造商/型号</th> <th>IP</th> <th>端口数</th> <th>类型</th> <th>备注</th> <th>状态</th> <th>机房</th> <th>操作</th> </tr> {% for s in securitydevicelist.object_list %} <tr> <td><input type="checkbox" name="idcheck" value={{ s.id }} class="acb" /></td> <td>{{ s.hostname }}</td> <td>{{ s.model }}</td> <td>{{ s.ip }}</td> <td>{{ s.port_num }}</td> <td>{{ s.type }}</td> <td>{{ s.memo }}</td> <td>{% if s.status == 0 %} 在线 {% elif s.status == 1 %} 已下线 {% elif s.status == 2 %} 未知 {% elif s.status == 3 %} 故障 {% elif s.status == 4 %} 备用 {% endif %} </td> <td>{{ s.machinaroom.name }}</td> <td> <a href="javascript:void(0)" onclick="edit_securitydevice('{{ s.id }}')" class="edit">编辑</a> <a href="javascript:void(0)" onclick="del_securitydevice({{ s.id }},{{ securitydevicelist.number }});">删除</a> </td> </tr> {% endfor %} </table> </div> </div> </div> <script type="text/javascript"> function search_securitydevice(page){ var mname = document.getElementById("mname").value; var sname = document.getElementById("sname").value; var ip= document.getElementById("ip").value; var model= document.getElementById("model").value; var type=document.getElementById("type").value; var status = document.getElementById("status").value; var myurl="search_securitydevice.html"+"?"+"mname="+mname+"&&sname="+sname+"&&ip="+ip+"&&model="+model+"&&type="+type+"&&status="+status+"&&page="+page; window.location.assign(encodeURI(myurl)) } function add_securitydevice(){ var width = 400; var height = 500; var left = parseInt((screen.availWidth/2) - (width/2));//屏幕居中 var top = parseInt((screen.availHeight/2) - (height/2)); var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top; newWindow = window.open("add_securitydevice.html", "subWind", windowFeatures); } function edit_securitydevice(id){ var width = 400; var height = 500; var left = parseInt((screen.availWidth/2) - (width/2));//屏幕居中 var top = parseInt((screen.availHeight/2) - (height/2)); var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top; newWindow = window.open("edit_securitydevice.html?id="+id, "subWind", windowFeatures); } function del_securitydevice(id,page){ if(window.confirm('确定要删除该记录吗?')){ var text1= document.getElementById("mname").value; var sname=document.getElementById("sname").value; var ip=document.getElementById("ip").value; var model=document.getElementById("model").value; var type=document.getElementById("type").value; var status=document.getElementById("status").value; var myurl="del_securitydevice.html"+"?"+"id="+id+"&&mname="+text1+"&&page="+page+"&&ip="+ip+"&&model="+model+"&&type="+type+"&&status="+status+"&&sname="+sname; window.location.assign(encodeURI(myurl)) return true; }else{ //alert("取消"); return false; } } function batdel_securitydevice(){ if(window.confirm('确定要删除记录吗?')){ obj = document.getElementsByName("idcheck"); var text1= document.getElementById("mname").value; var sname=document.getElementById("sname").value; var ip=document.getElementById("ip").value; var model=document.getElementById("model").value; var type=document.getElementById("type").value; var status=document.getElementById("status").value; check_val = []; for(k in obj){ if(obj[k].checked) check_val.push(obj[k].value); } var myurl="batdel_securitydevice.html"+"?"+"ids="+check_val+"&&mname="+text1+"&&ip="+ip+"&&model="+model+"&&type="+type+"&&status="+status+"&&sname="+sname; window.location.assign(encodeURI(myurl)) return true; }else{ return false; } } function excel_securitydevice(){ var text1 = document.getElementById("mname").value; var sname=document.getElementById("sname").value; var ip=document.getElementById("ip").value; var model=document.getElementById("model").value; var type=document.getElementById("type").value; var status=document.getElementById("status").value; var myurl="excel_securitydevice.html"+"?mname="+text1+"&&ip="+ip+"&&model="+model+"&&type="+type+"&&status="+status+"&&sname="+sname; window.location.assign(encodeURI(myurl)) } </script> {% endblock %} {% extends 'base.html' %} {% block title %} <script type="text/javascript" src="/static/scripts/jquery/jquery-1.7.1.js"></script> <link href="/static/style/authority/basic_layout.css" rel="stylesheet" type="text/css"> <link href="/static/style/authority/common_style.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="/static/scripts/authority/commonAll.js"></script> <script type="text/javascript" src="/static/scripts/fancybox/jquery.fancybox-1.3.4.js"></script> <script type="text/javascript" src="/static/scripts/fancybox/jquery.fancybox-1.3.4.pack.js"></script> <link rel="stylesheet" type="text/css" href="/static/style/authority/jquery.fancybox-1.3.4.css" media="screen"></link> <script type="text/javascript" src="/static/scripts/artDialog/artDialog.js?skin=default"></script> <div id="container"> <div class="ui_content"> <div class="ui_text_indent"> <div id="box_border"> <div id="box_top">搜索</div> 机房名字<input type="text" id="mname" name="mname" value="{{ mname }}" class="ui_input_txt03" /> 设备名字<input type="text" id="sname" name="sname" value="{{ sname }}" class="ui_input_txt03" /> ip地址<input type="text" id="ip" name="ip" value="{{ ip }}" class="ui_input_txt03" /> 制造商/型号<input type="text" id="model" name="model" value="{{ model }}" class="ui_input_txt03" /> 状态 <select id="status" name="status" class="ui_select02"> <option value=100 selected = "selected">所有</option> <option value=0 {% if status == 0 %} selected = "selected" {% endif %}>在线</option> <option value=1 {% if status == 1 %} selected = "selected" {% endif %}>已下线</option> <option value=2 {% if status == 2 %} selected = "selected" {% endif %}>未知</option> <option value=3 {% if status == 3 %} selected = "selected" {% endif %}>故障</option> <option value=4 {% if status == 4 %} selected = "selected" {% endif %}>备用</option> </select> </div> <div id="box_bottom"> <div class="pagination"> <span class="current"> {% if storagedevicelist.has_previous %} <a href="javascript:void(0)" onclick="search_storagedevice({{ storagedevicelist.previous_page_number }});">上一页</a> {% endif %} <span class="current"> Page {{ storagedevicelist.number }} of {{ storagedevicelist.paginator.num_pages }}. </span> {% if storagedevicelist.has_next %} <a href="javascript:void(0)" onclick="search_storagedevice({{ storagedevicelist.next_page_number }});">下一页</a> {% endif %} </span> </div> <input type="button" value="查询" class="ui_input_btn01" onclick="search_storagedevice(1);"/> <input type="button" value="新增" class="ui_input_btn01" onclick="add_storagedevice();" /> <input type="button" value="删除" class="ui_input_btn01" onclick="batdel_storagedevice();" /> <input type="button" value="导出EXCEL" class="ui_input_btn01" onclick="excel_storagedevice();" /> </div> </form> </div> </div> {% endblock %} {% block content %} <div class="ui_content"> <div class="ui_tb"> <table class="table" cellspacing="0" cellpadding="0" width="100%" align="center" border="0"> <tr> <th width="30"><input type="checkbox" id="id" name="id" /> </th> <th>设备名字</th> <th>制造商/型号</th> <th>IP</th> <th>容量信息</th> <th>备注</th> <th>状态</th> <th>机房</th> <th>操作</th> </tr> {% for s in storagedevicelist.object_list %} <tr> <td><input type="checkbox" name="idcheck" value={{ s.id }} class="acb" /></td> <td>{{ s.hostname }}</td> <td>{{ s.model }}</td> <td>{{ s.ip }}</td> <td>{{ s.disk }}</td> <td>{{ s.memo }}</td> <td>{% if s.status == 0 %} 在线 {% elif s.status == 1 %} 已下线 {% elif s.status == 2 %} 未知 {% elif s.status == 3 %} 故障 {% elif s.status == 4 %} 备用 {% endif %} </td> <td>{{ s.machinaroom.name }}</td> <td> <a href="javascript:void(0)" onclick="edit_storagedevice('{{ s.id }}')" class="edit">编辑</a> <a href="javascript:void(0)" onclick="del_storagedevice({{ s.id }},{{ storagedevicelist.number }});">删除</a> </td> </tr> {% endfor %} </table> </div> </div> </div> <script type="text/javascript"> function search_storagedevice(page){ var mname = document.getElementById("mname").value; var sname = document.getElementById("sname").value; var ip= document.getElementById("ip").value; var model= document.getElementById("model").value; var status = document.getElementById("status").value; var myurl="search_storagedevice.html"+"?"+"mname="+mname+"&&sname="+sname+"&&ip="+ip+"&&model="+model+"&&status="+status+"&&page="+page; window.location.assign(encodeURI(myurl)) } function add_storagedevice(){ var width = 400; var height = 500; var left = parseInt((screen.availWidth/2) - (width/2));//屏幕居中 var top = parseInt((screen.availHeight/2) - (height/2)); var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top; newWindow = window.open("add_storagedevice.html", "subWind", windowFeatures); } function edit_storagedevice(id){ var width = 400; var height = 500; var left = parseInt((screen.availWidth/2) - (width/2));//屏幕居中 var top = parseInt((screen.availHeight/2) - (height/2)); var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top; newWindow = window.open("edit_storagedevice.html?id="+id, "subWind", windowFeatures); } function del_storagedevice(id,page){ if(window.confirm('确定要删除该记录吗?')){ var text1= document.getElementById("mname").value; var sname=document.getElementById("sname").value; var ip=document.getElementById("ip").value; var model=document.getElementById("model").value; var status=document.getElementById("status").value; var myurl="del_storagedevice.html"+"?"+"id="+id+"&&mname="+text1+"&&page="+page+"&&ip="+ip+"&&model="+model+"&&status="+status+"&&sname="+sname; window.location.assign(encodeURI(myurl)) return true; }else{ //alert("取消"); return false; } } function batdel_storagedevice(){ if(window.confirm('确定要删除记录吗?')){ obj = document.getElementsByName("idcheck"); var text1= document.getElementById("mname").value; var sname=document.getElementById("sname").value; var ip=document.getElementById("ip").value; var model=document.getElementById("model").value; var status=document.getElementById("status").value; check_val = []; for(k in obj){ if(obj[k].checked) check_val.push(obj[k].value); } var myurl="batdel_storagedevice.html"+"?"+"ids="+check_val+"&&mname="+text1+"&&ip="+ip+"&&model="+model+"&&status="+status+"&&sname="+sname; window.location.assign(encodeURI(myurl)) return true; }else{ return false; } } function excel_storagedevice(){ var text1 = document.getElementById("mname").value; var sname=document.getElementById("sname").value; var ip=document.getElementById("ip").value; var model=document.getElementById("model").value; var status=document.getElementById("status").value; var myurl="excel_storagedevice.html"+"?mname="+text1+"&&ip="+ip+"&&model="+model+"&&status="+status+"&&sname="+sname; window.location.assign(encodeURI(myurl)) } </script> {% endblock %}

优秀的个人博客,低调大师

我的网站搭建: (第十天) Ueditor后台编辑器

之前说过,我的网站编辑器一开始是tinymce,然后才用的ckeditor。可是最近我发现,ckeditor的小图标不是很美观,看久了有点low的样子。我是不是应该换一个编辑器呢,一想到这里,马上打开谷歌搜索有没有更加美观的富文本编辑器。翻了几页发现,才发现百度Ueditor编辑器就很不错,其实之前我就了解过,但是并没有学习去怎么使用,这回好了,换个富文本编辑器顺便把Ueditor给学会了 安装及使用 1.Ueditor其实对python2和python3有一定的区别,在写程序时想通过Django的form表单顺便把评论框也改成Ueditor,但是没有将其实现却发现了错误提示为: fromwidgetsimportUEditorWidget,AdminUEditorWidget ImportError:Nomodulenamed‘widgets’ 经查发现,DjangoUeditor是基于Python 2.7的,对Python3的支持有问题。导致widgets.py文件出错,不能import,解决方法可以修改widgets.py或者采用网上修改好的版本DjangoUeditor3,github就有很多Ueditor的代码,有些不能直接使用,可能太久没更新了吧,然后才找到了:https://github.com/twz915/DjangoUeditor3 2.使用git下载后,输入如下命令将源码安装到Python路径中 python3setup.pyinstall 3.将DjangooUeditor添加到Django的INSTALLED_APPS中 4.在blog下的models.py文件导入 fromDjangoUeditor.modelsimportUEditorField #将之前ckeditor body=RichTextUploadingField() #改为 body=UEditorField(u'内容',width=1100,height=300,toolbars="full",imagePath="images/",filePath="files/",upload_settings={"imageMaxSize":1204000},) 5.进入admin后台管理页面,可以看到这时编辑器已经换了个装 6.去掉百度编辑器 ueditor 元素路径、字数统计等 在百度编辑器 ueditor 根目录下: ueditor.config.js 文件中 搜索并将参数elementPathEnabled设置成false即可 常用功能开关如下: ,elementPathEnabled : false //是否启用元素路径,默认是true显示 ,wordCount:false //是否开启字数统计 ,autoHeightEnabled:false // 编辑器内容,是否自动长高,默认true ,fullscreen : false //是否开启初始化时即全屏,默认关闭 7.图标对比 ckeditor是这样的 ueditor是这样的 代码高亮 1.为了这个代码高亮可是浪费了我不少时间,一开始是发现在DjangoUeditor/staticueditor/thirdd-party/SyntaxHighlighter文件夹中有shCoreDefault.css和shCore.js这两个文件的,网上也有很多文章说了可以在详情页添加下面三个标签 运行完后,发现的确有些效果,可是伴随着还有另外三个问题 一个是代码之间的行距和字体太小,不便于代码的阅读,通过对网页元素进行分析,我找到了shCoreDefault.css文件中的两个属性,通过文件搜索找出来将它们注释就可以解决了 line-height:1.1em!important; font-size:13px!important; 如果说上面的问题还能接收,第二个问题就完全不适应了,那就是行号与代码不匹配,经常在代码的两头空出多行是没有注明行号的,看着很不习惯 还有第三个问题,代码过长的情况下,不能自动换行,就导致代码块容易超出父容器宽度。网上的解决办法都是在shCoreDefault.css文件中通过ctrl+F查找:.syntaxhighlighter{,然后在括弧中加入样式:word-break:break-all,这个有效果,已经测试过了,但是第二个问题实在能力有限,无法解决,被迫放弃使用DjangoUeditor中的css样式 2.放弃DjangoUeditor的自带样式后,又找到了第二条路,那就是使用Hlightjs,我想要的是类似github上的那种白色背景的代码高亮显示,幸运的是Hlightjs插件提供了太多太多的代码样式。我参考的文章地址:https://blog.csdn.net/msllws/article/details/81048390 3.在官网https://highlightjs.org/download/下载好Hlightjs插件后,与之前使用SyntaxHighlighter类似,添加下面三个标签 <!--foundation.css文件就是我选择的代码样式--> <linkrel="stylesheet"type="text/css"href="{%static'blog/css/foundation.css'%}"> <scripttype="text/javascript"src="{%static'blog/js/highlight.pack.js'%}"></script> <script>hljs.initHighlightingOnLoad();</script> 这个时候,还无法正常显示,因为代码高亮遵循的格式是:<pre><code>代码</code></pre>而百度编辑器默认的代码块显示格式为:<pre>代码</pre>,所以还需要再写上一个script,添加在body下面 <scripttype="text/javascript"> varallpre=document.getElementsByTagName("pre"); for(i=0;i<allpre.length;i++) { varonepre=document.getElementsByTagName("pre")[i]; varmycode=document.getElementsByTagName("pre")[i].innerHTML; onepre.innerHTML='<codeid="mycode">'+mycode+'</code>'; } </script> 这个时候已经能看出代码样式发生改变了,但是没有行号,所以还要给代码加上行号,先创建一个code.css文件,里面包含了code代码块行号的样式效果 pre{ position:relative; padding:0; /*margin-bottom:24px;*/ border-radius:3px; border:1pxsolid#C3CCD0; background:#FFF; overflow:hidden; font-size:14px; } code{ display:block; padding:18px24px; overflow-y:auto; font-weight:300; font-family:Menlo,monospace; font-size:14px; } code.has-numbering{ margin-left:30px; } .pre-numbering{ position:absolute; top:0; left:0; width:30px; padding:8px5px5px0; border-right:1pxsolid#C3CCD0; border-radius:3px003px; background-color:#f5f5f5; text-align:right; font-family:Menlo,monospace; font-size:14px; color:#8c8c8c; } 将上面的行号样式通过javascript绑定到每个li元素上 <scripttype="text/javascript"> $(function(){ $('precode').each(function(){ varlines=$(this).text().split('\n').length-1; var$numbering=$('<ul/>').addClass('pre-numbering'); $(this) .addClass('has-numbering') .parent() .append($numbering); for(i=1;i<=lines+100;i++){ $numbering.append($('<li/>').text(i)); } }); }); </script> 完成后,就已经实现Ueditor+Hightjs的代码高亮了 4.代码高亮对比 Ckeditor是这样的 Ueditor是这样的 其他常见问题 1.此时可能还会出现编辑框内图片无法正常缩放,是因为页面上引入了Bootstrap,而Bootstrap默认将box-sizing样式统一设成border-box了,在ueditor.min.css中加入如下代码,就算是填坑成功 .edui-container*{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;} .edui-container*:before,.edui-container*:after{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;} 2.在css中可能出现长串字母或者数字不会自动换行的问题,在对应css中加: word-break:break-all; 3.因为在编辑文章的时候,上传图片的宽度是用px来表示的,这就有可能导致图片宽度超出父容器宽度,所以需要重新对img元素进行宽度重定义 #post-bodyimg{ max-width:100%; } 4.在编辑超链接内容时可以发现,在移动端或者宽度很窄的显示屏上,a标签元素也常常超出容器宽度之外,这是因为ueditor对长字母或者长数字不会自动换行导致的,所以需要设置自动换行 #post-bodya{ word-break:break-all; } 5.用过ueditor的人都知道,还有一个常见问题就是在编辑器下使用的表格可以被预览,但是内容发布之后,在网页显示中是看不见边框的。网上很多人大都提议取修改ueditor.all.js或者ueditor.all.min.js,但是我按照那个方法行不通,不知道是哪里还出了错,所以我就直接用最粗暴的方式,在详情页中的样式加上 #post-bodytable,#post-bodytr,#post-bodytd{ border:1pxsolid#000; max-width:100%; } 最后,实在没想到换个富文本编辑器会弄出这么多问题,学习之路,最难也是最让人愉悦的,也只有学习才是生活

资源下载

更多资源
腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册
修改密码
忘记密码