commit
00aea43519
5 changed files with 43 additions and 49 deletions
|
|
@ -10,31 +10,38 @@ export default class AdminTasksIndexController extends Controller {
|
|||
taskStatuses = taskStatuses;
|
||||
taskTypes = taskTypes;
|
||||
|
||||
queryParams = ['limit', 'status', 'type', 'indexUid'];
|
||||
queryParams = ['limit', 'statuses', 'types', 'indexUids'];
|
||||
|
||||
@tracked limit = 20;
|
||||
@tracked from;
|
||||
@tracked status;
|
||||
@tracked type;
|
||||
@tracked indexUid;
|
||||
@tracked statuses;
|
||||
@tracked types;
|
||||
@tracked indexUids;
|
||||
|
||||
@use
|
||||
tasks = resource(() => {
|
||||
tasks = resource(({ on }) => {
|
||||
this.tasksHolder.isLoading = true;
|
||||
|
||||
const controller = new AbortController();
|
||||
const params = {
|
||||
limit: this.limit,
|
||||
from: this.from,
|
||||
status: this.status,
|
||||
type: this.type,
|
||||
indexUid: this.indexUid,
|
||||
statuses: this.statuses,
|
||||
types: this.types,
|
||||
indexUids: this.indexUids,
|
||||
};
|
||||
|
||||
this.meilisearch.getTasks(params).then((data) => {
|
||||
this.tasksHolder.results = this.tasksHolder.results.concat(data.results);
|
||||
this.tasksHolder.next = data.next;
|
||||
this.tasksHolder.isLoading = false;
|
||||
});
|
||||
on.cleanup(() => controller.abort());
|
||||
|
||||
this.meilisearch
|
||||
.getTasks(params, { signal: controller.signal })
|
||||
.then((data) => {
|
||||
this.tasksHolder.results = this.tasksHolder.results.concat(
|
||||
data.results
|
||||
);
|
||||
this.tasksHolder.next = data.next;
|
||||
this.tasksHolder.isLoading = false;
|
||||
});
|
||||
|
||||
return this.tasksHolder;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ export default class AdminTasksIndexRoute extends Route {
|
|||
|
||||
queryParams = {
|
||||
limit: { refreshModel: true },
|
||||
status: { refreshModel: true },
|
||||
type: { refreshModel: true },
|
||||
indexUid: { refreshModel: true },
|
||||
statuses: { refreshModel: true },
|
||||
types: { refreshModel: true },
|
||||
indexUids: { refreshModel: true },
|
||||
};
|
||||
|
||||
model() {
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ export default class MeilisearchService extends Service {
|
|||
}
|
||||
|
||||
getDumps() {
|
||||
return this.getTasks({ type: 'dumpCreation' });
|
||||
return this.getTasks({ types: 'dumpCreation' });
|
||||
}
|
||||
|
||||
createDump() {
|
||||
|
|
|
|||
|
|
@ -1,31 +1,31 @@
|
|||
<Headers::H1 @title='Tasks' />
|
||||
|
||||
<div class='sm:flex sm:flex-nowrap'>
|
||||
{{! indexUid }}
|
||||
{{! indexUids }}
|
||||
<Form::Listbox
|
||||
@prefixValue={{'Index: '}}
|
||||
@value={{nu-co this.indexUid 'none'}}
|
||||
@value={{nu-co this.indexUids 'none'}}
|
||||
@values={{map-by 'uid' @model.indexes.results}}
|
||||
@onChange={{set this 'indexUid'}}
|
||||
@onChange={{set this 'indexUids'}}
|
||||
@allowClear={{true}}
|
||||
/>
|
||||
|
||||
{{! status }}
|
||||
{{! statuses }}
|
||||
<Form::Listbox
|
||||
@prefixValue={{'Status: '}}
|
||||
@value={{nu-co this.status 'none'}}
|
||||
@value={{nu-co this.statuses 'none'}}
|
||||
@values={{this.taskStatuses}}
|
||||
@onChange={{set this 'status'}}
|
||||
@onChange={{set this 'statuses'}}
|
||||
@allowClear={{true}}
|
||||
class='sm:ml-4 sm:flex-none'
|
||||
/>
|
||||
|
||||
{{! status }}
|
||||
{{! types }}
|
||||
<Form::Listbox
|
||||
@prefixValue={{'Type: '}}
|
||||
@value={{nu-co this.type 'none'}}
|
||||
@value={{nu-co this.types 'none'}}
|
||||
@values={{this.taskTypes}}
|
||||
@onChange={{set this 'type'}}
|
||||
@onChange={{set this 'types'}}
|
||||
@allowClear={{true}}
|
||||
class='sm:ml-4 sm:flex-none'
|
||||
/>
|
||||
|
|
@ -49,10 +49,7 @@
|
|||
>{{data.uid}}</LinkTo>
|
||||
</Column>
|
||||
<Column @prop='indexUid'>
|
||||
<LinkTo
|
||||
@route='admin.indexes.item'
|
||||
@model={{data.indexUid}}
|
||||
>{{data.indexUid}}</LinkTo>
|
||||
{{data.indexUid}}
|
||||
</Column>
|
||||
<Column @prop='status'>
|
||||
<Badge @label={{data.status}} @style={{data.style}} />
|
||||
|
|
|
|||
|
|
@ -16,29 +16,19 @@ export default function query(path, options = {}) {
|
|||
Object.assign(options, { headers })
|
||||
);
|
||||
|
||||
return fetch(req)
|
||||
.then((response) => {
|
||||
if (response.status === 204) {
|
||||
return;
|
||||
} else if (response.ok) {
|
||||
return response.json();
|
||||
} else {
|
||||
return response.json().then((reason) => {
|
||||
toaster.dangerToast({
|
||||
header: reason.type,
|
||||
text: reason.message,
|
||||
});
|
||||
|
||||
// throw new Error('Network response was not OK');
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((response) => {
|
||||
return fetch(req).then((response) => {
|
||||
if (response.status === 204) {
|
||||
return;
|
||||
} else if (response.ok) {
|
||||
return response.json();
|
||||
} else {
|
||||
return response.json().then((reason) => {
|
||||
toaster.dangerToast({
|
||||
header: reason.type,
|
||||
text: reason.message,
|
||||
});
|
||||
// throw new Error('Network response was not OK');
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue