FEATURE: added error reporting to the individual components

This commit is contained in:
walljm 2017-01-26 22:26:48 -05:00
parent 53f6218fa6
commit 79a757f765
14 changed files with 74 additions and 20 deletions

View File

@ -58,6 +58,7 @@
<Folder Include="src\components" />
<Folder Include="src\components\component-loader" />
<Folder Include="src\components\error" />
<Folder Include="src\components\error-message" />
<Folder Include="src\components\passage" />
<Folder Include="src\components\strongs" />
<Folder Include="src\components\strongs-modal" />

View File

@ -15,6 +15,7 @@ import { Strongs } from "../components/strongs/strongs";
import { Words } from "../components/words/words";
import { Error } from "../components/error/error";
import { StrongsModal } from "../components/strongs-modal/strongs-modal";
import { ErrorMessage } from '../components/error-message/error-message';
@NgModule({
declarations: [
@ -26,7 +27,8 @@ import { StrongsModal } from "../components/strongs-modal/strongs-modal";
Strongs,
StrongsModal,
Words,
Error
Error,
ErrorMessage
],
imports: [
IonicModule.forRoot(MyApp),
@ -41,7 +43,8 @@ import { StrongsModal } from "../components/strongs-modal/strongs-modal";
Strongs,
StrongsModal,
Words,
Error
Error,
ErrorMessage
],
providers: [{ provide: ErrorHandler, useClass: IonicErrorHandler }, Storage]
})

View File

@ -0,0 +1,2 @@
<br>
<p>{{msg}}</p>

View File

@ -0,0 +1,3 @@
err-message {
}

View File

@ -0,0 +1,16 @@
import { Component, Input} from "@angular/core";
@Component({
selector: 'error-message',
templateUrl: 'error-message.html'
})
export class ErrorMessage
{
@Input()
msg: string;
constructor()
{
this.msg = "";
}
}

View File

@ -1,10 +1,10 @@
<ion-item class="title passage-title" (swipe)="close()">
<ion-icon name="book" item-left></ion-icon> <span *ngIf="data !== undefined">{{data.ref}}</span>
<ion-icon name="book" item-left></ion-icon> <span *ngIf="data !== undefined"><span *ngIf="data.status === -1">Error:</span>{{data.ref}}</span>
<button ion-button icon-only item-right large clear (click)="close()">
<ion-icon name="close-circle"></ion-icon>
</button>
</ion-item>
<ion-card-content *ngIf="data !== undefined">
<ion-card-content *ngIf="data !== undefined && data.status === 0">
<br>
<div class="passage-text" *ngFor="let ch of data.cs">
<h2 *ngIf="data.cs.length > 1">
@ -18,6 +18,9 @@
</span>
</div>
</ion-card-content>
<ion-card-content *ngIf="data !== undefined && data.status === -1">
<error-message [msg]="data.msg"></error-message>
</ion-card-content>
<button ion-button icon-left clear small (click)="close()">
<ion-icon name="close-circle"></ion-icon>
<div>Close</div>

View File

@ -1,7 +1,7 @@
<ion-header>
<ion-toolbar>
<ion-title>
<ion-icon name="paper" item-left></ion-icon> <span *ngIf="item !== undefined">Strongs: {{item.prefix}}{{item.sn}}</span>
<ion-icon name="paper" item-left></ion-icon> <span *ngIf="item !== undefined"><span *ngIf="data.status === -1">Error:</span>Strongs: {{item.prefix}}{{item.sn}}</span>
</ion-title>
<ion-buttons start>
<button ion-button (click)="dismiss()" large>
@ -10,7 +10,7 @@
</ion-buttons>
</ion-toolbar>
</ion-header>
<ion-content padding *ngIf="item !== undefined">
<ion-content padding *ngIf="item !== undefined && data.status === 0">
<br>
<h2>Strong's Definitition</h2>
<p>
@ -35,3 +35,6 @@
</dd>
</dl>
</ion-content>
<ion-content *ngIf="data !== undefined && data.status === -1">
<error-message [msg]="data.msg"></error-message>
</ion-content>

View File

@ -1,10 +1,10 @@
<ion-item class="title strongs-title" padding (swipe)="close()">
<ion-icon name="paper" item-left></ion-icon> <span *ngIf="data !== undefined">{{data.prefix}}{{data.sn}}</span>
<ion-icon name="paper" item-left></ion-icon> <span *ngIf="data !== undefined"><span *ngIf="data.status === -1">Error:</span>{{data.prefix}}{{data.sn}}</span>
<button ion-button icon-only item-right large clear (click)="close()">
<ion-icon name="close-circle"></ion-icon>
</button>
</ion-item>
<ion-card-content *ngIf="data !== undefined">
<ion-card-content *ngIf="data !== undefined && data.status === 0">
<br>
<div class="strongs-def">
<h2>Strong's Definitition</h2>
@ -36,6 +36,9 @@
</div>
<br style="clear: both"> <!-- because you load with a promise, the height of the box doesn't get set properly-->
</ion-card-content>
<ion-card-content *ngIf="data !== undefined && data.status === -1">
<error-message [msg]="data.msg"></error-message>
</ion-card-content>
<button ion-button item-left icon-left clear small (click)="close()">
<ion-icon name="close-circle"></ion-icon>
<div>Close</div>

