Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fw upgrade one click #276

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
dce6d3d
refactor(app): introduce react-query
germanferrero Oct 19, 2020
dea6abc
improvement(firmware): add one click firmware upgrade support
germanferrero Oct 19, 2020
55ba7a9
refactor(stories): update stories
germanferrero Oct 19, 2020
8a407a8
chore(uhttpd.service): remove unnecessary sid property breaking tests
germanferrero Oct 19, 2020
3271fd6
chore(netadmin): fix api call after refactor of appcontext
germanferrero Oct 19, 2020
672866e
improvement(firmware): fix upload - upgrade file path logic
germanferrero Oct 20, 2020
0acfa38
improvement(firmware): add validation message for firmware image extname
germanferrero Oct 20, 2020
c45eba2
improvement(firmware): fix expected error message for invalid firmware
germanferrero Oct 20, 2020
855a84c
chore(firmware): fix typo in message
germanferrero Oct 20, 2020
0044613
improvement(firmware): fix downloading not showing up when downloading
germanferrero Oct 20, 2020
e2b1898
improvement(firmware): fix release banner hidding
germanferrero Oct 21, 2020
50cf1e1
improvement(firmware): clearly separate upgrade from release/file uis
germanferrero Oct 21, 2020
c182357
improvement(firmware): minor ui tweak
germanferrero Oct 21, 2020
0ffe48a
fix(firstbootwizard): ask root privilege to run fbw
germanferrero Oct 24, 2020
27f26a9
refactor(app): introduce react-query
germanferrero Oct 19, 2020
28a7d4e
improvement(firmware): add one click firmware upgrade support
germanferrero Oct 19, 2020
ce11b67
refactor(stories): update stories
germanferrero Oct 19, 2020
b60b8cb
chore(uhttpd.service): remove unnecessary sid property breaking tests
germanferrero Oct 19, 2020
5e3bff7
chore(netadmin): fix api call after refactor of appcontext
germanferrero Oct 19, 2020
dfa7693
improvement(firmware): fix upload - upgrade file path logic
germanferrero Oct 20, 2020
78dc6ba
improvement(firmware): add validation message for firmware image extname
germanferrero Oct 20, 2020
f1092e5
improvement(firmware): fix expected error message for invalid firmware
germanferrero Oct 20, 2020
cc5af04
chore(firmware): fix typo in message
germanferrero Oct 20, 2020
67e87a6
improvement(firmware): fix downloading not showing up when downloading
germanferrero Oct 20, 2020
a36b80b
improvement(firmware): fix release banner hidding
germanferrero Oct 21, 2020
d17799d
improvement(firmware): clearly separate upgrade from release/file uis
germanferrero Oct 21, 2020
4934253
improvement(firmware): minor ui tweak
germanferrero Oct 21, 2020
dda205c
Merge branch 'protect-firstbootwizard' into fw-upgrade-one-click
germanferrero Oct 28, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .storybook/addons.js

This file was deleted.

8 changes: 0 additions & 8 deletions .storybook/config.js

This file was deleted.

2 changes: 2 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const transformConfig = require('preact-cli/lib/lib/webpack/transform-config');
const webpack = require('webpack');

