From 740383d6be99d03a0e0f4a804836416445a61fc9 Mon Sep 17 00:00:00 2001 From: Sudhanshu Gautam Date: Wed, 4 Sep 2019 23:19:23 +0530 Subject: [PATCH] Adds ability to show device manifest for vanilla images Loads `openwrt---default.manifest` in case of Vanilla images and shows the list of default installed packages in a retractable list. Fixes #15 Signed-off-by: Sudhanshu Gautam --- src/containers/home/home.js | 61 +++++++++++++++++++++++++++++++------ src/services/data.js | 15 +++++---- 2 files changed, 59 insertions(+), 17 deletions(-) diff --git a/src/containers/home/home.js b/src/containers/home/home.js index 1fcc33a..4171b04 100644 --- a/src/containers/home/home.js +++ b/src/containers/home/home.js @@ -57,8 +57,9 @@ TabContainer.propTypes = { }; const sleep = m => new Promise(r => setTimeout(r, m)); +const CORSbyPass = 'https://cors-anywhere.herokuapp.com/'; const asu = 'https://aparcar.stephen304.com'; -const asu_download = +const asu_vanilla = 'https://aparcar.stephen304.com/download/json-demo/openwrt/'; class Home extends React.Component { @@ -97,11 +98,13 @@ class Home extends React.Component { async componentDidMount() { try { - const versionsResponse = await this.dataService.getVersions(); + const versionsResponse = await this.dataService.getVersions( + CORSbyPass + asu_vanilla + 'versions.json' + ); let data = versionsResponse.data.versions; for (var i = 0; i < data.length; i++) { const overviewResponse = await this.dataService.getOverview( - data[i].path + CORSbyPass + asu_vanilla + data[i].path + '/overview.json' ); data[i].devices = overviewResponse.data.devices; } @@ -158,6 +161,7 @@ class Home extends React.Component { deviceSubPath = deviceSubPath.replace('//', '/generic/'); } const devicePath = version.path + '/targets/' + deviceSubPath; + this.setState({ showDeviceData: true, showSearch: false, @@ -167,12 +171,28 @@ class Home extends React.Component { showAdvanced: false, configChanged: true, }); - let deviceResponse = await this.dataService.getDeviceData(devicePath); + + const deviceResponse = await this.dataService.getDeviceData( + CORSbyPass + asu_vanilla + devicePath + ); selection = this.state.selection; selection.device = deviceResponse.data; if (selection.device.target[selection.device.target.length - 1] === '/') { selection.device.target += 'generic'; } + + selection.device.deviceManifest = await this.dataService.getDeviceManifest( + CORSbyPass + + asu_vanilla + + version.path + + '/targets/' + + selection.device.target + + '/openwrt-' + + selection.device.target.split('/')[0] + + '-' + + selection.device.target.split('/')[1] + + '-default.manifest' + ); } catch (err) { this.setState({ showUnexpectedErrorBar: true, @@ -292,15 +312,15 @@ class Home extends React.Component { }; displayBuiltImageData = async buildStatusResponse => { - const manifestResponse = await this.dataService.getDeviceManifest( - buildStatusResponse.data.image_folder + + const builtDeviceManifest = await this.dataService.getDeviceManifest( + CORSbyPass + + asu + + buildStatusResponse.data.image_folder + '/' + buildStatusResponse.data.image_prefix + '.manifest' ); - const builtDeviceManifest = manifestResponse.data.split('\n'); - let builtImages = []; buildStatusResponse.data.images.forEach(image => { builtImages.push({ @@ -596,6 +616,29 @@ class Home extends React.Component { {this.props.t('Version')}:{' '} {this.state.data[this.state.selection.version].name} ( {this.state.data[this.state.selection.version].revision}) + + } + id="packages-manifest" + > + + Installed Packages ( + {this.state.selection.device.deviceManifest.length}) + + + +
+ {this.state.selection.device.deviceManifest.map( + package_name => ( +
{package_name}
+ ) + )} +
+
+
{this.props.t('Downloads')}: @@ -604,7 +647,7 @@ class Home extends React.Component {