Merge branch 'dev-josh'

This commit is contained in:
joshuaboud 2021-07-19 14:16:45 -03:00
commit 6114161171
No known key found for this signature in database
GPG Key ID: 17EFB59E2A8BF50E
16 changed files with 165 additions and 56 deletions

View File

@ -1,4 +1,4 @@
## Cockpit Navigator 0.5.2-1 ## Cockpit Navigator 0.5.3-1
* Implement uploading of entire directories. * Implement inline filename editing.
* Add cancel option to in-progress file uploads. * Add information popup button.

View File

@ -23,12 +23,12 @@ With no command line use needed, you can:
# Installation # Installation
## From Github Release ## From Github Release
### Ubuntu ### Ubuntu
1. `$ wget https://github.com/45Drives/cockpit-navigator/releases/download/v0.5.2/cockpit-navigator_0.5.2-1focal_all.deb` 1. `$ wget https://github.com/45Drives/cockpit-navigator/releases/download/v0.5.3/cockpit-navigator_0.5.3-1focal_all.deb`
1. `# apt install ./cockpit-navigator_0.5.2-1focal_all.deb` 1. `# apt install ./cockpit-navigator_0.5.3-1focal_all.deb`
### EL7 ### EL7
1. `# yum install https://github.com/45Drives/cockpit-navigator/releases/download/v0.5.2/cockpit-navigator-0.5.2-1.el7.noarch.rpm` 1. `# yum install https://github.com/45Drives/cockpit-navigator/releases/download/v0.5.3/cockpit-navigator-0.5.3-1.el7.noarch.rpm`
### EL8 ### EL8
1. `# dnf install https://github.com/45Drives/cockpit-navigator/releases/download/v0.5.2/cockpit-navigator-0.5.2-1.el8.noarch.rpm` 1. `# dnf install https://github.com/45Drives/cockpit-navigator/releases/download/v0.5.3/cockpit-navigator-0.5.3-1.el8.noarch.rpm`
## From Source ## From Source
1. Ensure dependencies are installed: `cockpit`, `python3`, `rsync`, `zip`. 1. Ensure dependencies are installed: `cockpit`, `python3`, `rsync`, `zip`.
1. `$ git clone https://github.com/45Drives/cockpit-navigator.git` 1. `$ git clone https://github.com/45Drives/cockpit-navigator.git`

View File

@ -27,6 +27,9 @@ ifeq ($(DIST),$(EL7_DIST))
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 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
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/components/ModalPrompt.js 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/components/ModalPrompt.js
endif endif
ifneq ($(NAV_VERS),)
echo "export let NAVIGATOR_VERSION = \"$(NAV_VERS)\";" > $(DESTDIR)/usr/share/cockpit/navigator/version.js
endif
uninstall: uninstall:
rm -rf $(DESTDIR)/usr/share/cockpit/navigator rm -rf $(DESTDIR)/usr/share/cockpit/navigator
@ -35,6 +38,9 @@ install-local:
mkdir -p $(HOME)/.local/share/cockpit mkdir -p $(HOME)/.local/share/cockpit
cp -rpf navigator $(HOME)/.local/share/cockpit cp -rpf navigator $(HOME)/.local/share/cockpit
find $(HOME)/.local/share/cockpit/navigator -name '*.js' -exec sed -i "s#\"/usr/share/\(cockpit/navigator/scripts/.*\)\"#\"$(HOME)/.local/share/\1\"#g" {} \; find $(HOME)/.local/share/cockpit/navigator -name '*.js' -exec sed -i "s#\"/usr/share/\(cockpit/navigator/scripts/.*\)\"#\"$(HOME)/.local/share/\1\"#g" {} \;
ifneq ($(NAV_VERS),)
echo "export let NAVIGATOR_VERSION = \"$(NAV_VERS)\";" > $(HOME)/.local/share/cockpit/navigator/version.js
endif
uninstall-local: uninstall-local:
rm -rf $(HOME)/.local/share/cockpit/navigator rm -rf $(HOME)/.local/share/cockpit/navigator

View File

