🔌 Cleaned up styling for AirDC++ socket status
This commit is contained in:
@@ -38,18 +38,20 @@ function sleep(ms: number): Promise<NodeJS.Timeout> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const toggleAirDCPPSocketConnectionStatus =
|
export const toggleAirDCPPSocketConnectionStatus =
|
||||||
(status: String) => async (dispatch) => {
|
(status: String, payload?: any) => async (dispatch) => {
|
||||||
console.log("sanul", status);
|
console.log("sanul", status);
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case "connected":
|
case "connected":
|
||||||
dispatch({
|
dispatch({
|
||||||
type: AIRDCPP_SOCKET_CONNECTED,
|
type: AIRDCPP_SOCKET_CONNECTED,
|
||||||
|
data: payload,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "disconnected":
|
case "disconnected":
|
||||||
dispatch({
|
dispatch({
|
||||||
type: AIRDCPP_SOCKET_DISCONNECTED,
|
type: AIRDCPP_SOCKET_DISCONNECTED,
|
||||||
|
data: payload,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,10 @@ pre {
|
|||||||
margin-left: -300px;
|
margin-left: -300px;
|
||||||
min-width: 500px;
|
min-width: 500px;
|
||||||
}
|
}
|
||||||
|
.airdcpp-status {
|
||||||
|
min-width: 300px;
|
||||||
|
line-height: 1.7rem;
|
||||||
|
}
|
||||||
body {
|
body {
|
||||||
background: #454a59;
|
background: #454a59;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,16 +4,22 @@ import { DownloadProgressTick } from "./ComicDetail/DownloadProgressTick";
|
|||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import { isUndefined } from "lodash";
|
import { isUndefined } from "lodash";
|
||||||
|
import { format, fromUnixTime } from "date-fns";
|
||||||
|
|
||||||
const Navbar: React.FunctionComponent = (props) => {
|
const Navbar: React.FunctionComponent = (props) => {
|
||||||
const downloadProgressTick = useSelector(
|
const downloadProgressTick = useSelector(
|
||||||
(state: RootState) => state.airdcpp.downloadProgressData,
|
(state: RootState) => state.airdcpp.downloadProgressData,
|
||||||
);
|
);
|
||||||
|
|
||||||
const airDCPPSocketConnectionStatus = useSelector((state: RootState) => {
|
const airDCPPSocketConnectionStatus = useSelector(
|
||||||
console.log(state);
|
(state: RootState) => state.airdcpp.isAirDCPPSocketConnected,
|
||||||
return state.airdcpp.isAirDCPPSocketConnected;
|
);
|
||||||
});
|
const airDCPPSessionInfo = useSelector(
|
||||||
|
(state: RootState) => state.airdcpp.airDCPPSessionInfo,
|
||||||
|
);
|
||||||
|
const socketDisconnectionReason = useSelector(
|
||||||
|
(state: RootState) => state.airdcpp.socketDisconnectionReason,
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav className="navbar is-fixed-top">
|
<nav className="navbar is-fixed-top">
|
||||||
@@ -80,7 +86,7 @@ const Navbar: React.FunctionComponent = (props) => {
|
|||||||
{downloadProgressTick && <div className="pulsating-circle"></div>}
|
{downloadProgressTick && <div className="pulsating-circle"></div>}
|
||||||
</a>
|
</a>
|
||||||
{!isUndefined(downloadProgressTick) ? (
|
{!isUndefined(downloadProgressTick) ? (
|
||||||
<div className="navbar-dropdown download-progress-meter">
|
<div className="navbar-dropdown is-right">
|
||||||
<a className="navbar-item">
|
<a className="navbar-item">
|
||||||
<DownloadProgressTick data={downloadProgressTick} />
|
<DownloadProgressTick data={downloadProgressTick} />
|
||||||
</a>
|
</a>
|
||||||
@@ -90,13 +96,51 @@ const Navbar: React.FunctionComponent = (props) => {
|
|||||||
{/* AirDC++ socket connection status */}
|
{/* AirDC++ socket connection status */}
|
||||||
<div className="navbar-item has-dropdown is-hoverable">
|
<div className="navbar-item has-dropdown is-hoverable">
|
||||||
{airDCPPSocketConnectionStatus ? (
|
{airDCPPSocketConnectionStatus ? (
|
||||||
<a className="navbar-link is-arrowless has-text-success">
|
<>
|
||||||
<i className="fa-solid fa-bolt"></i>
|
<a className="navbar-link is-arrowless has-text-success">
|
||||||
</a>
|
<i className="fa-solid fa-bolt"></i>
|
||||||
|
</a>
|
||||||
|
<div className="navbar-dropdown pt-4 pr-2 pl-2 is-right airdcpp-status">
|
||||||
|
{/* AirDC++ Session Information */}
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Last login was{" "}
|
||||||
|
<span className="tag">
|
||||||
|
{format(
|
||||||
|
fromUnixTime(airDCPPSessionInfo.user.last_login),
|
||||||
|
"dd MMMM, yyyy",
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
<hr className="navbar-divider" />
|
||||||
|
<p>
|
||||||
|
<span className="tag has-text-success">
|
||||||
|
{airDCPPSessionInfo.user.username}
|
||||||
|
</span>
|
||||||
|
connected to{" "}
|
||||||
|
<span className="tag has-text-success">
|
||||||
|
{airDCPPSessionInfo.system_info.client_version}
|
||||||
|
</span>{" "}
|
||||||
|
with session ID{" "}
|
||||||
|
<span className="tag has-text-success">
|
||||||
|
{airDCPPSessionInfo.session_id}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
{/* <pre>{JSON.stringify(airDCPPSessionInfo, null, 2)}</pre> */}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
) : (
|
) : (
|
||||||
<a className="navbar-link is-arrowless has-text-danger">
|
<>
|
||||||
<i className="fa-solid fa-bolt"></i>
|
<a className="navbar-link is-arrowless has-text-danger">
|
||||||
</a>
|
<i className="fa-solid fa-bolt"></i>
|
||||||
|
</a>
|
||||||
|
<div className="navbar-dropdown pr-2 pl-2 is-right">
|
||||||
|
<pre>
|
||||||
|
{JSON.stringify(socketDisconnectionReason, null, 2)}
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -63,14 +63,20 @@ const AirDCPPSocketContextProvider = ({ children }) => {
|
|||||||
|
|
||||||
// connect and disconnect handlers
|
// connect and disconnect handlers
|
||||||
initializedAirDCPPSocket.onConnected = (sessionInfo) => {
|
initializedAirDCPPSocket.onConnected = (sessionInfo) => {
|
||||||
dispatch(toggleAirDCPPSocketConnectionStatus("connected"));
|
dispatch(toggleAirDCPPSocketConnectionStatus("connected", sessionInfo));
|
||||||
};
|
};
|
||||||
initializedAirDCPPSocket.onDisconnected = async (
|
initializedAirDCPPSocket.onDisconnected = async (
|
||||||
reason,
|
reason,
|
||||||
code,
|
code,
|
||||||
wasClean,
|
wasClean,
|
||||||
) => {
|
) => {
|
||||||
dispatch(toggleAirDCPPSocketConnectionStatus("disconnected"));
|
dispatch(
|
||||||
|
toggleAirDCPPSocketConnectionStatus("disconnected", {
|
||||||
|
reason,
|
||||||
|
code,
|
||||||
|
wasClean,
|
||||||
|
}),
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const socketConnectionInformation = await initializedAirDCPPSocket.connect(
|
const socketConnectionInformation = await initializedAirDCPPSocket.connect(
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ const initialState = {
|
|||||||
bundles: [],
|
bundles: [],
|
||||||
transfers: [],
|
transfers: [],
|
||||||
isAirDCPPSocketConnected: false,
|
isAirDCPPSocketConnected: false,
|
||||||
|
airDCPPSessionInfo: {},
|
||||||
|
socketDisconnectionReason: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
function airdcppReducer(state = initialState, action) {
|
function airdcppReducer(state = initialState, action) {
|
||||||
@@ -103,12 +105,14 @@ function airdcppReducer(state = initialState, action) {
|
|||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
isAirDCPPSocketConnected: true,
|
isAirDCPPSocketConnected: true,
|
||||||
|
airDCPPSessionInfo: action.data,
|
||||||
};
|
};
|
||||||
|
|
||||||
case AIRDCPP_SOCKET_DISCONNECTED:
|
case AIRDCPP_SOCKET_DISCONNECTED:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
isAirDCPPSocketConnected: false,
|
isAirDCPPSocketConnected: false,
|
||||||
|
socketDisconnectionReason: action.data,
|
||||||
};
|
};
|
||||||
case LOCATION_CHANGE:
|
case LOCATION_CHANGE:
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user