Advertisement
Guest User

Untitled

a guest
Jan 9th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.55 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.  
  45. Partij;
  46. Email;
  47. sGebruiker = "";
  48. Emailbericht;
  49.  
  50. public onRegisterFormSubmit(values: Object, sType): void {
  51. if (this.registerForm.valid) {
  52. this.snackBar.open('You registered successfully!', '×', { panelClass: 'success', verticalPosition: 'top', duration: 3000 });
  53. }
  54.  
  55. delete this.Partij["_id"]
  56. let req = {
  57. sToken: "",
  58. Partij: this.Partij,
  59. Email: this.Email,
  60. sType: sType
  61. }
  62.  
  63. console.log("Partij", this.Partij)
  64. this.ds.iPartij(req).subscribe(res => {
  65. console.log("Response van iPartij", res)
  66.  
  67. console.log("Partij", this.Email)
  68. this.ds.iEmail(req).subscribe(res => {
  69. console.log("Response van iEmail", res)
  70.  
  71. this.ds.sRegTemplateViaID(req).subscribe(res => {
  72. this.Emailbericht = res;
  73.  
  74. let s = this.Emailbericht.sBericht;
  75. console.log(s);
  76. s = s.replace("[gebruiker]", this.Partij.Partij.sGebruiker)
  77.  
  78. console.log("Response van emailbericht", s)
  79. })
  80. })
  81.  
  82. })
  83.  
  84.  
  85.  
  86. }
  87.  
  88. sRegTemplateViaID(sType) {
  89. let req = {
  90. sToken: "",
  91. sType: sType,
  92. }
  93. this.ds.sRegTemplateViaID(req).subscribe(res => {
  94. this.Emailbericht = res;
  95. let s = this.Emailbericht.sBericht;
  96. console.log("Response van emailbericht", s)
  97. })
  98. }
  99. sPartijViaID(_id) {
  100. let req = {
  101. sToken: "",
  102. _id: _id
  103. }
  104. this.ds.sPartijViaID(req).subscribe(res => {
  105. this.Partij = res
  106. console.log("Response van sPartijlViaID", res)
  107. })
  108. }
  109.  
  110. on_iPartij() {
  111. delete this.Partij["_id"]
  112. let req = {
  113. sToken: "",
  114. Partij: this.Partij
  115. }
  116. console.log("Partij", this.Partij)
  117. this.ds.iPartij(req).subscribe(res => {
  118. console.log("Response van iPartij", res)
  119. })
  120. }
  121.  
  122. sEmailViaID(_id) {
  123. let req = {
  124. sToken: "",
  125. _id: _id
  126. }
  127. this.ds.sEmailViaID(req).subscribe(res => {
  128. this.Email = res
  129. console.log("Response van sEmailViaID", res)
  130. })
  131. }
  132.  
  133. on_iEmail() {
  134. let req = {
  135. sToken: "",
  136. Email: this.Email
  137. }
  138. console.log("Partij", this.Email)
  139. this.ds.iEmail(req).subscribe(res => {
  140. console.log("Response van iEmail", res)
  141. })
  142. }
  143.  
  144.  
  145. // var email = require("./path/to/emailjs/email");
  146. // var server = email.server.connect({
  147. // user: "username",
  148. // password:"password",
  149. // host: "smtp.your-email.com",
  150. // ssl: true
  151. // });
  152.  
  153. // // send the message and get a callback with an error or details of the message that was sent
  154. // server.send({
  155. // text: "i hope this works",
  156. // from: "you <username@your-email.com>",
  157. // to: "someone <someone@your-email.com>, another <another@your-email.com>",
  158. // cc: "else <else@your-email.com>",
  159. // subject: "testing emailjs"
  160. // }, function(err, message) { console.log(err || message); });
  161.  
  162. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement