diff --git a/public/index.html b/public/index.html deleted file mode 100644 index 2c11f22..0000000 --- a/public/index.html +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - fh & sons - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/app/app.module.ts b/src/app/app.module.ts index a57c11c..433affe 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,99 +1,101 @@ -import { BrowserModule } from '@angular/platform-browser'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; -import { RouterModule } from '@angular/router'; -import { AngularFireModule } from 'angularfire2'; -import { AngularFirestoreModule, AngularFirestore } from 'angularfire2/firestore'; -import { NgModule } from '@angular/core'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { AppComponent } from './app.component'; -import { environment } from '../environments/environment'; -import { ConvertFromGPipe, ConvertToGPipe } from './formulaManager/units.pipe'; -import { ScalePipe } from './formulaManager/scale.pipe'; -import { AngularMaterialModule } from './material.module'; -import { HomeComponent } from './home/home.component'; -import { ServiceWorkerModule } from '@angular/service-worker'; -import { FormulaManagerComponent } from './formulaManager/formulaManager.component'; -import { NgxElectronModule } from 'ngx-electron'; -import { AboutComponent } from './about/about.component'; -import { CategoriesComponent } from './store/categories.component'; -import { AngularFireStorageModule } from 'angularfire2/storage'; -import { LoginComponent } from './login/login.component'; -import { AngularFireAuthModule } from 'angularfire2/auth'; -import { NewCategoryComponent } from './store/newCategory/newCategory.component'; -import { NewProductComponent } from './store/newProduct/newProduct.component'; -import { DeleteComponent } from './delete/delete.component'; -import { ProductsComponent } from './store/products/products.component'; -import { CartComponent } from './store/cart/cart.component'; -import { ViewComponents } from './formulaManager/viewComponents/viewComponents.component'; -import { NewComponentComponent } from './formulaManager/newComponent/newComponent.component'; -import { NewFormulaComponent } from './formulaManager/newFormula/newFormula.component'; -import { AppStore } from './app.store'; -import { SlideshowModule } from 'ng-simple-slideshow'; +import {BrowserModule} from '@angular/platform-browser'; +import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; +import {RouterModule} from '@angular/router'; +import {AngularFireModule} from 'angularfire2'; +import {AngularFirestoreModule, AngularFirestore} from 'angularfire2/firestore'; +import {NgModule} from '@angular/core'; +import {FormsModule, ReactiveFormsModule} from '@angular/forms'; +import {AppComponent} from './app.component'; +import {environment} from '../environments/environment'; +import {ConvertFromGPipe, ConvertToGPipe} from './formulaManager/units.pipe'; +import {ScalePipe} from './formulaManager/scale.pipe'; +import {AngularMaterialModule} from './material.module'; +import {HomeComponent} from './home/home.component'; +import {ServiceWorkerModule} from '@angular/service-worker'; +import {FormulaManagerComponent} from './formulaManager/formulaManager.component'; +import {NgxElectronModule} from 'ngx-electron'; +import {AboutComponent} from './about/about.component'; +import {CategoriesComponent} from './store/categories.component'; +import {AngularFireStorageModule} from 'angularfire2/storage'; +import {LoginComponent} from './login/login.component'; +import {AngularFireAuthModule} from 'angularfire2/auth'; +import {NewCategoryComponent} from './store/newCategory/newCategory.component'; +import {NewProductComponent} from './store/newProduct/newProduct.component'; +import {DeleteComponent} from './delete/delete.component'; +import {ProductsComponent} from './store/products/products.component'; +import {CartComponent} from './store/cart/cart.component'; +import {ViewComponents} from './formulaManager/viewComponents/viewComponents.component'; +import {NewComponentComponent} from './formulaManager/newComponent/newComponent.component'; +import {NewFormulaComponent} from './formulaManager/newFormula/newFormula.component'; +import {AppStore} from './app.store'; +import {SlideshowModule} from 'ng-simple-slideshow'; import {HttpClientModule} from '@angular/common/http'; import {ScrollingModule} from '@angular/cdk/scrolling'; import {MSDSComponent} from './msds/msds.component'; +import {SizePipe} from './size.pipe'; @NgModule({ - declarations: [ - AboutComponent, - AppComponent, - CategoriesComponent, - CartComponent, - ConvertFromGPipe, - ConvertToGPipe, - DeleteComponent, - FormulaManagerComponent, - HomeComponent, - LoginComponent, - MSDSComponent, - NewCategoryComponent, - NewComponentComponent, - NewFormulaComponent, - NewProductComponent, - ProductsComponent, - ScalePipe, - ViewComponents - ], - imports: [ - AngularMaterialModule, - AngularFireAuthModule, - AngularFireModule.initializeApp(environment.firebase), - AngularFirestoreModule, - AngularFireStorageModule, - BrowserAnimationsModule, - BrowserModule, - FormsModule, - HttpClientModule, - NgxElectronModule, - ReactiveFormsModule, - RouterModule.forRoot([ - { path: 'about', component: AboutComponent }, - { path: 'cart', component: CartComponent }, - { path: 'formulaManager', component: FormulaManagerComponent }, - { path: 'msds', component: MSDSComponent }, - { path: 'products/:product', component: ProductsComponent }, - { path: 'store/:category', component: CategoriesComponent }, - { path: 'store', component: CategoriesComponent }, - { path: '**', component: HomeComponent } - ]), - ScrollingModule, - ServiceWorkerModule.register('/ngsw-worker.js', { enabled: environment.production }), - SlideshowModule - ], - providers: [AppStore], - entryComponents: [ - DeleteComponent, - LoginComponent, - NewCategoryComponent, - NewComponentComponent, - NewFormulaComponent, - NewProductComponent, - ViewComponents - ], - bootstrap: [AppComponent] + declarations: [ + AboutComponent, + AppComponent, + CategoriesComponent, + CartComponent, + ConvertFromGPipe, + ConvertToGPipe, + DeleteComponent, + FormulaManagerComponent, + HomeComponent, + LoginComponent, + MSDSComponent, + NewCategoryComponent, + NewComponentComponent, + NewFormulaComponent, + NewProductComponent, + ProductsComponent, + ScalePipe, + SizePipe, + ViewComponents + ], + imports: [ + AngularMaterialModule, + AngularFireAuthModule, + AngularFireModule.initializeApp(environment.firebase), + AngularFirestoreModule, + AngularFireStorageModule, + BrowserAnimationsModule, + BrowserModule, + FormsModule, + HttpClientModule, + NgxElectronModule, + ReactiveFormsModule, + RouterModule.forRoot([ + {path: 'about', component: AboutComponent}, + {path: 'cart', component: CartComponent}, + {path: 'formulaManager', component: FormulaManagerComponent}, + {path: 'msds', component: MSDSComponent}, + {path: 'products/:product', component: ProductsComponent}, + {path: 'store/:category', component: CategoriesComponent}, + {path: 'store', component: CategoriesComponent}, + {path: '**', component: HomeComponent} + ]), + ScrollingModule, + ServiceWorkerModule.register('/ngsw-worker.js', {enabled: environment.production}), + SlideshowModule + ], + providers: [AppStore], + entryComponents: [ + DeleteComponent, + LoginComponent, + NewCategoryComponent, + NewComponentComponent, + NewFormulaComponent, + NewProductComponent, + ViewComponents + ], + bootstrap: [AppComponent] }) export class AppModule { - constructor(private db: AngularFirestore) { - this.db.firestore.enablePersistence(); - } + constructor(private db: AngularFirestore) { + this.db.firestore.enablePersistence(); + } } diff --git a/src/app/msds/msds.component.html b/src/app/msds/msds.component.html index d33a29f..b6abba8 100644 --- a/src/app/msds/msds.component.html +++ b/src/app/msds/msds.component.html @@ -1,4 +1,5 @@ -
+ +

