2022-07-13 19:25:19 +02:00
|
|
|
import {Component, Input, OnDestroy, OnInit, ViewChild} from '@angular/core';
|
2017-12-19 13:53:46 +01:00
|
|
|
import {Location} from '@angular/common';
|
|
|
|
import {ActivatedRoute, Router} from '@angular/router';
|
2020-11-11 15:43:13 +01:00
|
|
|
import {Subject, Subscriber} from 'rxjs';
|
2019-09-13 09:01:19 +02:00
|
|
|
import {debounceTime, distinctUntilChanged} from 'rxjs/operators';
|
2017-12-19 13:53:46 +01:00
|
|
|
import {ClaimsService} from '../service/claims.service';
|
2022-06-30 12:40:37 +02:00
|
|
|
import {User} from '../../../login/utils/helper.class';
|
2019-07-23 14:23:12 +02:00
|
|
|
import {EnvProperties} from '../../../utils/properties/env-properties';
|
|
|
|
import {SEOService} from '../../../sharedComponents/SEO/SEO.service';
|
2021-02-10 11:24:52 +01:00
|
|
|
import {IndexInfoService} from '../../../utils/indexInfo.service';
|
|
|
|
import {ClaimDBRecord} from '../claimHelper.class';
|
|
|
|
import {Dates} from '../../../utils/string-utils.class';
|
|
|
|
import {HelperService} from '../../../utils/helper/helper.service';
|
|
|
|
import {Meta, Title} from '@angular/platform-browser';
|
|
|
|
import {PiwikService} from '../../../utils/piwik/piwik.service';
|
|
|
|
import {properties} from '../../../../../environments/environment';
|
2022-06-30 12:40:37 +02:00
|
|
|
import {FormBuilder, FormGroup} from '@angular/forms';
|
2021-02-10 11:24:52 +01:00
|
|
|
import {Option} from '../../../sharedComponents/input/input.component';
|
2022-05-10 16:28:50 +02:00
|
|
|
import {OpenaireEntities} from "../../../utils/properties/searchFields";
|
2022-06-27 11:00:30 +02:00
|
|
|
import {HelperFunctions} from "../../../utils/HelperFunctions.class";
|
2022-06-30 12:40:37 +02:00
|
|
|
import {NotificationHandler} from "../../../utils/notification-handler";
|
|
|
|
import {DropdownFilterComponent} from "../../../utils/dropdown-filter/dropdown-filter.component";
|
2021-02-10 11:24:52 +01:00
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
@Component({
|
2019-07-23 14:23:12 +02:00
|
|
|
selector: 'displayClaims',
|
|
|
|
templateUrl: 'displayClaims.component.html',
|
2022-07-05 15:41:11 +02:00
|
|
|
styleUrls: ['displayClaims.component.less']
|
2017-12-19 13:53:46 +01:00
|
|
|
})
|
2022-07-13 19:25:19 +02:00
|
|
|
export class DisplayClaimsComponent implements OnInit, OnDestroy {
|
2021-04-19 18:28:36 +02:00
|
|
|
@Input() pageTitle: string = "";
|
2019-07-23 14:23:12 +02:00
|
|
|
properties: EnvProperties;
|
2018-06-29 13:01:48 +02:00
|
|
|
public searchTermStream = new Subject<string>();
|
2020-11-11 15:43:13 +01:00
|
|
|
subscriptions: any = [];
|
2021-03-24 11:00:30 +01:00
|
|
|
public subResults: any;
|
2017-12-19 13:53:46 +01:00
|
|
|
//string because comes as input from component directive
|
|
|
|
@Input() enableDelete: boolean = false;
|
|
|
|
@Input() showUserEmail: boolean = true;
|
2019-07-23 14:23:12 +02:00
|
|
|
@Input() myClaims: boolean = false;
|
|
|
|
@Input() isAdmin: boolean = false;
|
2019-09-13 09:01:19 +02:00
|
|
|
page: number = 1;
|
2021-02-10 11:24:52 +01:00
|
|
|
size: number = 50;
|
2019-07-23 14:23:12 +02:00
|
|
|
keyword: string; // the keyword string to give to the request as parameter
|
|
|
|
types = ["All", "Project", "Context", "Result", "User"];
|
2022-06-30 12:40:37 +02:00
|
|
|
loading: boolean = false;
|
2019-07-23 14:23:12 +02:00
|
|
|
@Input() fetchBy: string;
|
|
|
|
@Input() fetchId: string;
|
2019-09-13 09:01:19 +02:00
|
|
|
@Input() user: User;
|
2022-06-30 12:40:37 +02:00
|
|
|
resultsNum: number = 0;
|
2019-07-23 14:23:12 +02:00
|
|
|
claims: ClaimDBRecord[];
|
|
|
|
@Input() externalPortalUrl: string = null;
|
|
|
|
@Input() claimsInfoURL: string;// ="https://www.openaire.eu/linking";
|
|
|
|
lastIndexDate = null;
|
2021-02-10 11:24:52 +01:00
|
|
|
public filterForm: FormGroup;
|
2022-06-30 12:40:37 +02:00
|
|
|
public entities: string[] = [];
|
2024-03-28 12:07:11 +01:00
|
|
|
selected = [];
|
2022-06-30 12:40:37 +02:00
|
|
|
|
|
|
|
allOptions: Option[] = [
|
|
|
|
{label: OpenaireEntities.PUBLICATIONS, value: "publication"},
|
|
|
|
{label: OpenaireEntities.DATASETS, value: "dataset"},
|
|
|
|
{label: OpenaireEntities.SOFTWARE, value: "software"},
|
|
|
|
{label: OpenaireEntities.OTHER, value: "other"},
|
|
|
|
{label: OpenaireEntities.PROJECTS, value: "project"},
|
|
|
|
{label: OpenaireEntities.COMMUNITIES, value: "context"}];
|
|
|
|
|
2021-02-10 11:24:52 +01:00
|
|
|
sortOptions: Option[] = [
|
2022-06-30 12:40:37 +02:00
|
|
|
{label: "Date (recent) ", value: {sort: "date", descending: true}},
|
|
|
|
{label: "Date (oldest) ", value: {sort: "date", descending: false}},
|
|
|
|
{label: "Title (desc) ", value: {sort: "target", descending: true}},
|
|
|
|
{label: "Title (asc) ", value: {sort: "target", descending: false}},
|
2021-02-10 11:24:52 +01:00
|
|
|
];
|
2019-07-23 14:23:12 +02:00
|
|
|
entityTypes: string[] = [];
|
2022-06-30 12:40:37 +02:00
|
|
|
index: number;
|
2017-12-19 13:53:46 +01:00
|
|
|
params;
|
2022-06-30 12:40:37 +02:00
|
|
|
@ViewChild("deleteModal") deleteModal;
|
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
claimsDeleted: number = 0;
|
|
|
|
@Input() communityId: string = null;
|
2022-06-30 12:40:37 +02:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
url = null;
|
2019-07-24 17:46:49 +02:00
|
|
|
public pageContents = null;
|
2022-06-30 12:40:37 +02:00
|
|
|
|
2022-07-13 19:25:19 +02:00
|
|
|
/* Sticky actions */
|
|
|
|
@Input()
|
|
|
|
public actions: boolean = false;
|
|
|
|
public offset: number;
|
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
constructor(private _claimService: ClaimsService, private route: ActivatedRoute, private _router: Router, private location: Location,
|
2019-09-13 09:01:19 +02:00
|
|
|
private _meta: Meta, private _title: Title, private _piwikService: PiwikService,
|
2021-02-10 11:24:52 +01:00
|
|
|
private seoService: SEOService, private indexInfoService: IndexInfoService, private helper: HelperService, private _fb: FormBuilder) {
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
2022-06-30 12:40:37 +02:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
ngOnInit() {
|
2022-07-13 19:25:19 +02:00
|
|
|
if (typeof document !== "undefined" && this.actions) {
|
2022-07-17 15:01:39 +02:00
|
|
|
this.offset = Number.parseInt(getComputedStyle(document.documentElement).getPropertyValue('--header-height'));
|
2022-07-13 19:25:19 +02:00
|
|
|
}
|
2022-06-30 12:40:37 +02:00
|
|
|
this.entities = [];
|
2021-02-10 11:24:52 +01:00
|
|
|
this.filterForm = this._fb.group({
|
|
|
|
keyword: [''],
|
2022-06-30 12:40:37 +02:00
|
|
|
entities: this._fb.control(this.entities),
|
2021-02-10 11:24:52 +01:00
|
|
|
sort: this._fb.control(this.sortOptions[0].value)
|
|
|
|
});
|
2022-06-30 12:40:37 +02:00
|
|
|
|
2021-02-10 11:24:52 +01:00
|
|
|
this.properties = properties;
|
|
|
|
this.url = properties.domain + properties.baseLink + this._router.url;
|
2022-06-30 12:40:37 +02:00
|
|
|
if (!this.myClaims) {
|
|
|
|
this.sortOptions.push({label: "User (desc) ", value: {sort: "user", descending: true}});
|
|
|
|
this.sortOptions.push({label: "User (asc) ", value: {sort: "user", descending: false}})
|
2021-02-10 11:24:52 +01:00
|
|
|
}
|
|
|
|
var description = "Openaire, linking, claim, publication, research data, software, other research product, project, community";
|
2021-04-19 18:28:36 +02:00
|
|
|
this.updateTitle(this.pageTitle);
|
2021-02-10 11:24:52 +01:00
|
|
|
this.updateDescription(description);
|
|
|
|
this.updateUrl(this.url);
|
2023-07-12 14:05:25 +02:00
|
|
|
this.subscriptions.push(this._piwikService.trackView(this.properties, this.pageTitle).subscribe());
|
2024-02-08 13:19:26 +01:00
|
|
|
|
|
|
|
if(properties.adminToolsPortalType !== "explore") {
|
|
|
|
this.subscriptions.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
|
|
|
|
this.pageContents = contents;
|
|
|
|
}));
|
|
|
|
}
|
2021-02-10 11:24:52 +01:00
|
|
|
this.subscriptions.push(this.indexInfoService.getLastIndexDate(this.properties).subscribe(res => {
|
|
|
|
this.lastIndexDate = res;
|
|
|
|
}));
|
|
|
|
this.subscriptions.push(this.route.queryParams.subscribe(params => {
|
|
|
|
this.seoService.createLinkForCanonicalURL(this.url, false);
|
2022-06-30 12:40:37 +02:00
|
|
|
|
2021-02-10 11:24:52 +01:00
|
|
|
if (this.myClaims) {
|
|
|
|
this.fetchBy = "User";
|
|
|
|
this.fetchId = this.user.email;
|
|
|
|
} else {
|
|
|
|
this.fetchBy = (this.fetchBy) ? this.fetchBy : params['fetchBy'];
|
|
|
|
this.fetchBy = (this.types.indexOf(this.fetchBy) != -1) ? this.fetchBy : 'All';
|
|
|
|
this.fetchId = (this.fetchId) ? this.fetchId : params['fetchId'];
|
|
|
|
this.fetchId = this.fetchId ? this.fetchId : '';
|
|
|
|
}
|
|
|
|
let page = (params['page'] === undefined) ? 1 : +params['page'];
|
|
|
|
this.keyword = (params['keyword'] ? params['keyword'] : "");
|
2021-03-18 09:51:09 +01:00
|
|
|
this.filterForm.get('keyword').setValue(this.keyword);
|
2021-02-10 11:24:52 +01:00
|
|
|
this.page = (page <= 0) ? 1 : page;
|
|
|
|
this.entityTypes = [];//(params['types']?params['types']:[]);
|
2022-05-10 16:28:50 +02:00
|
|
|
this.setTypes(params['types']); // check the appropriate checkboxes
|
2022-06-30 12:40:37 +02:00
|
|
|
this.setSortBy(params['sort']);
|
2021-02-10 11:24:52 +01:00
|
|
|
this.getClaims();
|
|
|
|
this.subscriptions.push(this.searchTermStream
|
|
|
|
.pipe(debounceTime(300), distinctUntilChanged())
|
|
|
|
.subscribe((term: string) => {
|
|
|
|
this.keyword = term;
|
|
|
|
this.page = 1;
|
|
|
|
this.goTo();
|
2020-11-11 15:43:13 +01:00
|
|
|
}));
|
2021-02-10 11:24:52 +01:00
|
|
|
this.subscriptions.push(this.filterForm.get('entities').valueChanges.subscribe(value => {
|
|
|
|
this.goTo();
|
|
|
|
}));
|
|
|
|
this.subscriptions.push(this.filterForm.get('sort').valueChanges.subscribe(value => {
|
|
|
|
this.goTo();
|
|
|
|
}));
|
|
|
|
}));
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
2022-06-30 12:40:37 +02:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
ngOnDestroy() {
|
2020-11-11 15:43:13 +01:00
|
|
|
this.subscriptions.forEach(subscription => {
|
|
|
|
if (subscription instanceof Subscriber) {
|
|
|
|
subscription.unsubscribe();
|
|
|
|
}
|
|
|
|
});
|
2022-06-30 12:40:37 +02:00
|
|
|
if (this.subResults) {
|
2021-03-24 11:00:30 +01:00
|
|
|
this.subResults.unsubscribe();
|
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
2022-06-30 12:40:37 +02:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
getClaims() {
|
2022-06-30 12:40:37 +02:00
|
|
|
let types = '';
|
|
|
|
for (let type of this.entities) {
|
|
|
|
types += (types.length > 0 ? '&' : '') + "types=" + type;
|
|
|
|
}
|
|
|
|
this.loading = true;
|
|
|
|
if (this.subResults) {
|
|
|
|
this.subResults.unsubscribe();
|
|
|
|
}
|
|
|
|
if (this.fetchBy == "Project") {
|
|
|
|
this.subResults = this._claimService.getClaimsByProject(this.size, this.page, this.fetchId, this.keyword, this.filterForm.get("sort").value.sort, this.filterForm.get("sort").value.descending, types, this.properties.claimsAPIURL).subscribe(
|
|
|
|
data => {
|
|
|
|
this.manageAPIData(data);
|
|
|
|
this.loading = false;
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.handleErrors(err, "Error getting claims for project with id: " + this.fetchId);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} else if (this.fetchBy == "User") {
|
|
|
|
this.subResults = this._claimService.getClaimsByUser(this.size, this.page, this.fetchId, this.keyword, this.filterForm.get("sort").value.sort, this.filterForm.get("sort").value.descending, types, this.properties.claimsAPIURL).subscribe(
|
|
|
|
data => {
|
|
|
|
this.manageAPIData(data);
|
|
|
|
this.loading = false;
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.handleErrors(err, "Error getting claims for user with id: " + this.fetchId);
|
|
|
|
this.loading = false;
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2022-06-30 12:40:37 +02:00
|
|
|
);
|
|
|
|
} else if (this.fetchBy == "Result") {
|
|
|
|
this.subResults = this._claimService.getClaimsByResult(this.size, this.page, this.fetchId, this.keyword, this.filterForm.get("sort").value.sort, this.filterForm.get("sort").value.descending, types, this.properties.claimsAPIURL).subscribe(
|
|
|
|
data => {
|
|
|
|
this.manageAPIData(data);
|
|
|
|
this.loading = false;
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.handleErrors(err, "Error getting claims for entity with id: " + this.fetchId);
|
|
|
|
this.loading = false;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} else if (this.fetchBy == "Context") {
|
|
|
|
this.subResults = this._claimService.getClaimsBycontext(this.size, this.page, this.fetchId, this.keyword, this.filterForm.get("sort").value.sort, this.filterForm.get("sort").value.descending, types, this.properties.claimsAPIURL).subscribe(
|
|
|
|
data => {
|
|
|
|
this.manageAPIData(data);
|
|
|
|
this.loading = false;
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.handleErrors(err, "Error getting claims for context with id: " + this.fetchId);
|
|
|
|
this.loading = false;
|
|
|
|
}
|
|
|
|
);
|
2019-07-23 14:23:12 +02:00
|
|
|
} else {
|
2022-06-30 12:40:37 +02:00
|
|
|
this.subResults = this._claimService.getClaims(this.size, this.page, this.keyword, this.filterForm.get("sort").value.sort, this.filterForm.get("sort").value.descending, types, this.properties.claimsAPIURL).subscribe(
|
|
|
|
data => {
|
|
|
|
this.manageAPIData(data);
|
|
|
|
this.loading = false;
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.handleErrors(err, "Error getting claims");
|
|
|
|
this.loading = false;
|
|
|
|
}
|
|
|
|
);
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
}
|
2022-06-30 12:40:37 +02:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
manageAPIData(data) {
|
|
|
|
this.claims = data.data;
|
2022-06-30 12:40:37 +02:00
|
|
|
this.resultsNum = +data.total;
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
2022-06-30 12:40:37 +02:00
|
|
|
|
2020-03-26 13:18:18 +01:00
|
|
|
handleErrors(err, message) {
|
2022-06-30 12:40:37 +02:00
|
|
|
NotificationHandler.rise(message, "danger");
|
2023-04-10 10:51:18 +02:00
|
|
|
console.error("Display Claims (component): " + message + " " + (err && err.error ? err.error : ''));
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
2022-06-30 12:40:37 +02:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
goTo(page: number = 1) {
|
2017-12-19 13:53:46 +01:00
|
|
|
this.page = page;
|
2019-07-23 14:23:12 +02:00
|
|
|
this.location.go(location.pathname, this.getParametersString());
|
2022-06-27 11:00:30 +02:00
|
|
|
HelperFunctions.scroll();
|
2017-12-19 13:53:46 +01:00
|
|
|
this.getClaims();
|
|
|
|
}
|
2022-06-30 12:40:37 +02:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
getParametersString() {
|
|
|
|
let params = '';
|
|
|
|
params += (this.page == 1 ? "" : (params.length > 0 ? '&' : '') + "page=" + this.page);
|
|
|
|
params += (this.size == 10 ? "" : (params.length > 0 ? '&' : '') + "size=" + this.size);
|
|
|
|
let types = "";
|
2022-06-30 12:40:37 +02:00
|
|
|
for (let type of this.entities) {
|
2022-05-10 16:28:50 +02:00
|
|
|
types += (types.length > 0 ? ',' : '') + type;
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
2022-06-30 12:40:37 +02:00
|
|
|
params += (this.entities.length > 0) ? (params.length > 0 ? '&' : '') + "types=" + types : "";
|
2019-07-23 14:23:12 +02:00
|
|
|
if (this.isAdmin) {
|
|
|
|
params += (this.fetchBy == 'All' ? "" : (params.length > 0 ? '&' : '') + "fetchBy=" + this.fetchBy);
|
|
|
|
params += (this.fetchId == '' ? "" : (params.length > 0 ? '&' : '') + "fetchId=" + this.fetchId);
|
|
|
|
}
|
2022-06-30 12:40:37 +02:00
|
|
|
params += (this.filterForm.get("sort").value.sort == 'date' && this.filterForm.get("sort").value.descending ? "" : (params.length > 0 ? '&' : '') + "sort=" + this.filterForm.get("sort").value.sort + "-" + this.filterForm.get("sort").value.descending);
|
2019-07-23 14:23:12 +02:00
|
|
|
params += (this.keyword == '' ? "" : (params.length > 0 ? '&' : '') + "keyword=" + this.keyword);
|
|
|
|
if (this.communityId != null) {
|
|
|
|
params += "&communityId=" + this.communityId;
|
|
|
|
}
|
|
|
|
return params;
|
|
|
|
}
|
2022-06-30 12:40:37 +02:00
|
|
|
|
|
|
|
setSortBy(sortby: string) {
|
2021-02-10 11:24:52 +01:00
|
|
|
let sort = "date";
|
|
|
|
let desc = "desc";
|
2022-06-30 12:40:37 +02:00
|
|
|
if (sortby && sortby.split("-").length == 2) {
|
2021-02-10 11:24:52 +01:00
|
|
|
sort = sortby.split("-")[0];
|
|
|
|
desc = sortby.split("-")[1];
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
2022-06-30 12:40:37 +02:00
|
|
|
|
|
|
|
let option = this.sortOptions.find(option => option.value.sort == sort && ((option.value.descending && desc == "desc") || (!option.value.descending && desc == "asc")));
|
|
|
|
this.filterForm.get("sort").setValue(option ? option.value : this.sortOptions[0].value);
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
2022-06-30 12:40:37 +02:00
|
|
|
|
2022-05-10 16:28:50 +02:00
|
|
|
setTypes(typesParam: string) {
|
2022-06-30 12:40:37 +02:00
|
|
|
for (let type of typesParam ? typesParam.split(',') : []) {
|
|
|
|
this.entities.push(type);
|
2022-05-10 16:28:50 +02:00
|
|
|
}
|
|
|
|
}
|
2022-06-30 12:40:37 +02:00
|
|
|
|
|
|
|
changeKeyword() {
|
2023-04-10 10:51:18 +02:00
|
|
|
if (this.filterForm.get("keyword") && (this.filterForm.get("keyword").value?.length >= 3 || this.filterForm.get("keyword").value?.length == 0)) {
|
2021-02-10 11:24:52 +01:00
|
|
|
this.searchTermStream.next(this.filterForm.get("keyword").value);
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
|
|
|
}
|
2022-06-30 12:40:37 +02:00
|
|
|
|
|
|
|
select(value: string, event, dropdownFilter: DropdownFilterComponent) {
|
|
|
|
if(event.target instanceof HTMLInputElement) {
|
|
|
|
dropdownFilter.closeDropdown();
|
|
|
|
if(event.target.checked && !this.entities.find(entity => value === entity)) {
|
|
|
|
this.entities.push(value);
|
|
|
|
} else if(!event.target.checked) {
|
|
|
|
let index = this.entities.indexOf(value);
|
|
|
|
if(index !== -1) {
|
|
|
|
this.entities.splice(index, 1);
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
2022-06-30 12:40:37 +02:00
|
|
|
this.filterForm.get('entities').setValue(this.entities);
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
2022-06-30 12:40:37 +02:00
|
|
|
|
|
|
|
isSelected(value: string) {
|
2024-03-28 12:07:11 +01:00
|
|
|
return this.filterForm && this.filterForm.get('entities').value.find(entity => entity === value);
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
2022-06-30 12:40:37 +02:00
|
|
|
|
2024-03-28 12:07:11 +01:00
|
|
|
deleteOpen(index: number = null) {
|
2022-06-30 12:40:37 +02:00
|
|
|
this.index = index;
|
|
|
|
this.deleteModal.alertTitle = 'Delete Confirmation';
|
2024-03-28 12:07:11 +01:00
|
|
|
this.deleteModal.message = 'Are you sure you want to delete ' + (this.index != null ? '1' : this.selected.length) + ' link(s)?';
|
2022-06-30 12:40:37 +02:00
|
|
|
this.deleteModal.okButtonText = 'Yes';
|
|
|
|
this.deleteModal.open();
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
2022-06-30 12:40:37 +02:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
delete() {
|
2024-03-28 12:07:11 +01:00
|
|
|
let claimsToBeDeleted = ((this.index != null) ? [this.claims[this.index].id] : this.selected.map(claim => claim.id));
|
|
|
|
console.log(claimsToBeDeleted);
|
|
|
|
this.subscriptions.push(this._claimService.deleteBulk(claimsToBeDeleted, this.properties.claimsAPIURL).subscribe(
|
2022-06-30 12:40:37 +02:00
|
|
|
res => {
|
2024-03-28 12:07:11 +01:00
|
|
|
if (this.index != null) {
|
|
|
|
this.claims.splice(this.index, 1);
|
|
|
|
this.resultsNum = this.resultsNum - 1;
|
|
|
|
NotificationHandler.rise('Link has been deleted successfully');
|
|
|
|
} else {
|
|
|
|
claimsToBeDeleted.forEach(claimId => {
|
|
|
|
this.claims.splice(this.claims.findIndex((id) => id == claimId), 1);
|
|
|
|
});
|
|
|
|
this.resultsNum = this.resultsNum - claimsToBeDeleted.length;
|
|
|
|
NotificationHandler.rise(claimsToBeDeleted.length + ' links have been deleted successfully');
|
|
|
|
}
|
|
|
|
this.selected = [];
|
2022-06-30 12:40:37 +02:00
|
|
|
let goToPage = this.page;
|
|
|
|
if (this.totalPages(this.resultsNum) < this.page && this.page > 0) {
|
|
|
|
goToPage = this.page - 1;
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
2022-06-30 12:40:37 +02:00
|
|
|
this.goTo(goToPage);
|
|
|
|
}, err => {
|
|
|
|
this.handleErrors(err, "Error deleting claim with id: " + this.claims[this.index].id);
|
2024-03-28 12:07:11 +01:00
|
|
|
}
|
|
|
|
));
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
2022-06-30 12:40:37 +02:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
pageChange($event) {
|
|
|
|
let page: number = +$event.value;
|
|
|
|
this.goTo(page);
|
|
|
|
}
|
2022-06-30 12:40:37 +02:00
|
|
|
|
2019-09-13 09:01:19 +02:00
|
|
|
isClaimAvailable(claim: ClaimDBRecord): boolean {
|
|
|
|
//claim.target.collectedFrom == "infrastruct_::openaire" &&
|
|
|
|
let lastUpdateDate = new Date((this.lastIndexDate != null) ? this.lastIndexDate : this.properties.lastIndexUpdate);
|
2019-07-23 14:23:12 +02:00
|
|
|
let lastUpdateDateStr = Dates.getDateToString(lastUpdateDate);
|
2019-09-13 09:01:19 +02:00
|
|
|
let claimDate = new Date(claim.date);
|
2019-07-23 14:23:12 +02:00
|
|
|
let claimDateStr = Dates.getDateToString(claimDate);
|
2019-09-13 09:01:19 +02:00
|
|
|
if (claimDateStr < lastUpdateDateStr) {
|
2019-07-23 14:23:12 +02:00
|
|
|
return true;
|
|
|
|
} else {
|
2022-06-30 12:40:37 +02:00
|
|
|
return claim.target.collectedFrom != "infrastruct_::openaire" && claim.indexed;
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
|
|
|
}
|
2022-06-30 12:40:37 +02:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
totalPages(totalResults: number): number {
|
2019-09-13 09:01:19 +02:00
|
|
|
let totalPages: any = totalResults / (this.size);
|
|
|
|
if (!(Number.isInteger(totalPages))) {
|
2019-07-23 14:23:12 +02:00
|
|
|
totalPages = (parseInt(totalPages, 10) + 1);
|
2018-10-25 11:33:56 +02:00
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
return totalPages;
|
|
|
|
}
|
2024-03-28 12:07:11 +01:00
|
|
|
|
|
|
|
selectClaim(item: any, event) {
|
|
|
|
let value = event.currentTarget.checked;
|
|
|
|
if (value) {
|
|
|
|
this.selected.push(item);
|
|
|
|
} else {
|
|
|
|
for (var _i = 0; _i < this.selected.length; _i++) {
|
|
|
|
let claim = this.selected[_i];
|
|
|
|
if (claim['id'] == item.id) {
|
|
|
|
this.selected.splice(_i, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
selectAll(event) {
|
|
|
|
let value = event.currentTarget.checked;
|
|
|
|
if (value) {
|
|
|
|
this.selected = [];
|
|
|
|
for (let _i = 0; _i < this.claims.length; _i++) {
|
|
|
|
let claim = this.claims[_i];
|
|
|
|
this.selected.push(claim);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.selected = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
isSelectedClaim(id: string) {
|
|
|
|
for (let _i = 0; _i < this.selected.length; _i++) {
|
|
|
|
let claim = this.selected[_i];
|
|
|
|
if (claim['id'] == id) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-09-13 09:01:19 +02:00
|
|
|
private updateDescription(description: string) {
|
|
|
|
this._meta.updateTag({content: description}, "name='description'");
|
|
|
|
this._meta.updateTag({content: description}, "property='og:description'");
|
2019-08-02 16:55:32 +02:00
|
|
|
}
|
2022-06-30 12:40:37 +02:00
|
|
|
|
2019-09-13 09:01:19 +02:00
|
|
|
private updateTitle(title: string) {
|
|
|
|
var _prefix = "";
|
|
|
|
if (!this.communityId) {
|
|
|
|
_prefix = "OpenAIRE | ";
|
2019-08-02 16:55:32 +02:00
|
|
|
}
|
2019-09-13 09:01:19 +02:00
|
|
|
var _title = _prefix + ((title.length > 50) ? title.substring(0, 50) : title);
|
2022-06-30 12:40:37 +02:00
|
|
|
if (this.myClaims) {
|
2021-03-19 17:51:02 +01:00
|
|
|
this._title.setTitle(_title);
|
|
|
|
}
|
2019-09-13 09:01:19 +02:00
|
|
|
this._meta.updateTag({content: _title}, "property='og:title'");
|
2019-08-02 16:55:32 +02:00
|
|
|
}
|
2022-06-30 12:40:37 +02:00
|
|
|
|
2019-09-13 09:01:19 +02:00
|
|
|
private updateUrl(url: string) {
|
|
|
|
this._meta.updateTag({content: url}, "property='og:url'");
|
2019-08-02 16:55:32 +02:00
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|