78 lines
3.0 KiB
TypeScript
78 lines
3.0 KiB
TypeScript
import { Component, Inject, Injectable, OnInit } from '@angular/core';
|
|
import { ActivatedRoute, Params, Router } from '@angular/router';
|
|
import { MatDialog, MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
|
import { MDStore, MDStoreRecord, MDStoreVersion } from '../common/is.model';
|
|
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
|
import { ISClient } from '../common/is.client';
|
|
import { combineLatest } from 'rxjs';
|
|
|
|
@Component({
|
|
selector: 'oai-explorer',
|
|
templateUrl: './oai-explorer.component.html',
|
|
styleUrls: []
|
|
})
|
|
export class OaiExplorerComponent implements OnInit {
|
|
|
|
oaiBaseUrl: string = ""
|
|
page: number = 1;
|
|
oaiResponse = {};
|
|
|
|
constructor(public client: OaiExplorerClient, public router: Router, public route: ActivatedRoute, public dialog: MatDialog) { }
|
|
|
|
ngOnInit() {
|
|
combineLatest([this.route.params, this.route.queryParams],
|
|
(params: Params, queryParams: Params) => ({ params, queryParams })
|
|
).subscribe((res: { params: Params; queryParams: Params }) => {
|
|
this.oaiBaseUrl = res.queryParams['baseUrl'];
|
|
|
|
if (this.oaiBaseUrl) {
|
|
if (res.queryParams['page'] == 1) {
|
|
this.client.callIdentifyVerb(this.oaiBaseUrl, (res: any) => this.oaiResponse = res);
|
|
} else if (res.queryParams['page'] == 2) {
|
|
this.client.callListSetsVerb(this.oaiBaseUrl, (res: any) => this.oaiResponse = res);
|
|
} else if (res.queryParams['page'] == 3) {
|
|
this.client.callListMdFormatsVerb(this.oaiBaseUrl, (res: any) => this.oaiResponse = res);
|
|
} else if (res.queryParams['page'] == 4) {
|
|
this.client.callListRecordsVerb(this.oaiBaseUrl, (res: any) => this.oaiResponse = res);
|
|
} else if (res.queryParams['page'] == 5) {
|
|
this.client.callListIdentifiersVerb(this.oaiBaseUrl, (res: any) => this.oaiResponse = res);
|
|
} else {
|
|
this.client.callIdentifyVerb(this.oaiBaseUrl, (res: any) => this.oaiResponse = res);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
changeUrl(baseUrl: string, page: number) {
|
|
this.router.navigate(['/oai-explorer'], { queryParams: { baseUrl: baseUrl, page: page } });
|
|
}
|
|
}
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class OaiExplorerClient extends ISClient {
|
|
baseUrl = '/proxy/byType/datasource_manager/api';
|
|
|
|
callIdentifyVerb(oaiBaseUrl: string, onSuccess: Function) {
|
|
this.httpGet(this.baseUrl + '/oai-explorer/info?baseUrl=' + encodeURIComponent(oaiBaseUrl), onSuccess);
|
|
}
|
|
|
|
callListSetsVerb(oaiBaseUrl: string, onSuccess: Function) {
|
|
this.httpGet(this.baseUrl + '/oai-explorer/sets?baseUrl=' + encodeURIComponent(oaiBaseUrl), onSuccess);
|
|
}
|
|
|
|
callListMdFormatsVerb(oaiBaseUrl: string, onSuccess: Function) {
|
|
this.httpGet(this.baseUrl + '/oai-explorer/mdformats?baseUrl=' + encodeURIComponent(oaiBaseUrl), onSuccess);
|
|
}
|
|
|
|
callListRecordsVerb(oaiBaseUrl: string, onSuccess: Function) {
|
|
this.httpGet(this.baseUrl + '/oai-explorer/records?baseUrl=' + encodeURIComponent(oaiBaseUrl), onSuccess);
|
|
}
|
|
|
|
callListIdentifiersVerb(oaiBaseUrl: string, onSuccess: Function) {
|
|
this.httpGet(this.baseUrl + '/oai-explorer/identifiers?baseUrl=' + encodeURIComponent(oaiBaseUrl), onSuccess);
|
|
}
|
|
|
|
}
|