fix: cockpit-sensors with correty base project
This commit is contained in:
parent
f9f2da6974
commit
57ad28ed58
13 changed files with 440 additions and 78 deletions
|
|
@ -16,7 +16,7 @@ test_task:
|
||||||
fix_kvm_script: sudo chmod 666 /dev/kvm
|
fix_kvm_script: sudo chmod 666 /dev/kvm
|
||||||
|
|
||||||
# test PO template generation
|
# test PO template generation
|
||||||
pot_build_script: make po/starter-kit.pot
|
pot_build_script: make po/sensors.pot
|
||||||
|
|
||||||
# chromium has too little /dev/shm, and we can't make that bigger
|
# chromium has too little /dev/shm, and we can't make that bigger
|
||||||
check_script: TEST_BROWSER=firefox TEST_JOBS=$(nproc) TEST_OS=$TEST_OS make check
|
check_script: TEST_BROWSER=firefox TEST_JOBS=$(nproc) TEST_OS=$TEST_OS make check
|
||||||
|
|
|
||||||
40
README.md
40
README.md
|
|
@ -1,3 +1,32 @@
|
||||||
|
# Cockpit Sensors
|
||||||
|
|
||||||
|
module that displays all data reported by lm-sensors
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
|
||||||
|
- Download the lastest [Sensors release](https://github.com/ocristopfer/cockpit-sensors/releases)
|
||||||
|
- Extract the content of dist folder to /usr/share/cockpit/sensors
|
||||||
|
- Check if Sensors tools is show on menu
|
||||||
|
|
||||||
|
- Installation script provided by [@subz390](https://github.com/subz390):
|
||||||
|
|
||||||
|
```shell
|
||||||
|
wget https://github.com/ocristopfer/cockpit-sensors/releases/latest/download/cockpit-sensors.tar.xz && \
|
||||||
|
tar -xf cockpit-sensors.tar.xz cockpit-sensors/dist && \
|
||||||
|
mv cockpit-sensors/dist /usr/share/cockpit/sensors && \
|
||||||
|
rm -r cockpit-sensors && \
|
||||||
|
rm cockpit-sensors.tar.xz
|
||||||
|
```
|
||||||
|
|
||||||
|
- .deb package:
|
||||||
|
https://github.com/ocristopfer/cockpit-sensors/releases/latest/download/cockpit-sensors.deb
|
||||||
|
|
||||||
|
# Prints
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
# Module created using Starter Kit
|
||||||
|
|
||||||
# Cockpit Starter Kit
|
# Cockpit Starter Kit
|
||||||
|
|
||||||
Scaffolding for a [Cockpit](https://cockpit-project.org/) module.
|
Scaffolding for a [Cockpit](https://cockpit-project.org/) module.
|
||||||
|
|
@ -12,7 +41,6 @@ On Fedora:
|
||||||
|
|
||||||
$ sudo dnf install gettext nodejs npm make
|
$ sudo dnf install gettext nodejs npm make
|
||||||
|
|
||||||
|
|
||||||
# Getting and building the source
|
# Getting and building the source
|
||||||
|
|
||||||
These commands check out the source and build it into the `dist/` directory:
|
These commands check out the source and build it into the `dist/` directory:
|
||||||
|
|
@ -156,7 +184,7 @@ To run the tests in the exact same way for upstream pull requests and for
|
||||||
[Fedora package update gating](https://docs.fedoraproject.org/en-US/ci/), the
|
[Fedora package update gating](https://docs.fedoraproject.org/en-US/ci/), the
|
||||||
tests are wrapped in the [FMF metadata format](https://github.com/teemtee/fmf)
|
tests are wrapped in the [FMF metadata format](https://github.com/teemtee/fmf)
|
||||||
for using with the [tmt test management tool](https://docs.fedoraproject.org/en-US/ci/tmt/).
|
for using with the [tmt test management tool](https://docs.fedoraproject.org/en-US/ci/tmt/).
|
||||||
Note that Packit tests can *not* run their own virtual machine images, thus
|
Note that Packit tests can _not_ run their own virtual machine images, thus
|
||||||
they only run [@nondestructive tests](https://github.com/cockpit-project/cockpit/blob/main/test/common/testlib.py).
|
they only run [@nondestructive tests](https://github.com/cockpit-project/cockpit/blob/main/test/common/testlib.py).
|
||||||
|
|
||||||
# Customizing
|
# Customizing
|
||||||
|
|
@ -201,7 +229,7 @@ which is run weekly or upon [manual request](https://github.com/cockpit-project/
|
||||||
|
|
||||||
# Further reading
|
# Further reading
|
||||||
|
|
||||||
* The [Starter Kit announcement](https://cockpit-project.org/blog/cockpit-starter-kit.html)
|
- The [Starter Kit announcement](https://cockpit-project.org/blog/cockpit-starter-kit.html)
|
||||||
blog post explains the rationale for this project.
|
blog post explains the rationale for this project.
|
||||||
* [Cockpit Deployment and Developer documentation](https://cockpit-project.org/guide/latest/)
|
- [Cockpit Deployment and Developer documentation](https://cockpit-project.org/guide/latest/)
|
||||||
* [Make your project easily discoverable](https://cockpit-project.org/blog/making-a-cockpit-application.html)
|
- [Make your project easily discoverable](https://cockpit-project.org/blog/making-a-cockpit-application.html)
|
||||||
|
|
|
||||||
17
org.cockpit-project.sensors.metainfo.xml
Normal file
17
org.cockpit-project.sensors.metainfo.xml
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<component type="addon">
|
||||||
|
<id>org.cockpit_project.sensors</id>
|
||||||
|
<metadata_license>CC0-1.0</metadata_license>
|
||||||
|
<name>Sensors</name>
|
||||||
|
<summary>Sensors cockpit module</summary>
|
||||||
|
<description>
|
||||||
|
<p>
|
||||||
|
Sensors cockpit module
|
||||||
|
</p>
|
||||||
|
</description>
|
||||||
|
<extends>org.cockpit_project.cockpit</extends>
|
||||||
|
<launchable type="cockpit-manifest">sensors</launchable>
|
||||||
|
<url type="homepage">https://github.com/ocristopfer/cockpit-sensors</url>
|
||||||
|
<url type="bugtracker">https://github.com/ocristopfer/cockpit-sensors/issues</url>
|
||||||
|
<update_contact>cockpit-devel_AT_lists.fedorahosted.org</update_contact>
|
||||||
|
</component>
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<component type="addon">
|
|
||||||
<id>org.cockpit_project.starter_kit</id>
|
|
||||||
<metadata_license>CC0-1.0</metadata_license>
|
|
||||||
<name>Starter Kit</name>
|
|
||||||
<summary>Scaffolding for a cockpit module</summary>
|
|
||||||
<description>
|
|
||||||
<p>
|
|
||||||
Scaffolding for a cockpit module.
|
|
||||||
</p>
|
|
||||||
</description>
|
|
||||||
<extends>org.cockpit_project.cockpit</extends>
|
|
||||||
<launchable type="cockpit-manifest">starter-kit</launchable>
|
|
||||||
<url type="homepage">https://github.com/cockpit-project/starter-kit</url>
|
|
||||||
<url type="bugtracker">https://github.com/cockpit-project/starter-kit/issues</url>
|
|
||||||
<update_contact>cockpit-devel_AT_lists.fedorahosted.org</update_contact>
|
|
||||||
</component>
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
{
|
{
|
||||||
"name": "starter-kit",
|
"name": "sensors",
|
||||||
"description": "Scaffolding for a cockpit module",
|
"description": "Module that displays all data reported by lm-sensors",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": "git@github.com:cockpit/starter-kit.git",
|
"repository": "git@github.com:ocristopfer/cockpit-sensors.git",
|
||||||
"author": "",
|
"author": "https://github.com/ocristopfer",
|
||||||
"license": "LGPL-2.1",
|
"license": "LGPL-2.1",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 16"
|
"node": ">= 16"
|
||||||
|
|
|
||||||
10
packaging/cockpit-sensors.control
Normal file
10
packaging/cockpit-sensors.control
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
Package: cockpit-sensors
|
||||||
|
Name: Cockpit Sensors
|
||||||
|
Description: Cockpit Sensors Module that displays all data reported by lm-sensors.
|
||||||
|
Author: ocristopfer <ocristopfer@gmail.com>
|
||||||
|
Maintainer: ocristopfer <ocristopfer@gmail.com>
|
||||||
|
Version: 1.4.2
|
||||||
|
Depends: lm-sensors
|
||||||
|
Architecture: all
|
||||||
|
Homepage: https://github.com/ocristopfer/cockpit-sensors
|
||||||
|
Website: https://github.com/ocristopfer/cockpit-sensors
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
Name: cockpit-starter-kit
|
Name: cockpit-sensors
|
||||||
Version: %{VERSION}
|
Version: %{VERSION}
|
||||||
Release: 1%{?dist}
|
Release: 1%{?dist}
|
||||||
Summary: Cockpit Starter Kit Example Module
|
Summary: Cockpit Sensors Module
|
||||||
License: LGPL-2.1-or-later
|
License: LGPL-2.1-or-later
|
||||||
|
|
||||||
Source0: https://github.com/cockpit-project/starter-kit/releases/download/%{version}/%{name}-%{version}.tar.xz
|
Source0: https://github.com/cockpit-project/starter-kit/releases/download/%{version}/%{name}-%{version}.tar.xz
|
||||||
|
|
@ -21,7 +21,7 @@ Requires: cockpit-bridge
|
||||||
%{NPM_PROVIDES}
|
%{NPM_PROVIDES}
|
||||||
|
|
||||||
%description
|
%description
|
||||||
Cockpit Starter Kit Example Module
|
Cockpit Sensors Module
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%autosetup -n %{name} -a 1
|
%autosetup -n %{name} -a 1
|
||||||
18
packit.yaml
18
packit.yaml
|
|
@ -2,7 +2,7 @@
|
||||||
# To use this, enable Packit-as-a-service in GitHub: https://packit.dev/docs/packit-as-a-service/
|
# To use this, enable Packit-as-a-service in GitHub: https://packit.dev/docs/packit-as-a-service/
|
||||||
# See https://packit.dev/docs/configuration/ for the format of this file
|
# See https://packit.dev/docs/configuration/ for the format of this file
|
||||||
|
|
||||||
specfile_path: cockpit-starter-kit.spec
|
specfile_path: cockpit-sensors.spec
|
||||||
# use the nicely formatted release description from our upstream release, instead of git shortlog
|
# use the nicely formatted release description from our upstream release, instead of git shortlog
|
||||||
copy_upstream_release_description: true
|
copy_upstream_release_description: true
|
||||||
|
|
||||||
|
|
@ -12,24 +12,24 @@ srpm_build_deps:
|
||||||
|
|
||||||
actions:
|
actions:
|
||||||
post-upstream-clone:
|
post-upstream-clone:
|
||||||
- make cockpit-starter-kit.spec
|
- make cockpit-sensors.spec
|
||||||
# replace Source1 manually, as create-archive: can't handle multiple tarballs
|
# replace Source1 manually, as create-archive: can't handle multiple tarballs
|
||||||
- make node-cache
|
- make node-cache
|
||||||
- sh -c 'sed -i "/^Source1:/ s/https:.*/$(ls *-node*.tar.xz)/" cockpit-*.spec'
|
- sh -c 'sed -i "/^Source1:/ s/https:.*/$(ls *-node*.tar.xz)/" cockpit-*.spec'
|
||||||
create-archive: make dist
|
create-archive: make dist
|
||||||
# starter-kit.git has no release tags; your project can drop this once you have a release
|
# sensors.git has no release tags; your project can drop this once you have a release
|
||||||
get-current-version: make print-version
|
get-current-version: make print-version
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
- job: copr_build
|
- job: copr_build
|
||||||
trigger: pull_request
|
trigger: pull_request
|
||||||
targets:
|
targets:
|
||||||
- fedora-all
|
- fedora-all
|
||||||
- fedora-latest-aarch64
|
- fedora-latest-aarch64
|
||||||
- centos-stream-8
|
- centos-stream-8
|
||||||
- centos-stream-9
|
- centos-stream-9
|
||||||
- centos-stream-9-aarch64
|
- centos-stream-9-aarch64
|
||||||
|
|
||||||
- job: tests
|
- job: tests
|
||||||
trigger: pull_request
|
trigger: pull_request
|
||||||
targets:
|
targets:
|
||||||
|
|
|
||||||
52
po/de.po
52
po/de.po
|
|
@ -1,8 +1,8 @@
|
||||||
# starter-kit German translations
|
# sensors German translations
|
||||||
#, fuzzy
|
#, fuzzy
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: starter-kit 1.0\n"
|
"Project-Id-Version: sensors 1.0\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2022-03-09 16:09+0100\n"
|
"POT-Creation-Date: 2022-03-09 16:09+0100\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
|
|
@ -15,25 +15,39 @@ msgstr ""
|
||||||
"Plural-Forms: nplurals=2; plural=n != 1\n"
|
"Plural-Forms: nplurals=2; plural=n != 1\n"
|
||||||
|
|
||||||
#: src/index.html:20
|
#: src/index.html:20
|
||||||
msgid "Cockpit Starter Kit"
|
msgid "Cockpit Sensors"
|
||||||
msgstr "Cockpit Bausatz"
|
msgstr "Cockpit Sensoren"
|
||||||
|
|
||||||
#: src/app.jsx:43
|
#: src/manifest.json:8
|
||||||
msgid "Running on $0"
|
#: org.cockpit-project.sensors.metainfo.xml:5
|
||||||
msgstr "Läuft auf $0"
|
#: src/app.jsx:162
|
||||||
|
msgid "Sensors"
|
||||||
|
msgstr "Sensoren"
|
||||||
|
|
||||||
#: org.cockpit-project.starter-kit.metainfo.xml:6
|
#: org.cockpit-project.sensors.metainfo.xml:8
|
||||||
msgid "Scaffolding for a cockpit module"
|
msgid "Sensors cockpit module"
|
||||||
msgstr "Gerüst für ein Cockpit-Modul"
|
msgstr "Sensoren Cockpit Modul"
|
||||||
|
|
||||||
#: org.cockpit-project.starter-kit.metainfo.xml:8
|
#: src/app.jsx:86
|
||||||
msgid "Scaffolding for a cockpit module."
|
msgid "lm-sensors not found, you want install it ?"
|
||||||
msgstr "Gerüst für ein Cockpit-Modul."
|
msgstr "lm-sensors nicht gefunden, möchten Sie es installieren?"
|
||||||
|
|
||||||
#: src/manifest.json:0 org.cockpit-project.starter-kit.metainfo.xml:5
|
#: src/app.jsx:95
|
||||||
msgid "Starter Kit"
|
msgid "this version of lm-sensors don't suport output sensors data!"
|
||||||
msgstr "Bausatz"
|
msgstr "diese Version von lm-sensors unterstützt keine Ausgabe von Sensordaten!"
|
||||||
|
|
||||||
#: src/app.jsx:29
|
#: src/app.jsx:130
|
||||||
msgid "Unknown"
|
msgid "lm-sensors has a bug that converts all data to fahrenheit, including voltage, fans and etc."
|
||||||
msgstr "Unbekannt"
|
msgstr "lm-sensors hat einen Fehler, der alle Daten in Fahrenheit umwandelt, einschließlich Spannung, Lüfter usw."
|
||||||
|
|
||||||
|
#: src/app.jsx:200
|
||||||
|
msgid "Show temperature in Fahrenheit"
|
||||||
|
msgstr "Temperatur in Fahrenheit anzeigen"
|
||||||
|
|
||||||
|
#: src/app.jsx:206
|
||||||
|
msgid "Expand all cards"
|
||||||
|
msgstr "Erweitern Sie alle Karten"
|
||||||
|
|
||||||
|
#: src/app.jsx:174
|
||||||
|
msgid "Install"
|
||||||
|
msgstr "Installieren"
|
||||||
53
po/pt_BR.po
Normal file
53
po/pt_BR.po
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
# sensors Portugues translations
|
||||||
|
#, fuzzy
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: sensors 1.0\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2022-03-09 16:09+0100\n"
|
||||||
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
|
"Last-Translator: Cristopfer Luis <ocristopfer@gmail.com>\n"
|
||||||
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
"Language: pt_BR\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: nplurals=2; plural=n != 1\n"
|
||||||
|
|
||||||
|
#: src/index.html:20
|
||||||
|
msgid "Cockpit Sensors"
|
||||||
|
msgstr "Sensores para Cockpit"
|
||||||
|
|
||||||
|
#: src/manifest.json:8
|
||||||
|
#: org.cockpit-project.sensors.metainfo.xml:5
|
||||||
|
#: src/app.jsx:162
|
||||||
|
msgid "Sensors"
|
||||||
|
msgstr "Sensores"
|
||||||
|
|
||||||
|
#: org.cockpit-project.sensors.metainfo.xml:8
|
||||||
|
msgid "Sensors cockpit module"
|
||||||
|
msgstr "Sensores do lm-sensors para o cockpit"
|
||||||
|
|
||||||
|
#: src/app.jsx:86
|
||||||
|
msgid "lm-sensors not found, you want install it ?"
|
||||||
|
msgstr "Não foi encontrado o lm-sensors, deseja instala-lo?"
|
||||||
|
|
||||||
|
#: src/app.jsx:95
|
||||||
|
msgid "this version of lm-sensors don't suport output sensors data!"
|
||||||
|
msgstr "Essa versão do lm-sensors não tem suporte para saida de dados!"
|
||||||
|
|
||||||
|
#: src/app.jsx:130
|
||||||
|
msgid "lm-sensors has a bug that converts all data to fahrenheit, including voltage, fans and etc."
|
||||||
|
msgstr "lm-sensors tem um problema aonde ele converte todos os dados para fahrenheit, incluindo voltage, vetoinhas e etc."
|
||||||
|
|
||||||
|
#: src/app.jsx:200
|
||||||
|
msgid "Show temperature in Fahrenheit"
|
||||||
|
msgstr "Exibir temperatus em Fahrenheit"
|
||||||
|
|
||||||
|
#: src/app.jsx:206
|
||||||
|
msgid "Expand all cards"
|
||||||
|
msgstr "Expandir todos os cards"
|
||||||
|
|
||||||
|
#: src/app.jsx:174
|
||||||
|
msgid "Install"
|
||||||
|
msgstr "Instalar"
|
||||||
285
src/app.jsx
285
src/app.jsx
|
|
@ -19,32 +19,289 @@
|
||||||
|
|
||||||
import cockpit from 'cockpit';
|
import cockpit from 'cockpit';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Alert } from "@patternfly/react-core/dist/esm/components/Alert/index.js";
|
import { Alert, Card, CardTitle, CardHeader, CardBody, CardExpandableContent, Checkbox, Button, Spinner, Flex, FlexItem } from '@patternfly/react-core';
|
||||||
import { Card, CardBody, CardTitle } from "@patternfly/react-core/dist/esm/components/Card/index.js";
|
import { FanIcon, ThermometerHalfIcon, ChargingStationIcon, CpuIcon } from '@patternfly/react-icons/dist/esm/icons/';
|
||||||
|
|
||||||
const _ = cockpit.gettext;
|
const _ = cockpit.gettext;
|
||||||
|
|
||||||
export class Application extends React.Component {
|
export class Application extends React.Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.state = { hostname: _("Unknown") };
|
this.state = { sensors: {}, intervalId: {}, alert: null, fahrenheitTemp: [], fahrenheitChecked: false, isShowBtnInstall: false, sensorArgumet: "-j", isShowLoading: false, isExpanded: {}, expandAllCards: false, isError: false, hidedCards: [] };
|
||||||
|
}
|
||||||
|
|
||||||
cockpit.file('/etc/hostname').watch(content => {
|
componentDidMount() {
|
||||||
this.setState({ hostname: content.trim() });
|
const intervalId = setInterval(() => {
|
||||||
|
if (!this.state.isShowBtnInstall && !this.state.isError)
|
||||||
|
this.loadSensors();
|
||||||
|
}, 1000);
|
||||||
|
this.setState({ intervalId });
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
clearInterval(this.state.intervalId);
|
||||||
|
}
|
||||||
|
|
||||||
|
loadSensors = () => {
|
||||||
|
cockpit
|
||||||
|
.spawn(["sensors", this.state.sensorArgumet], { err: "message", superuser: "try" })
|
||||||
|
.done((sucess) => {
|
||||||
|
if (this.state.sensorArgumet === "-j") {
|
||||||
|
this.setState({ sensors: JSON.parse(sucess), isShowBtnInstall: false });
|
||||||
|
} else {
|
||||||
|
const sensorsJson = {};
|
||||||
|
sucess.split(/\n\s*\n/).forEach(raw => {
|
||||||
|
let sensorsGroupName = "";
|
||||||
|
let index = 0;
|
||||||
|
let sensorTitle = "";
|
||||||
|
raw.split(/\n\s*/).forEach(element => {
|
||||||
|
if (index === 0) {
|
||||||
|
sensorsGroupName = element;
|
||||||
|
sensorsJson[sensorsGroupName] = {};
|
||||||
|
}
|
||||||
|
if (index === 1) {
|
||||||
|
const adapter = element.split(":");
|
||||||
|
sensorsJson[sensorsGroupName][adapter[0]] = adapter[1].trim();
|
||||||
|
}
|
||||||
|
if (index >= 2) {
|
||||||
|
const sensor = element.trim().split(":");
|
||||||
|
if (sensor[1] === "") {
|
||||||
|
sensorTitle = element.split(":")[0];
|
||||||
|
sensorsJson[sensorsGroupName][sensorTitle] = {};
|
||||||
|
} else {
|
||||||
|
sensorsJson[sensorsGroupName][sensorTitle][sensor[0]] = parseFloat(sensor[1].trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
index += 1;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
this.setState({ sensors: sensorsJson, isShowBtnInstall: false });
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.fail((err) => {
|
||||||
|
if (err.message === "not-found") {
|
||||||
|
this.setState({ isShowBtnInstall: true });
|
||||||
|
this.setAlert(_('lm-sensors not found, you want install it ?'), 'danger');
|
||||||
|
this.getLmSensorsInstallCmd(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (err.message === "sensors: invalid option -- 'j'") {
|
||||||
|
this.setState({ sensorArgumet: "-u" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err.message === "sensors: invalid option -- 'u'") {
|
||||||
|
this.setAlert(_("this version of lm-sensors don't suport output sensors data!"), 'danger');
|
||||||
|
this.setState({ isError: true });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.setAlert(err.message, 'warning');
|
||||||
|
clearInterval(this.state.intervalId);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
setIcon = (name) => {
|
||||||
|
if (typeof name !== 'undefined') {
|
||||||
|
if (name.includes('fan')) {
|
||||||
|
return <FanIcon size='md' />;
|
||||||
|
}
|
||||||
|
if (name.includes('temp')) {
|
||||||
|
return <ThermometerHalfIcon size='md' />;
|
||||||
|
}
|
||||||
|
if (name.includes('in')) {
|
||||||
|
return <ChargingStationIcon size='md' />;
|
||||||
|
}
|
||||||
|
if (name.includes('cpu')) {
|
||||||
|
return <CpuIcon size='md' />;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return <></>;
|
||||||
|
};
|
||||||
|
|
||||||
|
adjustLabel = (label) => {
|
||||||
|
return label.replace(label.substring(0, label.indexOf('_')) + '_', '');
|
||||||
|
};
|
||||||
|
|
||||||
|
setAlert = (msg, variant) => {
|
||||||
|
this.setState({ alert: { msg, variant } });
|
||||||
|
};
|
||||||
|
|
||||||
|
handleChange = (checked, event) => {
|
||||||
|
this.setState({ fahrenheitChecked: checked });
|
||||||
|
if (checked) {
|
||||||
|
// this.setAlert(_('lm-sensors has a bug that converts all data to fahrenheit, including voltage, fans and etc.'), 'info');
|
||||||
|
this.setState({ fahrenheitTemp: ['-f'] });
|
||||||
|
} else {
|
||||||
|
this.setState({ fahrenheitTemp: [], alert: null });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
handleChangeCards = (checked, event) => {
|
||||||
|
const isExpanded = this.state.isExpanded;
|
||||||
|
Object.keys(isExpanded).forEach((element) => {
|
||||||
|
isExpanded[element] = checked;
|
||||||
});
|
});
|
||||||
|
console.log(this.state.isExpanded, isExpanded);
|
||||||
|
this.setState({ isExpanded, expandAllCards: checked });
|
||||||
|
};
|
||||||
|
|
||||||
|
lstPacktsManager = ["apk", "apt-get", "dnf", "zypper"];
|
||||||
|
installCmd = null;
|
||||||
|
getLmSensorsInstallCmd = async (index) => {
|
||||||
|
const cmd = this.lstPacktsManager[index];
|
||||||
|
await cockpit.spawn([cmd, "-v"])
|
||||||
|
.then((sucesso) => {
|
||||||
|
switch (cmd) {
|
||||||
|
case "apk":
|
||||||
|
this.installCmd = [cmd, "add", "--no-cache", "lm-sensors", "-y"];
|
||||||
|
break;
|
||||||
|
case "dnf":
|
||||||
|
this.installCmd = [cmd, "install", "lm_sensors", "-y"];
|
||||||
|
break;
|
||||||
|
case "zypper":
|
||||||
|
this.installCmd = [cmd, "install", "-y", "sensors"];
|
||||||
|
break;
|
||||||
|
case "apt-get":
|
||||||
|
default:
|
||||||
|
this.installCmd = [cmd, "install", "lm-sensors", "-y"];
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.fail((e) => {
|
||||||
|
this.getLmSensorsInstallCmd(index + 1);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
handleInstallSensors = async () => {
|
||||||
|
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) => {
|
||||||
|
cockpit.spawn(["modprobe", "coretemp"], { err: "message", superuser: "require" });
|
||||||
|
cockpit.spawn(["modprobe", "i2c-i801"], { err: "message", superuser: "require" });
|
||||||
|
cockpit.spawn(["modprobe", "drivetemp"], { err: "message", superuser: "require" });
|
||||||
|
})
|
||||||
|
.fail((err) => {
|
||||||
|
this.setAlert(err.message, 'warning');
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.fail((err) => {
|
||||||
|
console.log('erro ?');
|
||||||
|
this.setState({ isShowLoading: false, isShowBtnInstall: false });
|
||||||
|
this.setAlert(err.message, 'warning');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
adjustValue = (name, value) => {
|
||||||
|
if (typeof name !== 'undefined') {
|
||||||
|
if (name.includes('temp')) {
|
||||||
|
return this.state.fahrenheitChecked
|
||||||
|
? parseFloat((value * 9 / 5) + 32).toFixed(1)
|
||||||
|
.toString()
|
||||||
|
.concat(' °F')
|
||||||
|
: parseFloat(value).toFixed(1)
|
||||||
|
.toString()
|
||||||
|
.concat(' °C');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name.includes('fan')) {
|
||||||
|
return value.toString().concat(' RPM');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
};
|
||||||
|
|
||||||
|
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);
|
||||||
|
console.log(cardId, hidedCards);
|
||||||
|
this.setState({ hidedCards });
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const { sensors, alert, fahrenheitChecked, isShowBtnInstall, isShowLoading, isExpanded, expandAllCards } = this.state;
|
||||||
return (
|
return (
|
||||||
<Card>
|
<>
|
||||||
<CardTitle>Starter Kit</CardTitle>
|
<Card>
|
||||||
<CardBody>
|
<CardTitle>{_('Sensors')}</CardTitle>
|
||||||
<Alert
|
<CardBody>
|
||||||
variant="info"
|
<Checkbox
|
||||||
title={ cockpit.format(_("Running on $0"), this.state.hostname) }
|
label={_("Show temperature in Fahrenheit")}
|
||||||
/>
|
isChecked={fahrenheitChecked}
|
||||||
</CardBody>
|
onChange={this.handleChange}
|
||||||
</Card>
|
id="fahrenheit-checkbox"
|
||||||
|
name="fahrenheit-checkbox"
|
||||||
|
/>
|
||||||
|
<Checkbox
|
||||||
|
label={_("Expand all cards")}
|
||||||
|
isChecked={expandAllCards}
|
||||||
|
onChange={this.handleChangeCards}
|
||||||
|
id="allcards-checkbox"
|
||||||
|
name="allcards-checkbox"
|
||||||
|
/>
|
||||||
|
<>
|
||||||
|
{isShowLoading ? <Spinner isSVG /> : <></>}
|
||||||
|
{alert != null ? <Alert variant={alert.variant}>{alert.msg}</Alert> : <></>}
|
||||||
|
{isShowBtnInstall ? <Button onClick={this.handleInstallSensors}>{_('Install')}</Button> : <></>}
|
||||||
|
</>
|
||||||
|
{sensors !== null
|
||||||
|
? Object.entries(sensors).map((key, keyIndex) =>
|
||||||
|
<Card key={key}>
|
||||||
|
<CardTitle>{key[0]}</CardTitle>
|
||||||
|
<CardBody>
|
||||||
|
<CardTitle>{key[1].Adapter}</CardTitle>
|
||||||
|
<Flex key={key[1]}>
|
||||||
|
{Object.entries(key[1]).map((item, itemIndex) => {
|
||||||
|
if (itemIndex === 0) return "";
|
||||||
|
const chave = keyIndex.toString() + itemIndex.toString();
|
||||||
|
if (isExpanded[chave] === undefined) {
|
||||||
|
isExpanded[chave] = false;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<FlexItem key={item} style={{ width: "15%" }}>
|
||||||
|
<Card key={item} id="expandable-card-icon" isExpanded={isExpanded[chave]}>
|
||||||
|
<CardHeader
|
||||||
|
style={{ justifyContent: 'normal' }}
|
||||||
|
onExpand={(e) => this.handleOnExpand(e, chave)}
|
||||||
|
toggleButtonProps={{
|
||||||
|
id: 'toggle-button2',
|
||||||
|
'aria-label': 'Patternfly Details',
|
||||||
|
'aria-expanded': isExpanded[chave]
|
||||||
|
}}
|
||||||
|
><CardTitle>{item[0]}</CardTitle>
|
||||||
|
</CardHeader>
|
||||||
|
<CardTitle>{this.setIcon(Object.keys(item[1])[0])} {this.adjustValue(Object.keys(item[1])[0], Object.values(item[1])[0])}
|
||||||
|
</CardTitle>
|
||||||
|
<CardExpandableContent>
|
||||||
|
<CardBody>
|
||||||
|
{Object.entries(item[1]).map((sensors, index) => (
|
||||||
|
<span key={sensors}>{this.adjustLabel(sensors[0])}: {sensors[1]}<br /></span>
|
||||||
|
))}
|
||||||
|
</CardBody>
|
||||||
|
</CardExpandableContent>
|
||||||
|
</Card>
|
||||||
|
</FlexItem>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Flex>
|
||||||
|
</CardBody>
|
||||||
|
</Card>
|
||||||
|
)
|
||||||
|
: ''}
|
||||||
|
</CardBody>
|
||||||
|
</Card>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
summary:
|
summary:
|
||||||
Run browser integration tests on the host
|
Run browser integration tests on the host
|
||||||
require:
|
require:
|
||||||
- cockpit-starter-kit
|
- cockpit-sensors
|
||||||
- cockpit-ws
|
- cockpit-ws
|
||||||
- cockpit-system
|
- cockpit-system
|
||||||
- bzip2
|
- bzip2
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ class TestApplication(testlib.MachineCase):
|
||||||
b = self.browser
|
b = self.browser
|
||||||
m = self.machine
|
m = self.machine
|
||||||
|
|
||||||
self.login_and_go("/starter-kit")
|
self.login_and_go("/sensors")
|
||||||
# verify expected heading
|
# verify expected heading
|
||||||
b.wait_text(".pf-v5-c-card__title", "Starter Kit")
|
b.wait_text(".pf-v5-c-card__title", "Starter Kit")
|
||||||
|
|
||||||
|
|
@ -39,12 +39,12 @@ class TestApplication(testlib.MachineCase):
|
||||||
b.click("#display-language-modal button.pf-m-primary")
|
b.click("#display-language-modal button.pf-m-primary")
|
||||||
b.wait_visible("#content")
|
b.wait_visible("#content")
|
||||||
# menu label (from manifest) should be translated
|
# menu label (from manifest) should be translated
|
||||||
b.wait_text("#host-apps a[href='/starter-kit']", "Bausatz")
|
b.wait_text("#host-apps a[href='/sensors']", "Bausatz")
|
||||||
# window title should be translated; this is not considered as "visible"
|
# window title should be translated; this is not considered as "visible"
|
||||||
self.assertIn("Bausatz", b.call_js_func("ph_text", "head title"))
|
self.assertIn("Bausatz", b.call_js_func("ph_text", "head title"))
|
||||||
|
|
||||||
b.go("/starter-kit")
|
b.go("/sensors")
|
||||||
b.enter_page("/starter-kit")
|
b.enter_page("/sensors")
|
||||||
# page label (from js) should be translated
|
# page label (from js) should be translated
|
||||||
b.wait_in_text(".pf-v5-c-alert__title", "Läuft auf")
|
b.wait_in_text(".pf-v5-c-alert__title", "Läuft auf")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue