@cryptotaxi247 / netdata-1 / commits / cf948d42c

Switched to the new React dashboard code as the default dashboard. (#8363)

* Initial installer components for new dashboard. * Add script to switch between react and classic dashboards. * Update to newest version of react dashboard. * Properly substitute webdir. * Fix installation of dashboard switch script. * Properly handle file ownership and permissions. * Fix install of react dashboard. * Add dashboard_info.js to the react dashboard tree. * Update to version 0.3.2 of the React dashboard. * Switch using file lists instead of nuking old directory. * Properly handle updates. * Fix variable naming in switching script. * Fix copying of files in switching script. * Fix switching script invocation in installer. * update dashboard to v0.4.0 * v0.4.1 gauge & easypiechart width update proper centering when clicking alarm in alarms-log keep loader until react app is ready fix top bar not showing when highlighting (few lines of code) "check known URLs" issue "reset" options is not hooked up go to host node from streamed node (low priority, because that's removed on release) * Persist user selection of dashboard across updates. * update dashboard to v0.4.2 (temperature, units options fixed) * v0.4.5 fixed print modal progress text force reload on sync-selection option change * fix memory leak on firefox * fix active-alarms number in main.js header fix "back to normal" notifications constantly throwing in loop * fix active-alarms fetching * support subpaths Co-authored-by: Jacek Kolasa <jacek.kolasa@gmail.com>

Austin S. Hemmelgarn committed Mar 31, 2020 at 06:53 UTC cf948d42c22093db5d5085b3b453f7bcc2d52ae3
9 files changed +143 -1
.gitignore
+1
@@ -128,6 +128,7 @@ collectors/python.d.plugin/python.d.plugin
128 collectors/fping.plugin/fping.plugin
129 collectors/ioping.plugin/ioping.plugin
130 collectors/go.d.plugin
131 +web/netdata-switch-dashboard.sh
132
133 # installer generated files
134 /netdata-uninstaller.sh
Makefile.am
+2
@@ -60,6 +60,8 @@ dist_noinst_DATA = \
60 package.json \
61 docs \
62 packaging/version \
63 + packaging/dashboard.version \
64 + packaging/dashboard.checksums \
65 packaging/go.d.version \
66 packaging/go.d.checksums \
67 packaging/libwebsockets.version \
build/subst.inc
+1
@@ -8,6 +8,7 @@
8 -e 's#[@]cachedir_POST@#$(cachedir)#g' \
9 -e 's#[@]registrydir_POST@#$(registrydir)#g' \
10 -e 's#[@]varlibdir_POST@#$(varlibdir)#g' \
11 + -e 's#[@]webdir_POST@#$(webdir)#g' \
12 $< > $@.tmp; then \
13 mv "$@.tmp" "$@"; \
14 else \
netdata-installer.sh
+59
@@ -571,6 +571,13 @@ bundle_libwebsockets() {
571
572 bundle_libwebsockets
573
574 +# -----------------------------------------------------------------------------
575 +# If we have the dashboard switching logic, make sure we're on the classic
576 +# dashboard during the install (updates don't work correctly otherwise).
577 +if [ -x "${NETDATA_PREFIX}/usr/libexec/netdata-switch-dashboard.sh" ] ; then
578 + "${NETDATA_PREFIX}/usr/libexec/netdata-switch-dashboard.sh" classic
579 +fi
580 +
581 # -----------------------------------------------------------------------------
582 echo >&2
583 progress "Run autotools to configure the build environment"
@@ -964,6 +971,57 @@ fi
971
972 # -----------------------------------------------------------------------------
973
974 +copy_react_dashboard() {
975 + run rm -rf "${NETDATA_WEB_DIR}-react"
976 + run rm -rf "${NETDATA_WEB_DIR}-classic"
977 + run cp -a "${1}/" "${NETDATA_WEB_DIR}-react"
978 + run cp -a "${NETDATA_WEB_DIR}/dashboard_info.js" "${NETDATA_WEB_DIR}-react"
979 + run cp -a "${NETDATA_WEB_DIR}/dashboard.slate.css" "${NETDATA_WEB_DIR}-react"
980 + run cp -a "${NETDATA_WEB_DIR}/dashboard.css" "${NETDATA_WEB_DIR}-react"
981 + run cp -a "${NETDATA_WEB_DIR}/main.css" "${NETDATA_WEB_DIR}-react"
982 + run echo "$(cd ${NETDATA_WEB_DIR}-react && find . -type f | sed -e 's/\.\///')" > "${NETDATA_WEB_DIR}-react/.files"
983 + run cp -a "${NETDATA_WEB_DIR}" "${NETDATA_WEB_DIR}-classic"
984 + run echo "$(find web/gui -type f | sed -e "s/web\/gui\///")" > "${NETDATA_WEB_DIR}-classic/.files"
985 + run chown -R "${NETDATA_WEB_USER}:${NETDATA_WEB_GROUP}" "${NETDATA_WEB_DIR}-react"
986 +}
987 +
988 +install_react_dashboard() {
989 + progress "Fetching and installing dashboard"
990 +
991 + DASHBOARD_PACKAGE_VERSION="$(cat packaging/dashboard.version)"
992 +
993 + tmp="$(mktemp -d -t netdata-dashboard-XXXXXX)"
994 + DASHBOARD_PACKAGE_BASENAME="dashboard.tar.gz"
995 +
996 + if fetch_and_verify "dashboard" \
997 + "https://github.com/netdata/dashboard/releases/download/${DASHBOARD_PACKAGE_VERSION}/${DASHBOARD_PACKAGE_BASENAME}" \
998 + "${DASHBOARD_PACKAGE_BASENAME}" \
999 + "${tmp}" \
1000 + "${NETDATA_LOCAL_TARBALL_OVERRIDE_DASHBOARD}"
1001 + then
1002 + if run tar -xf "${tmp}/${DASHBOARD_PACKAGE_BASENAME}" -C "${tmp}" && \
1003 + copy_react_dashboard "${tmp}/build" && \
1004 + rm -rf "${tmp}"
1005 + then
1006 + if run "${NETDATA_PREFIX}/usr/libexec/netdata/netdata-switch-dashboard.sh" "${NETDATA_SELECTED_DASHBOARD:-react}" ; then
1007 + run_ok "React dashboard installed."
1008 + else
1009 + run_failed "Failed to switch to React dashboard."
1010 + run rm -rf "${NETDATA_WEB_DIR}"
1011 + run cp -a "${NETDATA_WEB_DIR}-classic" "${NETDATA_WEB_DIR}"
1012 + fi
1013 + else
1014 + run_failed "Failed to install React dashboard. The install process will continue, but you will not be able to use the new dashboard."
1015 + fi
1016 + else
1017 + run_failed "Unable to fetch React dashboard. The install process will continue, but you will not be able to use the new dashboard."
1018 + fi
1019 +}
1020 +
1021 +install_react_dashboard
1022 +
1023 +# -----------------------------------------------------------------------------
1024 +
1025 # govercomp compares go.d.plugin versions. Exit codes:
1026 # 0 - version1 == version2
1027 # 1 - version1 > version2
@@ -1512,6 +1570,7 @@ REINSTALL_OPTIONS="${REINSTALL_OPTIONS}"
1570 RELEASE_CHANNEL="${RELEASE_CHANNEL}"
1571 IS_NETDATA_STATIC_BINARY="${IS_NETDATA_STATIC_BINARY}"
1572 NETDATA_LIB_DIR="${NETDATA_LIB_DIR}"
1573 +NETDATA_SELECTED_DASHBOARD="${NETDATA_SELECTED_DASHBOARD:-react}"
1574 EOF
1575 run chmod 0644 "${NETDATA_USER_CONFIG_DIR}/.environment"
1576
packaging/dashboard.checksums new
+1
@@ -0,0 +1 @@
1 +42e43aa7caf411f01799c2858621f9cd23061bf55e3ceef3f1bb9b2327ff3172 dashboard.tar.gz
packaging/dashboard.version new
+1
@@ -0,0 +1 @@
1 +v0.4.9
packaging/installer/netdata-updater.sh
+5 -1
@@ -185,8 +185,12 @@ update() {
185 do_not_start="--dont-start-it"
186 fi
187
188 + if [ -n "${NETDATA_SELECTED_DASHBOARD}" ] ; then
189 + env="NETDATA_SELECTED_DASHBOARD=${NETDATA_SELECTED_DASHBOARD}"
190 + fi
191 +
192 info "Re-installing netdata..."
189 - eval "./netdata-installer.sh ${REINSTALL_OPTIONS} --dont-wait ${do_not_start}" >&3 2>&3 || fatal "FAILED TO COMPILE/INSTALL NETDATA"
193 + eval "${env} ./netdata-installer.sh ${REINSTALL_OPTIONS} --dont-wait ${do_not_start}" >&3 2>&3 || fatal "FAILED TO COMPILE/INSTALL NETDATA"
194
195 # We no longer store checksum info here. but leave this so that we clean up all environment files upon next update.
196 sed -i '/NETDATA_TARBALL/d' "${ENVIRONMENT_FILE}"
web/Makefile.am
+13
@@ -9,8 +9,20 @@ SUBDIRS = \
9 server \
10 $(NULL)
11
12 +CLEANFILES = \
13 + netdata-switch-dashboard.sh \
14 + $(NULL)
15 +
16 usersslconfigdir=$(configdir)/ssl
17
18 +include $(top_srcdir)/build/subst.inc
19 +SUFFIXES = .in
20 +
21 +scriptsdir=${prefix}/libexec/netdata
22 +scripts_SCRIPTS = \
23 + netdata-switch-dashboard.sh \
24 + $(NULL)
25 +
26 # Explicitly install directories to avoid permission issues due to umask
27 install-exec-local:
28 $(INSTALL) -d $(DESTDIR)$(usersslconfigdir)
@@ -19,4 +31,5 @@ dist_noinst_DATA = \
31 README.md \
32 gui/confluence/README.md \
33 gui/custom/README.md \
34 + netdata-switch-dashboard.sh.in \
35 $(NULL)
web/netdata-switch-dashboard.sh.in new
+60
@@ -0,0 +1,60 @@
1 +#!/bin/sh
2 +# SPDX-License-Identifier: GPL-3.0-or-later
3 +# (c) 2020 Netdata Incorporated
4 +
5 +set -e
6 +
7 +webdir="@webdir_POST@"
8 +configdir="@configdir_POST@"
9 +
10 +usage() {
11 + cat << EOF
12 +USAGE: switch-netdata-dashboard.sh <dashboard-name>
13 +
14 +<dashboard-name> is required, it specifies which dashboard to use. Valid
15 +arguments are 'react' to use the new React dashboard, and 'classic'
16 +to use the old dashboard.
17 +
18 +Once run, you can use the new dashboard by performing a valdiating reload
19 +in your browser (Ctrl-Shift-R in most browsers).
20 +EOF
21 +exit 1
22 +}
23 +
24 +switch_dashboard() {
25 + new="${1}"
26 + path="${webdir}-${new}"
27 +
28 + echo "Switching to ${new} dashboard..."
29 +
30 + for dashboard in classic react ; do
31 + # shellcheck disable=SC2013
32 + for item in $(cat ${webdir}-${dashboard}/.files) ; do
33 + rm -f "${webdir}/${item}"
34 + done
35 + done
36 +
37 + cp -a "${path}/." "${webdir}"
38 +
39 + if [ -e "${configdir}/.environment" ] ; then
40 + if grep -q NETDATA_SELECTED_DASHBOARD "${configdir}/.environment" ; then
41 + sed -E "s/^NETDATA_SELECTED_DASHBOARD=\".*\"$/NETDATA_SELECTED_DASHBOARD=\"${new}\"/" "${configdir}/.environment"
42 + else
43 + echo "NETDATA_SELECTED_DASHBOARD=\"${new}\"" >> "${configdir}/.environment"
44 + fi
45 + fi
46 +
47 + exit 0
48 +}
49 +
50 +case "${1}" in
51 + react)
52 + switch_dashboard react
53 + ;;
54 + classic)
55 + switch_dashboard classic
56 + ;;
57 + *)
58 + usage
59 + ;;
60 +esac