Skip to content
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

master #133

Merged
merged 11 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/).

## 0.7.4
- Modify chart label button text
- Add Project information to settings page

## 0.7.3
- Add persistent title bars so it matches with the theme

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@
<br />
</p>
Pachtop is a cross-platform desktop application built with Rust that allows you to monitor your system resources in real time.

<br/>
<br/>

[!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://buymeacoffee.com/pacholoamit)

> NOTE: Pachtop is under active development, most of the features are still experimental and subject to change.

<p align="center">
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pachtop",
"private": true,
"version": "0.7.3",
"version": "0.7.4",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down Expand Up @@ -33,7 +33,9 @@
"react-apexcharts": "^1.4.1",
"react-dom": "^18.3.1",
"react-geiger": "^1.2.0",
"react-github-btn": "^1.4.0",
"react-router-dom": "^6.23.1",
"react-text-gradients": "^1.0.2",
"tauri-plugin-autostart-api": "https://github.com/tauri-apps/tauri-plugin-autostart",
"tauri-plugin-log-api": "https://github.com/tauri-apps/tauri-plugin-log",
"tauri-plugin-store": "https://github.com/tauri-apps/tauri-plugin-store"
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

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

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "app"
version = "0.7.3"
version = "0.7.4"
description = "Cross-platform (Linux, WIndows, MacOS) Desktop GUI system monitor"
authors = ["Pacholo Amit"]
license = "MIT"
Expand Down
8 changes: 0 additions & 8 deletions src-tauri/src/win/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,13 @@ use windows::Win32::Graphics::Dwm::DWMWA_USE_IMMERSIVE_DARK_MODE;
use windows::Win32::UI::Controls::SetWindowThemeAttribute;
use windows::Win32::UI::Controls::WTNCA_NODRAWCAPTION;

use std::path::PathBuf;
use tauri::Wry;
use tauri_plugin_store::with_store;
use tauri_plugin_store::StoreCollection;
use winver::WindowsVersion;

fn hex_color_to_colorref(color: HexColor) -> COLORREF {
// TODO: Remove this unsafe, This operation doesn't need to be unsafe!
unsafe { COLORREF(transmute::<[u8; 4], u32>([color.r, color.g, color.b, 0])) }
}

fn hex_color_to_string(color: HexColor) -> String {
format!("#{:02X}{:02X}{:02X}", color.r, color.g, color.b)
}

struct WinThemeAttribute {
flag: u32,
mask: u32,
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"package": {
"productName": "pachtop",
"version": "0.7.3"
"version": "0.7.4"
},
"tauri": {
"systemTray": {
Expand Down
6 changes: 3 additions & 3 deletions src/components/area-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,17 @@ export const useAreaChartState = (
{
count: 1,
type: "minute",
text: "1M",
text: "1m",
},
{
count: 5,
type: "minute",
text: "5M",
text: "5m",
},
{
count: 30,
type: "minute",
text: "30M",
text: "30m",
},
{
type: "all",
Expand Down
1 change: 1 addition & 0 deletions src/features/metrics/pages/dashboard.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import MemoryRadialChart from "@/features/metrics/components/memory/memory.radia
import SwapRadialChart from "@/features/metrics/components/swap/swap.radial-chart";
import CpusBarChart from "@/features/metrics/components/cpus/cpus.bar-chart";
import GlobalCpuStatsRing from "@/features/metrics/components/global-cpu/global-cpu.stats-ring";

import MemoryStatsRing from "@/features/metrics/components/memory/memory.stats-ring";
import SwapStatsRing from "@/features/metrics/components/swap/swap.stats-ring";
import DiskStatsRing from "@/features/metrics/components/disks/disk.stats-ring";
Expand Down
3 changes: 0 additions & 3 deletions src/features/settings/mdx/about.mdx

This file was deleted.

222 changes: 181 additions & 41 deletions src/features/settings/pages/settings.page.tsx
Original file line number Diff line number Diff line change
@@ -1,51 +1,191 @@
import React from "react";
import GeneralSettingsView from "@/features/settings/views/general.view";
import AboutView from "@/features/settings/views/about.view";
import { useEffect, useState } from "react";
import GitHubButton from "react-github-btn";
import PageWrapper from "@/components/page-wrapper";
import Card from "@/components/card";
import { Grid, Skeleton, Space, Stack, Switch, Title, Text, SegmentedControl, Group, ThemeIcon } from "@mantine/core";
import { useTheme } from "@/hooks/useTheme";
import { autostart } from "@/lib";
import { THEME_OPTION } from "@/providers/theme.provider";
import { LinearGradient } from "react-text-gradients";

import { IconGitBranch, IconSettings2 } from "@tabler/icons-react";
import { Center, Grid, NavLink } from "@mantine/core";
import { useState } from "react";
const GeneralSectionInfo = () => {
return (
<>
<Title order={4}>General</Title>
<Text c="dimmed" size={"sm"}>
Customize your application settings.
</Text>
</>
);
};
const GeneralSection = () => {
const [checked, setChecked] = useState(false);
const [loading, setLoading] = useState(true);
const checkAutoStart = async () => setChecked(await autostart.isEnabled());
const { setTheme, currentTheme } = useTheme();

useEffect(() => {
checkAutoStart();
setLoading(false);
}, [checkAutoStart]);

const onChange = () => {
if (!checked) {
autostart.enable();
} else {
autostart.disable();
}
setChecked(!checked);
};

if (loading) {
return (
<>
<Skeleton height={8} radius="xl" />
<Skeleton height={8} mt={6} radius="xl" />
<Skeleton height={8} mt={6} width="70%" radius="xl" />
</>
);
}

return (
<>
<Grid gutter={"xl"}>
<Grid.Col span={12} style={{ fontSize: "1.2rem" }}>
<Text size={"sm"} color="white">
Theme
</Text>
<SegmentedControl
defaultValue={currentTheme}
size="xs"
onChange={(value) => setTheme(value as THEME_OPTION)}
data={[
{ value: THEME_OPTION.SLATE, label: "Slate" },
{ value: THEME_OPTION.MIDNIGHT, label: "Midnight" },
{ value: THEME_OPTION.BUMBLEBEE, label: "Bumblebee" },
]}
/>
</Grid.Col>
<Grid.Col span={12} style={{ fontSize: "1.2rem" }}>
<Switch checked={checked} onChange={onChange} label="Start on system startup" />
</Grid.Col>
</Grid>
</>
);
};

const AboutSectionInfo = () => {
return (
<>
<Title order={4}>About</Title>
<Text c="dimmed" size={"sm"}>
Get information about the application.
</Text>
</>
);
};
const BuyMeACoffee = () => {
return (
<a href="https://www.buymeacoffee.com/pacholoamit" target="_blank" rel="noopener noreferrer">
<img
src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png"
alt="Buy Me A Coffee"
style={{
height: "26px",
width: "96px",
marginBottom: "8px",
}}
/>
</a>
);
};
const AboutSection = () => {
return (
<Stack spacing={"lg"}>
<Text>Pachtop will always remain open-source and free to use. 🤗</Text>
<Group>
<BuyMeACoffee />
<GitHubButton
href="https://github.com/sponsors/pacholoamit"
// data-color-scheme="no-preference: dark; light: dark; dark: dark;"
data-icon="octicon-heart"
data-size="large"
aria-label="Sponsor @pacholoamit on GitHub"
>
Sponsor
</GitHubButton>

<GitHubButton
href="https://github.com/pacholoamit/pachtop"
// data-color-scheme="no-preference: dark; light: dark; dark: dark;"
data-icon="octicon-star"
data-size="large"
data-show-count="true"
aria-label="Star pacholoamit/pachtop on GitHub"
>
Star
</GitHubButton>
</Group>
</Stack>
);
};

const settings = [
{ icon: IconSettings2, label: "General", view: <GeneralSettingsView /> },
const SponsorsSectionInfo = () => {
return (
<>
<Title order={4}>Sponsors</Title>
<Text c="dimmed" size={"sm"}>
A big shoutout to these amazing people who sponsored the project. Your support means a lot to me. ❤️
</Text>
</>
);
};

// TODO: FIX responsiveness
// {
// icon: IconGitBranch,
// label: "About",
// view: <AboutView />,
// },
];
const SponsorsSection = () => {
return (
<Stack spacing={"lg"}>
<Title order={1}>
<LinearGradient gradient={["to left", "#17acff ,#ff68f0"]}>Coming soon...</LinearGradient>
</Title>
</Stack>
);
};

const SettingsPage = () => {
const [active, setActive] = useState(0);

const items = settings.map((item, index) => (
<React.Fragment key={item.label}>
<Grid.Col span={3}>
<NavLink
key={item.label}
active={index === active}
label={item.label}
icon={<item.icon size="1rem" stroke={1.5} />}
onClick={() => {
setActive(index);
}}
/>
</Grid.Col>
<Grid.Col span={8}>{index === active && item.view}</Grid.Col>
</React.Fragment>
));

return (
<PageWrapper name="Settings" height={"94vh"}>
<Center>
<Card style={{ height: "85vh" }}>
<Grid style={{ width: "50rem" }}>{items}</Grid>
</Card>
</Center>
return (
<PageWrapper name="Settings">
<Card style={{ padding: "16px", height: "85vh" }}>
<Stack justify="space-around" spacing={"lg"}>
<Grid grow>
<Grid.Col span={4}>
<GeneralSectionInfo />
</Grid.Col>
<Grid.Col span={4}>
<GeneralSection />
</Grid.Col>
<Grid.Col span={4} />
<Grid.Col span={4}>
<Space h={"xl"} />
<AboutSectionInfo />
</Grid.Col>
<Grid.Col span={4}>
<Space h={"xl"} />
<AboutSection />
</Grid.Col>
<Grid.Col span={4} />
<Grid.Col span={4}>
<Space h={"xl"} />
<SponsorsSectionInfo />
</Grid.Col>
<Grid.Col span={4}>
<Space h={"xl"} />
<Space h={"xl"} />
<SponsorsSection />
</Grid.Col>
<Grid.Col span={4} />
</Grid>
</Stack>
</Card>
</PageWrapper>
);
};
Expand Down
7 changes: 0 additions & 7 deletions src/features/settings/views/about.view.tsx

This file was deleted.

Loading
Loading