mirror of
https://github.com/Eugeny/tabby.git
synced 2025-08-25 02:31:53 +00:00
project rename
This commit is contained in:
49
tabby-ssh/src/components/sftpDeleteModal.component.ts
Normal file
49
tabby-ssh/src/components/sftpDeleteModal.component.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { Component } from '@angular/core'
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { BaseComponent } from 'tabby-core'
|
||||
import { SFTPFile, SFTPSession } from '../api'
|
||||
|
||||
/** @hidden */
|
||||
@Component({
|
||||
template: require('./sftpDeleteModal.component.pug'),
|
||||
})
|
||||
export class SFTPDeleteModalComponent extends BaseComponent {
|
||||
sftp: SFTPSession
|
||||
item: SFTPFile
|
||||
progressMessage = ''
|
||||
cancelled = false
|
||||
|
||||
constructor (
|
||||
private modalInstance: NgbActiveModal,
|
||||
) {
|
||||
super()
|
||||
}
|
||||
|
||||
ngOnInit (): void {
|
||||
this.destroyed$.subscribe(() => this.cancel())
|
||||
this.run(this.item).then(() => {
|
||||
this.modalInstance.close()
|
||||
})
|
||||
}
|
||||
|
||||
cancel (): void {
|
||||
this.cancelled = true
|
||||
this.modalInstance.close()
|
||||
}
|
||||
|
||||
async run (file: SFTPFile): Promise<void> {
|
||||
this.progressMessage = file.fullPath
|
||||
|
||||
if (file.isDirectory) {
|
||||
for (const child of await this.sftp.readdir(file.fullPath)) {
|
||||
await this.run(child)
|
||||
if (this.cancelled) {
|
||||
break
|
||||
}
|
||||
}
|
||||
await this.sftp.rmdir(file.fullPath)
|
||||
} else {
|
||||
this.sftp.unlink(file.fullPath)
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user