This is an automated email from the ASF dual-hosted git repository. nbonte pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/atlas.git
The following commit(s) were added to refs/heads/master by this push: new a3e3b9c ATLAS-4270: UI: Deferred Actions: Add a notification about task running in the background fixed a3e3b9c is described below commit a3e3b9c02167e7832324b99c7c412bfaeeab52a8 Author: prasad pawar <prasad.pa...@freestoneinfotech.com> AuthorDate: Fri Apr 30 16:15:57 2021 +0530 ATLAS-4270: UI: Deferred Actions: Add a notification about task running in the background fixed Signed-off-by: Nikhil Bonte <nbo...@apache.org> --- dashboardv2/public/css/scss/tab.scss | 16 ++ dashboardv2/public/js/main.js | 5 +- .../detail_page/DetailPageLayoutView_tmpl.html | 10 + .../PendingTaskTableLayoutView_tmpl.html | 26 +++ dashboardv2/public/js/utils/Globals.js | 3 +- dashboardv2/public/js/utils/UrlLinks.js | 5 +- .../js/views/detail_page/DetailPageLayoutView.js | 11 +- .../detail_page/PendingTaskTableLayoutView.js | 218 +++++++++++++++++++++ dashboardv3/public/css/scss/tab.scss | 16 ++ dashboardv3/public/js/main.js | 5 +- .../detail_page/DetailPageLayoutView_tmpl.html | 10 + .../PendingTaskTableLayoutView_tmpl.html | 26 +++ dashboardv3/public/js/utils/Globals.js | 3 +- dashboardv3/public/js/utils/UrlLinks.js | 5 +- .../js/views/detail_page/DetailPageLayoutView.js | 11 +- .../detail_page/PendingTaskTableLayoutView.js | 218 +++++++++++++++++++++ .../apache/atlas/web/resources/AdminResource.java | 7 +- 17 files changed, 586 insertions(+), 9 deletions(-) diff --git a/dashboardv2/public/css/scss/tab.scss b/dashboardv2/public/css/scss/tab.scss index 1da54e0..9c85587 100644 --- a/dashboardv2/public/css/scss/tab.scss +++ b/dashboardv2/public/css/scss/tab.scss @@ -190,4 +190,20 @@ ul.tabs li.tab { } } } +} + +.pending-task { + padding: 10px 20px 15px 20px !important; + + .pending-refresh-btn { + margin-bottom: 10px; + } + + table tr th { + padding: 6px 8px !important; + } + + .panel-heading { + font-size: 16px; + } } \ No newline at end of file diff --git a/dashboardv2/public/js/main.js b/dashboardv2/public/js/main.js index 14d9e0f..7c8bbb4 100644 --- a/dashboardv2/public/js/main.js +++ b/dashboardv2/public/js/main.js @@ -283,6 +283,9 @@ require(['App', if (response['atlas.debug.metrics.enabled'] !== undefined) { Globals.isDebugMetricsEnabled = response["atlas.debug.metrics.enabled"]; } + if (response['atlas.tasks.enabled'] !== undefined) { + Globals.isTasksEnabled = response['atlas.tasks.enabled']; + } } --that.asyncFetchCounter; startApp(); @@ -362,4 +365,4 @@ require(['App', startApp(); } }); -}); +}); \ No newline at end of file diff --git a/dashboardv2/public/js/templates/detail_page/DetailPageLayoutView_tmpl.html b/dashboardv2/public/js/templates/detail_page/DetailPageLayoutView_tmpl.html index 5854dd7..ee4b943 100644 --- a/dashboardv2/public/js/templates/detail_page/DetailPageLayoutView_tmpl.html +++ b/dashboardv2/public/js/templates/detail_page/DetailPageLayoutView_tmpl.html @@ -58,6 +58,9 @@ <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> + {{#if isTasksEnabled}} + <li role="pendingTask" class="tab"><a href="#tab-pendingTask" aria-controls="tab-pendingTask" role="tab" data-toggle="tab">Tasks</a></li> + {{/if}} </ul> </div> </div> @@ -119,6 +122,13 @@ </div> </div> </div> + <div id="tab-pendingTask" role="pendingTask" class="tab-pane animated fadeIn pending-task"> + <div id="r_pendingTaskTableLayoutView"> + <div class="fontLoader-relative"> + <i class="fa fa-refresh fa-spin-custom"></i> + </div> + </div> + </div> <div id="tab-raudit" role="raudits" class="tab-pane"> <div id="r_replicationAuditTableLayoutView"> <div class="fontLoader-relative"> diff --git a/dashboardv2/public/js/templates/detail_page/PendingTaskTableLayoutView_tmpl.html b/dashboardv2/public/js/templates/detail_page/PendingTaskTableLayoutView_tmpl.html new file mode 100644 index 0000000..059c42f --- /dev/null +++ b/dashboardv2/public/js/templates/detail_page/PendingTaskTableLayoutView_tmpl.html @@ -0,0 +1,26 @@ +<!-- + * 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 class="position-relative"> + <button type="button" class="btn btn-action btn-md pull-right pending-refresh-btn" title="Refresh" data-id="refreshPendingTask" onclick="this.blur();" type="button"><i class="fa fa-refresh"></i></button> + <div class="tableOverlay"></div> + <div class="fontLoader"> + <i class="fa fa-refresh fa-spin-custom"></i> + </div> + <div class="auditTable" style="display: none"> + <div id="r_pendingTaskTableLayoutView"></div> + </div> +</div> \ No newline at end of file diff --git a/dashboardv2/public/js/utils/Globals.js b/dashboardv2/public/js/utils/Globals.js index 8ae89eb..2e94e6b 100644 --- a/dashboardv2/public/js/utils/Globals.js +++ b/dashboardv2/public/js/utils/Globals.js @@ -48,6 +48,7 @@ define(["require"], function(require) { Globals.isTimezoneFormatEnabled = true; Globals.isDebugMetricsEnabled = false; + Globals.isTasksEnabled = true; return Globals; -}); +}); \ No newline at end of file diff --git a/dashboardv2/public/js/utils/UrlLinks.js b/dashboardv2/public/js/utils/UrlLinks.js index 58a65f1..eb2980c 100644 --- a/dashboardv2/public/js/utils/UrlLinks.js +++ b/dashboardv2/public/js/utils/UrlLinks.js @@ -46,6 +46,9 @@ define(['require', 'utils/Enums', 'utils/Utils', 'underscore'], function(require metricsApiUrl: function() { return this.baseUrl + '/admin/metrics' }, + pendingTaskApiUrl: function() { + return this.baseUrl + '/admin/tasks' + }, debugMetricsApiUrl: function() { return this.baseUrl + '/admin/debug/metrics' }, @@ -263,4 +266,4 @@ define(['require', 'utils/Enums', 'utils/Utils', 'underscore'], function(require }); return UrlLinks; -}); +}); \ No newline at end of file diff --git a/dashboardv2/public/js/views/detail_page/DetailPageLayoutView.js b/dashboardv2/public/js/views/detail_page/DetailPageLayoutView.js index e83212f..d8e10cc 100644 --- a/dashboardv2/public/js/views/detail_page/DetailPageLayoutView.js +++ b/dashboardv2/public/js/views/detail_page/DetailPageLayoutView.js @@ -43,6 +43,7 @@ define(['require', RTagTableLayoutView: "#r_tagTableLayoutView", RLineageLayoutView: "#r_lineageLayoutView", RAuditTableLayoutView: "#r_auditTableLayoutView", + RPendingTaskTableLayoutView: "#r_pendingTaskTableLayoutView", RReplicationAuditTableLayoutView: "#r_replicationAuditTableLayoutView", RProfileLayoutView: "#r_profileLayoutView", RRelationshipLayoutView: "#r_relationshipLayoutView", @@ -71,7 +72,8 @@ define(['require', }, templateHelpers: function() { return { - entityUpdate: Globals.entityUpdate + entityUpdate: Globals.entityUpdate, + isTasksEnabled: Globals.isTasksEnabled }; }, /** ui events hash */ @@ -317,6 +319,7 @@ define(['require', this.renderRelationshipLayoutView(obj); this.renderAuditTableLayoutView(obj); this.renderTagTableLayoutView(obj); + if (Globals.isTasksEnabled) { this.renderPendingTaskTableLayoutView(); } // To render profile tab check for attribute "profileData" or typeName = "hive_db","hbase_namespace" if (collectionJSON && (!_.isUndefined(collectionJSON.attributes['profileData']) || collectionJSON.typeName === "hive_db" || collectionJSON.typeName === "hbase_namespace")) { @@ -629,6 +632,12 @@ define(['require', that.RTagTableLayoutView.show(new TagDetailTableLayoutView(obj)); }); }, + renderPendingTaskTableLayoutView: function() { + var that = this; + require(['views/detail_page/PendingTaskTableLayoutView'], function(PendingTaskTableLayoutView) { + that.RPendingTaskTableLayoutView.show(new PendingTaskTableLayoutView()); + }); + }, renderLineageLayoutView: function(obj) { var that = this; require(['views/graph/LineageLayoutView'], function(LineageLayoutView) { diff --git a/dashboardv2/public/js/views/detail_page/PendingTaskTableLayoutView.js b/dashboardv2/public/js/views/detail_page/PendingTaskTableLayoutView.js new file mode 100644 index 0000000..0e32ebe --- /dev/null +++ b/dashboardv2/public/js/views/detail_page/PendingTaskTableLayoutView.js @@ -0,0 +1,218 @@ +/** + * 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/detail_page/PendingTaskTableLayoutView_tmpl', + 'collection/VEntityList', + 'utils/Utils', + 'utils/Enums', + 'utils/UrlLinks', + 'utils/CommonViewFunction' +], function(require, Backbone, PendingTaskTableLayoutView_tmpl, VEntityList, Utils, Enums, UrlLinks, CommonViewFunction) { + 'use strict'; + + var PendingTaskTableLayoutView = Backbone.Marionette.LayoutView.extend( + /** @lends PendingTaskTableLayoutView */ + { + _viewName: 'PendingTaskTableLayoutView', + + template: PendingTaskTableLayoutView_tmpl, + + /** Layout sub regions */ + regions: { + RPendingTaskTableLayoutView: "#r_pendingTaskTableLayoutView", + }, + + /** ui selector cache */ + ui: { + refreshPendingTask: "[data-id='refreshPendingTask']" + }, + /** ui events hash */ + events: function() { + var events = {}; + events["click " + this.ui.refreshPendingTask] = function(e) { + this.fetchPendingTaskCollection(); + }; + return events; + }, + /** + * intialize a new PendingTaskTableLayoutView Layout + * @constructs + */ + initialize: function(options) { + _.extend(this, _.pick(options, 'guid', 'entity', 'entityName', 'attributeDefs')); + this.pendingTaskCollection = new VEntityList(); + this.limit = 25; + this.offset = 0; + this.pendingTaskCollection.url = UrlLinks.pendingTaskApiUrl(); + this.entityModel = new this.pendingTaskCollection.model(); + this.pervOld = []; + this.commonTableOptions = { + collection: this.pendingTaskCollection, + includeFilter: false, + includePagination: false, + includeAtlasPagination: true, + includeAtlasPageSize: true, + includeTableLoader: true, + includeAtlasTableSorting: false, + showDefaultTableSorted: false, + columnSorting: false, + includeFooterRecords: false, + gridOpts: { + className: "table table-hover backgrid table-quickMenu", + emptyText: 'No records found!' + }, + isApiSorting: false, + atlasPaginationOpts: this.getPaginationOptions(), + filterOpts: {}, + paginatorOpts: {} + }; + this.currPage = 1; + this.fromSort = false; + }, + onRender: function() { + this.fetchPendingTaskCollection(); + }, + fetchPendingTaskCollection: function() { + this.commonTableOptions['atlasPaginationOpts'] = this.getPaginationOptions(); + this.fetchCollection(); + this.pendingTaskCollection.comparator = function(model) { + return -model.get('createdBy'); + } + }, + bindEvents: function() {}, + getPaginationOptions: function() { + return { + count: this.getPageCount(), + offset: this.pendingTaskCollection.queryParams.offset || this.offset, + fetchCollection: this.fetchCollection.bind(this) + }; + }, + getPageCount: function() { + return (this.pendingTaskCollection.queryParams.limit || this.pendingTaskCollection.queryParams.count) || this.limit; + }, + fetchCollection: function(options) { + var that = this; + + this.pendingTaskCollection.fetch({ + success: function(dataOrCollection, response) { + that.pendingTaskCollection.state.pageSize = that.getPageCount(); + that.pendingTaskCollection.fullCollection.reset(response); + }, + complete: function() { + that.$('.fontLoader').hide(); + that.$('.tableOverlay').hide(); + that.$('.auditTable').show(); + that.renderTableLayoutView(); + }, + silent: true + }); + + }, + renderTableLayoutView: function() { + var that = this; + require(['utils/TableLayout'], function(TableLayout) { + var cols = new Backgrid.Columns(that.getAuditTableColumns()); + that.RPendingTaskTableLayoutView.show(new TableLayout(_.extend({}, that.commonTableOptions, { + columns: cols + }))); + + }); + }, + getAuditTableColumns: function() { + var that = this; + return this.pendingTaskCollection.constructor.getTableCols({ + tool: { + label: "", + cell: "html", + editable: false, + sortable: false, + fixWidth: "20", + cell: Backgrid.ExpandableCell, + accordion: false, + expand: function(el, model) { + el.attr('colspan', '8'); + var count = model.get('attemptCount'), + parameters = _.omit(_.extend(model.get('parameters'), { 'attemptCount': model.get('attemptCount'), 'createdBy': model.get('createdBy') }),"entityGuid"), + memoryTable = CommonViewFunction.propertyTable({ + scope: this, + formatStringVal: false, + valueObject: parameters + }), + tableData = ' <div class="col-sm-12"> <div class="card-container panel panel-default custom-panel">' + + '<div class="panel-heading">Parameters</div> <div class="panel-body">' + + '<table class="table stat-table task-details">' + + '<tbody data-id="memory-card">' + + memoryTable + + '</tbody>' + + '</table> </div> </div> </div>'; + $(el).append($('<div>').html(tableData)); + } + }, + type: { + label: "Type", + cell: "html", + sortable: false, + editable: false, + formatter: _.extend({}, Backgrid.CellFormatter.prototype, { + fromRaw: function(rawValue, model) { + return Enums.auditAction[model.get('type')] || rawValue; + } + }) + }, + guid: { + label: "Guid", + cell: "html", + sortable: false, + editable: false + }, + status: { + label: "Status", + cell: "html", + sortable: false, + editable: false + }, + createdTime: { + label: "Created Time", + cell: "html", + editable: false, + sortable: false, + formatter: _.extend({}, Backgrid.CellFormatter.prototype, { + fromRaw: function(rawValue, model) { + return Utils.formatDate({ date: rawValue }); + } + }) + }, + updatedTime: { + label: "Updated Time", + cell: "html", + editable: false, + sortable: false, + formatter: _.extend({}, Backgrid.CellFormatter.prototype, { + fromRaw: function(rawValue, model) { + return Utils.formatDate({ date: rawValue }); + } + }) + } + }, this.pendingTaskCollection); + + } + }); + return PendingTaskTableLayoutView; +}); \ No newline at end of file diff --git a/dashboardv3/public/css/scss/tab.scss b/dashboardv3/public/css/scss/tab.scss index 1da54e0..9c85587 100644 --- a/dashboardv3/public/css/scss/tab.scss +++ b/dashboardv3/public/css/scss/tab.scss @@ -190,4 +190,20 @@ ul.tabs li.tab { } } } +} + +.pending-task { + padding: 10px 20px 15px 20px !important; + + .pending-refresh-btn { + margin-bottom: 10px; + } + + table tr th { + padding: 6px 8px !important; + } + + .panel-heading { + font-size: 16px; + } } \ No newline at end of file diff --git a/dashboardv3/public/js/main.js b/dashboardv3/public/js/main.js index 7264a9c..374641e 100644 --- a/dashboardv3/public/js/main.js +++ b/dashboardv3/public/js/main.js @@ -312,6 +312,9 @@ require(['App', if (response['atlas.debug.metrics.enabled'] !== undefined) { Globals.isDebugMetricsEnabled = response["atlas.debug.metrics.enabled"]; } + if (response['atlas.tasks.enabled'] !== undefined) { + Globals.isTasksEnabled = response['atlas.tasks.enabled']; + } } --that.asyncFetchCounter; startApp(); @@ -393,4 +396,4 @@ require(['App', startApp(); } }); -}); +}); \ No newline at end of file diff --git a/dashboardv3/public/js/templates/detail_page/DetailPageLayoutView_tmpl.html b/dashboardv3/public/js/templates/detail_page/DetailPageLayoutView_tmpl.html index 18fc1f9..b209a49 100644 --- a/dashboardv3/public/js/templates/detail_page/DetailPageLayoutView_tmpl.html +++ b/dashboardv3/public/js/templates/detail_page/DetailPageLayoutView_tmpl.html @@ -61,6 +61,9 @@ <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> + {{#if isTasksEnabled}} + <li role="pendingTask" class="tab"><a href="#tab-pendingTask" aria-controls="tab-pendingTask" role="tab" data-toggle="tab">Tasks</a></li> + {{/if}} </ul> </div> </div> @@ -122,6 +125,13 @@ </div> </div> </div> + <div id="tab-pendingTask" role="pendingTask" class="tab-pane animated fadeIn pending-task"> + <div id="r_pendingTaskTableLayoutView"> + <div class="fontLoader-relative"> + <i class="fa fa-refresh fa-spin-custom"></i> + </div> + </div> + </div> <div id="tab-raudit" role="raudits" class="tab-pane"> <div id="r_replicationAuditTableLayoutView"> <div class="fontLoader-relative"> diff --git a/dashboardv3/public/js/templates/detail_page/PendingTaskTableLayoutView_tmpl.html b/dashboardv3/public/js/templates/detail_page/PendingTaskTableLayoutView_tmpl.html new file mode 100644 index 0000000..059c42f --- /dev/null +++ b/dashboardv3/public/js/templates/detail_page/PendingTaskTableLayoutView_tmpl.html @@ -0,0 +1,26 @@ +<!-- + * 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 class="position-relative"> + <button type="button" class="btn btn-action btn-md pull-right pending-refresh-btn" title="Refresh" data-id="refreshPendingTask" onclick="this.blur();" type="button"><i class="fa fa-refresh"></i></button> + <div class="tableOverlay"></div> + <div class="fontLoader"> + <i class="fa fa-refresh fa-spin-custom"></i> + </div> + <div class="auditTable" style="display: none"> + <div id="r_pendingTaskTableLayoutView"></div> + </div> +</div> \ No newline at end of file diff --git a/dashboardv3/public/js/utils/Globals.js b/dashboardv3/public/js/utils/Globals.js index 8ae89eb..2e94e6b 100644 --- a/dashboardv3/public/js/utils/Globals.js +++ b/dashboardv3/public/js/utils/Globals.js @@ -48,6 +48,7 @@ define(["require"], function(require) { Globals.isTimezoneFormatEnabled = true; Globals.isDebugMetricsEnabled = false; + Globals.isTasksEnabled = true; return Globals; -}); +}); \ No newline at end of file diff --git a/dashboardv3/public/js/utils/UrlLinks.js b/dashboardv3/public/js/utils/UrlLinks.js index 5047fe3..b500ebd 100644 --- a/dashboardv3/public/js/utils/UrlLinks.js +++ b/dashboardv3/public/js/utils/UrlLinks.js @@ -46,6 +46,9 @@ define(['require', 'utils/Enums', 'utils/Utils', 'underscore'], function(require metricsApiUrl: function() { return this.baseUrl + '/admin/metrics' }, + pendingTaskApiUrl: function() { + return this.baseUrl + '/admin/tasks' + }, debugMetricsApiUrl: function() { return this.baseUrl + '/admin/debug/metrics' }, @@ -254,4 +257,4 @@ define(['require', 'utils/Enums', 'utils/Utils', 'underscore'], function(require }); return UrlLinks; -}); +}); \ No newline at end of file diff --git a/dashboardv3/public/js/views/detail_page/DetailPageLayoutView.js b/dashboardv3/public/js/views/detail_page/DetailPageLayoutView.js index a18984e..8e0686b 100644 --- a/dashboardv3/public/js/views/detail_page/DetailPageLayoutView.js +++ b/dashboardv3/public/js/views/detail_page/DetailPageLayoutView.js @@ -43,6 +43,7 @@ define(['require', RTagTableLayoutView: "#r_tagTableLayoutView", RLineageLayoutView: "#r_lineageLayoutView", RAuditTableLayoutView: "#r_auditTableLayoutView", + RPendingTaskTableLayoutView: "#r_pendingTaskTableLayoutView", RReplicationAuditTableLayoutView: "#r_replicationAuditTableLayoutView", RProfileLayoutView: "#r_profileLayoutView", RRelationshipLayoutView: "#r_relationshipLayoutView", @@ -72,7 +73,8 @@ define(['require', }, templateHelpers: function() { return { - entityUpdate: Globals.entityUpdate + entityUpdate: Globals.entityUpdate, + isTasksEnabled: Globals.isTasksEnabled }; }, /** ui events hash */ @@ -321,6 +323,7 @@ define(['require', this.renderRelationshipLayoutView(obj); this.renderAuditTableLayoutView(obj); this.renderTagTableLayoutView(obj); + if (Globals.isTasksEnabled) { this.renderPendingTaskTableLayoutView(); } // To render profile tab check for attribute "profileData" or typeName = "hive_db","hbase_namespace" if (collectionJSON && (!_.isUndefined(collectionJSON.attributes['profileData']) || collectionJSON.typeName === "hive_db" || collectionJSON.typeName === "hbase_namespace")) { @@ -644,6 +647,12 @@ define(['require', that.RTagTableLayoutView.show(new TagDetailTableLayoutView(obj)); }); }, + renderPendingTaskTableLayoutView: function() { + var that = this; + require(['views/detail_page/PendingTaskTableLayoutView'], function(PendingTaskTableLayoutView) { + that.RPendingTaskTableLayoutView.show(new PendingTaskTableLayoutView()); + }); + }, renderLineageLayoutView: function(obj) { var that = this; require(['views/graph/LineageLayoutView'], function(LineageLayoutView) { diff --git a/dashboardv3/public/js/views/detail_page/PendingTaskTableLayoutView.js b/dashboardv3/public/js/views/detail_page/PendingTaskTableLayoutView.js new file mode 100644 index 0000000..0e32ebe --- /dev/null +++ b/dashboardv3/public/js/views/detail_page/PendingTaskTableLayoutView.js @@ -0,0 +1,218 @@ +/** + * 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/detail_page/PendingTaskTableLayoutView_tmpl', + 'collection/VEntityList', + 'utils/Utils', + 'utils/Enums', + 'utils/UrlLinks', + 'utils/CommonViewFunction' +], function(require, Backbone, PendingTaskTableLayoutView_tmpl, VEntityList, Utils, Enums, UrlLinks, CommonViewFunction) { + 'use strict'; + + var PendingTaskTableLayoutView = Backbone.Marionette.LayoutView.extend( + /** @lends PendingTaskTableLayoutView */ + { + _viewName: 'PendingTaskTableLayoutView', + + template: PendingTaskTableLayoutView_tmpl, + + /** Layout sub regions */ + regions: { + RPendingTaskTableLayoutView: "#r_pendingTaskTableLayoutView", + }, + + /** ui selector cache */ + ui: { + refreshPendingTask: "[data-id='refreshPendingTask']" + }, + /** ui events hash */ + events: function() { + var events = {}; + events["click " + this.ui.refreshPendingTask] = function(e) { + this.fetchPendingTaskCollection(); + }; + return events; + }, + /** + * intialize a new PendingTaskTableLayoutView Layout + * @constructs + */ + initialize: function(options) { + _.extend(this, _.pick(options, 'guid', 'entity', 'entityName', 'attributeDefs')); + this.pendingTaskCollection = new VEntityList(); + this.limit = 25; + this.offset = 0; + this.pendingTaskCollection.url = UrlLinks.pendingTaskApiUrl(); + this.entityModel = new this.pendingTaskCollection.model(); + this.pervOld = []; + this.commonTableOptions = { + collection: this.pendingTaskCollection, + includeFilter: false, + includePagination: false, + includeAtlasPagination: true, + includeAtlasPageSize: true, + includeTableLoader: true, + includeAtlasTableSorting: false, + showDefaultTableSorted: false, + columnSorting: false, + includeFooterRecords: false, + gridOpts: { + className: "table table-hover backgrid table-quickMenu", + emptyText: 'No records found!' + }, + isApiSorting: false, + atlasPaginationOpts: this.getPaginationOptions(), + filterOpts: {}, + paginatorOpts: {} + }; + this.currPage = 1; + this.fromSort = false; + }, + onRender: function() { + this.fetchPendingTaskCollection(); + }, + fetchPendingTaskCollection: function() { + this.commonTableOptions['atlasPaginationOpts'] = this.getPaginationOptions(); + this.fetchCollection(); + this.pendingTaskCollection.comparator = function(model) { + return -model.get('createdBy'); + } + }, + bindEvents: function() {}, + getPaginationOptions: function() { + return { + count: this.getPageCount(), + offset: this.pendingTaskCollection.queryParams.offset || this.offset, + fetchCollection: this.fetchCollection.bind(this) + }; + }, + getPageCount: function() { + return (this.pendingTaskCollection.queryParams.limit || this.pendingTaskCollection.queryParams.count) || this.limit; + }, + fetchCollection: function(options) { + var that = this; + + this.pendingTaskCollection.fetch({ + success: function(dataOrCollection, response) { + that.pendingTaskCollection.state.pageSize = that.getPageCount(); + that.pendingTaskCollection.fullCollection.reset(response); + }, + complete: function() { + that.$('.fontLoader').hide(); + that.$('.tableOverlay').hide(); + that.$('.auditTable').show(); + that.renderTableLayoutView(); + }, + silent: true + }); + + }, + renderTableLayoutView: function() { + var that = this; + require(['utils/TableLayout'], function(TableLayout) { + var cols = new Backgrid.Columns(that.getAuditTableColumns()); + that.RPendingTaskTableLayoutView.show(new TableLayout(_.extend({}, that.commonTableOptions, { + columns: cols + }))); + + }); + }, + getAuditTableColumns: function() { + var that = this; + return this.pendingTaskCollection.constructor.getTableCols({ + tool: { + label: "", + cell: "html", + editable: false, + sortable: false, + fixWidth: "20", + cell: Backgrid.ExpandableCell, + accordion: false, + expand: function(el, model) { + el.attr('colspan', '8'); + var count = model.get('attemptCount'), + parameters = _.omit(_.extend(model.get('parameters'), { 'attemptCount': model.get('attemptCount'), 'createdBy': model.get('createdBy') }),"entityGuid"), + memoryTable = CommonViewFunction.propertyTable({ + scope: this, + formatStringVal: false, + valueObject: parameters + }), + tableData = ' <div class="col-sm-12"> <div class="card-container panel panel-default custom-panel">' + + '<div class="panel-heading">Parameters</div> <div class="panel-body">' + + '<table class="table stat-table task-details">' + + '<tbody data-id="memory-card">' + + memoryTable + + '</tbody>' + + '</table> </div> </div> </div>'; + $(el).append($('<div>').html(tableData)); + } + }, + type: { + label: "Type", + cell: "html", + sortable: false, + editable: false, + formatter: _.extend({}, Backgrid.CellFormatter.prototype, { + fromRaw: function(rawValue, model) { + return Enums.auditAction[model.get('type')] || rawValue; + } + }) + }, + guid: { + label: "Guid", + cell: "html", + sortable: false, + editable: false + }, + status: { + label: "Status", + cell: "html", + sortable: false, + editable: false + }, + createdTime: { + label: "Created Time", + cell: "html", + editable: false, + sortable: false, + formatter: _.extend({}, Backgrid.CellFormatter.prototype, { + fromRaw: function(rawValue, model) { + return Utils.formatDate({ date: rawValue }); + } + }) + }, + updatedTime: { + label: "Updated Time", + cell: "html", + editable: false, + sortable: false, + formatter: _.extend({}, Backgrid.CellFormatter.prototype, { + fromRaw: function(rawValue, model) { + return Utils.formatDate({ date: rawValue }); + } + }) + } + }, this.pendingTaskCollection); + + } + }); + return PendingTaskTableLayoutView; +}); \ No newline at end of file diff --git a/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java b/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java index b812819..e4b6ea9 100755 --- a/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java +++ b/webapp/src/main/java/org/apache/atlas/web/resources/AdminResource.java @@ -23,6 +23,7 @@ import org.apache.atlas.ApplicationProperties; import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasConfiguration; import org.apache.atlas.AtlasErrorCode; +import org.apache.atlas.AtlasConfiguration; import org.apache.atlas.authorize.AtlasAdminAccessRequest; import org.apache.atlas.authorize.AtlasAuthorizationUtils; import org.apache.atlas.authorize.AtlasEntityAccessRequest; @@ -170,6 +171,7 @@ public class AdminResource { private final String uiDateFormat; private final AtlasDebugMetricsSink debugMetricsRESTSink; private final boolean isDebugMetricsEnabled; + private final boolean isTasksEnabled; static { try { @@ -209,11 +211,13 @@ public class AdminResource { this.isTimezoneFormatEnabled = atlasProperties.getBoolean(UI_DATE_TIMEZONE_FORMAT_ENABLED, true); this.uiDateFormat = atlasProperties.getString(UI_DATE_FORMAT, UI_DATE_DEFAULT_FORMAT); this.isDebugMetricsEnabled = AtlasConfiguration.DEBUG_METRICS_ENABLED.getBoolean(); + this.isTasksEnabled = AtlasConfiguration.TASKS_USE_ENABLED.getBoolean(); } else { this.defaultUIVersion = UI_VERSION_V2; this.isTimezoneFormatEnabled = true; this.uiDateFormat = UI_DATE_DEFAULT_FORMAT; this.isDebugMetricsEnabled = false; + this.isTasksEnabled = false; } } @@ -362,7 +366,8 @@ public class AdminResource { responseData.put(UI_DATE_TIMEZONE_FORMAT_ENABLED, isTimezoneFormatEnabled); responseData.put(UI_DATE_FORMAT, uiDateFormat); responseData.put(AtlasConfiguration.DEBUG_METRICS_ENABLED.getPropertyName(), isDebugMetricsEnabled); - + responseData.put(AtlasConfiguration.TASKS_USE_ENABLED.getPropertyName(), isTasksEnabled); + response = Response.ok(AtlasJson.toV1Json(responseData)).build(); if (LOG.isDebugEnabled()) {