Finished Feedback form code to working and added routing
This commit is contained in:
parent
506e3b36da
commit
95653e2a11
6 changed files with 28 additions and 31 deletions
|
@ -8,6 +8,7 @@ import { DashboardComponent } from './dashboard.component';
|
||||||
import { DashboardCustomerComponent } from './dashboard-customer.component';
|
import { DashboardCustomerComponent } from './dashboard-customer.component';
|
||||||
import { AccountEditComponent } from './account-edit.component';
|
import { AccountEditComponent } from './account-edit.component';
|
||||||
import { AddDataComponent } from './add-data.component';
|
import { AddDataComponent } from './add-data.component';
|
||||||
|
import { FeedbackComponent } from './feedback.component';
|
||||||
|
|
||||||
import { GraphWidget } from '../widgets/graph-widget.component';
|
import { GraphWidget } from '../widgets/graph-widget.component';
|
||||||
|
|
||||||
|
@ -32,6 +33,7 @@ import { OrgTableComponent } from '../shared/org-table.component';
|
||||||
AddDataComponent,
|
AddDataComponent,
|
||||||
OrgResultComponent,
|
OrgResultComponent,
|
||||||
OrgTableComponent,
|
OrgTableComponent,
|
||||||
|
FeedbackComponent,
|
||||||
GraphWidget,
|
GraphWidget,
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
|
@ -10,6 +10,7 @@ import { DashboardCustomerComponent } from './dashboard-customer.component';
|
||||||
import { FullLayoutComponent } from '../layouts/full-layout.component';
|
import { FullLayoutComponent } from '../layouts/full-layout.component';
|
||||||
import { AccountEditComponent } from './account-edit.component';
|
import { AccountEditComponent } from './account-edit.component';
|
||||||
import { AddDataComponent } from './add-data.component';
|
import { AddDataComponent } from './add-data.component';
|
||||||
|
import { FeedbackComponent } from './feedback.component';
|
||||||
|
|
||||||
// Using child path to allow for FullLayout theming
|
// Using child path to allow for FullLayout theming
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
|
@ -40,6 +41,11 @@ const routes: Routes = [
|
||||||
path: 'add-data',
|
path: 'add-data',
|
||||||
component: AddDataComponent,
|
component: AddDataComponent,
|
||||||
data: { title: 'Add Transaction' },
|
data: { title: 'Add Transaction' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'feedback',
|
||||||
|
component: FeedbackComponent,
|
||||||
|
data: { title: 'Give Feedback' },
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,14 +11,14 @@
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-md-3 form-control-label" for="text-input"><strong>Email</strong></label>
|
<label class="col-md-3 form-control-label" for="text-input"><strong>Email</strong></label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<input type="text" class="form-control" formControlName="email" [(ngModel)]="loggedInEmail" [readonly]="loggedIn">
|
<input type="text" class="form-control" formControlName="email" [(ngModel)]="loggedInEmail" [disabled]="noEmail">
|
||||||
<span class="help-block">Enter your account email if it is not shown here.</span>
|
<span class="help-block">Your email will load here.</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-md-3 form-control-label" for="text-input"><strong>Enter Feedback Here</strong></label>
|
<label class="col-md-3 form-control-label" for="text-input"><strong>Enter Feedback Here</strong></label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<textarea rows="7" class="form-control" formControlName="feedbacktext">
|
<textarea rows="7" class="form-control" formControlName="feedbacktext"></textarea>
|
||||||
<span class="help-block">Please enter your feedback in this textbox.</span>
|
<span class="help-block">Please enter your feedback in this textbox.</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<div [ngSwitch]="feedbackFormStatus">
|
<div [ngSwitch]="feedbackFormStatus">
|
||||||
<div *ngSwitchCase="'success'" class="alert alert-success" role="alert">
|
<div *ngSwitchCase="'success'" class="alert alert-success" role="alert">
|
||||||
Submit Succeeded.
|
Thank you for submitting feedback!
|
||||||
</div>
|
</div>
|
||||||
<div *ngSwitchCase="'send_failed'" class="alert alert-danger" role="alert">
|
<div *ngSwitchCase="'send_failed'" class="alert alert-danger" role="alert">
|
||||||
{{feedbackFormStatusError}}
|
{{feedbackFormStatusError}}
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer">
|
<div class="card-footer">
|
||||||
<button type="submit" [disabled]="!payrollForm.valid" class="btn btn-sm btn-primary"><i class="fa fa-dot-circle-o"></i> Submit</button>
|
<button type="submit" [disabled]="!feedbackForm.valid" class="btn btn-sm btn-primary"><i class="fa fa-dot-circle-o"></i> Submit</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,13 +5,13 @@ import { ApiService } from '../providers/api-service';
|
||||||
import 'rxjs/add/operator/map';
|
import 'rxjs/add/operator/map';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: 'add-data.component.html',
|
templateUrl: 'feedback.component.html',
|
||||||
providers: [ApiService]
|
providers: [ApiService]
|
||||||
})
|
})
|
||||||
export class FeedbackPage {
|
export class FeedbackComponent {
|
||||||
feedbackForm: FormGroup;
|
feedbackForm: FormGroup;
|
||||||
loggedIn: boolean;
|
|
||||||
loggedInEmail: any;
|
loggedInEmail: any;
|
||||||
|
noEmail: boolean = false;
|
||||||
username: any;
|
username: any;
|
||||||
feedbackFormStatus: any;
|
feedbackFormStatus: any;
|
||||||
feedbackFormStatusError: string = 'Error received, please try again.';
|
feedbackFormStatusError: string = 'Error received, please try again.';
|
||||||
|
@ -21,7 +21,10 @@ export class FeedbackPage {
|
||||||
private formBuilder: FormBuilder,
|
private formBuilder: FormBuilder,
|
||||||
private api: ApiService,
|
private api: ApiService,
|
||||||
) {
|
) {
|
||||||
this.getUserEmail();
|
this.loggedInEmail = localStorage.getItem('email');
|
||||||
|
if (this.loggedInEmail == null) {
|
||||||
|
this.noEmail = true;
|
||||||
|
}
|
||||||
|
|
||||||
this.feedbackForm = this.formBuilder.group({
|
this.feedbackForm = this.formBuilder.group({
|
||||||
email: ['', [Validators.required]],
|
email: ['', [Validators.required]],
|
||||||
|
@ -66,23 +69,4 @@ export class FeedbackPage {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getUserEmail() {
|
|
||||||
this.api.getEmail().subscribe(
|
|
||||||
result => {
|
|
||||||
if (result) {
|
|
||||||
console.log('Email has been received');
|
|
||||||
this.loggedInEmail = result;
|
|
||||||
this.loggedIn = true;
|
|
||||||
} else {
|
|
||||||
console.log('Email is not available');
|
|
||||||
this.loggedIn = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
err => {
|
|
||||||
console.log('Email could not be received');
|
|
||||||
this.loggedIn = false;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,9 +30,14 @@
|
||||||
<i class="icon-speedometer"></i> Dashboard
|
<i class="icon-speedometer"></i> Dashboard
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" routerLinkActive="active" [routerLink]="['/feedback']">
|
||||||
|
<i class="icon-envelope-letter"></i> Enter Feedback
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" routerLinkActive="active" [routerLink]="['/add-data']">
|
<a class="nav-link" routerLinkActive="active" [routerLink]="['/add-data']">
|
||||||
<i class="icon-list"></i> Add Transaction
|
<i class="icon-basket"></i> Add Transaction
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -88,8 +88,8 @@ export class ApiService {
|
||||||
public feedback(data) {
|
public feedback(data) {
|
||||||
data.app_name = 'Foodloop Web';
|
data.app_name = 'Foodloop Web';
|
||||||
data.package_name = 'Foodloop Web';
|
data.package_name = 'Foodloop Web';
|
||||||
data.version_code = '';
|
data.version_code = 'dev';
|
||||||
data.version_number = '';
|
data.version_number = 'dev';
|
||||||
console.log(data);
|
console.log(data);
|
||||||
return this.http.post(
|
return this.http.post(
|
||||||
this.apiUrl + '/feedback',
|
this.apiUrl + '/feedback',
|
||||||
|
|
Reference in a new issue