-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
147 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import _ from "lodash"; | ||
import { Separator } from "./ui/separator"; | ||
import { useEffect, useState } from "react"; | ||
import { getVersion } from "@/utils/app"; | ||
import { getLicenseIfIsPro, saveLicense } from "@/middlelayers/configuration"; | ||
import ViewIcon from "@/assets/icons/view-icon.png"; | ||
import HideIcon from "@/assets/icons/hide-icon.png"; | ||
import { Input } from "./ui/input"; | ||
import { Button } from "./ui/button"; | ||
import { ReloadIcon } from "@radix-ui/react-icons"; | ||
|
||
const App = () => { | ||
const [version, setVersion] = useState<string>("0.1.0"); | ||
|
||
const [license, setLicense] = useState<string | undefined>(); | ||
const [showLicense, setShowLicense] = useState(false); | ||
const [licenseChanged, setLicenseChanged] = useState<boolean>(false); | ||
const [saveLicenseLoading, setSaveLicenseLoading] = useState(false); | ||
|
||
useEffect(() => { | ||
loadVersion(); | ||
loadLicense(); | ||
}, []); | ||
|
||
function loadVersion() { | ||
getVersion().then((ver) => { | ||
setVersion(ver); | ||
}); | ||
} | ||
|
||
function loadLicense() { | ||
getLicenseIfIsPro().then((license) => { | ||
setLicense(license); | ||
}); | ||
} | ||
|
||
function onSaveLicenseClick() { | ||
if (!license) { | ||
return; | ||
} | ||
setSaveLicenseLoading(true); | ||
|
||
saveLicense(license).then(() => {}); | ||
} | ||
|
||
function onLicenseInputChange(val: string) { | ||
setLicenseChanged(true); | ||
setLicense(val); | ||
} | ||
|
||
function onViewOrHideClick() { | ||
setShowLicense(!showLicense); | ||
} | ||
|
||
return ( | ||
<div className="space-y-6"> | ||
<div> | ||
<h3 className="text-lg font-medium">System Info</h3> | ||
<p className="text-sm text-muted-foreground"> | ||
Show basic system information | ||
</p> | ||
</div> | ||
<Separator /> | ||
|
||
<div className="space-y-3"> | ||
<div className="text-l font-bold text-left">Version</div> | ||
<div className="text-sm text-left text-gray-400">{version}</div> | ||
</div> | ||
|
||
<div className="space-y-3"> | ||
<div className="text-l font-bold text-left">Pro Version</div> | ||
<div className="text-sm text-left text-gray-400"> | ||
Enter License Key To Active Pro Version ( Coming Soon ) | ||
</div> | ||
<div className="flex"> | ||
<Input | ||
id="license" | ||
value={license ?? ""} | ||
type={showLicense ? "text" : "password"} | ||
onChange={(e) => onLicenseInputChange(e.target.value)} | ||
placeholder="License Key" | ||
className="w-[400px] mr-2" | ||
/> | ||
<a onClick={onViewOrHideClick} className="mr-2"> | ||
<img | ||
className="view-or-hide-icon mt-1" | ||
src={showLicense ? ViewIcon : HideIcon} | ||
alt="view-or-hide" | ||
width={25} | ||
height={25} | ||
/> | ||
</a> | ||
<Button | ||
onClick={onSaveLicenseClick} | ||
disabled={saveLicenseLoading || !licenseChanged} | ||
> | ||
{saveLicenseLoading ?? ( | ||
<ReloadIcon className="mr-2 h-4 w-4 animate-spin" /> | ||
)} | ||
Active | ||
</Button> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default App; |