Commit 158678c2 authored by ibuler's avatar ibuler

[Bugfix] 修改bug,显示cluster

parent 2cceb281
...@@ -151,6 +151,8 @@ class AssetSerializer(BulkSerializerMixin, serializers.ModelSerializer): ...@@ -151,6 +151,8 @@ class AssetSerializer(BulkSerializerMixin, serializers.ModelSerializer):
""" """
资产的数据结构 资产的数据结构
""" """
cluster_name = serializers.SerializerMethodField()
class Meta(object): class Meta(object):
model = Asset model = Asset
list_serializer_class = BulkListSerializer list_serializer_class = BulkListSerializer
...@@ -165,6 +167,10 @@ class AssetSerializer(BulkSerializerMixin, serializers.ModelSerializer): ...@@ -165,6 +167,10 @@ class AssetSerializer(BulkSerializerMixin, serializers.ModelSerializer):
]) ])
return fields return fields
@staticmethod
def get_cluster_name(obj):
return obj.cluster.name
class AssetGrantedSerializer(serializers.ModelSerializer): class AssetGrantedSerializer(serializers.ModelSerializer):
""" """
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
<th class="text-center">{% trans 'Hostname' %}</th> <th class="text-center">{% trans 'Hostname' %}</th>
<th class="text-center">{% trans 'IP' %}</th> <th class="text-center">{% trans 'IP' %}</th>
<th class="text-center">{% trans 'Port' %}</th> <th class="text-center">{% trans 'Port' %}</th>
<th class="text-center">{% trans 'Cluster' %}</th>
<th class="text-center">{% trans 'Type' %}</th> <th class="text-center">{% trans 'Type' %}</th>
<th class="text-center">{% trans 'Env' %}</th> <th class="text-center">{% trans 'Env' %}</th>
<th class="text-center">{% trans 'Hardware' %}</th> <th class="text-center">{% trans 'Hardware' %}</th>
...@@ -74,14 +75,14 @@ function initTable() { ...@@ -74,14 +75,14 @@ function initTable() {
var detail_btn = '<a href="{{ the_url }}">' + cellData + '</a>'; var detail_btn = '<a href="{{ the_url }}">' + cellData + '</a>';
$(td).html(detail_btn.replace('{{ DEFAULT_PK }}', rowData.id)); $(td).html(detail_btn.replace('{{ DEFAULT_PK }}', rowData.id));
}}, }},
{targets: 7, createdCell: function (td, cellData) { {targets: 8, createdCell: function (td, cellData) {
if (!cellData) { if (!cellData) {
$(td).html('<i class="fa fa-times text-danger"></i>') $(td).html('<i class="fa fa-times text-danger"></i>')
} else { } else {
$(td).html('<i class="fa fa-check text-navy"></i>') $(td).html('<i class="fa fa-check text-navy"></i>')
} }
}}, }},
{targets: 8, createdCell: function (td, cellData) { {targets: 9, createdCell: function (td, cellData) {
if (cellData == 'Unknown'){ if (cellData == 'Unknown'){
$(td).html('<i class="fa fa-circle text-warning"></i>') $(td).html('<i class="fa fa-circle text-warning"></i>')
} else if (!cellData) { } else if (!cellData) {
...@@ -90,14 +91,14 @@ function initTable() { ...@@ -90,14 +91,14 @@ function initTable() {
$(td).html('<i class="fa fa-circle text-navy"></i>') $(td).html('<i class="fa fa-circle text-navy"></i>')
} }
}}, }},
{targets: 9, createdCell: function (td, cellData, rowData) { {targets: 10, createdCell: function (td, cellData, rowData) {
var update_btn = '<a href="{% url "assets:asset-update" pk=DEFAULT_PK %}" class="btn btn-xs btn-info">{% trans "Update" %}</a>'.replace("{{ DEFAULT_PK }}", cellData); var update_btn = '<a href="{% url "assets:asset-update" pk=DEFAULT_PK %}" class="btn btn-xs btn-info">{% trans "Update" %}</a>'.replace("{{ DEFAULT_PK }}", cellData);
var del_btn = '<a class="btn btn-xs btn-danger m-l-xs btn_asset_delete" data-uid="{{ DEFAULT_PK }}">{% trans "Delete" %}</a>'.replace('{{ DEFAULT_PK }}', cellData); var del_btn = '<a class="btn btn-xs btn-danger m-l-xs btn_asset_delete" data-uid="{{ DEFAULT_PK }}">{% trans "Delete" %}</a>'.replace('{{ DEFAULT_PK }}', cellData);
$(td).html(update_btn + del_btn) $(td).html(update_btn + del_btn)
}} }}
], ],
ajax_url: '{% url "api-assets:asset-list" %}', ajax_url: '{% url "api-assets:asset-list" %}',
columns: [{data: "id"}, {data: "hostname" }, {data: "ip" }, {data: "port" }, columns: [{data: "id"}, {data: "hostname" }, {data: "ip" }, {data: "port" }, {data: "cluster_name"},
{data: "get_type_display" }, {data: "get_env_display"}, {data: "hardware_info"}, {data: "get_type_display" }, {data: "get_env_display"}, {data: "hardware_info"},
{data: "is_active" }, {data: "is_connective"}, {data: "id" }], {data: "is_active" }, {data: "is_connective"}, {data: "id" }],
op_html: $('#actions').html() op_html: $('#actions').html()
......
...@@ -181,7 +181,7 @@ function initTable() { ...@@ -181,7 +181,7 @@ function initTable() {
} }
$(document).ready(function () { $(document).ready(function () {
$('.select2').select2(); $('.select2').select2()
.on("select2:select", function (evt) { .on("select2:select", function (evt) {
var data = evt.params.data; var data = evt.params.data;
jumpserver.assets_selected[data.id] = data.text; jumpserver.assets_selected[data.id] = data.text;
......
...@@ -125,7 +125,7 @@ function initAssetsTable() { ...@@ -125,7 +125,7 @@ function initAssetsTable() {
} }
$(document).ready(function () { $(document).ready(function () {
$('.select2').select2(); $('.select2').select2()
.on("select2:select", function (evt) { .on("select2:select", function (evt) {
var data = evt.params.data; var data = evt.params.data;
jumpserver.assets_selected[data.id] = data.text; jumpserver.assets_selected[data.id] = data.text;
......
...@@ -212,7 +212,7 @@ function updateSystemUserCluster(clusters) { ...@@ -212,7 +212,7 @@ function updateSystemUserCluster(clusters) {
} }
jumpserver.cluster_selected = {}; jumpserver.cluster_selected = {};
$(document).ready(function () { $(document).ready(function () {
$('.select2').select2(); $('.select2').select2()
.on('select2:select', function(evt) { .on('select2:select', function(evt) {
var data = evt.params.data; var data = evt.params.data;
jumpserver.cluster_selected[data.id] = data.text; jumpserver.cluster_selected[data.id] = data.text;
......
...@@ -190,7 +190,7 @@ function updateSystemUser(system_users) { ...@@ -190,7 +190,7 @@ function updateSystemUser(system_users) {
} }
$(document).ready(function () { $(document).ready(function () {
$('.select2').select2(); $('.select2').select2()
.on('select2:select', function(evt) { .on('select2:select', function(evt) {
var data = evt.params.data; var data = evt.params.data;
jumpserver.system_users_selected[data.id] = data.text; jumpserver.system_users_selected[data.id] = data.text;
......
...@@ -253,7 +253,7 @@ function updateUserGroups(groups) { ...@@ -253,7 +253,7 @@ function updateUserGroups(groups) {
} }
$(document).ready(function() { $(document).ready(function() {
$('.select2').select2(); $('.select2').select2()
.on('select2:select', function(evt) { .on('select2:select', function(evt) {
var data = evt.params.data; var data = evt.params.data;
jumpserver.groups_selected[data.id] = data.text; jumpserver.groups_selected[data.id] = data.text;
......
...@@ -150,7 +150,7 @@ function updateGroupMember(users) { ...@@ -150,7 +150,7 @@ function updateGroupMember(users) {
} }
$(document).ready(function () { $(document).ready(function () {
$('.select2').select2(); $('.select2').select2()
.on('select2:select', function(evt) { .on('select2:select', function(evt) {
var data = evt.params.data; var data = evt.params.data;
jumpserver.users_selected[data.id] = data.text; jumpserver.users_selected[data.id] = data.text;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment