may be some wrong

pull/530/head
ibuler 2016-10-16 22:12:13 +08:00
parent 26a8bce2c3
commit 4531157c72
21 changed files with 198 additions and 54 deletions

14
apps/apps/api.py Normal file
View File

@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
#
from rest_framework.generics import ListCreateAPIView
from .models import Terminal
from .serializers import TerminalSerializer
class TerminalApi(ListCreateAPIView):
queryset = Terminal.objects.all()
serializer_class = TerminalSerializer

View File

@ -3,5 +3,5 @@ from __future__ import unicode_literals
from django.apps import AppConfig from django.apps import AppConfig
class TerminalConfig(AppConfig): class AppsConfig(AppConfig):
name = 'terminal' name = 'apps'

View File

@ -17,14 +17,13 @@ class Terminal(models.Model):
is_bound_ip = models.BooleanField(default=False, verbose_name=_('Is bound ip')) is_bound_ip = models.BooleanField(default=False, verbose_name=_('Is bound ip'))
heatbeat_interval = models.IntegerField(default=60, verbose_name=_('Heatbeat interval')) heatbeat_interval = models.IntegerField(default=60, verbose_name=_('Heatbeat interval'))
type = models.CharField(choices=TYPE_CHOICES, max_length=2, verbose_name=_('Terminal type')) type = models.CharField(choices=TYPE_CHOICES, max_length=2, verbose_name=_('Terminal type'))
ssh_host = models.CharField(max_length=100, verbose_name=_('SSH host')) url = models.CharField(max_length=100, verbose_name=_('URL to login'))
ssh_port = models.IntegerField(verbose_name=_('SSH port'))
mail_to = models.ManyToManyField(User, verbose_name=_('Mail to')) mail_to = models.ManyToManyField(User, verbose_name=_('Mail to'))
date_created = models.DateTimeField(auto_now_add=True) date_created = models.DateTimeField(auto_now_add=True)
comment = models.TextField(verbose_name=_('Comment')) comment = models.TextField(verbose_name=_('Comment'))
class Meta: class Meta:
db_table = 'terminal' db_table = 'apps'
ordering = ['name'] ordering = ['name']

17
apps/apps/serializers.py Normal file
View File

@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
#
from rest_framework import serializers
from .models import Terminal
class TerminalSerializer(serializers.ModelSerializer):
class Meta:
model = Terminal
fields = ['name', 'ip', 'type', 'url', 'comment', 'is_active',
'get_type_display']
if __name__ == '__main__':
pass

View File

