From 147b8a787c32eefa82d86913e9fffa766a07d171 Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Wed, 15 Apr 2020 12:10:39 +1000 Subject: [PATCH] Improve log UI --- .../controllers/admin-wizards-logs.js.es6 | 7 ++----- .../discourse/models/custom-wizard-logs.js.es6 | 17 +++++++++++++++++ .../discourse/routes/admin-wizards-logs.js.es6 | 11 +++++++++++ .../discourse/templates/admin-wizards-logs.hbs | 14 ++++++++++---- .../templates/admin-wizards-wizard.hbs | 8 +++++++- assets/stylesheets/common/wizard-admin.scss | 14 ++++++++++++++ config/locales/client.en.yml | 4 +++- 7 files changed, 64 insertions(+), 11 deletions(-) create mode 100644 assets/javascripts/discourse/models/custom-wizard-logs.js.es6 create mode 100644 assets/javascripts/discourse/routes/admin-wizards-logs.js.es6 diff --git a/assets/javascripts/discourse/controllers/admin-wizards-logs.js.es6 b/assets/javascripts/discourse/controllers/admin-wizards-logs.js.es6 index aebc5d00..26e2d622 100644 --- a/assets/javascripts/discourse/controllers/admin-wizards-logs.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-wizards-logs.js.es6 @@ -2,6 +2,7 @@ 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"; +import CustomWizardLogs from '../models/custom-wizard-logs'; export default Ember.Controller.extend({ refreshing: false, @@ -15,11 +16,7 @@ export default Ember.Controller.extend({ this.set("refreshing", true); - ajax('/admin/wizards/logs', { - data: { - page: this.page - } - }).catch(popupAjaxError) + CustomWizardLogs.list() .then(result => { if (!result || result.length === 0) { this.set('canLoadMore', false); diff --git a/assets/javascripts/discourse/models/custom-wizard-logs.js.es6 b/assets/javascripts/discourse/models/custom-wizard-logs.js.es6 new file mode 100644 index 00000000..10f46d53 --- /dev/null +++ b/assets/javascripts/discourse/models/custom-wizard-logs.js.es6 @@ -0,0 +1,17 @@ +import { ajax } from 'discourse/lib/ajax'; +import { popupAjaxError } from 'discourse/lib/ajax-error'; +import EmberObject from "@ember/object"; + +const CustomWizardLogs = EmberObject.extend(); + +CustomWizardLogs.reopenClass({ + list(page = 0) { + return ajax('/admin/wizards/logs', { + data: { + page + } + }).catch(popupAjaxError); + } +}); + +export default CustomWizardLogs; \ No newline at end of file diff --git a/assets/javascripts/discourse/routes/admin-wizards-logs.js.es6 b/assets/javascripts/discourse/routes/admin-wizards-logs.js.es6 new file mode 100644 index 00000000..1c1de391 --- /dev/null +++ b/assets/javascripts/discourse/routes/admin-wizards-logs.js.es6 @@ -0,0 +1,11 @@ +import CustomWizardLogs from '../models/custom-wizard-logs'; + +export default Discourse.Route.extend({ + model() { + return CustomWizardLogs.list(); + }, + + setupController(controller, model) { + controller.set('logs', model); + } +}) \ No newline at end of file diff --git a/assets/javascripts/discourse/templates/admin-wizards-logs.hbs b/assets/javascripts/discourse/templates/admin-wizards-logs.hbs index 5843bb7b..28052fe2 100644 --- a/assets/javascripts/discourse/templates/admin-wizards-logs.hbs +++ b/assets/javascripts/discourse/templates/admin-wizards-logs.hbs @@ -1,8 +1,14 @@
- {{d-button label="refresh" icon="refresh" action="refresh"}} +

{{i18n 'admin.wizard.log.nav_label'}}

+ + {{d-button + label="refresh" + icon="refresh" + action="refresh" + class="refresh"}}
-{{#load-more selector=".log-list tr" action=(action "loadMore")}} +{{#load-more selector=".log-list tr" action=(action "loadMore") class="wizard-logs"}} {{#if noResults}}

{{i18n 'search.no_results'}}

{{else}} @@ -10,14 +16,14 @@ Message - Date + Date {{#each logs as |log|}} {{log.message}} - {{bound-date log.date}} + {{bound-date log.date}} {{/each}} diff --git a/assets/javascripts/discourse/templates/admin-wizards-wizard.hbs b/assets/javascripts/discourse/templates/admin-wizards-wizard.hbs index 08c33fbf..17221840 100644 --- a/assets/javascripts/discourse/templates/admin-wizards-wizard.hbs +++ b/assets/javascripts/discourse/templates/admin-wizards-wizard.hbs @@ -21,8 +21,14 @@
{{d-icon 'question-circle'}} + {{i18n 'admin.wizard.message.help'}} + - {{i18n 'admin.wizard.message.help'}} + {{i18n 'admin.wizard.message.documentation'}} + + + + {{i18n 'admin.wizard.message.contact'}}
diff --git a/assets/stylesheets/common/wizard-admin.scss b/assets/stylesheets/common/wizard-admin.scss index d165d9e8..56c5fb30 100644 --- a/assets/stylesheets/common/wizard-admin.scss +++ b/assets/stylesheets/common/wizard-admin.scss @@ -30,6 +30,20 @@ overflow: scroll; } +.admin-wizards-logs { + .admin-wizard-controls { + h3 { + margin: 0 7px; + } + } + + .wizard-logs { + .date { + width: 100px; + } + } +} + .wizard-settings-parent { margin-bottom: 30px; padding: 20px; diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 68e5da9a..bc4e335e 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -58,7 +58,9 @@ en: select: "Select a wizard, or create a new one" edit: "You're editing a wizard" create: "You're creating a new wizard" - help: "Need help? Check out the documentation" + help: "Need help?" + documentation: "Check out the documentation" + contact: "Contact the developer" editor: show: "Show"