More errors added

This commit is contained in:
piratefinn 2017-08-25 12:18:14 +01:00
parent b45bc19ba7
commit c1381b812c
7 changed files with 124 additions and 13 deletions

View file

@ -17,15 +17,15 @@
<input type="password" class="form-control" formControlName="password" placeholder="Password"> <input type="password" class="form-control" formControlName="password" placeholder="Password">
</div> </div>
<div class="mb-4"> <div class="mb-4">
<div [ngSwitch]="loginStatus"> <div [ngSwitch]="loginStatus">
<div *ngSwitchCase="'success'" class="alert alert-success" role="alert"> <div *ngSwitchCase="'success'" class="alert alert-success" role="alert">
Login Succeeded, routing to homepage. Login Succeeded, routing to homepage.
</div> </div>
<div *ngSwitchCase="'send_failed'" class="alert alert-danger" role="alert"> <div *ngSwitchCase="'send_failed'" class="alert alert-danger" role="alert">
Error received, please try again. Error received, please try again.
</div>
</div> </div>
</div> </div>
</div>
<div class="row"> <div class="row">
<div class="col-6"> <div class="col-6">
<button type="submit" [disabled]="!signin.valid" class="btn btn-primary px-4">Login</button> <button type="submit" [disabled]="!signin.valid" class="btn btn-primary px-4">Login</button>

View file

@ -134,12 +134,12 @@
</div> </div>
<div heading="Pending" *ngSwitchDefault>Please Select a User Type</div> <div heading="Pending" *ngSwitchDefault>Please Select a User Type</div>
</div> </div>
<div [ngSwitch]="registerStatus"> <div class="mb-3" [ngSwitch]="registerStatus">
<div *ngSwitchCase="'success'" class="alert alert-success" role="alert"> <div *ngSwitchCase="'success'" class="alert alert-success" role="alert">
Register Succeeded. Register Succeeded.
</div> </div>
<div *ngSwitchCase="'validation_failed'" class="alert alert-danger" role="alert"> <div *ngSwitchCase="'validation_failed'" class="alert alert-danger" role="alert">
Form validation failed, please ensure the form is filled. Form validation failed, please ensure the form is filled correctly.
</div> </div>
<div *ngSwitchCase="'send_failed'" class="alert alert-danger" role="alert"> <div *ngSwitchCase="'send_failed'" class="alert alert-danger" role="alert">
Failed to send to server, please try again later. Failed to send to server, please try again later.

View file

@ -81,10 +81,14 @@ export class RegisterComponent {
.subscribe( .subscribe(
result => { result => {
console.log('registered!'); console.log('registered!');
this.registerStatus = "success";
console.log(this.registerStatus);
this.router.navigate(['/dashboard']); this.router.navigate(['/dashboard']);
}, },
error => { error => {
console.log( error._body ); console.log( error._body );
this.registerStatus = "send_failed";
console.log(this.registerStatus)
} }
); );
} }

View file

@ -82,6 +82,19 @@
</div> </div>
</div> </div>
</div> </div>
<div class="card-block">
<div [ngSwitch]="submitStatus">
<div *ngSwitchCase="'success'" class="alert alert-success" role="alert">
Account Update Succeeded.
</div>
<div *ngSwitchCase="'validation_failed'" class="alert alert-danger" role="alert">
Form validation failed, please ensure the form is filled correctly.
</div>
<div *ngSwitchCase="'send_failed'" class="alert alert-danger" role="alert">
Failed to send to server, please try again later.
</div>
</div>
</div>
<div class="card-footer"> <div class="card-footer">
<button type="submit" class="btn btn-sm btn-primary"><i class="fa fa-dot-circle-o"></i> Submit</button> <button type="submit" class="btn btn-sm btn-primary"><i class="fa fa-dot-circle-o"></i> Submit</button>
</div> </div>
@ -107,6 +120,19 @@
</div> </div>
</div> </div>
</div> </div>
<div class="card-block">
<div [ngSwitch]="submitStatus">
<div *ngSwitchCase="'success'" class="alert alert-success" role="alert">
Account Update Succeeded.
</div>
<div *ngSwitchCase="'validation_failed'" class="alert alert-danger" role="alert">
Form validation failed, please ensure the form is filled correctly.
</div>
<div *ngSwitchCase="'send_failed'" class="alert alert-danger" role="alert">
Failed to send to server, please try again later.
</div>
</div>
</div>
<div class="card-footer"> <div class="card-footer">
<button type="submit" class="btn btn-sm btn-primary"><i class="fa fa-dot-circle-o"></i> Submit</button> <button type="submit" class="btn btn-sm btn-primary"><i class="fa fa-dot-circle-o"></i> Submit</button>
</div> </div>

