openwrt-firmware-selector/src/services/data.js
Sudhanshu Gautam 9475f4092a Add ESLint to maintain code style. Add pre-commit hook to lint prior.
ESLint is used with the standard react plugin. It detects all kinds of
issues ranging from misspells, indentation, variable-naming, etc.
A pre-commit hook is added to git. Prior commiting, ESlint will run
to validate that everything is OK and the user will have the option
to fix it.

Signed-off-by: Sudhanshu Gautam <me@sudhanshug.com>
2019-07-21 22:03:51 +05:30

48 lines
1.2 KiB
JavaScript

import axios from 'axios';
const base = 'https://cors-anywhere.herokuapp.com/https://mwarning.de/misc/json/bin';
class DataService {
getDevicesData = axios.get(
`${base}/overview.json`)
.then(res => res.data);
getDeviceData = (device_id) => axios.get(
base + '/targets/' + device_id)
.then(res => res.data);
getDistributions = axios.get(
'https://chef.libremesh.org/api/distributions')
.then(res => res.data);
buildImage = (board, packages, target, version) => {
return axios.post('https://chef.libremesh.org/api/build-request', {
board,
defaults: '',
distro: 'openwrt',
packages,
target,
version,
});
};
buildStatusCheck = async (request_hash) => {
let response = {
isBuilt: false,
};
await axios.get('https://chef.libremesh.org/api/build-request/' + request_hash).then((res) => {
response.isBuilt = res.status === 202 && res.data.files !== undefined;
response.status = res.status;
if (response.isBuilt) {
response = {...response, data: res.data};
}
});
return response;
};
getFiles = (files_url) => axios.get('https://chef.libremesh.org' + files_url).then(res => res.data);
}
export default DataService;