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

View File

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