@ -0,0 +1,79 @@
{% extends '_base_list.html' %}
{% load i18n static %}
{% block custom_head_css_js %}
{{ block.super }}
<style>
div.dataTables_wrapper div.dataTables_filter,
.dataTables_length {
float: right !important;
}
div.dataTables_wrapper div.dataTables_filter {
margin-left: 15px;
}
</style>
{% endblock %}
{% block table_search %}{% endblock %}
{% block table_container %}
{#<div class="uc pull-left m-l-5 m-r-5"><a href="{% url "users:user-create" %}" class="btn btn-sm btn-primary"> {% trans "Create user" %} </a></div>#}
<table class="table table-striped table-bordered table-hover " id="terminal_list_table" >
<thead>
<tr>
<th class="text-center">
<div class="checkbox checkbox-default">
<input type="checkbox" class="ipt_check_all">
</div>
</th>
<th class="text-center">{% trans 'Name' %}</th>
<th class="text-center">{% trans 'IP' %}</th>
<th class="text-center">{% trans 'Type' %}</th>
<th class="text-center">{% trans 'url' %}</th>
<th class="text-center">{% trans 'Active' %}</th>
<th class="text-center">{% trans 'Action' %}</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
{% endblock %}
{% block content_bottom_left %}{% endblock %}
{% block custom_foot_js %}
<script src="{% static 'js/jquery.form.min.js' %}"></script>
<script>
$(document).ready(function(){
var options = {
ele: $('#terminal_list_table'),
{# columnDefs: [#}
{# {targets: 1, createdCell: function (td, cellData, rowData) {#}
{# var detail_btn = '<a href="{% url "users:user-detail" pk=99991937 %}">' + cellData + '</a>';#}
{# $(td).html(detail_btn.replace('99991937', rowData.id));#}
{# }}#}
{# {targets: 4, createdCell: function (td, cellData) {#}
{# var innerHtml = cellData.length > 8 ? cellData.substring(0, 8) + '...': cellData;#}
{# $(td).html('<a href="javascript:void(0);" data-toggle="tooltip" title="' + cellData + '">' + innerHtml + '</a>');#}
{# }},#}
{# {targets: 6, createdCell: function (td, cellData) {#}
{# if (!cellData) {#}
{# $(td).html('<i class="fa fa-times text-danger"></i>')#}
{# } else {#}
{# $(td).html('<i class="fa fa-check text-navy"></i>')#}
{# }#}
{# }},#}
{# {targets: 7, createdCell: function (td, cellData, rowData) {#}
{# var update_btn = '<a href="{% url "users:user-update" pk=99991937 %}" class="btn btn-xs btn-info">{% trans "Update" %}</a>'.replace('99991937', cellData);#}
{# var del_btn = '<a class="btn btn-xs btn-danger m-l-xs btn_user_delete" data-uid="99991937">{% trans "Delete" %}</a>'.replace('99991937', cellData);#}
{# if (rowData.id === 1) {#}
{# $(td).html(update_btn)#}
{# } else {#}
{# $(td).html(update_btn + del_btn)#}
{# }}],#}
{# ],#}
ajax_url: '{% url "apps:apps-list-create-api" %}',
columns: [{data: function(){return ""}}, {data: "name" }, {data: "ip" }, {data: "get_type_display" }, {data: "url" },
{data: "is_active" }, {data: "ip"}],
op_html: $('#actions').html()
};
jumpserver.initDataTable(options);
})
</script>
{% endblock %}

18
apps/apps/urls.py Normal file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
from django.conf.urls import url
import views
import api
app_name = 'apps'
urlpatterns = [
url(r'^apps$', views.TerminalListView.as_view(), name='apps-list'),
]
urlpatterns += [
url(r'^v1/apps/$', api.TerminalApi.as_view(), name='apps-list-create-api'),
]

17
apps/apps/views.py Normal file
View File

@ -0,0 +1,17 @@
# ~*~ coding: utf-8 ~*~
#
from django.views.generic import ListView
from django.utils.translation import ugettext as _
from .models import Terminal
class TerminalListView(ListView):
model = Terminal
template_name = 'apps/terminal_list.html'
def get_context_data(self, **kwargs):
context = super(TerminalListView, self).get_context_data(**kwargs)
context.update({'app': _('Terminal'), 'action': _('Terminal list')})
return context

View File

@ -366,7 +366,7 @@ class Asset(models.Model):
class Tag(models.Model): class Tag(models.Model):
name = models.CharField(max_length=64, unique=True, verbose_name=_('Name')) name = models.CharField(max_length=64, unique=True, verbose_name=_('Name'))
created_time = models.DateTimeField(auto_now_add_add=True, verbose_name=_('Create time')) created_time = models.DateTimeField(auto_now_add=True, verbose_name=_('Create time'))
created_by = models.CharField(max_length=32, null=True, blank=True, verbose_name=_('Created by')) created_by = models.CharField(max_length=32, null=True, blank=True, verbose_name=_('Created by'))
def __unicode__(self): def __unicode__(self):

View File

@ -54,10 +54,10 @@ INSTALLED_APPS = [
'users.apps.UsersConfig', 'users.apps.UsersConfig',
'assets.apps.AssetsConfig', 'assets.apps.AssetsConfig',
'perms.apps.PermsConfig', 'perms.apps.PermsConfig',
'terminal.apps.TerminalConfig',
'ops.apps.OpsConfig', 'ops.apps.OpsConfig',
'audits.apps.AuditsConfig', 'audits.apps.AuditsConfig',
'common.apps.CommonConfig', 'common.apps.CommonConfig',
'apps.apps.TerminalConfig',
'rest_framework', 'rest_framework',
'rest_framework.authtoken', 'rest_framework.authtoken',
'bootstrapform', 'bootstrapform',

View File

@ -26,6 +26,7 @@ urlpatterns = [
url(r'^assets/', include('assets.urls')), url(r'^assets/', include('assets.urls')),
url(r'^perms/', include('perms.urls')), url(r'^perms/', include('perms.urls')),
url(r'^(api/)?audits/', include('audits.urls')), url(r'^(api/)?audits/', include('audits.urls')),
url(r'^(api/)?apps/', include('apps.urls')),
] ]

View File

@ -121,7 +121,7 @@ NgApp.controller('TerminalRecordCtrl', function ($scope, $http) {
timelist = timelist.sort(function(a, b){return a-b}); timelist = timelist.sort(function(a, b){return a-b});
totalTime = totalTime * 1000; totalTime = totalTime * 1000;
document.getElementById("afterScrubberText").innerHTML = buildTimeString(totalTime); document.getElementById("afterScrubberText").innerHTML = buildTimeString(totalTime);
term.open(document.getElementById('terminal')); term.open(document.getElementById('apps'));
timer = setInterval(advance, TICK); timer = setInterval(advance, TICK);
}) })

View File

@ -588,7 +588,7 @@ Terminal.bindKeys = function(document) {
}, true); }, true);
// If we click somewhere other than a // If we click somewhere other than a
// terminal, unfocus the terminal. // apps, unfocus the apps.
on(document, 'mousedown', function(ev) { on(document, 'mousedown', function(ev) {
if (!Terminal.focus) return; if (!Terminal.focus) return;
@ -742,7 +742,7 @@ Terminal.insertStyle = function(document, bg, fg) {
// textContent doesn't work well with IE for <style> elements. // textContent doesn't work well with IE for <style> elements.
style.innerHTML = '' style.innerHTML = ''
+ '.terminal {\n' + '.apps {\n'
+ ' float: left;\n' + ' float: left;\n'
+ ' border: ' + bg + ' solid 5px;\n' + ' border: ' + bg + ' solid 5px;\n'
+ ' font-family: "DejaVu Sans Mono", "Liberation Mono", monospace;\n' + ' font-family: "DejaVu Sans Mono", "Liberation Mono", monospace;\n'
@ -751,7 +751,7 @@ Terminal.insertStyle = function(document, bg, fg) {
+ ' background: ' + bg + ';\n' + ' background: ' + bg + ';\n'
+ '}\n' + '}\n'
+ '\n' + '\n'
+ '.terminal-cursor {\n' + '.apps-cursor {\n'
+ ' color: ' + bg + ';\n' + ' color: ' + bg + ';\n'
+ ' background: ' + fg + ';\n' + ' background: ' + fg + ';\n'
+ '}\n'; + '}\n';
@ -802,7 +802,7 @@ Terminal.prototype.open = function(parent) {
this.isMSIE = !!~this.context.navigator.userAgent.indexOf('MSIE'); this.isMSIE = !!~this.context.navigator.userAgent.indexOf('MSIE');
} }
// Create our main terminal element. // Create our main apps element.
this.element = this.document.createElement('div'); this.element = this.document.createElement('div');
this.element.className = 'terminal'; this.element.className = 'terminal';
this.element.style.outline = 'none'; this.element.style.outline = 'none';
@ -811,7 +811,7 @@ Terminal.prototype.open = function(parent) {
this.element.style.backgroundColor = this.colors[256]; this.element.style.backgroundColor = this.colors[256];
this.element.style.color = this.colors[257]; this.element.style.color = this.colors[257];
// Create the lines for our terminal. // Create the lines for our apps.
this.children = []; this.children = [];
for (; i < this.rows; i++) { for (; i < this.rows; i++) {
div = this.document.createElement('div'); div = this.document.createElement('div');
@ -1020,7 +1020,7 @@ Terminal.prototype.open = function(parent) {
if (!('useMouse' in this.options) || this.options.useMouse) { if (!('useMouse' in this.options) || this.options.useMouse) {
// Listen for mouse events and translate // Listen for mouse events and translate
// them into terminal mouse protocols. // them into apps mouse protocols.
this.bindMouse(); this.bindMouse();
} }
@ -1549,7 +1549,7 @@ Terminal.prototype.refresh = function(start, end) {
} }
if (data !== this.defAttr) { if (data !== this.defAttr) {
if (data === -1) { if (data === -1) {
out += '<span class="reverse-video terminal-cursor">'; out += '<span class="reverse-video apps-cursor">';
} else { } else {
out += '<span style="'; out += '<span style="';
@ -1660,7 +1660,7 @@ Terminal.prototype.refresh = function(start, end) {
} }
if (this._textarea) { if (this._textarea) {
var cursorElement = this.element.querySelector('.terminal-cursor'); var cursorElement = this.element.querySelector('.apps-cursor');
if(cursorElement){ if(cursorElement){
var cursor_x = cursorElement.offsetLeft; var cursor_x = cursorElement.offsetLeft;
var cursor_y = cursorElement.offsetTop; var cursor_y = cursorElement.offsetTop;
@ -2474,7 +2474,7 @@ Terminal.prototype.write = function(data) {
// break; // break;
// CSI > Ps p Set pointer mode. // CSI > Ps p Set pointer mode.
// CSI ! p Soft terminal reset (DECSTR). // CSI ! p Soft apps reset (DECSTR).
// CSI Ps$ p // CSI Ps$ p
// Request ANSI mode (DECRQM). // Request ANSI mode (DECRQM).
// CSI ? Ps$ p // CSI ? Ps$ p
@ -3959,7 +3959,7 @@ Terminal.prototype.HPositionRelative = function(params) {
}; };
// CSI Ps c Send Device Attributes (Primary DA). // CSI Ps c Send Device Attributes (Primary DA).
// Ps = 0 or omitted -> request attributes from terminal. The // Ps = 0 or omitted -> request attributes from apps. The
// response depends on the decTerminalID resource setting. // response depends on the decTerminalID resource setting.
// -> CSI ? 1 ; 2 c (``VT100 with Advanced Video Option'') // -> CSI ? 1 ; 2 c (``VT100 with Advanced Video Option'')
// -> CSI ? 1 ; 0 c (``VT101 with No Options'') // -> CSI ? 1 ; 0 c (``VT101 with No Options'')
@ -3967,7 +3967,7 @@ Terminal.prototype.HPositionRelative = function(params) {
// -> CSI ? 6 0 ; 1 ; 2 ; 6 ; 8 ; 9 ; 1 5 ; c (``VT220'') // -> CSI ? 6 0 ; 1 ; 2 ; 6 ; 8 ; 9 ; 1 5 ; c (``VT220'')
// The VT100-style response parameters do not mean anything by // The VT100-style response parameters do not mean anything by
// themselves. VT220 parameters do, telling the host what fea- // themselves. VT220 parameters do, telling the host what fea-
// tures the terminal supports: // tures the apps supports:
// Ps = 1 -> 132-columns. // Ps = 1 -> 132-columns.
// Ps = 2 -> Printer. // Ps = 2 -> Printer.
// Ps = 6 -> Selective erase. // Ps = 6 -> Selective erase.
@ -3978,12 +3978,12 @@ Terminal.prototype.HPositionRelative = function(params) {
// Ps = 2 9 -> ANSI text locator (i.e., DEC Locator mode). // Ps = 2 9 -> ANSI text locator (i.e., DEC Locator mode).
// CSI > Ps c // CSI > Ps c
// Send Device Attributes (Secondary DA). // Send Device Attributes (Secondary DA).
// Ps = 0 or omitted -> request the terminal's identification // Ps = 0 or omitted -> request the apps's identification
// code. The response depends on the decTerminalID resource set- // code. The response depends on the decTerminalID resource set-
// ting. It should apply only to VT220 and up, but xterm extends // ting. It should apply only to VT220 and up, but xterm extends
// this to VT100. // this to VT100.
// -> CSI > Pp ; Pv ; Pc c // -> CSI > Pp ; Pv ; Pc c
// where Pp denotes the terminal type // where Pp denotes the apps type
// Pp = 0 -> ``VT100''. // Pp = 0 -> ``VT100''.
// Pp = 1 -> ``VT220''. // Pp = 1 -> ``VT220''.
// and Pv is the firmware version (for xterm, this was originally // and Pv is the firmware version (for xterm, this was originally
@ -3992,7 +3992,7 @@ Terminal.prototype.HPositionRelative = function(params) {
// always zero. // always zero.
// More information: // More information:
// xterm/charproc.c - line 2012, for more information. // xterm/charproc.c - line 2012, for more information.
// vim responds with ^[[?0c or ^[[?1c after the terminal's response (?) // vim responds with ^[[?0c or ^[[?1c after the apps's response (?)
Terminal.prototype.sendDeviceAttributes = function(params) { Terminal.prototype.sendDeviceAttributes = function(params) {
if (params[0] > 0) return; if (params[0] > 0) return;
@ -4217,19 +4217,19 @@ Terminal.prototype.setMode = function(params) {
// focusout: ^[[O // focusout: ^[[O
this.sendFocus = true; this.sendFocus = true;
break; break;
case 1005: // utf8 ext mode mouse case 1005: // utf8 apps mode mouse
this.utfMouse = true; this.utfMouse = true;
// for wide terminals // for wide terminals
// simply encodes large values as utf8 characters // simply encodes large values as utf8 characters
break; break;
case 1006: // sgr ext mode mouse case 1006: // sgr apps mode mouse
this.sgrMouse = true; this.sgrMouse = true;
// for wide terminals // for wide terminals
// does not add 32 to fields // does not add 32 to fields
// press: ^[[<b;x;yM // press: ^[[<b;x;yM
// release: ^[[<b;x;ym // release: ^[[<b;x;ym
break; break;
case 1015: // urxvt ext mode mouse case 1015: // urxvt apps mode mouse
this.urxvtMouse = true; this.urxvtMouse = true;
// for wide terminals // for wide terminals
// numbers for fields // numbers for fields
@ -4406,13 +4406,13 @@ Terminal.prototype.resetMode = function(params) {
case 1004: // send focusin/focusout events case 1004: // send focusin/focusout events
this.sendFocus = false; this.sendFocus = false;
break; break;
case 1005: // utf8 ext mode mouse case 1005: // utf8 apps mode mouse
this.utfMouse = false; this.utfMouse = false;
break; break;
case 1006: // sgr ext mode mouse case 1006: // sgr apps mode mouse
this.sgrMouse = false; this.sgrMouse = false;
break; break;
case 1015: // urxvt ext mode mouse case 1015: // urxvt apps mode mouse
this.urxvtMouse = false; this.urxvtMouse = false;
break; break;
case 25: // hide cursor case 25: // hide cursor
@ -4622,7 +4622,7 @@ Terminal.prototype.setPointerMode = function(params) {
; ;
}; };
// CSI ! p Soft terminal reset (DECSTR). // CSI ! p Soft apps reset (DECSTR).
// http://vt100.net/docs/vt220-rm/table4-10.html // http://vt100.net/docs/vt220-rm/table4-10.html
Terminal.prototype.softReset = function(params) { Terminal.prototype.softReset = function(params) {
this.cursorHidden = false; this.cursorHidden = false;
@ -4870,7 +4870,7 @@ Terminal.prototype.enableFilterRectangle = function(params) {
// CSI Ps x Request Terminal Parameters (DECREQTPARM). // CSI Ps x Request Terminal Parameters (DECREQTPARM).
// if Ps is a "0" (default) or "1", and xterm is emulating VT100, // if Ps is a "0" (default) or "1", and xterm is emulating VT100,
// the control sequence elicits a response of the same form whose // the control sequence elicits a response of the same form whose
// parameters describe the terminal: // parameters describe the apps:
// Ps -> the given Ps incremented by 2. // Ps -> the given Ps incremented by 2.
// Pn = 1 <- no parity. // Pn = 1 <- no parity.
// Pn = 1 <- eight bits. // Pn = 1 <- eight bits.
@ -6113,7 +6113,7 @@ function inherits(child, parent) {
} }
// if bold is broken, we can't // if bold is broken, we can't
// use it in the terminal. // use it in the apps.
function isBoldBroken(document) { function isBoldBroken(document) {
var body = document.getElementsByTagName('body')[0]; var body = document.getElementsByTagName('body')[0];
var terminal = document.createElement('div'); var terminal = document.createElement('div');

View File

@ -13,7 +13,7 @@ WSSHClient.prototype._generateEndpoint = function (options) {
var protocol = 'ws://'; var protocol = 'ws://';
} }
var endpoint = protocol + document.URL.match(RegExp('//(.*?)/'))[1] + '/ws/terminal' + document.URL.match(/(\?.*)/); var endpoint = protocol + document.URL.match(RegExp('//(.*?)/'))[1] + '/ws/apps' + document.URL.match(/(\?.*)/);
return endpoint; return endpoint;
}; };
WSSHClient.prototype.connect = function (options) { WSSHClient.prototype.connect = function (options) {
@ -81,7 +81,7 @@ function openTerminal(options) {
term.on('data', function (data) { term.on('data', function (data) {
client.send(data) client.send(data)
}); });
$('.terminal').detach().appendTo('#term'); $('.apps').detach().appendTo('#term');
//term.resize(colWidth, rowHeight); //term.resize(colWidth, rowHeight);
term.write('Connecting...'); term.write('Connecting...');
client.connect($.extend(options, { client.connect($.extend(options, {
@ -100,13 +100,13 @@ function openTerminal(options) {
term.write(data); term.write(data);
} }
})); }));
//rowHeight = 0.0 + 1.00 * $('.terminal').height() / 24; //rowHeight = 0.0 + 1.00 * $('.apps').height() / 24;
//colWidth = 0.0 + 1.00 * $('.terminal').width() / 80; //colWidth = 0.0 + 1.00 * $('.apps').width() / 80;
return {'term': term, 'client': client}; return {'term': term, 'client': client};
} }
//function resize() { //function resize() {
// $('.terminal').css('width', window.innerWidth - 25); // $('.apps').css('width', window.innerWidth - 25);
// console.log(window.innerWidth); // console.log(window.innerWidth);
// console.log(window.innerWidth - 10); // console.log(window.innerWidth - 10);
// var rows = Math.floor(window.innerHeight / rowHeight) - 2; // var rows = Math.floor(window.innerHeight / rowHeight) - 2;
@ -145,10 +145,10 @@ $(document).ready(function () {
term_client.client.send({'resize': {'rows': row, 'cols': col}}); term_client.client.send({'resize': {'rows': row, 'cols': col}});
$('#ssh').show(); $('#ssh').show();
}); });
$(".terminal").mouseleave(function () { $(".apps").mouseleave(function () {
$(".termChangBar").slideDown(); $(".termChangBar").slideDown();
}); });
$(".terminal").mouseenter(function () { $(".apps").mouseenter(function () {
$(".termChangBar").slideUp(); $(".termChangBar").slideUp();
}) })
}); });

View File

@ -47,7 +47,7 @@ WSSHClient.prototype._generateEndpoint = function(options) {
var protocol = 'ws://'; var protocol = 'ws://';
} }
var endpoint = protocol + window.location.host + ':8080' + '/terminal'; var endpoint = protocol + window.location.host + ':8080' + '/apps';
return endpoint; return endpoint;
}; };

View File

@ -32,11 +32,13 @@
<li id="asset-permission"> <li id="asset-permission">
<a href="{% url 'perms:asset-permission-list' %}">{% trans 'Asset permission' %}</a> <a href="{% url 'perms:asset-permission-list' %}">{% trans 'Asset permission' %}</a>
</li> </li>
{# <li id="user-group">#}
{# <a href="">{% trans 'User group perm' %}</a>#}
{# </li>#}
</ul> </ul>
</li> </li>
<li id="">
<a href="{% url 'apps:apps-list' %}">
<i class="fa fa-desktop"></i><span class="nav-label">{% trans 'Terminal' %}</span><span class="label label-info pull-right"></span>
</a>
</li>
<li id=""> <li id="">
<a href=""> <a href="">
<i class="fa fa-files-o"></i><span class="nav-label">{% trans 'Audits' %}</span><span class="label label-info pull-right"></span> <i class="fa fa-files-o"></i><span class="nav-label">{% trans 'Audits' %}</span><span class="label label-info pull-right"></span>

View File

@ -1,3 +0,0 @@
from django.shortcuts import render
# Create your views here.

View File

@ -89,8 +89,8 @@ class UserListUpdateApi(BulkDeleteApiMixin, ListBulkCreateUpdateDestroyAPIView):
serializer_class = UserBulkUpdateSerializer serializer_class = UserBulkUpdateSerializer
permission_classes = (IsSuperUserOrAppUser,) permission_classes = (IsSuperUserOrAppUser,)
def get(self, request, *args, **kwargs): # def get(self, request, *args, **kwargs):
return super(UserListUpdateApi, self).get(request, *args, **kwargs) # return super(UserListUpdateApi, self).get(request, *args, **kwargs)
class GroupListUpdateApi(BulkDeleteApiMixin, ListBulkCreateUpdateDestroyAPIView): class GroupListUpdateApi(BulkDeleteApiMixin, ListBulkCreateUpdateDestroyAPIView):

View File

@ -23,12 +23,12 @@ div.dataTables_wrapper div.dataTables_filter {
<th class="text-center"> <th class="text-center">
<div class="checkbox checkbox-default"><input id="" type="checkbox" class="ipt_check_all"><label></label></div> <div class="checkbox checkbox-default"><input id="" type="checkbox" class="ipt_check_all"><label></label></div>
</th> </th>
<th class="text-center">{% trans 'Name' %}</a></th> <th class="text-center">{% trans 'Name' %}</th>
<th class="text-center">{% trans 'Username' %}</a></th> <th class="text-center">{% trans 'Username' %}</th>
<th class="text-center">{% trans 'Role' %}</th> <th class="text-center">{% trans 'Role' %}</th>
<th class="text-center">{% trans 'User group' %}</th> <th class="text-center">{% trans 'User group' %}</th>
<th class="text-center">{% trans 'Asset num' %}</th> <th class="text-center">{% trans 'Asset num' %}</th>
<th class="text-center">{% trans 'Active' %}</a></th> <th class="text-center">{% trans 'Active' %}</th>
<th class="text-center">{% trans 'Action' %}</th> <th class="text-center">{% trans 'Action' %}</th>
</tr> </tr>
</thead> </thead>
@ -165,7 +165,7 @@ $(document).ready(function(){
var fail = function() { var fail = function() {
var msg = "{% trans 'User Deleting failed.' %}"; var msg = "{% trans 'User Deleting failed.' %}";
swal("{% trans 'User Delete' %}", msg, "error"); swal("{% trans 'User Delete' %}", msg, "error");
} };
APIUpdateAttr({ APIUpdateAttr({
url: the_url, url: the_url,
body: JSON.stringify(body), body: JSON.stringify(body),
@ -208,15 +208,15 @@ $(document).ready(function(){
post_list.push(content); post_list.push(content);
}); });
if (post_list === []) { if (post_list === []) {
return false; return false
}; }
var the_url = "{% url 'users:user-bulk-update-api' %}"; var the_url = "{% url 'users:user-bulk-update-api' %}";
var success = function() { var success = function() {
var msg = "{% trans 'The selected users has been updated successfully.' %}"; var msg = "{% trans 'The selected users has been updated successfully.' %}";
swal("{% trans 'User Updated' %}", msg, "success"); swal("{% trans 'User Updated' %}", msg, "success");
$('#user_list_table').DataTable().ajax.reload(); $('#user_list_table').DataTable().ajax.reload();
jumpserver.checked = false; jumpserver.checked = false;
} };
APIUpdateAttr({url: the_url, method: 'PATCH', body: JSON.stringify(post_list), success: success}); APIUpdateAttr({url: the_url, method: 'PATCH', body: JSON.stringify(post_list), success: success});
$('#user_bulk_update_modal').modal('hide'); $('#user_bulk_update_modal').modal('hide');
}).on('click', '#btn_user_import', function() { }).on('click', '#btn_user_import', function() {