Skip to content

Commit

Permalink
Merge branch 'dev-2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
laurenwalker committed Aug 21, 2018
2 parents 7f82e0a + a8363fa commit 518afc2
Show file tree
Hide file tree
Showing 17 changed files with 351 additions and 326 deletions.
2 changes: 1 addition & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


<!-- Pull in correct theme configuration, then use Require.js to manage dependencies -->
<script id="loader" type="text/javascript" src="/metacatui/loader.js?v=2.1.0"
<script id="loader" type="text/javascript" src="/metacatui/loader.js?v=2.1.1"
data-theme="default"
data-metacat-context="metacat"
data-map-key="YOUR-GOOGLE-MAPS-API-KEY"
Expand Down
6 changes: 6 additions & 0 deletions src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,12 @@ function(Bootstrap, AppView, AppModel) {
return;
}

//Don't route to URLs with the DataONE API, which are sometimes proxied
// via Apache ProxyPass so start with the MetacatUI origin
if( href.attr.indexOf("/cn/v2/") > 0 || href.attr.indexOf("/mn/v2/") > 0 ){
return;
}

var root = location.protocol + "//" + location.host + Backbone.history.options.root;
// Remove the MetacatUI (plus a trailing /) from the value in the 'href'
// attribute of the clicked element so Backbone.history.navigate works.
Expand Down
24 changes: 22 additions & 2 deletions src/js/models/NodeModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,22 @@ define(['jquery', 'underscore', 'backbone'],
node.memberSince = node.CN_date_operational;

node.shortIdentifier = node.identifier.substring(node.identifier.lastIndexOf(":") + 1);


if(node.type == "mn") memberList.push(node);
if(node.type == "cn") coordList.push(node);
// Push only if the node is not present in the list
if ( node.type == "mn" ) {
if ( !thisModel.containsObject(node, memberList) ) {
memberList.push(node);
}
}

// Push only if the node is not present in the list
if ( node.type == "cn" ) {
if ( !thisModel.containsObject(node, coordList) ) {
coordList.push(node);
}
}

});

//Save the cn and mn lists in the model when all members have been added
Expand Down Expand Up @@ -174,6 +187,13 @@ define(['jquery', 'underscore', 'backbone'],
}
});
},

// Checks if the node already exists in the List
containsObject: function (obj, list) {
var res = _.find(list, function(val){ return _.isEqual(obj, val)});
return (_.isObject(res))? true:false;
},


