Skip to content

Commit

Permalink
Merge branch 'master' into sunspec
Browse files Browse the repository at this point in the history
  • Loading branch information
rpochet authored Oct 6, 2023
2 parents 01a60cf + f5a6a0d commit df83005
Show file tree
Hide file tree
Showing 58 changed files with 3,186 additions and 46 deletions.
12 changes: 12 additions & 0 deletions front/src/actions/dashboard/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function createActions(store) {
const actions = {
setFullScreen(state, fullScreen) {
store.setState({
fullScreen
});
}
};
return actions;
}

export default createActions;
Binary file added front/src/assets/integrations/cover/melcloud.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions front/src/components/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ import TuyaEditPage from '../routes/integration/all/tuya/edit-page';
import TuyaSetupPage from '../routes/integration/all/tuya/setup-page';
import TuyaDiscoverPage from '../routes/integration/all/tuya/discover-page';

// MELCloud integration
import MELCloudPage from '../routes/integration/all/melcloud/device-page';
import MELCloudEditPage from '../routes/integration/all/melcloud/edit-page';
import MELCloudSetupPage from '../routes/integration/all/melcloud/setup-page';
import MELCloudDiscoverPage from '../routes/integration/all/melcloud/discover-page';

const defaultState = getDefaultState();
const store = createStore(defaultState);

