installation done

This commit is contained in:
Aria Moradi 2020-12-25 03:08:08 +03:30
parent f16bead363
commit 5ddc087a6d
3 changed files with 20 additions and 9 deletions

View File

@ -207,6 +207,7 @@ class Main {
app.get("/api/v1/extensions/install/:apkName") { ctx -> app.get("/api/v1/extensions/install/:apkName") { ctx ->
val apkName = ctx.pathParam("apkName") val apkName = ctx.pathParam("apkName")
println(apkName)
ctx.status( ctx.status(
downloadApk(apkName) downloadApk(apkName)
) )

View File

@ -1,4 +1,4 @@
import React from 'react'; import React, { useState } from 'react';
import { makeStyles } from '@material-ui/core/styles'; import { makeStyles } from '@material-ui/core/styles';
import Card from '@material-ui/core/Card'; import Card from '@material-ui/core/Card';
import CardContent from '@material-ui/core/CardContent'; import CardContent from '@material-ui/core/CardContent';
@ -36,16 +36,24 @@ interface IProps {
extension: IExtension extension: IExtension
} }
export default function ExtensionCard({ export default function ExtensionCard(props: IProps) {
extension: { const {
name, lang, versionName, iconUrl, extension: {
}, name, lang, versionName, iconUrl, installed, apkName,
}: IProps) { },
} = props;
const [installedState, setInstalledState] = useState<string>((installed ? 'installed' : 'install'));
const classes = useStyles(); const classes = useStyles();
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const bull = <span className={classes.bullet}></span>;
const langPress = lang === 'all' ? 'All' : lang.toUpperCase(); const langPress = lang === 'all' ? 'All' : lang.toUpperCase();
function install() {
setInstalledState('installing');
fetch(`http://127.0.0.1:4567/api/v1/extensions/install/${apkName}`).then(() => {
setInstalledState('installed');
});
}
return ( return (
<Card> <Card>
<CardContent className={classes.root}> <CardContent className={classes.root}>
@ -68,7 +76,7 @@ export default function ExtensionCard({
</div> </div>
</div> </div>
<Button variant="outlined">install</Button> <Button variant="outlined" onClick={() => install()}>{installedState}</Button>
</CardContent> </CardContent>
</Card> </Card>
); );

View File

@ -3,4 +3,6 @@ interface IExtension {
lang: string lang: string
versionName: string versionName: string
iconUrl: string iconUrl: string
installed: boolean
apkName: string
} }