diff --git a/src/containers/home/home.js b/src/containers/home/home.js
index b17aed5..4626765 100644
--- a/src/containers/home/home.js
+++ b/src/containers/home/home.js
@@ -1,10 +1,30 @@
import React from "react";
-import { Container, Paper, Typography, InputAdornment, FormControl, TextField, List, ListItem, ListItemText, CircularProgress, Button } from "@material-ui/core";
+import {
+ Container,
+ Paper,
+ Typography,
+ InputAdornment,
+ FormControl,
+ TextField,
+ List,
+ ListItem,
+ ListItemText,
+ CircularProgress,
+ Button,
+ Grid,
+ ClickAwayListener,
+ ExpansionPanel,
+ ExpansionPanelSummary,
+ ExpansionPanelDetails,
+ Checkbox,
+ FormGroup,
+ FormControlLabel } from "@material-ui/core";
import { fade, makeStyles } from '@material-ui/core/styles';
-
import SearchIcon from '@material-ui/icons/Search';
import CloudDownloadIcon from '@material-ui/icons/CloudDownload';
+import WarningIcon from '@material-ui/icons/Warning';
+import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
import './home.scss';
import { withTranslation } from 'react-i18next';
import FuzzySet from 'fuzzyset.js';
@@ -57,7 +77,7 @@ class Home extends React.Component {
deviceNamesID = {};
state = {
showDeviceData: false,
- device: null,
+ device: {},
deviceLoaded: false,
devices: [],
devicesLoaded: false,
@@ -66,17 +86,20 @@ class Home extends React.Component {
selectedSearchIndex: 0,
query: '',
downloading: false,
+ packages: {},
};
fuzzySet;
+ packages = ["opkg","ip6tables","odhcp6c","base-files","mtd","fstools","kmod-leds-gpio","busybox","wpad-mini","kmod-gpio-button-hotplug","kmod-mt76","logd","swconfig","dnsmasq","dropbear","ppp","netifd","ppp-mod-pppoe","uci","libc","uclient-fetch","kmod-ipt-offload","libgcc","odhcpd-ipv6only","iptables","firewall","luci"];
getDevicesData = () => fetch('https://chef.libremesh.org/download/json/devices.json').then(res => res.json());
getDeviceData = (device_id) => fetch('https://chef.libremesh.org/download/json/' + device_id + '.json').then(res => res.json());
componentDidMount() {
this.getDevicesData().then(data => {
- Object.keys(data['devices']).forEach((device_name) => {
+ Object.keys(data['devices']).forEach((device_id) => {
+ var device_name = data['devices'][device_id];
this.deviceNames.push(device_name);
- this.deviceNamesID[device_name] = data['devices'][device_name];
+ this.deviceNamesID[device_name] = device_id;
});
this.fuzzySet = FuzzySet(this.deviceNames);
this.setState({
@@ -84,17 +107,25 @@ class Home extends React.Component {
devicesLoaded: true,
});
});
+ var packages = {};
+ this.packages.forEach((package_name) => {
+ packages[package_name] = true;
+ });
+ this.setState({
+ packages,
+ });
}
selectDevice = (device_name) => {
if (device_name != null) {
+ var device_id = this.deviceNamesID[device_name];
this.setState({
showDeviceData: true,
showSearch: false,
query: device_name,
deviceLoaded: false,
});
- this.getDeviceData(this.state.devices[device_name]).then(data => {
+ this.getDeviceData(device_id).then(data => {
this.setState({
device: data,
deviceLoaded: true,
@@ -119,28 +150,22 @@ class Home extends React.Component {
}
this.setState({
searchResults,
- showSearch: true,
+ showSearch: query.length > 0,
});
}
- isDescendant = (parent, child) => {
- var node = child.parentNode;
- if (child === parent) {
- return true;
- }
- while (node !== null) {
- if (node === parent) {
- return true;
- }
- node = node.parentNode;
- }
- return false;
+ hideSearchResults = () => {
+ console.log("bahar")
+ this.setState({
+ showSearch: false
+ });
}
- toggleSearchIfIntended = (event) => {
- var showSearch = this.isDescendant(document.getElementsByClassName('search-container')[0], event.target) && this.state.query !== '';
+ packageSettingChange = (event, package_name) => {
+ var packages = this.state.packages;
+ packages[package_name] = event.target.checked;
this.setState({
- showSearch
+ packages,
});
}
@@ -156,6 +181,23 @@ class Home extends React.Component {
}
render() {
+ const warning432 = this.state.showDeviceData && parseInt((this.state.device['image_size'] || '').slice(0, -1)) <= 4000 && (
+
-