feat: start hide card funcionality

This commit is contained in:
Cristopfer Luis Viana da Silva 2024-02-05 15:04:38 -03:00
parent 6cc1d077be
commit 941147b1de

View file

@ -20,7 +20,7 @@
import cockpit from 'cockpit';
import React from 'react';
import { Alert, Card, CardTitle, CardHeader, CardBody, CardExpandableContent, Checkbox, Button, Spinner, Flex, FlexItem } from '@patternfly/react-core';
import { FanIcon, ThermometerHalfIcon, ChargingStationIcon, CpuIcon } from '@patternfly/react-icons/dist/esm/icons/';
import { FanIcon, ThermometerHalfIcon, ChargingStationIcon, CpuIcon, EyeSlashIcon } from '@patternfly/react-icons/dist/esm/icons/';
const _ = cockpit.gettext;
@ -35,7 +35,7 @@ export class Application extends React.Component {
if (!this.state.isShowBtnInstall && !this.state.isError)
this.loadSensors();
}, 1000);
this.setState({ intervalId });
this.setState({ intervalId, hidedCards: localStorage.getItem('hidedCards') });
}
componentWillUnmount() {
@ -225,7 +225,7 @@ export class Application extends React.Component {
hideCard(cardId) {
const hidedCards = this.state.hidedCards.push(cardId);
console.log(cardId, hidedCards);
localStorage.setItem('hidedCards', hidedCards)
this.setState({ hidedCards });
}
@ -257,6 +257,7 @@ export class Application extends React.Component {
</>
{sensors !== null
? Object.entries(sensors).map((key, keyIndex) =>
<div key={key}>
<Card key={key}>
<CardTitle>{key[0]}</CardTitle>
<CardBody>
@ -297,6 +298,13 @@ export class Application extends React.Component {
</Flex>
</CardBody>
</Card>
<div style={{ marginTop: '20px' }}>
<Button variant="plain" aria-label="Action" onClick={this.hideCard(key)}>
<EyeSlashIcon />
</Button>
</div>
</div>
)
: ''}
</CardBody>