v0.1 基础版本

v0.1 基础版本
This commit is contained in:
何全
2019-03-02 12:02:55 +08:00
parent 16f25e8147
commit a059c74cb4
2331 changed files with 524759 additions and 2 deletions

View File

@@ -0,0 +1,95 @@
{% extends "base/base.html" %}
{% load bootstrap4 %}
{% block title %}资产添加/修改{% endblock %}
{% block header-css %}
{% endblock %}
{% block page-content %}
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-lg-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>资产添加/修改</h5>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="close-link">
<i class="fa fa-times"></i>
</a>
</div>
</div>
<div class="ibox-content">
<form enctype="multipart/form-data" method="post" class="form-horizontal" action="">
{% csrf_token %}
{% if form.non_field_errors %}
<div class="alert alert-danger" style="margin: 20px auto 0px">
{{ form.non_field_errors }}
</div>
{% endif %}
<div class="form-group">
<div class="col-sm-10 col-sm-offset-0">
<h3>基本</h3>
{% bootstrap_field form.hostname layout="horizontal" %}
{% bootstrap_field form.type layout="horizontal" %}
{% bootstrap_field form.instance_id layout="horizontal" %}
{% bootstrap_field form.instance_name layout="horizontal" %}
{% bootstrap_field form.os_name layout="horizontal" %}
{% bootstrap_field form.cpu layout="horizontal" %}
{% bootstrap_field form.memory layout="horizontal" %}
{% bootstrap_field form.private_ip layout="horizontal" %}
{% bootstrap_field form.public_ip layout="horizontal" %}
</div>
</div>
<input type="hidden" name="__next__" value="{{ i__next__ }}">
<div class="hr-line-dashed"></div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-3">
{% bootstrap_button "保存" button_type="submit" button_class="btn-primary" %}
<a class="btn btn-white" href="{{ i__next__ }}">取消</a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
{% block footer-js %}
<script>
window.onload = function () {
$(".assets").addClass("active");
$(".ecs-create").addClass("active");
}
</script>
{% endblock %}
{% endblock %}

View File

@@ -0,0 +1,134 @@
{% extends "base/base.html" %}
{% block title %}资产详情{% endblock %}
{% block header-css %}
{% load bootstrap4 %}
{% endblock %}
{% block page-content %}
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="panel-options">
<ul class="nav nav-tabs">
<li class="active">
<a class="text-center"><i class="fa fa-laptop"></i>资产详情</a>
</li>
</ul>
</div>
<div class="tab-content">
<div class="col-sm-7" style="padding-left: 0">
<div class="ibox float-e-margins">
<div class="ibox-title">
<span class="label"><b>{{ ecs.hostname }}</b></span>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="close-link">
<i class="fa fa-times"></i>
</a>
</div>
</div>
<div class="ibox-content">
<table class="table">
<tbody>
<tr>
<td style=" border-top: none !important;" width="20%">主机类型:</td>
<td style=" border-top: none !important;"><b>{{ ecs.get_type_display }}</b>
</td>
</tr>
<tr>
<td width="20%">实例ID:</td>
<td><b>{{ ecs.instance_id }}</b>
</td>
</tr>
<tr>
<td width="20%">标签:</td>
<td><b>{{ ecs.instance_name }}</b>
</td>
</tr>
<tr>
<td width="20%">系统版本:</td>
<td><b>{{ ecs.os_name }}</b>
</td>
</tr>
<tr>
<td width="20%">CPU:</td>
<td><b>{{ ecs.cpu }}</b>
</td>
</tr>
<tr>
<td width="20%">内存:</td>
<td><b>{{ ecs.memory }}</b>
</td>
</tr>
<tr>
<td width="20%">内网IP:</td>
<td><b>{{ ecs.private_ip }}</b>
</td>
</tr>
<tr>
<td width="20%">外网IP:</td>
<td><b>{{ ecs.public_ip }}</b>
</td>
</tr>
<tr>
<td width="20%">创建时间:</td>
<td><b>{{ ecs.c_time }}</b>
</td>
</tr>
<tr>
<td width="20%">更新时间:</td>
<td><b>{{ ecs.u_time }}</b>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% block footer-js %}
<script>
window.onload = function () {
$(".assets").addClass("active");
$(".ecs-list").addClass("active");
};
</script>
{% endblock %}
{% endblock %}

