Commit ab2043a8 by Abhishek Kadam Committed by kevalbhatt

ATLAS-2820: UI : Add replication audits tab for AtlasCluster entity to show Export & Import audit

Signed-off-by: 's avatarkevalbhatt <kbhatt@apache.org>
parent 21fcc7e1
......@@ -60,6 +60,16 @@ define(['require',
return [];
}
},
getExpimpAudit: function(params, options) {
var url = UrlLinks.expimpAudit(params);
options = _.extend({
contentType: 'application/json',
dataType: 'json',
}, options);
return this.constructor.nonCrudOperation.call(this, url, 'GET', options);
},
getBasicRearchResult: function(options) {
var url = UrlLinks.searchApiUrl('basic');
......
<!--
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-->
<div>
<div class="tableOverlay"></div>
<div id="r_replicationAuditTableLayoutView"></div>
</div>
......@@ -28,7 +28,7 @@
</h4>
</div>
{{/if}} {{#if contentWithFooter}} {{else}}
<div class="modal-body">{{#if contentHtml}} {{{contentHtm}}} {{else}} {{content}} {{/if}}
<div class="modal-body">{{#if contentHtml}} {{{content}}} {{else}} {{content}} {{/if}}
</div>
{{#if showFooter}}
<div class="modal-footer">
......
......@@ -26,6 +26,12 @@
<div class="clearfix banded">
<div data-id="r_footerRecords" class="margin-top-10"></div>
</div>
{{/if}} {{#if includeAtlasPagination}}
<div class="row form-group pagination-box filter-box">
<div class="col-sm-4">
<span class="labelShowRecord pull-left" data-id="pageRecordText"> </span>
</div>
</div>
{{/if}}
<div class="position-relative thick-border">
<div data-id="r_tableList" class="table-responsive tableBorder"> </div>
......@@ -53,5 +59,49 @@
</div>
</div>
</div>
{{/if}} {{#if includeAtlasPagination}}
<div class="row pagination-box">
<div class="col-sm-offset-4 col-sm-8">
<div class="inline-content-fr">
<div class="backgrid-paginator inline">
<ul class="" data-id="paginationDiv" style="display:none">
<li>
<button type="button" data-id="previousData" title="Previous" disabled=true>
<i class="fa fa-angle-left" aria-hidden="true"></i>
</button>
</li>
<li class="active">
<a href="javascript:void(0)" data-id="activePage"></a>
</li>
<li>
<button type="button" data-id="nextData" title="Next">
<i class="fa fa-angle-right" aria-hidden="true"></i>
</button>
</li>
</ul>
</div>
{{#if includeAtlasGotoPage}}
<div class="inline col-sm-4" data-id="paginationDiv" style="display:none">
<div class="input-group" data-id="goToPageDiv">
<input type="text" class="form-control number-input" data-id="gotoPage" placeholder="Goto Page" />
<span class="input-group-btn">
<button class="btn btn-default" type="button" data-id="gotoPagebtn" title="Goto Page" disabled="disabled">Go!</button>
</span>
</div>
</div>
{{/if}} {{#if includeAtlasPageSize}}
<div class="inline">
<div class="form-group inline-content">
<span class="control-label-sm inline ">Page Limit :</span>
<div class="inline" style="width: 80px;">
<select data-id="showPage" multiple="multiple" class="form-control">
</select>
</div>
</div>
</div>
{{/if}}
</div>
</div>
</div>
{{/if}}
</div>
\ No newline at end of file
......@@ -52,6 +52,7 @@
<li role="relationship" class="tab"><a href="#tab-relationship" aria-controls="tab-relationship" role="tab" data-toggle="tab">Relationships</a></li>
<li role="classification"><a href="#tab-tagTable" aria-controls="tab-tagTable" role="tab" data-toggle="tab">Classifications</a></li>
<li role="audit" class="tab"><a href="#tab-audit" aria-controls="tab-audit" role="tab" data-toggle="tab">Audits</a></li>
<li role="raudits" class="tab replicationTab" style="display:none"><a href="#tab-raudit" aria-controls="tab-raudit" role="tab" data-toggle="tab">Export/Import Audits</a></li>
<li role="schema" class="tab schemaTable" style="display:none"><a href="#tab-schema" aria-controls="tab-schema" role="tab" data-toggle="tab">Schema</a></li>
<li role="profile" class="tab profileTab" style="display:none"><a href="#tab-profile" aria-controls="tab-profile" role="tab" data-toggle="tab">Profile</a></li>
</ul>
......@@ -99,6 +100,13 @@
</div>
</div>
</div>
<div id="tab-raudit" role="raudits" class="tab-pane">
<div id="r_replicationAuditTableLayoutView">
<div class="fontLoader-relative">
<i class="fa fa-refresh fa-spin-custom"></i>
</div>
</div>
</div>
<div id="tab-schema" role="schema" class="tab-pane animated fadeIn">
<div id="r_schemaTableLayoutView">
<div class="fontLoader-relative">
......
......@@ -84,6 +84,29 @@ define(['require', 'utils/Enums', 'utils/Utils', 'underscore'], function(require
entityCollectionaudit: function(guid) {
return this.baseUrlV2 + '/entity/' + guid + '/audit';
},
expimpAudit: function(options) {
var url = this.baseUrl + '/admin/expimp/audit',
queryParam = [];
if (options) {
var serverName = options.serverName,
limit = options.limit,
offset = options.offset;
}
if (serverName) {
queryParam.push("serverName=" + serverName);
}
if (limit) {
queryParam.push("limit=" + limit);
}
if (offset) {
queryParam.push("offset=" + offset);
}
if (queryParam.length > 0) {
url = url + "?" + queryParam.join("&");
}
return url;
},
classicationApiUrl: function(name, guid) {
var typeUrl = this.typedefsUrl();
if (name) {
......
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
define(['require',
'backbone',
'hbs!tmpl/audit/ReplicationAuditTableLayoutView_tmpl',
'utils/CommonViewFunction',
'utils/Utils',
'collection/VSearchList',
'collection/VEntityList',
'utils/Messages',
'utils/UrlLinks'
], function(require, Backbone, ReplicationAuditTableLayoutView_tmpl, CommonViewFunction, Utils, VSearchList, VEntityList, Messages, UrlLinks) {
'use strict';
var ReplicationAuditTableLayoutView = Backbone.Marionette.LayoutView.extend(
/** @lends TagDetailTableLayoutView */
{
_viewName: 'ReplicationAuditTableLayoutView',
template: ReplicationAuditTableLayoutView_tmpl,
/** Layout sub regions */
regions: {
RReplicationAuditTableLayoutView: "#r_replicationAuditTableLayoutView"
},
/** ui selector cache */
ui: {
auditDetail: "[data-action='audit_detail']",
},
/** ui events hash */
events: function() {
var events = {}
events["click " + this.ui.auditDetail] = "onClickAuditDetails";
return events;
},
/**
* intialize a new TagDetailTableLayoutView Layout
* @constructs
*/
initialize: function(options) {
_.extend(this, _.pick(options, 'entity', 'entityName', 'attributeDefs'));
this.searchCollection = new VSearchList();
this.entityModel = new(new VEntityList()).model();
this.limit = 25;
this.offset = 0;
this.name = Utils.getName(this.entity);
this.commonTableOptions = {
collection: this.searchCollection,
includePagination: false,
includeAtlasPagination: true,
includeFooterRecords: false,
includeColumnManager: false,
includeOrderAbleColumns: false,
includeSizeAbleColumns: false,
includeTableLoader: true,
atlasPaginationOpts: {
limit: this.limit,
offset: this.offset,
fetchCollection: this.fetchCollection.bind(this),
},
gridOpts: {
emptyText: 'No Record found!',
className: 'table table-hover backgrid table-quickMenu colSort'
},
filterOpts: {},
paginatorOpts: {}
};
},
bindEvents: function() {},
onRender: function() {
this.renderTableLayoutView();
},
fetchCollection: function(options) {
var that = this;
this.searchCollection.getExpimpAudit(this.searchCollection.queryParams, {
success: function(response) {
that.searchCollection.reset(response, options);
}
});
},
renderTableLayoutView: function() {
var that = this;
require(['utils/TableLayout'], function(TableLayout) {
var columnCollection = Backgrid.Columns.extend({
sortKey: "displayOrder",
comparator: function(item) {
return item.get(this.sortKey) || 999;
},
setPositions: function() {
_.each(this.models, function(model, index) {
model.set("displayOrder", index + 1, { silent: true });
});
return this;
}
});
var columns = new columnCollection(that.getColumn());
columns.setPositions().sort();
that.RReplicationAuditTableLayoutView.show(new TableLayout(_.extend({}, that.commonTableOptions, {
columns: columns
})));
_.extend(that.searchCollection.queryParams, { limit: that.limit, offset: that.offset, "serverName": that.name });
that.fetchCollection(_.extend({ 'fromUrl': true }));
});
},
getColumn: function(argument) {
var that = this,
col = {};
col['operation'] = {
label: "Operation",
cell: "string",
editable: false,
sortable: false,
className: "searchTableName"
};
col['sourceServerName'] = {
label: "Source Server",
cell: "string",
editable: false,
sortable: false,
className: "searchTableName"
};
col['targetServerName'] = {
label: "Target Server",
cell: "string",
editable: false,
sortable: false,
className: "searchTableName"
};
col['startTime'] = {
label: "Operation StartTime",
cell: "html",
editable: false,
sortable: false,
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
if (rawValue) {
return new Date(rawValue);
} else {
return '-';
}
}
})
};
col['endTime'] = {
label: "Operation EndTime",
cell: "html",
editable: false,
sortable: false,
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
if (rawValue) {
return new Date(rawValue);
} else {
return '-';
}
}
})
};
col['tools'] = {
label: "Tools",
cell: "html",
editable: false,
sortable: false,
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
return '<div class="btn btn-action btn-sm" data-action="audit_detail" data-guid="' + model.get('guid') + '">Detail</div>';
}
})
};
return this.searchCollection.constructor.getTableCols(col, this.searchCollection);
},
onClickAuditDetails: function(e) {
var that = this;
require([
'modules/Modal',
'views/audit/CreateAuditTableLayoutView',
], function(Modal, CreateAuditTableLayoutView) {
$(e.target).attr('disabled', true);
var guid = $(e.target).data("guid"),
model = that.searchCollection.fullCollection.findWhere({ 'guid': guid }),
result = JSON.parse(model.get("resultSummary")),
view = "<table class='table table-bordered table-striped'>" + CommonViewFunction.propertyTable({ scope: that, valueObject: result, attributeDefs: that.attributeDefs }) + "</table>";
var modal = new Modal({
title: model.get("operation") + " Details",
content: view,
contentHtml: true,
okCloses: true,
showFooter: true,
});
modal.open();
modal.on('closeModal', function() {
modal.trigger('cancel');
});
modal.on('hidden.bs.modal', function() {
that.$('.btn-action[data-action="audit_detail"]').attr('disabled', false);
});
});
},
});
return ReplicationAuditTableLayoutView;
});
\ No newline at end of file
......@@ -44,6 +44,7 @@ define(['require',
RTagTableLayoutView: "#r_tagTableLayoutView",
RLineageLayoutView: "#r_lineageLayoutView",
RAuditTableLayoutView: "#r_auditTableLayoutView",
RReplicationAuditTableLayoutView: "#r_replicationAuditTableLayoutView",
RProfileLayoutView: "#r_profileLayoutView",
RRelationshipLayoutView: "#r_relationshipLayoutView"
},
......@@ -228,6 +229,11 @@ define(['require',
}
if (this.activeEntityDef) {
//to display ReplicationAudit tab
if (collectionJSON && collectionJSON.typeName === "AtlasServer") {
this.$('.replicationTab').show();
this.renderReplicationAuditTableLayoutView(obj);
}
// To render Schema check attribute "schemaElementsAttribute"
var schemaOptions = this.activeEntityDef.get('options');
if (schemaOptions && schemaOptions.hasOwnProperty('schemaElementsAttribute') && schemaOptions.schemaElementsAttribute !== "") {
......@@ -489,6 +495,12 @@ define(['require',
that.RAuditTableLayoutView.show(new AuditTableLayoutView(obj));
});
},
renderReplicationAuditTableLayoutView: function(obj) {
var that = this;
require(['views/audit/ReplicationAuditTableLayoutView'], function(ReplicationAuditTableLayoutView) {
that.RReplicationAuditTableLayoutView.show(new ReplicationAuditTableLayoutView(obj));
});
},
renderProfileLayoutView: function(obj) {
var that = this;
require(['views/profile/ProfileLayoutView'], function(ProfileLayoutView) {
......
......@@ -69,7 +69,7 @@ define(['require',
showPage: "[data-id='showPage']",
gotoPage: "[data-id='gotoPage']",
gotoPagebtn: "[data-id='gotoPagebtn']",
activePage: "[data-id='activePage']",
activePage: "[data-id='activePage']"
},
templateHelpers: function() {
return {
......
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