mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 21:40:39 +03:00
Re-implementing the loading indicator for the Ember admin
closes #2855 , closes #2848 - New mixin that utilizes NProgress for displaying a loading indictor for all routes who's model issue a "loading" event (aka: when requesting data from the server during a route change). - Also removing (the now unnecessary) "loading" template.
This commit is contained in:
parent
42c9a272a7
commit
2afc1ff04f
@ -29,6 +29,7 @@
|
|||||||
"$": true,
|
"$": true,
|
||||||
"validator": true,
|
"validator": true,
|
||||||
"ic": true,
|
"ic": true,
|
||||||
"_": true
|
"_": true,
|
||||||
|
"NProgress": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import ShortcutsRoute from 'ghost/mixins/shortcuts-route';
|
import ShortcutsRoute from 'ghost/mixins/shortcuts-route';
|
||||||
import styleBody from 'ghost/mixins/style-body';
|
import styleBody from 'ghost/mixins/style-body';
|
||||||
|
import loadingIndicator from 'ghost/mixins/loading-indicator';
|
||||||
|
|
||||||
|
|
||||||
var EditorRouteBase = Ember.Mixin.create(styleBody, ShortcutsRoute, {
|
var EditorRouteBase = Ember.Mixin.create(styleBody, ShortcutsRoute, loadingIndicator, {
|
||||||
actions: {
|
actions: {
|
||||||
save: function () {
|
save: function () {
|
||||||
this.get('controller').send('save');
|
this.get('controller').send('save');
|
||||||
|
25
ghost/admin/mixins/loading-indicator.js
Normal file
25
ghost/admin/mixins/loading-indicator.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// mixin used for routes to display a loading indicator when there is network activity
|
||||||
|
var loaderOptions = {
|
||||||
|
'showSpinner': false
|
||||||
|
};
|
||||||
|
NProgress.configure(loaderOptions);
|
||||||
|
|
||||||
|
var loadingIndicator = Ember.Mixin.create({
|
||||||
|
actions: {
|
||||||
|
|
||||||
|
loading: function () {
|
||||||
|
NProgress.start();
|
||||||
|
this.router.one('didTransition', function () {
|
||||||
|
NProgress.done();
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
|
error: function () {
|
||||||
|
NProgress.done();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default loadingIndicator;
|
@ -1,8 +1,9 @@
|
|||||||
import styleBody from 'ghost/mixins/style-body';
|
import styleBody from 'ghost/mixins/style-body';
|
||||||
import AuthenticatedRoute from 'ghost/routes/authenticated';
|
import AuthenticatedRoute from 'ghost/routes/authenticated';
|
||||||
import SettingsModel from 'ghost/models/settings';
|
import SettingsModel from 'ghost/models/settings';
|
||||||
|
import loadingIndicator from 'ghost/mixins/loading-indicator';
|
||||||
|
|
||||||
export default AuthenticatedRoute.extend(styleBody, {
|
export default AuthenticatedRoute.extend(styleBody, loadingIndicator, {
|
||||||
classNames: ['settings'],
|
classNames: ['settings'],
|
||||||
|
|
||||||
model: function () {
|
model: function () {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import styleBody from 'ghost/mixins/style-body';
|
import styleBody from 'ghost/mixins/style-body';
|
||||||
|
import loadingIndicator from 'ghost/mixins/loading-indicator';
|
||||||
|
|
||||||
var ForgottenRoute = Ember.Route.extend(styleBody, {
|
var ForgottenRoute = Ember.Route.extend(styleBody, loadingIndicator, {
|
||||||
classNames: ['ghost-forgotten']
|
classNames: ['ghost-forgotten']
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import AuthenticatedRoute from 'ghost/routes/authenticated';
|
import AuthenticatedRoute from 'ghost/routes/authenticated';
|
||||||
import styleBody from 'ghost/mixins/style-body';
|
import styleBody from 'ghost/mixins/style-body';
|
||||||
import ShortcutsRoute from 'ghost/mixins/shortcuts-route';
|
import ShortcutsRoute from 'ghost/mixins/shortcuts-route';
|
||||||
|
import loadingIndicator from 'ghost/mixins/loading-indicator';
|
||||||
|
|
||||||
var paginationSettings = {
|
var paginationSettings = {
|
||||||
status: 'all',
|
status: 'all',
|
||||||
@ -8,7 +9,7 @@ var paginationSettings = {
|
|||||||
page: 1
|
page: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
var PostsRoute = AuthenticatedRoute.extend(ShortcutsRoute, styleBody, {
|
var PostsRoute = AuthenticatedRoute.extend(ShortcutsRoute, styleBody, loadingIndicator, {
|
||||||
classNames: ['manage'],
|
classNames: ['manage'],
|
||||||
|
|
||||||
model: function () {
|
model: function () {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import AuthenticatedRoute from 'ghost/routes/authenticated';
|
import AuthenticatedRoute from 'ghost/routes/authenticated';
|
||||||
|
import loadingIndicator from 'ghost/mixins/loading-indicator';
|
||||||
|
|
||||||
var PostsIndexRoute = AuthenticatedRoute.extend({
|
var PostsIndexRoute = AuthenticatedRoute.extend(loadingIndicator, {
|
||||||
// redirect to first post subroute
|
// redirect to first post subroute
|
||||||
beforeModel: function () {
|
beforeModel: function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import AuthenticatedRoute from 'ghost/routes/authenticated';
|
import AuthenticatedRoute from 'ghost/routes/authenticated';
|
||||||
|
import loadingIndicator from 'ghost/mixins/loading-indicator';
|
||||||
|
|
||||||
var PostsPostRoute = AuthenticatedRoute.extend({
|
var PostsPostRoute = AuthenticatedRoute.extend(loadingIndicator, {
|
||||||
model: function (params) {
|
model: function (params) {
|
||||||
var self = this,
|
var self = this,
|
||||||
post,
|
post,
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import styleBody from 'ghost/mixins/style-body';
|
import styleBody from 'ghost/mixins/style-body';
|
||||||
|
import loadingIndicator from 'ghost/mixins/loading-indicator';
|
||||||
|
|
||||||
var ResetRoute = Ember.Route.extend(styleBody, {
|
var ResetRoute = Ember.Route.extend(styleBody, loadingIndicator, {
|
||||||
classNames: ['ghost-reset'],
|
classNames: ['ghost-reset'],
|
||||||
setupController: function (controller, params) {
|
setupController: function (controller, params) {
|
||||||
controller.token = params.token;
|
controller.token = params.token;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import styleBody from 'ghost/mixins/style-body';
|
import styleBody from 'ghost/mixins/style-body';
|
||||||
import AuthenticatedRoute from 'ghost/routes/authenticated';
|
import AuthenticatedRoute from 'ghost/routes/authenticated';
|
||||||
|
import loadingIndicator from 'ghost/mixins/loading-indicator';
|
||||||
|
|
||||||
var SettingsRoute = AuthenticatedRoute.extend(styleBody, {
|
var SettingsRoute = AuthenticatedRoute.extend(styleBody, loadingIndicator, {
|
||||||
classNames: ['settings']
|
classNames: ['settings']
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import AuthenticatedRoute from 'ghost/routes/authenticated';
|
import AuthenticatedRoute from 'ghost/routes/authenticated';
|
||||||
|
import loadingIndicator from 'ghost/mixins/loading-indicator';
|
||||||
|
|
||||||
var SettingsGeneralRoute = AuthenticatedRoute.extend({
|
var SettingsGeneralRoute = AuthenticatedRoute.extend(loadingIndicator, {
|
||||||
model: function () {
|
model: function () {
|
||||||
return this.store.find('setting', { type: 'blog,theme' }).then(function (records) {
|
return this.store.find('setting', { type: 'blog,theme' }).then(function (records) {
|
||||||
return records.get('firstObject');
|
return records.get('firstObject');
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import ajax from 'ghost/utils/ajax';
|
import ajax from 'ghost/utils/ajax';
|
||||||
import styleBody from 'ghost/mixins/style-body';
|
import styleBody from 'ghost/mixins/style-body';
|
||||||
|
import loadingIndicator from 'ghost/mixins/loading-indicator';
|
||||||
|
|
||||||
var isEmpty = Ember.isEmpty;
|
var isEmpty = Ember.isEmpty;
|
||||||
|
|
||||||
var SigninRoute = Ember.Route.extend(styleBody, {
|
var SigninRoute = Ember.Route.extend(styleBody, loadingIndicator, {
|
||||||
classNames: ['ghost-login'],
|
classNames: ['ghost-login'],
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import ajax from 'ghost/utils/ajax';
|
import ajax from 'ghost/utils/ajax';
|
||||||
import styleBody from 'ghost/mixins/style-body';
|
import styleBody from 'ghost/mixins/style-body';
|
||||||
import AuthenticatedRoute from 'ghost/routes/authenticated';
|
import AuthenticatedRoute from 'ghost/routes/authenticated';
|
||||||
|
import loadingIndicator from 'ghost/mixins/loading-indicator';
|
||||||
|
|
||||||
var SignoutRoute = AuthenticatedRoute.extend(styleBody, {
|
var SignoutRoute = AuthenticatedRoute.extend(styleBody, loadingIndicator, {
|
||||||
classNames: ['ghost-signout'],
|
classNames: ['ghost-signout'],
|
||||||
|
|
||||||
beforeModel: function () {
|
beforeModel: function () {
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import ajax from 'ghost/utils/ajax';
|
import ajax from 'ghost/utils/ajax';
|
||||||
import styleBody from 'ghost/mixins/style-body';
|
import styleBody from 'ghost/mixins/style-body';
|
||||||
|
import loadingIndicator from 'ghost/mixins/loading-indicator';
|
||||||
|
|
||||||
var SignupRoute = Ember.Route.extend(styleBody, {
|
var SignupRoute = Ember.Route.extend(styleBody, loadingIndicator, {
|
||||||
classNames: ['ghost-signup'],
|
classNames: ['ghost-signup'],
|
||||||
|
|
||||||
name: null,
|
name: null,
|
||||||
|
@ -1 +0,0 @@
|
|||||||
<h1>Loading...</h1>
|
|
Loading…
Reference in New Issue
Block a user