View file

@ -14,6 +14,7 @@ export class AccountEditComponent implements OnInit {
settingCustomerForm: FormGroup; settingCustomerForm: FormGroup;
accountType: any; accountType: any;
@ViewChild('fileInput') fileInput; @ViewChild('fileInput') fileInput;
submitStatus: any;
constructor( constructor(
private http: Http, private http: Http,
@ -70,6 +71,8 @@ export class AccountEditComponent implements OnInit {
console.log(this.settingForm.valid); console.log(this.settingForm.valid);
if (!this.settingForm.valid && !this.settingOrganisationForm.valid) { if (!this.settingForm.valid && !this.settingOrganisationForm.valid) {
console.log('Not Valid!'); console.log('Not Valid!');
this.submitStatus = "validation_failed";
console.log(this.submitStatus);
return; return;
} }
@ -103,9 +106,13 @@ export class AccountEditComponent implements OnInit {
.subscribe( .subscribe(
result => { result => {
console.log('data submitted!'); console.log('data submitted!');
this.submitStatus = "success";
console.log(this.submitStatus);
}, },
error => { error => {
console.log( error._body ); console.log( error._body );
this.submitStatus = "send_failed";
console.log(this.submitStatus);
} }
); );
} }
@ -114,6 +121,8 @@ export class AccountEditComponent implements OnInit {
console.log(this.settingForm.valid); console.log(this.settingForm.valid);
if (!this.settingForm.valid && !this.settingCustomerForm.valid) { if (!this.settingForm.valid && !this.settingCustomerForm.valid) {
console.log('Not Valid!'); console.log('Not Valid!');
this.submitStatus = "validation_failed";
console.log(this.submitStatus);
return; return;
} }
@ -145,9 +154,13 @@ export class AccountEditComponent implements OnInit {
.subscribe( .subscribe(
result => { result => {
console.log('data submitted!'); console.log('data submitted!');
this.submitStatus = "success";
console.log(this.submitStatus);
}, },
error => { error => {
console.log( error._body ); console.log( error._body );
this.submitStatus = "send_failed";
console.log(this.submitStatus);
} }
); );
} }

View file

@ -89,9 +89,21 @@
<span class="help-block">A total of other payments such as refunded fuel etc.</span> <span class="help-block">A total of other payments such as refunded fuel etc.</span>
</div> </div>
</div> </div>
<div class="form-group row">
<div class="col-md-9">
<div [ngSwitch]="payrollFormStatus">
<div *ngSwitchCase="'success'" class="alert alert-success" role="alert">
Submit Succeeded.
</div>
<div *ngSwitchCase="'send_failed'" class="alert alert-danger" role="alert">
Error received, please try again.
</div>
</div>
</div>
</div>
</div> </div>
<div class="card-footer"> <div class="card-footer">
<button type="submit" class="btn btn-sm btn-primary"><i class="fa fa-dot-circle-o"></i> Submit</button> <button type="submit" [disabled]="!payrollForm.valid" class="btn btn-sm btn-primary"><i class="fa fa-dot-circle-o"></i> Submit</button>
</div> </div>
</form> </form>
</div> </div>
@ -133,9 +145,21 @@
<span class="help-block">This is a help text</span> <span class="help-block">This is a help text</span>
</div> </div>
</div> </div>
<div class="form-group row">
<div class="col-md-9">
<div [ngSwitch]="suppliersFormStatus">
<div *ngSwitchCase="'success'" class="alert alert-success" role="alert">
Submit Succeeded.
</div>
<div *ngSwitchCase="'send_failed'" class="alert alert-danger" role="alert">
Error received, please try again.
</div>
</div>
</div>
</div>
</div> </div>
<div class="card-footer"> <div class="card-footer">
<button type="submit" class="btn btn-sm btn-primary"><i class="fa fa-dot-circle-o"></i> Submit</button> <button type="submit" [disabled]="!suppliersForm.valid" class="btn btn-sm btn-primary"><i class="fa fa-dot-circle-o"></i> Submit</button>
</div> </div>
</form> </form>
</div> </div>
@ -177,9 +201,21 @@
<span class="help-block">This is a help text</span> <span class="help-block">This is a help text</span>
</div> </div>
</div> </div>
<div class="form-group row">
<div class="col-md-9">
<div [ngSwitch]="singleSupplierFormStatus">
<div *ngSwitchCase="'success'" class="alert alert-success" role="alert">
Submit Succeeded.
</div>
<div *ngSwitchCase="'send_failed'" class="alert alert-danger" role="alert">
Error received, please try again.
</div>
</div>
</div>
</div>
</div> </div>
<div class="card-footer"> <div class="card-footer">
<button type="submit" class="btn btn-sm btn-primary"><i class="fa fa-dot-circle-o"></i> Submit</button> <button type="submit" [disabled]="!singleSupplierForm.valid" class="btn btn-sm btn-primary"><i class="fa fa-dot-circle-o"></i> Submit</button>
</div> </div>
</form> </form>
</div> </div>
@ -254,9 +290,21 @@
<span class="help-block">A total of other payments such as refunded fuel etc.</span> <span class="help-block">A total of other payments such as refunded fuel etc.</span>
</div> </div>
</div> </div>
<div class="form-group row">
<div class="col-md-9">
<div [ngSwitch]="employeeFormStatus">
<div *ngSwitchCase="'success'" class="alert alert-success" role="alert">
Submit Succeeded.
</div>
<div *ngSwitchCase="'send_failed'" class="alert alert-danger" role="alert">
Error received, please try again.
</div>
</div>
</div>
</div>
</div> </div>
<div class="card-footer"> <div class="card-footer">
<button type="submit" class="btn btn-sm btn-primary"><i class="fa fa-dot-circle-o"></i> Submit</button> <button type="submit" [disabled]="!employeeForm.valid" class="btn btn-sm btn-primary"><i class="fa fa-dot-circle-o"></i> Submit</button>
</div> </div>
</form> </form>
</div> </div>

View file

@ -13,6 +13,10 @@ export class AddDataComponent {
suppliersForm: FormGroup; suppliersForm: FormGroup;
singleSupplierForm: FormGroup; singleSupplierForm: FormGroup;
employeeForm: FormGroup; employeeForm: FormGroup;
payrollFormStatus: any;
suppliersFormStatus: any;
singleSupplierFormStatus: any;
employeeFormStatus: any;
constructor( constructor(
private http: Http, private http: Http,
@ -61,9 +65,13 @@ export class AddDataComponent {
.subscribe( .subscribe(
result => { result => {
console.log('data submitted!'); console.log('data submitted!');
this.payrollFormStatus = "success";
console.log(this.payrollFormStatus);
}, },
error => { error => {
console.log( error._body ); console.log( error._body );
this.payrollFormStatus = "send_failed";
console.log(this.payrollFormStatus);
} }
); );
} }
@ -76,9 +84,13 @@ export class AddDataComponent {
.subscribe( .subscribe(
result => { result => {
console.log('data submitted!'); console.log('data submitted!');
this.suppliersFormStatus = "success";
console.log(this.suppliersFormStatus);
}, },
error => { error => {
console.log( error._body ); console.log( error._body );
this.suppliersFormStatus = "send_failed";
console.log(this.suppliersFormStatus);
} }
); );
} }
@ -91,9 +103,13 @@ export class AddDataComponent {
.subscribe( .subscribe(
result => { result => {
console.log('data submitted!'); console.log('data submitted!');
this.singleSupplierFormStatus = "success";
console.log(this.singleSupplierFormStatus);
}, },
error => { error => {
console.log( error._body ); console.log( error._body );
this.singleSupplierFormStatus = "send_failed";
console.log(this.singleSupplierFormStatus);
} }
); );
} }
@ -106,9 +122,13 @@ export class AddDataComponent {
.subscribe( .subscribe(
result => { result => {
console.log('data submitted!'); console.log('data submitted!');
this.employeeFormStatus = "success";
console.log(this.employeeFormStatus);
}, },
error => { error => {
console.log( error._body ); console.log( error._body );
this.employeeFormStatus = "send_failed";
console.log(this.employeeFormStatus);
} }
); );
} }