Skip to content

Commit

Permalink
Merge pull request #1 from jecsham/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
jecsham authored May 20, 2022
2 parents 17cee9b + 205154c commit 468638a
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 68 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
## MY SYSTEM INFORMATION
A program that allows you to visualize the main components of your windows computer
![preview](https://i.imgur.com/TfnwqXO.png)
A program that allows you to visualize the main components of your Windows computer
![preview](https://i.imgur.com/g8dhO8i.png)

### Main features
- Visualize main components of your windows computer
- Save the data as screenshot image
- Save the data as `.txt` file
### Development
- Initially created with [electron](https://github.com/electron/electron), later moved to [tauri](https://github.com/tauri-apps/tauri) reducing `~80%` executable file
- Using react for frontend
- Initially created with [electron](https://github.com/electron/electron), later moved to [tauri](https://github.com/tauri-apps/tauri) reducing `~80%` executable file size
- Using React for frontend
- Using Rust for backend
### License
[MIT](https://www.mit.edu/~amini/LICENSE.md)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "jecsham-msi",
"name": "msi",
"version": "2.0.0",
"private": true,
"dependencies": {
Expand Down
12 changes: 8 additions & 4 deletions public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ html, body {
overflow: hidden;
user-select: none;
background-color: transparent;
border: 1px solid rgba(0, 0, 0, 0.05);
}

.content {
Expand Down Expand Up @@ -40,16 +41,19 @@ code {
cursor: pointer;
}

.cursor-default {
cursor: default;
}
.cursor-default:hover {
cursor: default;
}

.title-panel {
width: 100%;
height: 32px;
background: #fff;
}

.default {
cursor: default !important;
}

::-webkit-scrollbar {
width: 10px;
}
Expand Down
23 changes: 0 additions & 23 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,7 @@
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->

<!-- css styles -->
<link rel="stylesheet" href="/css/uikit.min.css">
Expand All @@ -39,15 +26,5 @@
<body id="body">
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
22 changes: 11 additions & 11 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "Jecsham My System Information"
name = "msi"
version = "2.0.0"
description = "A program that allows you to visualize the main components of your Windows computer"
authors = ["you"]
license = ""
repository = ""
default-run = "app"
authors = ["Jecsham Castillo"]
license = "MIT"
repository = "https://github.com/jecsham/msi"
default-run = "msi"
edition = "2021"
rust-version = "1.57"

Expand Down
7 changes: 7 additions & 0 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ fn get_system_data() -> Result<String, Box<dyn std::error::Error>> {
Product: String,
}
let result_motherboard: Vec<Win32_BaseBoard> = wmi_con.query()?;

// used to test not available data
// #[derive(Serialize, Deserialize, Debug)]
// struct Win32_TapeDrive {
// Name: String,
// }
// let not_found: Vec<Win32_TapeDrive> = wmi_con.query()?;

let json_response = json!({
"os": result_os,
Expand Down
15 changes: 2 additions & 13 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,30 +61,19 @@ function App() {
data-tauri-drag-region
className="uk-text-small uk-text-center p-n"
>
<span id="text-title">
<a
className="uk-text-muted pointer"
href="https://msi.jecsham.com"
target="_blank"
>
msi.jecsham.com
</a>{" "}
</span>
<span data-tauri-drag-region id="text-title">msi.jecsham.com</span>
</div>
</div>
<button
onClick={closeWindow}
id="btnCloser"
className="uk-button uk-button-danger uk-button-small default"
className="uk-button uk-button-danger uk-button-small cursor-default"
>
x
</button>
</section>
<div id="render-portion">
<div className="uk-padding-large uk-padding-remove-vertical">
<p className="uk-text-center uk-margin-small uk-text-bold">
My System Information
</p>
<p
id="text-website"
className="uk-text-center uk-margin-small uk-text-muted uk-text-small uk-margin-remove-top"
Expand Down
19 changes: 14 additions & 5 deletions src/components/HardwareTableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,24 @@ interface HardwareTableRowProps {
content: string[];
}
function HardwareTableRow({ title, content }: HardwareTableRowProps) {
const contentValue = (content: string[]) => {
if (content?.length === 0) {
return <li key="0">No data available</li>;
}
return (
<>
{content.map((e, index) => (
<li key={index}>{e}</li>
))}
</>
);
};

return (
<tr>
<td className="uk-text-small uk-text-bold ">{title}</td>
<td className="uk-text-small uk-padding-remove-right">
<ul className="uk-list uk-list-divider">
{content.map((e, index) => (
<li key={index}>{e}</li>
))}
</ul>
<ul className="uk-list uk-list-divider">{contentValue(content)}</ul>
</td>
</tr>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/SaveAsImgButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function SaveAsImgButton() {
return (
<button
id="btnSaveImage"
className="uk-button uk-button-default uk-button-small uk-margin-small-right"
className="uk-button uk-button-default uk-button-small uk-margin-small-right cursor-default"
onClick={() => {
save();
}}
Expand Down
2 changes: 1 addition & 1 deletion src/components/SaveAsTxtButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function SaveAsTxtButton() {
return (
<button
id="btnSaveTxt"
className="uk-button uk-button-default uk-button-small"
className="uk-button uk-button-default uk-button-small cursor-default"
onClick={() => {
save();
}}
Expand Down
13 changes: 13 additions & 0 deletions src/libs/std_format.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
import convert from "convert";

const _validateContent = (jsonData: any) => {
if (jsonData?.length === 0) {
return false;
}
return true;
};

const _formatCpu = (jsonData: any) => {
if (!_validateContent(jsonData)) return [];
let formattedContent = jsonData.map((e: any) =>
e.Name.replace("(R)", "®").replace("(TM)", "™")
);
return formattedContent;
};

const _formatGpu = (jsonData: any) => {
if (!_validateContent(jsonData)) return [];
let formattedContent = jsonData.map((e: any) => e.Name);
return formattedContent;
};

const _formatRam = (jsonData: any) => {
if (!_validateContent(jsonData)) return [];
let formattedContent = jsonData.map((e: any) => {
let orgSize = convert(e.Capacity, "bytes").to("best");
let quantity = Number(orgSize.quantity).toFixed(0);
Expand All @@ -27,6 +37,7 @@ const _formatRam = (jsonData: any) => {
};

const _formatDisk = (jsonData: any) => {
if (!_validateContent(jsonData)) return [];
let formattedContent = jsonData.map((e: any) => {
let orgSize = convert(e.Size, "bytes").to("best");
let quantity = Number(orgSize.quantity).toFixed(2);
Expand All @@ -37,13 +48,15 @@ const _formatDisk = (jsonData: any) => {
};

const _formatMotherboard = (jsonData: any) => {
if (!_validateContent(jsonData)) return [];
let formattedContent = jsonData.map(
(e: any) => `${e.Product} - ${e.Manufacturer}`
);
return formattedContent;
};

const _formatOs = (jsonData: any) => {
if (!_validateContent(jsonData)) return [];
let formattedContent = jsonData.map((e: any) => `${e.Caption}`);
return formattedContent;
};
Expand Down

0 comments on commit 468638a

Please sign in to comment.