Guest User

Untitled

a guest
Nov 2nd, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.22 KB | None | 0 0
  1. import { NgModule, ModuleWithProviders } from '@angular/core';
  2. import { CommonModule } from '@angular/common';
  3.  
  4. /* Nativescript modules */
  5. import { NativeScriptFormsModule } from 'nativescript-angular/forms';
  6. import { NativeScriptModule } from 'nativescript-angular/nativescript.module';
  7. import { NativeScriptRouterModule } from 'nativescript-angular/router';
  8.  
  9. import { registerElement } from 'nativescript-angular/element-registry';
  10. registerElement('CardView', () => require('nativescript-cardview').CardView);
  11. /* End nativescript modules */
  12.  
  13. import { StoreModule } from '@ngrx/store';
  14. import { EffectsModule } from '@ngrx/effects';
  15. import { LoginPageComponent } from './containers/login-page/login-page.component';
  16. import { RegisterPageComponent } from './containers/register-page/register-page.component';
  17. import { ForgotPasswordPageComponent } from './containers/forgot-password-page/forgot-password-page.component';
  18. import { LoginFormComponent } from './components/login-form/login-form.component';
  19. import { RegisterFormComponent } from './components/register-form/register-form.component';
  20. import { ForgotPasswordFormComponent } from './components/forgot-password-form/forgot-password-form.component';
  21. import { TermsComponent } from './components/terms/terms.component';
  22.  
  23. import { AuthService } from './services/auth.service';
  24. import { AuthGuard, LazyAuthGuard } from './services/auth-guard.service';
  25. import { AuthEffects } from './effects/auth.effects';
  26. import { reducers } from './reducers';
  27.  
  28. import { AuthRoutingModule } from './auth-routing.module';
  29.  
  30. export const COMPONENTS = [
  31. LoginPageComponent,
  32. RegisterPageComponent,
  33. ForgotPasswordPageComponent,
  34. LoginFormComponent,
  35. RegisterFormComponent,
  36. ForgotPasswordFormComponent,
  37. TermsComponent,
  38. ];
  39.  
  40. @NgModule({
  41. imports: [
  42. CommonModule,
  43. NativeScriptModule,
  44. NativeScriptRouterModule,
  45. NativeScriptFormsModule,
  46. ],
  47. declarations: COMPONENTS,
  48. exports: COMPONENTS,
  49. entryComponents: [TermsComponent],
  50. })
  51. export class AuthModule {
  52. static forRoot(): ModuleWithProviders {
  53. return {
  54. ngModule: RootAuthModule,
  55. providers: [AuthService, AuthGuard, LazyAuthGuard],
  56. };
  57. }
  58. }
  59.  
  60. @NgModule({
  61. imports: [
  62. AuthModule,
  63. AuthRoutingModule,
  64. StoreModule.forFeature('auth', reducers),
  65. EffectsModule.forFeature([AuthEffects]),
  66. ],
  67. })
  68. export class RootAuthModule {}
  69.  
  70.  
  71. import { Component } from '@angular/core';
  72. import { ModalDialogParams } from 'nativescript-angular/modal-dialog';
  73. import { Page } from 'ui/page';
  74. import { terms, Terms } from './terms';
  75. @Component({
  76. moduleId: module.id,
  77. selector: 'terms-dialog',
  78. templateUrl: 'terms.component.html',
  79. })
  80. export class TermsComponent {
  81. public currentdate: Date;
  82. public test = 'sdfsdfsdfsd';
  83. public terms: Terms = terms;
  84. constructor(private params: ModalDialogParams, private page: Page) {
  85. this.page.on('unloaded', () => {
  86. // using the unloaded event to close the modal when there is user interaction
  87. // e.g. user taps outside the modal page
  88. this.params.closeCallback();
  89. });
  90. this.currentdate = new Date();
  91. }
  92. public getText(){
  93. return 'some text';
  94. }
  95. public close() {
  96. debugger;
  97. this.params.closeCallback();
  98. }
  99. }
  100.  
  101.  
  102. import {
  103. Component,
  104. OnInit,
  105. Input,
  106. Output,
  107. EventEmitter,
  108. ViewContainerRef,
  109. } from '@angular/core';
  110. import { FormGroup, FormControl } from '@angular/forms';
  111. import { Register } from '../../models/user';
  112. import { Config } from '../../../common/index';
  113. import { TermsComponent } from '../terms/terms.component';
  114.  
  115. /* Mobile Specific Stuff */
  116. import imagepicker = require('nativescript-imagepicker');
  117. import {
  118. ModalDialogService,
  119. ModalDialogOptions,
  120. } from 'nativescript-angular/modal-dialog';
  121.  
  122. @Component({
  123. moduleId: module.id,
  124. selector: 'bc-register-form',
  125. templateUrl: 'register-form.component.html',
  126. styleUrls: ['register-form.component.scss'],
  127. })
  128. export class RegisterFormComponent implements OnInit {
  129. @Input()
  130. set pending(isPending: boolean) {
  131. if (isPending) {
  132. this.form.disable();
  133. } else {
  134. this.form.enable();
  135. }
  136. }
  137.  
  138. @Input() errorMessage: string | null;
  139.  
  140. @Output() submitted = new EventEmitter<Register>();
  141.  
  142. form: FormGroup = new FormGroup({
  143. username: new FormControl(''),
  144. password: new FormControl(''),
  145. email: new FormControl(''),
  146. avatar: new FormControl(''),
  147. });
  148.  
  149. avatarFilePreview: any;
  150.  
  151. constructor(
  152. public modalService: ModalDialogService,
  153. private viewContainer: ViewContainerRef
  154. ) {}
  155.  
  156. ngOnInit() {
  157. this.form.get('avatar').valueChanges.subscribe(v => {
  158. this.avatarFilePreview = v._files[0];
  159. });
  160. }
  161.  
  162. openDialog() {
  163. const options: ModalDialogOptions = {
  164. fullscreen: false,
  165. viewContainerRef: this.viewContainer,
  166. context: {}
  167. };
  168.  
  169. return this.modalService.showModal(TermsComponent, options);
  170. }
  171.  
  172. getNativescriptImagePicker() {
  173. let context = imagepicker.create({
  174. mode: 'single',
  175. });
  176. var self = this;
  177. context
  178. .authorize()
  179. .then(function() {
  180. return context.present();
  181. })
  182. .then(function(selection) {
  183. self.avatarFilePreview = selection[0];
  184. })
  185. .catch(function(e) {
  186. // process error
  187. });
  188. }
  189.  
  190. submit() {
  191. if (this.form.valid) {
  192. this.submitted.emit(this.form.value);
  193. }
  194. }
  195. }
Add Comment
Please, Sign In to add comment