mirror of
https://git.netzspielplatz.de/docker-multiarch/openwrt-firmware-selector.git
synced 2025-11-08 17:19:25 +00:00
fix snapshot download links
This commit is contained in:
parent
849c4b6366
commit
b3b52baf11
5 changed files with 27 additions and 8 deletions
|
|
@ -11,7 +11,9 @@ const config = {
|
|||
default_version: '19.07.7',
|
||||
|
||||
// Image download URL (optional)
|
||||
image_url: 'https://downloads.openwrt.org/releases/{version}/targets/{target}',
|
||||
base_url: 'https://downloads.openwrt.org',
|
||||
releases_directory: 'releases',
|
||||
target_directory: 'targets',
|
||||
|
||||
// Info link URL (optional)
|
||||
info_url: 'https://openwrt.org/start?do=search&id=toh&q={title}',
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import config from '../../../config';
|
|||
import { getTitle } from '../utils/title';
|
||||
import asu from '../../../utils/asu';
|
||||
import { GetBuildResponse } from '../../../types/asu';
|
||||
import { getAsuDownloadLink, getStockDownloadLink } from '../utils/links';
|
||||
|
||||
const useStyles = makeStyles(() => ({
|
||||
chip: {
|
||||
|
|
@ -153,9 +154,11 @@ const ProfileDetails: FunctionComponent<Props> = ({ selectedVersion, selectedPro
|
|||
|
||||
const buildCustomImage = async () => {
|
||||
setBuildStatus('Please wait...');
|
||||
setBuildError(undefined);
|
||||
try {
|
||||
const response = await asu.build(
|
||||
Array.from(customPackages.values()),
|
||||
profile.target,
|
||||
profile.id,
|
||||
profile.version_number,
|
||||
onBuildStatusChange
|
||||
|
|
@ -254,9 +257,11 @@ const ProfileDetails: FunctionComponent<Props> = ({ selectedVersion, selectedPro
|
|||
</TableHead>
|
||||
<TableBody>
|
||||
{profile.images?.map((i) => {
|
||||
const downloadURL = `${config.image_url
|
||||
.replace('{target}', profile.target)
|
||||
.replace('{version}', profile.version_number)}/${i.name}`;
|
||||
const downloadURL = getStockDownloadLink(
|
||||
profile.version_number,
|
||||
profile.target,
|
||||
i.name
|
||||
);
|
||||
return (
|
||||
<TableRow key={downloadURL + i.type}>
|
||||
<TableCell>
|
||||
|
|
@ -426,8 +431,7 @@ const ProfileDetails: FunctionComponent<Props> = ({ selectedVersion, selectedPro
|
|||
</TableHead>
|
||||
<TableBody>
|
||||
{buildResponse.images?.map((i) => {
|
||||
// eslint-disable-next-line max-len
|
||||
const downloadURL = `${config.asu_url}/store/${buildResponse.bin_dir}/${i.name}`;
|
||||
const downloadURL = getAsuDownloadLink(buildResponse.bin_dir, i.name);
|
||||
return (
|
||||
<TableRow key={downloadURL + i.type}>
|
||||
<TableCell>
|
||||
|
|
|
|||
11
src/containers/home/utils/links.ts
Normal file
11
src/containers/home/utils/links.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import config from '../../../config';
|
||||
|
||||
export const getAsuDownloadLink = (bin_dir: string, name: string) => {
|
||||
return `${config.asu_url}/store/${bin_dir}/${name}`;
|
||||
};
|
||||
|
||||
export const getStockDownloadLink = (version: string, target: string, name: string) => {
|
||||
return `${config.base_url}/${
|
||||
version === 'SNAPSHOT' ? 'snapshots' : `${config.releases_directory}/${version}`
|
||||
}/${config.target_directory}/${target}/${name}`;
|
||||
};
|
||||
|
|
@ -3,8 +3,9 @@ import config from '../config';
|
|||
import { GetBuildResponse } from '../types/asu';
|
||||
|
||||
const asu = {
|
||||
buildNew: (packages: string[], profile: string, version: string) =>
|
||||
buildNew: (packages: string[], target: string, profile: string, version: string) =>
|
||||
axios.post<GetBuildResponse>(`${config.asu_url}/api/build`, {
|
||||
target,
|
||||
version,
|
||||
profile,
|
||||
packages,
|
||||
|
|
|
|||
|
|
@ -3,11 +3,12 @@ import { sleep } from './common';
|
|||
|
||||
const build = async (
|
||||
packages: string[],
|
||||
target: string,
|
||||
profile: string,
|
||||
version: string,
|
||||
buildStatusCallback: (status: string) => void
|
||||
) => {
|
||||
const buildResponse = await api.asu.buildNew(packages, profile, version);
|
||||
const buildResponse = await api.asu.buildNew(packages, target, profile, version);
|
||||
if (buildResponse.status === 202) {
|
||||
buildStatusCallback(`#${buildResponse} in queue`);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue