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 { AccountEditComponent } from './account-edit.component';
|
||||
import { AddDataComponent } from './add-data.component';
|
||||
import { FeedbackComponent } from './feedback.component';
|
||||
|
||||
import { GraphWidget } from '../widgets/graph-widget.component';
|
||||
|
||||
|
@ -32,6 +33,7 @@ import { OrgTableComponent } from '../shared/org-table.component';
|
|||
AddDataComponent,
|
||||
OrgResultComponent,
|
||||
OrgTableComponent,
|
||||
FeedbackComponent,
|
||||
GraphWidget,
|
||||
]
|
||||
})
|
||||
|
|
|
@ -10,6 +10,7 @@ import { DashboardCustomerComponent } from './dashboard-customer.component';
|
|||
import { FullLayoutComponent } from '../layouts/full-layout.component';
|
||||
import { AccountEditComponent } from './account-edit.component';
|
||||
import { AddDataComponent } from './add-data.component';
|
||||
import { FeedbackComponent } from './feedback.component';
|
||||
|
||||
// Using child path to allow for FullLayout theming
|
||||
const routes: Routes = [
|
||||
|
@ -40,6 +41,11 @@ const routes: Routes = [
|
|||
path: 'add-data',
|
||||
component: AddDataComponent,
|
||||
data: { title: 'Add Transaction' },
|
||||
},
|
||||
{
|
||||
path: 'feedback',
|
||||
component: FeedbackComponent,
|
||||
data: { title: 'Give Feedback' },
|
||||
}
|
||||
],
|
||||
}
|
||||
|
|
|
@ -11,14 +11,14 @@
|
|||
<div class="form-group row">
|
||||
<label class="col-md-3 form-control-label" for="text-input"><strong>Email</strong></label>
|
||||
<div class="col-md-9">
|
||||
<input type="text" class="form-control" formControlName="email" [(ngModel)]="loggedInEmail" [readonly]="loggedIn">
|
||||
<span class="help-block">Enter your account email if it is not shown here.</span>
|
||||
<input type="text" class="form-control" formControlName="email" [(ngModel)]="loggedInEmail" [disabled]="noEmail">
|
||||
<span class="help-block">Your email will load here.</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-md-3 form-control-label" for="text-input"><strong>Enter Feedback Here</strong></label>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -26,7 +26,7 @@
|
|||
<div class="col-md-9">
|
||||
<div [ngSwitch]="feedbackFormStatus">
|
||||
<div *ngSwitchCase="'success'" class="alert alert-success" role="alert">
|
||||
Submit Succeeded.
|
||||
Thank you for submitting feedback!
|
||||
</div>
|
||||
<div *ngSwitchCase="'send_failed'" class="alert alert-danger" role="alert">
|
||||
{{feedbackFormStatusError}}
|
||||
|
@ -36,7 +36,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<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>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -5,13 +5,13 @@ import { ApiService } from '../providers/api-service';
|
|||
import 'rxjs/add/operator/map';
|
||||
|
||||
@Component({
|
||||
templateUrl: 'add-data.component.html',
|
||||
templateUrl: 'feedback.component.html',
|
||||
providers: [ApiService]
|
||||
})
|
||||
export class FeedbackPage {
|
||||
export class FeedbackComponent {
|
||||
feedbackForm: FormGroup;
|
||||
loggedIn: boolean;
|
||||
loggedInEmail: any;
|
||||
noEmail: boolean = false;
|
||||
username: any;
|
||||
feedbackFormStatus: any;
|
||||
feedbackFormStatusError: string = 'Error received, please try again.';
|
||||
|
@ -21,7 +21,10 @@ export class FeedbackPage {
|
|||
private formBuilder: FormBuilder,
|
||||
private api: ApiService,
|
||||
) {
|
||||
this.getUserEmail();
|
||||
this.loggedInEmail = localStorage.getItem('email');
|
||||
if (this.loggedInEmail == null) {
|
||||
this.noEmail = true;
|
||||
}
|
||||
|
||||
this.feedbackForm = this.formBuilder.group({
|
||||
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
|
||||
</a>
|
||||
</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">
|
||||
<a class="nav-link" routerLinkActive="active" [routerLink]="['/add-data']">
|
||||
<i class="icon-list"></i> Add Transaction
|
||||
<i class="icon-basket"></i> Add Transaction
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
@ -88,8 +88,8 @@ export class ApiService {
|
|||
public feedback(data) {
|
||||
data.app_name = 'Foodloop Web';
|
||||
data.package_name = 'Foodloop Web';
|
||||
data.version_code = '';
|
||||
data.version_number = '';
|
||||
data.version_code = 'dev';
|
||||
data.version_number = 'dev';
|
||||
console.log(data);
|
||||
return this.http.post(
|
||||
this.apiUrl + '/feedback',
|
||||
|
|
Reference in a new issue