2019-08-17 23:03:10 +00:00
|
|
|
import { rawDataToServerObject, Server } from '@/api/server/getServer';
|
|
|
|
import http, { getPaginationSet, PaginatedResult } from '@/api/http';
|
|
|
|
|
2020-04-26 00:52:32 +00:00
|
|
|
export default (query?: string, includeAdmin?: boolean): Promise<PaginatedResult<Server>> => {
|
2019-08-17 23:03:10 +00:00
|
|
|
return new Promise((resolve, reject) => {
|
2020-07-05 01:30:50 +00:00
|
|
|
http.get('/api/client', {
|
2020-04-26 00:52:32 +00:00
|
|
|
params: {
|
|
|
|
include: [ 'allocation' ],
|
2020-07-07 04:25:00 +00:00
|
|
|
type: includeAdmin ? 'all' : undefined,
|
|
|
|
'filter[name]': query,
|
2020-04-26 00:52:32 +00:00
|
|
|
},
|
|
|
|
})
|
2019-08-17 23:03:10 +00:00
|
|
|
.then(({ data }) => resolve({
|
2020-07-10 04:00:03 +00:00
|
|
|
items: (data.data || []).map((datum: any) => rawDataToServerObject(datum)),
|
2019-08-17 23:03:10 +00:00
|
|
|
pagination: getPaginationSet(data.meta.pagination),
|
|
|
|
}))
|
|
|
|
.catch(reject);
|
|
|
|
});
|
|
|
|
};
|