mirror of https://github.com/jumpserver/jumpserver
Merge branch 'dev' of github.com:jumpserver/jumpserver into dev
commit
daadcedc21
|
@ -203,17 +203,14 @@ class Node(OrgModelMixin):
|
||||||
# 如果使用current_org 在set_current_org时会死循环
|
# 如果使用current_org 在set_current_org时会死循环
|
||||||
_current_org = get_current_org()
|
_current_org = get_current_org()
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
if _current_org.is_root():
|
if not _current_org.is_real():
|
||||||
key = '0'
|
return cls.default_node()
|
||||||
elif _current_org.is_default():
|
set_current_org(Organization.root())
|
||||||
key = '1'
|
org_nodes_roots = cls.objects.filter(key__regex=r'^[0-9]+$')
|
||||||
else:
|
org_nodes_roots_keys = org_nodes_roots.values_list('key', flat=True) or ['1']
|
||||||
set_current_org(Organization.root())
|
key = max([int(k) for k in org_nodes_roots_keys])
|
||||||
org_nodes_roots = cls.objects.filter(key__regex=r'^[0-9]+$')
|
key = str(key + 1) if key != 0 else '2'
|
||||||
org_nodes_roots_keys = org_nodes_roots.values_list('key', flat=True) or ['1']
|
set_current_org(_current_org)
|
||||||
key = max([int(k) for k in org_nodes_roots_keys])
|
|
||||||
key = str(key + 1) if key != 0 else '2'
|
|
||||||
set_current_org(_current_org)
|
|
||||||
root = cls.objects.create(key=key, value=_current_org.name)
|
root = cls.objects.create(key=key, value=_current_org.name)
|
||||||
return root
|
return root
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ $(document).ready(function () {
|
||||||
})
|
})
|
||||||
.on('click', '#btn_asset_modal_confirm', function () {
|
.on('click', '#btn_asset_modal_confirm', function () {
|
||||||
var assets = asset_table2.selected;
|
var assets = asset_table2.selected;
|
||||||
$('.select2').val(assets).trigger('change');
|
$('#id_assets').val(assets).trigger('change');
|
||||||
$("#asset_list_modal").modal('hide');
|
$("#asset_list_modal").modal('hide');
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# ~*~ coding: utf-8 ~*~
|
# ~*~ coding: utf-8 ~*~
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
import json
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
from ansible import constants as C
|
from ansible import constants as C
|
||||||
|
@ -163,6 +164,28 @@ class CommandResultCallback(AdHocResultCallback):
|
||||||
self._play = play
|
self._play = play
|
||||||
self._display.banner(msg)
|
self._display.banner(msg)
|
||||||
|
|
||||||
|
def v2_runner_on_unreachable(self, result):
|
||||||
|
self.results_summary['success'] = False
|
||||||
|
self.gather_result("unreachable", result)
|
||||||
|
msg = result._result.get("msg")
|
||||||
|
if not msg:
|
||||||
|
msg = json.dumps(result._result, indent=4)
|
||||||
|
self._display.display("%s | FAILED! => \n%s" % (
|
||||||
|
result._host.get_name(),
|
||||||
|
msg,
|
||||||
|
), color=C.COLOR_ERROR)
|
||||||
|
|
||||||
|
def v2_runner_on_failed(self, result, ignore_errors=False):
|
||||||
|
self.results_summary['success'] = False
|
||||||
|
self.gather_result("failed", result)
|
||||||
|
msg = result._result.get("msg") or result._result.get("module_stdout")
|
||||||
|
if not msg:
|
||||||
|
msg = json.dumps(result._result, indent=4)
|
||||||
|
self._display.display("%s | FAILED! => \n%s" % (
|
||||||
|
result._host.get_name(),
|
||||||
|
msg,
|
||||||
|
), color=C.COLOR_ERROR)
|
||||||
|
|
||||||
def _print_task_banner(self, task):
|
def _print_task_banner(self, task):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,10 @@
|
||||||
<script src="{% static 'js/plugins/xterm/xterm.js' %}"></script>
|
<script src="{% static 'js/plugins/xterm/xterm.js' %}"></script>
|
||||||
<link rel="stylesheet" href="{% static 'js/plugins/xterm/xterm.css' %}" />
|
<link rel="stylesheet" href="{% static 'js/plugins/xterm/xterm.css' %}" />
|
||||||
<script src="{% static 'js/plugins/xterm/addons/fit/fit.js' %}"></script>
|
<script src="{% static 'js/plugins/xterm/addons/fit/fit.js' %}"></script>
|
||||||
|
<script src="{% static 'js/plugins/codemirror/codemirror.js' %}"></script>
|
||||||
|
<script src="{% static 'js/plugins/codemirror/mode/shell/shell.js' %}"></script>
|
||||||
|
<link href="{% static 'css/plugins/codemirror/codemirror.css' %}" rel="stylesheet">
|
||||||
|
<link href="{% static 'css/plugins/codemirror/ambiance.css' %}" rel="stylesheet">
|
||||||
<link href="{% static 'css/plugins/select2/select2.min.css' %}" rel="stylesheet">
|
<link href="{% static 'css/plugins/select2/select2.min.css' %}" rel="stylesheet">
|
||||||
<script src="{% static 'js/plugins/select2/select2.full.min.js' %}"></script>
|
<script src="{% static 'js/plugins/select2/select2.full.min.js' %}"></script>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
|
@ -51,24 +55,22 @@
|
||||||
<div id="term" style="height: 100%;width: 100%"></div>
|
<div id="term" style="height: 100%;width: 100%"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
<div class="col-lg-10">
|
||||||
|
<div class="input-group" style="height: 100%; width: 100%">
|
||||||
|
<textarea class="form-control" id="command-text"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="col-lg-2">
|
<div class="col-lg-2">
|
||||||
<select class="select2 form-control" id="system-users-select">
|
<select class="select2 form-control" id="system-users-select">
|
||||||
{% for s in system_users %}
|
{% for s in system_users %}
|
||||||
{% if s.protocol == 'ssh' and s.login_mode == 'auto' %}
|
{% if s.protocol == 'ssh' and s.login_mode == 'auto' %}
|
||||||
<option value="{{ s.id }}">{{ s }}</option>
|
<option value="{{ s.id }}">{{ s }}</option>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
<button type="button" class="btn btn-primary btn-execute" style="margin-top: 30px; width: 100%">{% trans 'Go' %}</button>
|
||||||
<div class="col-lg-10">
|
|
||||||
<div class="input-group" style="height: 100%">
|
|
||||||
<input type="text" id="command-text" class="form-control">
|
|
||||||
<span class="input-group-btn">
|
|
||||||
<button type="button" class="btn btn-primary btn-execute">{% trans 'Go' %}</button>
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -186,7 +188,7 @@ function execute() {
|
||||||
}
|
}
|
||||||
var url = '{% url "api-ops:command-execution-list" %}';
|
var url = '{% url "api-ops:command-execution-list" %}';
|
||||||
var run_as = systemUserId;
|
var run_as = systemUserId;
|
||||||
var command = $("#command-text").val();
|
var command = editor.getValue();
|
||||||
var hosts = getSelectedAssetsNode().map(function (node) {
|
var hosts = getSelectedAssetsNode().map(function (node) {
|
||||||
return node.id;
|
return node.id;
|
||||||
});
|
});
|
||||||
|
@ -242,6 +244,7 @@ function execute() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var editor;
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
systemUserId = $('#system-users-select').val();
|
systemUserId = $('#system-users-select').val();
|
||||||
$(".select2").select2().on('select2:select', function(evt) {
|
$(".select2").select2().on('select2:select', function(evt) {
|
||||||
|
@ -249,6 +252,19 @@ $(document).ready(function(){
|
||||||
systemUserId = data.id;
|
systemUserId = data.id;
|
||||||
initTree();
|
initTree();
|
||||||
});
|
});
|
||||||
|
editor = CodeMirror.fromTextArea(document.getElementById("command-text"), {
|
||||||
|
lineNumbers: true,
|
||||||
|
lineWrapping: true,
|
||||||
|
mode: "shell"
|
||||||
|
});
|
||||||
|
editor.setSize(600, 100);
|
||||||
|
var charWidth = editor.defaultCharWidth(), basePadding = 4;
|
||||||
|
editor.on("renderLine", function(cm, line, elt) {
|
||||||
|
var off = CodeMirror.countColumn(line.text, null, cm.getOption("tabSize")) * charWidth;
|
||||||
|
elt.style.textIndent = "-" + off + "px";
|
||||||
|
elt.style.paddingLeft = (basePadding + off) + "px";
|
||||||
|
});
|
||||||
|
editor.refresh();
|
||||||
initTree();
|
initTree();
|
||||||
initResultTerminal();
|
initResultTerminal();
|
||||||
}).on('click', '.btn-execute', function () {
|
}).on('click', '.btn-execute', function () {
|
||||||
|
|
|
@ -54,9 +54,15 @@
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<div class="input-daterange input-group" id="datepicker">
|
<div class="input-daterange input-group" id="datepicker">
|
||||||
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
|
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
|
||||||
<input type="text" class="input-sm form-control" id="date_start" name="date_start" value="{{ form.date_start.value|date:'Y-m-d H:i' }}">
|
{% if form.errors %}
|
||||||
<span class="input-group-addon">to</span>
|
<input type="text" class="input-sm form-control" id="date_start" name="date_start" value="{{ form.date_start.value }}">
|
||||||
<input type="text" class="input-sm form-control" id="date_expired" name="date_expired" value="{{ form.date_expired.value|date:'Y-m-d H:i' }}">
|
<span class="input-group-addon">to</span>
|
||||||
|
<input type="text" class="input-sm form-control" id="date_expired" name="date_expired" value="{{ form.date_expired.value }}">
|
||||||
|
{% else %}
|
||||||
|
<input type="text" class="input-sm form-control" id="date_start" name="date_start" value="{{ form.date_start.value|date:'Y-m-d H:i' }}">
|
||||||
|
<span class="input-group-addon">to</span>
|
||||||
|
<input type="text" class="input-sm form-control" id="date_expired" name="date_expired" value="{{ form.date_expired.value|date:'Y-m-d H:i' }}">
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<span class="help-block ">{{ form.date_expired.errors }}</span>
|
<span class="help-block ">{{ form.date_expired.errors }}</span>
|
||||||
<span class="help-block ">{{ form.date_start.errors }}</span>
|
<span class="help-block ">{{ form.date_start.errors }}</span>
|
||||||
|
@ -113,7 +119,7 @@ $(document).ready(function () {
|
||||||
.on('click', '#btn_asset_modal_confirm', function () {
|
.on('click', '#btn_asset_modal_confirm', function () {
|
||||||
var assets = asset_table2.selected;
|
var assets = asset_table2.selected;
|
||||||
|
|
||||||
$('.select2').val(assets).trigger('change');
|
$('#id_assets').val(assets).trigger('change');
|
||||||
|
|
||||||
$("#asset_list_modal").modal('hide');
|
$("#asset_list_modal").modal('hide');
|
||||||
});
|
});
|
||||||
|
|
|
@ -131,6 +131,10 @@ class UserCreateUpdateForm(OrgModelForm):
|
||||||
|
|
||||||
|
|
||||||
class UserProfileForm(forms.ModelForm):
|
class UserProfileForm(forms.ModelForm):
|
||||||
|
username = forms.CharField(disabled=True)
|
||||||
|
name = forms.CharField(disabled=True)
|
||||||
|
email = forms.CharField(disabled=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = User
|
model = User
|
||||||
fields = [
|
fields = [
|
||||||
|
|
|
@ -260,8 +260,6 @@ class User(AbstractUser):
|
||||||
self.role = 'Admin'
|
self.role = 'Admin'
|
||||||
self.is_active = True
|
self.is_active = True
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
if current_org and current_org.is_real():
|
|
||||||
self.orgs.add(current_org.id)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def private_token(self):
|
def private_token(self):
|
||||||
|
|
|
@ -30,7 +30,11 @@
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<div class="input-group date">
|
<div class="input-group date">
|
||||||
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
|
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
|
||||||
<input id="{{ form.date_expired.id_for_label }}" name="{{ form.date_expired.html_name }}" type="text" class="form-control" value="{{ form.date_expired.value|date:'Y-m-d H:i' }}">
|
{% if form.errors %}
|
||||||
|
<input id="{{ form.date_expired.id_for_label }}" name="{{ form.date_expired.html_name }}" type="text" class="form-control" value="{{ form.date_expired.value }}">
|
||||||
|
{% else %}
|
||||||
|
<input id="{{ form.date_expired.id_for_label }}" name="{{ form.date_expired.html_name }}" type="text" class="form-control" value="{{ form.date_expired.value|date:'Y-m-d H:i' }}">
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<span class="help-block ">{{ form.date_expired.errors }}</span>
|
<span class="help-block ">{{ form.date_expired.errors }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -87,6 +87,8 @@ class UserCreateView(AdminUserRequiredMixin, SuccessMessageMixin, CreateView):
|
||||||
user = form.save(commit=False)
|
user = form.save(commit=False)
|
||||||
user.created_by = self.request.user.username or 'System'
|
user.created_by = self.request.user.username or 'System'
|
||||||
user.save()
|
user.save()
|
||||||
|
if current_org and current_org.is_real():
|
||||||
|
user.orgs.add(current_org.id)
|
||||||
post_user_create.send(self.__class__, user=user)
|
post_user_create.send(self.__class__, user=user)
|
||||||
return super().form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
tiff-dev jpeg-dev zlib-dev freetype-dev lcms-dev libwebp-dev tcl-dev tk-dev python3-dev libressl-dev openldap-dev cyrus-sasl-dev krb5-dev sshpass postgresql-dev mariadb-dev sqlite-dev libffi-dev openssh-client
|
Loading…
Reference in New Issue