mirror of
https://git.netzspielplatz.de/docker-multiarch/openwrt-firmware-selector.git
synced 2025-11-08 21:59:27 +00:00
Adds ability to show device manifest for vanilla images
Loads `openwrt-<target>-<sub-target>-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 <me@sudhanshug.com>
This commit is contained in:
parent
dd6624c322
commit
740383d6be
2 changed files with 59 additions and 17 deletions
|
|
@ -57,8 +57,9 @@ TabContainer.propTypes = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const sleep = m => new Promise(r => setTimeout(r, m));
|
const sleep = m => new Promise(r => setTimeout(r, m));
|
||||||
|
const CORSbyPass = 'https://cors-anywhere.herokuapp.com/';
|
||||||
const asu = 'https://aparcar.stephen304.com';
|
const asu = 'https://aparcar.stephen304.com';
|
||||||
const asu_download =
|
const asu_vanilla =
|
||||||
'https://aparcar.stephen304.com/download/json-demo/openwrt/';
|
'https://aparcar.stephen304.com/download/json-demo/openwrt/';
|
||||||
|
|
||||||
class Home extends React.Component {
|
class Home extends React.Component {
|
||||||
|
|
@ -97,11 +98,13 @@ class Home extends React.Component {
|
||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
try {
|
try {
|
||||||
const versionsResponse = await this.dataService.getVersions();
|
const versionsResponse = await this.dataService.getVersions(
|
||||||
|
CORSbyPass + asu_vanilla + 'versions.json'
|
||||||
|
);
|
||||||
let data = versionsResponse.data.versions;
|
let data = versionsResponse.data.versions;
|
||||||
for (var i = 0; i < data.length; i++) {
|
for (var i = 0; i < data.length; i++) {
|
||||||
const overviewResponse = await this.dataService.getOverview(
|
const overviewResponse = await this.dataService.getOverview(
|
||||||
data[i].path
|
CORSbyPass + asu_vanilla + data[i].path + '/overview.json'
|
||||||
);
|
);
|
||||||
data[i].devices = overviewResponse.data.devices;
|
data[i].devices = overviewResponse.data.devices;
|
||||||
}
|
}
|
||||||
|
|
@ -158,6 +161,7 @@ class Home extends React.Component {
|
||||||
deviceSubPath = deviceSubPath.replace('//', '/generic/');
|
deviceSubPath = deviceSubPath.replace('//', '/generic/');
|
||||||
}
|
}
|
||||||
const devicePath = version.path + '/targets/' + deviceSubPath;
|
const devicePath = version.path + '/targets/' + deviceSubPath;
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
showDeviceData: true,
|
showDeviceData: true,
|
||||||
showSearch: false,
|
showSearch: false,
|
||||||
|
|
@ -167,12 +171,28 @@ class Home extends React.Component {
|
||||||
showAdvanced: false,
|
showAdvanced: false,
|
||||||
configChanged: true,
|
configChanged: true,
|
||||||
});
|
});
|
||||||
let deviceResponse = await this.dataService.getDeviceData(devicePath);
|
|
||||||
|
const deviceResponse = await this.dataService.getDeviceData(
|
||||||
|
CORSbyPass + asu_vanilla + devicePath
|
||||||
|
);
|
||||||
selection = this.state.selection;
|
selection = this.state.selection;
|
||||||
selection.device = deviceResponse.data;
|
selection.device = deviceResponse.data;
|
||||||
if (selection.device.target[selection.device.target.length - 1] === '/') {
|
if (selection.device.target[selection.device.target.length - 1] === '/') {
|
||||||
selection.device.target += 'generic';
|
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) {
|
} catch (err) {
|
||||||
this.setState({
|
this.setState({
|
||||||
showUnexpectedErrorBar: true,
|
showUnexpectedErrorBar: true,
|
||||||
|
|
@ -292,15 +312,15 @@ class Home extends React.Component {
|
||||||
};
|
};
|
||||||
|
|
||||||
displayBuiltImageData = async buildStatusResponse => {
|
displayBuiltImageData = async buildStatusResponse => {
|
||||||
const manifestResponse = await this.dataService.getDeviceManifest(
|
const builtDeviceManifest = await this.dataService.getDeviceManifest(
|
||||||
|
CORSbyPass +
|
||||||
|
asu +
|
||||||
buildStatusResponse.data.image_folder +
|
buildStatusResponse.data.image_folder +
|
||||||
'/' +
|
'/' +
|
||||||
buildStatusResponse.data.image_prefix +
|
buildStatusResponse.data.image_prefix +
|
||||||
'.manifest'
|
'.manifest'
|
||||||
);
|
);
|
||||||
|
|
||||||
const builtDeviceManifest = manifestResponse.data.split('\n');
|
|
||||||
|
|
||||||
let builtImages = [];
|
let builtImages = [];
|
||||||
buildStatusResponse.data.images.forEach(image => {
|
buildStatusResponse.data.images.forEach(image => {
|
||||||
builtImages.push({
|
builtImages.push({
|
||||||
|
|
@ -596,6 +616,29 @@ class Home extends React.Component {
|
||||||
{this.props.t('Version')}:{' '}
|
{this.props.t('Version')}:{' '}
|
||||||
{this.state.data[this.state.selection.version].name} (
|
{this.state.data[this.state.selection.version].name} (
|
||||||
{this.state.data[this.state.selection.version].revision})
|
{this.state.data[this.state.selection.version].revision})
|
||||||
|
<ExpansionPanel
|
||||||
|
className="installed-packages"
|
||||||
|
elevation={0}
|
||||||
|
>
|
||||||
|
<ExpansionPanelSummary
|
||||||
|
expandIcon={<ExpandMoreIcon />}
|
||||||
|
id="packages-manifest"
|
||||||
|
>
|
||||||
|
<Typography className="installed-packages-title">
|
||||||
|
Installed Packages (
|
||||||
|
{this.state.selection.device.deviceManifest.length})
|
||||||
|
</Typography>
|
||||||
|
</ExpansionPanelSummary>
|
||||||
|
<ExpansionPanelDetails>
|
||||||
|
<div>
|
||||||
|
{this.state.selection.device.deviceManifest.map(
|
||||||
|
package_name => (
|
||||||
|
<div key={package_name}>{package_name}</div>
|
||||||
|
)
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</ExpansionPanelDetails>
|
||||||
|
</ExpansionPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs>
|
<Grid item xs>
|
||||||
<b>{this.props.t('Downloads')}: </b>
|
<b>{this.props.t('Downloads')}: </b>
|
||||||
|
|
@ -604,7 +647,7 @@ class Home extends React.Component {
|
||||||
<Button
|
<Button
|
||||||
className="download-button"
|
className="download-button"
|
||||||
href={
|
href={
|
||||||
asu_download +
|
asu_vanilla +
|
||||||
this.state.data[this.state.selection.version].path +
|
this.state.data[this.state.selection.version].path +
|
||||||
'/targets/' +
|
'/targets/' +
|
||||||
this.state.selection.device.target +
|
this.state.selection.device.target +
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,19 @@
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
const base =
|
|
||||||
'https://cors-anywhere.herokuapp.com/https://aparcar.stephen304.com';
|
|
||||||
const base_downloads =
|
|
||||||
'https://cors-anywhere.herokuapp.com/https://aparcar.stephen304.com/download/json-demo/openwrt/';
|
|
||||||
const base_api =
|
const base_api =
|
||||||
'https://cors-anywhere.herokuapp.com/https://aparcar.stephen304.com/api/';
|
'https://cors-anywhere.herokuapp.com/https://aparcar.stephen304.com/api/';
|
||||||
|
|
||||||
class DataService {
|
class DataService {
|
||||||
getVersions = () => axios.get(base_downloads + 'versions.json');
|
getVersions = versionsPath => axios.get(versionsPath);
|
||||||
|
|
||||||
getOverview = path => axios.get(base_downloads + path + '/overview.json');
|
getOverview = overviewPath => axios.get(overviewPath);
|
||||||
|
|
||||||
getDeviceData = device_path => axios.get(base_downloads + device_path);
|
getDeviceData = devicePath => axios.get(devicePath);
|
||||||
|
|
||||||
getDeviceManifest = manifest_path => axios.get(base + manifest_path);
|
getDeviceManifest = async manifest_path => {
|
||||||
|
const manifest = await axios.get(manifest_path);
|
||||||
|
return manifest.data.split('\n');
|
||||||
|
};
|
||||||
|
|
||||||
getDevicePackages = (version, target, profile) =>
|
getDevicePackages = (version, target, profile) =>
|
||||||
axios.get(
|
axios.get(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue