From a3113603b26f2822b049fc7b132129ca73e848d5 Mon Sep 17 00:00:00 2001 From: joshuaboud Date: Fri, 28 May 2021 15:57:30 -0300 Subject: [PATCH 01/22] update gitignore for deb packaging --- .gitignore | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.gitignore b/.gitignore index 722d5e7..a3abede 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,13 @@ +# IDE .vscode + +# deb packaging +debian/cockpit-samba-manager +debian/cockpit-samba-manager.substvars +debian/cockpit-samba-manager.postrm.debhelper +debian/debhelper-build-stamp +debian/files +debian/.debhelper + +# build output +dist \ No newline at end of file From f39c14ac26a1e875b2f610ae9bcdb14620f4808c Mon Sep 17 00:00:00 2001 From: joshuaboud Date: Fri, 28 May 2021 16:08:27 -0300 Subject: [PATCH 02/22] set up deb packaging files --- debian/changelog | 5 +++++ debian/control | 13 +++++++++++++ debian/copyright | 35 +++++++++++++++++++++++++++++++++++ debian/rules | 23 +++++++++++++++++++++++ debian/source/format | 1 + 5 files changed, 77 insertions(+) create mode 100644 debian/changelog create mode 100644 debian/control create mode 100644 debian/copyright create mode 100755 debian/rules create mode 100644 debian/source/format diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..5aa0cc0 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +cockpit-navigator (0.0.1-1focal) focal; urgency=medium + + * Initial packaging of cockpit-navigator for Ubuntu Focal. + + -- Josh Boudreau Fri, 28 May 2021 3:58:00 -0300 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..068b2a7 --- /dev/null +++ b/debian/control @@ -0,0 +1,13 @@ +Source: cockpit-navigator +Section: utils +Priority: optional +Maintainer: Josh Boudreau +Build-Depends: debhelper-compat (= 12) +Standards-Version: 4.4.1 +Homepage: https://github.com/45Drives/cockpit-navigator + +Package: cockpit-navigator +Architecture: all +Depends: ${shlibs:Depends}, ${misc:Depends}, + cockpit, python3 +Description: A File System Browser for Cockpit. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..bf6b808 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,35 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: cockpit-navigator +Upstream-Contact: Josh Boudreau +Source: https://github.com/45Drives/cockpit-navigator + +Files: * +Copyright: 2021 Josh Boudreau +License: GPL-3.0+ + +Files: navigator/navigator.* +Copyright: 2021 Sam Silver +License: GPL-3.0+ + +Files: navigator/navigator.js +Copyright: 2021 Dawson Della Valle +License: GPL-3.0+ + +Files: debian/* +Copyright: 2021 Josh Boudreau +License: GPL-3.0+ + +License: GPL-3.0+ + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + . + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with the Onboard package. If not, please have a look at + /usr/share/common-licenses or . diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..e73eae0 --- /dev/null +++ b/debian/rules @@ -0,0 +1,23 @@ +#!/usr/bin/make -f +# See debhelper(7) (uncomment to enable) +# output every command that modifies files on the build system. +#export DH_VERBOSE = 1 + + +# see FEATURE AREAS in dpkg-buildflags(1) +#export DEB_BUILD_MAINT_OPTIONS = hardening=+all + +# see ENVIRONMENT in dpkg-buildflags(1) +# package maintainers to append CFLAGS +#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic +# package maintainers to append LDFLAGS +#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed + +%: + dh $@ + + +# dh_make generated override targets +# This is example for Cmake (See https://bugs.debian.org/641051 ) +#override_dh_auto_configure: +# dh_auto_configure -- # -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) From 1ba43c7bf222b73230d11ad3f7992849846c44b6 Mon Sep 17 00:00:00 2001 From: joshuaboud Date: Fri, 28 May 2021 16:09:26 -0300 Subject: [PATCH 03/22] change first version to 0.1.0 --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 5aa0cc0..0ea640b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -cockpit-navigator (0.0.1-1focal) focal; urgency=medium +cockpit-navigator (0.1.0-1focal) focal; urgency=medium * Initial packaging of cockpit-navigator for Ubuntu Focal. From 282bf8afb28d3f3e9003f7896dbc75c63df819f0 Mon Sep 17 00:00:00 2001 From: joshuaboud Date: Fri, 28 May 2021 16:11:29 -0300 Subject: [PATCH 04/22] create spec file for RPM packaging --- el/cockpit-navigator.spec | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 el/cockpit-navigator.spec diff --git a/el/cockpit-navigator.spec b/el/cockpit-navigator.spec new file mode 100644 index 0000000..f1a9a11 --- /dev/null +++ b/el/cockpit-navigator.spec @@ -0,0 +1,36 @@ +Name: cockpit-navigator +Version: 0.1.0 +Release: 1%{?dist} +Summary: A File System Browser for Cockpit. +License: GPL-3.0+ +URL: github.com/45drives/cockpit-navigator/blob/main/README.md +Source0: %{name}-%{version}.tar.gz +BuildArch: noarch +Requires: cockpit python3 + +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root + +%description +Cockpit Navigator +A File System Browser for Cockpit. + +%prep +%setup -q + +%build +# empty + +%install +rm -rf %{buildroot} +mkdir -p %{buildroot} +cp -a * %{buildroot} + +%clean +rm -rf %{buildroot} + +%files +/usr/share/cockpit/samba-navigator/* + +%changelog +* Fri May 28 2021 Josh Boudreau 0.1.0-1 +- First Build From 507ff2cddaaf27e05ff6eb4d2e695f87c9c4b01d Mon Sep 17 00:00:00 2001 From: joshuaboud Date: Fri, 28 May 2021 16:15:07 -0300 Subject: [PATCH 05/22] add dockerfiles for build containers --- docker/el7 | 17 +++++++++++++++++ docker/el8 | 15 +++++++++++++++ docker/ubuntu | 8 ++++++++ 3 files changed, 40 insertions(+) create mode 100644 docker/el7 create mode 100644 docker/el8 create mode 100644 docker/ubuntu diff --git a/docker/el7 b/docker/el7 new file mode 100644 index 0000000..7076f22 --- /dev/null +++ b/docker/el7 @@ -0,0 +1,17 @@ +FROM centos:7 + +LABEL description="Container in which to build el7 applications" + +ENV TZ=America/Glace_Bay +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +RUN yum install -y gcc rpm-build rpm-devel rpmlint make python python3 bash coreutils diffutils patch rpmdevtools + +RUN mkdir -p /home/rpm/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS,tmp} + +RUN echo %_topdir /home/rpm/rpmbuild > /etc/rpm/macros +RUN echo %_tmppath %{_topdir}/tmp >> /etc/rpm/macros + +RUN chmod -R 777 /home/rpm + +RUN ln -fs /usr/bin/python3 /usr/bin/python diff --git a/docker/el8 b/docker/el8 new file mode 100644 index 0000000..e62dab7 --- /dev/null +++ b/docker/el8 @@ -0,0 +1,15 @@ +FROM centos:8 + +LABEL description="Container in which to build el8 applications" + +ENV TZ=America/Glace_Bay +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +RUN dnf install -y gcc rpm-build rpm-devel rpmlint make python3 bash diffutils patch rpmdevtools + +RUN mkdir -p /home/rpm/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS,tmp} + +RUN echo %_topdir /home/rpm/rpmbuild > /etc/rpm/macros +RUN echo %_tmppath %{_topdir}/tmp >> /etc/rpm/macros + +RUN chmod -R 777 /home/rpm diff --git a/docker/ubuntu b/docker/ubuntu new file mode 100644 index 0000000..4c11f1c --- /dev/null +++ b/docker/ubuntu @@ -0,0 +1,8 @@ +FROM ubuntu:focal + +LABEL description="Container in which to build ubuntu applications" + +ENV TZ=America/Glace_Bay +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +RUN apt update && apt install -y make build-essential fakeroot devscripts debhelper python3 From 8182ae7ffa900cd30dd5e7b9b32a7c34c88cedbd Mon Sep 17 00:00:00 2001 From: joshuaboud Date: Fri, 28 May 2021 16:22:18 -0300 Subject: [PATCH 06/22] fix path under %files --- el/cockpit-navigator.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/el/cockpit-navigator.spec b/el/cockpit-navigator.spec index f1a9a11..23521a1 100644 --- a/el/cockpit-navigator.spec +++ b/el/cockpit-navigator.spec @@ -29,7 +29,7 @@ cp -a * %{buildroot} rm -rf %{buildroot} %files -/usr/share/cockpit/samba-navigator/* +/usr/share/cockpit/navigator/* %changelog * Fri May 28 2021 Josh Boudreau 0.1.0-1 From 338d75749957acb92c7c304a7ffa18bcdeb80516 Mon Sep 17 00:00:00 2001 From: joshuaboud Date: Fri, 28 May 2021 16:22:27 -0300 Subject: [PATCH 07/22] fix paths --- .gitignore | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index a3abede..97f2204 100644 --- a/.gitignore +++ b/.gitignore @@ -2,9 +2,9 @@ .vscode # deb packaging -debian/cockpit-samba-manager -debian/cockpit-samba-manager.substvars -debian/cockpit-samba-manager.postrm.debhelper +debian/cockpit-navigator +debian/cockpit-navigator.substvars +debian/cockpit-navigator.postrm.debhelper debian/debhelper-build-stamp debian/files debian/.debhelper From cbbb71740416e3f260ab4c2fcddc2e2cd0086776 Mon Sep 17 00:00:00 2001 From: joshuaboud Date: Fri, 28 May 2021 16:22:38 -0300 Subject: [PATCH 08/22] add packaging scripts --- package-all.sh | 20 ++++++++++++++++ package-deb.sh | 58 ++++++++++++++++++++++++++++++++++++++++++++ package-el7.sh | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++ package-el8.sh | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 208 insertions(+) create mode 100755 package-all.sh create mode 100755 package-deb.sh create mode 100755 package-el7.sh create mode 100755 package-el8.sh diff --git a/package-all.sh b/package-all.sh new file mode 100755 index 0000000..16626b4 --- /dev/null +++ b/package-all.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +# Copyright (C) 2021 Joshua Boudreau +# +# This file is part of Cockpit Navigator. +# +# Cockpit Navigator is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Cockpit Navigator is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Cockpit Navigator. If not, see . + +./package-deb.sh && ./package-el7.sh && ./package-el8.sh diff --git a/package-deb.sh b/package-deb.sh new file mode 100755 index 0000000..82d3d00 --- /dev/null +++ b/package-deb.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# Copyright (C) 2021 Joshua Boudreau +# +# This file is part of Cockpit Navigator. +# +# Cockpit Navigator is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Cockpit Navigator is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Cockpit Navigator. If not, see . + +if [[ "$#" == 1 && "$1" == "clean" ]]; then + pushd debian + rm -f cockpit-navigator.postrm.debhelper cockpit-navigator.substvars debhelper-build-stamp files + rm -rf .debhelper cockpit-navigator + popd + rm -rf dist/ubuntu + exit 0 +fi + +command -v docker > /dev/null 2>&1 || { + echo "Please install docker."; + exit 1; +} + +# if docker image DNE, build it +if [[ "$(docker images -q cockpit-navigator-ubuntu-builder 2> /dev/null)" == "" ]]; then + docker build -t cockpit-navigator-ubuntu-builder - < docker/ubuntu + res=$? + if [ $res -ne 0 ]; then + echo "Building docker image failed." + exit $res + fi +fi + +mkdir -p dist/ubuntu + +# mirror current directory to working directory in container, and mirror dist/ubuntu to .. for deb output +docker run -u $(id -u):$(id -g) -w /home/deb/build -it -v$(pwd):/home/deb/build -v$(pwd)/dist/ubuntu:/home/deb --rm cockpit-navigator-ubuntu-builder dpkg-buildpackage -us -uc -b +res=$? +if [ $res -ne 0 ]; then + echo "Packaging failed." + exit $res +fi + +rmdir dist/ubuntu/build + +echo "deb is in dist/ubuntu/" + +exit 0 diff --git a/package-el7.sh b/package-el7.sh new file mode 100755 index 0000000..b8551b1 --- /dev/null +++ b/package-el7.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash + +# Copyright (C) 2021 Joshua Boudreau +# +# This file is part of Cockpit Navigator. +# +# Cockpit Navigator is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Cockpit Navigator is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Cockpit Navigator. If not, see . + +if [[ "$#" == 1 && "$1" == "clean" ]]; then + rm -rf dist/tmp + rm -rf dist/el7 + exit 0 +fi + +command -v docker > /dev/null 2>&1 || { + echo "Please install docker."; + exit 1; +} + +# if docker image DNE, build it +if [[ "$(docker images -q cockpit-navigator-el7-builder 2> /dev/null)" == "" ]]; then + docker build -t cockpit-navigator-el7-builder - < docker/el7 + res=$? + if [ $res -ne 0 ]; then + echo "Building docker image failed." + exit $res + fi +fi + +mkdir -p dist/{el7,tmp} + +SOURCE_DIR_NAME=cockpit-navigator-$(grep Version el/cockpit-navigator.spec --color=never | awk '{print $2}') +SOURCE_DIR=dist/tmp/$SOURCE_DIR_NAME +mkdir -p $SOURCE_DIR + +make DESTDIR=$SOURCE_DIR EL7=1 install + +pushd $SOURCE_DIR/.. +tar -czvf $SOURCE_DIR_NAME.tar.gz $SOURCE_DIR_NAME +popd + +# build rpm from source tar and place it dist/el7 by mirroring dist/el7 to rpmbuild/RPMS +docker run -u $(id -u):$(id -g) -w /home/rpm/rpmbuild -it -v$(pwd)/dist/tmp:/home/rpm/rpmbuild/SOURCES -v$(pwd)/dist/el7:/home/rpm/rpmbuild/RPMS -v$(pwd)/el:/home/rpm/rpmbuild/SPECS --rm cockpit-navigator-el7-builder rpmbuild -ba SPECS/cockpit-navigator.spec +res=$? +if [ $res -ne 0 ]; then + echo "Packaging failed." + exit $res +fi + +rm -rf dist/tmp + +echo "rpm is in dist/el7/" + +exit 0 diff --git a/package-el8.sh b/package-el8.sh new file mode 100755 index 0000000..01b912f --- /dev/null +++ b/package-el8.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash + +# Copyright (C) 2021 Joshua Boudreau +# +# This file is part of Cockpit Navigator. +# +# Cockpit Navigator is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Cockpit Navigator is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Cockpit Navigator. If not, see . + +if [[ "$#" == 1 && "$1" == "clean" ]]; then + rm -rf dist/tmp + rm -rf dist/el8 + exit 0 +fi + +command -v docker > /dev/null 2>&1 || { + echo "Please install docker."; + exit 1; +} + +# if docker image DNE, build it +if [[ "$(docker images -q cockpit-navigator-el8-builder 2> /dev/null)" == "" ]]; then + docker build -t cockpit-navigator-el8-builder - < docker/el8 + res=$? + if [ $res -ne 0 ]; then + echo "Building docker image failed." + exit $res + fi +fi + +mkdir -p dist/{el8,tmp} + +SOURCE_DIR_NAME=cockpit-navigator-$(grep Version el/cockpit-navigator.spec --color=never | awk '{print $2}') +SOURCE_DIR=dist/tmp/$SOURCE_DIR_NAME +mkdir -p $SOURCE_DIR + +make DESTDIR=$SOURCE_DIR install + +pushd $SOURCE_DIR/.. +tar -czvf $SOURCE_DIR_NAME.tar.gz $SOURCE_DIR_NAME +popd + +# build rpm from source tar and place it dist/el8 by mirroring dist/el8 to rpmbuild/RPMS +docker run -u $(id -u):$(id -g) -w /home/rpm/rpmbuild -it -v$(pwd)/dist/tmp:/home/rpm/rpmbuild/SOURCES -v$(pwd)/dist/el8:/home/rpm/rpmbuild/RPMS -v$(pwd)/el:/home/rpm/rpmbuild/SPECS --rm cockpit-navigator-el8-builder rpmbuild -ba SPECS/cockpit-navigator.spec +res=$? +if [ $res -ne 0 ]; then + echo "Packaging failed." + exit $res +fi + +rm -rf dist/tmp + +echo "rpm is in dist/el8/" + +exit 0 From b099adc3e8cae8a2a6c97cb2639d4939172e4ecd Mon Sep 17 00:00:00 2001 From: joshuaboud Date: Fri, 28 May 2021 16:29:57 -0300 Subject: [PATCH 09/22] give text editor monospaced font family --- navigator/navigator.css | 1 + 1 file changed, 1 insertion(+) diff --git a/navigator/navigator.css b/navigator/navigator.css index de2cf0e..2657241 100644 --- a/navigator/navigator.css +++ b/navigator/navigator.css @@ -332,6 +332,7 @@ input[type="text"] { padding: 5px; color: var(--font); background-color: var(--textarea-bg); + font-family: 'Courier New', Courier, monospace; } .nav-footer { From 36c4cb93c27e44fee7acdbe2bb0c5da507de4366 Mon Sep 17 00:00:00 2001 From: joshuaboud Date: Fri, 28 May 2021 17:18:32 -0300 Subject: [PATCH 10/22] fix height in el7 --- navigator/navigator.css | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/navigator/navigator.css b/navigator/navigator.css index 2657241..ae4571a 100644 --- a/navigator/navigator.css +++ b/navigator/navigator.css @@ -53,6 +53,14 @@ --symlink-symbol-color: var(--navigation); } +html { + height: 100%; +} + +body { + height: 100%; +} + .pf-c-button:disabled[data-theme="dark"] { background-color: var(--border); } From b75ddda0955212b2c8594203a7f280b3d9a5a731 Mon Sep 17 00:00:00 2001 From: joshuaboud Date: Fri, 28 May 2021 17:19:01 -0300 Subject: [PATCH 11/22] apply patternfly 3 button stylings in el7 --- makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/makefile b/makefile index f94c268..50cefd4 100644 --- a/makefile +++ b/makefile @@ -21,6 +21,9 @@ all: default install: mkdir -p $(DESTDIR)/usr/share/cockpit/ cp -rpf navigator $(DESTDIR)/usr/share/cockpit +ifeq ($(EL7),1) + sed -i "s/pf-c-button/btn/g;s/pf-m-primary/btn-primary/g;s/pf-m-secondary/btn-default/g;s/pf-m-danger/btn-danger/g" $(DESTDIR)/usr/share/cockpit/navigator/navigator.html +endif uninstall: rm -rf $(DESTDIR)/usr/share/cockpit/navigator From 5955a677d4e962f4e93e01394ab1b139de3feaac Mon Sep 17 00:00:00 2001 From: joshuaboud Date: Fri, 28 May 2021 17:21:41 -0300 Subject: [PATCH 12/22] run attribution script for fontawesome --- navigator/navigator.html | 1 + 1 file changed, 1 insertion(+) diff --git a/navigator/navigator.html b/navigator/navigator.html index da81635..5c8cea2 100644 --- a/navigator/navigator.html +++ b/navigator/navigator.html @@ -24,6 +24,7 @@ + From 3cf77257875c73bd76d4614e5cb05a81cce4830b Mon Sep 17 00:00:00 2001 From: joshuaboud Date: Mon, 31 May 2021 10:15:54 -0300 Subject: [PATCH 13/22] re-enable buttons if editing fails or is cancelled --- navigator/navigator.js | 73 +++++++++++++++++++++++++++++++----------- 1 file changed, 54 insertions(+), 19 deletions(-) diff --git a/navigator/navigator.js b/navigator/navigator.js index 8a2cc02..893936a 100644 --- a/navigator/navigator.js +++ b/navigator/navigator.js @@ -366,19 +366,29 @@ class NavFile extends NavEntry { } async show_edit_file_contents() { - for (let button of document.getElementsByTagName("button")) { - if (!button.classList.contains("editor-btn")) - button.disabled = true; - } - document.getElementById("pwd").disabled = true; + this.nav_window_ref.disable_buttons_for_editing(); var proc_output = await cockpit.spawn(["file", "--mime-type", this.path_str()], {superuser: "try"}); var fields = proc_output.split(':'); var type = fields[1].trim(); - if(!(type.match(/^text/) || type.match(/^inode\/x-empty$/) || this.stat["size"] === 0)){ - if(!window.confirm("File is of type `" + type + "`. Are you sure you want to edit it?")) + if (!(type.match(/^text/) || type.match(/^inode\/x-empty$/) || this.stat["size"] === 0)) { + if (!window.confirm("File is of type `" + type + "`. Are you sure you want to edit it?")) { + this.nav_window_ref.enable_buttons(); return; + } + } + var contents = ""; + try { + contents = await cockpit.spawn(["cat", this.path_str()], {superuser: "try"}); + } catch (e) { + this.nav_window_ref.enable_buttons(); + var message = ""; + if (e.message === "protocol-error") + message = "Error reading file."; + else + message = e.message; + window.alert(message); + return; } - var contents = await cockpit.spawn(["cat", this.path_str()], {superuser: "try"}); document.getElementById("nav-edit-contents-textarea").value = contents; document.getElementById("nav-cancel-edit-contents-btn").onclick = this.hide_edit_file_contents.bind(this); document.getElementById("nav-continue-edit-contents-btn").onclick = this.write_to_file.bind(this); @@ -397,10 +407,7 @@ class NavFile extends NavEntry { hide_edit_file_contents() { document.getElementById("nav-edit-contents-view").style.display = "none"; document.getElementById("nav-contents-view").style.display = "flex"; - for (let button of document.getElementsByTagName("button")) { - button.disabled = false; - } - document.getElementById("pwd").disabled = false; + this.nav_window_ref.enable_buttons(); } } @@ -443,20 +450,31 @@ class NavFileLink extends NavFile{ } async show_edit_file_contents() { - for (let button of document.getElementsByTagName("button")) { - if (!button.classList.contains("editor-btn")) - button.disabled = true; - } + this.nav_window_ref.disable_buttons_for_editing(); document.getElementById("pwd").disabled = true; var target_path = this.get_link_target_path(); var proc_output = await cockpit.spawn(["file", "--mime-type", target_path], {superuser: "try"}); var fields = proc_output.split(':'); var type = fields[1].trim(); - if(!(type.match(/^text/) || type.match(/^inode\/x-empty$/) || this.stat["size"] === 0)){ - if(!window.confirm("File is of type `" + type + "`. Are you sure you want to edit it?")) + if (!(type.match(/^text/) || type.match(/^inode\/x-empty$/) || this.stat["size"] === 0)) { + if (!window.confirm("File is of type `" + type + "`. Are you sure you want to edit it?")) { + this.nav_window_ref.enable_buttons(); return; + } + } + var contents = ""; + try { + contents = await cockpit.spawn(["cat", target_path], {superuser: "try"}); + } catch(e) { + this.nav_window_ref.enable_buttons(); + var message = ""; + if (e.message === "protocol-error") + message = "Error reading file."; + else + message = e.message; + window.alert(message); + return; } - var contents = await cockpit.spawn(["cat", target_path], {superuser: "try"}); document.getElementById("nav-edit-contents-textarea").value = contents; document.getElementById("nav-cancel-edit-contents-btn").onclick = this.hide_edit_file_contents.bind(this); document.getElementById("nav-continue-edit-contents-btn").onclick = this.write_to_file.bind(this); @@ -993,6 +1011,7 @@ class NavWindow { } this.refresh(); } + async get_system_users() { var proc = cockpit.spawn(["getent", "passwd"], {err: "ignore", superuser: "try"}); var list = document.getElementById("possible-owners"); @@ -1009,6 +1028,7 @@ class NavWindow { list.appendChild(option); } } + async get_system_groups() { var proc = cockpit.spawn(["getent", "group"], {err: "ignore", superuser: "try"}); var list = document.getElementById("possible-groups"); @@ -1025,6 +1045,21 @@ class NavWindow { list.appendChild(option); } } + + disable_buttons_for_editing() { + for (let button of document.getElementsByTagName("button")) { + if (!button.classList.contains("editor-btn")) + button.disabled = true; + } + document.getElementById("pwd").disabled = true; + } + + enable_buttons() { + for (let button of document.getElementsByTagName("button")) { + button.disabled = false; + } + document.getElementById("pwd").disabled = false; + } } let nav_window = new NavWindow(); From 60fe5a3bf5eefd32780946d3cddcfaf57ef7ce70 Mon Sep 17 00:00:00 2001 From: joshuaboud Date: Mon, 31 May 2021 10:32:06 -0300 Subject: [PATCH 14/22] print verbose exception message when ls fails --- navigator/scripts/ls.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/navigator/scripts/ls.py b/navigator/scripts/ls.py index 0ea29bc..ba1dbe8 100755 --- a/navigator/scripts/ls.py +++ b/navigator/scripts/ls.py @@ -68,8 +68,8 @@ def main(): sys.exit(1) try: nodes = os.listdir(sys.argv[1]) - except: - print("No such file or directory") + except Exception as e: + print(e) sys.exit(1) response = { ".": get_stat(sys.argv[1]), From 442470dffd9bed43d7d158ff9ff50a93892adf83 Mon Sep 17 00:00:00 2001 From: joshuaboud Date: Mon, 31 May 2021 10:32:22 -0300 Subject: [PATCH 15/22] add ability to create symlinks --- navigator/navigator.css | 11 +++++++++++ navigator/navigator.html | 10 +++++++--- navigator/navigator.js | 24 ++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/navigator/navigator.css b/navigator/navigator.css index ae4571a..52559ce 100644 --- a/navigator/navigator.css +++ b/navigator/navigator.css @@ -428,3 +428,14 @@ input:checked + .slider:before { .slider.round:before { border-radius: 50%; } + +.nav-icon-decorated { + position: relative; +} + +.nav-icon-decoration { + position: absolute; + font-size: 60%; + top: -10%; + left: -30%; +} diff --git a/navigator/navigator.html b/navigator/navigator.html index 5c8cea2..fa8dcb1 100644 --- a/navigator/navigator.html +++ b/navigator/navigator.html @@ -54,9 +54,13 @@
- -
- +
diff --git a/navigator/navigator.js b/navigator/navigator.js index 893936a..ed44516 100644 --- a/navigator/navigator.js +++ b/navigator/navigator.js @@ -934,6 +934,29 @@ class NavWindow { this.refresh(); } + async ln() { + var link_target = window.prompt("Link Target: "); + if (link_target === null) + return; + var link_name = window.prompt("Link Name: "); + if (link_name === null) + return; + if (link_name.includes("/")) { + window.alert("Link name can't contain `/`."); + return; + } + var link_path = this.pwd().path_str() + "/" + link_name; + var proc = cockpit.spawn( + ["ln", "-sn", link_target, link_path], + {superuser: "try", err: "out"} + ); + proc.fail((e, data) => { + window.alert(data); + }); + await proc; + this.refresh(); + } + /** * * @param {Event} e @@ -1071,6 +1094,7 @@ function set_up_buttons() { document.getElementById("nav-refresh-btn").addEventListener("click", nav_window.refresh.bind(nav_window)); document.getElementById("nav-mkdir-btn").addEventListener("click", nav_window.mkdir.bind(nav_window)); document.getElementById("nav-touch-btn").addEventListener("click", nav_window.touch.bind(nav_window)); + document.getElementById("nav-ln-btn").addEventListener("click", nav_window.ln.bind(nav_window)); document.getElementById("nav-delete-btn").addEventListener("click", nav_window.delete_selected.bind(nav_window)); document.getElementById("nav-edit-properties-btn").addEventListener("click", nav_window.show_edit_selected.bind(nav_window)); document.getElementById("nav-cancel-edit-btn").addEventListener("click", nav_window.hide_edit_selected.bind(nav_window)); From 75cd0835af53052707adaa2d679823a7dec6300a Mon Sep 17 00:00:00 2001 From: joshuaboud Date: Mon, 31 May 2021 12:54:51 -0300 Subject: [PATCH 16/22] truncate filename in right column and add tooltips --- navigator/navigator.css | 8 ++++++++ navigator/navigator.html | 36 ++++++++++++++++++------------------ navigator/navigator.js | 4 +++- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/navigator/navigator.css b/navigator/navigator.css index 52559ce..e828bcf 100644 --- a/navigator/navigator.css +++ b/navigator/navigator.css @@ -257,10 +257,18 @@ input[type="text"] { border-radius: var(--nav-border-radius); } +.min-width-0 { + min-width: 0; +} + .nav-info-column-filename { + flex: 1; margin: 0 12px 0 12px; font-weight: bolder; font-size: 150%; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; } .nav-property-pair { diff --git a/navigator/navigator.html b/navigator/navigator.html index fa8dcb1..1b53b5d 100644 --- a/navigator/navigator.html +++ b/navigator/navigator.html @@ -39,27 +39,27 @@
- +
@@ -71,20 +71,20 @@
- @@ -147,7 +147,7 @@ - Directories, - Files
- + 45Drives
@@ -155,7 +155,7 @@