-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app): Add application installation
- Loading branch information
1 parent
25f252b
commit 479bd31
Showing
17 changed files
with
240 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>PlayOS</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> | ||
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"> | ||
<meta name="apple-mobile-web-app-capable" content="yes"> | ||
<meta name="apple-mobile-web-app-status-bar-style" content="black"> | ||
<meta name="format-detection" content="telephone=no"> | ||
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"> | ||
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"> | ||
<link rel="manifest" href="/manifest.json"> | ||
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5"> | ||
<meta name="theme-color" content="#ffffff"> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script src="./index.js" charset="utf-8"></script> | ||
</body> | ||
</html> |
Empty file.
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
Empty file.
Empty file.
58 changes: 58 additions & 0 deletions
58
src/js/components/molecules/SideNavigation/AppInstallDialog.tsx
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,58 @@ | ||
import * as React from 'react'; | ||
import { connect } from 'react-redux'; | ||
import Button from '@material-ui/core/Button'; | ||
import Dialog from '@material-ui/core/Dialog'; | ||
import DialogTitle from '@material-ui/core/DialogTitle'; | ||
import DialogContent from '@material-ui/core/DialogContent'; | ||
import DialogContentText from '@material-ui/core/DialogContentText'; | ||
import DialogActions from '@material-ui/core/DialogActions'; | ||
import TextField from '@material-ui/core/TextField'; | ||
import useMedia from '../../../services/hooks/useMedia'; | ||
import { addApplication } from '../../../services/ApplicationService'; | ||
import { addSingleApplication } from '../../../store/ApplicationStore'; | ||
|
||
interface Props { | ||
open: boolean; | ||
onClose: () => void; | ||
dispatch: Function; | ||
} | ||
|
||
function AppInstallDialog(props: Props) { | ||
const [manifestTextFieldValue, setManifestTextFieldValue] = React.useState(''); | ||
const isDesktop = useMedia('(min-width: 960px)'); | ||
|
||
async function handleAppInstallClick() { | ||
const app = await addApplication(manifestTextFieldValue); | ||
props.dispatch(addSingleApplication(app)); | ||
} | ||
|
||
function handleClose() { | ||
setManifestTextFieldValue(''); | ||
props.onClose(); | ||
} | ||
|
||
return ( | ||
<Dialog open={props.open} onClose={handleClose} fullScreen={!isDesktop}> | ||
<DialogTitle>Install app via Manifest</DialogTitle> | ||
<DialogContent> | ||
<DialogContentText> | ||
You can install Progressive Web Apps via the manifest.json. Please fill in the location of the manifest. | ||
</DialogContentText> | ||
<TextField | ||
margin="dense" | ||
fullWidth | ||
label="Manifest.json" | ||
value={manifestTextFieldValue} | ||
onChange={(event) => setManifestTextFieldValue(event.target.value)} | ||
/> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button onClick={handleClose}>Cancel</Button> | ||
<Button onClick={handleAppInstallClick} color="primary">Install</Button> | ||
</DialogActions> | ||
</Dialog> | ||
); | ||
} | ||
|
||
// @ts-ignore | ||
export default connect()(AppInstallDialog); |
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,16 @@ | ||
import Application from "../models/Application"; | ||
import IProvider from "./providers/IProvider"; | ||
import Configuration from "../Configuration"; | ||
|
||
export async function addApplication(manifestUrl: string): Promise<Application> { | ||
const provider: IProvider = Configuration.get('provider'); | ||
const response = await fetch(manifestUrl); | ||
const app: Application = await response.json(); | ||
|
||
app.id = Math.random().toString(); | ||
app.manifest_url = manifestUrl; | ||
|
||
await provider.addApplicationToStore(app); | ||
|
||
return app; | ||
} |
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,25 @@ | ||
import * as ethers from "ethers"; | ||
import Application from "../../models/Application"; | ||
|
||
class RutileContract { | ||
contract: ethers.Contract; | ||
|
||
constructor(address: string, provider: ethers.providers.JsonRpcProvider, wallet: ethers.Wallet) { | ||
const abi: string[] = [ | ||
'function addApplicationToStore(string app)', | ||
]; | ||
|
||
this.contract = new ethers.Contract(address, abi, wallet); | ||
} | ||
|
||
async addApplicationToStore(app: Application) { | ||
const data = ethers.utils.toUtf8Bytes(JSON.stringify(app)); | ||
const encodedData = ethers.utils.hexlify(data); | ||
|
||
console.log('[] this.contract -> ', this.contract); | ||
|
||
await this.contract.addApplicationToStore(encodedData); | ||
} | ||
} | ||
|
||
export default RutileContract; |
Oops, something went wrong.