Expand Down Expand Up @@ -266,6 +272,11 @@ const AppRouter = connect(
<TuyaDiscoverPage path="/dashboard/integration/device/tuya/discover" />
<TuyaSetupPage path="/dashboard/integration/device/tuya/setup" />

<MELCloudPage path="/dashboard/integration/device/melcloud" />
<MELCloudEditPage path="/dashboard/integration/device/melcloud/edit/:deviceSelector" />
<MELCloudDiscoverPage path="/dashboard/integration/device/melcloud/discover" />
<MELCloudSetupPage path="/dashboard/integration/device/melcloud/setup" />

<BluetoothDevicePage path="/dashboard/integration/device/bluetooth" />
<BluetoothEditDevicePage path="/dashboard/integration/device/bluetooth/:deviceSelector" />
<BluetoothSetupPage path="/dashboard/integration/device/bluetooth/setup" />
Expand Down
57 changes: 56 additions & 1 deletion front/src/config/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,61 @@
"conflictError": "Current device is already in Gladys."
}
},
"melcloud": {
"title": "MELCloud",
"description": "Control your MELCloud devices (works with the cloud)",
"deviceTab": "Devices",
"discoverTab": "MELCloud discover",
"setupTab": "Setup",
"discoverDeviceDescr": "Automatically scan MELCloud devices",
"nameLabel": "Device Name",
"namePlaceholder": "Enter the name of your device",
"modelLabel": "Model",
"roomLabel": "Room",
"saveButton": "Save",
"updateButton": "Update",
"alreadyCreatedButton": "Already created",
"deleteButton": "Delete",
"unmanagedModelButton": "Model not managed or available",
"status": {
"notConnected": "Gladys failed to connect to MELCloud cloud account, please go to ",
"setupPageLink": "MELCloud configuration page.",
"online": "Online",
"offline": "Offline"
},
"device": {
"title": "Devices in Gladys",
"updates": "Check updates",
"editButton": "Edit",
"noDeviceFound": "No MELCloud device found.",
"featuresLabel": "Features"
},
"discover": {
"title": "Devices detected on your MELCloud cloud account",
"description": "MELCloud devices are automatically discovered. Your eWeLink devices need to be added to your eWeLink cloud account before.",
"error": "Error discovering MELCloud devices. Please verify your credentials on Setup.",
"noDeviceFound": "No MELCloud device discovered.",
"scan": "Scan"
},
"setup": {
"title": "MELCloud configuration",
"description": "You can connect Gladys to your MELCloud account to control the related devices.",
"username": "Email",
"usernamePlaceholder": "Enter your MELCloud account email address",
"password": "Password",
"passwordPlaceholder": "Enter your MELCloud account password",
"saveLabel": "Save configuration",
"error": "An error occured while saving configuration.",
"connecting": "Configuration saved. Now connecting to your MELCloud cloud account...",
"connected": "Connected to the MELCloud cloud account with success !",
"connectionError": "Error while connecting, please check your configuration."
},
"error": {
"defaultError": "There was an error saving the device.",
"defaultDeletionError": "There was an error deleting the device.",
"conflictError": "Current device is already in Gladys."
}
},
"mqtt": {
"title": "MQTT",
"description": "Connect to a local or remote MQTT server",
Expand All @@ -826,7 +881,7 @@
"notFound": "Requested device not found.",
"backToList": "Back to device list",
"saveError": "Error saving or deleting device",
"saveConflictError": "Conflict: Are you sure all device feature external IDs are unique?",
"saveConflictError": "Conflict: Are you sure all external IDs are unique?",
"mostRecentValueAt": "Last value received {{mostRecentValueAt}}.",
"noValueReceived": "No value received."
},
Expand Down
58 changes: 57 additions & 1 deletion front/src/config/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,62 @@
"conflictError": "L'appareil actuel est déjà dans Gladys."
}
},
"melcloud": {
"title": "MELCloud",
"description": "Contrôler vos appareils MELCloud",
"deviceTab": "Appareils",
"discoverTab": "Découverte MELCloud",
"setupTab": "Configuration",
"discoverDeviceDescr": "Scanner automatiquement les appareils MELCloud",
"nameLabel": "Nom de l'appareil",
"namePlaceholder": "Entrez le nom de votre appareil",
"modelLabel": "Modèle",
"roomLabel": "Pièce",
"saveButton": "Sauvegarder",
"updateButton": "Mettre à jour",
"alreadyCreatedButton": "Déjà créé",
"deleteButton": "Supprimer",
"unmanagedModelButton": "Modèle non pris en charge ou non disponible",
"status": {
"notConnected": "Gladys n'a pas réussi à se connecter au compte MELCloud, plus d'informations sur la ",
"setupPageLink": "page de configuration MELCloud.",
"online": "En ligne",
"offline": "Hors ligne"
},
"device": {
"title": "Appareils MELCloud dans Gladys",
"updates": "Vérifier les mises à jour",
"editButton": "Editer",
"noDeviceFound": "Aucun appareil MELCloud trouvé.",
"featuresLabel": "Fonctionnalités"
},
"discover": {
"title": "Appareils détectés sur votre compte cloud MELCloud",
"description": "Les appareils MELCloud sont automatiquement découverts. Vos appareils MELCloud doivent être ajoutés à votre compte cloud MELCloud avant.",
"error": "Erreur de découverte des appareils MELCloud. Veuillez vérifier vos informations d'identification lors de l'installation.",
"noDeviceFound": "Aucun appareil MELCloud n'a été découvert.",
"scan": "Scanner"
},
"setup": {
"title": "Configuration MELCloud",
"description": "Vous pouvez connecter Gladys à votre compte cloud MELCloud pour commander les appareils associés.",
"username": "Email",
"usernamePlaceholder": "Entrez l'email du compte MELCloud",
"password": "Mot de passe",
"passwordPlaceholder": "Entrez le mot de passe utilisateur du compte MELCloud",
"saveLabel": "Enregistrer la configuration",
"error": "Une erreur s'est produite lors de la sauvegarde de la configuration.",
"connecting": "Configuration sauvegardée. Connexion à votre compte cloud MELCloud...",
"connected": "Connexion réussie au compte cloud MELCloud !",
"connectionError": "Erreur lors de la connexion, veuillez vérifier votre configuration."
},

"error": {
"defaultError": "Une erreur s'est produite lors de l'enregistrement de l'appareil.",
"defaultDeletionError": "Une erreur s'est produite lors de la suppression de l'appareil.",
"conflictError": "L'appareil actuel est déjà dans Gladys."
}
},
"mqtt": {
"title": "MQTT",
"description": "Connexion à un serveur MQTT, en local ou en distant.",
Expand All @@ -953,7 +1009,7 @@
"notFound": "Appareil introuvable.",
"backToList": "Retour à la liste des appareils",
"saveError": "Erreur lors de l'enregistrement ou de la suppression de l'appareil",
"saveConflictError": "Conflit : êtes-vous sûr que tous les IDs externes des fonctionnalités de l'appareil sont uniques ?",
"saveConflictError": "Conflit : êtes-vous sûr que tous les IDs externes sont uniques ?",
"mostRecentValueAt": "Dernière valeur reçue {{mostRecentValueAt}}.",
"noValueReceived": "Aucune valeur reçue."
},
Expand Down
5 changes: 5 additions & 0 deletions front/src/config/integrations/devices.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,10 @@
"key": "tuya",
"link": "tuya",
"img": "/assets/integrations/cover/tuya.jpg"
},
{
"key": "melcloud",
"link": "melcloud",
"img": "/assets/integrations/cover/melcloud.jpg"
}
]
24 changes: 13 additions & 11 deletions front/src/routes/dashboard/DashboardPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,19 @@ const DashboardPage = ({ children, ...props }) => (
</div>

<div class="page-options d-flex align-content-between flex-wrap">
{!props.dashboardNotConfigured && props.browserFullScreenCompatible && (
<button onClick={props.toggleFullScreen} class={cx('btn btn-outline-secondary ml-2 btn-sm')}>
<span>
{!props.fullScreen && <Text id="dashboard.enableFullScreen" />}
{props.fullScreen && <Text id="dashboard.disableFullScreen" />}{' '}
{!props.fullScreen && <i class="fe fe-maximize-2" />}
{props.fullScreen && <i class="fe fe-minimize-2" />}
</span>
</button>
)}
{props.currentDashboard && (
{!props.dashboardNotConfigured &&
props.browserFullScreenCompatible &&
!props.hideExitFullScreenButton && (
<button onClick={props.toggleFullScreen} class={cx('btn btn-outline-secondary ml-2 btn-sm')}>
<span>
{!props.fullScreen && <Text id="dashboard.enableFullScreen" />}
{props.fullScreen && <Text id="dashboard.disableFullScreen" />}{' '}
{!props.fullScreen && <i class="fe fe-maximize-2" />}
{props.fullScreen && <i class="fe fe-minimize-2" />}
</span>
</button>
)}
{props.currentDashboard && !props.hideExitFullScreenButton && (
<button onClick={props.editDashboard} class={cx('btn btn-outline-primary ml-2')}>
<span class={style.editDashboardText}>
<Text id="dashboard.editDashboardButton" />
Expand Down
55 changes: 38 additions & 17 deletions front/src/routes/dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { route } from 'preact-router';

import DashboardPage from './DashboardPage';
import GatewayAccountExpired from '../../components/gateway/GatewayAccountExpired';
import actions from '../../actions/dashboard';
import get from 'get-value';

class Dashboard extends Component {
Expand Down Expand Up @@ -76,6 +77,16 @@ class Dashboard extends Component {
}
};

checkIfFullScreenParameterIsHere = () => {
if (this.props.fullscreen === 'force') {
try {
this.switchToFullScreen();
} catch (e) {
console.error(e);
}
}
};

init = async () => {
await this.getDashboards();
if (this.state.currentDashboardSelector) {
Expand All @@ -101,26 +112,34 @@ class Dashboard extends Component {
return document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement;
};

switchToFullScreen = () => {
if (document.documentElement.requestFullscreen) {
// chrome & firefox
document.documentElement.requestFullscreen();
} else if (document.documentElement.webkitRequestFullscreen) {
// safari
document.documentElement.webkitRequestFullscreen();
}
this.props.setFullScreen(true);
};

exitFullScreen = () => {
if (document.exitFullscreen) {
// chrome & firefox
document.exitFullscreen();
} else if (document.webkitExitFullscreen) {
// safari
document.webkitExitFullscreen();
}
this.props.setFullScreen(false);
};

toggleFullScreen = () => {
const isFullScreen = this.isFullScreen();
if (!isFullScreen) {
if (document.documentElement.requestFullscreen) {
// chrome & firefox
document.documentElement.requestFullscreen();
} else if (document.documentElement.webkitRequestFullscreen) {
// safari
document.documentElement.webkitRequestFullscreen();
}
this.props.setFullScreen(true);
this.switchToFullScreen();
} else {
if (document.exitFullscreen) {
// chrome & firefox
document.exitFullscreen();
} else if (document.webkitExitFullscreen) {
// safari
document.webkitExitFullscreen();
}
this.props.setFullScreen(false);
this.exitFullScreen();
}
};

Expand Down Expand Up @@ -149,6 +168,7 @@ class Dashboard extends Component {
document.addEventListener('webkitfullscreenchange', this.onFullScreenChange, false);
document.addEventListener('mozfullscreenchange', this.onFullScreenChange, false);
document.addEventListener('click', this.closeDashboardDropdown, true);
this.checkIfFullScreenParameterIsHere();
}

componentDidUpdate(prevProps) {
Expand Down Expand Up @@ -204,9 +224,10 @@ class Dashboard extends Component {
editDashboard={this.editDashboard}
toggleFullScreen={this.toggleFullScreen}
fullScreen={props.fullScreen}
hideExitFullScreenButton={props.fullscreen === 'force'}
/>
);
}
}

export default connect('user,fullScreen,currentUrl,httpClient,gatewayAccountExpired', {})(Dashboard);
export default connect('user,fullScreen,currentUrl,httpClient,gatewayAccountExpired', actions)(Dashboard);
Loading

0 comments on commit df83005

Please sign in to comment.