Skip to content

Commit

Permalink
Small GUI fixes, pt. 2 (#815)
Browse files Browse the repository at this point in the history
  • Loading branch information
ImUrX committed Aug 19, 2023
1 parent a92dec8 commit 4df2d87
Show file tree
Hide file tree
Showing 16 changed files with 685 additions and 34 deletions.
36 changes: 36 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

YELLOW="\033[1;33m"
GREEN="\033[1;32m"
RESET="\033[0m"

if git rev-parse -q --verify MERGE_HEAD; then
echo -e "${YELLOW}Skipping precommit hook because of merge${RESET}"
exit 0
fi

APP_PRE_COMMIT_OPTIONS="$(dirname "$0")/_/pre-commit.options"

if ! [ -f "$APP_PRE_COMMIT_OPTIONS" ]; then
echo -e "${YELLOW}\nSkipping pre-commit hook."
echo -e "If you want to use pre-commit for lint-staged, run:\n"
echo -e " ${GREEN}echo -e 'APP_LINT=true;' > ${APP_PRE_COMMIT_OPTIONS}${RESET}"
echo -e "${YELLOW}\nIt will add some delay before committing!\n${RESET}"
exit 0
fi

source $APP_PRE_COMMIT_OPTIONS

if [ -n "${APP_LINT}" ] && [ "${APP_LINT}" == "true" ]; then
echo -e "${GREEN}[husky] [pre-commit] [lint-staged]${RESET}"
case "$(uname -sr)" in
CYGWIN*|MINGW*|MINGW32*|MSYS*)
npx.cmd lint-staged
;;

*)
npx lint-staged
;;
esac
fi
9 changes: 9 additions & 0 deletions .lintstagedrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default {
'server/**/*.{java,kt,kts}': (filenames) =>
filenames.map(
(filename) =>
`./gradlew${
process.platform === 'win32' ? '.bat' : ''
} spotlessApply "-PspotlessIdeHook=${filename}"`
),
};
Empty file modified gradlew.bat
100644 → 100755
Empty file.
3 changes: 3 additions & 0 deletions gui/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ yarn-error.log*
# vite
/dist
/stats.html

# eslint
.eslintcache
5 changes: 5 additions & 0 deletions gui/.lintstagedrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
"**/*.{ts,tsx}": () => "tsc -p tsconfig.json --noEmit",
"**/*.{js,jsx,ts,tsx}": "eslint --cache --fix",
"**/*.{js,jsx,ts,tsx,css,md,json}": "prettier --write"
};
4 changes: 2 additions & 2 deletions gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
"dev": "tauri dev",
"skipbundler": "tauri build -b none",
"tauri": "tauri",
"lint": "eslint --max-warnings=0 \"src/**/*.{js,jsx,ts,tsx,json}\" && prettier --check \"src/**/*.{js,jsx,ts,tsx,css,md,json}\"",
"lint:fix": "eslint --fix \"src/**/*.{js,jsx,ts,tsx,json}\"",
"lint": "tsc --noEmit && eslint --max-warnings=0 \"src/**/*.{js,jsx,ts,tsx,json}\" && prettier --check \"src/**/*.{js,jsx,ts,tsx,css,md,json}\"",
"lint:fix": "tsc --noEmit && eslint --fix --max-warnings=0 \"src/**/*.{js,jsx,ts,tsx,json}\" && npm run format",
"format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,css,md,json}\"",
"preview-vite": "vite preview",
"javaversion-build": "cd src-tauri/src/ && javac JavaVersion.java && jar cvfe JavaVersion.jar JavaVersion JavaVersion.class"
Expand Down
9 changes: 0 additions & 9 deletions gui/src/App.test.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion gui/src/components/commons/NumberSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function NumberSelector({
step,
disabled = false,
}: {
label: string;
label?: string;
valueLabelFormat?: (value: number) => string;
control: Control<any>;
name: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,21 @@ interface FlatDeviceTrackerDummy {
export function TrackersAssignPage() {
const { isMobile } = useBreakpoint('mobile');
const { l10n } = useLocalization();
const { config, setConfig } = useConfig();
const { useAssignedTrackers, trackers } = useTrackers();
const { applyProgress, state } = useOnboarding();
const { sendRPCPacket, useRPCPacket } = useWebsocketAPI();

const { control, watch } = useForm<{ advanced: boolean }>({
defaultValues: { advanced: false },
defaultValues: { advanced: config?.advancedAssign ?? false },
});
const { advanced } = watch();
const [selectedRole, setSelectRole] = useState<BodyPart>(BodyPart.NONE);
const assignedTrackers = useAssignedTrackers();
useEffect(() => {
setConfig({ advancedAssign: advanced });
}, [advanced]);

const { config } = useConfig();
const [tapDetectionSettings, setTapDetectionSettings] = useState<Omit<
TapDetectionSettingsT,
'pack'
Expand Down
2 changes: 1 addition & 1 deletion gui/src/components/settings/pages/GeneralSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ interface SettingsForm {
yawResetTaps: number;
fullResetTaps: number;
mountingResetTaps: number;
numberTrackersOverThreshold;
numberTrackersOverThreshold: number;
};
legTweaks: {
correctionStrength: number;
Expand Down
2 changes: 2 additions & 0 deletions gui/src/hooks/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface Config {
theme: string;
textSize: number;
fonts: string[];
advancedAssign: boolean;
}

export interface ConfigContext {
Expand All @@ -41,6 +42,7 @@ export const defaultConfig = {
theme: 'slime',
textSize: 12,
fonts: ['poppins'],
advancedAssign: false,
};

function fallbackToDefaults(loadedConfig: any): Config {
Expand Down
2 changes: 1 addition & 1 deletion gui/src/hooks/countdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function useCountdown({
}) {
const [isCounting, setIsCounting] = useState(false);
const [timer, setDisplayTimer] = useState(0);
const countdownTimer = useRef<NodeJS.Timer>();
const countdownTimer = useRef<NodeJS.Timeout>();
const counter = useRef(0);

const startCountdown = () => {
Expand Down
2 changes: 1 addition & 1 deletion gui/src/hooks/status-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export function parseStatusToLocale(
}
case StatusData.StatusTrackerError: {
const data = status.data as StatusTrackerErrorT;
if (!data.trackerId?.trackerNum || !trackers) {
if (data.trackerId?.trackerNum === undefined || !trackers) {
return {};
}

Expand Down
15 changes: 0 additions & 15 deletions gui/src/reportWebVitals.ts

This file was deleted.

Loading

0 comments on commit 4df2d87

Please sign in to comment.