-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added library section and ability to upload and view files
- Loading branch information
Showing
20 changed files
with
3,141 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,44 @@ | ||
<md-sidenav-container> | ||
<md-toolbar> | ||
Toolbar | ||
</md-toolbar> | ||
<div class="main-content"> | ||
<md-toolbar> | ||
<toolbar></toolbar> | ||
</md-toolbar> | ||
<!--<button (click)="toggleHeading()">Toggle Heading</button>--> | ||
<!--<h1 *ngIf="showHeading">Hello Angular</h1>--> | ||
|
||
<!--<button (click)="toggleHeading()">Toggle Heading</button>--> | ||
<!--<h1 *ngIf="showHeading">Hello Angular</h1>--> | ||
<!--<h3>List of Heroes</h3>--> | ||
<!--<div *ngFor="let hero of heroes">{{hero}}</div>--> | ||
|
||
<!--<h3>List of Heroes</h3>--> | ||
<!--<div *ngFor="let hero of heroes">{{hero}}</div>--> | ||
|
||
|
||
<!--<div>--> | ||
<!--<div>--> | ||
<!--<button md-raised-button color="primary">Primary Button</button>--> | ||
<!--<button md-raised-button color="accent">Accent Button</button>--> | ||
<!--</div>--> | ||
<!--</div>--> | ||
|
||
<!--<div class="deck1">--> | ||
<!--<div class="deck1">--> | ||
<!--<button md-raised-button color="primary">Primary Button</button>--> | ||
<!--<button md-raised-button color="accent">Accent Button</button>--> | ||
<!--</div>--> | ||
<!--</div>--> | ||
|
||
<!--<div class="deck2">--> | ||
<!--<div class="deck2">--> | ||
<!--<button md-raised-button color="primary">Primary Button</button>--> | ||
<!--<button md-raised-button color="accent">Accent Button</button>--> | ||
<!--</div>--> | ||
|
||
<!--<md-slider min="-1" max="1" step="0.015625" value="0"></md-slider>--> | ||
|
||
<md-grid-list cols="7" gutterSize="3" rowHeight="300"> | ||
<md-grid-tile colspan="2" class="deck1" style="background-color: red"> | ||
a | ||
</md-grid-tile> | ||
<md-grid-tile colspan="3" style="background-color: blue"> | ||
b | ||
</md-grid-tile> | ||
<md-grid-tile colspan="2" class="deck2" style="background-color: green"> | ||
c | ||
</md-grid-tile> | ||
</md-grid-list> | ||
</md-sidenav-container> | ||
<!--</div>--> | ||
|
||
<!--<md-slider min="-1" max="1" step="0.015625" value="0"></md-slider>--> | ||
<div class="deck-section"> | ||
<div class="deck1 deck" style="background-color: red;"> | ||
a | ||
</div> | ||
<div class="center-controls" style="background-color: blue;"> | ||
b | ||
</div> | ||
<div class="deck2 deck" style="background-color: green;"> | ||
c | ||
</div> | ||
</div> | ||
<div class="library-section"> | ||
<library></library> | ||
</div> | ||
</div> | ||
</md-sidenav-container> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
.main-content { | ||
padding: 0 3px; | ||
display: flex; | ||
flex-direction: column; | ||
height: 100%; | ||
} | ||
|
||
.row { | ||
margin-bottom: 3px; | ||
} | ||
|
||
.deck-section { | ||
height: 450px; | ||
display: flex; | ||
} | ||
|
||
.deck-section-item { | ||
|
||
} | ||
|
||
.deck { | ||
width: 28.6% | ||
} | ||
|
||
.center-controls { | ||
width: 42.8%; | ||
} | ||
|
||
.library-section { | ||
flex-grow: 1; | ||
display: flex; | ||
} | ||
|
||
library { | ||
display: flex; | ||
flex-grow: 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
import {NgModule} from '@angular/core'; | ||
import {BrowserModule} from '@angular/platform-browser'; | ||
import { MaterialModule } from '@angular/material'; | ||
import {AppComponent} from './app.component'; | ||
import {NgModule} from "@angular/core"; | ||
import {BrowserModule} from "@angular/platform-browser"; | ||
import {MaterialModule} from "@angular/material"; | ||
import {AppComponent} from "./app.component"; | ||
import {LibraryComponent} from "./library/library.component"; | ||
import {FileDropDirective} from "./library/fileDrop.directive"; | ||
import {ToolbarComponent} from "./toolbar/toolbar.component"; | ||
import {AudioUtil} from "./services/audioUtil"; | ||
import {Db} from "./services/db"; | ||
import {SpinnerComponent} from "./spinner/spinner.component"; | ||
|
||
@NgModule({ | ||
imports: [BrowserModule, MaterialModule.forRoot()], | ||
declarations: [AppComponent], | ||
bootstrap: [AppComponent] | ||
declarations: [AppComponent, LibraryComponent, ToolbarComponent, FileDropDirective, SpinnerComponent], | ||
bootstrap: [AppComponent], | ||
providers: [AudioUtil, Db] | ||
}) | ||
|
||
export class AppModule { | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
interface iFileAPI { | ||
readAsDataURL(file: File, cb: Function): void; | ||
readAsBinaryString(file: File, cb: Function): void; | ||
readAsArrayBuffer(file: File, cb: Function): void; | ||
readAsText(file: File, cb: Function): void; | ||
} | ||
|
||
declare let FileAPI: iFileAPI; | ||
|
||
import { | ||
Directive, | ||
EventEmitter, | ||
ElementRef, | ||
HostListener, | ||
Input, | ||
Output, | ||
} from '@angular/core'; | ||
|
||
export interface Options { | ||
readAs?: string; | ||
} | ||
|
||
@Directive({ selector: '[fileDrop]' }) | ||
export class FileDropDirective { | ||
@Output() public fileOver: EventEmitter<boolean> = new EventEmitter<boolean>(); | ||
@Output() public onFileDrop: EventEmitter<File> = new EventEmitter<File>(); | ||
@Input() public options: Options; | ||
|
||
private element: ElementRef; | ||
|
||
public constructor( | ||
element: ElementRef | ||
) { | ||
this.element = element; | ||
} | ||
|
||
@HostListener('dragover', [ | ||
'$event', | ||
]) | ||
public onDragOver(event: any): void { | ||
const transfer = this.getDataTransfer(event); | ||
|
||
if (!this.haveFiles(transfer.types)) { | ||
return; | ||
} | ||
|
||
transfer.dropEffect = 'copy'; | ||
this.preventAndStop(event); | ||
this.emitFileOver(true); | ||
} | ||
|
||
@HostListener('dragleave', [ | ||
'$event', | ||
]) | ||
public onDragLeave(event: any): void { | ||
if (event.currentTarget === (this as any).element[0]) { | ||
return; | ||
} | ||
|
||
this.preventAndStop(event); | ||
this.emitFileOver(false); | ||
} | ||
|
||
@HostListener('drop', [ | ||
'$event', | ||
]) | ||
public onDrop(event: any): void { | ||
const transfer = this.getDataTransfer(event); | ||
|
||
if (!transfer) { | ||
return; | ||
} | ||
|
||
this.preventAndStop(event); | ||
this.emitFileOver(false); | ||
this.readFile(transfer.files[0]); | ||
} | ||
|
||
private readFile(file: File): void { | ||
const strategy = this.pickStrategy(); | ||
|
||
if (!strategy) { | ||
this.emitFileDrop(file); | ||
} else { | ||
// XXX Waiting for angular/zone.js#358 | ||
const method = `readAs${strategy}`; | ||
|
||
let reader = new FileReader(); | ||
reader[method](file, (event) => { | ||
if (event.type === 'load') { | ||
this.emitFileDrop(event.result); | ||
} else if (event.type === 'error') { | ||
throw new Error(`Couldn't read file '${file.name}'`); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
private emitFileOver(isOver: boolean): void { | ||
this.fileOver.emit(isOver); | ||
} | ||
|
||
private emitFileDrop(file: any): void { | ||
this.onFileDrop.emit(file); | ||
} | ||
|
||
private pickStrategy(): string | void { | ||
if (!this.options) { | ||
return; | ||
} | ||
|
||
if (this.hasStrategy(this.options.readAs)) { | ||
return this.options.readAs; | ||
} | ||
} | ||
|
||
private hasStrategy(type: string): boolean { | ||
return [ | ||
'DataURL', | ||
'BinaryString', | ||
'ArrayBuffer', | ||
'Text', | ||
].indexOf(type) !== -1; | ||
} | ||
|
||
private getDataTransfer(event: any | any): DataTransfer { | ||
return event.dataTransfer ? event.dataTransfer : event.originalEvent.dataTransfer; | ||
} | ||
|
||
private preventAndStop(event: any): void { | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
} | ||
|
||
private haveFiles(types: any): boolean { | ||
if (!types) { | ||
return false; | ||
} | ||
|
||
if (types.indexOf) { | ||
return types.indexOf('Files') !== -1; | ||
} | ||
|
||
if (types.contains) { | ||
return types.contains('Files'); | ||
} | ||
|
||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<div id="library"> | ||
<div fileDrop | ||
[ngClass]="{'file-is-over-drop': fileIsOverDrop && !uploadingFile}" class="file-drop-section" | ||
(fileOver)="onFileOverDrop($event)" | ||
(onFileDrop)="uploadFile($event)"> | ||
drop files here | ||
<spinner *ngIf="uploadingFile"></spinner> | ||
</div> | ||
<div class="file-list"> | ||
<div *ngFor="let songDetails of allSongDetails | async"> | ||
{{songDetails.title}} | ||
<img [src]="'data:' + songDetails.picFormat + ';base64,' + songDetails.base64Pic" alt="Album Cover" height="64px"> | ||
</div> | ||
</div> | ||
</div> |
Oops, something went wrong.