From 95653e2a11e2aca9580349a813231fe4d4b1159b Mon Sep 17 00:00:00 2001 From: piratefinn Date: Fri, 1 Sep 2017 15:02:05 +0100 Subject: [PATCH] Finished Feedback form code to working and added routing --- src/app/dashboard/dashboard.module.ts | 2 ++ src/app/dashboard/dashboard.routing.ts | 6 +++++ src/app/dashboard/feedback.component.html | 10 ++++---- src/app/dashboard/feedback.component.ts | 30 +++++----------------- src/app/layouts/full-layout.component.html | 7 ++++- src/app/providers/api-service.ts | 4 +-- 6 files changed, 28 insertions(+), 31 deletions(-) diff --git a/src/app/dashboard/dashboard.module.ts b/src/app/dashboard/dashboard.module.ts index 63a45f5..117f427 100644 --- a/src/app/dashboard/dashboard.module.ts +++ b/src/app/dashboard/dashboard.module.ts @@ -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, ] }) diff --git a/src/app/dashboard/dashboard.routing.ts b/src/app/dashboard/dashboard.routing.ts index d63a6a2..1fa4903 100644 --- a/src/app/dashboard/dashboard.routing.ts +++ b/src/app/dashboard/dashboard.routing.ts @@ -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' }, } ], } diff --git a/src/app/dashboard/feedback.component.html b/src/app/dashboard/feedback.component.html index f03f9dd..d827b99 100644 --- a/src/app/dashboard/feedback.component.html +++ b/src/app/dashboard/feedback.component.html @@ -11,14 +11,14 @@
- - Enter your account email if it is not shown here. + + Your email will load here.
- Please enter your feedback in this textbox.
@@ -26,7 +26,7 @@
diff --git a/src/app/dashboard/feedback.component.ts b/src/app/dashboard/feedback.component.ts index 8b87596..9350c3d 100644 --- a/src/app/dashboard/feedback.component.ts +++ b/src/app/dashboard/feedback.component.ts @@ -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; - } - ); - } - } diff --git a/src/app/layouts/full-layout.component.html b/src/app/layouts/full-layout.component.html index 23da7e0..4bb30ab 100644 --- a/src/app/layouts/full-layout.component.html +++ b/src/app/layouts/full-layout.component.html @@ -30,9 +30,14 @@ Dashboard + diff --git a/src/app/providers/api-service.ts b/src/app/providers/api-service.ts index 8ac13d2..93edc5e 100644 --- a/src/app/providers/api-service.ts +++ b/src/app/providers/api-service.ts @@ -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',