Skip to content

Commit

Permalink
Updating StatsView to use AppModel nodeId
Browse files Browse the repository at this point in the history
Updating StatsView to use AppModel nodeId
  • Loading branch information
rushirajnenuji committed Feb 18, 2020
1 parent 8aed303 commit 71c853d
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 36 deletions.
6 changes: 6 additions & 0 deletions src/js/models/AppModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ define(['jquery', 'underscore', 'backbone'],
*/
metricsUrl: 'https://logproc-stage-ucsb-1.test.dataone.org/metrics',

// Metrics Falgs for the /profile view (summary view)
hideSummaryCitationsChart: false,
hideSummaryDownloadsChart: false,
hideSummaryMetadataAssessment: true,
hideSummaryViewsChart: false,

/**
* Metrics flag for the Dataset Landing Page
* Enable this flag to enable metrics display
Expand Down
9 changes: 3 additions & 6 deletions src/js/routers/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,17 +409,14 @@ function ($, _, Backbone) {
if(!username || !MetacatUI.appModel.get("enableUserProfiles")){
this.routeHistory.push("summary");

var viewOptions = { nodeId: "urn:node:CN" };
// flag indicating /profile view
var viewOptions = { nodeSummaryView: true };

if(!MetacatUI.appView.statsView){

require(['views/StatsView'], function(StatsView){
MetacatUI.appView.statsView = new StatsView({
userType: "repository",
hideMetadataAssessment: true,
hideCitationsChart: false,
hideDownloadsChart: false,
hideViewsChart: false
userType: "repository"
});

MetacatUI.appView.showView(MetacatUI.appView.statsView, viewOptions);
Expand Down
8 changes: 7 additions & 1 deletion src/js/themes/arctic/models/AppModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,13 @@ define(['jquery', 'underscore', 'backbone'],
mdqAggregatedSuiteLabels: ["FAIR Suite v1.0"],

// Metrics endpoint url
metricsUrl: 'https://logproc-stage-ucsb-1.test.dataone.org/test/metrics',
metricsUrl: 'https://logproc-stage-ucsb-1.test.dataone.org/metrics',

// Metrics Falgs for the /profile view (summary view)
hideSummaryCitationsChart: false,
hideSummaryDownloadsChart: false,
hideSummaryMetadataAssessment: true,
hideSummaryViewsChart: false,

// Metrics flags for the Dataset Landing Page
// Enable these flags to enable metrics display
Expand Down
9 changes: 3 additions & 6 deletions src/js/themes/arctic/routers/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,17 +224,14 @@ function ($, _, Backbone) {
if(!username || !MetacatUI.appModel.get("enableUserProfiles")){
this.routeHistory.push("summary");

var viewOptions = { nodeId: "urn:node:ARCTIC" };
// flag indicating /profile view
var viewOptions = { nodeSummaryView: true };

if(!MetacatUI.appView.statsView){

require(['views/StatsView'], function(StatsView){
MetacatUI.appView.statsView = new StatsView({
userType: "repository",
hideMetadataAssessment: true,
hideCitationsChart: false,
hideDownloadsChart: false,
hideViewsChart: false
userType: "repository"
});

MetacatUI.appView.showView(MetacatUI.appView.statsView, viewOptions);
Expand Down
7 changes: 7 additions & 0 deletions src/js/themes/dataone/models/AppModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ define(['jquery', 'underscore', 'backbone'],
// Metrics endpoint url
metricsUrl: 'https://logproc-stage-ucsb-1.test.dataone.org/metrics',

// Metrics Falgs for the /profile view (summary view)
hideSummaryCitationsChart: false,
hideSummaryDownloadsChart: false,
hideSummaryMetadataAssessment: true,
hideSummaryViewsChart: false,


// Metrics flags for the Dataset Landing Page
// Enable these flags to enable metrics display
displayDatasetMetrics: true,
Expand Down
9 changes: 3 additions & 6 deletions src/js/themes/dataone/routers/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,17 +254,14 @@ function ($, _, Backbone) {
if(!username || !MetacatUI.appModel.get("enableUserProfiles")){
this.routeHistory.push("summary");

var viewOptions = { nodeId: "urn:node:CN" };
// flag indicating /profile view
var viewOptions = { nodeSummaryView: true };

if(!MetacatUI.appView.statsView){

require(['views/StatsView'], function(StatsView){
MetacatUI.appView.statsView = new StatsView({
userType: "repository",
hideMetadataAssessment: true,
hideCitationsChart: false,
hideDownloadsChart: false,
hideViewsChart: false
userType: "repository"
});

MetacatUI.appView.showView(MetacatUI.appView.statsView, viewOptions);
Expand Down
8 changes: 2 additions & 6 deletions src/js/themes/goa/routers/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,17 +227,13 @@ function ($, _, Backbone) {
if(!username || !MetacatUI.appModel.get("enableUserProfiles")){
this.routeHistory.push("summary");

var viewOptions = { nodeId: "urn:node:GOA" };
var viewOptions = { nodeSummaryView: true };

if(!MetacatUI.appView.statsView){

require(['views/StatsView'], function(StatsView){
MetacatUI.appView.statsView = new StatsView({
userType: "repository",
hideMetadataAssessment: true,
hideCitationsChart: false,
hideDownloadsChart: false,
hideViewsChart: false
userType: "repository"
});

MetacatUI.appView.showView(MetacatUI.appView.statsView, viewOptions);
Expand Down
8 changes: 7 additions & 1 deletion src/js/themes/knb/models/AppModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,13 @@ define(['jquery', 'underscore', 'backbone'],
mdqAggregatedSuiteLabels: ["FAIR Suite v1.0"],

// Metrics endpoint url
metricsUrl: 'https://logproc-stage-ucsb-1.test.dataone.org/test/metrics',
metricsUrl: 'https://logproc-stage-ucsb-1.test.dataone.org/metrics',

// Metrics Falgs for the /profile view (summary view)
hideSummaryCitationsChart: false,
hideSummaryDownloadsChart: false,
hideSummaryMetadataAssessment: true,
hideSummaryViewsChart: false,

// Metrics flags for the Dataset Landing Page
// Enable these flags to enable metrics display
Expand Down
11 changes: 4 additions & 7 deletions src/js/themes/knb/routers/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,15 @@ function($, _, Backbone, BaseRouter) {

if(!username || !MetacatUI.appModel.get("enableUserProfiles")){
this.routeHistory.push("summary");

var viewOptions = { nodeId: "urn:node:KNB" };

// flag indicating /profile view
var viewOptions = { nodeSummaryView: true };

if(!MetacatUI.appView.statsView){

require(['views/StatsView'], function(StatsView){
MetacatUI.appView.statsView = new StatsView({
userType: "repository",
hideMetadataAssessment: true,
hideCitationsChart: false,
hideDownloadsChart: false,
hideViewsChart: false
userType: "repository"
});

MetacatUI.appView.showView(MetacatUI.appView.statsView, viewOptions);
Expand Down
18 changes: 15 additions & 3 deletions src/js/views/StatsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,15 @@ define(['jquery', 'underscore', 'backbone', 'd3', 'LineChart', 'BarChart', 'Donu
if ( !options )
options = {};

var nodeId = (typeof options.nodeId === "undefined") ? "undefined" : options.nodeId;
if ( options.nodeSummaryView ) {
var nodeId = MetacatUI.appModel.get("nodeId");

// Overwrite the metrics display flags as set in the AppModel
this.hideMetadataAssessment = MetacatUI.appModel.get("hideSummaryMetadataAssessment");
this.hideCitationsChart = MetacatUI.appModel.get("hideSummaryCitationsChart");
this.hideDownloadsChart = MetacatUI.appModel.get("hideSummaryDownloadsChart");
this.hideViewsChart = MetacatUI.appModel.get("hideSummaryViewsChart");
}

if ( typeof this.metricsModel === "undefined" ) {

Expand Down Expand Up @@ -86,15 +94,19 @@ define(['jquery', 'underscore', 'backbone', 'd3', 'LineChart', 'BarChart', 'Donu
//Clear the page
this.$el.html("");

var view = this;

if (this.userType == "portal" || this.userType === "repository") {
if (this.metricsModel.get("totalViews") !== null) {
this.renderMetrics();
}
else{
this.listenTo(this.metricsModel, "sync" , this.renderMetrics);

// render metrics on fetch success.
this.listenTo(view.metricsModel, "sync" , this.renderMetrics);

// in case when there is an error for the fetch call.
this.listenTo(this.metricsModel, "error", this.renderUsageMetricsError);
this.listenTo(view.metricsModel, "error", this.renderUsageMetricsError);
}
}

Expand Down

0 comments on commit 71c853d

Please sign in to comment.