Skip to content

Instantly share code, notes, and snippets.

@jsicot
Created May 15, 2020 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsicot/df94d3d4ed73fab815398324ffd41492 to your computer and use it in GitHub Desktop.
Save jsicot/df94d3d4ed73fab815398324ffd41492 to your computer and use it in GitHub Desktop.
intégration istex dans primo
(function() {
"use strict";
'use strict';
var app = angular.module('viewCustom', ['angularLoad']);
app.config(['$sceDelegateProvider', function($sceDelegateProvider) {
var urlWhitelist = $sceDelegateProvider.resourceUrlWhitelist();
urlWhitelist.push('https://api.istex.fr/document/openurl**');
$sceDelegateProvider.resourceUrlWhitelist(urlWhitelist);
}]);
app.component('prmViewOnlineAfter', {
bindings: { parentCtrl: '<' },
controller: ['$scope', '$http', '$element', function controller($scope, $http, $element) {
this.$onInit = function() {
var obj = $scope.$ctrl.parentCtrl.item.linkElement.links[0];
console.log(obj);
if (obj.hasOwnProperty("getItTabText") && obj.hasOwnProperty("displayText") && obj.hasOwnProperty("isLinktoOnline") && obj.hasOwnProperty("link")) {
if (obj['displayText'] == "openurlfulltext") {
$scope.istexloading = true;
// console.log(obj);
// console.log(obj['link']);
var openurl = obj['link'];
var openurlSvc = openurl.replace("http://acceder.bu.univ-rennes2.fr/sfx_33puedb", "https://api.istex.fr/document/openurl");
openurlSvc = openurlSvc + "&noredirect";
console.log(openurlSvc);
$http({
method: 'GET',
url: openurlSvc,
headers: {
'Content-Type': 'application/json',
'X-From-ExL-API-Gateway': undefined
},
cache: true,
}).then(function(response) {
console.log(response);
$scope.istexloading = false;
var istex = response.data;
if (istex.resourceUrl !== null && istex.code != "404") {
$scope.istex = istex;
}
}).catch(function(err) {
$scope.istexloading = false;
console.log(err);
});
}
}
};
}],
template: '<prm-spinner class="inline-loader display-inline dark-on-light half-transparent" ng-if="istexloading"></prm-spinner>\
<span ng-if="istex" class="bold-text">Également disponibile sur :</span>\
<md-list ng-if="istex" class="separate-list-items margin-left-medium">\
<md-list-item class="md-2-line _md-no-proxy _md">\
<a class="neutralized-button layout-full-width layout-display-flex md-button md-ink-ripple layout-row" tabindex="0" layout="flex" href="{{istex.resourceUrl}}" target="_blank" md-ink-ripple="red" role="button">\
<div layout="row" flex="100" layout-align="space-between center" class="layout-align-space-between-center layout-row flex-100">\
<div class="md-list-item-text layout-wrap layout-row flex" layout="row" layout-wrap="" flex="">\
<div flex="" flex-xs="100" class="flex-xs-100 flex">\
<h3>Istex</h3>\
<p><span class="availability-status available">Accès</span></p>\
</div>\
<div layout-align="end center" layout="row" layout-wrap="" flex-xs="100" flex-sm="10" flex="" class="list-item-actions layout-wrap layout-align-end-center layout-row flex-xs-100 flex-sm-10 flex-10"></div>\
</div>\
<prm-icon class="padding-right-small" icon-type="svg" svg-icon-set="action" icon-definition="ic_open_in_new_24px"></prm-icon-after></prm-icon>\
</div>\
<div class="md-ripple-container" style=""></div>\
</a>\
</md-list-item>\
</md-list>'
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment