- {isToobNamModelFile && (
-
-
- Download model files from TONE3000
-
- { this.handleTone3000Help(e); }} aria-label="help" edge="end" color="inherit" style={{ opacity: 0.6, marginLeft: 8 }}
- >
-
-
-
-
- )}
- {isToobMLModelFile && (
-
-
- Download model files from GuitarML
-
- { this.handleGuitarMlHelp(e); }} aria-label="help" edge="end" color="inherit" style={{ opacity: 0.6, marginLeft: 8 }}
- >
-
-
-
-
- )}
-
-
- {this.state.windowWidth > 500 ? (
-
-
-
-
this.handleDelete()} >
-
+
+ {isToobNamModelFile && (
+
+
+
{ this.handleTone3000Help(e); }} aria-label="help" edge="end" color="inherit" style={{ opacity: 0.6, marginLeft: 8 }}
+ >
+
-
-
}
- onClick={() => { this.setState({ openUploadFileDialog: true }) }} disabled={protectedDirectory}
- >
-
Upload
-
-
-
}
- onClick={() => { this.handleDownloadFile(); }} disabled={protectedDirectory || !this.state.hasFileSelection}
- >
-
Download
-
-
-
-
-
-
-
- ) : (
-
-
-
this.handleDelete()} >
-
+
+ )}
+ {isToobMLModelFile && (
+
+
+ Download model files from GuitarML
+
+
{ this.handleGuitarMlHelp(e); }} aria-label="help" edge="end" color="inherit" style={{ opacity: 0.6, marginLeft: 8 }}
+ >
+
-
-
}
- onClick={() => { this.setState({ openUploadFileDialog: true }) }} disabled={protectedDirectory}
- >
-
Upload
-
-
-
}
- onClick={() => { this.handleDownloadFile(); }} disabled={protectedDirectory || !this.state.hasFileSelection}
-
- >
-
Download
-
-
-
-
-
-
-
+
+ {this.state.windowWidth > 500 ? (
+
+
+
+
this.handleDelete()} >
+
+
+
+
}
+ onClick={() => { this.setState({ openUploadFileDialog: true }) }} disabled={protectedDirectory}
+ >
+
Upload
+
+
+
}
+ onClick={() => { this.handleDownloadFile(); }} disabled={protectedDirectory || !this.state.hasFileSelection}
+ >
+
Download
+
+
+
+
+
+
+
-
- )}
+ ) : (
+
+
+
this.handleDelete()} >
+
+
+
+
}
+ onClick={() => { this.setState({ openUploadFileDialog: true }) }} disabled={protectedDirectory}
+ >
+
Upload
+
+
+
}
+ onClick={() => { this.handleDownloadFile(); }} disabled={protectedDirectory || !this.state.hasFileSelection}
+
+ >
+
Download
+
+
+
+
+
+
+
+
+
+
+
+ )}
>
@@ -1742,12 +1742,17 @@ export default withStyles(
)
)
}
- {/* {this.state.openTone3000Dialog && (
+ {this.state.openTone3000Dialog && (
this.setState({ openTone3000Dialog: false })}
+ onCancel={() => this.setState({ openTone3000Dialog: false })}
+ onDownload={(toneUrl: string) => {
+ alert("Donload tone url: " + toneUrl);
+ this.setState({ openTone3000Dialog: false });
+ }
+ }
/>
- )} */}
+ )}
{this.state.openTone3000Help && (
)}
{this.state.textFileName !== undefined && (
- this.setState({ textFileName: undefined })}
- />
+ fileName={this.state.textFileName} onClose={() => this.setState({ textFileName: undefined })}
+ />
)}
);
}
isLicenseFile(fileName: string) {
let extension = pathExtension(fileName);
- if (extension === ".txt" || extension === ".md"){
+ if (extension === ".txt" || extension === ".md") {
return true;
- }
+ }
let fileNameOnly = pathFileNameOnly(fileName);
- if (fileNameOnly.toUpperCase() === "LICENSE" || fileNameOnly.toUpperCase() === "README")
- {
+ if (fileNameOnly.toUpperCase() === "LICENSE" || fileNameOnly.toUpperCase() === "README") {
return true;
}
return false;
diff --git a/vite/src/pipedal/Tone3000Dialog.tsx b/vite/src/pipedal/Tone3000Dialog.tsx
index 8b889fc..d585447 100644
--- a/vite/src/pipedal/Tone3000Dialog.tsx
+++ b/vite/src/pipedal/Tone3000Dialog.tsx
@@ -1,15 +1,10 @@
import React from 'react';
-import Dialog from '@mui/material/Dialog';
-import DialogTitle from '@mui/material/DialogTitle';
-import DialogContent from '@mui/material/DialogContent';
-import DialogActions from '@mui/material/DialogActions';
-import Button from '@mui/material/Button';
+import AppBar from '@mui/material/AppBar';
import Typography from '@mui/material/Typography';
import { PiPedalModel, PiPedalModelFactory } from './PiPedalModel';
import DialogEx from './DialogEx';
-import Link from '@mui/material/Link';
import Toolbar from '@mui/material/Toolbar';
import IconButtonEx from './IconButtonEx';
import ArrowBackIcon from '@mui/icons-material/ArrowBack';
@@ -19,142 +14,109 @@ import ArrowBackIcon from '@mui/icons-material/ArrowBack';
export interface Tone3000DialogProps {
open: boolean;
- onClose: () => void;
+ onCancel: () => void;
+ onDownload: (toneUrl: string) => void;
}
+interface Tone3000AuthState {
+ authToken: string;
+ refreshToken: string;
+ expiry: number;
+};
+
+// function getAuthToken(): Tone3000AuthState | null {
+
+// let authToken = window.localStorage.getItem("tone300_auth_token");
+// if (authToken === null) {
+// return null;
+// }
+// let refreshToken = window.localStorage.getItem("tone3000_refresh_token");
+// if (refreshToken === null) {
+// return null;
+// }
+// let expiry = window.localStorage.getTime("tone3000_auth_expiry");
+// return { authToken: authToken, refreshToken: refreshToken, expiry: expiry };
+// }
+
+// function setAuthToken(authToken: string, refreshToken: string, expirySeconds: number) {
+// window.localStorage.setItem("tone3000_auth_token", authToken);
+// window.localStorage.setItem("tone3000_refresh_token", refreshToken);
+// window.localStorage.setItem("tone3000_auth_expiry", String(Date.now() + (expirySeconds * 1000)));
+// }
+
+// enum AuthState {
+// OnBoarding,
+// TokenExpired,
+// Authenticated
+// }
+
function Tone3000Dialog(props: Tone3000DialogProps) {
- const { open, onClose } = props;
-
- const model: PiPedalModel = PiPedalModelFactory.getInstance();
-
- let [openAuthDialog, setOpenAuthDialog] = React.useState(!model.hasTone3000Auth.get());
-
-
- React.useEffect(()=> {
- let authListener = (value: boolean) => {
- setOpenAuthDialog(!value);
- }
- model.hasTone3000Auth.addOnChangedHandler(authListener);
- return () => {
- model.hasTone3000Auth.removeOnChangedHandler(authListener);
- }
- });
+ const { onCancel,onDownload } = props;
function RedirectUrl() {
let baseUrl = new URL(window.location.href);
- let result = "http://" + baseUrl.hostname + ":" + baseUrl.port + "/";
+ let result = "http://" + baseUrl.hostname + ":" + baseUrl.port + "/public/handleTone3000download.html";
return result;
}
- function AuthUrl() {
- //return "https://www.tone3000.com/api/v1/auth?redirect_url=" + encodeURIComponent(RedirectUrl()) + "&opt_only=true";
- return "https://www.tone3000.com/api/v1/auth?redirect_url=" + encodeURIComponent(RedirectUrl()) + "&otp_only=true";
+ const appId = 'pipedal_app';
+ const redirectUrl = RedirectUrl();
+
+ let selectUrl = `https://www.tone3000.com/api/v1/select?app_id=${appId}&redirect_url=${redirectUrl}`;
+
+ const model: PiPedalModel = PiPedalModelFactory.getInstance();
+ if (model) {
+
}
+
+ React.useEffect(()=> {
+
+ let messagehandler = (event: MessageEvent) => {
+ // Handle messages received from the iframe
+ if (event.origin !== "https://www.tone3000.com") {
+ return;
+ }
+ const data = event.data;
+ if (data.type === "tone3000_selection") {
+ onDownload(data.toneUrl);
+ }
+ }
+ window.addEventListener("message", messagehandler);
+
+ return () => {
+ window.removeEventListener("message", messagehandler);
+ }
+ });
+
+
return (
- { onClose(); }}
- onClose={() => { onClose(); }}
- aria-labelledby="tone3000-dialog-title"
- aria-describedby="tone3000-dialog-description"
- >
-
-
- { onClose(); }}
- >
-
-
+ { onCancel()}} fullScreen={true} tag="tone3000Dlg" onEnterKey={()=>{}} >
-
- TONE3000 Models
-
-
-
-
-
-
- This is a placeholder for the Tone 3000 dialog.
-
-
-
-
-
- {
- openAuthDialog && (
-
);