feat: start hide card funcionality
This commit is contained in:
parent
6cc1d077be
commit
941147b1de
1 changed files with 51 additions and 43 deletions
14
src/app.jsx
14
src/app.jsx
|
|
@ -20,7 +20,7 @@
|
||||||
import cockpit from 'cockpit';
|
import cockpit from 'cockpit';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Alert, Card, CardTitle, CardHeader, CardBody, CardExpandableContent, Checkbox, Button, Spinner, Flex, FlexItem } from '@patternfly/react-core';
|
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;
|
const _ = cockpit.gettext;
|
||||||
|
|
||||||
|
|
@ -35,7 +35,7 @@ export class Application extends React.Component {
|
||||||
if (!this.state.isShowBtnInstall && !this.state.isError)
|
if (!this.state.isShowBtnInstall && !this.state.isError)
|
||||||
this.loadSensors();
|
this.loadSensors();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
this.setState({ intervalId });
|
this.setState({ intervalId, hidedCards: localStorage.getItem('hidedCards') });
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
|
|
@ -225,7 +225,7 @@ export class Application extends React.Component {
|
||||||
|
|
||||||
hideCard(cardId) {
|
hideCard(cardId) {
|
||||||
const hidedCards = this.state.hidedCards.push(cardId);
|
const hidedCards = this.state.hidedCards.push(cardId);
|
||||||
console.log(cardId, hidedCards);
|
localStorage.setItem('hidedCards', hidedCards)
|
||||||
this.setState({ hidedCards });
|
this.setState({ hidedCards });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -257,6 +257,7 @@ export class Application extends React.Component {
|
||||||
</>
|
</>
|
||||||
{sensors !== null
|
{sensors !== null
|
||||||
? Object.entries(sensors).map((key, keyIndex) =>
|
? Object.entries(sensors).map((key, keyIndex) =>
|
||||||
|
<div key={key}>
|
||||||
<Card key={key}>
|
<Card key={key}>
|
||||||
<CardTitle>{key[0]}</CardTitle>
|
<CardTitle>{key[0]}</CardTitle>
|
||||||
<CardBody>
|
<CardBody>
|
||||||
|
|
@ -297,6 +298,13 @@ export class Application extends React.Component {
|
||||||
</Flex>
|
</Flex>
|
||||||
</CardBody>
|
</CardBody>
|
||||||
</Card>
|
</Card>
|
||||||
|
<div style={{ marginTop: '20px' }}>
|
||||||
|
<Button variant="plain" aria-label="Action" onClick={this.hideCard(key)}>
|
||||||
|
<EyeSlashIcon />
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
: ''}
|
: ''}
|
||||||
</CardBody>
|
</CardBody>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue