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

Feature/UI indicate when no connection #10774

Merged
merged 5 commits into from
Jun 22, 2022
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 @@ -3,6 +3,7 @@
#### New Features

#### Improvements
- Added connection (lost) indicator on the Medusa log ([10774](https://github.com/pymedusa/Medusa/pull/10774))

#### Fixes

Expand Down
6 changes: 5 additions & 1 deletion themes-default/slim/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,20 @@ export default new Vue({
setLoadingFinished(true);
setLoadingDisplay(false);
}, 2000);
this.connect(true);
});
}).catch(error => {
console.debug(error);
alert('Unable to connect to Medusa!'); // eslint-disable-line no-alert
this.connect(false);
});
}
},
methods: {
...mapActions({
getShows: 'getShows'
getShows: 'getShows',
connect: 'connect'

}),
...mapMutations([
'setLoadingDisplay',
Expand Down
19 changes: 17 additions & 2 deletions themes-default/slim/src/components/app-header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
<span class="icon-bar" />
<span class="icon-bar" />
</button>
<app-link class="navbar-brand" href="home/" title="Medusa"><img alt="Medusa" src="images/medusa.png" style="height: 50px;" class="img-responsive pull-left"></app-link>
<app-link v-if="isConnected || !socketIsConnected" class="navbar-brand" style="position: relative" title="Medusa">
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this supposed to be !isConnected?

Right now I always get a disconnected icon and so clicking on the logo refreshes the page.

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 fixed that in a PR that came after

Copy link
Contributor

Choose a reason for hiding this comment

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

Was broken on my end. Had the fixed version, but my Synology Reverse Proxy didn't forward it correctly without some additional config.

https://mlohr.com/websockets-for-synology-dsm/

<img alt="Medusa" src="images/medusa.png" style="height: 50px;" class="img-responsive pull-left" @click="reloadPage">
<img alt="disconnected" src="images/no16.png" class="disconnected spin-hover-90">
</app-link>
<app-link v-else class="navbar-brand" href="home/" title="Medusa"><img alt="Medusa" src="images/medusa.png" style="height: 50px;" class="img-responsive pull-left"></app-link>
</div>
<div v-if="isAuthenticated" class="collapse navbar-collapse" id="main_nav">
<ul class="nav navbar-nav navbar-right navbar-mobile">
Expand Down Expand Up @@ -123,7 +127,9 @@ export default {
isAuthenticated: state => state.auth.isAuthenticated,
username: state => state.auth.user.username,
warningLevel: state => state.config.general.logs.loggingLevels.warning,
client: state => state.auth.client
client: state => state.auth.client,
isConnected: state => state.auth.isConnected,
socketIsConnected: state => state.socket.isConnected
}),
/**
* Moved into a computed, so it's easier to mock in Jest.
Expand Down Expand Up @@ -304,6 +310,9 @@ export default {
'Error trying to update plex'
);
}
},
reloadPage() {
location.reload();
}
}
};
Expand Down Expand Up @@ -350,4 +359,10 @@ export default {
transform: translateX(-6rem);
}
}

.disconnected {
position: absolute;
right: 1rem;
bottom: 0.5rem;
}
</style>
1 change: 1 addition & 0 deletions themes-default/slim/src/components/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export default {
@use '../style/modal.scss';
@use '../style/vue-tags.scss';
@use '../style/back-arrow.scss';
@use '../style/spin.scss';

#app {
padding-top: 4rem;
Expand Down
4 changes: 2 additions & 2 deletions themes-default/slim/src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ Vue.use(VueNativeSock, websocketUrl, {
store,
format: 'json',
reconnection: true, // (Boolean) whether to reconnect automatically (false)
reconnectionAttempts: 2, // (Number) number of reconnection attempts before giving up (Infinity),
reconnectionDelay: 1000, // (Number) how long to initially wait before attempting a new (1000)
reconnectionAttempts: 25, // (Number) number of reconnection attempts before giving up (Infinity),
reconnectionDelay: 2500, // (Number) how long to initially wait before attempting a new (1000)
passToStoreHandler, // (Function|<false-y>) Handler for events triggered by the WebSocket (false)
mutations: {
SOCKET_ONOPEN,
Expand Down
8 changes: 8 additions & 0 deletions themes-default/slim/src/store/modules/auth.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
AUTHENTICATE,
CONNECT,
LOGIN_PENDING,
LOGIN_SUCCESS,
LOGIN_FAILED,
Expand All @@ -12,6 +13,7 @@ import VueJwtDecode from 'vue-jwt-decode';

const state = {
isAuthenticated: false,
isConnected: false,
user: {},
tokens: {
access: null,
Expand Down Expand Up @@ -48,6 +50,9 @@ const mutations = {
[AUTHENTICATE](state, client) {
state.client = client;
state.tokens.access = client.token;
},
[CONNECT](state, value) {
state.isConnected = value;
}
};

Expand Down Expand Up @@ -92,6 +97,9 @@ const actions = {
resolve();
});
});
},
connect({ commit }, connected) {
commit(CONNECT, connected);
}
};

Expand Down
2 changes: 2 additions & 0 deletions themes-default/slim/src/store/mutation-types.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const AUTHENTICATE = '🔒 Authenticating';
const CONNECT = '🔒 🔗 Connected';
const LOGIN_PENDING = '🔒 Logging in';
const LOGIN_SUCCESS = '🔒 ✅ Login Successful';
const LOGIN_FAILED = '🔒 ❌ Login Failed';
Expand Down Expand Up @@ -49,6 +50,7 @@ const ADD_SCHEDULE = '📅 Schedule information added';

export {
AUTHENTICATE,
CONNECT,
LOGIN_PENDING,
LOGIN_SUCCESS,
LOGIN_FAILED,
Expand Down
13 changes: 13 additions & 0 deletions themes-default/slim/src/style/spin.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.spin-hover-90:hover {
animation: spin-90 0.3s linear;
}

@keyframes spin-90 {
from {
transform: rotate(0deg);
}

to {
transform: rotate(90deg);
}
}
1 change: 1 addition & 0 deletions themes-default/slim/test/__fixtures__/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -1539,6 +1539,7 @@
},
"auth": {
"isAuthenticated": true,
"isConnected": true,
"user": {
"username": "admin"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ exports[`AppHeader.test.js renders 1`] = `

<app-link-stub
class="navbar-brand"
href="home/"
placeholder="indexer-to-name"
style="position: relative;"
title="Medusa"
>
<img
Expand All @@ -54,6 +54,12 @@ exports[`AppHeader.test.js renders 1`] = `
src="images/medusa.png"
style="height: 50px;"
/>

<img
alt="disconnected"
class="disconnected spin-hover-90"
src="images/no16.png"
/>
</app-link-stub>
</div>

Expand Down
2 changes: 1 addition & 1 deletion themes/dark/assets/js/app.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading