[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 {SearchDataprovidersService} from "../../openaireLibrary/services/searchDataproviders.service";
|
||||
import {CriteriaModule} from "./criteria/criteria.module";
|
||||
import {MatSlideToggleModule} from "@angular/material/slide-toggle";
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
@ -48,7 +49,7 @@ import {CriteriaModule} from "./criteria/criteria.module";
|
|||
path: '', component: ManageContentProvidersComponent
|
||||
}
|
||||
]),
|
||||
NoLoadPaging, LoadingModule, IconsModule, FullScreenModalModule, ResultPreviewModule, CriteriaModule
|
||||
NoLoadPaging, LoadingModule, IconsModule, FullScreenModalModule, ResultPreviewModule, CriteriaModule, MatSlideToggleModule
|
||||
],
|
||||
declarations: [
|
||||
ManageContentProvidersComponent,
|
||||
|
|
|
@ -23,6 +23,7 @@ import {ManageCommunityContentProvidersService} from "../../services/manageConte
|
|||
[communityContentProviders]="communityContentProviders"
|
||||
[loading]="showLoadingInRemove" [community]="community"
|
||||
(editCriteria)="openCriteria($event)"
|
||||
(editDepositInfo)="openDeposit($event)"
|
||||
(communityContentProvidersChanged)="communityContentProvidersChanged($event)">
|
||||
</remove-content-providers>
|
||||
<fs-modal #addContentProvidersModal>
|
||||
|
@ -44,6 +45,17 @@ import {ManageCommunityContentProvidersService} from "../../services/manageConte
|
|||
</criteria>
|
||||
</div>
|
||||
</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('addContentProvidersModal', { static: true }) addContentProvidersModal: FullScreenModalComponent;
|
||||
@ViewChild('filtersModal', { static: true }) filtersModal: FullScreenModalComponent;
|
||||
@ViewChild('depositModal', { static: true }) depositModal: FullScreenModalComponent;
|
||||
private subscriptions: any[] = [];
|
||||
public showLoadingInRemove: boolean = true;
|
||||
public body: string = "Send from page";
|
||||
|
@ -60,6 +73,8 @@ export class ManageContentProvidersComponent implements OnInit {
|
|||
public openaireEntities = OpenaireEntities;
|
||||
public community: CommunityInfo;
|
||||
public dataProvider: ContentProvider;
|
||||
message = "";
|
||||
deposit= false;
|
||||
|
||||
constructor(private title: Title,
|
||||
private cdr: ChangeDetectorRef,
|
||||
|
@ -103,7 +118,17 @@ export class ManageContentProvidersComponent implements OnInit {
|
|||
this.filtersModal.open();
|
||||
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() {
|
||||
let callback = (selectionCriteria): void => {
|
||||
this.dataProvider.selectioncriteria = selectionCriteria;
|
||||
|
@ -128,4 +153,21 @@ export class ManageContentProvidersComponent implements OnInit {
|
|||
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>
|
||||
</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 class="uk-text-meta uk-margin-small-bottom">Filters</div>
|
||||
<div [innerHTML]="criteriaUtils.getFiltersAsText(item.selectioncriteria.criteria)"></div>
|
||||
|
@ -64,6 +66,22 @@
|
|||
</div>
|
||||
<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>
|
||||
<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 class="uk-padding-small uk-padding-remove-horizontal">
|
||||
<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 = '';
|
||||
@Output() addContentProviders: EventEmitter<void> = new EventEmitter();
|
||||
@Output() editCriteria: EventEmitter<ContentProvider> = new EventEmitter<ContentProvider>();
|
||||
@Output() editDepositInfo: EventEmitter<ContentProvider> = new EventEmitter<ContentProvider>();
|
||||
|
||||
constructor(private route: ActivatedRoute, private _router: Router,
|
||||
private _fb: UntypedFormBuilder,
|
||||
|
@ -183,4 +184,7 @@ export class RemoveContentProvidersComponent implements OnInit {
|
|||
openCriteria(contentProvider: 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 {
|
||||
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});
|
||||
}
|
||||
|
||||
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);
|
||||
return this.http.post<ContentProvider>(url, communityContentProvider);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue