Added node pagination to SiteModel (#2136)

This commit is contained in:
Vito
2017-07-26 08:03:55 -07:00
committed by Eugenio Romano
parent 16149e8c55
commit 8ca2609e43
2 changed files with 12 additions and 5 deletions

View File

@@ -15,6 +15,8 @@
* limitations under the License.
*/
import { Pagination } from 'alfresco-js-api';
export class SiteModel {
role: string;
visibility: string;
@@ -25,6 +27,7 @@ export class SiteModel {
title: string;
contents: SiteContentsModel[] = [];
members: SiteMembersModel[] = [];
pagination: Pagination;
constructor(obj?: any) {
if (obj && obj.entry) {
@@ -35,6 +38,7 @@ export class SiteModel {
this.id = obj.entry.id || null;
this.preset = obj.entry.preset;
this.title = obj.entry.title;
this.pagination = obj.pagination || null;
if (obj.relations && obj.relations.containers) {
obj.relations.containers.list.entries.forEach((content) => {

View File

@@ -37,8 +37,7 @@ export class SitesApiService {
};
const queryOptions = Object.assign({}, defaultOptions, opts);
return Observable.fromPromise(this.apiService.getInstance().core.sitesApi.getSites(queryOptions))
.map((res: any) => res.list.entries)
.map((objList) => this.convertToModel(objList))
.map((res) => this.convertToModel(res))
.catch(this.handleError);
}
@@ -68,10 +67,14 @@ export class SitesApiService {
return Observable.throw(error || 'Server error');
}
private convertToModel(objList: any[]) {
private convertToModel(response: any) {
let convertedList: SiteModel[] = [];
if (objList && objList.length > 0) {
objList.forEach((element: any) => {
if (response &&
response.list &&
response.list.entries &&
response.list.entries.length > 0) {
response.list.entries.forEach((element: any) => {
element.pagination = response.list.pagination;
convertedList.push(new SiteModel(element));
});
}