mirror of
https://github.com/eugeny/tabby
synced 2025-12-15 12:15:44 +00:00
Organize the connections in folders.
Filter connections in quick connect. Need more custom CSS to handle long connection list. See also #403
This commit is contained in:
@@ -14,6 +14,9 @@ export class SSHModalComponent {
|
||||
connections: SSHConnection[]
|
||||
quickTarget: string
|
||||
lastConnection: SSHConnection
|
||||
currentPath: string
|
||||
childFolders: string[]
|
||||
childConnections: SSHConnection[]
|
||||
|
||||
constructor (
|
||||
public modalInstance: NgbActiveModal,
|
||||
@@ -28,6 +31,19 @@ export class SSHModalComponent {
|
||||
if (window.localStorage.lastConnection) {
|
||||
this.lastConnection = JSON.parse(window.localStorage.lastConnection)
|
||||
}
|
||||
this.currentPath = "/"
|
||||
this.findChildren()
|
||||
}
|
||||
|
||||
filter () {
|
||||
if (!this.quickTarget) {
|
||||
this.findChildren()
|
||||
}
|
||||
else
|
||||
{
|
||||
this.childFolders = [];
|
||||
this.childConnections = this.connections.filter(connection => connection.name.toLowerCase().indexOf(this.quickTarget) >= 0)
|
||||
}
|
||||
}
|
||||
|
||||
quickConnect () {
|
||||
@@ -65,4 +81,38 @@ export class SSHModalComponent {
|
||||
close () {
|
||||
this.modalInstance.close()
|
||||
}
|
||||
|
||||
findChildren () {
|
||||
this.childFolders = []
|
||||
this.childConnections = []
|
||||
|
||||
if (this.currentPath != "/")
|
||||
this.childFolders.push("..")
|
||||
|
||||
for (let connection of this.connections) {
|
||||
if (!connection.path)
|
||||
connection.path = "/"
|
||||
if (connection.path.startsWith(this.currentPath)) {
|
||||
let folder = connection.path.substr(this.currentPath.length, connection.path.indexOf("/", this.currentPath.length) - this.currentPath.length)
|
||||
if (folder.length == 0) {
|
||||
this.childConnections.push(connection)
|
||||
}
|
||||
else if (this.childFolders.indexOf(folder) < 0) {
|
||||
this.childFolders.push(folder)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cd (path: string) {
|
||||
if (path == "..") {
|
||||
path = this.currentPath.substr(0, this.currentPath.lastIndexOf("/", this.currentPath.length - 2) + 1)
|
||||
}
|
||||
else {
|
||||
path = this.currentPath + path + '/'
|
||||
}
|
||||
|
||||
this.currentPath = path
|
||||
this.findChildren()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user