forked from vergnet/application-amicale
Updated proxiwash to match v2 API
This commit is contained in:
parent
b1e3fe6658
commit
23bc034b34
6 changed files with 68 additions and 41 deletions
|
@ -5,9 +5,11 @@ import ProxiwashConstants from "../../../constants/ProxiwashConstants";
|
||||||
import i18n from "i18n-js";
|
import i18n from "i18n-js";
|
||||||
import AprilFoolsManager from "../../../managers/AprilFoolsManager";
|
import AprilFoolsManager from "../../../managers/AprilFoolsManager";
|
||||||
import * as Animatable from "react-native-animatable";
|
import * as Animatable from "react-native-animatable";
|
||||||
|
import type {CustomTheme} from "../../../managers/ThemeManager";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
item: Object,
|
item: Object,
|
||||||
|
theme: CustomTheme,
|
||||||
onPress: Function,
|
onPress: Function,
|
||||||
isWatched: boolean,
|
isWatched: boolean,
|
||||||
isDryer: boolean,
|
isDryer: boolean,
|
||||||
|
@ -53,20 +55,24 @@ class ProxiwashListItem extends React.Component<Props> {
|
||||||
}
|
}
|
||||||
|
|
||||||
updateStateStrings() {
|
updateStateStrings() {
|
||||||
this.stateStrings[ProxiwashConstants.machineStates.TERMINE] = i18n.t('proxiwashScreen.states.finished');
|
this.stateStrings[ProxiwashConstants.machineStates.AVAILABLE] = i18n.t('proxiwashScreen.states.ready');
|
||||||
this.stateStrings[ProxiwashConstants.machineStates.DISPONIBLE] = i18n.t('proxiwashScreen.states.ready');
|
this.stateStrings[ProxiwashConstants.machineStates.RUNNING] = i18n.t('proxiwashScreen.states.running');
|
||||||
this.stateStrings[ProxiwashConstants.machineStates["EN COURS"]] = i18n.t('proxiwashScreen.states.running');
|
this.stateStrings[ProxiwashConstants.machineStates.RUNNING_NOT_STARTED] = i18n.t('proxiwashScreen.states.runningNotStarted');
|
||||||
this.stateStrings[ProxiwashConstants.machineStates.HS] = i18n.t('proxiwashScreen.states.broken');
|
this.stateStrings[ProxiwashConstants.machineStates.FINISHED] = i18n.t('proxiwashScreen.states.finished');
|
||||||
this.stateStrings[ProxiwashConstants.machineStates.ERREUR] = i18n.t('proxiwashScreen.states.error');
|
this.stateStrings[ProxiwashConstants.machineStates.UNAVAILABLE] = i18n.t('proxiwashScreen.states.broken');
|
||||||
|
this.stateStrings[ProxiwashConstants.machineStates.ERROR] = i18n.t('proxiwashScreen.states.error');
|
||||||
|
this.stateStrings[ProxiwashConstants.machineStates.UNKNOWN] = i18n.t('proxiwashScreen.states.unknown');
|
||||||
}
|
}
|
||||||
|
|
||||||
updateStateColors() {
|
updateStateColors() {
|
||||||
const colors = this.props.theme.colors;
|
const colors = this.props.theme.colors;
|
||||||
this.stateColors[ProxiwashConstants.machineStates.TERMINE] = colors.proxiwashFinishedColor;
|
this.stateColors[ProxiwashConstants.machineStates.AVAILABLE] = colors.proxiwashReadyColor;
|
||||||
this.stateColors[ProxiwashConstants.machineStates.DISPONIBLE] = colors.proxiwashReadyColor;
|
this.stateColors[ProxiwashConstants.machineStates.RUNNING] = colors.proxiwashRunningColor;
|
||||||
this.stateColors[ProxiwashConstants.machineStates["EN COURS"]] = colors.proxiwashRunningColor;
|
this.stateColors[ProxiwashConstants.machineStates.RUNNING_NOT_STARTED] = colors.proxiwashRunningNotStartedColor;
|
||||||
this.stateColors[ProxiwashConstants.machineStates.HS] = colors.proxiwashBrokenColor;
|
this.stateColors[ProxiwashConstants.machineStates.FINISHED] = colors.proxiwashFinishedColor;
|
||||||
this.stateColors[ProxiwashConstants.machineStates.ERREUR] = colors.proxiwashErrorColor;
|
this.stateColors[ProxiwashConstants.machineStates.UNAVAILABLE] = colors.proxiwashBrokenColor;
|
||||||
|
this.stateColors[ProxiwashConstants.machineStates.ERROR] = colors.proxiwashErrorColor;
|
||||||
|
this.stateColors[ProxiwashConstants.machineStates.UNKNOWN] = colors.proxiwashUnknownColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
onListItemPress = () => this.props.onPress(this.title, this.props.item, this.props.isDryer);
|
onListItemPress = () => this.props.onPress(this.title, this.props.item, this.props.isDryer);
|
||||||
|
@ -75,14 +81,14 @@ class ProxiwashListItem extends React.Component<Props> {
|
||||||
const props = this.props;
|
const props = this.props;
|
||||||
const colors = props.theme.colors;
|
const colors = props.theme.colors;
|
||||||
const machineState = props.item.state;
|
const machineState = props.item.state;
|
||||||
const isRunning = ProxiwashConstants.machineStates[machineState] === ProxiwashConstants.machineStates["EN COURS"];
|
const isRunning = machineState === ProxiwashConstants.machineStates.RUNNING;
|
||||||
const isReady = ProxiwashConstants.machineStates[machineState] === ProxiwashConstants.machineStates.DISPONIBLE;
|
const isReady = machineState === ProxiwashConstants.machineStates.AVAILABLE;
|
||||||
const description = isRunning ? props.item.startTime + '/' + props.item.endTime : '';
|
const description = isRunning ? props.item.startTime + '/' + props.item.endTime : '';
|
||||||
const stateIcon = ProxiwashConstants.stateIcons[machineState];
|
const stateIcon = ProxiwashConstants.stateIcons[machineState];
|
||||||
const stateString = this.stateStrings[ProxiwashConstants.machineStates[machineState]];
|
const stateString = this.stateStrings[machineState];
|
||||||
const progress = isRunning
|
const progress = isRunning
|
||||||
? props.item.donePercent !== ''
|
? props.item.donePercent !== ''
|
||||||
? parseInt(props.item.donePercent) / 100
|
? parseFloat(props.item.donePercent) / 100
|
||||||
: 0
|
: 0
|
||||||
: 1;
|
: 1;
|
||||||
|
|
||||||
|
@ -123,7 +129,7 @@ class ProxiwashListItem extends React.Component<Props> {
|
||||||
height: props.height
|
height: props.height
|
||||||
}}
|
}}
|
||||||
progress={progress}
|
progress={progress}
|
||||||
color={this.stateColors[ProxiwashConstants.machineStates[machineState]]}
|
color={this.stateColors[machineState]}
|
||||||
/>
|
/>
|
||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
|
@ -140,7 +146,7 @@ class ProxiwashListItem extends React.Component<Props> {
|
||||||
<View style={{flexDirection: 'row',}}>
|
<View style={{flexDirection: 'row',}}>
|
||||||
<View style={{justifyContent: 'center',}}>
|
<View style={{justifyContent: 'center',}}>
|
||||||
<Text style={
|
<Text style={
|
||||||
ProxiwashConstants.machineStates[machineState] === ProxiwashConstants.machineStates.TERMINE ?
|
machineState === ProxiwashConstants.machineStates.FINISHED ?
|
||||||
{fontWeight: 'bold',} : {}}
|
{fontWeight: 'bold',} : {}}
|
||||||
>
|
>
|
||||||
{stateString}
|
{stateString}
|
||||||
|
|
|
@ -1,16 +1,20 @@
|
||||||
export default {
|
export default {
|
||||||
machineStates: {
|
machineStates: {
|
||||||
"TERMINE": "0",
|
"AVAILABLE": 0,
|
||||||
"DISPONIBLE": "1",
|
"RUNNING": 1,
|
||||||
"EN COURS": "2",
|
"RUNNING_NOT_STARTED": 2,
|
||||||
"HS": "3",
|
"FINISHED": 3,
|
||||||
"ERREUR": "4"
|
"UNAVAILABLE": 4,
|
||||||
|
"ERROR": 5,
|
||||||
|
"UNKNOWN": 6,
|
||||||
},
|
},
|
||||||
stateIcons: {
|
stateIcons: {
|
||||||
"TERMINE": 'check-circle',
|
0: 'radiobox-blank',
|
||||||
"DISPONIBLE": 'radiobox-blank',
|
1: 'progress-check',
|
||||||
"EN COURS": 'progress-check',
|
2: 'alert-circle-outline',
|
||||||
"HS": 'alert-octagram-outline',
|
3: 'check-circle',
|
||||||
"ERREUR": 'alert'
|
4: 'alert-octagram-outline',
|
||||||
|
5: 'alert',
|
||||||
|
6: 'help-circle-outline',
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -31,9 +31,11 @@ export type CustomTheme = {
|
||||||
proxiwashFinishedColor: string,
|
proxiwashFinishedColor: string,
|
||||||
proxiwashReadyColor: string,
|
proxiwashReadyColor: string,
|
||||||
proxiwashRunningColor: string,
|
proxiwashRunningColor: string,
|
||||||
|
proxiwashRunningNotStartedColor: string,
|
||||||
proxiwashRunningBgColor: string,
|
proxiwashRunningBgColor: string,
|
||||||
proxiwashBrokenColor: string,
|
proxiwashBrokenColor: string,
|
||||||
proxiwashErrorColor: string,
|
proxiwashErrorColor: string,
|
||||||
|
proxiwashUnknownColor: string,
|
||||||
|
|
||||||
// Screens
|
// Screens
|
||||||
planningColor: string,
|
planningColor: string,
|
||||||
|
@ -100,9 +102,11 @@ export default class ThemeManager {
|
||||||
proxiwashFinishedColor: "#a5dc9d",
|
proxiwashFinishedColor: "#a5dc9d",
|
||||||
proxiwashReadyColor: "transparent",
|
proxiwashReadyColor: "transparent",
|
||||||
proxiwashRunningColor: "#a0ceff",
|
proxiwashRunningColor: "#a0ceff",
|
||||||
|
proxiwashRunningNotStartedColor: "#c9e0ff",
|
||||||
proxiwashRunningBgColor: "#c7e3ff",
|
proxiwashRunningBgColor: "#c7e3ff",
|
||||||
proxiwashBrokenColor: "#8e8e8e",
|
proxiwashBrokenColor: "#ffa8a2",
|
||||||
proxiwashErrorColor: "rgba(204,7,0,0.31)#e35f57",
|
proxiwashErrorColor: "#ffa8a2",
|
||||||
|
proxiwashUnknownColor: "#b6b6b6",
|
||||||
|
|
||||||
// Screens
|
// Screens
|
||||||
planningColor: '#d9b10a',
|
planningColor: '#d9b10a',
|
||||||
|
@ -158,9 +162,11 @@ export default class ThemeManager {
|
||||||
proxiwashFinishedColor: "#31682c",
|
proxiwashFinishedColor: "#31682c",
|
||||||
proxiwashReadyColor: "transparent",
|
proxiwashReadyColor: "transparent",
|
||||||
proxiwashRunningColor: "#213c79",
|
proxiwashRunningColor: "#213c79",
|
||||||
|
proxiwashRunningNotStartedColor: "#1e263e",
|
||||||
proxiwashRunningBgColor: "#1a2033",
|
proxiwashRunningBgColor: "#1a2033",
|
||||||
proxiwashBrokenColor: "#656565",
|
proxiwashBrokenColor: "#7e2e2f",
|
||||||
proxiwashErrorColor: "#7e2e2f",
|
proxiwashErrorColor: "#7e2e2f",
|
||||||
|
proxiwashUnknownColor: "#535353",
|
||||||
|
|
||||||
// Screens
|
// Screens
|
||||||
planningColor: '#d99e09',
|
planningColor: '#d99e09',
|
||||||
|
|
|
@ -20,7 +20,7 @@ import {StackNavigationProp} from "@react-navigation/stack";
|
||||||
import {getCleanedMachineWatched, getMachineEndDate, isMachineWatched} from "../../utils/Proxiwash";
|
import {getCleanedMachineWatched, getMachineEndDate, isMachineWatched} from "../../utils/Proxiwash";
|
||||||
import {Modalize} from "react-native-modalize";
|
import {Modalize} from "react-native-modalize";
|
||||||
|
|
||||||
const DATA_URL = "https://etud.insa-toulouse.fr/~amicale_app/washinsa/washinsa.json";
|
const DATA_URL = "https://etud.insa-toulouse.fr/~amicale_app/v2/washinsa/washinsa_data.json";
|
||||||
|
|
||||||
let modalStateStrings = {};
|
let modalStateStrings = {};
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ export type Machine = {
|
||||||
endTime: string,
|
endTime: string,
|
||||||
donePercent: string,
|
donePercent: string,
|
||||||
remainingTime: string,
|
remainingTime: string,
|
||||||
|
program: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
@ -75,11 +76,13 @@ class ProxiwashScreen extends React.Component<Props, State> {
|
||||||
*/
|
*/
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
modalStateStrings[ProxiwashConstants.machineStates.TERMINE] = i18n.t('proxiwashScreen.modal.finished');
|
modalStateStrings[ProxiwashConstants.machineStates.AVAILABLE] = i18n.t('proxiwashScreen.modal.ready');
|
||||||
modalStateStrings[ProxiwashConstants.machineStates.DISPONIBLE] = i18n.t('proxiwashScreen.modal.ready');
|
modalStateStrings[ProxiwashConstants.machineStates.RUNNING] = i18n.t('proxiwashScreen.modal.running');
|
||||||
modalStateStrings[ProxiwashConstants.machineStates["EN COURS"]] = i18n.t('proxiwashScreen.modal.running');
|
modalStateStrings[ProxiwashConstants.machineStates.RUNNING_NOT_STARTED] = i18n.t('proxiwashScreen.modal.runningNotStarted');
|
||||||
modalStateStrings[ProxiwashConstants.machineStates.HS] = i18n.t('proxiwashScreen.modal.broken');
|
modalStateStrings[ProxiwashConstants.machineStates.FINISHED] = i18n.t('proxiwashScreen.modal.finished');
|
||||||
modalStateStrings[ProxiwashConstants.machineStates.ERREUR] = i18n.t('proxiwashScreen.modal.error');
|
modalStateStrings[ProxiwashConstants.machineStates.UNAVAILABLE] = i18n.t('proxiwashScreen.modal.broken');
|
||||||
|
modalStateStrings[ProxiwashConstants.machineStates.ERROR] = i18n.t('proxiwashScreen.modal.error');
|
||||||
|
modalStateStrings[ProxiwashConstants.machineStates.UNKNOWN] = i18n.t('proxiwashScreen.modal.unknown');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -264,9 +267,9 @@ class ProxiwashScreen extends React.Component<Props, State> {
|
||||||
icon: '',
|
icon: '',
|
||||||
onPress: undefined
|
onPress: undefined
|
||||||
};
|
};
|
||||||
let message = modalStateStrings[ProxiwashConstants.machineStates[item.state]];
|
let message = modalStateStrings[item.state];
|
||||||
const onPress = this.onSetupNotificationsPress.bind(this, item);
|
const onPress = this.onSetupNotificationsPress.bind(this, item);
|
||||||
if (ProxiwashConstants.machineStates[item.state] === ProxiwashConstants.machineStates["EN COURS"]) {
|
if (item.state === ProxiwashConstants.machineStates.RUNNING) {
|
||||||
let remainingTime = parseInt(item.remainingTime)
|
let remainingTime = parseInt(item.remainingTime)
|
||||||
if (remainingTime < 0)
|
if (remainingTime < 0)
|
||||||
remainingTime = 0;
|
remainingTime = 0;
|
||||||
|
@ -286,7 +289,7 @@ class ProxiwashScreen extends React.Component<Props, State> {
|
||||||
end: item.endTime,
|
end: item.endTime,
|
||||||
remaining: remainingTime
|
remaining: remainingTime
|
||||||
});
|
});
|
||||||
} else if (ProxiwashConstants.machineStates[item.state] === ProxiwashConstants.machineStates.DISPONIBLE) {
|
} else if (item.state === ProxiwashConstants.machineStates.AVAILABLE) {
|
||||||
if (isDryer)
|
if (isDryer)
|
||||||
message += '\n' + i18n.t('proxiwashScreen.dryersTariff');
|
message += '\n' + i18n.t('proxiwashScreen.dryersTariff');
|
||||||
else
|
else
|
||||||
|
@ -347,7 +350,7 @@ class ProxiwashScreen extends React.Component<Props, State> {
|
||||||
data = this.fetchedData.washers;
|
data = this.fetchedData.washers;
|
||||||
let count = 0;
|
let count = 0;
|
||||||
for (let i = 0; i < data.length; i++) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
if (ProxiwashConstants.machineStates[data[i].state] === ProxiwashConstants.machineStates["DISPONIBLE"])
|
if (data[i].state === ProxiwashConstants.machineStates.AVAILABLE)
|
||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
|
|
|
@ -182,8 +182,10 @@
|
||||||
"finished": "This machine is finished. If you started it, you can get back your laundry.",
|
"finished": "This machine is finished. If you started it, you can get back your laundry.",
|
||||||
"ready": "This machine is empty and ready to use.",
|
"ready": "This machine is empty and ready to use.",
|
||||||
"running": "This machine has been started at %{start} and will end at %{end}.\nRemaining time: %{remaining} min",
|
"running": "This machine has been started at %{start} and will end at %{end}.\nRemaining time: %{remaining} min",
|
||||||
|
"runningNotStarted": "This machine is ready but not started. Please make sure you pressed the start button.",
|
||||||
"broken": "This machine is broken and cannot be used. Thank you for your comprehension.",
|
"broken": "This machine is broken and cannot be used. Thank you for your comprehension.",
|
||||||
"error": "There has been an error and we are unable to get information from this machine. Sorry for the inconvenience.",
|
"error": "There has been an error and we are unable to get information from this machine. Sorry for the inconvenience.",
|
||||||
|
"unknown": "This machine is in an unknown state. Sorry for the inconvenience.",
|
||||||
"notificationErrorTitle": "Error",
|
"notificationErrorTitle": "Error",
|
||||||
"notificationErrorDescription": "Impossible to create notifications. Please make sure you enabled notifications then restart the app."
|
"notificationErrorDescription": "Impossible to create notifications. Please make sure you enabled notifications then restart the app."
|
||||||
},
|
},
|
||||||
|
@ -191,8 +193,10 @@
|
||||||
"finished": "FINISHED",
|
"finished": "FINISHED",
|
||||||
"ready": "READY",
|
"ready": "READY",
|
||||||
"running": "RUNNING",
|
"running": "RUNNING",
|
||||||
|
"runningNotStarted": "NOT STARTED",
|
||||||
"broken": "BROKEN",
|
"broken": "BROKEN",
|
||||||
"error": "ERROR"
|
"error": "ERROR",
|
||||||
|
"unknown": "UNKNOWN"
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"machineFinishedTitle": "Laundry Ready",
|
"machineFinishedTitle": "Laundry Ready",
|
||||||
|
|
|
@ -182,8 +182,10 @@
|
||||||
"finished": "Cette machine est terminée. Si vous l'avez démarrée, vous pouvez récupérer votre linge.",
|
"finished": "Cette machine est terminée. Si vous l'avez démarrée, vous pouvez récupérer votre linge.",
|
||||||
"ready": "Cette machine est vide et prête à être utilisée.",
|
"ready": "Cette machine est vide et prête à être utilisée.",
|
||||||
"running": "Cette machine a démarré à %{start} et terminera à %{end}.\nTemps restant : %{remaining} min",
|
"running": "Cette machine a démarré à %{start} et terminera à %{end}.\nTemps restant : %{remaining} min",
|
||||||
|
"runningNotStarted": "Cette machine est prête mais n'est pas démarrée. Assurez vous de bien avoir appuyé sur le bouton start.",
|
||||||
"broken": "Cette machine est hors service. Merci pour votre compréhension.",
|
"broken": "Cette machine est hors service. Merci pour votre compréhension.",
|
||||||
"error": "Il y a eu une erreur et il est impossible de récupérer les informations de cette machine. Veuillez nous excuser pour le gène occasionnée.",
|
"error": "Il y a eu une erreur et il est impossible de récupérer les informations de cette machine. Veuillez nous excuser pour le gène occasionnée.",
|
||||||
|
"unknown": "Cette machine est dans un état inconnu. Veuillez nous excuser pour ce problème.",
|
||||||
"notificationErrorTitle": "Erreur",
|
"notificationErrorTitle": "Erreur",
|
||||||
"notificationErrorDescription": "Impossible de créer les notifications. Merci de vérifier que vous avez activé les notifications puis redémarrez l'appli."
|
"notificationErrorDescription": "Impossible de créer les notifications. Merci de vérifier que vous avez activé les notifications puis redémarrez l'appli."
|
||||||
},
|
},
|
||||||
|
@ -191,8 +193,10 @@
|
||||||
"finished": "TERMINÉ",
|
"finished": "TERMINÉ",
|
||||||
"ready": "DISPONIBLE",
|
"ready": "DISPONIBLE",
|
||||||
"running": "EN COURS",
|
"running": "EN COURS",
|
||||||
|
"runningNotStarted": "NON DÉMARRÉE",
|
||||||
"broken": "HORS SERVICE",
|
"broken": "HORS SERVICE",
|
||||||
"error": "ERREUR"
|
"error": "ERREUR",
|
||||||
|
"unknown": "INCONNU"
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"machineFinishedTitle": "Linge prêt",
|
"machineFinishedTitle": "Linge prêt",
|
||||||
|
|
Loading…
Reference in a new issue