View File

@ -1,14 +1,17 @@
<ion-item class="title words-title" padding (swipe)="close()">
<ion-icon name="grid" item-left></ion-icon> <span *ngIf="data !== undefined">{{data.refs.length}}" results for {{data.word}}</span>
<ion-icon name="grid" item-left></ion-icon> <span *ngIf="data !== undefined"><span *ngIf="data.status === -1">Error:</span> {{data.refs.length}} results for {{data.word}}</span>
<button ion-button icon-only item-right large clear (click)="close()">
<ion-icon name="close-circle"></ion-icon>
</button>
</ion-item>
<ion-card-content *ngIf="data !== undefined">
<ion-card-content *ngIf="data !== undefined && data.status === 0">
<ion-scroll scrollY="true" overflow-scroll="true">
<a class="passage-button" *ngFor="let ref of data.refs" (click)="openPassage(ref)">{{makePassage(ref)}}</a>
</ion-scroll>
</ion-card-content>
<ion-card-content *ngIf="data !== undefined && data.status === -1">
<error-message [msg]="data.msg"></error-message>
</ion-card-content>
<button ion-button icon-left clear small (click)="close()">
<ion-icon name="close-circle"></ion-icon>
<div>Close</div>

View File

@ -87,7 +87,9 @@ export class Words implements AfterViewChecked, OnInit
ngOnInit(): void
{
this.wordService.getResultAsPromise(this.cardItem.qry).then(data => this.data = data);
this.wordService.getResultAsPromise(this.cardItem.qry).then(data =>
this.data = data
);
}
close()
@ -103,6 +105,6 @@ export class Words implements AfterViewChecked, OnInit
openPassage(p: string)
{
let ref = this.makePassage(p);
this.onItemClicked.emit({ card: this.cardItem, qry: ref, from_search_bar: false });
this.onItemClicked.emit({ card: this.cardItem, qry: ref, from_search_bar: false });
}
}

View File

@ -33,6 +33,21 @@ export class BibleService
status: 0,
msg: ":)"
};
if (Number(section.start.chapter) > section.start.lastchapter)
{
self.result.status = -1;
self.result.msg = "The requested chapter for " + section.start.bookname + " is out of range. Please pick a chapter between 1 and " + section.start.lastchapter + ".";
return self.result;
}
if (Number(section.end.chapter) > section.end.lastchapter)
{
self.result.status = -1;
self.result.msg = "The requested chapter for " + section.end.bookname + " is out of range. Please pick a chapter between 1 and " + section.end.lastchapter + ".";
return self.result;
}
this.count = Number(section.end.chapter) - Number(section.start.chapter) + 1;
for (let i = Number(section.start.chapter); i <= Number(section.end.chapter); i++)

View File

@ -38,7 +38,7 @@ export class StrongsService
if (sn > 5624 || sn < 1)
{
self.result.status = -1;
self.result.msg = "Strongs Number G" + sn + " is out of range.";
self.result.msg = "Strong's Number G" + sn + " is out of range. Strong's numbers range from 1 - 5624 in the New Testament.";
}
}
else
@ -47,7 +47,7 @@ export class StrongsService
if (sn > 8674 || sn < 1)
{
self.result.status = -1;
self.result.msg = "Strongs Number H" + sn + " is out of range.";
self.result.msg = "Strong's Number H" + sn + " is out of range. Strong's numbers range from 1 - 8674 in the Old Testament.";
}
}
this.result.sn = sn;
@ -68,7 +68,7 @@ export class StrongsService
{
console.log(error);
self.result.status = -1;
self.result.msg = "Unable to retrieve Strongs Data for " + self.result.prefix + self.result.sn;
self.result.msg = "Unable to retrieve Strong's Data for " + self.result.prefix + self.result.sn;
}
});
@ -98,7 +98,7 @@ export class StrongsService
{
console.log(error);
self.result.status = -1;
self.result.msg = "Unable to retrieve Strongs Cross References for " + self.result.prefix + self.result.sn;
self.result.msg = "Unable to retrieve Strong's Cross References for " + self.result.prefix + self.result.sn;
}
});

View File

@ -53,7 +53,7 @@ export class WordService
// Now we need to test results. If there is more than one item in the array, we need to find the set
// that is shared by all of them. IF not, we can just return those refs.
if (results.length == 0 || results == null || results == undefined)
return { word: qry, refs: null, status: -1, msg: "No passages found for query: " + qry + "." };
return { word: qry, refs: [], status: -1, msg: "No passages found for query: " + qry + "." };
let shared: string[];
if (results.length == 1)
@ -62,7 +62,7 @@ export class WordService
shared = this.findSharedSet(results);
if (shared == null || shared == undefined || shared.length == 0)
return { word: qry, refs: null, status: -1, msg: "No passages found for query: " + qry + "." };
return { word: qry, refs: [], status: -1, msg: "No passages found for query: " + qry + "." };
return { word: qry, refs: shared, status: 0, msg: ":)" };
}