Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display a soft "Loading..." mask until page is ready #4629

Merged
merged 4 commits into from
Jul 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- `/addShows` - Add Shows ([#4564](https://github.com/pymedusa/Medusa/pull/4564))
- `/addRecommended` - Add Recommended Shows ([#4564](https://github.com/pymedusa/Medusa/pull/4564))
- Removed the old `/ui` route ([#4565](https://github.com/pymedusa/Medusa/pull/4565))
- Added a simple "Loading..." message while the page is loading ([#4629](https://github.com/pymedusa/Medusa/pull/4629))
- _Simple message describing the improvement, and a link to the pull request._

**Fixes**
Expand Down
8 changes: 8 additions & 0 deletions themes-default/slim/views/displayShow.mako
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ const startVue = () => {
const { $store } = this;
$store.dispatch('getShows'); // Used by show-selector component
},
mounted() {
// Adjust the summary background position and size on page load and resize
this.$once('loaded', () => {
this.$nextTick(() => {
window.dispatchEvent(new Event('resize'));
});
});
}
});
};
</script>
Expand Down
22 changes: 19 additions & 3 deletions themes-default/slim/views/layouts/main.mako
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@
% endif
<%include file="/partials/alerts.mako"/>
<div id="content-row" class="row">
<div id="content-col" class="${'col-lg-10 col-lg-offset-1 col-md-10 col-md-offset-1' if not app.LAYOUT_WIDE else 'col-lg-12 col-md-12'} col-sm-12 col-xs-12">
<div v-if="globalLoading" class="text-center ${'col-lg-10 col-lg-offset-1 col-md-10 col-md-offset-1' if not app.LAYOUT_WIDE else 'col-lg-12 col-md-12'} col-sm-12 col-xs-12">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we maybe incorporate this as a separate component?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could try,
but I don't think it's worth the effort because we don't plan on keeping it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not keep it? You always need to load data right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will be much less noticeable when it's a true single page application.

<h3>Loading....</h3>
If this is taking too long,<br>
<i style="cursor: pointer;" @click="globalLoading = false;">click here</i> to show the page.
</div>
<div :style="globalLoading ? { opacity: '0 !important' } : undefined" id="content-col" class="${'col-lg-10 col-lg-offset-1 col-md-10 col-md-offset-1' if not app.LAYOUT_WIDE else 'col-lg-12 col-md-12'} col-sm-12 col-xs-12">
<%block name="content" />
</div>
</div><!-- /content -->
Expand Down Expand Up @@ -164,20 +169,31 @@
// @TODO: Remove this before v1.0.0
Vue.mixin({
data() {
return {
globalLoading: true
};
},
mounted() {
if (this.$root === this && !document.location.pathname.endsWith('/login/')) {
// We wait 1000ms to allow the mutations to show in vue dev-tools
// Please see https://github.com/egoist/puex/issues/8
setTimeout(() => {
const { store } = window;
store.dispatch('login');
store.dispatch('getConfig');
store.dispatch('getConfig')
.then(() => this.$emit('loaded'));
}, 1000);
}
this.$once('loaded', () => {
this.globalLoading = false;
});
},
// Make auth and config accessible to all components
computed: store.mapState(['auth', 'config'])
})
});
window.routes = [];
if ('${bool(app.DEVELOPER)}' === 'True') {
Vue.config.devtools = true;
Expand Down
8 changes: 8 additions & 0 deletions themes-default/slim/views/snatchSelection.mako
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ const startVue = () => {
el: '#vue-wrap',
data() {
return {};
},
mounted() {
// Adjust the summary background position and size on page load and resize
this.$once('loaded', () => {
this.$nextTick(() => {
window.dispatchEvent(new Event('resize'));
});
});
}
});
};
Expand Down
8 changes: 8 additions & 0 deletions themes/dark/templates/displayShow.mako
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ const startVue = () => {
const { $store } = this;
$store.dispatch('getShows'); // Used by show-selector component
},
mounted() {
// Adjust the summary background position and size on page load and resize
this.$once('loaded', () => {
this.$nextTick(() => {
window.dispatchEvent(new Event('resize'));
});
});
}
});
};
</script>
Expand Down
22 changes: 19 additions & 3 deletions themes/dark/templates/layouts/main.mako
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@
% endif
<%include file="/partials/alerts.mako"/>
<div id="content-row" class="row">
<div id="content-col" class="${'col-lg-10 col-lg-offset-1 col-md-10 col-md-offset-1' if not app.LAYOUT_WIDE else 'col-lg-12 col-md-12'} col-sm-12 col-xs-12">
<div v-if="globalLoading" class="text-center ${'col-lg-10 col-lg-offset-1 col-md-10 col-md-offset-1' if not app.LAYOUT_WIDE else 'col-lg-12 col-md-12'} col-sm-12 col-xs-12">
<h3>Loading....</h3>
If this is taking too long,<br>
<i style="cursor: pointer;" @click="globalLoading = false;">click here</i> to show the page.
</div>
<div :style="globalLoading ? { opacity: '0 !important' } : undefined" id="content-col" class="${'col-lg-10 col-lg-offset-1 col-md-10 col-md-offset-1' if not app.LAYOUT_WIDE else 'col-lg-12 col-md-12'} col-sm-12 col-xs-12">
<%block name="content" />
</div>
</div><!-- /content -->
Expand Down Expand Up @@ -164,20 +169,31 @@
// @TODO: Remove this before v1.0.0
Vue.mixin({
data() {
return {
globalLoading: true
};
},
mounted() {
if (this.$root === this && !document.location.pathname.endsWith('/login/')) {
// We wait 1000ms to allow the mutations to show in vue dev-tools
// Please see https://github.com/egoist/puex/issues/8
setTimeout(() => {
const { store } = window;
store.dispatch('login');
store.dispatch('getConfig');
store.dispatch('getConfig')
.then(() => this.$emit('loaded'));
}, 1000);
}
this.$once('loaded', () => {
this.globalLoading = false;
});
},
// Make auth and config accessible to all components
computed: store.mapState(['auth', 'config'])
})
});
window.routes = [];
if ('${bool(app.DEVELOPER)}' === 'True') {
Vue.config.devtools = true;
Expand Down
8 changes: 8 additions & 0 deletions themes/dark/templates/snatchSelection.mako
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ const startVue = () => {
el: '#vue-wrap',
data() {
return {};
},
mounted() {
// Adjust the summary background position and size on page load and resize
this.$once('loaded', () => {
this.$nextTick(() => {
window.dispatchEvent(new Event('resize'));
});
});
}
});
};
Expand Down
8 changes: 8 additions & 0 deletions themes/light/templates/displayShow.mako
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ const startVue = () => {
const { $store } = this;
$store.dispatch('getShows'); // Used by show-selector component
},
mounted() {
// Adjust the summary background position and size on page load and resize
this.$once('loaded', () => {
this.$nextTick(() => {
window.dispatchEvent(new Event('resize'));
});
});
}
});
};
</script>
Expand Down
22 changes: 19 additions & 3 deletions themes/light/templates/layouts/main.mako
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@
% endif
<%include file="/partials/alerts.mako"/>
<div id="content-row" class="row">
<div id="content-col" class="${'col-lg-10 col-lg-offset-1 col-md-10 col-md-offset-1' if not app.LAYOUT_WIDE else 'col-lg-12 col-md-12'} col-sm-12 col-xs-12">
<div v-if="globalLoading" class="text-center ${'col-lg-10 col-lg-offset-1 col-md-10 col-md-offset-1' if not app.LAYOUT_WIDE else 'col-lg-12 col-md-12'} col-sm-12 col-xs-12">
<h3>Loading....</h3>
If this is taking too long,<br>
<i style="cursor: pointer;" @click="globalLoading = false;">click here</i> to show the page.
</div>
<div :style="globalLoading ? { opacity: '0 !important' } : undefined" id="content-col" class="${'col-lg-10 col-lg-offset-1 col-md-10 col-md-offset-1' if not app.LAYOUT_WIDE else 'col-lg-12 col-md-12'} col-sm-12 col-xs-12">
<%block name="content" />
</div>
</div><!-- /content -->
Expand Down Expand Up @@ -164,20 +169,31 @@
// @TODO: Remove this before v1.0.0
Vue.mixin({
data() {
return {
globalLoading: true
};
},
mounted() {
if (this.$root === this && !document.location.pathname.endsWith('/login/')) {
// We wait 1000ms to allow the mutations to show in vue dev-tools
// Please see https://github.com/egoist/puex/issues/8
setTimeout(() => {
const { store } = window;
store.dispatch('login');
store.dispatch('getConfig');
store.dispatch('getConfig')
.then(() => this.$emit('loaded'));
}, 1000);
}
this.$once('loaded', () => {
this.globalLoading = false;
});
},
// Make auth and config accessible to all components
computed: store.mapState(['auth', 'config'])
})
});
window.routes = [];
if ('${bool(app.DEVELOPER)}' === 'True') {
Vue.config.devtools = true;
Expand Down
8 changes: 8 additions & 0 deletions themes/light/templates/snatchSelection.mako
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ const startVue = () => {
el: '#vue-wrap',
data() {
return {};
},
mounted() {
// Adjust the summary background position and size on page load and resize
this.$once('loaded', () => {
this.$nextTick(() => {
window.dispatchEvent(new Event('resize'));
});
});
}
});
};
Expand Down