diff --git a/src/app.jsx b/src/app.jsx index 64c4d04..ae5ebe5 100644 --- a/src/app.jsx +++ b/src/app.jsx @@ -31,11 +31,13 @@ export class Application extends React.Component { } componentDidMount() { + const storageHidedCards = localStorage.getItem('hidedCards'); + const hidedCards = storageHidedCards != null && storageHidedCards !== '' ? storageHidedCards.split(',') : []; const intervalId = setInterval(() => { if (!this.state.isShowBtnInstall && !this.state.isError) this.loadSensors(); }, 1000); - this.setState({ intervalId, hidedCards: localStorage.getItem('hidedCards') }); + this.setState({ intervalId, hidedCards }); } componentWillUnmount() { @@ -142,7 +144,6 @@ export class Application extends React.Component { Object.keys(isExpanded).forEach((element) => { isExpanded[element] = checked; }); - console.log(this.state.isExpanded, isExpanded); this.setState({ isExpanded, expandAllCards: checked }); }; @@ -176,7 +177,6 @@ export class Application extends React.Component { this.setState({ isShowLoading: true }); cockpit.spawn(this.installCmd, { err: "message", superuser: "require" }) .done((sucess) => { - console.log('instalou ?'); this.setState({ isShowLoading: false, isShowBtnInstall: false, alert: null }); cockpit.spawn(["sensors-detect", "--auto"], { err: "message", superuser: "require" }) .done((sucess) => { @@ -189,7 +189,6 @@ export class Application extends React.Component { }); }) .fail((err) => { - console.log('erro ?'); this.setState({ isShowLoading: false, isShowBtnInstall: false }); this.setAlert(err.message, 'warning'); }); @@ -215,22 +214,26 @@ export class Application extends React.Component { }; handleOnExpand = (event, id) => { - // eslint-disable-next-line no-console - const isExpanded = this.state.isExpanded; isExpanded[id] = !isExpanded[id]; - console.log(id, this.state.isExpanded, isExpanded); this.setState({ isExpanded }); }; hideCard(cardId) { - const hidedCards = this.state.hidedCards.push(cardId); - localStorage.setItem('hidedCards', hidedCards) + const hidedCards = this.state.hidedCards; + hidedCards.push(cardId); + localStorage.setItem('hidedCards', hidedCards); + this.setState({ hidedCards }); + } + + handleShowHidedCards() { + const hidedCards = []; + localStorage.setItem('hidedCards', hidedCards); this.setState({ hidedCards }); } render() { - const { sensors, alert, fahrenheitChecked, isShowBtnInstall, isShowLoading, isExpanded, expandAllCards } = this.state; + const { sensors, alert, fahrenheitChecked, isShowBtnInstall, isShowLoading, isExpanded, expandAllCards, hidedCards } = this.state; return ( <> @@ -254,14 +257,24 @@ export class Application extends React.Component { {isShowLoading ? : <>} {alert != null ? {alert.msg} : <>} {isShowBtnInstall ? : <>} + {hidedCards.length > 0 ? : <>} {sensors !== null - ? Object.entries(sensors).map((key, keyIndex) => -
+ ? Object.entries(sensors).map((key, keyIndex) => { + if (hidedCards.includes(key[0])) { + return (''); + } + return ( - {key[0]} + {key[0]} + + + {key[1].Adapter} + {Object.entries(key[1]).map((item, itemIndex) => { if (itemIndex === 0) return ""; @@ -269,8 +282,12 @@ export class Application extends React.Component { if (isExpanded[chave] === undefined) { isExpanded[chave] = false; } + if (hidedCards.includes(chave)) { + return (''); + } return ( + {item[0]} + {this.setIcon(Object.keys(item[1])[0])} {this.adjustValue(Object.keys(item[1])[0], Object.values(item[1])[0])} @@ -298,13 +318,8 @@ export class Application extends React.Component { -
- - -
-
+ ); + } ) : ''}