[plugins-functionality | WIP] content providers: update methods, add options to select for deposit and add deposition message
This commit is contained in:
parent
49e8e56e92
commit
2a27c1caf7
|
@ -28,6 +28,7 @@ import {AddContentProvidersComponent} from "./add-content-providers.component";
|
||||||
import {ManageCommunityContentProvidersService} from "../../services/manageContentProviders.service";
|
import {ManageCommunityContentProvidersService} from "../../services/manageContentProviders.service";
|
||||||
import {SearchDataprovidersService} from "../../openaireLibrary/services/searchDataproviders.service";
|
import {SearchDataprovidersService} from "../../openaireLibrary/services/searchDataproviders.service";
|
||||||
import {CriteriaModule} from "./criteria/criteria.module";
|
import {CriteriaModule} from "./criteria/criteria.module";
|
||||||
|
import {MatSlideToggleModule} from "@angular/material/slide-toggle";
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -48,7 +49,7 @@ import {CriteriaModule} from "./criteria/criteria.module";
|
||||||
path: '', component: ManageContentProvidersComponent
|
path: '', component: ManageContentProvidersComponent
|
||||||
}
|
}
|
||||||
]),
|
]),
|
||||||
NoLoadPaging, LoadingModule, IconsModule, FullScreenModalModule, ResultPreviewModule, CriteriaModule
|
NoLoadPaging, LoadingModule, IconsModule, FullScreenModalModule, ResultPreviewModule, CriteriaModule, MatSlideToggleModule
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
ManageContentProvidersComponent,
|
ManageContentProvidersComponent,
|
||||||
|
|
|
@ -23,6 +23,7 @@ import {ManageCommunityContentProvidersService} from "../../services/manageConte
|
||||||
[communityContentProviders]="communityContentProviders"
|
[communityContentProviders]="communityContentProviders"
|
||||||
[loading]="showLoadingInRemove" [community]="community"
|
[loading]="showLoadingInRemove" [community]="community"
|
||||||
(editCriteria)="openCriteria($event)"
|
(editCriteria)="openCriteria($event)"
|
||||||
|
(editDepositInfo)="openDeposit($event)"
|
||||||
(communityContentProvidersChanged)="communityContentProvidersChanged($event)">
|
(communityContentProvidersChanged)="communityContentProvidersChanged($event)">
|
||||||
</remove-content-providers>
|
</remove-content-providers>
|
||||||
<fs-modal #addContentProvidersModal>
|
<fs-modal #addContentProvidersModal>
|
||||||
|
@ -44,6 +45,17 @@ import {ManageCommunityContentProvidersService} from "../../services/manageConte
|
||||||
</criteria>
|
</criteria>
|
||||||
</div>
|
</div>
|
||||||
</fs-modal>
|
</fs-modal>
|
||||||
|
<fs-modal #depositModal (okEmitter)="saveDepositInfo()" (cancelEmitter)="depositReset()"
|
||||||
|
[okButtonDisabled]="!dataProvider || (message == dataProvider.message && message!=null && deposit == dataProvider.deposit)">
|
||||||
|
<div class="uk-container uk-container-large">
|
||||||
|
<div class="uk-width-1-1" input placeholder="Type a deposit message for researchers"
|
||||||
|
[value]="message" (valueChange)="message=$event">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<label class="uk-margin-top ">Suggest repository for deposition:</label>
|
||||||
|
<mat-slide-toggle [checked]="deposit" (change)="deposit = !deposit"></mat-slide-toggle>
|
||||||
|
</div>
|
||||||
|
</fs-modal>
|
||||||
`
|
`
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -53,6 +65,7 @@ export class ManageContentProvidersComponent implements OnInit {
|
||||||
@ViewChild('criteria') criteria: CriteriaComponent;
|
@ViewChild('criteria') criteria: CriteriaComponent;
|
||||||
@ViewChild('addContentProvidersModal', { static: true }) addContentProvidersModal: FullScreenModalComponent;
|
@ViewChild('addContentProvidersModal', { static: true }) addContentProvidersModal: FullScreenModalComponent;
|
||||||
@ViewChild('filtersModal', { static: true }) filtersModal: FullScreenModalComponent;
|
@ViewChild('filtersModal', { static: true }) filtersModal: FullScreenModalComponent;
|
||||||
|
@ViewChild('depositModal', { static: true }) depositModal: FullScreenModalComponent;
|
||||||
private subscriptions: any[] = [];
|
private subscriptions: any[] = [];
|
||||||
public showLoadingInRemove: boolean = true;
|
public showLoadingInRemove: boolean = true;
|
||||||
public body: string = "Send from page";
|
public body: string = "Send from page";
|
||||||
|
@ -60,6 +73,8 @@ export class ManageContentProvidersComponent implements OnInit {
|
||||||
public openaireEntities = OpenaireEntities;
|
public openaireEntities = OpenaireEntities;
|
||||||
public community: CommunityInfo;
|
public community: CommunityInfo;
|
||||||
public dataProvider: ContentProvider;
|
public dataProvider: ContentProvider;
|
||||||
|
message = "";
|
||||||
|
deposit= false;
|
||||||
|
|
||||||
constructor(private title: Title,
|
constructor(private title: Title,
|
||||||
private cdr: ChangeDetectorRef,
|
private cdr: ChangeDetectorRef,
|
||||||
|
@ -103,7 +118,17 @@ export class ManageContentProvidersComponent implements OnInit {
|
||||||
this.filtersModal.open();
|
this.filtersModal.open();
|
||||||
this.cdr.detectChanges();
|
this.cdr.detectChanges();
|
||||||
}
|
}
|
||||||
|
public openDeposit(contentProvider: ContentProvider) {
|
||||||
|
this.dataProvider = contentProvider;
|
||||||
|
this.deposit = this.dataProvider.deposit;
|
||||||
|
this.message = this.dataProvider.message;
|
||||||
|
this.depositModal.title = 'Deposit info';
|
||||||
|
this.depositModal.okButtonText = "Save";
|
||||||
|
this.depositModal.back = true;
|
||||||
|
this.depositModal.okButton = true;
|
||||||
|
this.depositModal.open();
|
||||||
|
this.cdr.detectChanges();
|
||||||
|
}
|
||||||
public saveCriteria() {
|
public saveCriteria() {
|
||||||
let callback = (selectionCriteria): void => {
|
let callback = (selectionCriteria): void => {
|
||||||
this.dataProvider.selectioncriteria = selectionCriteria;
|
this.dataProvider.selectioncriteria = selectionCriteria;
|
||||||
|
@ -128,4 +153,21 @@ export class ManageContentProvidersComponent implements OnInit {
|
||||||
this.removeContentProvidersComponent.applyFilters();
|
this.removeContentProvidersComponent.applyFilters();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
saveDepositInfo(){
|
||||||
|
this.dataProvider.deposit = this.deposit;
|
||||||
|
this.dataProvider.message = this.message;
|
||||||
|
console.log(this.message)
|
||||||
|
this.manageCommunityContentProvidersService.saveContentProvider(this.properties, this.dataProvider).subscribe(() => {
|
||||||
|
this.removeContentProvidersComponent.getCommunityContentProviders();
|
||||||
|
NotificationHandler.rise('Deposit info have been <b>successfully updated</b>');
|
||||||
|
}, error => {
|
||||||
|
this.criteria.handeError('An error has been occurred. Try again later!', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
depositReset(){
|
||||||
|
this.message = this.dataProvider.message;
|
||||||
|
this.deposit = this.dataProvider.deposit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,8 @@
|
||||||
<span *ngIf="!item.officialname && !item.name">[no title available]</span>
|
<span *ngIf="!item.officialname && !item.name">[no title available]</span>
|
||||||
</span>
|
</span>
|
||||||
</h6>
|
</h6>
|
||||||
|
<div *ngIf="item.deposit" class="uk-label uk-label-success">Deposit</div>
|
||||||
|
<div *ngIf="item.deposit && item.message" class="">{{item.message}}</div>
|
||||||
<div *ngIf="item.selectioncriteria?.criteria?.length > 0" class="uk-margin-small-bottom uk-text-small">
|
<div *ngIf="item.selectioncriteria?.criteria?.length > 0" class="uk-margin-small-bottom uk-text-small">
|
||||||
<div class="uk-text-meta uk-margin-small-bottom">Filters</div>
|
<div class="uk-text-meta uk-margin-small-bottom">Filters</div>
|
||||||
<div [innerHTML]="criteriaUtils.getFiltersAsText(item.selectioncriteria.criteria)"></div>
|
<div [innerHTML]="criteriaUtils.getFiltersAsText(item.selectioncriteria.criteria)"></div>
|
||||||
|
@ -64,6 +66,22 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="uk-card-footer uk-padding-remove-vertical">
|
<div class="uk-card-footer uk-padding-remove-vertical">
|
||||||
<div class="uk-grid uk-grid-small uk-flex-nowrap uk-grid-divider uk-flex-right" uk-grid>
|
<div class="uk-grid uk-grid-small uk-flex-nowrap uk-grid-divider uk-flex-right" uk-grid>
|
||||||
|
<div>
|
||||||
|
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||||
|
<a (click)="openDeposit(item)" class="uk-button uk-button-link uk-flex uk-flex-middle">
|
||||||
|
<icon name="filters" [flex]="true"></icon>
|
||||||
|
<span *ngIf="item.deposit" class="uk-margin-small-left"
|
||||||
|
uk-tooltip="<div>Manage deposit info.</div>">
|
||||||
|
|
||||||
|
Edit deposit info
|
||||||
|
</span>
|
||||||
|
<span *ngIf="!(item.deposit)" class="uk-margin-small-left"
|
||||||
|
uk-tooltip="<div>Add as a suggested repository to deposit.</div>">
|
||||||
|
Add in deposit
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="uk-padding-small uk-padding-remove-horizontal">
|
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||||
<a (click)="openCriteria(item)" class="uk-button uk-button-link uk-flex uk-flex-middle">
|
<a (click)="openCriteria(item)" class="uk-button uk-button-link uk-flex uk-flex-middle">
|
||||||
|
|
|
@ -49,6 +49,7 @@ export class RemoveContentProvidersComponent implements OnInit {
|
||||||
public keyword: string = '';
|
public keyword: string = '';
|
||||||
@Output() addContentProviders: EventEmitter<void> = new EventEmitter();
|
@Output() addContentProviders: EventEmitter<void> = new EventEmitter();
|
||||||
@Output() editCriteria: EventEmitter<ContentProvider> = new EventEmitter<ContentProvider>();
|
@Output() editCriteria: EventEmitter<ContentProvider> = new EventEmitter<ContentProvider>();
|
||||||
|
@Output() editDepositInfo: EventEmitter<ContentProvider> = new EventEmitter<ContentProvider>();
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute, private _router: Router,
|
constructor(private route: ActivatedRoute, private _router: Router,
|
||||||
private _fb: UntypedFormBuilder,
|
private _fb: UntypedFormBuilder,
|
||||||
|
@ -183,4 +184,7 @@ export class RemoveContentProvidersComponent implements OnInit {
|
||||||
openCriteria(contentProvider: ContentProvider) {
|
openCriteria(contentProvider: ContentProvider) {
|
||||||
this.editCriteria.emit(contentProvider);
|
this.editCriteria.emit(contentProvider);
|
||||||
}
|
}
|
||||||
|
openDeposit(contentProvider: ContentProvider) {
|
||||||
|
this.editDepositInfo.emit(contentProvider);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,18 +11,18 @@ export class ManageCommunityContentProvidersService {
|
||||||
|
|
||||||
removeContentProvider(properties: EnvProperties, pid: string, id: string): any {
|
removeContentProvider(properties: EnvProperties, pid: string, id: string): any {
|
||||||
let headers = new HttpHeaders({'Content-Type': 'application/json', 'accept': 'application/json'});
|
let headers = new HttpHeaders({'Content-Type': 'application/json', 'accept': 'application/json'});
|
||||||
let url = properties.communityAPI + pid + '/contentproviders?contentproviderId=' +id;
|
let url = properties.communityAPI + pid + '/datasources?dsId=' +id;
|
||||||
return this.http.request('delete', url, {body: id, headers: headers});
|
return this.http.request('delete', url, {body: id, headers: headers});
|
||||||
}
|
}
|
||||||
|
|
||||||
addContentProvider(properties: EnvProperties, pid: string, contentProvider: any): Observable<ContentProvider> {
|
addContentProvider(properties: EnvProperties, pid: string, contentProvider: any): Observable<ContentProvider> {
|
||||||
let url = properties.communityAPI + pid + '/contentproviders';
|
let url = properties.communityAPI + pid + '/datasources';
|
||||||
let communityContentProvider = this.convertSearchContentProviderToCommunityContentProvider(contentProvider, pid);
|
let communityContentProvider = this.convertSearchContentProviderToCommunityContentProvider(contentProvider, pid);
|
||||||
return this.http.post<ContentProvider>(url, communityContentProvider);
|
return this.http.post<ContentProvider>(url, communityContentProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
saveContentProvider(properties: EnvProperties, contentProvider: ContentProvider): Observable<ContentProvider> {
|
saveContentProvider(properties: EnvProperties, contentProvider: ContentProvider): Observable<ContentProvider> {
|
||||||
let url = properties.communityAPI + contentProvider.communityId + '/contentproviders';
|
let url = properties.communityAPI + contentProvider.communityId + '/datasources';
|
||||||
return this.http.post<ContentProvider>(url, contentProvider);
|
return this.http.post<ContentProvider>(url, contentProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue