-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #250 from italia/upload-zip
Upload zip
- Loading branch information
Showing
18 changed files
with
838 additions
and
44 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
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
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
178 changes: 178 additions & 0 deletions
178
spid-validator/client/src/views/MetadataSpUploadZip/MetadataSpUploadZip.js
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,178 @@ | ||
import React, { Component } from 'react'; | ||
import view from "./view.js"; | ||
import Utility from '../../utility'; | ||
import Services from '../../services'; | ||
import ReduxStore from "../../redux/store"; | ||
import Actions from "../../redux/main/actions"; | ||
|
||
|
||
class MetadataSpUploadZip extends Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
detailview: false, | ||
file: null, | ||
loading: false, | ||
loaded: false, | ||
fileName: null, | ||
fileSize: null, | ||
fileType: null, | ||
check: "extra", | ||
profile: "spid-sp-ag-public-full", | ||
production: true, | ||
report: null | ||
}; | ||
} | ||
|
||
componentDidMount() { | ||
let service = Services.getMainService(); | ||
let store = ReduxStore.getMain(); | ||
let storeState = store.getState(); | ||
} | ||
|
||
render() { | ||
return view(this); | ||
} | ||
|
||
setDetailView(detailed) { | ||
this.setState({ | ||
detailview: detailed | ||
}); | ||
} | ||
|
||
setCheck(check) { | ||
this.setState({ | ||
check: check | ||
}); | ||
} | ||
|
||
setProfile(profile) { | ||
this.setState({ | ||
profile: profile | ||
}); | ||
} | ||
|
||
setProduction(production) { | ||
this.setState({ | ||
production: production | ||
}); | ||
this.setState({ | ||
production: production | ||
}, ()=> { | ||
this.uploadMetadataZip(this.state.file); | ||
}); | ||
} | ||
|
||
|
||
uploadMetadataZip(metadata_zip) { | ||
|
||
let service = Services.getMainService(); | ||
|
||
this.setState({ | ||
file: metadata_zip, | ||
loading: true, | ||
loaded: false, | ||
fileName: metadata_zip.name, | ||
fileSize: metadata_zip.size, | ||
fileType: metadata_zip.type, | ||
report: null | ||
}); | ||
|
||
Utility.blockUI(true); | ||
service.uploadFile( | ||
metadata_zip, | ||
this.state.check, | ||
this.state.profile, | ||
this.state.production? 'Y':'N', | ||
|
||
(progress)=> { | ||
let progress_percent = Math.round((parseInt(progress.loaded)*100)/parseInt(progress.total)); | ||
if(progress_percent<100) { | ||
this.setState({ | ||
progress_message: "Uploading ZIP file...", | ||
progress: progress_percent + "%" | ||
}); | ||
} else { | ||
this.setState({ | ||
progress_message: "Validating all metadata. Please wait...", | ||
progress: "" | ||
}); | ||
} | ||
}, | ||
(progress)=> { | ||
let progress_percent = Math.round((parseInt(progress.loaded)*100)/parseInt(progress.total)); | ||
this.setState({ | ||
progress_message: "Downloading report...", | ||
progress: progress_percent + '%' | ||
}); | ||
}, | ||
(report)=> { | ||
this.setState({ | ||
file: metadata_zip, | ||
loading: false, | ||
loaded: true, | ||
progress: 0, | ||
check: report.check, | ||
profile: report.profile, | ||
production: report.production, | ||
report: report | ||
}); | ||
|
||
Utility.blockUI(false); | ||
}, | ||
(error)=> { | ||
Utility.showModal({ | ||
title: "Errore", | ||
body: error, | ||
isOpen: true | ||
}); | ||
this.setState({ | ||
file: null, | ||
loading: false, | ||
loaded: false, | ||
fileName: null, | ||
fileSize: null, | ||
fileType: null, | ||
check: "extra", | ||
profile: "spid-sp-ag-public-full", | ||
production: true, | ||
report: null | ||
}); | ||
|
||
Utility.blockUI(false); | ||
} | ||
); | ||
} | ||
|
||
openMetadata(metadata) { | ||
let service = Services.getMainService(); | ||
let store = ReduxStore.getMain(); | ||
|
||
Utility.blockUI(true); | ||
service.setSessionMetadata(metadata, | ||
(success)=> { | ||
store.dispatch(Actions.setMetadataSpURL(metadata.url)); | ||
store.dispatch(Actions.setMetadataSpXML(metadata.xml)); | ||
this.props.history.push('/metadata-sp-download'); | ||
Utility.blockUI(false); | ||
}, | ||
(error)=> { | ||
Utility.showModal({ | ||
title: "Errore", | ||
body: error, | ||
isOpen: true | ||
}); | ||
Utility.blockUI(false); | ||
} | ||
); | ||
} | ||
|
||
print() { | ||
Utility.print(this.state.fileName); | ||
} | ||
|
||
} | ||
|
||
export default MetadataSpUploadZip; |
6 changes: 6 additions & 0 deletions
6
spid-validator/client/src/views/MetadataSpUploadZip/package.json
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,6 @@ | ||
{ | ||
"name": "MetadataSpUploadZip", | ||
"version": "0.0.0", | ||
"private": true, | ||
"main": "./MetadataSpUploadZip.js" | ||
} |
Oops, something went wrong.