0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-30 04:30:29 +01:00
discourse-custom-wizard/assets/javascripts/discourse/controllers/admin-wizards-logs.js.es6

49 Zeilen
1,1 KiB
Text

2020-04-15 02:46:44 +02:00
import { default as computed } from 'discourse-common/utils/decorators';
import { popupAjaxError } from 'discourse/lib/ajax-error';
import { ajax } from 'discourse/lib/ajax';
import { notEmpty } from "@ember/object/computed";
2020-04-15 04:10:39 +02:00
import CustomWizardLogs from '../models/custom-wizard-logs';
2020-04-15 02:46:44 +02:00
export default Ember.Controller.extend({
refreshing: false,
hasLogs: notEmpty("logs"),
page: 0,
canLoadMore: true,
logs: [],
loadLogs() {
if (!this.canLoadMore) return;
this.set("refreshing", true);
2020-04-15 04:10:39 +02:00
CustomWizardLogs.list()
2020-04-15 02:46:44 +02:00
.then(result => {
if (!result || result.length === 0) {
this.set('canLoadMore', false);
}
this.set("logs", this.logs.concat(result));
})
.finally(() => this.set("refreshing", false));
},
@computed('hasLogs', 'refreshing')
noResults(hasLogs, refreshing) {
return !hasLogs && !refreshing;
},
actions: {
loadMore() {
this.set('page', this.page += 1);
this.loadLogs();
},
refresh() {
this.setProperties({
canLoadMore: true,
page: 0,
logs: []
})
this.loadLogs();
}
}
});