1
1
import { Component , OnInit } from '@angular/core' ;
2
- import { CollectionCategoryQuery } from "fusio-sdk/dist/src/generated/backend/CollectionCategoryQuery" ;
3
2
import { ActivatedRoute , Router } from "@angular/router" ;
4
- import { AxiosResponse } from "axios" ;
5
3
import { ClientAbstract } from "sdkgen-client" ;
6
4
import { Collection } from "fusio-sdk/dist/src/generated/backend/Collection" ;
7
5
import { Message } from "fusio-sdk/dist/src/generated/backend/Message" ;
8
- import { CollectionQuery } from "fusio-sdk/dist/src/generated/backend/CollectionQuery" ;
9
6
import { FusioService } from "../service/fusio.service" ;
10
7
import { ErrorService } from "../service/error.service" ;
11
8
import { EventService } from "../service/event.service" ;
@@ -76,8 +73,8 @@ export abstract class Query<C extends ClientAbstract, T extends ModelId> impleme
76
73
try {
77
74
const response = await this . getAll ( this . getCollectionQuery ( ) ) ;
78
75
79
- this . totalResults = response . data . totalResults || 0 ;
80
- this . entries = response . data . entry || [ ] ;
76
+ this . totalResults = response . totalResults || 0 ;
77
+ this . entries = response . entry || [ ] ;
81
78
82
79
this . onList ( ) ;
83
80
} catch ( error ) {
@@ -93,22 +90,19 @@ export abstract class Query<C extends ClientAbstract, T extends ModelId> impleme
93
90
this . finishLoading ( ) ;
94
91
}
95
92
96
- protected getCollectionQuery ( ) : CollectionQuery {
97
- let query : CollectionQuery = { } ;
98
- query . startIndex = ( this . page - 1 ) * this . pageSize ;
99
- query . count = this . pageSize ;
93
+ protected getCollectionQuery ( ) : Array < any > {
94
+ let query : Array < any > = [ ] ;
95
+ query . push ( ( this . page - 1 ) * this . pageSize ) ;
96
+ query . push ( this . pageSize ) ;
100
97
if ( this . search ) {
101
- query . search = this . search ;
98
+ query . push ( this . search ) ;
102
99
}
103
100
return query ;
104
101
}
105
102
106
103
async doGet ( id : string ) {
107
104
try {
108
- const response = await this . get ( id ) ;
109
-
110
- this . selected = response . data ;
111
-
105
+ this . selected = await this . get ( id ) ;
112
106
this . onGet ( ) ;
113
107
} catch ( error ) {
114
108
this . response = this . error . convert ( error ) ;
@@ -170,8 +164,8 @@ export abstract class Query<C extends ClientAbstract, T extends ModelId> impleme
170
164
} , 100 ) ;
171
165
}
172
166
173
- protected abstract getAll ( query : CollectionCategoryQuery ) : Promise < AxiosResponse < Collection < T > > > ;
174
- protected abstract get ( id : string ) : Promise < AxiosResponse < T > > ;
167
+ protected abstract getAll ( parameters : Array < any > ) : Promise < Collection < T > > ;
168
+ protected abstract get ( id : string ) : Promise < T > ;
175
169
protected abstract getRoute ( ) : string ;
176
170
177
171
protected onList ( ) : void
0 commit comments