Fix file transfers of larger files, and action button not working.
This commit is contained in:
@@ -26,7 +26,7 @@
|
|||||||
<ng-container *ngFor="let favourite of appService.headerComponent.favourites.fileFavourites">
|
<ng-container *ngFor="let favourite of appService.headerComponent.favourites.fileFavourites">
|
||||||
<a href="javascript:void(0)" class="waves-effect waves-light synthrideerz margin-right"
|
<a href="javascript:void(0)" class="waves-effect waves-light synthrideerz margin-right"
|
||||||
(click)="appService.filesComponent.open(favourite.uri)"
|
(click)="appService.filesComponent.open(favourite.uri)"
|
||||||
mTooltip="{{favourite.name}}">
|
mTooltip [attr.data-tooltip]="favourite.name">
|
||||||
<img *ngIf="favourite.icon" src="{{favourite.icon}}" class="responsive-img" /></a>
|
<img *ngIf="favourite.icon" src="{{favourite.icon}}" class="responsive-img" /></a>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<div class="divider divider-margin-top margin-bottom"></div>
|
<div class="divider divider-margin-top margin-bottom"></div>
|
||||||
@@ -55,32 +55,34 @@
|
|||||||
</div>
|
</div>
|
||||||
<br><br>
|
<br><br>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="fixed-action-btn" #fixedAction *ngIf="isConnected()">
|
<div class="fixed-action-btn" #fixedAction *ngIf="isConnected()">
|
||||||
<a class="btn-floating btn-large pink lightn-2" data-position="left" mTooltip data-tooltip="Add a file.">
|
<a class="dropdown-trigger btn-floating btn-large pink lightn-2" data-position="left" mTooltip data-tooltip="Add a file." >
|
||||||
<i class="large material-icons">add</i>
|
<i class="large material-icons">add</i>
|
||||||
</a>
|
</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li data-position="left" mTooltip data-tooltip="Manage favourite folders"
|
<li data-position="left" mTooltip data-tooltip="Manage favourite folders"
|
||||||
(click)="appService.headerComponent.favoriteType = 'fileFavourites';appService.headerComponent.manageFavs.openModal(); appService.headerComponent.favouriteMax = 10; appService.headerComponent.favoritePathType = 'Path';"
|
(click)="appService.headerComponent.favoriteType = 'fileFavourites';appService.headerComponent.manageFavs.openModal(); appService.headerComponent.favouriteMax = 10; appService.headerComponent.favoritePathType = 'Path';"
|
||||||
><a class="btn-floating red"><i class="material-icons">favorite</i></a></li>
|
><a class="btn-floating red"><i class="material-icons">favorite</i></a></li>
|
||||||
<li data-position="left" mTooltip data-tooltip="Upload file to this folder" (click)="uploadFiles()"><a
|
<li data-position="left" mTooltip data-tooltip="Upload file to this folder" (click)="uploadFiles()"><a
|
||||||
class="btn-floating purple"><i class="material-icons">file_upload</i></a></li>
|
class="btn-floating purple"><i class="material-icons">file_upload</i></a></li>
|
||||||
<li data-position="left" mTooltip data-tooltip="Make new folder in this folder" (click)="mkDirModal.openModal()"><a
|
<li data-position="left" mTooltip data-tooltip="Make new folder in this folder" (click)="mkDirModal.openModal()"><a
|
||||||
class="btn-floating blue"><i class="material-icons">create_new_folder</i></a></li>
|
class="btn-floating blue"><i class="material-icons">create_new_folder</i></a></li>
|
||||||
<li data-position="left" mTooltip data-tooltip="Open current save location" (click)="openSaveLocation()"><a
|
<li data-position="left" mTooltip data-tooltip="Open current save location" (click)="openSaveLocation()"><a
|
||||||
class="btn-floating yellow darken-2"><i class="material-icons">open_in_new</i></a></li>
|
class="btn-floating yellow darken-2"><i class="material-icons">open_in_new</i></a></li>
|
||||||
<li *ngIf="quickSaveSupported()" data-position="left" mTooltip data-tooltip="Save screenshots and recordings"
|
<li *ngIf="quickSaveSupported()" data-position="left" mTooltip data-tooltip="Save screenshots and recordings"
|
||||||
(click)="downloadMediaModal.openModal()"><a class="btn-floating green"><i class="material-icons">get_app</i></a>
|
(click)="downloadMediaModal.openModal()"><a class="btn-floating green"><i class="material-icons">get_app</i></a>
|
||||||
</li>
|
</li>
|
||||||
<li *ngIf="selectedFiles.length > 0" class="divider"></li>
|
<li *ngIf="selectedFiles.length > 0" class="divider"></li>
|
||||||
<li *ngIf="selectedFiles.length > 0" data-position="left" mTooltip data-tooltip="Delete selected items"
|
<li *ngIf="selectedFiles.length > 0" data-position="left" mTooltip data-tooltip="Delete selected items"
|
||||||
(click)="filesToBeDeleted = selectedFiles; confirmModal.openModal()"><a class="btn-floating red darken-2"><i
|
(click)="filesToBeDeleted = selectedFiles; confirmModal.openModal()"><a class="btn-floating red darken-2"><i
|
||||||
class="material-icons">delete</i></a></li>
|
class="material-icons">delete</i></a></li>
|
||||||
<li *ngIf="selectedFiles.length > 0" data-position="left" mTooltip data-tooltip="Save selected items to computer"
|
<li *ngIf="selectedFiles.length > 0" data-position="left" mTooltip data-tooltip="Save selected items to computer"
|
||||||
(click)="filesToBeSaved = selectedFiles; filesModal.openModal()">
|
(click)="filesToBeSaved = selectedFiles; filesModal.openModal()">
|
||||||
<a class="btn-floating orange"><i class="material-icons">get_app</i></a>
|
<a class="btn-floating orange"><i class="material-icons">get_app</i></a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<mz-modal #mkDirModal [fixedFooter]="true">
|
<mz-modal #mkDirModal [fixedFooter]="true">
|
||||||
|
|||||||
@@ -1,4 +1,12 @@
|
|||||||
import { AfterViewInit, Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
import {
|
||||||
|
afterNextRender,
|
||||||
|
AfterRenderPhase,
|
||||||
|
AfterViewInit,
|
||||||
|
Component,
|
||||||
|
OnDestroy,
|
||||||
|
OnInit,
|
||||||
|
ViewChild,
|
||||||
|
} from '@angular/core';
|
||||||
import { AdbClientService, ConnectionStatus } from '../adb-client.service';
|
import { AdbClientService, ConnectionStatus } from '../adb-client.service';
|
||||||
import { AppService } from '../app.service';
|
import { AppService } from '../app.service';
|
||||||
import { LoadingSpinnerService } from '../loading-spinner.service';
|
import { LoadingSpinnerService } from '../loading-spinner.service';
|
||||||
@@ -21,7 +29,7 @@ declare let M;
|
|||||||
templateUrl: './files.component.html',
|
templateUrl: './files.component.html',
|
||||||
styleUrls: ['./files.component.scss'],
|
styleUrls: ['./files.component.scss'],
|
||||||
})
|
})
|
||||||
export class FilesComponent implements OnInit {
|
export class FilesComponent implements OnInit, AfterViewInit {
|
||||||
@ViewChild('filesModal') filesModal;
|
@ViewChild('filesModal') filesModal;
|
||||||
@ViewChild('fixedAction') fixedAction;
|
@ViewChild('fixedAction') fixedAction;
|
||||||
@ViewChild('downloadMediaModal') downloadMediaModal;
|
@ViewChild('downloadMediaModal') downloadMediaModal;
|
||||||
@@ -49,9 +57,20 @@ export class FilesComponent implements OnInit {
|
|||||||
// appService.isFilesOpen = true;
|
// appService.isFilesOpen = true;
|
||||||
appService.webService.isWebviewOpen = false;
|
appService.webService.isWebviewOpen = false;
|
||||||
}
|
}
|
||||||
ngOnAfterViewInit() {
|
|
||||||
M.FloatingActionButton.init(this.fixedAction.nativeElement, {});
|
ngAfterViewInit() {
|
||||||
|
this.setupActionButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private setupActionButton() {
|
||||||
|
// We have to wait until it is actually ready, this component isn't ready even afterViewInit, so we have to loop wait
|
||||||
|
if (this.fixedAction == null) {
|
||||||
|
setTimeout(() => this.setupActionButton(), 100);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
M.FloatingActionButton.init(this.fixedAction.nativeElement, {});
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.appService.setTitle('Headset Files');
|
this.appService.setTitle('Headset Files');
|
||||||
}
|
}
|
||||||
@@ -411,4 +430,5 @@ export class FilesComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
return dirContents;
|
return dirContents;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,11 +13,10 @@ export class PackageService {
|
|||||||
}
|
}
|
||||||
async getAppIndex() {
|
async getAppIndex() {
|
||||||
const request = await fetch(this.indexUrl, {
|
const request = await fetch(this.indexUrl, {
|
||||||
method: 'GET',
|
method: 'GET'
|
||||||
headers: { "Content-Type": "application/json" }
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let json = await request.json();
|
let blob = await request.blob();
|
||||||
const request2 = await fetch(this.indexUrl + 'app-index.json', {
|
const request2 = await fetch(this.indexUrl + 'app-index.json', {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: { "Content-Type": "application/json" }
|
headers: { "Content-Type": "application/json" }
|
||||||
|
|||||||
+13
-9
@@ -457,24 +457,28 @@ class ADB {
|
|||||||
|
|
||||||
if (!this.client) return ecb('Not connected.');
|
if (!this.client) return ecb('Not connected.');
|
||||||
const device = this.client.getDevice(serial);
|
const device = this.client.getDevice(serial);
|
||||||
|
// TODO: See if we can pipe this thru a stream to get progress
|
||||||
device
|
device
|
||||||
.push(fs.createReadStream(path), savePath)
|
.push(fs.createReadStream(path), savePath)
|
||||||
.then(transfer => {
|
.then(transfer => {
|
||||||
let _stats, autoCancel;
|
let _stats = {bytesTransferred: 0}, counter=0;
|
||||||
|
let lastNumber = 0;
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
scb(_stats);
|
// We are cheating here, frequently the progress event will just stop firing but still will be transferring
|
||||||
|
// We are faking it at a slower pace so that the user still sees something is happening
|
||||||
|
if (lastNumber === _stats.bytesTransferred) {
|
||||||
|
counter += 1024;
|
||||||
|
scb({bytesTransferred: _stats.bytesTransferred + counter * 10240})
|
||||||
|
} else {
|
||||||
|
counter = 0;
|
||||||
|
scb(_stats);
|
||||||
|
lastNumber = _stats.bytesTransferred;
|
||||||
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
transfer.on('progress', stats => {
|
transfer.on('progress', stats => {
|
||||||
// clearTimeout(autoCancel);
|
|
||||||
console.log("Progress", stats, Date.now());
|
|
||||||
_stats = stats;
|
_stats = stats;
|
||||||
/* autoCancel = setTimeout(() => {
|
|
||||||
clearInterval(interval);
|
|
||||||
cb();
|
|
||||||
}, 90000); */
|
|
||||||
});
|
});
|
||||||
transfer.on('end', () => {
|
transfer.on('end', () => {
|
||||||
// clearTimeout(autoCancel);
|
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user