import { compose } from 'redux';
import { DetailsAttribute } from "components/details-attribute/details-attribute";
import { DownloadIcon } from "components/icon/icon";
+import { DefaultCodeSnippet } from "components/default-code-snippet/default-code-snippet";
-export type CssRules = 'details' | 'downloadButton';
+export type CssRules = 'details' | 'downloadButton' | 'detailsAttrValWithCode';
const styles: StyleRulesCallback<CssRules> = theme => ({
details: {
},
downloadButton: {
marginTop: theme.spacing.unit * 2,
+ },
+ detailsAttrValWithCode: {
+ display: "flex",
+ alignItems: "center",
}
});
<key>Port</key>
<string>${(cyberDavStr.split(':')[2] || '443').split('/')[0]}</string>
<key>Username</key>
- <string>${username}</string>${isValidIpAddress(collectionsUrl.replace('https://', ``).split(':')[0])?
+ <string>${username}</string>${isValidIpAddress(collectionsUrl.replace('https://', ``).split(':')[0]) ?
`
<key>Path</key>
<string>/c=${uuid}</string>` : ''}
} else {
winDav = new URL(props.data.downloadUrl);
cyberDav = new URL(props.data.downloadUrl);
- winDav.pathname = `/by_id/${props.data.uuid}`;
- cyberDav.pathname = `/by_id/${props.data.uuid}`;
+ winDav.pathname = `/c=${props.data.uuid}`;
+ cyberDav.pathname = `/c=${props.data.uuid}`;
}
cyberDav.username = props.data.username;
tokenSecret = tokenUuid;
}
- const supportsWebdav = (props.data.uuid.indexOf("-4zz18-") === 5);
+ const isCollection = (props.data.uuid.indexOf("-4zz18-") === 5);
let activeTab = props.data.activeTab;
- if (!supportsWebdav) {
+ if (!isCollection) {
activeTab = 2;
}
+ const wgetCommand = `wget --http-user=${props.data.username} --http-passwd=${props.data.token} --mirror --no-parent --no-host --cut-dirs=0 ${winDav.toString()}`;
+ const curlCommand = `curl -O -u ${props.data.username}:${props.data.token} ${winDav.toString()}`;
+
return <Dialog
open={props.open}
maxWidth="md"
title={`Open with 3rd party client`} />
<div className={props.classes.details} >
<Tabs value={activeTab} onChange={props.data.setActiveTab}>
- {supportsWebdav && <Tab value={0} key="cyberduck" label="WebDAV" />}
- {supportsWebdav && <Tab value={1} key="windows" label="Windows or MacOS" />}
+ {isCollection && <Tab value={0} key="cyberduck" label="WebDAV" />}
+ {isCollection && <Tab value={1} key="windows" label="Windows or MacOS" />}
<Tab value={2} key="s3" label="S3 bucket" />
- {supportsWebdav && <Tab value={3} key="cli" label="wget / curl" />}
+ {isCollection && <Tab value={3} key="cli" label="wget / curl" />}
</Tabs>
<TabPanel index={1} value={activeTab}>
Download Cyber/Mountain Duck bookmark
</Button>
- <h3>Gnome</h3>
+ <h3>GNOME</h3>
<ol>
<li>Open Files</li>
<li>Select +Other Locations</li>
<DetailsAttribute
label='Wget command'
- value={`wget --http-user=${props.data.username} --http-passwd=${props.data.token} --mirror --no-parent --no-host --cut-dirs=0 ${winDav.toString()}`}
- copyValue={winDav.toString()} />
+ copyValue={wgetCommand}
+ classValue={props.classes.detailsAttrValWithCode}>
+ <DefaultCodeSnippet
+ lines={[wgetCommand]} />
+ </DetailsAttribute>
<DetailsAttribute
- label='Username'
- value={props.data.username}
- copyValue={props.data.username} />
-
- <DetailsAttribute
- label='Password'
- value={props.data.token}
- copyValue={props.data.token} />
+ label='Curl command'
+ copyValue={curlCommand}
+ classValue={props.classes.detailsAttrValWithCode}>
+ <DefaultCodeSnippet
+ lines={[curlCommand]} />
+ </DetailsAttribute>
+
+ <p>
+ Note: This curl command downloads single files.
+ Append the desired filename to the end of the URL.
+ </p>
</TabPanel>
color='primary'
onClick={props.closeDialog}>
Close
- </Button>
+ </Button>
</DialogActions>
</Dialog >;