-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
storage: SMART support #19103
base: main
Are you sure you want to change the base?
storage: SMART support #19103
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/* | ||
* This file is part of Cockpit. | ||
* | ||
* Copyright (C) 2017 Red Hat, Inc. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a new file, should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. correct, we live in ${current_year} |
||
* | ||
* Cockpit is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation; either version 2.1 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Cockpit is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with Cockpit; If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import cockpit from "cockpit"; | ||
import React, { useState } from "react"; | ||
import * as timeformat from "timeformat.js"; | ||
|
||
import { Card, CardBody, CardHeader, CardTitle, DescriptionList, DescriptionListDescription, DescriptionListGroup, DescriptionListTerm } from "@patternfly/react-core"; | ||
import { Dropdown, DropdownItem, KebabToggle } from '@patternfly/react-core/dist/esm/deprecated/components/Dropdown/index.js'; | ||
|
||
const _ = cockpit.gettext; | ||
|
||
const selftestStatusDescription = { | ||
success: _("Successful"), | ||
aborted: _("Aborted"), | ||
interrupted: _("Interrupted"), | ||
fatal: _("Did not complete"), | ||
error_unknown: _("Failed (Unknown)"), | ||
error_electrical: _("Failed (Electrical)"), | ||
error_servo: _("Failed (Servo)"), | ||
error_read: _("Failed (Read)"), | ||
error_handling: _("Failed (Damaged)"), | ||
inprogress: _("In progress"), | ||
}; | ||
|
||
const SmartActions = ({ smartInfo }) => { | ||
const [isKebabOpen, setKebabOpen] = useState(false); | ||
const smartSelftestStatus = smartInfo.SmartSelftestStatus; | ||
Comment on lines
+42
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These 3 added lines are not executed by any test. Details |
||
|
||
const runSmartTest = async (type) => { | ||
await smartInfo.SmartSelftestStart(type, {}); | ||
Comment on lines
+46
to
+47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These 2 added lines are not executed by any test. Details |
||
}; | ||
|
||
const abortSmartTest = async () => { | ||
await smartInfo.SmartSelftestAbort({}); | ||
Comment on lines
+50
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These 2 added lines are not executed by any test. Details |
||
}; | ||
|
||
const actions = [ | ||
<DropdownItem key="run-short-test" | ||
isDisabled={smartSelftestStatus === "inprogress"} | ||
onClick={() => { setKebabOpen(false); runSmartTest('short') }}> | ||
{_("Run short test")} | ||
</DropdownItem>, | ||
<DropdownItem key="run-extended-test" | ||
isDisabled={smartSelftestStatus === "inprogress"} | ||
onClick={() => { setKebabOpen(false); runSmartTest('extended') }}> | ||
{_("Run extended test")} | ||
</DropdownItem>, | ||
<DropdownItem key="run-conveyance-test" | ||
isDisabled={smartSelftestStatus === "inprogress"} | ||
onClick={() => { setKebabOpen(false); runSmartTest('conveyance') }}> | ||
{_("Run conveyance test")} | ||
</DropdownItem>, | ||
Comment on lines
+54
to
+69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These 16 added lines are not executed by any test. Details |
||
]; | ||
|
||
if (smartInfo.SmartSelftestStatus === "inprogress") { | ||
actions.push( | ||
<DropdownItem key="abort-smart-test" | ||
onClick={() => { setKebabOpen(false); abortSmartTest('conveyance') }}> | ||
{_("Abort test")} | ||
</DropdownItem>, | ||
Comment on lines
+72
to
+77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These 6 added lines are not executed by any test. Details |
||
); | ||
} | ||
|
||
return ( | ||
<Dropdown toggle={<KebabToggle onToggle={(_, isOpen) => setKebabOpen(isOpen)} />} | ||
isPlain | ||
isOpen={isKebabOpen} | ||
position="right" | ||
id="smart-actions" | ||
dropdownItems={actions} /> | ||
Comment on lines
+81
to
+87
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These 7 added lines are not executed by any test. Details |
||
); | ||
}; | ||
|
||
export const SmartDetails = ({ smartInfo }) => { | ||
const SmartDetailRow = ({ title, value }) => { | ||
if (value === undefined) | ||
return null; | ||
Comment on lines
+91
to
+94
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These 4 added lines are not executed by any test. Details |
||
|
||
return ( | ||
<DescriptionListGroup> | ||
<DescriptionListTerm>{title}</DescriptionListTerm> | ||
<DescriptionListDescription>{value}</DescriptionListDescription> | ||
</DescriptionListGroup> | ||
Comment on lines
+96
to
+100
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These 5 added lines are not executed by any test. Details |
||
); | ||
}; | ||
|
||
return ( | ||
<Card> | ||
<CardHeader actions={{ actions: <SmartActions smartInfo={smartInfo} /> }}> | ||
<CardTitle component="h2">{_("S.M.A.R.T")}</CardTitle> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that's really something one can translate? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm force of habit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe in non-latin languages? Like chinese or russian or so? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, if in doubt, keep it translatable. I can't say I like the many dots, this looks a bit like a 90's superhero comic 😁 So please either "SMART", or at least make it consistent and add a period to the |
||
</CardHeader> | ||
<CardBody> | ||
<DescriptionList isHorizontal horizontalTermWidthModifier={{ default: '20ch' }}> | ||
<SmartDetailRow title={_("Power on hours")} value={cockpit.format(_("$0 hours"), Math.round(smartInfo.SmartPowerOnSeconds / 3600))} /> | ||
<SmartDetailRow title={_("Last updated")} value={timeformat.dateTime(new Date(smartInfo.SmartUpdated * 1000))} /> | ||
<SmartDetailRow title={_("Smart selftest status")} value={selftestStatusDescription[smartInfo.SmartSelftestStatus]} /> | ||
<SmartDetailRow title={_("Number of bad sectors")} value={smartInfo.SmartNumBadSectors} /> | ||
<SmartDetailRow title={_("Atributes failing")} value={smartInfo.SmartNumAttributesFailing} /> | ||
</DescriptionList> | ||
</CardBody> | ||
</Card> | ||
Comment on lines
+104
to
+118
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These 15 added lines are not executed by any test. Details |
||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These 3 added lines are not executed by any test. Details