Merge pull request #2964 from jumpserver/dev

Dev
pull/3007/head
BaiJiangJie 2019-07-16 15:42:23 +08:00 committed by GitHub
commit eb93e634e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 45 additions and 6 deletions

View File

@ -0,0 +1,18 @@
# Generated by Django 2.1.7 on 2019-07-16 07:35
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assets', '0035_auto_20190711_2018'),
]
operations = [
migrations.AlterField(
model_name='commandfilter',
name='name',
field=models.CharField(max_length=64, unique=True, verbose_name='Name'),
),
]

View File

@ -17,7 +17,7 @@ __all__ = [
class CommandFilter(OrgModelMixin):
id = models.UUIDField(default=uuid.uuid4, primary_key=True)
name = models.CharField(max_length=64, verbose_name=_("Name"))
name = models.CharField(max_length=64, unique=True, verbose_name=_("Name"))
is_active = models.BooleanField(default=True, verbose_name=_('Is active'))
comment = models.TextField(blank=True, default='', verbose_name=_("Comment"))
date_created = models.DateTimeField(auto_now_add=True)

View File

@ -22,7 +22,6 @@ class CommandFilterSerializer(BulkOrgResourceModelSerializer):
extra_kwargs = {
'rules': {'read_only': True},
'system_users': {'read_only': True}
}

View File

@ -29,7 +29,7 @@
<a class="btn btn-outline btn-default" href="{% url 'assets:cmd-filter-update' pk=object.id %}"><i class="fa fa-edit"></i>{% trans 'Update' %}</a>
</li>
<li class="pull-right">
<a class="btn btn-outline btn-danger btn-del">
<a class="btn btn-outline btn-danger btn-del btn-delete-cmd-filter">
<i class="fa fa-trash-o"></i>{% trans 'Delete' %}
</a>
</li>
@ -164,5 +164,13 @@ $(document).ready(function () {
});
updateCMDFilterSystemUsers(system_users)
})
.on('click', '.btn-delete-cmd-filter', function () {
var $this = $(this);
var name = "{{object.name }}";
var uid = "{{ object.id }}";
var the_url = '{% url "api-assets:cmd-filter-detail" pk=DEFAULT_PK %}'.replace('{{ DEFAULT_PK }}', uid);
var redirect_url = "{% url 'assets:cmd-filter-list' %}";
objectDelete($this, name, the_url, redirect_url);
})
</script>
{% endblock %}

View File

@ -24,7 +24,7 @@
<a class="btn btn-outline btn-default" href="{% url 'assets:domain-update' pk=object.id %}"><i class="fa fa-edit"></i>{% trans 'Update' %}</a>
</li>
<li class="pull-right">
<a class="btn btn-outline btn-danger btn-del">
<a class="btn btn-outline btn-danger btn-del btn-delete-domain">
<i class="fa fa-trash-o"></i>{% trans 'Delete' %}
</a>
</li>
@ -127,6 +127,15 @@ $(document).ready(function(){
setTimeout( function () {
$data_table.ajax.reload();
}, 3000);
});
})
.on('click', '.btn-delete-domain', function () {
var $this = $(this);
var name = "{{ object.name }}";
var uid = "{{ object.id }}";
var the_url = '{% url "api-assets:domain-detail" pk=DEFAULT_PK %}'.replace('{{ DEFAULT_PK }}', uid);
var redirect_url = "{% url 'assets:domain-list' %}";
objectDelete($this, name, the_url, redirect_url);
})
;
</script>
{% endblock %}

View File

@ -174,6 +174,8 @@ class GrantAssetsMixin(LabelFilterMixin):
system_user = system_users_map.get(sid)
if not system_user:
continue
if not asset.has_protocol(system_user.protocol):
continue
system_user.actions = action
system_users_granted.append(system_user)
asset.system_users_granted = system_users_granted

View File

@ -256,6 +256,8 @@ class UserGrantedNodesWithAssetsApi(UserPermissionCacheMixin, NodesWithUngroupMi
system_user = _system_users_map.get(system_user_id)
if not system_user:
continue
if not asset.has_protocol(system_user.protocol):
continue
system_user.actions = action
system_user_granted.append(system_user)
asset.system_users_granted = system_user_granted

View File

@ -1110,6 +1110,7 @@ function objectAttrsIsBool(obj, attrs) {
}
function cleanDate(d) {
if (typeof d === 'number'){return d}
for (var i=0; i<2; i++) {
if (isNaN(Date.parse(d))) {
d = d.split('+')[0].trimRight();

View File

@ -7,7 +7,7 @@
<script src="{% static "js/plugins/toastr/toastr.min.js" %}"></script>
<script src="{% static "js/inspinia.js" %}"></script>
<script type="text/javascript" src="{% url 'javascript-catalog' %}"></script>
<script src="{% static "js/jumpserver.js" %}"></script>
<script src="{% static "js/jumpserver.js" %}?v=1"></script>
<script>
activeNav();
$(document).ready(function(){