View File

@@ -0,0 +1,280 @@
{% extends "base/base.html" %}
{% load i18n %}
{% load asset_filter %}
{% load bootstrap4 %}
{% load static %}
{% block header-css %}
<style type="text/css">
.sort_both_png {
background: url('/static/img/sort_both.png') no-repeat right 1px center;
cursor: pointer;
}
.sort_asc_png {
background: url('/static/img/sort_asc.png') no-repeat right 1px center;
cursor: pointer;
}
.sort_desc_png {
background: url('/static/img/sort_desc.png') no-repeat right 1px center;
cursor: pointer;
}
</style>
{% endblock %}
{% block title %}资产列表{% endblock %}
{% block page-content %}
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-lg-12" id="split-right">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>资产列表</h5>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="close-link">
<i class="fa fa-times"></i>
</a>
</div>
</div>
<div class="ibox-content">
<form id="cha" class="form-horizontal" action="{% url 'assets:ecs-list' %}" method="GET">
{% csrf_token %}
<div class="row">
<div class="col-sm-2">
<input class="form-control input-sm" type="text" name="hostname__icontains"
id="hostname"
placeholder="主机名" style=""/>
</div>
<div class="col-sm-2">
<select class="input-sm form-control select2 inline" name="type" id="type">
<option value="">主机类型</option>
{% for i in ''|ecs_type_choices %}
<option value="{{ i.0 }}">{{ i.1 }}</option>
{% endfor %}
</select>
</div>
<div class="col-sm-2">
<button type="submit" class="btn btn-sm btn-primary"> 搜索</button>
</div>
</div>
</form>
<br/>
<div class="table-responsive">
{# <a href="{% url 'asset:ecs_export' %}" class="btn btn-sm btn-primary ">导出</a>#}
<form class="form-horizontal "
method="post">
{% csrf_token %}
<table class="table table-striped table-bordered table-hover dataTables-asset">
<thead>
<tr>
<th>主机名</th>
<th>主机类型</th>
<th>实例ID</th>
<th>标签</th>
<th>系统版本</th>
<th>内网IP</th>
<th {% if request.GET.order_by == "-c_time" %}
class="sort_asc_png" onclick="window.location.href='?order_by=c_time'"
{% elif request.GET.order_by == "c_time" %}
class="sort_desc_png"
onclick="window.location.href='?order_by=-c_time'"
{% else %}
class="sort_both_png" onclick="window.location.href='?order_by=c_time'"
{% endif %}>创建时间
</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{% for row in ecs_list.object_list %}
<tr class="gradeA" id="{{ row.id }}" name="{{ row.hostname }}">
<td class="center">
<div class="">{{ row.hostname }}</div>
</td>
<td class="center">
<div class="">{{ row.get_type_display }}</div>
</td>
<td class="center">
<div class="">{{ row.instance_id }}</div>
</td>
<td class="center">
<div class="">{{ row.instance_name }}</div>
</td>
<td class="center">
<div class="">{{ row.os_name }}</div>
</td>
<td class="center">
<div class="">{{ row.private_ip }}</div>
</td>
<td class="center">
<div class="">{{ row.c_time | date:'Y-m-d' }}</div>
</td>
<td>
{% if perms.assets.view_ecs %}
<a class="btn btn-success btn-xs "
href="{% url "assets:ecs-detail" pk=row.id %}">详情</a>
{% endif %}
{% if perms.assets.change_ecs %}
<a class="btn btn-primary btn-xs "
href="{% url "assets:ecs-update" pk=row.id %}">编辑</a>
{% endif %}
{% if perms.assets.delete_ecs %}
<a class="btn btn-danger btn-xs ecs-delete"
href="#">删除</a>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="m-auto">
<nav class="pagination">
&nbsp;
<li><a href="{% url "assets:ecs-list" %}?page=1">首页 </a></li>
{% if ecs_list.has_previous %}
<li class="long"><a
href="?{{ ecs_list.previous_page_number.querystring }}">上一页</a>
</li>
{% endif %}
{% for page in ecs_list.pages %}
{% if page %}
{% ifequal page ecs_list.number %}
<li class="active"><a href="?{{ page.querystring }}">{{ page }}</a>
</li>
{% else %}
<li><a href="?{{ page.querystring }}" class="page">{{ page }}</a>
</li>
{% endifequal %}
{% else %}
<li class="none"><a href="">...</a></li>
{% endif %}
{% endfor %}
{% if ecs_list.has_next %}
<li class="long"><a
href="?{{ ecs_list.next_page_number.querystring }}">下一页</a>
</li>
{% endif %}
<li>
<a href="{% url "assets:ecs-list" %}?page={{ ecs_list.paginator.num_pages }}">尾页 </a>
</li>
<li><span
style="color: #0a0a0a">总: &nbsp;{{ ecs_list.paginator.num_pages }} 页</span>
</li>
<li><span
style="color: #0a0a0a"> 数量: {{ ecs_count }}</span>
</li>
</nav>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
{% block footer-js %}
<script>
window.onload = function () { // 固定左边导航栏
$(".assets").addClass("active");
$(".ecs-list").addClass("active");
};
var filter_dict = {{ filter_dict | safe}}; // 搜索完之后,还能保存搜索项目
$("#hostname").val(filter_dict['hostname__icontains']);
$("#type").val(filter_dict['type']);
$(function () {
$(document).on('click', '.ecs-delete', function () {
var id = $(this).parent().parent().attr('id');
var name = $(this).parent().parent().attr('name');
swal({
title: "你确定删除",
text: name,
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "确定",
cancelButtonText: "取消",
closeOnConfirm: false
}, function () {
$.ajax({
url: "{% url 'assets:ecs-delete' %}",
type: 'POST',
data: {'nid': id},
success: function (data) {
var obj = JSON.parse(data);
if (obj.status) {
swal({title: "删除", text: "已成功删除", type: "success"}, function () {
window.location.reload();
})
} else {
swal("错误", "删除" + "[ " + obj.error + " ]" + "遇到错误", "error");
}
}
});
});
});
});
</script>
{% endblock %}
{% endblock %}

23
templates/base/_css.html Normal file
View File

@@ -0,0 +1,23 @@
{% load static %}
<link href=" {% static "css/bootstrap.min.css" %}" rel="stylesheet">
<link href="{% static "font-awesome/css/font-awesome.css" %}" rel="stylesheet">
<link href="{% static "css/animate.css" %}" rel="stylesheet">
<link href="{% static "css/style.css" %} " rel="stylesheet">
<link href="{% static "css/datatables.min.css" %} " rel="stylesheet">
<link href="{% static "css/plugins/select2/select2.min.css" %} " rel="stylesheet">
<link href="{% static "css/plugins/sweetalert/sweetalert.css" %}" rel="stylesheet">
<link href="{% static "css/animate.css" %}" rel="stylesheet">
<link href="{% static "css/style.css" %}" rel="stylesheet">
<link href="{% static "css/plugins/toastr/toastr.min.css" %}" rel="stylesheet">
<link href="{% static "css/plugins/steps/jquery.steps.css" %}" rel="stylesheet">

View File

@@ -0,0 +1,8 @@
<div class="footer">
<div class="pull-right">
<strong>Version 0.1 </strong>
</div>
<div>
<strong>海豹 作者:何全 邮箱: hequan2011@sina.com </strong>
</div>
</div>

88
templates/base/_js.html Normal file
View File

@@ -0,0 +1,88 @@
{% load static %}
<script src="{% static "js/plugins/umd/popper.js" %}"></script>
<script src="{% static "js/jquery-3.1.1.min.js" %}" type="text/javascript" ></script>
<script src="{% static "js/bootstrap.min.js" %}"></script>
<script src="{% static "js/plugins/metisMenu/jquery.metisMenu.js" %}"></script>
<script src="{% static "js/plugins/slimscroll/jquery.slimscroll.min.js" %}"></script>
<!-- Custom and plugin javascript -->
<script src="{% static "js/inspinia.js" %} "></script>
<script src="{% static "js/plugins/pace/pace.min.js" %}"></script>
<script src="{% static "js/datatables.min.js" %}"></script>
<script src="{% static "js/plugins/select2/select2.full.min.js" %}"></script>
<!-- Sweet alert -->
<script src="{% static "js/plugins/sweetalert/sweetalert.min.js" %}"></script>
<script type="text/JavaScript">
$.ajaxSetup({headers: {"X-CSRFToken": '{{ csrf_token }}'}});
</script>
<script>
$(document).ready(function () {
$('.dataTables-example').DataTable({
"oLanguage": {
"sLengthMenu": "每页显示 _MENU_ 条记录",
"sZeroRecords": "对不起,查询不到任何相关数据",
"sInfo": "当前显示 _START_ 到 _END_ 条,共 _TOTAL_条记录",
"sInfoEmtpy": "找不到相关数据",
"sInfoFiltered": " 数据表中共为 _MAX_ 条记录",
"sProcessing": "正在加载中...",
"sSearch": "搜索",
"oPaginate": {
"sFirst": "第一页",
"sPrevious": " 上一页 ",
"sNext": " 下一页 ",
"sLast": " 最后一页 "
}
},
dom: '<"html5buttons"B>lTfgitp,',
buttons: [ 'copy', 'csv', 'excel' ]
});
$('.dataTables-code').DataTable({
"oLanguage": {
"sLengthMenu": "每页显示 _MENU_ 条记录",
"sZeroRecords": "对不起,查询不到任何相关数据",
"sInfo": "当前显示 _START_ 到 _END_ 条,共 _TOTAL_条记录",
"sInfoEmtpy": "找不到相关数据",
"sInfoFiltered": " 数据表中共为 _MAX_ 条记录",
"sProcessing": "正在加载中...",
"sSearch": "搜索",
"oPaginate": {
"sFirst": "第一页",
"sPrevious": " 上一页 ",
"sNext": " 下一页 ",
"sLast": " 最后一页 "
}
},
bFilter: false,
"order": [[1, 'desc']],
"info": false,//是否显示页脚信息
destroy: true,
"ordering": false,
dom: '<"html5buttons"B>lTfgitp,',
buttons: [],
lengthMenu: [[-1], ["全部"]],
"paging": false, // 禁止分页
});
});
$(function () {
$(".select2").select2();
});
</script>

72
templates/base/_nav.html Normal file
View File

@@ -0,0 +1,72 @@
<nav class="navbar-default navbar-static-side" role="navigation">
<div class="sidebar-collapse">
<ul class="nav metismenu chrome-nav" id="side-menu">
<li class="nav-header">
<div class="dropdown profile-element">
{% if user.avatar %}
<span>
<img alt="image" class="img-circle" style="width:48px; height:48px;" src="{{ user.avatar }}"/>
</span>
{% endif %}
<a data-toggle="dropdown" class="dropdown-toggle" href="#">
<span class="clear"> <span class="block m-t-xs"> <strong
class="font-bold">{{ user }}</strong>
</span> <span class="text-muted text-xs block">
{% ifequal user.is_superuser 1 %}
管理员 {% else %} {{ user.position }} {% endifequal %}
<b class="caret"></b></span> </span>
</a>
<ul class="dropdown-menu animated fadeInRight m-t-xs">
<li><a href="{% url "system:password_update" %}">修改密码</a></li>
<li><a href="{% url "system:logout" %}">退出</a></li>
</ul>
</div>
<div class="logo-element">
海豹
</div>
</li>
<li>
<a href="{% url "index" %}"> <i class="fa fa-dashboard"></i> <span class="nav-label">首页</span>
</a>
</li>
<li class="assets">
<a href="#"> <i class="fa fa-gitlab"></i> <span class="nav-label">资产管理</span></a>
<ul class="nav nav-second-level">
{% if perms.assets.add_ecs %}
<li class="ecs-create">
<a href="{% url "assets:ecs-create" %}">添加资产</a>
</li>
{% endif %}
{% if perms.assets.view_ecs %}
<li class="ecs-list">
<a href="{% url "assets:ecs-list" %}">资产列表</a>
</li>
{% endif %}
</ul>
</li>
{% ifequal user.is_superuser 1 %}
<li>
<a href="/admin" target="_blank"><i class="fa fa-gears"></i> <span class="nav-label">管理界面</span>
</a>
</li>
{% endifequal %}
</ul>
</div>
</nav>

View File

@@ -0,0 +1,37 @@
<div class="row border-bottom">
<nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0">
<div class="navbar-header">
<a class="navbar-minimalize minimalize-styl-2 btn btn-primary " href="#"><i class="fa fa-bars"></i> </a>
{# <form role="search" class="navbar-form-custom" action="search_results.html">#}
{# <div class="form-group">#}
{# <input type="text" placeholder="请输入搜索内容" class="form-control" name="top-search" id="top-search">#}
{# </div>#}
{# </form>#}
</div>
<ul class="nav navbar-top-links navbar-right">
<li style="padding: 20px">
<span class="m-r-sm text-muted welcome-message">欢迎 {{ user }} 来到 海豹管理后台</span>
</li>
<li>
<a href="{% url "system:logout" %}">
<i class="fa fa-sign-out"></i> 注销
</a>
</li>
</ul>
</nav>
</div>

46
templates/base/base.html Normal file
View File

@@ -0,0 +1,46 @@
{% load staticfiles %}
{% load static %}
{% load bootstrap4 %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}{% endblock %}</title>
{% include "base/_css.html" %}
{% block header-css %}
{% endblock %}
</head>
<body>
<div id="wrapper">
{% include "base/_nav.html" %}
<div id="page-wrapper" class="gray-bg">
{% include "base/_navbar-static-top.html" %}
{% block page-content %}
{% endblock %}
{% include "base/_footer.html" %}
</div>
</div>
</body>
{% include "base/_js.html" %}
{% block footer-js %}
{% endblock %}
</html>

View File

@@ -0,0 +1,24 @@
{% extends "base/base.html" %}
{% load static %}
{% block title %} 海豹 | 首页{% endblock %}
{% block header-css %}
{% endblock %}
{% block page-content %}
<div class="wrapper wrapper-content">
</div>
{% endblock %}
{% block footer-js %}
{% endblock %}

View File

@@ -0,0 +1,57 @@
{% load static %}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>海豹 | 登录</title>
<link href=" {% static "css/bootstrap.min.css" %}" rel="stylesheet">
<link href="{% static "font-awesome/css/font-awesome.css" %}" rel="stylesheet">
<link href="{% static "css/animate.css" %}" rel="stylesheet">
<link href="{% static "css/style.css" %} " rel="stylesheet">
</head>
<body class="gray-bg">
<div class="middle-box text-center loginscreen animated fadeInDown">
<div>
<div>
</div>
<h3>欢迎登录 海豹 系统</h3>
<form class="m-t" role="form" action="{% url "system:login" %}" method="POST">
{% csrf_token %}
<div class="form-group">
<input type="text" name="username" class="form-control" placeholder="用户名" required="">
</div>
<div class="form-group">
<input type="password" name="password" class="form-control" placeholder="密码" required="">
</div>
<button type="submit" class="btn btn-primary block full-width m-b">登录</button>
<a href="#">
<span style="color: red;"> {{ error_msg }}</span><br>
不推荐使用IE/360浏览器(兼容模式)浏览!<br />
</a>
<div id="login_container"></div>
</form>
</div>
</div>
<script src="{% static "js/jquery-3.1.1.min.js" %}"></script>
<script src="{% static "js/bootstrap.min.js" %}"></script>
</body>
</html>

View File

@@ -0,0 +1,66 @@
{% extends "base/base.html" %}
{% load bootstrap4 %}
{% block title %}海豹 | 修改密码{% endblock %}
{% block header-css %}
{% endblock %}
{% block page-content %}
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="panel-options">
<ul class="nav nav-tabs">
<li class="active">
<a href="" class="text-center">密码 </a>
</li>
</ul>
</div>
<div class="tab-content" style="background-color: #ffffff">
<div class="wrapper wrapper-content animated fadeInRight">
<form method="post" class="form-horizontal" action="" enctype="multipart/form-data">
{% csrf_token %}
{% if form.non_field_errors %}
<div class="alert alert-danger" style="margin: 20px auto 0px">
{{ form.non_field_errors }}
</div>
{% endif %}
<div class="form-group">
<div class="col-sm-10 col-sm-offset-0"> {{ msg }}
{% bootstrap_field form.old_password layout="horizontal" %}
{% bootstrap_field form.new_password layout="horizontal" %}
{% bootstrap_field form.confirm_password layout="horizontal" %}</div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-3">
<button id="submit_button" class="btn btn-primary" type="submit">提交</button>
<button class="btn btn-white" type="reset">重置</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block footer-js %}
{% endblock %}