module.exports = {
stories: ['../stories/**/*.stories.js', '../plugins/**/*.stories.js'],
addons: ['@storybook/addon-actions', '@storybook/addon-knobs'],
webpackFinal: async(config, {configType}) => {
const isProd = configType === 'PRODUCTION';
const cwd = process.env.PWD;
Expand Down
3 changes: 2 additions & 1 deletion .storybook/preview-body.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<style>
body {
display: flex;
display: flex !important;
padding: 0 !important;
}
#root {
flex: auto;
Expand Down
52 changes: 52 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { h } from 'preact';
import '../src/i18nline-glue';
import '../src/style';

import { ReactQueryCacheProvider, QueryCache } from 'react-query';
import { addDecorator } from '@storybook/preact';
import { withKnobs } from '@storybook/addon-knobs';

const boarData = {
hostname: 'ql-anaymarcos',
release: {
description: 'LibreRouterOs 1.2-SNAPSHOT r0-21f7665'
},
model: 'LibreRouter v1'
};

const DEFAULT_QUERIES = [
[['system', 'board'], boarData]
]

function queryCacheFactory(queries=[]) {
const defaultQueries = Object.fromEntries(DEFAULT_QUERIES
.map(([key, value]) => [JSON.stringify(key), value]))
const customQueries = Object.fromEntries(queries
.map(([key, value]) => [JSON.stringify(key), value]))
const finalQueries = {
...defaultQueries,
...customQueries
}
const queryCache = new QueryCache({
defaultConfig: {
queries: {
initialStale: Infinity,
staleTime: Infinity,
refetchOnMount: false,
retry: 0
}
}
});
for (const [key, value] of Object.entries(finalQueries)) {
queryCache.setQueryData(JSON.parse(key), value)
}
return queryCache;
}

const withQueryCache = (Story, context) => (
<ReactQueryCacheProvider queryCache={queryCacheFactory(context.args.queries)}>
<Story />
</ReactQueryCacheProvider>
)
addDecorator(withKnobs);
addDecorator(withQueryCache);
26 changes: 20 additions & 6 deletions i18n/generic.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"en": {
"a_new_firmware_version_has_been_released_17f89266": "A new firmware version has been released",
"align_11050992": "Align",
"an_error_occurred_a4e1cda4": "An error occurred",
"applying_changes_the_system_takes_a_minute_to_get__189a700d": "Applying changes. The system takes a minute to get back online.",
"applying_changes_23ae34f2": "Applying changes.",
"at_least_one_alphanumeric_character_357817ee": "At least one alphanumeric character",
"at_least_one_number_bf8434bb": "At least one number",
"cancel_caeb1e68": "Cancel",
Expand Down Expand Up @@ -42,7 +43,11 @@
"create_network_d229d642": "Create network",
"create_new_network_28805f92": "Create new network",
"current_status_830c5a75": "Current status",
"currently_your_node_has_version_1c26984b": "Currently your node has version:",
"device_95d26d94": "Device",
"don_t_show_this_message_again_9950c20": "Don't show this message again",
"download_c7ffdfb9": "Download",
"downloading_1e41f805": "Downloading",
"edit_location_420eadc4": "edit location",
"error_98e81528": "Error",
"filename_83eeb4ac": "Filename",
Expand Down Expand Up @@ -71,6 +76,8 @@
"metrics_status_gateway_2a77a113": "metrics_status_gateway",
"metrics_status_path_905a8d22": "metrics_status_path",
"metrics_status_stations_464641e8": "metrics_status_stations",
"more_details_on_the_release_can_be_found_at_dfc8f165": "More details on the release can be found at:",
"more_info_at_117c8533": "More info at:",
"more_than_10_characters_15a6e3bf": "More than 10 characters",
"most_active_2d5a3cae": "Most Active",
"must_select_a_network_and_a_valid_hostname_ea82e72c": "Must select a network and a valid hostname",
Expand All @@ -81,25 +88,29 @@
"notes_of_a44a4158": "Notes of",
"ok_ff1b646a": "Ok",
"only_gateway_727b1656": "Only gateway",
"or_choose_a_firmware_image_from_your_device_d56be2d8": "Or choose a firmware image from your device",
"or_upgrade_to_latest_release_e062ddee": "Or upgrade to latest release",
"packet_loss_1afe48a8": "Packet loss",
"password_8a271b1c": "Password",
"please_configure_your_network_d6eb8b76": "Please configure your network",
"please_select_a_file_b49d6bf4": "Please select a file",
"please_select_a_sh_or_bin_file_4004723": "Please select a .sh or .bin file",
"please_wait_62914c7c": "Please wait",
"please_wait_patiently_for_seconds_seconds_and_do_n_b98cfb66": "Please wait patiently for %{seconds} seconds and do not disconnect the device.",
"please_wait_while_the_device_reboots_and_reload_th_67bd290d": "Please wait while the device reboots, and reload the app",
"preserve_config_94b340cf": "Preserve config",
"re_enter_password_49757ed": "Re-enter Password",
"re_enter_the_shared_password_20f09406": "Re-enter the shared password",
"reload_3e45154f": "Reload",
"reload_page_2d381199": "Reload page",
"rescan_dff042fc": "Rescan",
"retry_ebd5f8ba": "Retry",
"revert_702e7694": "Revert",
"reverting_to_previous_version_e6e43529": "Reverting to previous version",
"save_notes_616850ea": "Save notes",
"scan_for_existing_networks_f7f485c": "Scan for existing networks",
"scanning_for_existing_networks_195ddb9b": "Scanning for existing networks",
"seconds_aee2098": "seconds",
"see_more_b24a4422": "See More",
"select_a_network_to_join_b7040672": "Select a network to join",
"select_file_71aa4113": "Select file",
"select_new_base_station_3652ae73": "Select new base station",
Expand All @@ -111,15 +122,15 @@
"shared_password_dac7c19d": "Shared Password",
"show_community_42f3833": "show community",
"size_b30e1077": "Size",
"station_ip_v4_3158a957": "Station IP v4",
"station_name_7d67417c": "Station name",
"stations_18122820": "Stations",
"status_e7fdbe06": "Status",
"system_55b0ca91": "System",
"the_download_failed_130e1274": "The download failed",
"the_firmware_is_being_upgraded_f3881802": "The firmware is being upgraded...",
"the_password_should_have_b9f88155": "The password should have:",
"the_passwords_do_not_match_62d77c67": "The passwords do not match!",
"the_selected_image_is_not_a_valid_for_the_target_d_c5edf208": "The selected image is not a valid for the target device",
"the_selected_image_is_not_valid_for_the_target_dev_cea9b494": "The selected image is not valid for the target device",
"the_shared_password_has_been_chosen_by_the_communi_f9d30a92": "The shared password has been chosen by the community when the network was created. You can ask other community members for it.",
"the_upgrade_should_be_done_d66854": "The upgrade should be done",
"this_device_does_not_support_secure_rollback_to_pr_1c167a2c": "This device does not support secure rollback to previous version if something goes wrong",
Expand All @@ -131,18 +142,21 @@
"to_the_previous_configuration_bf087867": "to the previous configuration",
"traffic_bfe536d2": "Traffic",
"try_reloading_the_app_4e4c3a66": "Try reloading the app",
"un_unexpected_error_occurred_please_contact_the_de_b9eb7c49": "Un unexpected error occurred, please contact the developer team",
"upgrade_5de364f8": "Upgrade",
"upgrade_now_f300d697": "Upgrade Now",
"upgrade_to_lastest_firmware_version_9b159910": "Upgrade to lastest firmware version",
"upgrade_to_versionname_621a0b6a": "Upgrade to %{versionName}",
"upload_firmware_image_from_your_device_57327bee": "Upload firmware image from your device",
"uptime_c1d2415d": "Uptime",
"versionname_is_now_available_a6fbbb63": "%{versionName} is now available",
"when_reloading_the_app_you_will_be_asked_to_confir_f9ecb33e": "When reloading the app you will be asked to confirm the upgrade, otherwise it will be reverted",
"wrong_password_try_again_3100aecf": "Wrong password, try again",
"you_are_connected_to_another_node_in_the_network_t_a423710a": "You are connected to another node in the network, try connecting to",
"you_are_now_part_of_90f2585a": "You are now part of ",
"you_can_search_for_mesh_networks_around_you_to_add_e6fbf1c5": "You can search for mesh networks around you to add or to create a new one.",
"you_can_upgrade_to_7af1ea19": "You can upgrade to:",
"you_don_t_go_through_any_paths_to_get_here_25203ed3": "You don't go through any paths to get here.",
"you_have_successfuly_connected_to_ddb8c613": "You have successfuly connected to",
"you_may_need_to_connect_to_the_new_wireless_networ_e931e438": "You may need to connect to the new wireless network and reload the app",
"you_need_to_know_the_shared_password_to_enter_this_4b0c4ec1": "You need to know the shared password to enter this page",
"you_should_try_to_connect_to_the_network_network_8d7f515e": "You should try to connect to the network %{network}.",
"your_router_has_not_yet_been_configured_you_can_us_27c91373": "Your router has not yet been configured, \n\t\t\tyou can use our wizard to incorporate it into an existing network or create a new one.\n\t\t\tIf you ignore this message it will continue to work with the default configuration."
Expand Down
31 changes: 23 additions & 8 deletions i18n/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@
"traffic_bfe536d2": "Tráfico",
"uptime_c1d2415d": "Tiempo en actividad",
"interfaces_44f8a99c": "Interfaces",
"applying_changes_the_system_takes_a_minute_to_get__189a700d": "Aplicando cambios, el equipo puede no responder por un minuto.",
"ground_routing_12ab04c9": "Ground Routing",
"ground_routing_configuration_3f4fa9c1": "Configuración de Ground Routing",
"login_6f3d6249": "Ingresar",
"station_ip_v4_3158a957": "IP v4",
"station_name_7d67417c": "Nombre del nodo",
"this_node_does_not_see_other_nodes_in_the_network_f281b047": "Este nodo no ve a ningún otro nodo la red",
"cancel_caeb1e68": "Cancelar",
Expand Down Expand Up @@ -107,17 +105,13 @@
"you_need_to_know_the_shared_password_to_enter_this_4b0c4ec1": "Debes ingresar la contraseña compartida para seguir",
"shared_password_dac7c19d": "Contraseña Compartida",
"an_error_occurred_a4e1cda4": "Ocurrió un error",
"un_unexpected_error_occurred_please_contact_the_de_b9eb7c49": "Un error inesperado ocurrió, porfavor contactá al equipo de desarrollo",
"reload_3e45154f": "Recargar",
"firmware_6a098a0d": "Firmware",
"preserve_config_94b340cf": "Preservar configuración",
"select_file_71aa4113": "Seleccioná el archivo",
"you_may_need_to_connect_to_the_new_wireless_networ_e931e438": "Es posible que debas conectarte a la nueva red wifi y recargar la aplicación",
"the_selected_image_is_not_a_valid_for_the_target_d_c5edf208": "La imagen seleccionada no es válida para este dispositivo",
"the_selected_image_is_not_valid_for_the_target_dev_cea9b494": "La imagen seleccionada no es válida para este dispositivo",
"this_device_does_not_support_secure_rollback_to_pr_1c167a2c": "En este dispositivo no se puede revertir la actualización en caso de errores",
"this_device_supports_secure_rollback_to_previous_v_a60ddbcb": "En este dispositivo se puede revertir la actualización en caso de errores",
"upgrade_5de364f8": "Actualizar",
"upload_firmware_image_from_your_device_57327bee": "Subí una imagen de firmware desde tu dispositivo",
"cofirm_upgrade_before_seconds_seconds_or_it_will_b_48b600b6": "Confirmá la actualización en los próximos %{seconds} segundos o será revertida",
"confirm_6556b3a6": "Confirmar",
"filename_83eeb4ac": "Nombre",
Expand Down Expand Up @@ -150,6 +144,27 @@
"count_seconds_2953a98e": {
"one": "segundo",
"other": "segundos"
}
},
"a_new_firmware_version_has_been_released_17f89266": "Nueva versión del firmware disponible",
"applying_changes_23ae34f2": "Aplicando cambios",
"currently_your_node_has_version_1c26984b": "Actualmente tu nodo tiene la versión",
"more_details_on_the_release_can_be_found_at_dfc8f165": "Puedes encontrar las novedades de esta versión en:",
"upgrade_now_f300d697": "Actualizar ahora",
"versionname_is_now_available_a6fbbb63": "%{versionName} ya está disponible",
"you_can_upgrade_to_7af1ea19": "Puedes actualizar a:",
"don_t_show_this_message_again_9950c20": "No volver a mostrar a este mensaje",
"download_c7ffdfb9": "Descargar",
"downloading_1e41f805": "Descargando",
"more_info_at_117c8533": "Más info en:",
"retry_ebd5f8ba": "Reintenar",
"see_more_b24a4422": "Ver más",
"the_download_failed_130e1274": "La descarga falló",
"upgrade_to_versionname_621a0b6a": "Actualizar a %{versionName}",
"upload_firmware_image_from_your_device_57327bee": "Subí una imagen del firmware desde tu dispositivo",
"please_select_a_sh_or_bin_file_4004723": "Por favor, seleccioná un archivo .bin o .sh",
"or_choose_a_firmware_image_from_your_device_d56be2d8": "O elige una imagen de firmware desde tu dispositivo",
"or_upgrade_to_latest_release_e062ddee": "O actualiza a la última version del firmware",
"upgrade_to_lastest_firmware_version_9b159910": "Actualizar a la última version del firwmare"

}

10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
"devDependencies": {
"@commitlint/cli": "^8.0.0",
"@commitlint/config-conventional": "^8.0.0",
"@storybook/addon-actions": "^5.3.19",
"@storybook/addon-knobs": "^5.3.19",
"@storybook/preact": "^5.3.19",
"@storybook/addon-actions": "^6.0.26",
"@storybook/addon-knobs": "^6.0.26",
"@storybook/preact": "^6.0.26",
"@testing-library/jest-dom": "^5.9.0",
"@testing-library/preact": "^2.0.0",
"colors": "^1.4.0",
Expand All @@ -57,6 +57,7 @@
"jest": "^24.9.0",
"jest-extended": "^0.11.5",
"jest-preset-preact": "^1.0.0",
"jest-when": "^2.7.2",
"per-env": "^1.0.2",
"preact-cli": "^3.0.0-rc.6",
"preact-render-spy": "^1.2.1",
Expand All @@ -78,6 +79,9 @@
"preact-render-to-string": "^5.1.0",
"preact-router": "^3.0.0",
"preact-router-redux": "^4.1.0",
"react-hook-form": "^6.9.2",
"react-query": "^2.23.1",
"react-query-devtools": "^2.6.0",
"react-redux": "^7.1.3",
"react-router-redux": "^4.0.8",
"redux": "^4.0.0",
Expand Down
32 changes: 4 additions & 28 deletions plugins/lime-plugin-admin/admin.stories.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,19 @@
/* eslint-disable react/display-name */
import { h } from 'preact';
import { action } from '@storybook/addon-actions';
import { withKnobs, text } from '@storybook/addon-knobs/react';

import { Admin } from './src/adminPage';
import { AppContext } from 'utils/app.context';

const actions = {
changeHostname: action('changeHostname')
};

export default {
title: 'Containers|Admin',
component: Admin,
decorators: [withKnobs]
title: 'Containers/Admin',
component: Admin
};

const nodeHostname = text('nodeHostname', 'ql-anaymarcos');
export const configForm = () => <Admin loading={false} {...actions} />

export const configForm = () => {
const appContext = { nodeHostname };
return (
<AppContext.Provider value={appContext}>
<Admin
loading={false}
{...actions}
/>
</AppContext.Provider>);
};

export const waitingForChanges = () => {
const appContext = { nodeHostname };
return (
<AppContext.Provider value={appContext}>
<Admin
loading
{...actions}
/>
</AppContext.Provider>
);
};
export const waitingForChanges = () => <Admin loading {...actions} />

7 changes: 3 additions & 4 deletions plugins/lime-plugin-admin/src/adminPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import Loading from 'components/loading';
import I18n from 'i18n-js';
import { isValidHostname, slugify } from 'utils/isValidHostname';
import { showNotification } from '../../../src/store/actions';
import { useAppContext } from 'utils/app.context';
import axios from 'axios';
import { useBoardData } from 'utils/queries';

const style = {
textLoading: {
Expand All @@ -37,8 +36,8 @@ const style = {


export const Admin = ({ ipv4, changeHostname, showNotification, loading, redirect, error }) => {
const { nodeHostname } = useAppContext();
const [ hostname, setHostname ] = useState(nodeHostname);
const { data: boardData } = useBoardData();
const [ hostname, setHostname ] = useState(boardData && boardData.hostname);

useEffect(() => {
if (redirect) {
Expand Down
Loading