Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INSPIRE / Validation / Add API usage #7284

Merged
merged 1 commit into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2596,6 +2596,41 @@
}
]);

module.directive("gnInspireUsageDetails", [
"$http",
function ($http) {
return {
restrict: "A",
replace: true,
scope: {
inspireApiUrl: "=gnInspireUsageDetails",
inspireApiKey: "=apiKey"
},
templateUrl: "../../catalog/components/utility/partials/inspireapiusage.html",
link: function (scope, element, attrs) {
scope.inspireApiUsage = undefined;
if (
scope.inspireApiUrl &&
scope.inspireApiUrl.length > 0 &&
scope.inspireApiKey &&
scope.inspireApiKey.length > 0
josegar74 marked this conversation as resolved.
Show resolved Hide resolved
) {
$http
.get(scope.inspireApiUrl + "/v2/Usages/" + scope.inspireApiKey + "/")
.then(
function (response) {
scope.inspireApiUsage = response.data;
},
function (error) {
console.warn("Error while retrieving INSPIRE API quotas: ", error);
}
);
}
}
};
}
]);

module.directive("gnSuggest", [
"gnMetadataManager",
function (gnMetadataManager) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div data-ng-show="inspireApiUsage">
<span data-translate="">inspireApiQuotaCurrentValue</span><br />
<span data-ng-if="!inspireApiUsage.body.items">{{inspireApiUsage.body}}</span>

<ul data-ng-if="inspireApiUsage.body.items">
<li data-ng-repeat="date in inspireApiUsage.body.items">
<span>{{date.date}}:</span>
<span data-translate="">inspireApiQuotaValidation</span>
<span>{{date.uses}}</span>
<span> / </span>
<span data-translate="">inspireApiQuotaRemaining</span>
<span>{{date.remaining_uses}}</span>
</li>
</ul>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@
$scope.settings = data;
angular.copy(data, $scope.initalSettings);

$scope.inspireApiUrl = undefined;
$scope.inspireApiKey = undefined;

for (var i = 0; i < $scope.settings.length; i++) {
if ($scope.settings[i].name == "metadata/workflow/enable") {
$scope.workflowEnable = $scope.settings[i].value == "true";
Expand All @@ -236,9 +239,19 @@
) {
$scope.isGroupPublicationNotificationLevel =
$scope.settings[i].value === "recordGroupEmail";
} else if ("system/localrating/notificationLevel") {
} else if (
$scope.settings[i].name == "system/localrating/notificationLevel"
) {
$scope.isGroupLocalRatingNotificationLevel =
$scope.settings[i].value === "recordGroupEmail";
} else if (
$scope.settings[i].name == "system/inspire/remotevalidation/url"
) {
$scope.inspireApiUrl = $scope.settings[i].value;
} else if (
$scope.settings[i].name == "system/inspire/remotevalidation/apikey"
) {
$scope.inspireApiKey = $scope.settings[i].value;
}

var tokens = $scope.settings[i].name.split("/");
Expand Down
3 changes: 3 additions & 0 deletions web-ui/src/main/resources/catalog/locales/en-v4.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@
"valid_inspire-0": "Invalid",
"valid_inspire-3": "No rule applies",
"valid_inspire--1": "Unknown",
"inspireApiQuotaCurrentValue": "JRC INSPIRE validator API usage information",
"inspireApiQuotaValidation": "Number of validation:",
"inspireApiQuotaRemaining": "Remaining:",
"facet-OrgForResource": "Organizations",
"facet-sourceCatalogue": "Catalogues",
"facet-groupOwner": "Record groups",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -626,27 +626,32 @@ <h4 class="modal-title" data-translate="">
/>
</div>

<div
class="input-group"
data-ng-switch-when="system/inspire/remotevalidation/url"
>
<input
type="text"
class="form-control"
id="{{s['name']}}"
name="{{s.name}}"
value="{{s.value}}"
placeholder="{{'system/inspire/remotevalidation/url-placeholder' | translate}}"
/>
<span class="input-group-btn">
<div
class="btn btn-default"
onClick="document.getElementById('system/inspire/remotevalidation/url').value = 'https://inspire.ec.europa.eu/validator/';"
data-translate=""
>
validatorUseInspireOne
</div>
</span>
<div data-ng-switch-when="system/inspire/remotevalidation/url">
<div class="input-group">
<input
type="text"
class="form-control"
id="{{s['name']}}"
name="{{s.name}}"
value="{{s.value}}"
placeholder="{{'system/inspire/remotevalidation/url-placeholder' | translate}}"
/>
<span class="input-group-btn">
<div
class="btn btn-default"
onClick="document.getElementById('system/inspire/remotevalidation/url').value = 'https://inspire.ec.europa.eu/validator/';"
data-translate=""
>
validatorUseInspireOne
</div>
</span>
</div>
<br />
<div
class="alert alert-info"
data-gn-inspire-usage-details="inspireApiUrl"
data-api-key="inspireApiKey"
></div>
</div>

<div
Expand Down
Loading