update firebase
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Document, HeadingLevel, Packer, Paragraph} from 'docx';
|
||||
import {Document, HeadingLevel, ISectionOptions, Packer, Paragraph} from 'docx';
|
||||
import {ShowService} from './show.service';
|
||||
import {ShowTypePipe} from '../../../widget-modules/pipes/show-type-translater/show-type.pipe';
|
||||
import {first} from 'rxjs/operators';
|
||||
@@ -48,11 +48,18 @@ export class DocxService {
|
||||
...this.renderSongs(songs, options, config),
|
||||
];
|
||||
|
||||
const document = this.prepareNewDocument(type, user.name, options);
|
||||
document.addSection({
|
||||
properties: {top: 400, bottom: 400, left: 400, right: 400},
|
||||
children: paragraphs,
|
||||
});
|
||||
const sections: ISectionOptions[] = [
|
||||
{
|
||||
properties: {
|
||||
page: {
|
||||
margin: {top: 400, bottom: 400, left: 400, right: 400},
|
||||
},
|
||||
},
|
||||
children: paragraphs,
|
||||
}
|
||||
]
|
||||
const document = this.prepareNewDocument(type, user.name, options, sections);
|
||||
|
||||
|
||||
const blob = await Packer.toBlob(document);
|
||||
|
||||
@@ -60,11 +67,12 @@ export class DocxService {
|
||||
this.saveAs(blob, `${title}.docx`);
|
||||
}
|
||||
|
||||
private prepareNewDocument(type: string, name: string, options: DownloadOptions): Document {
|
||||
private prepareNewDocument(type: string, name: string, options: DownloadOptions, sections: ISectionOptions[]): Document {
|
||||
return new Document({
|
||||
creator: name,
|
||||
title: type,
|
||||
description: '... mit Beschreibung',
|
||||
sections: sections,
|
||||
styles: {
|
||||
paragraphStyles: [
|
||||
{
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {File} from './file';
|
||||
import {Observable} from 'rxjs';
|
||||
import {map} from 'rxjs/operators';
|
||||
import {FileServer} from './fileServer';
|
||||
import {DbService} from '../../../services/db.service';
|
||||
|
||||
@@ -27,12 +26,8 @@ export class FileDataService {
|
||||
|
||||
public read$(songId: string): Observable<File[]> {
|
||||
const songRef = this.db.doc('songs/' + songId);
|
||||
return songRef.collection<File>('files').snapshotChanges().pipe(map(actions => {
|
||||
return actions.map(a => ({
|
||||
...a.payload.doc.data(),
|
||||
id: a.payload.doc.id
|
||||
}));
|
||||
}));
|
||||
return songRef.collection<File>('files').valueChanges({idField: 'id'});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {AngularFirestore, AngularFirestoreCollection, AngularFirestoreDocument} from '@angular/fire/firestore';
|
||||
import {Observable} from 'rxjs';
|
||||
import {map} from 'rxjs/operators';
|
||||
|
||||
type CollectionPredicate<T> = string | AngularFirestoreCollection<T>;
|
||||
type DocumentPredicate<T> = string | AngularFirestoreDocument<T>;
|
||||
@@ -23,22 +22,11 @@ export class DbService {
|
||||
}
|
||||
|
||||
public doc$<T>(ref: DocumentPredicate<T>): Observable<T> {
|
||||
return this.doc(ref).snapshotChanges().pipe(
|
||||
map(doc => {
|
||||
const data = doc.payload.data();
|
||||
const id = doc.payload.id;
|
||||
return {...data, id} as T;
|
||||
})
|
||||
);
|
||||
return this.doc(ref).valueChanges({idField: 'id'});
|
||||
|
||||
}
|
||||
|
||||
public col$<T>(ref: CollectionPredicate<T>, queryFn?): Observable<T[]> {
|
||||
return this.col(ref, queryFn).snapshotChanges().pipe(
|
||||
map(doc => doc.map(_ => {
|
||||
const data = _.payload.doc.data();
|
||||
const id = _.payload.doc.id;
|
||||
return {...data, id} as T;
|
||||
}))
|
||||
);
|
||||
return this.col(ref, queryFn).valueChanges({idField: 'id'});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ export class UserService {
|
||||
}
|
||||
|
||||
public async login(user: string, password: string): Promise<any> {
|
||||
const aUser = await this.afAuth.auth.signInWithEmailAndPassword(user, password);
|
||||
const aUser = await this.afAuth.signInWithEmailAndPassword(user, password);
|
||||
const dUser = await this.readUser(aUser.user.uid);
|
||||
this._user$.next(dUser);
|
||||
this._userId$.next(aUser.user.uid);
|
||||
@@ -55,7 +55,7 @@ export class UserService {
|
||||
public list$ = (): Observable<User[]> => this.db.col$('users');
|
||||
|
||||
public async logout(): Promise<any> {
|
||||
await this.afAuth.auth.signOut();
|
||||
await this.afAuth.signOut();
|
||||
this._user$.next(null);
|
||||
this._userId$.next(null);
|
||||
}
|
||||
@@ -66,11 +66,11 @@ export class UserService {
|
||||
|
||||
public async changePassword(user: string): Promise<any> {
|
||||
const url = environment.url;
|
||||
await this.afAuth.auth.sendPasswordResetEmail(user, {url});
|
||||
await this.afAuth.sendPasswordResetEmail(user, {url});
|
||||
}
|
||||
|
||||
public async createNewUser(user: string, name: string, password: string): Promise<any> {
|
||||
const aUser = await this.afAuth.auth.createUserWithEmailAndPassword(user, password);
|
||||
const aUser = await this.afAuth.createUserWithEmailAndPassword(user, password);
|
||||
const userId = aUser.user.uid;
|
||||
await this.db.doc('users/' + userId).set({name, chordMode: 'onlyFirst'});
|
||||
const dUser = await this.readUser(aUser.user.uid);
|
||||
|
||||
Reference in New Issue
Block a user