@ -3,7 +3,7 @@
"name": "cockpit-navigator", "name": "cockpit-navigator",
"title": "Cockpit Navigator", "title": "Cockpit Navigator",
"prerelease": false, "prerelease": false,
"version": "0.5.2", "version": "0.5.3",
"buildVersion": "1", "buildVersion": "1",
"author": "Josh Boudreau <jboudreau@45drives.com>", "author": "Josh Boudreau <jboudreau@45drives.com>",
"url": "https://github.com/45Drives/cockpit-navigator", "url": "https://github.com/45Drives/cockpit-navigator",
@ -54,7 +54,7 @@
], ],
"changelog": { "changelog": {
"urgency": "medium", "urgency": "medium",
"version": "0.5.2", "version": "0.5.3",
"buildVersion": "1", "buildVersion": "1",
"ignore": [], "ignore": [],
"date": null, "date": null,

View File

@ -96,7 +96,7 @@ export class ModalPrompt {
*/ */
set_body(message) { set_body(message) {
this.body.innerHTML = ""; this.body.innerHTML = "";
this.body.innerText = message; this.body.innerHTML = message;
} }
/** /**

View File

@ -53,7 +53,7 @@ export class NavContextMenu {
var name_list = func[0].split("_"); var name_list = func[0].split("_");
name_list.forEach((word, index) => {name_list[index] = word.charAt(0).toUpperCase() + word.slice(1)}); name_list.forEach((word, index) => {name_list[index] = word.charAt(0).toUpperCase() + word.slice(1)});
elem.innerHTML = func[1] + name_list.join(" "); elem.innerHTML = func[1] + name_list.join(" ");
elem.addEventListener("click", (e) => {this[func[0]].bind(this).apply()}); elem.addEventListener("click", (e) => {this[func[0]].bind(this, e).apply()});
elem.classList.add("nav-context-menu-item") elem.classList.add("nav-context-menu-item")
elem.id = "nav-context-menu-" + func[0]; elem.id = "nav-context-menu-" + func[0];
this.dom_element.appendChild(elem); this.dom_element.appendChild(elem);
@ -61,58 +61,37 @@ export class NavContextMenu {
} }
} }
new_dir() { new_dir(e) {
this.nav_window_ref.mkdir(); this.nav_window_ref.mkdir();
} }
new_file() { new_file(e) {
this.nav_window_ref.touch(); this.nav_window_ref.touch();
} }
new_link() { new_link(e) {
var default_target = ""; var default_target = "";
if (this.nav_window_ref.selected_entries.size <= 1 && this.target !== this.nav_window_ref.pwd()) if (this.nav_window_ref.selected_entries.size <= 1 && this.target !== this.nav_window_ref.pwd())
default_target = this.target.filename(); default_target = this.target.filename();
this.nav_window_ref.ln(default_target); this.nav_window_ref.ln(default_target);
} }
cut() { cut(e) {
this.nav_window_ref.cut(); this.nav_window_ref.cut();
} }
copy() { copy(e) {
this.nav_window_ref.copy(); this.nav_window_ref.copy();
} }
paste() { paste(e) {
this.nav_window_ref.paste(); this.nav_window_ref.paste();
} }
async rename() { async rename(e) {
this.hide(); this.hide();
let response = await this.nav_window_ref.modal_prompt.prompt("Renaming " + this.target.filename(), this.target.show_edit(this.target.dom_element.nav_item_title);
{ e.stopPropagation();
new_name: {
label: "New Name: ",
type: "text",
default: this.target.filename()
}
}
);
if (response === null)
return;
var new_name = response.new_name;
if (new_name.includes("/")) {
this.nav_window_ref.modal_prompt.alert("File name can't contain `/`.");
return;
}
try {
await this.target.mv(new_name);
} catch(e) {
this.nav_window_ref.modal_prompt.alert(e);
return;
}
this.nav_window_ref.refresh();
} }
zip_for_download() { zip_for_download() {
@ -134,7 +113,7 @@ export class NavContextMenu {
}); });
} }
async download() { async download(e) {
var download_target = ""; var download_target = "";
if (this.nav_window_ref.selected_entries.size === 1 && !(this.nav_window_ref.selected_entry() instanceof NavDir)) { if (this.nav_window_ref.selected_entries.size === 1 && !(this.nav_window_ref.selected_entry() instanceof NavDir)) {
download_target = this.nav_window_ref.selected_entry(); download_target = this.nav_window_ref.selected_entry();
@ -155,11 +134,11 @@ export class NavContextMenu {
download.download(); download.download();
} }
delete() { delete(e) {
this.nav_window_ref.delete_selected(); this.nav_window_ref.delete_selected();
} }
properties() { properties(e) {
this.nav_window_ref.show_edit_selected(); this.nav_window_ref.show_edit_selected();
} }

View File

@ -42,6 +42,20 @@ export class NavEntry {
title.innerText = this.filename(); title.innerText = this.filename();
this.dom_element.appendChild(icon); this.dom_element.appendChild(icon);
this.dom_element.appendChild(title); this.dom_element.appendChild(title);
let title_edit = this.dom_element.nav_item_title.editor = document.createElement("input");
title_edit.type = "text";
title_edit.style.display = "none";
title_edit.style.padding = "0";
title_edit.style.flexBasis = "0";
title_edit.style.flexGrow = "2";
title_edit.classList.add("nav-item-title");
title_edit.oninput = (e) => {
let elem = e.target;
elem.style.width = elem.value.length + "ch";
}
title_edit.addEventListener("keydown", (e) => {e.stopPropagation();});
title_edit.addEventListener("click", (e) => {e.stopPropagation();});
this.dom_element.appendChild(title_edit);
this.stat = stat; this.stat = stat;
if (stat && stat["inaccessible"]) { if (stat && stat["inaccessible"]) {
this.dom_element.style.cursor = "not-allowed"; this.dom_element.style.cursor = "not-allowed";
@ -80,9 +94,18 @@ export class NavEntry {
handleEvent(e) { handleEvent(e) {
switch (e.type) { switch (e.type) {
case "click": case "click":
if (this.nav_window_ref.selected_entries.size === 1 && this.nav_window_ref.selected_entries.has(this)) {
switch (e.target) {
case this.dom_element.nav_item_title:
this.show_edit(e.target);
e.stopPropagation();
break;
default:
break;
}
}
this.nav_window_ref.set_selected(this, e.shiftKey, e.ctrlKey); this.nav_window_ref.set_selected(this, e.shiftKey, e.ctrlKey);
this.context_menu_ref.hide(); this.context_menu_ref.hide();
e.stopPropagation();
break; break;
case "contextmenu": case "contextmenu":
this.context_menu_ref.show(e, this); this.context_menu_ref.show(e, this);
@ -227,6 +250,72 @@ export class NavEntry {
}); });
} }
/**
*
* @param {string} new_path
*/
async rename(new_name) {
if (new_name === this.filename())
return;
if (new_name.includes("/")) {
this.nav_window_ref.modal_prompt.alert("File name can't contain `/`.");
return;
} else if (new_name === "..") {
this.nav_window_ref.modal_prompt.alert(
"File name can't be `..`.",
"If you want to move the file, right click > cut then right click > paste."
);
return;
}
try {
await this.mv(new_name);
} catch(e) {
this.nav_window_ref.modal_prompt.alert(e);
return;
}
this.nav_window_ref.refresh();
}
/**
*
* @param {HTMLDivElement} element
* @returns
*/
show_edit(element) {
if (!element.editor)
return;
element.hide_func = () => {this.hide_edit(element)};
element.editor.onchange = element.hide_func;
window.addEventListener("click", element.hide_func);
switch (element) {
case this.dom_element.nav_item_title:
element.editor.value = this.filename();
break;
default:
element.editor.value = element.innerText;
break;
}
element.editor.style.width = element.editor.value.length + "ch";
element.editor.style.display = "inline-block";
element.style.display = "none";
element.editor.focus();
}
hide_edit(element) {
if (!element.editor)
return;
switch (element) {
case this.dom_element.nav_item_title:
this.rename(element.editor.value);
break;
default:
break;
}
element.editor.style.display = "none";
element.style.display = "inline-block";
window.removeEventListener("click", element.hide_func);
}
/** /**
* *
* @param {string} extra_properties * @param {string} extra_properties

View File

@ -43,9 +43,10 @@ export class NavFile extends NavEntry {
handleEvent(e) { handleEvent(e) {
switch(e.type){ switch(e.type){
case "click": case "click":
if (this.double_click) if (this.double_click) {
this.open(); this.open();
else { // single click return;
} else { // single click
this.double_click = true; this.double_click = true;
if(this.timeout) if(this.timeout)
clearTimeout(this.timeout) clearTimeout(this.timeout)

View File

@ -58,8 +58,10 @@ export class NavWindow {
handleEvent(e) { handleEvent(e) {
switch (e.type) { switch (e.type) {
case "click": case "click":
if (e.target === this.window) {
this.clear_selected(); this.clear_selected();
this.show_selected_properties(); this.show_selected_properties();
}
break; break;
case "contextmenu": case "contextmenu":
this.context_menu.show(e, this.pwd()); this.context_menu.show(e, this.pwd());
@ -129,8 +131,8 @@ export class NavWindow {
document.getElementById("pwd").value = this.pwd().path_str(); document.getElementById("pwd").value = this.pwd().path_str();
this.set_selected(this.pwd(), false, false); this.set_selected(this.pwd(), false, false);
this.show_selected_properties(); this.show_selected_properties();
document.getElementById("nav-num-dirs").innerText = num_dirs.toString(); document.getElementById("nav-num-dirs").innerText = `${num_dirs} Director${(num_dirs === 1)? "y" : "ies"}`;
document.getElementById("nav-num-files").innerText = num_files.toString(); document.getElementById("nav-num-files").innerText = `${num_files} File${(num_files === 1)? "" : "s"}`;
document.getElementById("nav-num-bytes").innerText = format_bytes(bytes_sum); document.getElementById("nav-num-bytes").innerText = format_bytes(bytes_sum);
this.stop_load(); this.stop_load();
this.set_nav_button_state(); this.set_nav_button_state();

View File

@ -162,7 +162,7 @@
</div> </div>
<div class="flex-row nav-footer"> <div class="flex-row nav-footer">
<div> <div>
<span id="nav-num-dirs">-</span> Directories, <span id="nav-num-files">-</span> Files (<span id="nav-num-bytes">-</span>) <span id="nav-num-dirs">-</span>, <span id="nav-num-files">-</span> (<span id="nav-num-bytes">-</span>)
</div> </div>
<div class="flex-grow"></div> <div class="flex-grow"></div>
<a href="https://www.45drives.com/?utm_source=Houston&utm_medium=UI&utm_campaign=OS-Link" target="_blank" title="Visit 45Drives.com"> <a href="https://www.45drives.com/?utm_source=Houston&utm_medium=UI&utm_campaign=OS-Link" target="_blank" title="Visit 45Drives.com">
@ -194,6 +194,10 @@
</label> </label>
</div> </div>
</div> </div>
<div class="horizontal-spacer"></div>
<div id="nav-info-btn" class="clickable">
<i class="far fa-question-circle" id="nav-info-icon"></i>
</div>
</div> </div>
</div> </div>
</body> </body>

View File

@ -17,7 +17,9 @@
along with Cockpit Navigator. If not, see <https://www.gnu.org/licenses/>. along with Cockpit Navigator. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {ModalPrompt} from "./components/ModalPrompt.js";
import {NavWindow} from "./components/NavWindow.js"; import {NavWindow} from "./components/NavWindow.js";
import {NAVIGATOR_VERSION} from "./version.js";
/** /**
* *
@ -139,6 +141,16 @@ function set_up_buttons() {
e.target.selectionStart = e.target.selectionEnd = start + 1; e.target.selectionStart = e.target.selectionEnd = start + 1;
} }
}); });
document.getElementById("nav-info-btn").addEventListener("click", () => {
new ModalPrompt().alert(
`Cockpit Navigator ${NAVIGATOR_VERSION}`,
`<p>` +
`Created by <a target="_blank" href=https://www.45drives.com/?utm_source=Houston&utm_medium=UI&utm_campaign=OS-Link>45Drives</a> for Houston UI (Cockpit).<br>` +
`<a target="_blank" href=https://github.com/45Drives/cockpit-navigator/issues>Issue Tracker</a><br>` +
`<a target="_blank" href=https://github.com/45Drives/cockpit-navigator/discussions>Feedback</a><br>` +
`</p>`
);
});
} }
async function main() { async function main() {

1
navigator/version.js Normal file
View File

@ -0,0 +1 @@
export let NAVIGATOR_VERSION = "built from source";

View File

@ -23,7 +23,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
# empty # empty
%install %install
make DESTDIR=%{buildroot} DIST=%{dist} install make DESTDIR=%{buildroot} DIST=%{dist} NAV_VERS="%{version}-%{release}" install
%clean %clean
rm -rf %{buildroot} rm -rf %{buildroot}
@ -32,6 +32,9 @@ rm -rf %{buildroot}
/usr/share/cockpit/navigator/* /usr/share/cockpit/navigator/*
%changelog %changelog
* Mon Jul 19 2021 Josh Boudreau <jboudreau@45drives.com> 0.5.3-1
- Implement inline filename editing.
- Add information popup button.
* Fri Jul 16 2021 Josh Boudreau <jboudreau@45drives.com> 0.5.2-1 * Fri Jul 16 2021 Josh Boudreau <jboudreau@45drives.com> 0.5.2-1
- Implement uploading of entire directories. - Implement uploading of entire directories.
- Add cancel option to in-progress file uploads. - Add cancel option to in-progress file uploads.
@ -41,7 +44,7 @@ rm -rf %{buildroot}
* Thu Jul 15 2021 Josh Boudreau <jboudreau@45drives.com> 0.5.0-1 * Thu Jul 15 2021 Josh Boudreau <jboudreau@45drives.com> 0.5.0-1
- Implement custom modal style popups to replace browser dialogs. - Implement custom modal style popups to replace browser dialogs.
* Wed Jul 07 2021 Josh Boudreau <jboudreau@45drives.com> 0.4.6-3 * Wed Jul 07 2021 Josh Boudreau <jboudreau@45drives.com> 0.4.6-3
- Add relase for el7 - Add release for el7
* Wed Jun 30 2021 Josh Boudreau <jboudreau@45drives.com> 0.4.6-2 * Wed Jun 30 2021 Josh Boudreau <jboudreau@45drives.com> 0.4.6-2
- First build with auto packaging - First build with auto packaging
* Fri Jun 18 2021 Josh Boudreau <jboudreau@45drives.com> 0.4.6-1 * Fri Jun 18 2021 Josh Boudreau <jboudreau@45drives.com> 0.4.6-1

View File

@ -23,7 +23,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
# empty # empty
%install %install
make DESTDIR=%{buildroot} DIST=%{dist} install make DESTDIR=%{buildroot} DIST=%{dist} NAV_VERS="%{version}-%{release}" install
%clean %clean
rm -rf %{buildroot} rm -rf %{buildroot}
@ -32,6 +32,9 @@ rm -rf %{buildroot}
/usr/share/cockpit/navigator/* /usr/share/cockpit/navigator/*
%changelog %changelog
* Mon Jul 19 2021 Josh Boudreau <jboudreau@45drives.com> 0.5.3-1
- Implement inline filename editing.
- Add information popup button.
* Fri Jul 16 2021 Josh Boudreau <jboudreau@45drives.com> 0.5.2-1 * Fri Jul 16 2021 Josh Boudreau <jboudreau@45drives.com> 0.5.2-1
- Implement uploading of entire directories. - Implement uploading of entire directories.
- Add cancel option to in-progress file uploads. - Add cancel option to in-progress file uploads.
@ -41,7 +44,7 @@ rm -rf %{buildroot}
* Thu Jul 15 2021 Josh Boudreau <jboudreau@45drives.com> 0.5.0-1 * Thu Jul 15 2021 Josh Boudreau <jboudreau@45drives.com> 0.5.0-1
- Implement custom modal style popups to replace browser dialogs. - Implement custom modal style popups to replace browser dialogs.
* Wed Jul 07 2021 Josh Boudreau <jboudreau@45drives.com> 0.4.6-3 * Wed Jul 07 2021 Josh Boudreau <jboudreau@45drives.com> 0.4.6-3
- Add relase for el7 - Add release for el7
* Wed Jun 30 2021 Josh Boudreau <jboudreau@45drives.com> 0.4.6-2 * Wed Jun 30 2021 Josh Boudreau <jboudreau@45drives.com> 0.4.6-2
- First build with auto packaging - First build with auto packaging
* Fri Jun 18 2021 Josh Boudreau <jboudreau@45drives.com> 0.4.6-1 * Fri Jun 18 2021 Josh Boudreau <jboudreau@45drives.com> 0.4.6-1

View File

@ -1,3 +1,10 @@
cockpit-navigator (0.5.3-1focal) focal; urgency=medium
* Implement inline filename editing.
* Add information popup button.
-- Josh Boudreau <jboudreau@45drives.com> Mon, 19 Jul 2021 10:34:27 -0300
cockpit-navigator (0.5.2-1focal) focal; urgency=medium cockpit-navigator (0.5.2-1focal) focal; urgency=medium
* Implement uploading of entire directories. * Implement uploading of entire directories.

View File

@ -13,6 +13,8 @@
# package maintainers to append LDFLAGS # package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed #export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
export NAV_VERS := $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ':')
%: %:
dh $@ dh $@