/*
* Returns true if the given nodeId is a Coordinating Node
Expand Down
27 changes: 14 additions & 13 deletions src/js/routers/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ function ($, _, Backbone) {
// to make this route more inclusive.
this.route(/^view\/(.*)$/, "renderMetadata");

this.on("route", this.trackHash);
this.on("route", this.trackPathName);

// Clear stale JSONLD and meta tags
this.on("route", this.clearJSONLD);
this.on("route", this.clearHighwirePressMetaTags);
},

//Keep track of navigation movements
routeHistory: new Array(),
hashHistory: new Array(),
pathHistory: new Array(),

// Will return the last route, which is actually the second to last item in the route history,
// since the last item is the route being currently viewed
Expand All @@ -66,21 +66,22 @@ function ($, _, Backbone) {
return this.routeHistory[this.routeHistory.length-2];
},

trackHash: function(e){
if(_.last(this.hashHistory) != window.location.hash)
this.hashHistory.push(window.location.hash);
trackPathName: function(e){
if(_.last(this.pathHistory) != window.location.pathname)
this.pathHistory.push(window.location.pathname);
},

//If the user or app cancelled the last route, call this function to revert the window location hash back to the correct value
//If the user or app cancelled the last route, call this function to revert
// the window location pathname back to the correct value
undoLastRoute: function(){
this.routeHistory.pop();

// Remove the last route and hash from the history
if(_.last(this.hashHistory) == window.location.hash)
this.hashHistory.pop();
// Remove the last route and pathname from the history
if(_.last(this.pathHistory) == window.location.pathname)
this.pathHistory.pop();

//Change the hash in the window location back
this.navigate(_.last(this.hashHistory), {replace: true});
//Change the pathname in the window location back
this.navigate(_.last(this.pathHistory), {replace: true});
},

renderIndex: function (param) {
Expand Down Expand Up @@ -442,7 +443,7 @@ function ($, _, Backbone) {
renderLdapSignInSuccess: function(){

//If there is an LDAP sign in error message
if(window.location.hash.indexOf("error=Unable%20to%20authenticate%20LDAP%20user") > -1){
if(window.location.pathname.indexOf("error=Unable%20to%20authenticate%20LDAP%20user") > -1){
this.renderLdapOnlySignInError();
}
else{
Expand Down
26 changes: 13 additions & 13 deletions src/js/themes/arctic/routers/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ function ($, _, Backbone) {
// to make this route more inclusive.
this.route(/^view\/(.*)$/, "renderMetadata");

//Track the history of hashes
this.on("route", this.trackHash);
//Track the history of pathnames
this.on("route", this.trackPathName);

// Clear stale JSONLD and meta tags
this.on("route", this.clearJSONLD);
this.on("route", this.clearHighwirePressMetaTags);
},

//Keep track of navigation movements
routeHistory: new Array(),
hashHistory: new Array(),
pathHistory: new Array(),

// Will return the last route, which is actually the second to last item in the route history,
// since the last item is the route being currently viewed
Expand All @@ -58,21 +58,21 @@ function ($, _, Backbone) {
return this.routeHistory[this.routeHistory.length-2];
},

trackHash: function(e){
if(_.last(this.hashHistory) != window.location.hash)
this.hashHistory.push(window.location.hash);
trackPathName: function(e){
if(_.last(this.pathHistory) != window.location.pathname)
this.pathHistory.push(window.location.pathname);
},

//If the user or app cancelled the last route, call this function to revert the window location hash back to the correct value
//If the user or app cancelled the last route, call this function to revert the window location pathname back to the correct value
undoLastRoute: function(){
this.routeHistory.pop();

// Remove the last route and hash from the history
if(_.last(this.hashHistory) == window.location.hash)
this.hashHistory.pop();
// Remove the last route and pathname from the history
if(_.last(this.pathHistory) == window.location.pathname)
this.pathHistory.pop();

//Change the hash in the window location back
this.navigate(_.last(this.hashHistory), {replace: true});
//Change the pathname in the window location back
this.navigate(_.last(this.pathHistory), {replace: true});
},

renderAPI: function (anchorId) {
Expand Down
4 changes: 2 additions & 2 deletions src/js/themes/dataone/css/metacatui.css
Original file line number Diff line number Diff line change
Expand Up @@ -1721,9 +1721,9 @@ svg .packages,
.profile .bar-label.packages{
fill: inherit;
}
.profile .download-chart .bar-chart .bar.packages,
.profile .download-chart .bar-chart text.packages{
.profile .download-chart .bar-chart .bar.packages{
fill: #32887F;
stroke: #32887F;
}
/* Donut charts */
#metadata-chart,
Expand Down
2 changes: 1 addition & 1 deletion src/js/themes/dataone/models/AppModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ define(['jquery', 'underscore', 'backbone'],
this.set('orcidSearchUrl', this.get('orcidBaseUrl') + '/v1.1/search/orcid-bio?q=');

//The package service for v2 DataONE API
this.set('packageServiceUrl', this.get('baseUrl') + this.get('context') + this.get('d1Service') + '/packages/application%2Fbagit-097/');
this.set('packageServiceUrl', this.get('baseUrl') + this.get('d1Service') + '/packages/application%2Fbagit-097/');

//Only use these settings in production
if(this.get("baseUrl").indexOf("search.dataone.org") > -1)
Expand Down
38 changes: 19 additions & 19 deletions src/js/themes/dataone/routers/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,24 @@ function ($, _, Backbone) {

initialize: function(){
this.listenTo(Backbone.history, "routeNotFound", this.navigateToDefault);

// This route handler replaces the route handler we had in the
// routes table before which was "view/*pid". The * only finds URL
// parts until the ? but DataONE PIDs can have ? in them so we need
// to make this route more inclusive.
this.route(/^view\/(.*)$/, "renderMetadata");
//Track the history of hashes
this.on("route", this.trackHash);

//Track the history of pathnames
this.on("route", this.trackPathName);

// Clear stale JSONLD and meta tags
this.on("route", this.clearJSONLD);
this.on("route", this.clearHighwirePressMetaTags);
},

//Keep track of navigation movements
routeHistory: new Array(),
hashHistory: new Array(),
pathHistory: new Array(),

// Will return the last route, which is actually the second to last item in the route history,
// since the last item is the route being currently viewed
Expand All @@ -58,21 +58,21 @@ function ($, _, Backbone) {
return this.routeHistory[this.routeHistory.length-2];
},

trackHash: function(e){
if(_.last(this.hashHistory) != window.location.hash)
this.hashHistory.push(window.location.hash);
trackPathName: function(e){
if(_.last(this.pathHistory) != window.location.pathname)
this.pathHistory.push(window.location.pathname);
},

//If the user or app cancelled the last route, call this function to revert the window location hash back to the correct value
//If the user or app cancelled the last route, call this function to revert the window location pathname back to the correct value
undoLastRoute: function(){
this.routeHistory.pop();

//Remove the last route and hash from the history
if(_.last(this.hashHistory) == window.location.hash)
this.hashHistory.pop();
//Remove the last route and pathname from the history
if(_.last(this.pathHistory) == window.location.pathname)
this.pathHistory.pop();

//Change the hash in the window location back
this.navigate(_.last(this.hashHistory), {replace: true});
//Change the pathname in the window location back
this.navigate(_.last(this.pathHistory), {replace: true});
},

renderMdqRun: function (suiteId, pid) {
Expand Down Expand Up @@ -144,9 +144,9 @@ function ($, _, Backbone) {

//Check for a query URL parameter
if((typeof query !== "undefined") && query){
var customQuery = appSearchModel.get('additionalCriteria');
var customQuery = MetacatUI.appSearchModel.get('additionalCriteria');
customQuery.push(query);
appSearchModel.set('additionalCriteria', customQuery);
MetacatUI.appSearchModel.set('additionalCriteria', customQuery);
}

if(!MetacatUI.appView.dataCatalogView){
Expand Down Expand Up @@ -210,7 +210,7 @@ function ($, _, Backbone) {
renderMetadata: function (pid) {
this.routeHistory.push("metadata");
MetacatUI.appModel.set('lastPid', MetacatUI.appModel.get("pid"));

var seriesId;

//Check for a seriesId
Expand Down Expand Up @@ -281,7 +281,7 @@ function ($, _, Backbone) {
MetacatUI.appView.showView(MetacatUI.appView.userView, viewOptions);
}
},

renderMyProfile: function(section, subsection){
if(MetacatUI.appUserModel.get("checked") && !MetacatUI.appUserModel.get("loggedIn"))
this.renderTokenSignIn();
Expand Down
2 changes: 1 addition & 1 deletion src/js/themes/dataone/templates/resultsItem.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<% } %>
<div class="resource-map icons stop-route">
<% if (resourceMap) {
print('<img src="js/themes/dataone/img/data-file-icon-magenta-desat.png" class="icon tooltip-this stop-route" data-toggle="tooltip" data-placement="top" title="This data set includes data files"></i>');
print('<img src="' + MetacatUI.root + '/js/themes/dataone/img/data-file-icon-magenta-desat.png" class="icon tooltip-this stop-route" data-toggle="tooltip" data-placement="top" title="This data set includes data files"></i>');
} %>

</div>
Expand Down
27 changes: 14 additions & 13 deletions src/js/themes/goa/routers/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,23 @@ function ($, _, Backbone) {
MetacatUI.appModel.set('ldapwebServiceUrl', 'https://knb.ecoinformatics.org/knb/cgi-bin/ldapweb.cgi');

this.listenTo(Backbone.history, "routeNotFound", this.navigateToDefault);

// This route handler replaces the route handler we had in the
// routes table before which was "view/*pid". The * only finds URL
// parts until the ? but DataONE PIDs can have ? in them so we need
// to make this route more inclusive.
this.route(/^view\/(.*)$/, "renderMetadata");

this.on("route", this.trackHash);
this.on("route", this.trackPathName);

// Clear stale JSONLD and meta tags
this.on("route", this.clearJSONLD);
this.on("route", this.clearHighwirePressMetaTags);
},

//Keep track of navigation movements
routeHistory: new Array(),
hashHistory: new Array(),
pathHistory: new Array(),

// Will return the last route, which is actually the second to last item in the route history,
// since the last item is the route being currently viewed
Expand All @@ -61,21 +61,22 @@ function ($, _, Backbone) {
return this.routeHistory[this.routeHistory.length-2];
},

trackHash: function(e){
if(_.last(this.hashHistory) != window.location.hash)
this.hashHistory.push(window.location.hash);
trackPathName: function(e){
if(_.last(this.pathHistory) != window.location.pathname)
this.pathHistory.push(window.location.pathname);
},

//If the user or app cancelled the last route, call this function to revert the window location hash back to the correct value
//If the user or app cancelled the last route, call this function to revert
// the window location pathname back to the correct value
undoLastRoute: function(){
this.routeHistory.pop();

Remove the last route and hash from the history
if(_.last(this.hashHistory) == window.location.hash)
this.hashHistory.pop();
Remove the last route and pathname from the history
if(_.last(this.pathHistory) == window.location.pathname)
this.pathHistory.pop();

//Change the hash in the window location back
this.navigate(_.last(this.hashHistory), {replace: true});
//Change the pathname in the window location back
this.navigate(_.last(this.pathHistory), {replace: true});
},

renderText: function(options){
Expand Down
Loading

0 comments on commit 518afc2

Please sign in to comment.