mirror of
https://github.com/ascribe/onion.git
synced 2024-12-31 17:17:48 +01:00
fineuploader session with cors
This commit is contained in:
parent
85347a8916
commit
18f3b51153
@ -110,8 +110,8 @@ let Form = React.createClass({
|
|||||||
buttons = (
|
buttons = (
|
||||||
<div className="row" style={{margin: 0}}>
|
<div className="row" style={{margin: 0}}>
|
||||||
<p className="pull-right">
|
<p className="pull-right">
|
||||||
<Button className="ascribe-btn" type="submit">Save</Button>
|
<Button className="btn btn-default btn-sm ascribe-margin-1px" type="submit">SAVE</Button>
|
||||||
<Button className="ascribe-btn" onClick={this.reset}>Cancel</Button>
|
<Button className="btn btn-danger btn-delete btn-sm ascribe-margin-1px" onClick={this.reset}>CANCEL</Button>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -555,6 +555,10 @@ let FileUploader = React.createClass({
|
|||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
'pk': this.props.edition.other_data ? this.props.edition.other_data.id : null
|
'pk': this.props.edition.other_data ? this.props.edition.other_data.id : null
|
||||||
|
},
|
||||||
|
cors: {
|
||||||
|
expected: true,
|
||||||
|
sendCredentials: true
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
areAssetsDownloadable={true}
|
areAssetsDownloadable={true}
|
||||||
|
@ -15,6 +15,8 @@ import ApplicationStore from '../stores/application_store';
|
|||||||
import GlobalNotificationModel from '../models/global_notification_model';
|
import GlobalNotificationModel from '../models/global_notification_model';
|
||||||
import GlobalNotificationActions from '../actions/global_notification_actions';
|
import GlobalNotificationActions from '../actions/global_notification_actions';
|
||||||
|
|
||||||
|
import ReactS3FineUploader from './ascribe_uploader/react_s3_fine_uploader';
|
||||||
|
|
||||||
import CollapsibleParagraph from './ascribe_collapsible/collapsible_paragraph';
|
import CollapsibleParagraph from './ascribe_collapsible/collapsible_paragraph';
|
||||||
import Form from './ascribe_forms/form';
|
import Form from './ascribe_forms/form';
|
||||||
import Property from './ascribe_forms/property';
|
import Property from './ascribe_forms/property';
|
||||||
@ -22,6 +24,7 @@ import Property from './ascribe_forms/property';
|
|||||||
import apiUrls from '../constants/api_urls';
|
import apiUrls from '../constants/api_urls';
|
||||||
import AppConstants from '../constants/application_constants';
|
import AppConstants from '../constants/application_constants';
|
||||||
|
|
||||||
|
import { getCookie } from '../utils/fetch_api_utils';
|
||||||
|
|
||||||
let SettingsContainer = React.createClass({
|
let SettingsContainer = React.createClass({
|
||||||
mixins: [Router.Navigation],
|
mixins: [Router.Navigation],
|
||||||
@ -30,8 +33,11 @@ let SettingsContainer = React.createClass({
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<AccountSettings />
|
<AccountSettings />
|
||||||
<BitcoinWalletSettings />
|
|
||||||
<APISettings />
|
<APISettings />
|
||||||
|
<BitcoinWalletSettings />
|
||||||
|
<LoanContractSettings />
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -172,19 +178,57 @@ let BitcoinWalletSettings = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let ContractSettings = React.createClass({
|
let LoanContractSettings = React.createClass({
|
||||||
|
|
||||||
propTypes: {
|
|
||||||
currentUser: React.PropTypes.object
|
|
||||||
},
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<CollapsibleParagraph
|
||||||
<div>Username: {this.props.currentUser.username}</div>
|
title="Loan Contract Settings"
|
||||||
<div>Email: {this.props.currentUser.email}</div>
|
show={true}
|
||||||
</div>
|
defaultExpanded={true}>
|
||||||
|
<FileUploader />
|
||||||
|
</CollapsibleParagraph>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let FileUploader = React.createClass({
|
||||||
|
propTypes: {
|
||||||
|
},
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<Form>
|
||||||
|
<Property
|
||||||
|
label="Contract file">
|
||||||
|
<ReactS3FineUploader
|
||||||
|
keyRoutine={{
|
||||||
|
url: AppConstants.serverUrl + 's3/key/',
|
||||||
|
fileClass: 'contract'
|
||||||
|
}}
|
||||||
|
createBlobRoutine={{
|
||||||
|
url: apiUrls.ownership_loans_contract
|
||||||
|
}}
|
||||||
|
validation={{
|
||||||
|
itemLimit: 100000,
|
||||||
|
sizeLimit: '10000000'
|
||||||
|
}}
|
||||||
|
session={{
|
||||||
|
endpoint: apiUrls.ownership_loans_contract,
|
||||||
|
customHeaders: {
|
||||||
|
'X-CSRFToken': getCookie('csrftoken')
|
||||||
|
},
|
||||||
|
cors: {
|
||||||
|
expected: true,
|
||||||
|
sendCredentials: true
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
areAssetsDownloadable={true}
|
||||||
|
areAssetsEditable={true}/>
|
||||||
|
</Property>
|
||||||
|
<hr />
|
||||||
|
</Form>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -23,6 +23,7 @@ let apiUrls = {
|
|||||||
'ownership_loans': AppConstants.apiEndpoint + 'ownership/loans/',
|
'ownership_loans': AppConstants.apiEndpoint + 'ownership/loans/',
|
||||||
'ownership_loans_confirm': AppConstants.apiEndpoint + 'ownership/loans/confirm/',
|
'ownership_loans_confirm': AppConstants.apiEndpoint + 'ownership/loans/confirm/',
|
||||||
'ownership_loans_deny': AppConstants.apiEndpoint + 'ownership/loans/deny/',
|
'ownership_loans_deny': AppConstants.apiEndpoint + 'ownership/loans/deny/',
|
||||||
|
'ownership_loans_contract': AppConstants.apiEndpoint + 'ownership/loans/contract/',
|
||||||
'ownership_shares': AppConstants.apiEndpoint + 'ownership/shares/',
|
'ownership_shares': AppConstants.apiEndpoint + 'ownership/shares/',
|
||||||
'ownership_transfers': AppConstants.apiEndpoint + 'ownership/transfers/',
|
'ownership_transfers': AppConstants.apiEndpoint + 'ownership/transfers/',
|
||||||
'ownership_transfers_withdraw': AppConstants.apiEndpoint + 'ownership/transfers/withdraw/',
|
'ownership_transfers_withdraw': AppConstants.apiEndpoint + 'ownership/transfers/withdraw/',
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import fetch from 'isomorphic-fetch';
|
import requests from '../utils/requests';
|
||||||
|
|
||||||
import AppConstants from '../constants/application_constants';
|
import AppConstants from '../constants/application_constants';
|
||||||
|
|
||||||
|
|
||||||
@ -11,13 +10,7 @@ let OwnershipFetcher = {
|
|||||||
* If no arg is supplied, load the current user
|
* If no arg is supplied, load the current user
|
||||||
*/
|
*/
|
||||||
fetchLoanContract(email) {
|
fetchLoanContract(email) {
|
||||||
return fetch(AppConstants.baseUrl + 'ownership/loans/contract/?loanee=' + email, {
|
return requests.get(AppConstants.apiEndpoint + 'ownership/loans/contract/?loanee=' + email);
|
||||||
headers: {
|
|
||||||
'Authorization': 'Basic ' + AppConstants.debugCredentialBase64
|
|
||||||
}
|
|
||||||
}).then(
|
|
||||||
(res) => res.json()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -44,10 +44,10 @@ class Requests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleAPIError(json) {
|
handleAPIError(json) {
|
||||||
if (!json.success) {
|
if (json.success === false) {
|
||||||
let error = new APIError();
|
let error = new APIError();
|
||||||
error.json = json;
|
error.json = json;
|
||||||
console.error(new Error('The \'success\' property is missing in the server\'s response.'));
|
//console.error(new Error('The \'success\' property is missing in the server\'s response.'));
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
return json;
|
return json;
|
||||||
|
Loading…
Reference in New Issue
Block a user