DSP-UI CORE module
DspCoreModule is a configuration handler for @dasch-swiss/dsp-js
which offers all the services to make DSP-API requests.
Prerequisites
For help getting started with a new Angular app, check out the Angular CLI.
For existing apps, follow these steps to begin using DSP-UI CORE.
Installation
DspCoreModule is part of @dasch-swiss/dsp-ui, follow the installation guide.
Usage
The following ProjectsComponent example shows how to implement the two libraries to get all projects from DSP-API:
import { Component, Inject, OnInit } from '@angular/core';
import { DspApiConnectionToken } from '@dasch-swiss/dsp-ui';
import {
ApiResponseData,
ApiResponseError,
KnoraApiConnection,
ProjectsResponse,
ReadProject
} from '@dasch-swiss/dsp-js';
@Component({
selector: 'app-projects',
template: `<ul><li *ngFor="let p of projects">{{p.longname}} (<strong>{{p.shortname}}</strong> | {{p.shortcode}})</li></ul>`
})
export class ProjectsComponent implements OnInit {
projects: ReadProject[];
constructor(
@Inject(DspApiConnectionToken) private dspApiConnection: KnoraApiConnection
) { }
ngOnInit() {
this.getProjects();
}
getProjects() {
this.dspApiConnection.admin.projectsEndpoint.getProjects().subscribe(
(response: ApiResponseData<ProjectsResponse>) => {
this.projects = response.body.projects;
},
(error: ApiResponseError) => {
console.error(error);
}
);
}
}
Last update: 2021-08-13