Advertisement
Guest User

Untitled

a guest
Dec 20th, 2018
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.61 KB | None | 0 0
  1. import { Component, OnInit, ViewChild } from '@angular/core';
  2. import { Router } from '@angular/router';
  3. import { FormBuilder, FormGroup, Validators } from '@angular/forms';
  4. import { MatSnackBar } from '@angular/material';
  5. import { emailValidator, matchingPasswords } from '../../theme/utils/app-validators';
  6. import { DataService } from './../../../services/data.service';
  7.  
  8. @Component({
  9. selector: 'app-sign-in',
  10. templateUrl: './sign-in.component.html',
  11. styleUrls: ['./sign-in.component.scss']
  12. })
  13. export class SignInComponent implements OnInit {
  14. @ViewChild('sidenav') sidenav: any;
  15. loginForm: FormGroup;
  16. registerForm: FormGroup;
  17. constructor(public formBuilder: FormBuilder, public router:Router, public snackBar: MatSnackBar, public ds: DataService) { }
  18.  
  19. ngOnInit() {
  20. this.loginForm = this.formBuilder.group({
  21. 'email': ['', Validators.compose([Validators.required, emailValidator])],
  22. 'password': ['', Validators.compose([Validators.required, Validators.minLength(6)])]
  23. });
  24.  
  25. this.registerForm = this.formBuilder.group({
  26. 'name': ['', Validators.compose([Validators.required, Validators.minLength(3)])],
  27. 'email': ['', Validators.compose([Validators.required, emailValidator])],
  28. 'password': ['', Validators.required],
  29. 'confirmPassword': ['', Validators.required]
  30. },{validator: matchingPasswords('password', 'confirmPassword')});
  31.  
  32. this.sPartijViaID("5bfbd6ef7e04b021103c3d28")
  33. this.sEmailViaID("5c1231507e04b02308c16ff7")
  34.  
  35.  
  36. }
  37.  
  38. public onLoginFormSubmit(values:Object):void {
  39. if (this.loginForm.valid) {
  40. this.router.navigate(['/products']);
  41. }
  42. }
  43.  
  44. public onRegisterFormSubmit(values:Object):void {
  45. if (this.registerForm.valid) {
  46. this.snackBar.open('You registered successfully!', '×', { panelClass: 'success', verticalPosition: 'top', duration: 3000 });
  47. }
  48. }
  49. Partij;
  50. Email;
  51. sGebruiker = "";
  52. sPartijViaID(_id){
  53.  
  54. let req = {
  55.  
  56. sToken: "",
  57.  
  58. _id: _id
  59.  
  60. }
  61.  
  62. this.ds.sPartijViaID(req).subscribe(res => {
  63.  
  64. this.Partij = res
  65.  
  66. console.log("Response van sPartijlViaID", res)
  67.  
  68. })
  69.  
  70. }
  71.  
  72. on_iPartij(){
  73.  
  74. delete this.Partij["_id"]
  75. let req = {
  76. sToken: "",
  77. Partij: this.Partij
  78. }
  79.  
  80. console.log("Partij", this.Partij)
  81. this.ds.iPartij(req).subscribe(res => {
  82. console.log("Response van iPartij", res)
  83. })
  84. }
  85.  
  86. sEmailViaID(_id){
  87.  
  88. let req = {
  89.  
  90. sToken: "",
  91.  
  92. _id: _id
  93.  
  94. }
  95.  
  96. this.ds.sEmailViaID(req).subscribe(res => {
  97.  
  98. this.Email = res
  99.  
  100. console.log("Response van sEmailViaID", res)
  101.  
  102. })
  103.  
  104. }
  105.  
  106. on_iEmail(){
  107.  
  108. let req = {
  109.  
  110. sToken: "",
  111.  
  112. Email: this.Email
  113.  
  114. }
  115.  
  116. console.log("Partij", this.Email)
  117.  
  118. this.ds.iEmail(req).subscribe(res => {
  119.  
  120. console.log("Response van iEmail", res)
  121.  
  122. })}
  123.  
  124. // var email = require("./path/to/emailjs/email");
  125. // var server = email.server.connect({
  126. // user: "username",
  127. // password:"password",
  128. // host: "smtp.your-email.com",
  129. // ssl: true
  130. // });
  131.  
  132. // // send the message and get a callback with an error or details of the message that was sent
  133. // server.send({
  134. // text: "i hope this works",
  135. // from: "you <username@your-email.com>",
  136. // to: "someone <someone@your-email.com>, another <another@your-email.com>",
  137. // cc: "else <else@your-email.com>",
  138. // subject: "testing emailjs"
  139. // }, function(err, message) { console.log(err || message); });
  140.  
  141. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement