Skip to content

Commit

Permalink
Display a soft "Loading..." mask until page is ready (#4629)
Browse files Browse the repository at this point in the history
* Soft "Loading..." mask

* Update changelog

* Emit the event after 'getConfig'

* Fix summaryBackground location
  • Loading branch information
sharkykh authored and p0psicles committed Jul 10, 2018
1 parent e09d270 commit ef96dba
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 9 deletions.
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">
<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

0 comments on commit ef96dba

Please sign in to comment.