Skip to content

Commit

Permalink
https://github.com/DASISH/qddt-client/issues/770
Browse files Browse the repository at this point in the history
  • Loading branch information
StigNorland committed Jan 18, 2022
1 parent 81967a8 commit c41a22a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/app/components/revision/revision.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class RevisionComponent implements OnChanges {
this.showProgressBar = true;
this.service.getRevisions(this.getElementKind(), this.current.id).then(
(result: any) => {
this.revisions = result._embedded.halRepresentationModels;
this.revisions = result;
this.showProgressBar = false;
},
(error) => {
Expand Down
35 changes: 27 additions & 8 deletions src/app/components/revision/revision.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable, Inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { API_BASE_HREF } from '../../api';
import { ElementKind, getQueryInfo, Page } from '../../lib';
import { ElementKind, getQueryInfo, HalResource, Page } from '../../lib';


@Injectable()
Expand All @@ -13,21 +13,40 @@ export class RevisionService {
public getRevisionByRev(kind: ElementKind, id: string, rev: number): Promise<any> {

const qe = getQueryInfo(kind);
return this.http.get(this.api + qe.path + '/' + id + ':' + rev).toPromise();
return this.http.get<HalResource>(this.api + qe.path + '/revision/' + id + ':' + rev).toPromise();

}

public getRevisions(kind: ElementKind, id: string): Promise<any> {

const qe = getQueryInfo(kind);
return this.http.get(this.api + qe.path + '/revisions/' + id).toPromise();

return new Promise((resolve, reject) => {
const qe = getQueryInfo(kind);
this.http.get<HalResource>(this.api + qe.path + '/revisions/' + id).toPromise()
.then(
async result => {
// const qe = getQueryInfo(kind);
resolve(result._embedded[qe.halName]);
},
err => {
reject(err);
}
);
});
}

public getRevisionPage(kind: ElementKind, id: string, page: Page): Promise<any> {

const qe = getQueryInfo(kind);
return this.http.get(this.api + '' + qe.path + '/revisions/' + id + '?' + page.queryPage).toPromise();
return new Promise((resolve, reject) => {
const qe = getQueryInfo(kind);
this.http.get<HalResource>(this.api + '' + qe.path + '/revisions/' + id + '?' + page.queryPage).toPromise()
.then(
async result => {
resolve(result._embedded[qe.halName]);
},
err => {
reject(err);
}
);
});

}
}
2 changes: 1 addition & 1 deletion src/app/lib/services/template.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class TemplateService {
// return this.http.get<IPageResult>
// (this.api + '/' + qe.path + '/' + id + '/revisions').toPromise();
// } else {
return this.http.get<IPageResult>(this.api + 'revisions/'+ qe.path + '/' + id ).toPromise();
return this.http.get<IPageResult>(this.api + qe.path + '/revisions/' + id ).toPromise();
// }
}
return new Promise(null);
Expand Down

0 comments on commit c41a22a

Please sign in to comment.