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">
</div>
<div class="mb-4">
<div [ngSwitch]="loginStatus">
<div *ngSwitchCase="'success'" class="alert alert-success" role="alert">
Login Succeeded, routing to homepage.
</div>
<div *ngSwitchCase="'send_failed'" class="alert alert-danger" role="alert">
Error received, please try again.
</div>
<div [ngSwitch]="loginStatus">
<div *ngSwitchCase="'success'" class="alert alert-success" role="alert">
Login Succeeded, routing to homepage.
</div>
<div *ngSwitchCase="'send_failed'" class="alert alert-danger" role="alert">
Error received, please try again.
</div>
</div>
</div>
<div class="row">
<div class="col-6">
<button type="submit" [disabled]="!signin.valid" class="btn btn-primary px-4">Login</button>

View file

@ -134,12 +134,12 @@
</div>
<div heading="Pending" *ngSwitchDefault>Please Select a User Type</div>
</div>
<div [ngSwitch]="registerStatus">
<div class="mb-3" [ngSwitch]="registerStatus">
<div *ngSwitchCase="'success'" class="alert alert-success" role="alert">
Register Succeeded.
</div>
<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 *ngSwitchCase="'send_failed'" class="alert alert-danger" role="alert">
Failed to send to server, please try again later.

View file

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

View file

@ -82,6 +82,19 @@
</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">
<button type="submit" class="btn btn-sm btn-primary"><i class="fa fa-dot-circle-o"></i> Submit</button>
</div>
@ -107,6 +120,19 @@
</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">
<button type="submit" class="btn btn-sm btn-primary"><i class="fa fa-dot-circle-o"></i> Submit</button>
</div>

View file

@ -14,6 +14,7 @@ export class AccountEditComponent implements OnInit {
settingCustomerForm: FormGroup;
accountType: any;
@ViewChild('fileInput') fileInput;
submitStatus: any;
constructor(
private http: Http,
@ -70,6 +71,8 @@ export class AccountEditComponent implements OnInit {
console.log(this.settingForm.valid);
if (!this.settingForm.valid && !this.settingOrganisationForm.valid) {
console.log('Not Valid!');
this.submitStatus = "validation_failed";
console.log(this.submitStatus);
return;
}
@ -103,9 +106,13 @@ export class AccountEditComponent implements OnInit {
.subscribe(
result => {
console.log('data submitted!');
this.submitStatus = "success";
console.log(this.submitStatus);
},
error => {
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);
if (!this.settingForm.valid && !this.settingCustomerForm.valid) {
console.log('Not Valid!');
this.submitStatus = "validation_failed";
console.log(this.submitStatus);
return;
}
@ -145,9 +154,13 @@ export class AccountEditComponent implements OnInit {
.subscribe(
result => {
console.log('data submitted!');
this.submitStatus = "success";
console.log(this.submitStatus);
},
error => {
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>
</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 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>
</form>
</div>
@ -133,9 +145,21 @@
<span class="help-block">This is a help text</span>
</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 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>
</form>
</div>
@ -177,9 +201,21 @@
<span class="help-block">This is a help text</span>
</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 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>
</form>
</div>
@ -254,9 +290,21 @@
<span class="help-block">A total of other payments such as refunded fuel etc.</span>
</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 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>
</form>
</div>

View file

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