mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-04 18:39:54 +00:00
Merge branch 'master' of github.com:Eugeny/tabby
This commit is contained in:
commit
3a012878d0
@ -0,0 +1,12 @@
|
|||||||
|
.modal-body
|
||||||
|
label(translate) Name for the new directory
|
||||||
|
.form-group.w-100.mr-2
|
||||||
|
input.form-control(
|
||||||
|
type='text',
|
||||||
|
[(ngModel)]='directoryName',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
.modal-footer
|
||||||
|
button.btn.btn-success((click)='create()', translate) Create
|
||||||
|
button.btn.btn-danger((click)='cancel()', translate) Cancel
|
@ -0,0 +1,24 @@
|
|||||||
|
import { Component } from '@angular/core'
|
||||||
|
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||||
|
import { BaseComponent } from 'tabby-core'
|
||||||
|
|
||||||
|
/** @hidden */
|
||||||
|
@Component({
|
||||||
|
template: require('./sftpCreateDirectoryModal.component.pug'),
|
||||||
|
})
|
||||||
|
export class SFTPCreateDirectoryModalComponent extends BaseComponent {
|
||||||
|
directoryName: string
|
||||||
|
|
||||||
|
constructor (
|
||||||
|
private modalInstance: NgbActiveModal,
|
||||||
|
) {
|
||||||
|
super()
|
||||||
|
}
|
||||||
|
|
||||||
|
create (): void {
|
||||||
|
this.modalInstance.close(this.directoryName)
|
||||||
|
}
|
||||||
|
cancel (): void {
|
||||||
|
this.modalInstance.close('')
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,10 @@
|
|||||||
(click)='navigate(segment.path)'
|
(click)='navigate(segment.path)'
|
||||||
) {{segment.name}}
|
) {{segment.name}}
|
||||||
|
|
||||||
|
button.btn.btn-link.btn-sm.d-flex((click)='openCreateDirectoryModal()')
|
||||||
|
i.fas.fa-plus.mr-1
|
||||||
|
div(translate) Create directory
|
||||||
|
|
||||||
button.btn.btn-link.btn-sm.d-flex((click)='upload()')
|
button.btn.btn-link.btn-sm.d-flex((click)='upload()')
|
||||||
i.fas.fa-upload.mr-1
|
i.fas.fa-upload.mr-1
|
||||||
div(translate) Upload
|
div(translate) Upload
|
||||||
|
@ -5,6 +5,8 @@ import { FileUpload, MenuItemOptions, NotificationsService, PlatformService } fr
|
|||||||
import { SFTPSession, SFTPFile } from '../session/sftp'
|
import { SFTPSession, SFTPFile } from '../session/sftp'
|
||||||
import { SSHSession } from '../session/ssh'
|
import { SSHSession } from '../session/ssh'
|
||||||
import { SFTPContextMenuItemProvider } from '../api'
|
import { SFTPContextMenuItemProvider } from '../api'
|
||||||
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
||||||
|
import { SFTPCreateDirectoryModalComponent } from './sftpCreateDirectoryModal.component'
|
||||||
|
|
||||||
interface PathSegment {
|
interface PathSegment {
|
||||||
name: string
|
name: string
|
||||||
@ -26,6 +28,7 @@ export class SFTPPanelComponent {
|
|||||||
pathSegments: PathSegment[] = []
|
pathSegments: PathSegment[] = []
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
|
private ngbModal: NgbModal,
|
||||||
private platform: PlatformService,
|
private platform: PlatformService,
|
||||||
private notifications: NotificationsService,
|
private notifications: NotificationsService,
|
||||||
@Optional() @Inject(SFTPContextMenuItemProvider) protected contextMenuProviders: SFTPContextMenuItemProvider[],
|
@Optional() @Inject(SFTPContextMenuItemProvider) protected contextMenuProviders: SFTPContextMenuItemProvider[],
|
||||||
@ -106,6 +109,19 @@ export class SFTPPanelComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async openCreateDirectoryModal (): Promise<void> {
|
||||||
|
const modal = this.ngbModal.open(SFTPCreateDirectoryModalComponent)
|
||||||
|
const directoryName = await modal.result
|
||||||
|
if (directoryName !== '') {
|
||||||
|
this.sftp.mkdir(path.join(this.path, directoryName)).then(() => {
|
||||||
|
this.notifications.notice('The directory was created successfully')
|
||||||
|
this.navigate(path.join(this.path, directoryName))
|
||||||
|
}).catch(() => {
|
||||||
|
this.notifications.error('The directory could not be created')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async upload (): Promise<void> {
|
async upload (): Promise<void> {
|
||||||
const transfers = await this.platform.startUpload({ multiple: true })
|
const transfers = await this.platform.startUpload({ multiple: true })
|
||||||
await Promise.all(transfers.map(t => this.uploadOne(t)))
|
await Promise.all(transfers.map(t => this.uploadOne(t)))
|
||||||
|
@ -26,6 +26,7 @@ import { SFTPContextMenu } from './tabContextMenu'
|
|||||||
import { SSHProfilesService } from './profiles'
|
import { SSHProfilesService } from './profiles'
|
||||||
import { SFTPContextMenuItemProvider } from './api/contextMenu'
|
import { SFTPContextMenuItemProvider } from './api/contextMenu'
|
||||||
import { CommonSFTPContextMenu } from './sftpContextMenu'
|
import { CommonSFTPContextMenu } from './sftpContextMenu'
|
||||||
|
import { SFTPCreateDirectoryModalComponent } from './components/sftpCreateDirectoryModal.component'
|
||||||
|
|
||||||
/** @hidden */
|
/** @hidden */
|
||||||
@NgModule({
|
@NgModule({
|
||||||
@ -50,6 +51,7 @@ import { CommonSFTPContextMenu } from './sftpContextMenu'
|
|||||||
entryComponents: [
|
entryComponents: [
|
||||||
SSHProfileSettingsComponent,
|
SSHProfileSettingsComponent,
|
||||||
SFTPDeleteModalComponent,
|
SFTPDeleteModalComponent,
|
||||||
|
SFTPCreateDirectoryModalComponent,
|
||||||
SSHPortForwardingModalComponent,
|
SSHPortForwardingModalComponent,
|
||||||
SSHSettingsTabComponent,
|
SSHSettingsTabComponent,
|
||||||
SSHTabComponent,
|
SSHTabComponent,
|
||||||
@ -58,6 +60,7 @@ import { CommonSFTPContextMenu } from './sftpContextMenu'
|
|||||||
declarations: [
|
declarations: [
|
||||||
SSHProfileSettingsComponent,
|
SSHProfileSettingsComponent,
|
||||||
SFTPDeleteModalComponent,
|
SFTPDeleteModalComponent,
|
||||||
|
SFTPCreateDirectoryModalComponent,
|
||||||
SSHPortForwardingModalComponent,
|
SSHPortForwardingModalComponent,
|
||||||
SSHPortForwardingConfigComponent,
|
SSHPortForwardingConfigComponent,
|
||||||
SSHSettingsTabComponent,
|
SSHSettingsTabComponent,
|
||||||
|
@ -123,6 +123,11 @@ export class SFTPSession {
|
|||||||
await promisify((f: any) => this.sftp.rmdir(p, f))()
|
await promisify((f: any) => this.sftp.rmdir(p, f))()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async mkdir (p: string): Promise<void> {
|
||||||
|
this.logger.debug('mkdir', p)
|
||||||
|
await promisify((f: any) => this.sftp.mkdir(p, f))()
|
||||||
|
}
|
||||||
|
|
||||||
async rename (oldPath: string, newPath: string): Promise<void> {
|
async rename (oldPath: string, newPath: string): Promise<void> {
|
||||||
this.logger.debug('rename', oldPath, newPath)
|
this.logger.debug('rename', oldPath, newPath)
|
||||||
await promisify((f: any) => this.sftp.rename(oldPath, newPath, f))()
|
await promisify((f: any) => this.sftp.rename(oldPath, newPath, f))()
|
||||||
|
@ -22,6 +22,12 @@ export class CommonSFTPContextMenu extends SFTPContextMenuItemProvider {
|
|||||||
|
|
||||||
async getItems (item: SFTPFile, panel: SFTPPanelComponent): Promise<MenuItemOptions[]> {
|
async getItems (item: SFTPFile, panel: SFTPPanelComponent): Promise<MenuItemOptions[]> {
|
||||||
return [
|
return [
|
||||||
|
{
|
||||||
|
click: async () => {
|
||||||
|
await panel.openCreateDirectoryModal()
|
||||||
|
},
|
||||||
|
label: this.translate.instant('Create directory'),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
click: async () => {
|
click: async () => {
|
||||||
if ((await this.platform.showMessageBox({
|
if ((await this.platform.showMessageBox({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user