Asset meta (#3539)

- 更改了资产表单,影响
  - 资产创建和更新
- 增加了资产平台数据库,影响
  - 平台创建更新和删除
- 更改了资产的platform字段,又一个字符字段,改为一个外键,影响 
  - 资产创建和更新
  - 资产连接 [windows,linux]
  - 测试连接等ansible任务
  - 自动化云导入
- 更改了资产的序列化器,影响
  - 资产创建更新列表
- 统一了树列表基础模板,影响
  - 资产列表页,权限列表页,vault页,资产收集页
- 统一了导入导出组件,影响
  - 资产导入导出
  - 用户导入导出
  - 用户组导入导出
  - 系统用户导入导出
  - 管理用户导入导出
  - vault导出导出
  - 收集用户列表导入导出
- 修改用户更新密码信号,影响
  - 修改用户密码产生的改密日志

- 新增Model instance序列化工具函数,影响
  - 操作日志生成
- 修改api mixin,新增 serializer_classes字段,serializer_classes = {"default": "", "display": "", "list": .., "other_action": ""}, 根据用户请求的方式返回不同的serializer_class,影响

  - 用户的viewset
  - 资产权限的viewset
- 统一系统配置中的tab切换
- 统一没有nav的页面,影响
  - 重置密码
  - 忘记密码
  - 重置中设置密码
  - 独立的message页面
- 修改用户组列表页,不再返还用户组下的用户,仅有数量
- 组织的一些方法变为layzproperty,避免重复计算
- 修改用户组详情页,影响
  - 用户组增加删除用户
This commit is contained in:
老广
2019-12-16 16:53:29 +08:00
committed by GitHub
parent 4ac4b517f4
commit e1919d0a62
96 changed files with 2323 additions and 2314 deletions

View File

@@ -0,0 +1,55 @@
{% extends 'base.html' %}
{% load static %}
{% load i18n %}
{% block help_message %}
{% endblock %}
{% block content %}
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-sm-3" id="split-left" style="padding-left: 3px;padding-right: 0">
{% include 'assets/_node_tree.html' %}
</div>
<div class="col-sm-9 animated fadeInRight" id="split-right">
<div class="tree-toggle" style="z-index: 10">
<div class="btn btn-sm btn-primary tree-toggle-btn" onclick="toggleSpliter()">
<i class="fa fa-angle-left fa-x" id="toggle-icon"></i>
</div>
</div>
<div class="mail-box-header">
{% block table_container %}
<table class="table table-striped table-bordered table-hover" id="{% block table_id %}editable{% endblock %}" >
<thead>
<tr>
{% block table_head %} {% endblock %}
</tr>
</thead>
<tbody>
{% block table_body %} {% endblock %}
</tbody>
</table>
{% endblock %}
</div>
</div>
</div>
</div>
<script>
var showTree = 1;
function toggleSpliter() {
if (showTree === 1) {
$("#split-left").hide(500, function () {
$("#split-right").attr("class", "col-sm-12");
$("#toggle-icon").attr("class", "fa fa-angle-right fa-x");
showTree = 1;
});
} else {
console.log("hide")
$("#split-right").attr("class", "col-sm-9");
$("#toggle-icon").attr("class", "fa fa-angle-left fa-x");
$("#split-left").show(500);
showTree = 0;
}
}
</script>
{% endblock %}

View File

@@ -0,0 +1,47 @@
{% load static %}
{% load i18n %}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="{{ FAVICON_URL }}" type="image/x-icon">
<title>{% block html_title %}{% endblock %}</title>
{% include '_head_css_js.html' %}
<link href="{% static "css/jumpserver.css" %}" rel="stylesheet">
<script type="text/javascript" src="{% url 'javascript-catalog' %}"></script>
<script src="{% static "js/jumpserver.js" %}"></script>
<style>
.passwordBox {
max-width: 560px;
margin: 0 auto;
padding: 100px 20px 20px 20px;
}
</style>
{% block custom_head_css_js %} {% endblock %}
</head>
<body class="gray-bg">
<div class="passwordBox animated fadeInDown">
<div class="row">
<div class="col-md-12">
<div class="ibox-content">
<img src="{{ LOGO_URL }}" style="margin: auto" width="50" height="50">
<h2 class="font-bold" style="display: inline">{% block title %}{% endblock %}</h2>
<h1></h1>
{% block content %} {% endblock %}
</div>
</div>
</div>
<hr/>
<div class="row">
<div class="col-md-12">
{% include '_copyright.html' %}
</div>
</div>
</div>
</body>
{% block custom_foot_js %} {% endblock %}
</html>

View File

@@ -0,0 +1,62 @@
{% load i18n %}
<div class="" style="float: right">
<div class=" btn-group">
<button data-toggle="dropdown" class="btn btn-default btn-sm dropdown-toggle">CSV <span class="caret"></span></button>
<ul class="dropdown-menu">
<li id="li_csv_export">
<a id="btn_csv_export" tabindex="0">
<span>{% trans "Export" %}</span>
</a>
</li>
<li id="li_csv_import">
<a id="btn_csv_import" data-toggle="modal" data-target="#csv_import_modal" tabindex="0">
<span>{% trans "Import" %}</span>
</a>
</li>
<li id="li_csv_update">
<a id="btn_csv_update" data-toggle="modal" data-target="#csv_update_modal" tabindex="0">
<span>{% trans "Update" %}</span>
</a>
</li>
</ul>
</div>
</div>
{% include '_csv_import_modal.html' %}
{% include '_csv_update_modal.html' %}
<script>
var csvTable = null;
var csvListUrl = null;
var csvExportCallback = null;
function initCsvImportExport(table, objectType, listUrl, hide) {
csvTable = table;
$(".csv_object_type").html(objectType);
csvListUrl = listUrl ? listUrl : csvTable.ajax.url();
if (hide && hide.length > 0) {
hide.forEach(function (v) {
$("#li_csv_" + v).hide();
})
}
}
var datatableInternalParams = ['draw', 'limit', 'order', 'offset'];
$(document).ready(function () {
}).on('click', '#btn_csv_export', function () {
var selectedObjects = csvTable.selected;
function _export() {
APIExportCSV({
listUrl: csvListUrl,
objectsId: selectedObjects,
table: csvTable
});
}
if (csvExportCallback) {
csvExportCallback(_export)
} else {
_export();
}
})
</script>

View File

@@ -0,0 +1,52 @@
{% extends '_modal.html' %}
{% load i18n %}
{% block modal_id %}csv_import_modal{% endblock %}
{% block modal_title%}<span class="csv_object_type">csv</span> {% trans 'Import' %}{% endblock %}
{% block modal_confirm_id %}btn_csv_import_confirm{% endblock %}
{% block modal_body %}
<form method="post" id="fm_import">
{% csrf_token %}
<div class="form-group">
<label class="control-label">{% trans "Download the imported template or use the exported CSV file format" %}</label>
<a id="csv_download_template" style="display: block">{% trans 'Download the import template' %}</a>
</div>
<div class="form-group">
<label class="control-label" for="id_file">{% trans "Select the CSV file to import" %}</label>
<input id="id_csv_file" type="file" name="file" />
</div>
</form>
<div style="max-height: 300px;overflow: auto">
<p class="text-success" id="success_created"></p>
<p id="success_created_detail"></p>
<p class="text-danger" id="created_failed"></p>
<p id="created_failed_detail"></p>
</div>
<script>
$(document).ready(function () {
}).on("click", '#csv_download_template', function () {
var theUrl ="csvImportURL?format=csv&template=import&limit=1" ;
theUrl = theUrl.replace("csvImportURL", csvListUrl);
window.open(theUrl)
}).on('click', '#btn_csv_import_confirm', function () {
var file = document.getElementById('id_csv_file').files[0];
if(!file){
toastr.error("{% trans "Please select file" %}");
return
}
APIImportData({
url: csvListUrl,
method: "POST",
body: file,
data_table: csvTable
});
})
</script>
{% endblock %}

View File

@@ -0,0 +1,54 @@
{% extends '_modal.html' %}
{% load i18n %}
{% block modal_id %}csv_update_modal{% endblock %}
{% block modal_confirm_id %}btn_csv_update_confirm{% endblock %}
{% block modal_title%}<span class="csv_object_type">csv</span> {% trans 'Update' %}{% endblock %}
{% block modal_body %}
<form method="post" id="fm_import">
{% csrf_token %}
<div class="form-group">
<label class="control-label">{% trans "Download the update template or use the exported CSV file format" %}</label>
<a id="csv_download_update_template" style="display: block">{% trans 'Download the update template' %}</a>
</div>
<div class="form-group">
<label class="control-label" for="update_file">{% trans "Select the CSV file to import" %}</label>
<input id="csv_update_file" type="file" name="file" />
</div>
</form>
<div>
<p class="text-warning" id="success_updated"></p>
<p id="success_updated_detail"></p>
<p class="text-danger" id="updated_failed"></p>
<p id="updated_failed_detail"></p>
</div>
<script>
$(document).ready(function () {
}).on('click', '#csv_download_update_template', function () {
var objectsId = csvTable.selected;
APIExportCSV({
listUrl: csvListUrl,
objectsId: objectsId,
template: 'update',
table: csvTable
});
}).on('click', '#btn_csv_update_confirm', function () {
var file = document.getElementById('csv_update_file').files[0];
if(!file){
toastr.error("{% trans "Please select file" %}");
return
}
APIImportData({
url: csvListUrl,
method: "PUT",
body: file,
data_table: csvTable
});
})
</script>
{% endblock %}

View File

@@ -45,6 +45,9 @@
<li id="system-user"><a href="{% url 'assets:system-user-list' %}">{% trans 'System user' %}</a></li>
<li id="label"><a href="{% url 'assets:label-list' %}">{% trans 'Labels' %}</a></li>
<li id="cmd-filter"><a href="{% url 'assets:cmd-filter-list' %}">{% trans 'Command filters' %}</a></li>
{% if request.user.is_superuser %}
<li id="platform"><a href="{% url 'assets:platform-list' %}">{% trans 'Platform list' %}</a></li>
{% endif %}
</ul>
</li>
{% endif %}

View File

@@ -0,0 +1,43 @@
{% load static %}
{% load i18n %}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title> {{ JMS_TITLE }} </title>
<link rel="shortcut icon" href="{{ FAVICON_URL }}" type="image/x-icon">
{# <link rel="stylesheet" href="{% static 'fonts/font_otp/iconfont.css' %}" />#}
<link rel="stylesheet" href="{% static 'css/otp.css' %}" />
<script src="{% static 'js/jquery-3.1.1.min.js' %}"></script>
<script type="text/javascript" src="{% url 'javascript-catalog' %}"></script>
</head>
<body>
<header>
<div class="logo">
<a href="{% url 'index' %}">
<img src="{{ LOGO_URL }}" alt="" width="50px" height="50px"/>
</a>
<a href="{% url 'index' %}">{{ JMS_TITLE }}</a>
</div>
<div>
<a href="{% url 'index' %}">{% trans 'Home page' %}</a>
<b></b>
<a href="http://docs.jumpserver.org/zh/docs/">{% trans 'Docs' %}</a>
<b></b>
<a href="https://www.github.com/jumpserver/">GitHub</a>
</div>
</header>
<body>
{% block body %}
{% endblock %}
</body>
<footer>
<div class="" style="margin-top: 100px;">
{% include '_copyright.html' %}
</div>
</footer>
</body>
</html>

View File

@@ -1,83 +1,64 @@
{% load i18n %}
{% extends '_base_only_content.html' %}
{% load static %}
<!DOCTYPE html>
<html>
{% load i18n %}
{% block html_title %} {{ title }} {% endblock %}
{% block title %} {{ title }}{% endblock %}
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{% block custom_head_css_js %}
<style>
.passwordBox {
max-width: 660px;
}
</style>
{% endblock %}
<title>{{ title }}</title>
{% include '_head_css_js.html' %}
<link href="{% static "css/jumpserver.css" %}" rel="stylesheet">
<script type="text/javascript" src="{% url 'javascript-catalog' %}"></script>
<script src="{% static "js/jumpserver.js" %}"></script>
</head>
<body class="gray-bg">
<div class="passwordBox2 animated fadeInDown">
<div class="row">
<div class="col-md-12">
<div class="ibox-content">
<div>
<img src="{{ LOGO_URL }}" style="margin: auto" width="82" height="82">
<h2 style="display: inline">
{{ JMS_TITLE }}
</h2>
</div>
{% if errors %}
<p>
<div class="alert alert-danger">
{{ errors }}
</div>
</p>
{% endif %}
{% if messages %}
<p>
<div class="alert alert-success" id="messages">
{{ messages|safe }}
</div>
</p>
{% endif %}
<div class="row">
<div class="col-lg-3">
<a href="{{ redirect_url }}" class="btn btn-primary block full-width m-b">{% trans 'Return' %}</a>
</div>
</div>
</div>
{% block content %}
<div>
{% if errors %}
<p>
<div class="alert alert-danger">
{{ errors }}
</div>
</div>
<hr/>
</p>
{% endif %}
{% if messages %}
<p>
<div class="alert alert-success" id="messages">
{{ messages|safe }}
</div>
</p>
{% endif %}
<div class="row">
<div class="col-md-6">
{% include '_copyright.html' %}
<div class="col-lg-3">
<a href="{{ redirect_url }}" class="btn btn-primary block full-width m-b">{% trans 'Return' %}</a>
</div>
</div>
</div>
</body>
{% endblock %}
{% block custom_foot_js %}
<script>
var time = '{{ interval }}';
if (!time){
if (!time) {
time = 5;
} else {
time = parseInt(time);
}
function redirect_page() {
if (time >= 0) {
var messages = '{{ messages|safe }} <b>' + time +'</b> ...';
var messages = '{{ messages|safe }} <b>' + time + '</b> ...';
$('#messages').html(messages);
time--;
setTimeout(redirect_page, 1000);
}
else {
} else {
window.location.href = "{{ redirect_url }}";
}
}
{% if auto_redirect %}
window.onload = redirect_page;
window.onload = redirect_page;
{% endif %}
</script>
</html>
{% endblock %}