diff --git a/client/Nightr/src/app/app.component.css b/client/Nightr/src/app/app.component.css new file mode 100644 index 0000000..18496f5 --- /dev/null +++ b/client/Nightr/src/app/app.component.css @@ -0,0 +1,5 @@ +.float-btn-container + { + margin-top: 35%; + margin-left: 20%; + } diff --git a/client/Nightr/src/app/app.component.html b/client/Nightr/src/app/app.component.html index 6dea362..7aaab14 100644 --- a/client/Nightr/src/app/app.component.html +++ b/client/Nightr/src/app/app.component.html @@ -1,3 +1,9 @@ - - + + + + + + + + diff --git a/client/Nightr/src/app/app.component.ts b/client/Nightr/src/app/app.component.ts index d88b2fe..76d0c64 100644 --- a/client/Nightr/src/app/app.component.ts +++ b/client/Nightr/src/app/app.component.ts @@ -1,8 +1,40 @@ import { Component } from "@angular/core"; +import * as dialogs from "tns-core-modules/ui/dialogs"; +import { MyHttpPostService } from './services/my-http-post-service' +import { TouchGestureEventData, GestureEventData } from 'tns-core-modules/ui/gestures' @Component({ selector: "ns-app", moduleId: module.id, - templateUrl: "./app.component.html" + templateUrl: "./app.component.html", + styleUrls: ['./app.component.css'], + providers: [MyHttpPostService] }) -export class AppComponent { } +export class AppComponent { + public user: string = ""; + public pass: string = ""; + returnMessage: string = ""; + + constructor(private myHttpPostSerivce: MyHttpPostService) { } + + public onTap(args: GestureEventData): any { + this.submit(); + dialogs.confirm("Should be result").then(result => { + console.log("Dialog result: " + result); + }); + } + + public submit(): void { + this.makePostRequest(); + } + + private makePostRequest(): void { + console.log('Reached makepostRequest'); + this.myHttpPostSerivce + .postData({ username: this.user, password: this.pass }) + .subscribe(res => { + console.log('This is res', res); + this.returnMessage = (res).json.data.username; + }); + } +} diff --git a/client/Nightr/src/app/app.module.ts b/client/Nightr/src/app/app.module.ts index d5d8d40..3b24722 100644 --- a/client/Nightr/src/app/app.module.ts +++ b/client/Nightr/src/app/app.module.ts @@ -2,7 +2,8 @@ import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core"; import { NativeScriptModule } from "nativescript-angular/nativescript.module"; import { AppComponent } from "./app.component"; -import { MyButtonComponent } from './my-button/my-button.component'; +import { MyButtonComponent } from './component/my-button/my-button.component'; +import { NativeScriptHttpClientModule } from "nativescript-angular/http-client"; // Uncomment and add to NgModule imports if you need to use two-way binding // import { NativeScriptFormsModule } from "nativescript-angular/forms"; @@ -16,6 +17,7 @@ import { MyButtonComponent } from './my-button/my-button.component'; ], imports: [ NativeScriptModule, + NativeScriptHttpClientModule, ], declarations: [ AppComponent, diff --git a/client/Nightr/src/app/my-button/my-button.component.css b/client/Nightr/src/app/my-button/my-button.component.css deleted file mode 100644 index bcd4764..0000000 --- a/client/Nightr/src/app/my-button/my-button.component.css +++ /dev/null @@ -1 +0,0 @@ -/* Add mobile styles for the component here. */ diff --git a/client/Nightr/src/app/my-button/my-button.component.html b/client/Nightr/src/app/my-button/my-button.component.html deleted file mode 100644 index 59259f8..0000000 --- a/client/Nightr/src/app/my-button/my-button.component.html +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/client/Nightr/src/app/my-button/my-button.component.ts b/client/Nightr/src/app/my-button/my-button.component.ts deleted file mode 100644 index d18c116..0000000 --- a/client/Nightr/src/app/my-button/my-button.component.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Component, OnInit } from '@angular/core'; - -@Component({ - selector: 'ns-my-button', - templateUrl: './my-button.component.html', - styleUrls: ['./my-button.component.css'], - moduleId: module.id, -}) -export class MyButtonComponent implements OnInit { - - constructor() { } - - ngOnInit() { - } - -} diff --git a/client/Nightr/src/app/services/my-http-get.service.ts b/client/Nightr/src/app/services/my-http-get.service.ts new file mode 100644 index 0000000..e26ecc4 --- /dev/null +++ b/client/Nightr/src/app/services/my-http-get.service.ts @@ -0,0 +1,9 @@ +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class MyHttpGetService { + + constructor() { } +} diff --git a/client/Nightr/src/app/services/my-http-post-service.ts b/client/Nightr/src/app/services/my-http-post-service.ts new file mode 100644 index 0000000..8dca261 --- /dev/null +++ b/client/Nightr/src/app/services/my-http-post-service.ts @@ -0,0 +1,24 @@ +import { Injectable } from "@angular/core"; +import { HttpClient, HttpHeaders } from "@angular/common/http"; + +@Injectable({ + providedIn: 'root' + }) +export class MyHttpPostService { + private serverUrl = "https://nightr.caspervk.net"; + + constructor(private http: HttpClient) { } + + postData(data: any) { + console.log('logged data is', data); + let options = this.createRequestOptions(); + return this.http.post(this.serverUrl, { data }, { headers: options }); + } + + private createRequestOptions() { + let headers = new HttpHeaders({ + "Content-Type": "application/json" + }); + return headers; + } +}