Rebase to master when repo went private
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
.breadcrumb-wrapper{
|
||||
position: fixed;
|
||||
top: 200px;
|
||||
}
|
||||
|
||||
.drag-indicator{
|
||||
font-size: 2rem;
|
||||
line-height: 3rem;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.selected{
|
||||
background: #e93c96;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.save-icon{
|
||||
margin-right: 0.5em;
|
||||
margin-left: 0.5em;
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
<div *ngIf="isConnected()">
|
||||
<br><br><br>
|
||||
<nav class="pink lighten-2 breadcrumb-wrapper ">
|
||||
<div class="nav-wrapper container">
|
||||
<div class="col s12">
|
||||
<a *ngFor="let breadcrumb of breadcrumbs" href="javascript:void(0)" class="breadcrumb"
|
||||
(click)="open('/'+breadcrumb.path)">{{breadcrumb.name}}</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div *ngIf="!isConnected()">
|
||||
<h4
|
||||
[ngClass]="{'text-dark-theme':appService.currentTheme === 'dark','text-light-theme':appService.currentTheme === 'light'}">
|
||||
No device connected...</h4>
|
||||
|
||||
</div>
|
||||
<div *ngIf="isConnected()">
|
||||
<div *ngIf="!files.length">
|
||||
<h4
|
||||
[ngClass]="{'text-dark-theme':appService.currentTheme === 'dark','text-light-theme':appService.currentTheme === 'light'}">
|
||||
No files here...</h4>
|
||||
|
||||
</div>
|
||||
<div *ngFor="let file of files" class="vertical-align cursor"
|
||||
[ngClass]="{'text-dark-theme':appService.currentTheme === 'dark','text-light-theme':appService.currentTheme === 'light'}">
|
||||
<div class="file" (click)="selectFile($event, file); $event.stopPropagation()">
|
||||
<div class="right">
|
||||
<span *ngIf="file.icon !== 'folder'">{{file.size|number:'1.2-2'}}MB | </span>{{file.time|date:'short'}}
|
||||
|
||||
<i class="material-icons cursor white-text drag-indicator save-icon"
|
||||
(click)="filesToBeSaved = [file]; filesModal.openModal();">save</i>
|
||||
<i class="material-icons cursor orange-text drag-indicator right delete"
|
||||
(click)="filesToBeDeleted = [file]; confirmModal.openModal()">close</i>
|
||||
</div>
|
||||
<div>
|
||||
<i class="material-icons medium vertical-align"
|
||||
[ngClass]="{'text-dark-theme':appService.currentTheme === 'dark','text-light-theme':appService.currentTheme === 'light'}">{{file.icon}}</i>{{file.name}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br><br>
|
||||
</div>
|
||||
<div class="fixed-action-btn" #fixedAction *ngIf="isConnected()">
|
||||
<a class="btn-floating btn-large pink lightn-2" mz-tooltip position="left" tooltip="Add a file.">
|
||||
<i class="large material-icons">add</i>
|
||||
</a>
|
||||
<ul>
|
||||
<li mz-tooltip position="left" tooltip="Copy file to this folder" (click)="uploadFiles()"><a
|
||||
class="btn-floating purple"><i class="material-icons">insert_drive_file</i></a></li>
|
||||
<li mz-tooltip position="left" tooltip="Make folder in this folder" (click)="mkDirModal.openModal()"><a
|
||||
class="btn-floating blue"><i class="material-icons">folder</i></a></li>
|
||||
<li mz-tooltip position="left" tooltip="Open current save location" (click)="openSaveLocation()"><a
|
||||
class="btn-floating yellow darken-2"><i class="material-icons">folder</i></a></li>
|
||||
<li *ngIf="selectedFiles.length > 0" mz-tooltip position="left" tooltip="Delete selected items"
|
||||
(click)="filesToBeDeleted = selectedFiles; confirmModal.openModal()"><a class="btn-floating red darken-2"><i
|
||||
class="material-icons">delete</i></a></li>
|
||||
<li *ngIf="quickSaveSupported()" mz-tooltip position="left" tooltip="Save screenshots and recordings"
|
||||
(click)="downloadMediaModal.openModal()"><a class="btn-floating green"><i class="material-icons">get_app</i></a>
|
||||
</li>
|
||||
<li *ngIf="selectedFiles.length > 0" mz-tooltip position="left" tooltip="Save selected items to computer"
|
||||
(click)="filesToBeSaved = selectedFiles; filesModal.openModal()">
|
||||
<a class="btn-floating orange"><i class="material-icons">get_app</i></a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<mz-modal #mkDirModal [fixedFooter]="true">
|
||||
<mz-modal-header>
|
||||
<h4>Make Folder</h4>
|
||||
</mz-modal-header>
|
||||
<mz-modal-content>
|
||||
Please enter a folder name.
|
||||
<div class="input-field ">
|
||||
<input id="devicePaste" type="text" [(ngModel)]="folderName" autofocus />
|
||||
<label for="devicePaste">Folder Name</label>
|
||||
</div>
|
||||
</mz-modal-content>
|
||||
<mz-modal-footer>
|
||||
<button mz-button [flat]="true" mz-modal-close>Close</button>
|
||||
<button mz-button class="pink-button" mz-modal-close (click)="makeFolder()">Make Folder</button>
|
||||
</mz-modal-footer>
|
||||
</mz-modal>
|
||||
|
||||
<mz-modal #filesModal [fixedFooter]="true">
|
||||
<mz-modal-header>
|
||||
<h4>Save selected file(s) to your PC</h4>
|
||||
</mz-modal-header>
|
||||
<mz-modal-content>
|
||||
Pick a location on your PC to save the following file(s):<br><br>
|
||||
<div *ngFor="let file of filesToBeSaved">
|
||||
<div class="file">
|
||||
<div>
|
||||
<i class="material-icons cursor orange-text drag-indicator" (click)="filesToBeSaved.splice(filesToBeSaved.indexOf(file), 1);
|
||||
clearSelection([file]);
|
||||
filesToBeSaved.length === 0 && filesModal.closeModal()">close</i>
|
||||
{{file.name}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br><br>
|
||||
<button mz-button class="pink-button" (click)="pickLocation()">Select Location</button><br><br>
|
||||
Current Location: {{adbService.savePath}}
|
||||
|
||||
|
||||
</mz-modal-content>
|
||||
<mz-modal-footer>
|
||||
<button mz-button [flat]="true" mz-modal-close>Close</button>
|
||||
<button mz-button class="pink-button" mz-modal-close
|
||||
(click)="saveFiles(filesToBeSaved); clearSelection(filesToBeSaved)">Save To PC</button>
|
||||
</mz-modal-footer>
|
||||
</mz-modal>
|
||||
|
||||
<mz-modal #downloadMediaModal [fixedFooter]="true">
|
||||
<mz-modal-header>
|
||||
<h4>Save local media to your PC</h4>
|
||||
</mz-modal-header>
|
||||
<mz-modal-content>
|
||||
Pick a location on your PC to save screenshots and recordings:<br><br>
|
||||
<button mz-button class="pink-button" (click)="pickLocation()">Select Location</button><br><br>
|
||||
Current Location: {{adbService.savePath}}
|
||||
|
||||
|
||||
</mz-modal-content>
|
||||
<mz-modal-footer>
|
||||
<button mz-button [flat]="true" mz-modal-close>Close</button>
|
||||
<button mz-button class="pink-button" mz-modal-close (click)="downloadMedia()">Save To PC</button>
|
||||
</mz-modal-footer>
|
||||
</mz-modal>
|
||||
|
||||
<mz-modal #confirmModal [fixedFooter]="true">
|
||||
<mz-modal-header>
|
||||
<h4>Delete selected file(s)</h4>
|
||||
</mz-modal-header>
|
||||
<mz-modal-content>
|
||||
Are you sure you want to delete the selected file(s)? <br>
|
||||
<em>Click <i class="material-icons orange-text" style="font-size: 16px">close</i> to remove files</em>
|
||||
<br><br>
|
||||
<div *ngFor="let file of filesToBeDeleted">
|
||||
<div class="file">
|
||||
<div>
|
||||
<i class="material-icons cursor orange-text drag-indicator" (click)="filesToBeDeleted.splice(filesToBeDeleted.indexOf(file), 1);
|
||||
clearSelection([file]);
|
||||
filesToBeDeleted.length === 0 && confirmModal.closeModal()">close</i>
|
||||
{{file.name}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<h5><em>WARNING: This cannot be undone!!</em></h5>
|
||||
</mz-modal-content>
|
||||
<mz-modal-footer>
|
||||
<button mz-button [flat]="true" mz-modal-close>Close</button>
|
||||
<button mz-button class="red" mz-modal-close
|
||||
(click)="deleteFiles(filesToBeDeleted); clearSelection(filesToBeDeleted)">Delete Items</button>
|
||||
</mz-modal-footer>
|
||||
</mz-modal>
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { FilesComponent } from './files.component';
|
||||
|
||||
describe('FilesComponent', () => {
|
||||
let component: FilesComponent;
|
||||
let fixture: ComponentFixture<FilesComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ FilesComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(FilesComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,378 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { AdbClientService, ConnectionStatus } from '../adb-client.service';
|
||||
import { AppService } from '../app.service';
|
||||
import { LoadingSpinnerService } from '../loading-spinner.service';
|
||||
import { StatusBarService } from '../status-bar.service';
|
||||
import { ProcessBucketService } from '../process-bucket.service';
|
||||
interface FileFolderListing {
|
||||
name: string;
|
||||
icon: string;
|
||||
size: number;
|
||||
time: Date;
|
||||
filePath: string;
|
||||
}
|
||||
interface BreadcrumbListing {
|
||||
name: string;
|
||||
path: string;
|
||||
}
|
||||
declare let M;
|
||||
@Component({
|
||||
selector: 'app-files',
|
||||
templateUrl: './files.component.html',
|
||||
styleUrls: ['./files.component.css'],
|
||||
})
|
||||
export class FilesComponent implements OnInit {
|
||||
@ViewChild('filesModal', { static: false }) filesModal;
|
||||
@ViewChild('fixedAction', { static: false }) fixedAction;
|
||||
@ViewChild('downloadMediaModal', { static: false }) downloadMediaModal;
|
||||
files: FileFolderListing[] = [];
|
||||
selectedFiles: FileFolderListing[] = [];
|
||||
filesToBeSaved: FileFolderListing[];
|
||||
filesToBeDeleted: FileFolderListing[];
|
||||
breadcrumbs: BreadcrumbListing[] = [];
|
||||
isOpen: boolean = false;
|
||||
currentPath: string;
|
||||
folderName: string;
|
||||
currentFile: FileFolderListing;
|
||||
quickSaveModels: string[] = ['Quest', 'Go'];
|
||||
constructor(
|
||||
public spinnerService: LoadingSpinnerService,
|
||||
public adbService: AdbClientService,
|
||||
public appService: AppService,
|
||||
public statusService: StatusBarService,
|
||||
private processService: ProcessBucketService
|
||||
) {
|
||||
this.appService.resetTop();
|
||||
appService.filesComponent = this;
|
||||
appService.isFilesOpen = true;
|
||||
appService.webService.isWebviewOpen = false;
|
||||
}
|
||||
ngOnAfterViewInit() {
|
||||
M.FloatingActionButton.init(this.fixedAction.nativeElement, {});
|
||||
}
|
||||
ngOnInit() {
|
||||
this.appService.setTitle('Headset Files');
|
||||
}
|
||||
async makeFolder() {
|
||||
if (
|
||||
~this.files
|
||||
.filter(f => f.icon === 'folder')
|
||||
.map(f => f.name)
|
||||
.indexOf(this.folderName)
|
||||
) {
|
||||
return this.statusService.showStatus('A folder already exists with that name!!', true);
|
||||
} else {
|
||||
await this.adbService.makeDirectory(this.appService.path.posix.join(this.currentPath, this.folderName)).then(r => {
|
||||
this.folderName = '';
|
||||
this.open(this.currentPath);
|
||||
});
|
||||
}
|
||||
}
|
||||
selectFile(event: Event, file: FileFolderListing) {
|
||||
let fileElement = event.target as Element;
|
||||
|
||||
if (file.icon === 'folder' && !(fileElement.classList.contains('save-icon') || fileElement.classList.contains('delete'))) {
|
||||
this.selectedFiles.length = 0;
|
||||
this.open(this.appService.path.posix.join(this.currentPath, file.name));
|
||||
} else if (!fileElement.classList.contains('delete') && !fileElement.classList.contains('save-icon')) {
|
||||
while (!fileElement.classList.contains('file')) {
|
||||
fileElement = fileElement.parentElement;
|
||||
}
|
||||
|
||||
if (this.selectedFiles.includes(file)) {
|
||||
this.selectedFiles.splice(this.selectedFiles.indexOf(file), 1);
|
||||
fileElement.classList.remove('selected');
|
||||
} else {
|
||||
this.selectedFiles.push(file);
|
||||
fileElement.classList.add('selected');
|
||||
}
|
||||
}
|
||||
}
|
||||
clearSelection(files?: FileFolderListing[]) {
|
||||
if (files) {
|
||||
for (const file of files) {
|
||||
document
|
||||
.querySelectorAll('.file')
|
||||
.item(this.files.indexOf(file))
|
||||
.classList.remove('selected');
|
||||
this.selectedFiles = this.selectedFiles.filter(f => f !== file);
|
||||
}
|
||||
} else {
|
||||
document.querySelectorAll('.selected').forEach(element => {
|
||||
element.classList.remove('selected');
|
||||
});
|
||||
this.selectedFiles.length = 0;
|
||||
}
|
||||
}
|
||||
async uploadFolder(folder, files, task) {
|
||||
task.status = 'Restoring Folder... ' + folder;
|
||||
if (this.appService.fs.existsSync(folder)) {
|
||||
this.adbService.localFiles = [];
|
||||
await this.adbService
|
||||
.getLocalFoldersRecursive(folder)
|
||||
.then(() => {
|
||||
this.adbService.localFiles.forEach(file => {
|
||||
file.savePath = this.appService.path.posix.join(
|
||||
this.currentPath,
|
||||
file.name
|
||||
.replace(folder, this.appService.path.basename(folder))
|
||||
.split('\\')
|
||||
.join('/')
|
||||
);
|
||||
});
|
||||
return this.adbService.uploadFile(this.adbService.localFiles.filter(f => f.__isFile), task);
|
||||
})
|
||||
.then(() => setTimeout(() => this.uploadFile(files, task), 500));
|
||||
}
|
||||
}
|
||||
uploadFile(files, task): Promise<any> {
|
||||
if (!files.length) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
const f = files.shift();
|
||||
const savePath = this.appService.path.posix.join(this.currentPath, this.appService.path.basename(f));
|
||||
if (!this.appService.fs.existsSync(f)) {
|
||||
return Promise.resolve().then(() => setTimeout(() => this.uploadFile(files, task), 500));
|
||||
}
|
||||
if (this.appService.fs.lstatSync(f).isDirectory()) {
|
||||
return new Promise(async resolve => {
|
||||
this.folderName = this.appService.path.basename(f);
|
||||
await this.makeFolder();
|
||||
await this.uploadFolder(f, files, task);
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
return this.adbService
|
||||
.adbCommand('push', { serial: this.adbService.deviceSerial, path: f, savePath }, stats => {
|
||||
task.status =
|
||||
'File uploading: ' +
|
||||
this.appService.path.basename(f) +
|
||||
' ' +
|
||||
Math.round((stats.bytesTransferred / 1024 / 1024) * 100) / 100 +
|
||||
'MB';
|
||||
})
|
||||
.then(() => setTimeout(() => this.uploadFile(files, task), 500));
|
||||
}
|
||||
uploadFilesFromList(files: string[]) {
|
||||
if (files !== undefined && files.length) {
|
||||
return this.processService.addItem('restore_files', async task => {
|
||||
task.status = 'Starting Upload to ' + this.currentPath;
|
||||
this.uploadFile(files, task)
|
||||
.then(() => {
|
||||
setTimeout(() => {
|
||||
this.open(this.currentPath);
|
||||
task.status = 'Upload complete! ' + this.currentPath;
|
||||
this.statusService.showStatus('Files/Folders uploaded successfully!');
|
||||
}, 1500);
|
||||
})
|
||||
.catch(e => this.statusService.showStatus(e.toString(), true));
|
||||
});
|
||||
}
|
||||
}
|
||||
uploadFiles() {
|
||||
this.appService.electron.remote.dialog.showOpenDialog(
|
||||
{
|
||||
properties: ['openFile', 'multiSelections'],
|
||||
defaultPath: this.adbService.savePath,
|
||||
},
|
||||
files => this.uploadFilesFromList(files)
|
||||
);
|
||||
}
|
||||
quickSaveSupported() {
|
||||
return this.quickSaveModels.includes(this.adbService.deviceModel);
|
||||
}
|
||||
async downloadMedia() {
|
||||
let paths = [];
|
||||
let media: FileFolderListing[] = [];
|
||||
|
||||
if (this.adbService.deviceModel === 'Quest' || this.adbService.deviceModel === 'Go') {
|
||||
paths = ['/sdcard/Oculus/Screenshots', '/sdcard/Oculus/VideoShots'];
|
||||
}
|
||||
|
||||
for (const path of paths) {
|
||||
await this.readdir(path).then(dirContents => {
|
||||
media = media.concat(dirContents.filter(file => file.icon !== 'folder'));
|
||||
});
|
||||
}
|
||||
|
||||
this.saveFiles(media);
|
||||
}
|
||||
deleteFiles(files: FileFolderListing[]) {
|
||||
for (const file of files) {
|
||||
this.deleteFile(file);
|
||||
}
|
||||
|
||||
this.statusService.showStatus(files.length + ' Item(s) Deleted!!');
|
||||
}
|
||||
deleteFile(file: FileFolderListing) {
|
||||
this.adbService
|
||||
.adbCommand('shell', { serial: this.adbService.deviceSerial, command: 'rm "' + file.filePath + '" -r' })
|
||||
.then(r => {
|
||||
this.files.splice(this.files.indexOf(file), 1);
|
||||
});
|
||||
}
|
||||
saveFiles(files: FileFolderListing[]) {
|
||||
this.filesModal.closeModal();
|
||||
for (const file of files) {
|
||||
if (file.icon !== 'folder') {
|
||||
this.saveFile(file);
|
||||
} else {
|
||||
this.saveFolder(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
saveFile(file: FileFolderListing) {
|
||||
const savePath = this.appService.path.join(this.adbService.savePath, file.name);
|
||||
const path = file.filePath;
|
||||
return this.processService.addItem('save_files', async task => {
|
||||
return this.adbService
|
||||
.adbCommand('pull', { serial: this.adbService.deviceSerial, path, savePath }, stats => {
|
||||
task.status =
|
||||
'File downloading: ' +
|
||||
this.appService.path.basename(savePath) +
|
||||
' - ' +
|
||||
Math.round(stats.bytesTransferred / 1024 / 1024) +
|
||||
' / ' +
|
||||
file.size +
|
||||
' MB';
|
||||
})
|
||||
.then(() => {
|
||||
task.status = 'Files Saved to ' + savePath + '!!';
|
||||
this.statusService.showStatus('File (' + file.name + ') Saved OK!');
|
||||
})
|
||||
.catch(e => this.statusService.showStatus(e.toString(), true));
|
||||
});
|
||||
}
|
||||
saveFolder(file: FileFolderListing) {
|
||||
this.filesModal.closeModal();
|
||||
const savePath = this.appService.path.join(this.adbService.savePath, file.name);
|
||||
const path = file.filePath;
|
||||
this.adbService.files = [];
|
||||
return this.processService.addItem('save_files', async task => {
|
||||
return this.adbService
|
||||
.getFoldersRecursive(path)
|
||||
.then(() => this.appService.mkdir(savePath))
|
||||
.then(
|
||||
() =>
|
||||
(this.adbService.files = this.adbService.files.map(f => {
|
||||
f.saveName = this.appService.path.join(savePath, f.name.replace(path, ''));
|
||||
return f;
|
||||
}))
|
||||
)
|
||||
.then(() => this.adbService.makeFolder(this.adbService.files.filter(f => !f.__isFile)))
|
||||
.then(() => this.adbService.downloadFile(this.adbService.files.filter(f => f.__isFile), task))
|
||||
.then(() => this.statusService.showStatus('Folder Saved OK!'));
|
||||
});
|
||||
}
|
||||
pickLocation() {
|
||||
this.appService.electron.remote.dialog.showOpenDialog(
|
||||
{
|
||||
properties: ['openDirectory'],
|
||||
defaultPath: this.adbService.savePath,
|
||||
},
|
||||
files => {
|
||||
if (files !== undefined && files.length === 1) {
|
||||
this.adbService.savePath = files[0];
|
||||
this.adbService.setSavePath();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
isConnected() {
|
||||
const isConnected = this.adbService.deviceStatus === ConnectionStatus.CONNECTED;
|
||||
if (isConnected && !this.isOpen) {
|
||||
this.isOpen = true;
|
||||
this.open('/sdcard/');
|
||||
}
|
||||
return isConnected;
|
||||
}
|
||||
getCrumb(path: string) {
|
||||
const parts = path.split('/');
|
||||
const name = parts.pop();
|
||||
const parentPath = parts.join('/');
|
||||
if (parts.length > 0) {
|
||||
this.getCrumb(parentPath);
|
||||
}
|
||||
this.breadcrumbs.push({ path, name });
|
||||
}
|
||||
open(path: string) {
|
||||
//this.spinnerService.showLoader();
|
||||
//this.spinnerService.setMessage('Loading files...');
|
||||
this.currentPath = path;
|
||||
this.breadcrumbs = [];
|
||||
this.selectedFiles.length = 0;
|
||||
this.getCrumb(
|
||||
this.currentPath
|
||||
.split('/')
|
||||
.filter(d => d)
|
||||
.join('/')
|
||||
);
|
||||
if (!this.isConnected()) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
this.readdir(path).then(dirContents => {
|
||||
this.files = dirContents;
|
||||
this.files.sort(function(a, b) {
|
||||
const textA = a.name.toUpperCase();
|
||||
const textB = b.name.toUpperCase();
|
||||
return textA < textB ? -1 : textA > textB ? 1 : 0;
|
||||
});
|
||||
this.files = this.files.filter(d => d.icon === 'folder').concat(this.files.filter(d => d.icon !== 'folder'));
|
||||
//this.spinnerService.hideLoader();
|
||||
});
|
||||
}
|
||||
openSaveLocation() {
|
||||
this.appService.electron.remote.shell.openItem(this.adbService.savePath);
|
||||
}
|
||||
async readdir(path: String) {
|
||||
let dirContents: FileFolderListing[];
|
||||
await this.adbService.adbCommand('readdir', { serial: this.adbService.deviceSerial, path }).then(files => {
|
||||
dirContents = files.map(file => {
|
||||
const name = file.name;
|
||||
const size = Math.round((file.size / 1024 / 1024) * 100) / 100;
|
||||
const time = file.mtime;
|
||||
const filePath = this.appService.path.posix.join(path, file.name);
|
||||
let icon = 'folder';
|
||||
if (file.__isFile) {
|
||||
const fileParts = file.name.split('.');
|
||||
const extension = (fileParts[fileParts.length - 1] || '').toLowerCase();
|
||||
switch (extension) {
|
||||
case 'gif':
|
||||
case 'png':
|
||||
case 'jpeg':
|
||||
case 'jpg':
|
||||
icon = 'photo';
|
||||
break;
|
||||
case 'wav':
|
||||
case 'ogg':
|
||||
case 'mp3':
|
||||
icon = 'music_note';
|
||||
break;
|
||||
case 'avi':
|
||||
case 'mp4':
|
||||
icon = 'ondemand_video';
|
||||
break;
|
||||
case 'txt':
|
||||
case 'docx':
|
||||
case 'doc':
|
||||
icon = 'receipt';
|
||||
break;
|
||||
case 'pptx':
|
||||
case 'ppt':
|
||||
icon = 'picture_in_picture';
|
||||
break;
|
||||
case 'xlsx':
|
||||
case 'xls':
|
||||
icon = 'grid_on';
|
||||
break;
|
||||
default:
|
||||
icon = 'receipt';
|
||||
break;
|
||||
}
|
||||
}
|
||||
return { name, icon, size, time, filePath };
|
||||
});
|
||||
});
|
||||
return dirContents;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user