MSDS

@@ -7,9 +8,25 @@
- - {{l.name}} - + + + + + + + + + + + + + + + +
File NameSize
{{l.name}}{{l.size / 1024 | size}} + + +
\ No newline at end of file diff --git a/src/app/msds/msds.component.ts b/src/app/msds/msds.component.ts index 22759c5..e85e602 100644 --- a/src/app/msds/msds.component.ts +++ b/src/app/msds/msds.component.ts @@ -9,6 +9,7 @@ import {AppStore} from '../app.store'; export class MSDSComponent implements OnInit { firestore; links = []; + loading = false; storage; constructor(public store: AppStore) { @@ -16,6 +17,18 @@ export class MSDSComponent implements OnInit { this.storage = firebase.storage(); } + async delete(link) { + this.loading = true; + let wait = [ + this.storage.ref(`MSDS/${link.name}`).delete(), + this.firestore.collection('msds').doc(link.name).delete() + ]; + + await Promise.all(wait); + this.links.splice(this.links.indexOf(link), 1); + this.loading = false; + } + async ngOnInit() { let docs = await this.firestore.collection('msds').get(); docs.forEach(snap => this.links = this.links.concat([snap.data()]).sort()); @@ -26,16 +39,17 @@ export class MSDSComponent implements OnInit { } upload(e) { + this.loading = true; this.storage.ref(`MSDS/${e.files[0].name}`).put(e.files[0]).then(async e => { let data = { name: e.metadata.name, + size: e.metadata.size, src: await this.storage.ref(e.metadata.fullPath).getDownloadURL() }; - console.log(data); - - this.links.concat([data]).sort(); - this.firestore.collection('msds').doc(e.metadata.name).set(data); + await this.firestore.collection('msds').doc(e.metadata.name).set(data); + this.links = this.links.concat([data]).sort(); + this.loading = false; }); } } diff --git a/src/app/size.pipe.ts b/src/app/size.pipe.ts new file mode 100644 index 0000000..7015ec5 --- /dev/null +++ b/src/app/size.pipe.ts @@ -0,0 +1,13 @@ +import {Pipe, PipeTransform} from '@angular/core'; + +@Pipe({ + name: 'size' +}) +export class SizePipe implements PipeTransform { + + constructor() { } + + transform(val, unit) { + return `${Math.round(val)} KB`; + } +} \ No newline at end of file diff --git a/src/assets/Chromatex_MSDS.pdf b/src/assets/Chromatex_MSDS.pdf deleted file mode 100644 index 5d9d88a..0000000 Binary files a/src/assets/Chromatex_MSDS.pdf and /dev/null differ