Merge pull request #13 from 45Drives/dev-josh

changes for v0.4.0
This commit is contained in:
Josh Boudreau 2021-06-07 12:26:43 -03:00 committed by GitHub
commit da70193ef4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 672 additions and 217 deletions

View File

@ -7,7 +7,10 @@ With no command line use needed, you can:
* Create, delete, and rename files,
* Edit file contents,
* Edit file ownership and permissions,
* Create symbolic links to files and directories.
* Create symbolic links to files and directories,
* Reorganize files through cut, copy, and paste,
* **Upload files by dragging and dropping**,
* **Download files and directories**.
### Browsing Filesystem
![User Interface](doc/ui_root.png)
@ -19,17 +22,17 @@ With no command line use needed, you can:
# Installation
## From Github Release
### Ubuntu
1. `$ wget https://github.com/45Drives/cockpit-navigator/releases/download/v0.3.0/cockpit-navigator_0.3.0-1focal_all.deb`
1. `# apt install ./cockpit-navigator_0.3.0-1focal_all.deb`
1. `$ wget https://github.com/45Drives/cockpit-navigator/releases/download/v0.4.0/cockpit-navigator_0.4.0-1focal_all.deb`
1. `# apt install ./cockpit-navigator_0.4.0-1focal_all.deb`
### EL7
1. `# yum install https://github.com/45Drives/cockpit-navigator/releases/download/v0.3.0/cockpit-navigator-0.3.0-1.el7.noarch.rpm`
1. `# yum install https://github.com/45Drives/cockpit-navigator/releases/download/v0.4.0/cockpit-navigator-0.4.0-1.el7.noarch.rpm`
### EL8
1. `# dnf install https://github.com/45Drives/cockpit-navigator/releases/download/v0.3.0/cockpit-navigator-0.3.0-1.el8.noarch.rpm`
1. `# dnf install https://github.com/45Drives/cockpit-navigator/releases/download/v0.4.0/cockpit-navigator-0.4.0-1.el8.noarch.rpm`
## From Source
1. Ensure dependencies are installed: `cockpit`, `python3`, `rsync`.
1. Ensure dependencies are installed: `cockpit`, `python3`, `rsync`, `zip`.
1. `$ git clone https://github.com/45Drives/cockpit-navigator.git`
1. `$ cd cockpit-navigator`
1. `$ git checkout <version>` (v0.3.0 is latest)
1. `$ git checkout <version>` (v0.4.0 is latest)
1. `# make install`
## From 45Drives Repositories
### Ubuntu

8
debian/changelog vendored
View File

@ -1,3 +1,11 @@
cockpit-navigator (0.4.0-1focal) focal; urgency=low
* Add icons to right click menu.
* Add ability to download files and directories.
* Show transfer rate and ETA while uploading files.
-- Josh Boudreau <jboudreau@45drives.com> Mon, 07 Jun 2021 12:09:00 -0300
cockpit-navigator (0.3.0-1focal) focal; urgency=medium
* Add drag and drop uploading of files.

2
debian/control vendored
View File

@ -9,5 +9,5 @@ Homepage: https://github.com/45Drives/cockpit-navigator
Package: cockpit-navigator
Architecture: all
Depends: ${shlibs:Depends}, ${misc:Depends},
cockpit, python3, rsync
cockpit, python3, rsync, zip
Description: A File System Browser for Cockpit.

View File

@ -1,12 +1,12 @@
Name: cockpit-navigator
Version: 0.3.0
Version: 0.4.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 rsync
Requires: cockpit python3 rsync zip
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
@ -32,6 +32,10 @@ rm -rf %{buildroot}
/usr/share/cockpit/navigator/*
%changelog
* Mon Jun 07 2021 Josh Boudreau <jboudreau@45drives.com> 0.4.0-1
- Add icons to right click menu.
- Add ability to download files and directories.
- Show transfer rate and ETA while uploading files.
* Thu Jun 03 2021 Josh Boudreau <jboudreau@45drives.com> 0.3.0-1
- Add drag and drop uploading of files.
- Add event listeners for ctrl+a to select all, ctrl+x to cut,

View File

@ -480,14 +480,24 @@ input:checked + .slider:before {
}
.nav-context-menu-item {
padding: 0 12px 0 12px;
padding: 0 12px 0 0;
cursor: pointer;
display: flex;
flex-flow: row nowrap;
align-items: baseline;
}
.nav-context-menu-item:hover {
background-color: var(--border);
}
.nav-context-menu-item > div {
width: 40px;
display: flex;
flex-flow: row nowrap;
justify-content: center;
}
.drag-enter {
border: 1px dashed var(--border);
}

File diff suppressed because it is too large Load Diff

View File

@ -43,7 +43,7 @@ def main():
sys.exit(1)
path = sys.argv[1]
try:
file = open(path, "xb")
file = open(path, "wb")
except Exception as e:
print(e)
sys.exit(1)

View File

@ -0,0 +1,102 @@
#!/usr/bin/env python3
"""
Cockpit Navigator - A File System Browser for Cockpit.
Copyright (C) 2021 Josh Boudreau <jboudreau@45drives.com>
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 <https://www.gnu.org/licenses/>.
"""
"""
Synopsis: `zip-for-download.py </path/to/cwd> </path/to/file> [</path/to/file> ...]`
Output is JSON object with form:
{
message: <error message if applicable>,
archive-path: </path/to/archive>,
stat: {
size: <size of archive in bytes> // for setting channel max read size
}
}
"""
import os
import sys
import json
import subprocess
from datetime import datetime
def get_relpaths(full_paths, cwd):
response = []
for path in full_paths:
response.append(os.path.relpath(path, cwd))
return response
def make_zip(path):
try:
cwd = sys.argv[1]
files = get_relpaths(sys.argv[2:], cwd)
os.chdir(cwd)
except Exception as e:
print(json.dumps({
"message": e
}))
sys.exit(1)
cmd = ["zip", "-ryq", path, *files]
try:
child = subprocess.Popen(
cmd,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True
)
except Exception as e:
print(json.dumps({
"message": e
}))
sys.exit(1)
child.wait()
if child.returncode:
stdout, stderr = child.communicate()
print(json.dumps({
"message": stdout + stderr
}))
sys.exit(child.returncode)
try:
archive_size = os.stat(path).st_size
except Exception as e:
print(json.dumps({
"message": e
}))
sys.exit(1)
print(json.dumps({
"message": "",
"archive-path": path,
"stat": {
"size": archive_size
}
}))
def main():
tmp_dir = "/tmp/navigator"
if not os.path.exists(tmp_dir):
os.mkdir(tmp_dir)
elif not os.path.isdir(tmp_dir):
print(json.dumps({
"message": "Temp path already exists."
}))
sys.exit(1)
archive_path = tmp_dir + "/navigator-download_" + datetime.now().strftime("%Y-%m-%d_%H-%M-%S.%f") + ".zip"
make_zip(archive_path)
sys.exit(0)
if __name__ == "__main__":
main()