Update to Angular 7
|
|
@ -1,4 +1,4 @@
|
|||
# Editor configuration, see http://editorconfig.org
|
||||
# Editor configuration, see https://editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
|
|
|
|||
|
|
@ -8,6 +8,10 @@
|
|||
# dependencies
|
||||
/node_modules
|
||||
|
||||
# profiling files
|
||||
chrome-profiler-events.json
|
||||
speed-measure-plugin.json
|
||||
|
||||
# IDEs and editors
|
||||
/.idea
|
||||
.project
|
||||
|
|
@ -23,6 +27,7 @@
|
|||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
.history/*
|
||||
|
||||
# misc
|
||||
/.sass-cache
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Client
|
||||
# Ofbclient
|
||||
|
||||
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 6.0.1.
|
||||
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.2.2.
|
||||
|
||||
## Development server
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
"version": 1,
|
||||
"newProjectRoot": "projects",
|
||||
"projects": {
|
||||
"Client": {
|
||||
"ofbclient": {
|
||||
"root": "",
|
||||
"sourceRoot": "src",
|
||||
"projectType": "application",
|
||||
|
|
@ -19,8 +19,9 @@
|
|||
"polyfills": "src/polyfills.ts",
|
||||
"tsConfig": "src/tsconfig.app.json",
|
||||
"assets": [
|
||||
"src/web-app-files",
|
||||
"src/assets"
|
||||
"src/favicon.ico",
|
||||
"src/assets",
|
||||
"src/web-app-files"
|
||||
],
|
||||
"styles": [
|
||||
"src/styles.css"
|
||||
|
|
@ -43,25 +44,32 @@
|
|||
"aot": true,
|
||||
"extractLicenses": true,
|
||||
"vendorChunk": false,
|
||||
"buildOptimizer": true
|
||||
"buildOptimizer": true,
|
||||
"budgets": [
|
||||
{
|
||||
"type": "initial",
|
||||
"maximumWarning": "2mb",
|
||||
"maximumError": "5mb"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"serve": {
|
||||
"builder": "@angular-devkit/build-angular:dev-server",
|
||||
"options": {
|
||||
"browserTarget": "Client:build"
|
||||
"browserTarget": "ofbclient:build"
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"browserTarget": "Client:build:production"
|
||||
"browserTarget": "ofbclient:build:production"
|
||||
}
|
||||
}
|
||||
},
|
||||
"extract-i18n": {
|
||||
"builder": "@angular-devkit/build-angular:extract-i18n",
|
||||
"options": {
|
||||
"browserTarget": "Client:build"
|
||||
"browserTarget": "ofbclient:build"
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
|
|
@ -95,15 +103,21 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"Client-e2e": {
|
||||
"ofbclient-e2e": {
|
||||
"root": "e2e/",
|
||||
"projectType": "application",
|
||||
"prefix": "",
|
||||
"architect": {
|
||||
"e2e": {
|
||||
"builder": "@angular-devkit/build-angular:protractor",
|
||||
"options": {
|
||||
"protractorConfig": "e2e/protractor.conf.js",
|
||||
"devServerTarget": "Client:serve"
|
||||
"devServerTarget": "ofbclient:serve"
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"devServerTarget": "ofbclient:serve:production"
|
||||
}
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
|
|
@ -118,5 +132,5 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"defaultProject": "Client"
|
||||
"defaultProject": "ofbclient"
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import { AppPage } from './app.po';
|
||||
import { browser, logging } from 'protractor';
|
||||
|
||||
describe('workspace-project App', () => {
|
||||
let page: AppPage;
|
||||
|
|
@ -9,6 +10,14 @@ describe('workspace-project App', () => {
|
|||
|
||||
it('should display welcome message', () => {
|
||||
page.navigateTo();
|
||||
expect(page.getParagraphText()).toEqual('Welcome to app!');
|
||||
expect(page.getTitleText()).toEqual('Welcome to ofbclient!');
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
// Assert that there are no errors emitted from the browser
|
||||
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
|
||||
expect(logs).not.toContain(jasmine.objectContaining({
|
||||
level: logging.Level.SEVERE,
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ export class AppPage {
|
|||
return browser.get('/');
|
||||
}
|
||||
|
||||
getParagraphText() {
|
||||
getTitleText() {
|
||||
return element(by.css('app-root h1')).getText();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "client",
|
||||
"name": "ofbclient",
|
||||
"version": "0.0.0",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
|
|
@ -11,41 +11,41 @@
|
|||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "^6.0.0",
|
||||
"@angular/cdk": "^6.0.2",
|
||||
"@angular/common": "^6.0.0",
|
||||
"@angular/compiler": "^6.0.0",
|
||||
"@angular/core": "^6.0.0",
|
||||
"@angular/forms": "^6.0.0",
|
||||
"@angular/http": "^6.0.0",
|
||||
"@angular/material": "^6.0.2",
|
||||
"@angular/platform-browser": "^6.0.0",
|
||||
"@angular/platform-browser-dynamic": "^6.0.0",
|
||||
"@angular/router": "^6.0.0",
|
||||
"@angular/animations": "^7.2.1",
|
||||
"@angular/cdk": "^7.2.1",
|
||||
"@angular/common": "~7.2.0",
|
||||
"@angular/compiler": "~7.2.0",
|
||||
"@angular/core": "~7.2.0",
|
||||
"@angular/forms": "~7.2.0",
|
||||
"@angular/material": "^7.2.1",
|
||||
"@angular/platform-browser": "~7.2.0",
|
||||
"@angular/platform-browser-dynamic": "~7.2.0",
|
||||
"@angular/router": "~7.2.0",
|
||||
"core-js": "^2.5.4",
|
||||
"hammerjs": "^2.0.8",
|
||||
"rxjs": "^6.0.0",
|
||||
"zone.js": "^0.8.26"
|
||||
"rxjs": "~6.3.3",
|
||||
"tslib": "^1.9.0",
|
||||
"zone.js": "~0.8.26"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular/compiler-cli": "^6.0.0",
|
||||
"@angular-devkit/build-angular": "~0.6.1",
|
||||
"typescript": "~2.7.2",
|
||||
"@angular/cli": "~6.0.1",
|
||||
"@angular/language-service": "^6.0.0",
|
||||
"@types/jasmine": "~2.8.6",
|
||||
"@types/jasminewd2": "~2.0.3",
|
||||
"@angular-devkit/build-angular": "~0.12.0",
|
||||
"@angular/cli": "~7.2.2",
|
||||
"@angular/compiler-cli": "~7.2.0",
|
||||
"@angular/language-service": "~7.2.0",
|
||||
"@types/node": "~8.9.4",
|
||||
"codelyzer": "~4.2.1",
|
||||
"@types/jasmine": "~2.8.8",
|
||||
"@types/jasminewd2": "~2.0.3",
|
||||
"codelyzer": "~4.5.0",
|
||||
"jasmine-core": "~2.99.1",
|
||||
"jasmine-spec-reporter": "~4.2.1",
|
||||
"karma": "~1.7.1",
|
||||
"karma": "~3.1.1",
|
||||
"karma-chrome-launcher": "~2.2.0",
|
||||
"karma-coverage-istanbul-reporter": "~1.4.2",
|
||||
"karma-jasmine": "~1.1.1",
|
||||
"karma-coverage-istanbul-reporter": "~2.0.1",
|
||||
"karma-jasmine": "~1.1.2",
|
||||
"karma-jasmine-html-reporter": "^0.2.2",
|
||||
"protractor": "~5.3.0",
|
||||
"ts-node": "~5.0.1",
|
||||
"tslint": "~5.9.1"
|
||||
"protractor": "~5.4.0",
|
||||
"ts-node": "~7.0.0",
|
||||
"tslint": "~5.11.0",
|
||||
"typescript": "~3.2.2"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,66 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule } from '@angular/router';
|
||||
|
||||
//Components
|
||||
import { HomeComponent } from './components/home/home.component';
|
||||
import { WhoWeAreComponent } from './components/whoweare/whoweare.component';
|
||||
import { ServicesComponent } from './components/services/services.component';
|
||||
import { SermonsComponent } from './components/sermons/sermons.component';
|
||||
import { LocationComponent } from './components/location/location.component';
|
||||
import { EventsPageComponent } from './components/events-page/events-page.component';
|
||||
import { ContactPageComponent } from './components/contact-page/contact-page.component';
|
||||
import { SalvationPageComponent } from './components/salvation-page/salvation-page.component';
|
||||
|
||||
const routes =
|
||||
[
|
||||
{
|
||||
path: '',
|
||||
redirectTo: '/home',
|
||||
pathMatch: 'full'
|
||||
},{
|
||||
path: 'home',
|
||||
component: HomeComponent
|
||||
},
|
||||
{
|
||||
path: 'whoweare',
|
||||
component: WhoWeAreComponent
|
||||
},
|
||||
{
|
||||
path: 'services',
|
||||
component: ServicesComponent
|
||||
},
|
||||
{
|
||||
path: 'contact',
|
||||
component: ContactPageComponent
|
||||
},
|
||||
{
|
||||
path: 'sermons',
|
||||
component: SermonsComponent
|
||||
},
|
||||
{
|
||||
path: 'sermons/:id',
|
||||
component: SermonsComponent
|
||||
},
|
||||
{
|
||||
path: 'location',
|
||||
component: LocationComponent
|
||||
},
|
||||
{
|
||||
path: 'events',
|
||||
component: EventsPageComponent
|
||||
},
|
||||
{
|
||||
path: 'events/:id',
|
||||
component: EventsPageComponent
|
||||
},
|
||||
{
|
||||
path: 'salvation',
|
||||
component: SalvationPageComponent
|
||||
}
|
||||
]
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forRoot(routes)],
|
||||
exports: [RouterModule]
|
||||
})
|
||||
export class AppRoutingModule { }
|
||||
|
|
@ -4,18 +4,15 @@ import { WindowRefService } from './services/window-ref.service';
|
|||
import { EmailService } from './services/email.service';
|
||||
import { SermonService } from './services/sermon.service';
|
||||
import { LoginService } from './services/login.service';
|
||||
import { ProgressService } from './services/xhr-progress.service';
|
||||
import { ProgressXhr } from './extensions/xhr-progress.extension';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { NgModule, Component } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { HttpModule, BrowserXhr } from '@angular/http';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { MatButtonModule,
|
||||
MatInputModule,
|
||||
MatSliderModule,
|
||||
MatSnackBarModule,
|
||||
MatDialogModule } from '@angular/material';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import 'hammerjs';
|
||||
|
||||
|
|
@ -58,54 +55,8 @@ import { DurationPipe } from './pipes/duration.pipe';
|
|||
import { SafeUrlPipe } from './pipes/safe-url.pipe';
|
||||
import { OfbDatePipe } from './pipes/ofb-date.pipe';
|
||||
|
||||
|
||||
const Routes =
|
||||
[
|
||||
{
|
||||
path: '',
|
||||
redirectTo: '/home',
|
||||
pathMatch: 'full'
|
||||
},{
|
||||
path: 'home',
|
||||
component: HomeComponent
|
||||
},
|
||||
{
|
||||
path: 'whoweare',
|
||||
component: WhoWeAreComponent
|
||||
},
|
||||
{
|
||||
path: 'services',
|
||||
component: ServicesComponent
|
||||
},
|
||||
{
|
||||
path: 'contact',
|
||||
component: ContactPageComponent
|
||||
},
|
||||
{
|
||||
path: 'sermons',
|
||||
component: SermonsComponent
|
||||
},
|
||||
{
|
||||
path: 'sermons/:id',
|
||||
component: SermonsComponent
|
||||
},
|
||||
{
|
||||
path: 'location',
|
||||
component: LocationComponent
|
||||
},
|
||||
{
|
||||
path: 'events',
|
||||
component: EventsPageComponent
|
||||
},
|
||||
{
|
||||
path: 'events/:id',
|
||||
component: EventsPageComponent
|
||||
},
|
||||
{
|
||||
path: 'salvation',
|
||||
component: SalvationPageComponent
|
||||
}
|
||||
]
|
||||
// Routing
|
||||
import { AppRoutingModule } from './app-routing.module';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
|
|
@ -145,8 +96,9 @@ const Routes =
|
|||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
AppRoutingModule,
|
||||
FormsModule,
|
||||
HttpModule,
|
||||
HttpClientModule,
|
||||
BrowserAnimationsModule,
|
||||
//Angular Material Components
|
||||
MatButtonModule,
|
||||
|
|
@ -154,10 +106,8 @@ const Routes =
|
|||
MatSliderModule,
|
||||
MatSnackBarModule,
|
||||
MatDialogModule,
|
||||
RouterModule.forRoot(Routes)
|
||||
|
||||
],
|
||||
providers: [LoginService,GoogleAnalyticsService,SermonService,EventService,ProgressService,EmailService,WindowRefService,{provide:BrowserXhr,useClass:ProgressXhr}],
|
||||
providers: [LoginService,GoogleAnalyticsService,SermonService,EventService,EmailService,WindowRefService],
|
||||
entryComponents: [AddSermonPopupComponent,
|
||||
LoginPopupComponent,
|
||||
OkPopupComponent,
|
||||
|
|
@ -168,11 +118,4 @@ const Routes =
|
|||
AddEventPopupComponent],
|
||||
bootstrap: [AppComponent]
|
||||
})
|
||||
|
||||
export class AppModule {
|
||||
public routes = Routes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
export class AppModule { }
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
</a>
|
||||
<p><a href="tel:+1-406-494-5028" class="phone">(406) 494 - 5028</a></p>
|
||||
<p>Pastor Ron Derksen</p>
|
||||
<p>Assistant Pastor Derek Loewen</p>
|
||||
<p>Associate Pastor Derek Loewen</p>
|
||||
</div>
|
||||
<div id="footer-services-content" class="footer-panel">
|
||||
<p>Sunday School: 10AM</p>
|
||||
|
|
|
|||
|
|
@ -59,8 +59,8 @@ export class EventsPageComponent implements OnInit {
|
|||
this.events = [];
|
||||
}
|
||||
this.eventService.getEvents(1).subscribe(
|
||||
events => {
|
||||
this.addEvents(events);
|
||||
eventReponse => {
|
||||
this.addEvents(eventReponse.events);
|
||||
this.loading = false;
|
||||
},
|
||||
error => console.error(error)
|
||||
|
|
@ -71,13 +71,14 @@ export class EventsPageComponent implements OnInit {
|
|||
this.events = [];
|
||||
this.loading = true;
|
||||
this.eventService.getSingleEvent(id).subscribe(event => {
|
||||
this.events.push(event);
|
||||
this.events.push(event.event);
|
||||
this.loading = false;
|
||||
this.googleAnalyticsService.shareEventConversion(event.id,event.title);
|
||||
this.googleAnalyticsService.shareEventConversion(event.event.id,event.event.title);
|
||||
});
|
||||
}
|
||||
|
||||
addEvents(events: Event[]): void{
|
||||
console.log(events);
|
||||
for(let i = 0; i < events.length; i++){
|
||||
this.events.push(events[i]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ img.full {
|
|||
text-align: center;
|
||||
}
|
||||
img.full {
|
||||
width: 70%;
|
||||
width: 90%;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -9,10 +9,13 @@
|
|||
|
||||
<div class="row tint" *ngIf="showSpecial" >
|
||||
<div class="row-content">
|
||||
<div class="row-content-col-left">
|
||||
<a href="assets/images/champ_flyer.jpg" download="champ_flyer.jpg"><img class="full" ofbFadeInOnScroll src="assets/images/home-images/tiny/champ.jpg" height="300"></a>
|
||||
</div>
|
||||
<div class="row-content-col-right align-top center">
|
||||
<p ofbFadeInOnScroll class="row-content-header">Champ the Smiling Trick Horse</p>
|
||||
<p ofbFadeInOnScroll>
|
||||
Come join us for this special event happening September 5th and 6th at Old Fashion Baptist!.
|
||||
Come join us for this special event happening September 5th and 6th at Old Fashion Baptist!
|
||||
</p>
|
||||
<br>
|
||||
<p ofbFadeInOnScroll>
|
||||
|
|
@ -35,9 +38,6 @@
|
|||
<i ofbicon>phone</i> <a href="tel:+1-406-494-5028" class="align-top">406-494-5028</a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="row-content-col-left">
|
||||
<a href="assets/images/champ_flyer.jpg" download="champ_flyer.jpg"><img class="full" ofbFadeInOnScroll src="assets/images/home-images/tiny/champ.jpg" height="300"></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ export class AddEventPopupComponent implements OnInit {
|
|||
this.eventService.addEvent(e).subscribe(
|
||||
data=>{
|
||||
this.updateAddButton(true);
|
||||
this.MatDialogRef.close(data.sermon);
|
||||
this.MatDialogRef.close(data['event']);
|
||||
},
|
||||
error => {
|
||||
this.updateAddButton(true);
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
import { OkPopupComponent } from './../ok-popup/ok-popup.component';
|
||||
import { Observable, Subscription } from 'rxjs';
|
||||
import { ProgressService } from './../../../services/xhr-progress.service';
|
||||
import { LoginPopupComponent } from './../login-popup/login-popup.component';
|
||||
import { MatDialog, MatDialogRef, MatSnackBar } from '@angular/material';
|
||||
import { Sermon } from './../../../interfaces/sermon';
|
||||
import { SermonService } from './../../../services/sermon.service';
|
||||
import { LoginService } from './../../../services/login.service';
|
||||
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||
import { HttpEvent, HttpEventType } from '@angular/common/http';
|
||||
|
||||
@Component({
|
||||
selector: 'app-add-sermon-popup',
|
||||
templateUrl: './add-sermon-popup.component.html',
|
||||
styleUrls: ['./add-sermon-popup.component.css']
|
||||
})
|
||||
export class AddSermonPopupComponent implements OnInit, OnDestroy {
|
||||
export class AddSermonPopupComponent implements OnInit {
|
||||
public addSermonButtonText: string = "Add Sermon";
|
||||
public addSermonButtonDisabled: boolean = false;
|
||||
|
||||
|
|
@ -25,25 +25,16 @@ export class AddSermonPopupComponent implements OnInit, OnDestroy {
|
|||
|
||||
public errorMessages: string[] = [];
|
||||
|
||||
private _uploadTotal: number = 100;
|
||||
private _uploadProgress: number = 25;
|
||||
public uploadTotal: number = 100;
|
||||
public uploadProgress: number = 0;
|
||||
public monitorProgress: boolean;
|
||||
|
||||
private progressSubscription: Subscription;
|
||||
|
||||
constructor(private progressService: ProgressService, private MatDialog: MatDialog, private MatDialogRef: MatDialogRef<AddSermonPopupComponent>, private loginService: LoginService, private sermonService: SermonService) { }
|
||||
constructor(private MatDialog: MatDialog, private MatDialogRef: MatDialogRef<AddSermonPopupComponent>, private loginService: LoginService, private sermonService: SermonService) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.progressSubscription = this.progressService.uploadProgress.subscribe(evt => {
|
||||
this._uploadTotal = evt.total;
|
||||
this._uploadProgress = evt.loaded;
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(){
|
||||
this.progressSubscription.unsubscribe();
|
||||
}
|
||||
|
||||
onSubmit(){
|
||||
|
|
@ -106,30 +97,43 @@ export class AddSermonPopupComponent implements OnInit, OnDestroy {
|
|||
s.title = this.sermonTitle;
|
||||
s.author = this.sermonSpeaker;
|
||||
s.description = this.sermonDescription;
|
||||
s.sermonDate = this.sermonDate;
|
||||
s.date = this.sermonDate;
|
||||
|
||||
//Start monitoring Progress
|
||||
this.monitorProgress = true;
|
||||
let timer = setInterval(()=>{
|
||||
this.uploadTotal = this._uploadTotal;
|
||||
this.uploadProgress = this._uploadProgress;
|
||||
},500);
|
||||
|
||||
this.sermonService.addSermon(s,this.sermonFile).subscribe(
|
||||
data=>{
|
||||
this.updateAddButton(true);
|
||||
this.monitorProgress = false;
|
||||
clearInterval(timer);
|
||||
this.MatDialogRef.close(data.sermon);
|
||||
},
|
||||
data => {this.getEventMessage(data); },
|
||||
error => {
|
||||
alert(error);
|
||||
this.updateAddButton(true);
|
||||
this.monitorProgress = false;
|
||||
clearInterval(timer);
|
||||
let errorDialog = this.MatDialog.open(OkPopupComponent,{data:{title:'Upload Error',message:'There was an error uploading the sermon\n' + error}});
|
||||
});
|
||||
}
|
||||
|
||||
private getEventMessage(event: HttpEvent<any>) {
|
||||
switch (event.type) {
|
||||
case HttpEventType.Sent:
|
||||
return;
|
||||
|
||||
case HttpEventType.UploadProgress:
|
||||
this.uploadProgress = event.loaded;
|
||||
this.uploadTotal = event.total;
|
||||
return;
|
||||
|
||||
case HttpEventType.Response:
|
||||
this.updateAddButton(true);
|
||||
this.monitorProgress = false;
|
||||
this.MatDialogRef.close(event['body']['sermon']);
|
||||
return;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onFileChange(event){
|
||||
this.sermonFile = event.srcElement.files[0];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ export class LoginPopupComponent implements OnInit {
|
|||
this.loginButtonText = 'Please Wait...';
|
||||
this.loginButtonDisabled = true;
|
||||
this.loginService.login(this.username,this.password).subscribe(
|
||||
data => {
|
||||
(data:any) => {
|
||||
if (data.message === 'Logged In'){
|
||||
this.MatDialogRef.close(true);
|
||||
let s = this.snackbar.open("Logged In","OK");
|
||||
|
|
|
|||
|
|
@ -68,11 +68,11 @@ export class UpdateSermonPopupComponent implements OnInit {
|
|||
s.title = this.sermonTitle;
|
||||
s.author = this.sermonSpeaker;
|
||||
s.description = this.sermonDescription;
|
||||
s.sermonDate = this.sermonDate;
|
||||
s.date = this.sermonDate;
|
||||
|
||||
//Start monitoring Progress
|
||||
this.sermonService.updateSermon(s).subscribe(
|
||||
data=>{
|
||||
(data:any)=>{
|
||||
this.MatDialogRef.close(data.sermon);
|
||||
},
|
||||
error => {
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@
|
|||
<li *ngFor="let sermon of sermons; let i = index;">
|
||||
<sermon-small-component
|
||||
[title]="sermon.title"
|
||||
[date]="sermon.sermonDate"
|
||||
[date]="sermon.date"
|
||||
[delayFadeIn]="(i+1)*200"
|
||||
[url]="sermon.url"
|
||||
[url]="sermon.file"
|
||||
[id]="sermon.id"
|
||||
></sermon-small-component>
|
||||
</li>
|
||||
|
|
|
|||
|
|
@ -25,9 +25,10 @@ export class RecentSermonsComponent implements OnInit {
|
|||
getSermons(): void{
|
||||
this.sermons = [];
|
||||
this.loading = true;
|
||||
this.sermonService.getSermons(this.numberOfSermonsToShow).subscribe(sermons => {
|
||||
this.sermons = sermons;
|
||||
this.sermonService.getSermons(this.numberOfSermonsToShow).subscribe(response => {
|
||||
this.sermons = response.sermons;
|
||||
this.loading = false;
|
||||
console.log(response);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ export class SermonSmallComponent implements AfterContentInit {
|
|||
}
|
||||
|
||||
play(): void{
|
||||
|
||||
if (this.audioPlayer.getIsPlaying() == true && this.audioPlayer.getMetaData() != null && this.audioPlayer.getMetaData().id == this.id){
|
||||
this.audioPlayer.pause();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@
|
|||
<sermon-large-component
|
||||
[id]="sermon.id"
|
||||
[title]="sermon.title"
|
||||
[date]="sermon.sermonDate"
|
||||
[date]="sermon.date"
|
||||
[description]="sermon.description"
|
||||
[author]="sermon.author"
|
||||
[delayFadeIn]="(i-((((sermons.length*10)/10)-10) > 0 ? (((sermons.length*10)/10)-10) : 0))*200"
|
||||
[url]="sermon.url"
|
||||
[url]="sermon.file"
|
||||
[loggedIn]="loggedIn"
|
||||
></sermon-large-component>
|
||||
</li>
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@ import { MatSnackBar, MatDialog, MatDialogConfig } from '@angular/material';
|
|||
|
||||
import { AddSermonPopupComponent } from '../popups/add-sermon-popup/add-sermon-popup.component';
|
||||
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'sermons-component',
|
||||
templateUrl: './sermons.component.html',
|
||||
|
|
@ -78,8 +76,8 @@ export class SermonsComponent implements OnInit {
|
|||
this.sermons = [];
|
||||
|
||||
this.sermonService.getSermonById(id).subscribe(
|
||||
sermons => {
|
||||
this.sermons.push(sermons)
|
||||
response => {
|
||||
this.sermons.push(response.sermon)
|
||||
this.loading = false;
|
||||
},
|
||||
error => {
|
||||
|
|
@ -95,8 +93,8 @@ export class SermonsComponent implements OnInit {
|
|||
this.page = 1;
|
||||
}
|
||||
this.sermonService.searchSermons(this.searchTerm,this.page).subscribe(
|
||||
sermons => {
|
||||
this.addSermons(sermons);
|
||||
response => {
|
||||
this.addSermons(response.sermons);
|
||||
this.loading = false;
|
||||
},
|
||||
error => console.error(error) );
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ export class UpcomingEventsComponent implements OnInit {
|
|||
this.events = [];
|
||||
this.loading = true;
|
||||
this.eventService.getEvents(1).subscribe(events => {
|
||||
this.events = events.slice(0,this.numberOfEventsToShow);
|
||||
this.events = events.events.slice(0,this.numberOfEventsToShow);
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,18 @@
|
|||
export const EVENTS_ADD_URL = "/api2/events/a/";
|
||||
export const EVENT_BY_ID = "/api2/events/";
|
||||
export const EVENTS_BY_PAGE_URL = "/api2/events/page/";
|
||||
export const EVENTS_DELETE_BY_ID_URL = "/api2/events/a/";
|
||||
export const SERMONS_BY_ID = '/api2/sermons/';
|
||||
export const SERMONS_BY_PAGE_URL = '/api2/sermons/page/';
|
||||
export const SERMONS_BY_SEARCH_URL = '/api2/sermons/search';
|
||||
import { environment } from '../../environments/environment';
|
||||
|
||||
export const EVENTS_ADD_URL = environment.baseUrl + "/api2/events/a/";
|
||||
export const EVENT_BY_ID = environment.baseUrl + "/api2/events/";
|
||||
export const EVENTS_BY_PAGE_URL = environment.baseUrl + "/api2/events/page/";
|
||||
export const EVENTS_DELETE_BY_ID_URL = environment.baseUrl + "/api2/events/a/";
|
||||
export const SERMONS_BY_ID = environment.baseUrl + '/api2/sermons/';
|
||||
export const SERMONS_BY_PAGE_URL = environment.baseUrl + '/api2/sermons/page/';
|
||||
export const SERMONS_BY_SEARCH_URL = environment.baseUrl + '/api2/sermons/search';
|
||||
export const SERMON_MP3_BASE_URL = '//ofbbutte.com/static/media/';
|
||||
export const SERMON_ADD_URL = "/api2/sermons/a/";
|
||||
export const SERMON_DELETE_URL = "/api2/sermons/a/";
|
||||
export const SERMON_UPDATE_URL = "/api2/sermons/a/";
|
||||
export const SERMON_DOWNLOAD_URL = "/api2/sermons/download/";
|
||||
export const LOGIN_URL = '/api2/login';
|
||||
export const SERMON_ADD_URL = environment.baseUrl + "/api2/sermons/a/";
|
||||
export const SERMON_DELETE_URL = environment.baseUrl + "/api2/sermons/a/";
|
||||
export const SERMON_UPDATE_URL = environment.baseUrl + "/api2/sermons/a/";
|
||||
export const SERMON_DOWNLOAD_URL = environment.baseUrl + "/api2/sermons/download/";
|
||||
export const LOGIN_URL = environment.baseUrl + '/api2/login';
|
||||
export const LOGIN_VALIDATE_TOKEN = '';
|
||||
export const EMAIL_URL = "/api2/email";
|
||||
export const EMAIL_URL = environment.baseUrl + "/api2/email";
|
||||
export const RANDOM_VERSE_URL = "//www.kingjamesbibleonline.org/popular-bible-verses-widget.php";
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
import { ProgressService } from './../services/xhr-progress.service';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { BrowserXhr } from '@angular/http';
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class ProgressXhr extends BrowserXhr {
|
||||
|
||||
constructor(private service: ProgressService) { super(); }
|
||||
|
||||
build(): any {
|
||||
|
||||
let xhr = super.build();
|
||||
xhr.onprogress = (event) => {
|
||||
this.service.downloadProgress.next(event);
|
||||
};
|
||||
|
||||
xhr.upload.onprogress = (event) => {
|
||||
this.service.uploadProgress.next(event);
|
||||
};
|
||||
|
||||
return <any>(xhr);
|
||||
}
|
||||
}
|
||||
|
|
@ -5,3 +5,14 @@ export class Event{
|
|||
endDate: Date;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export class EventResponse {
|
||||
status: number;
|
||||
events: Event[];
|
||||
}
|
||||
|
||||
export class SingleEventResponse {
|
||||
status: number;
|
||||
event: Event;
|
||||
|
||||
}
|
||||
|
|
@ -1,9 +1,19 @@
|
|||
export class Sermon{
|
||||
id: number;
|
||||
title: string;
|
||||
sermonDate: Date;
|
||||
date: Date;
|
||||
uploadDate: Date;
|
||||
description: string;
|
||||
author: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
export class SingleSermonResponse {
|
||||
status: number;
|
||||
sermon: Sermon;
|
||||
}
|
||||
|
||||
export class MultipleSermonResponse {
|
||||
status: number;
|
||||
sermons: Sermon[];
|
||||
}
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { Sermon } from '../interfaces/sermon';
|
||||
import { AudioStates } from '../enum/audio-states';
|
||||
import { BehaviorSubject, Observable, Subject } from 'rxjs';
|
||||
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Subject } from 'rxjs';
|
||||
import { SERMON_MP3_BASE_URL } from '../constants/urls';
|
||||
|
||||
@Injectable()
|
||||
export class AudioPlayerService {
|
||||
|
|
@ -29,6 +31,7 @@ export class AudioPlayerService {
|
|||
}
|
||||
|
||||
play(src: string, metaData?: any): void{
|
||||
src = SERMON_MP3_BASE_URL + src;
|
||||
try{
|
||||
if (typeof src === 'undefined' || src == null) return;
|
||||
this.loading = true;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { Http, Response } from '@angular/http';
|
||||
import { HttpClient, HttpResponse } from '@angular/common/http';
|
||||
|
||||
import { Observable, throwError as observableThrowError, observable } from 'rxjs';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { RANDOM_VERSE_URL } from '../constants/urls';
|
||||
|
||||
@Injectable()
|
||||
export class BibleVerseService {
|
||||
constructor(private http: Http){}
|
||||
constructor(private httpClient: HttpClient){}
|
||||
|
||||
randomVerse(){
|
||||
//return this.http.get(RANDOM_VERSE_URL).map(this.gotData).catch(this.dataError);
|
||||
|
|
@ -16,19 +16,6 @@ export class BibleVerseService {
|
|||
gotData(res: Response){
|
||||
console.log(res);
|
||||
}
|
||||
|
||||
dataError(error: Response | any){
|
||||
let errMsg: string;
|
||||
if (error instanceof Response) {
|
||||
const body = error.json() || '';
|
||||
const err = body.error || JSON.stringify(body);
|
||||
errMsg = `${error.status} - ${error.statusText || ''} ${err}`;
|
||||
} else {
|
||||
errMsg = error.message ? error.message : error.toString();
|
||||
}
|
||||
console.error(errMsg);
|
||||
return observableThrowError(errMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import { throwError } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
import {throwError as observableThrowError, Observable } from 'rxjs';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
|
||||
import { Http, Response } from '@angular/http';
|
||||
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { EMAIL_URL } from '../constants/urls';
|
||||
|
||||
|
|
@ -10,7 +9,7 @@ import { EMAIL_URL } from '../constants/urls';
|
|||
@Injectable()
|
||||
export class EmailService {
|
||||
|
||||
constructor(private http: Http){
|
||||
constructor(private httpClient: HttpClient){
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -28,22 +27,24 @@ export class EmailService {
|
|||
hp: hp
|
||||
};
|
||||
|
||||
return this.http.post(EMAIL_URL,body,{withCredentials:true})
|
||||
.pipe(map(r => { return r.json(); })
|
||||
,catchError(this.dataError));
|
||||
return this.httpClient.post(EMAIL_URL, body, {withCredentials:true})
|
||||
.pipe(catchError(this.handleError))
|
||||
|
||||
}
|
||||
|
||||
dataError(error: Response | any){
|
||||
let errMsg: string;
|
||||
if (error instanceof Response) {
|
||||
const body = error.json() || '';
|
||||
const err = body.error || JSON.stringify(body);
|
||||
errMsg = `${error.status} - ${error.statusText || ''} ${err}`;
|
||||
private handleError(error: HttpErrorResponse) {
|
||||
if (error.error instanceof ErrorEvent) {
|
||||
// A client-side or network error occurred. Handle it accordingly.
|
||||
console.error('An error occurred:', error.error.message);
|
||||
} else {
|
||||
errMsg = error.message ? error.message : error.toString();
|
||||
}
|
||||
console.error(errMsg);
|
||||
return observableThrowError(error.json());
|
||||
// The backend returned an unsuccessful response code.
|
||||
// The response body may contain clues as to what went wrong,
|
||||
console.error(
|
||||
`Backend returned code ${error.status}, ` +
|
||||
`body was: ${error.error}`);
|
||||
}
|
||||
// return an observable with a user-facing error message
|
||||
return throwError(
|
||||
'Something bad happened; please try again later.');
|
||||
};
|
||||
}
|
||||
|
|
@ -1,31 +1,52 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { Http, Response } from '@angular/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
import { Event } from '../interfaces/event';
|
||||
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
|
||||
import { Observable, throwError } from 'rxjs';
|
||||
import { catchError, tap, map } from 'rxjs/operators';
|
||||
import { Event, EventResponse, SingleEventResponse } from '../interfaces/event';
|
||||
|
||||
import { EVENTS_BY_PAGE_URL,
|
||||
EVENT_BY_ID,
|
||||
EVENTS_ADD_URL,
|
||||
EVENTS_DELETE_BY_ID_URL } from '../constants/urls';
|
||||
import { getBodyNode } from '@angular/animations/browser/src/render/shared';
|
||||
|
||||
@Injectable()
|
||||
export class EventService {
|
||||
|
||||
constructor(private http: Http){
|
||||
constructor(private httpClient: HttpClient){
|
||||
|
||||
}
|
||||
|
||||
getEvents(page: number): Observable<Event[]> {
|
||||
getEvents(page: number): Observable<EventResponse> {
|
||||
let url = EVENTS_BY_PAGE_URL + page + "?pageSize=" + 10;
|
||||
return this.http.get(url).pipe(map(this.gotData,this),catchError(this.dataError));
|
||||
return this.httpClient.get<EventResponse>(url)
|
||||
.pipe(tap(e => this.setMultipleEventDates(e)),
|
||||
catchError(this.handleError));
|
||||
};
|
||||
|
||||
getSingleEvent(id: Number): Observable<Event>{
|
||||
getSingleEvent(id: Number): Observable<SingleEventResponse>{
|
||||
let url = EVENT_BY_ID + id;
|
||||
return this.http.get(url).pipe(map(this.gotDataSingle,this),catchError(this.dataError));
|
||||
return this.httpClient.get<SingleEventResponse>(url).pipe(tap(e => this.setSingleEventDates(e)), catchError(this.handleError));
|
||||
};
|
||||
|
||||
setEventDates(event: Event): Event {
|
||||
event.startDate = new Date(event.startDate);
|
||||
event.endDate = new Date(event.endDate);
|
||||
return event;
|
||||
}
|
||||
|
||||
setSingleEventDates(event : SingleEventResponse) : SingleEventResponse {
|
||||
event.event = this.setEventDates(event.event);
|
||||
return event;
|
||||
}
|
||||
|
||||
setMultipleEventDates(event: EventResponse) : EventResponse {
|
||||
event.events.forEach(e => {
|
||||
e = this.setEventDates(e);
|
||||
});
|
||||
return event;
|
||||
}
|
||||
|
||||
addEvent(event: Event){
|
||||
let fd = new FormData();
|
||||
fd.append("title",event.title);
|
||||
|
|
@ -34,28 +55,16 @@ export class EventService {
|
|||
fd.append("endDate",new Date(event.endDate).getTime().toString()); //Pass date as milliseconds since 1970
|
||||
fd.append("timezoneOffset",new Date().getTimezoneOffset().toString());
|
||||
|
||||
return this.http.post(EVENTS_ADD_URL,fd,{withCredentials:true})
|
||||
.pipe(map(d=>{ return d.json(); })
|
||||
,catchError(this.dataError));
|
||||
return this.httpClient.post(EVENTS_ADD_URL, fd, {withCredentials:true}).pipe(catchError(this.handleError));
|
||||
}
|
||||
|
||||
deleteEvent(eventId: number){
|
||||
return this.http.delete(EVENTS_DELETE_BY_ID_URL,{withCredentials:true,body:{"id":eventId}})
|
||||
.pipe(map(d => {return d.json(); })
|
||||
,catchError(this.dataError));
|
||||
}
|
||||
let ro = {
|
||||
body: {"id":eventId},
|
||||
withCredentials: true
|
||||
};
|
||||
|
||||
gotDataSingle(res: Response){
|
||||
let body = res.json();
|
||||
return this.toEvent(body.event);
|
||||
}
|
||||
|
||||
gotData(res: Response){
|
||||
let body = res.json();
|
||||
body = body.events.map(e => {
|
||||
return this.toEvent(e);
|
||||
});
|
||||
return body || { };
|
||||
return this.httpClient.delete(EVENTS_DELETE_BY_ID_URL, ro).pipe(catchError(this.handleError));
|
||||
}
|
||||
|
||||
toEvent(json: any): Event{
|
||||
|
|
@ -68,17 +77,21 @@ export class EventService {
|
|||
}
|
||||
}
|
||||
|
||||
dataError(error: Response | any){
|
||||
let errMsg: string;
|
||||
if (error instanceof Response) {
|
||||
const body = error.json() || '';
|
||||
const err = body.error || JSON.stringify(body);
|
||||
errMsg = `${error.status} - ${error.statusText || ''} ${err}`;
|
||||
private handleError(error: HttpErrorResponse) {
|
||||
console.error(error);
|
||||
if (error.error instanceof ErrorEvent) {
|
||||
// A client-side or network error occurred. Handle it accordingly.
|
||||
console.error('An error occurred:', error.error.message);
|
||||
} else {
|
||||
errMsg = error.message ? error.message : error.toString();
|
||||
}
|
||||
console.error(errMsg);
|
||||
return Observable.throw(errMsg);
|
||||
// The backend returned an unsuccessful response code.
|
||||
// The response body may contain clues as to what went wrong,
|
||||
console.error(
|
||||
`Backend returned code ${error.status}, ` +
|
||||
`body was: ${error.error}`);
|
||||
}
|
||||
// return an observable with a user-facing error message
|
||||
return throwError(
|
||||
'Something bad happened; please try again later.');
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
import { TestBed, inject } from '@angular/core/testing';
|
||||
|
||||
import { GoogleAnalyticsService } from './google-analytics.service';
|
||||
|
||||
describe('GoogleAnalyticsService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [GoogleAnalyticsService]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([GoogleAnalyticsService], (service: GoogleAnalyticsService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
|
|
@ -1,12 +1,9 @@
|
|||
|
||||
import {throwError as observableThrowError, Observable , Subject, of } from 'rxjs';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Http, Response, RequestOptions } from '@angular/http';
|
||||
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
|
||||
|
||||
import { Observable, Subject, throwError, of } from 'rxjs';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
|
||||
|
||||
import { Sermon } from '../interfaces/sermon';
|
||||
import { LOGIN_URL } from '../constants/urls';
|
||||
|
||||
@Injectable()
|
||||
|
|
@ -14,64 +11,58 @@ export class LoginService {
|
|||
private loggedIn: boolean = false;
|
||||
private onChange: Subject<{isLoggedIn: boolean}>;
|
||||
private lastLoginCheck: Date;
|
||||
private options: RequestOptions;
|
||||
private options: {};
|
||||
|
||||
constructor(private http: Http){
|
||||
this.options = new RequestOptions({
|
||||
constructor(private httpClient: HttpClient){
|
||||
this.options = {
|
||||
withCredentials: true
|
||||
});
|
||||
};
|
||||
this.lastLoginCheck = new Date();
|
||||
this.lastLoginCheck.setHours(this.lastLoginCheck.getHours() - 2);
|
||||
this.onChange = new Subject<{isLoggedIn: boolean}>();
|
||||
}
|
||||
|
||||
login(username: string, password: string){
|
||||
return this.http.post(LOGIN_URL,{userName:username,password:password},this.options)
|
||||
.pipe(map(r=> { return this.gotData(r);})
|
||||
,catchError(this.dataError));
|
||||
return this.httpClient.post(LOGIN_URL, {userName: username, password: password}, this.options).pipe(catchError(this.handleError));
|
||||
}
|
||||
|
||||
isLoggedIn(fromServer: boolean = false){
|
||||
var now = new Date();
|
||||
var hours = Math.abs(now.valueOf() - this.lastLoginCheck.valueOf()) / 36e5;
|
||||
if (hours > 0.75 || fromServer === true){
|
||||
return this.http.post(LOGIN_URL + "/isloggedin",{},this.options)
|
||||
.pipe(map(d => {
|
||||
let is = d.json().loggedIn === true;
|
||||
return this.httpClient.post(LOGIN_URL + "/isloggedin",{},this.options)
|
||||
.pipe(map((d:any) => {
|
||||
let is = d.loggedIn === true;
|
||||
this.loggedIn = is;
|
||||
this.lastLoginCheck = new Date();
|
||||
this.onChange.next({isLoggedIn: this.loggedIn});
|
||||
return this.loggedIn;
|
||||
})
|
||||
,catchError(this.dataError));
|
||||
}),
|
||||
catchError(this.handleError));
|
||||
|
||||
} else {
|
||||
let val = this.loggedIn;
|
||||
return of(val);
|
||||
}
|
||||
}
|
||||
|
||||
gotData(res: Response){
|
||||
let body = res.json();
|
||||
this.lastLoginCheck = new Date();
|
||||
this.loggedIn = body.message === 'Logged In';
|
||||
this.onChange.next({isLoggedIn: this.loggedIn});
|
||||
return body;
|
||||
}
|
||||
|
||||
dataError(error: Response | any){
|
||||
let errMsg: string;
|
||||
if (error instanceof Response) {
|
||||
const body = error.json() || '';
|
||||
const err = body.error || JSON.stringify(body);
|
||||
errMsg = `${error.status} - ${error.statusText || ''} ${err}`;
|
||||
} else {
|
||||
errMsg = error.message ? error.message : error.toString();
|
||||
}
|
||||
console.error(errMsg);
|
||||
return observableThrowError(errMsg);
|
||||
}
|
||||
|
||||
onLogin(): Observable<{isLoggedIn: boolean}>{
|
||||
return this.onChange.asObservable();
|
||||
}
|
||||
|
||||
private handleError(error: HttpErrorResponse) {
|
||||
if (error.error instanceof ErrorEvent) {
|
||||
// A client-side or network error occurred. Handle it accordingly.
|
||||
console.error('An error occurred:', error.error.message);
|
||||
} else {
|
||||
// The backend returned an unsuccessful response code.
|
||||
// The response body may contain clues as to what went wrong,
|
||||
console.error(
|
||||
`Backend returned code ${error.status}, ` +
|
||||
`body was: ${error.error}`);
|
||||
}
|
||||
// return an observable with a user-facing error message
|
||||
return throwError(
|
||||
'Something bad happened; please try again later.');
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
|
||||
import {throwError as observableThrowError, Observable } from 'rxjs';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Http, Response } from '@angular/http';
|
||||
import { HttpClient, HttpErrorResponse, HttpRequest } from '@angular/common/http';
|
||||
|
||||
import { Observable, throwError } from 'rxjs';
|
||||
import { catchError, tap } from 'rxjs/operators';
|
||||
|
||||
|
||||
import { Sermon } from '../interfaces/sermon';
|
||||
import { Sermon, MultipleSermonResponse, SingleSermonResponse } from '../interfaces/sermon';
|
||||
import { SERMONS_BY_ID,
|
||||
SERMONS_BY_PAGE_URL,
|
||||
SERMON_MP3_BASE_URL,
|
||||
|
|
@ -20,41 +18,45 @@ import { SERMONS_BY_ID,
|
|||
export class SermonService {
|
||||
private pageSize: number = 10;
|
||||
|
||||
constructor(private http: Http){
|
||||
constructor(private httpClient: HttpClient){
|
||||
|
||||
}
|
||||
|
||||
getSermons(count: number): Observable<Sermon[]> {
|
||||
getSermons(count: number): Observable<MultipleSermonResponse> {
|
||||
let url = SERMONS_BY_PAGE_URL + 1 + "?pageSize=" + 5;
|
||||
return this.http.get(url).pipe(map(this.gotData),catchError(this.dataError));
|
||||
return this.httpClient.get<MultipleSermonResponse>(url).pipe(tap(e => this.setMultipleDates(e)), catchError(this.handleError));
|
||||
};
|
||||
|
||||
getSermonsByPage(page: number): Observable<Sermon[]>{
|
||||
getSermonsByPage(page: number): Observable<MultipleSermonResponse>{
|
||||
let url = SERMONS_BY_PAGE_URL + page + "?pageSize=" + this.pageSize;
|
||||
return this.http.get(url).pipe(map(this.gotData),catchError(this.dataError));
|
||||
return this.httpClient.get<MultipleSermonResponse>(url).pipe(tap(e => this.setMultipleDates(e)), catchError(this.handleError));
|
||||
}
|
||||
|
||||
getSermonById(id: number): Observable<Sermon>{
|
||||
getSermonById(id: number): Observable<SingleSermonResponse>{
|
||||
let url = SERMONS_BY_ID + id + "?pageSize=" + this.pageSize;
|
||||
return this.http.get(url).pipe(map(this.gotSermon),catchError(this.dataError));
|
||||
return this.httpClient.get<SingleSermonResponse>(url).pipe(tap(e => this.setSingleDate(e)), catchError(this.handleError));
|
||||
}
|
||||
|
||||
searchSermons(searchTerm: string, page: number): Observable<Sermon[]>{
|
||||
searchSermons(searchTerm: string, page: number): Observable<MultipleSermonResponse>{
|
||||
let url = SERMONS_BY_SEARCH_URL + "?searchTerm=" + searchTerm + "&page=" + page + "&pageSize=" + this.pageSize;
|
||||
return this.http.get(url).pipe(map(this.gotData),catchError(this.dataError));
|
||||
return this.httpClient.get<MultipleSermonResponse>(url).pipe(tap(e => this.setMultipleDates(e)), catchError(this.handleError));
|
||||
}
|
||||
|
||||
addSermon(sermon: Sermon, sermonFile: File){
|
||||
let fd = new FormData();
|
||||
fd.append("title",sermon.title);
|
||||
fd.append("description",sermon.description);
|
||||
fd.append("date",new Date(sermon.sermonDate).getTime().toString()); //Pas date as milliseconds since 1970
|
||||
fd.append("date",new Date(sermon.date).getTime().toString()); //Pas date as milliseconds since 1970
|
||||
fd.append("author",sermon.author);
|
||||
fd.append("file",sermonFile);
|
||||
fd.append("timezoneOffset",new Date().getTimezoneOffset().toString());
|
||||
return this.http.post(SERMON_ADD_URL,fd,{withCredentials:true})
|
||||
.pipe(map(d=>{ return d.json(); })
|
||||
,catchError(this.dataError));
|
||||
const req = new HttpRequest('POST', SERMON_ADD_URL, fd, {
|
||||
reportProgress: true,
|
||||
withCredentials: true
|
||||
});
|
||||
return this.httpClient.request(req).pipe(
|
||||
catchError(this.handleError)
|
||||
);
|
||||
}
|
||||
|
||||
updateSermon(sermon: Sermon){
|
||||
|
|
@ -62,60 +64,56 @@ export class SermonService {
|
|||
fd.append("id",sermon.id.toString());
|
||||
fd.append("title",sermon.title);
|
||||
fd.append("description",sermon.description);
|
||||
fd.append("date",new Date(sermon.sermonDate).toUTCString());
|
||||
fd.append("date",new Date(sermon.date).toUTCString());
|
||||
fd.append("author",sermon.author);
|
||||
fd.append("timezoneOffset",new Date().getTimezoneOffset().toString());
|
||||
return this.http.put(SERMON_UPDATE_URL,fd,{withCredentials:true})
|
||||
.pipe(map(d => { return d.json(); })
|
||||
,catchError(this.dataError));
|
||||
return this.httpClient.put<Sermon>(SERMON_UPDATE_URL,fd,{withCredentials:true})
|
||||
.pipe(catchError(this.handleError));
|
||||
}
|
||||
|
||||
|
||||
deleteSermon(sermonId: number){
|
||||
return this.http.delete(SERMON_DELETE_URL,{withCredentials:true,body:{"id":sermonId}})
|
||||
.pipe(map(d=>{ return d.json(); })
|
||||
,catchError(this.dataError));
|
||||
let options = {
|
||||
withCredentials: true,
|
||||
body: {
|
||||
"id" : sermonId
|
||||
}
|
||||
|
||||
gotSermon(res: Response){
|
||||
let s = res.json().sermon;
|
||||
s = {
|
||||
id: s.id,
|
||||
title: s.title,
|
||||
sermonDate: new Date(s.date),
|
||||
uploadDate: null,
|
||||
description: s.description,
|
||||
url: SERMON_MP3_BASE_URL + s.file,
|
||||
author: s.author
|
||||
};
|
||||
return s || { };
|
||||
return this.httpClient.delete(SERMON_DELETE_URL,options)
|
||||
.pipe(catchError(this.handleError));
|
||||
}
|
||||
|
||||
gotData(res: Response){
|
||||
//if (1 == 1) return MOCK;
|
||||
let body = res.json();
|
||||
body = body.sermons.map(s => { return {
|
||||
id: s.id,
|
||||
title: s.title,
|
||||
sermonDate: new Date(s.date),
|
||||
uploadDate: null,
|
||||
description: s.description,
|
||||
url: SERMON_MP3_BASE_URL + s.file,
|
||||
author: s.author
|
||||
}});
|
||||
return body || { };
|
||||
setSingleDate(e : SingleSermonResponse): SingleSermonResponse {
|
||||
e.sermon = this.setDates(e.sermon);
|
||||
return e;
|
||||
}
|
||||
|
||||
dataError(error: Response | any){
|
||||
let errMsg: string;
|
||||
if (error instanceof Response) {
|
||||
const body = error.json() || '';
|
||||
const err = body.error || JSON.stringify(body);
|
||||
errMsg = `${error.status} - ${error.statusText || ''} ${err}`;
|
||||
setMultipleDates(e : MultipleSermonResponse) : MultipleSermonResponse {
|
||||
e.sermons.forEach(s => {
|
||||
s = this.setDates(s);
|
||||
});
|
||||
return e;
|
||||
}
|
||||
|
||||
setDates(sermon: Sermon): Sermon {
|
||||
sermon.date = new Date(sermon.date);
|
||||
sermon.uploadDate = new Date(sermon.uploadDate);
|
||||
return sermon;
|
||||
}
|
||||
|
||||
private handleError(error: HttpErrorResponse) {
|
||||
if (error.error instanceof ErrorEvent) {
|
||||
// A client-side or network error occurred. Handle it accordingly.
|
||||
console.error('An error occurred:', error.error.message);
|
||||
} else {
|
||||
errMsg = error.message ? error.message : error.toString();
|
||||
}
|
||||
console.error(errMsg);
|
||||
return observableThrowError(errMsg);
|
||||
// The backend returned an unsuccessful response code.
|
||||
// The response body may contain clues as to what went wrong,
|
||||
console.error(
|
||||
`Backend returned code ${error.status}, ` +
|
||||
`body was: ${error.error}`);
|
||||
}
|
||||
// return an observable with a user-facing error message
|
||||
return throwError(
|
||||
'Something bad happened; please try again later.');
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
import { Subject } from 'rxjs';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class ProgressService {
|
||||
downloadProgress: Subject<any> = new Subject();
|
||||
uploadProgress: Subject<any> = new Subject();
|
||||
}
|
||||
|
Before Width: | Height: | Size: 6.0 MiB |
|
Before Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
|
@ -1,9 +1,11 @@
|
|||
# This file is currently used by autoprefixer to adjust CSS to support the below specified browsers
|
||||
# For additional information regarding the format and rule options, please see:
|
||||
# https://github.com/browserslist/browserslist#queries
|
||||
# For IE 9-11 support, please uncomment the last line of the file and adjust as needed
|
||||
#
|
||||
# For IE 9-11 support, please remove 'not' from the last line of the file and adjust as needed
|
||||
|
||||
> 0.5%
|
||||
last 2 versions
|
||||
Firefox ESR
|
||||
not dead
|
||||
# IE 9-11
|
||||
not IE 9-11
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
export const environment = {
|
||||
production: true
|
||||
production: true,
|
||||
baseUrl: ""
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,15 +1,17 @@
|
|||
// This file can be replaced during build by using the `fileReplacements` array.
|
||||
// `ng build ---prod` replaces `environment.ts` with `environment.prod.ts`.
|
||||
// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
|
||||
// The list of file replacements can be found in `angular.json`.
|
||||
|
||||
export const environment = {
|
||||
production: false
|
||||
production: false,
|
||||
baseUrl: "http://localhost:25776"
|
||||
};
|
||||
|
||||
/*
|
||||
* In development mode, to ignore zone related error stack frames such as
|
||||
* `zone.run`, `zoneDelegate.invokeTask` for easier debugging, you can
|
||||
* import the following file, but please comment it out in production mode
|
||||
* because it will have performance impact when throw error
|
||||
* For easier debugging in development mode, you can import the following file
|
||||
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
|
||||
*
|
||||
* This import should be commented out in production mode because it will have a negative impact
|
||||
* on performance if an error is thrown.
|
||||
*/
|
||||
// import 'zone.js/dist/zone-error'; // Included with Angular CLI.
|
||||
|
|
|
|||
|
After Width: | Height: | Size: 5.3 KiB |
|
|
@ -17,7 +17,7 @@ module.exports = function (config) {
|
|||
},
|
||||
coverageIstanbulReporter: {
|
||||
dir: require('path').join(__dirname, '../coverage'),
|
||||
reports: ['html', 'lcovonly'],
|
||||
reports: ['html', 'lcovonly', 'text-summary'],
|
||||
fixWebpackSourcePaths: true
|
||||
},
|
||||
reporters: ['progress', 'kjhtml'],
|
||||
|
|
|
|||
|
|
@ -9,4 +9,4 @@ if (environment.production) {
|
|||
}
|
||||
|
||||
platformBrowserDynamic().bootstrapModule(AppModule)
|
||||
.catch(err => console.log(err));
|
||||
.catch(err => console.error(err));
|
||||
|
|
|
|||
|
|
@ -11,14 +11,17 @@
|
|||
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
|
||||
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
|
||||
*
|
||||
* Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
|
||||
* Learn more in https://angular.io/guide/browser-support
|
||||
*/
|
||||
|
||||
/***************************************************************************************************
|
||||
* BROWSER POLYFILLS
|
||||
*/
|
||||
|
||||
/** IE9, IE10 and IE11 requires all of the following polyfills. **/
|
||||
/** IE9, IE10, IE11, and Chrome <55 requires all of the following polyfills.
|
||||
* This also includes Android Emulators with older versions of Chrome and Google Search/Googlebot
|
||||
*/
|
||||
|
||||
import 'core-js/es6/symbol';
|
||||
import 'core-js/es6/object';
|
||||
import 'core-js/es6/function';
|
||||
|
|
@ -40,33 +43,36 @@ import 'core-js/es6/set';
|
|||
/** IE10 and IE11 requires the following for the Reflect API. */
|
||||
// import 'core-js/es6/reflect';
|
||||
|
||||
|
||||
/** Evergreen browsers require these. **/
|
||||
// Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove.
|
||||
import 'core-js/es7/reflect';
|
||||
|
||||
|
||||
/**
|
||||
* Web Animations `@angular/platform-browser/animations`
|
||||
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
|
||||
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
|
||||
**/
|
||||
*/
|
||||
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
|
||||
|
||||
/**
|
||||
* By default, zone.js will patch all possible macroTask and DomEvents
|
||||
* user can disable parts of macroTask/DomEvents patch by setting following flags
|
||||
*/
|
||||
|
||||
// (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
|
||||
// (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
|
||||
// (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
|
||||
|
||||
/*
|
||||
* because those flags need to be set before `zone.js` being loaded, and webpack
|
||||
* will put import in the top of bundle, so user need to create a separate file
|
||||
* in this directory (for example: zone-flags.ts), and put the following flags
|
||||
* into that file, and then add the following code before importing zone.js.
|
||||
* import './zone-flags.ts';
|
||||
*
|
||||
* The flags allowed in zone-flags.ts are listed here.
|
||||
*
|
||||
* The following flags will work for all browsers.
|
||||
*
|
||||
* (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
|
||||
* (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
|
||||
* (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
|
||||
*
|
||||
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
|
||||
* with the following flag, it will bypass `zone.js` patch for IE/Edge
|
||||
*
|
||||
* (window as any).__Zone_enable_cross_context_check = true;
|
||||
*
|
||||
*/
|
||||
// (window as any).__Zone_enable_cross_context_check = true;
|
||||
|
||||
/***************************************************************************************************
|
||||
* Zone JS is required by default for Angular itself.
|
||||
|
|
@ -74,7 +80,6 @@ import 'core-js/es7/reflect';
|
|||
import 'zone.js/dist/zone'; // Included with Angular CLI.
|
||||
|
||||
|
||||
|
||||
/***************************************************************************************************
|
||||
* APPLICATION IMPORTS
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
/* You can add global styles to this file, and also import other style files */
|
||||
@import '../node_modules/@angular/material/prebuilt-themes/indigo-pink.css';
|
||||
|
||||
@import "~@angular/material/prebuilt-themes/indigo-pink.css";
|
||||
|
||||
*{
|
||||
padding: 0px;
|
||||
|
|
|
|||
|
|
@ -2,11 +2,10 @@
|
|||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../out-tsc/app",
|
||||
"module": "es2015",
|
||||
"types": []
|
||||
},
|
||||
"exclude": [
|
||||
"src/test.ts",
|
||||
"test.ts",
|
||||
"**/*.spec.ts"
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../out-tsc/spec",
|
||||
"module": "commonjs",
|
||||
"types": [
|
||||
"jasmine",
|
||||
"node"
|
||||
|
|
|
|||
|
|
@ -5,15 +5,17 @@
|
|||
"outDir": "./dist/out-tsc",
|
||||
"sourceMap": true,
|
||||
"declaration": false,
|
||||
"module": "es2015",
|
||||
"moduleResolution": "node",
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"importHelpers": true,
|
||||
"target": "es5",
|
||||
"typeRoots": [
|
||||
"node_modules/@types"
|
||||
],
|
||||
"lib": [
|
||||
"es2017",
|
||||
"es2018",
|
||||
"dom"
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"rulesDirectory": [
|
||||
"node_modules/codelyzer"
|
||||
"codelyzer"
|
||||
],
|
||||
"rules": {
|
||||
"arrow-return-shorthand": true,
|
||||
|
|
@ -65,6 +65,7 @@
|
|||
],
|
||||
"no-misused-new": true,
|
||||
"no-non-null-assertion": true,
|
||||
"no-redundant-jsdoc": true,
|
||||
"no-shadowed-variable": true,
|
||||
"no-string-literal": false,
|
||||
"no-string-throw": true,
|
||||
|
|
|
|||