Skip to content
Commits on Source (3)
import { Component, EventEmitter, NgZone } from '@angular/core';
import { Component, EventEmitter, NgZone, Output } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { Client } from '../../../services/api';
......@@ -7,10 +7,12 @@ import { Session } from '../../../services/session';
@Component({
moduleId: module.id,
selector: 'minds-form-login',
outputs: ['done', 'doneRegistered'],
templateUrl: 'login.html',
})
export class LoginForm {
@Output() done: EventEmitter<any> = new EventEmitter();
@Output() doneRegistered: EventEmitter<any> = new EventEmitter();
errorMessage: string = '';
twofactorToken: string = '';
hideLogin: boolean = false;
......@@ -20,9 +22,6 @@ export class LoginForm {
form: FormGroup;
done: EventEmitter<any> = new EventEmitter();
doneRegistered: EventEmitter<any> = new EventEmitter();
//Taken from advice in https://stackoverflow.com/a/1373724
private emailRegex: RegExp = new RegExp(
"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?"
......@@ -54,11 +53,14 @@ export class LoginForm {
this.errorMessage = '';
this.inProgress = true;
let opts = {
username: username,
password: this.form.value.password,
};
this.client
.post('api/v1/authenticate', {
username: username,
password: this.form.value.password,
})
.post('api/v1/authenticate', opts)
.then((data: any) => {
// TODO: [emi/sprint/bison] Find a way to reset controls. Old implementation throws Exception;
this.inProgress = false;
......
......@@ -12,6 +12,7 @@ import { Client } from '../../../services/api';
import { Session } from '../../../services/session';
import { ReCaptchaComponent } from '../../../modules/captcha/recaptcha/recaptcha.component';
import { ExperimentsService } from '../../experiments/experiments.service';
import { RouterHistoryService } from '../../../common/services/router-history.service';
@Component({
moduleId: module.id,
......@@ -19,11 +20,15 @@ import { ExperimentsService } from '../../experiments/experiments.service';
templateUrl: 'register.html',
})
export class RegisterForm {
@Input() referrer: string;
@Input() parentId: string = '';
@Output() done: EventEmitter<any> = new EventEmitter();
errorMessage: string = '';
twofactorToken: string = '';
hideLogin: boolean = false;
inProgress: boolean = false;
@Input() referrer: string;
captcha: string;
takenUsername: boolean = false;
usernameValidationTimeout: any;
......@@ -34,8 +39,6 @@ export class RegisterForm {
fbForm: FormGroup;
minds = window.Minds;
@Output() done: EventEmitter<any> = new EventEmitter();
@ViewChild('reCaptcha', { static: false }) reCaptcha: ReCaptchaComponent;
constructor(
......@@ -43,7 +46,8 @@ export class RegisterForm {
public client: Client,
fb: FormBuilder,
public zone: NgZone,
private experiments: ExperimentsService
private experiments: ExperimentsService,
private routerHistoryService: RouterHistoryService
) {
this.form = fb.group({
username: ['', Validators.required],
......@@ -53,6 +57,7 @@ export class RegisterForm {
tos: [false],
exclusive_promotions: [false],
captcha: [''],
previousUrl: this.routerHistoryService.getPreviousUrl(),
});
}
......@@ -85,10 +90,14 @@ export class RegisterForm {
}
this.form.value.referrer = this.referrer;
this.form.value.parentId = this.parentId;
this.inProgress = true;
let opts = { ...this.form.value };
this.client
.post('api/v1/register', this.form.value)
.post('api/v1/register', opts)
.then((data: any) => {
// TODO: [emi/sprint/bison] Find a way to reset controls. Old implementation throws Exception;
......
......@@ -22,6 +22,7 @@ import { AnalyticsService } from '../../../services/analytics';
import { MindsVideoComponent } from '../components/video/video.component';
import isMobileOrTablet from '../../../helpers/is-mobile-or-tablet';
import { ActivityService } from '../../../common/services/activity.service';
import { SiteService } from '../../../common/services/site.service';
export type MediaModalParams = {
redirectUrl?: string;
......@@ -118,7 +119,8 @@ export class MediaModalComponent implements OnInit, OnDestroy {
public analyticsService: AnalyticsService,
private overlayModal: OverlayModalService,
private router: Router,
private location: Location
private location: Location,
private site: SiteService
) {}
ngOnInit() {
......@@ -204,8 +206,14 @@ export class MediaModalComponent implements OnInit, OnDestroy {
this.isTablet =
isMobileOrTablet() && Math.min(screen.width, screen.height) >= 768;
let url = `${this.pageUrl}?ismodal=true`;
if (this.site.isProDomain) {
url = `/pro/${this.site.pro.user_guid}${url}`;
}
this.analyticsService.send('pageview', {
url: `${this.pageUrl}?ismodal=true`,
url,
});
// * LOCATION & ROUTING * -----------------------------------------------------------------------------------
......
......@@ -11,6 +11,7 @@ import { WireCreatorComponent } from '../../wire/creator/creator.component';
import { SessionsStorageService } from '../../../services/session-storage.service';
import { SiteService } from '../../../common/services/site.service';
import { BehaviorSubject, Subscription } from 'rxjs';
import { AnalyticsService } from '../../../services/analytics';
export type RouterLinkToType =
| 'home'
......@@ -55,7 +56,8 @@ export class ProChannelService implements OnDestroy {
protected modalService: OverlayModalService,
protected sessionStorage: SessionsStorageService,
protected router: Router,
protected site: SiteService
protected site: SiteService,
protected analytics: AnalyticsService
) {
this.listen();
}
......@@ -334,6 +336,10 @@ export class ProChannelService implements OnDestroy {
this.sessionStorage.destroy('pro::wire-modal::open');
})
.present();
this.analytics.send('pageview', {
url: `/pro/${this.currentChannel.guid}/wire?ismodal=true`,
});
}
pushMenuNavItems(navItems: Array<NavItems>, clean?: boolean) {
......
......@@ -22,7 +22,7 @@
</span>
<minds-form-register
[referrer]="referrerGuid"
[referrer]="referrer"
(done)="registered()"
></minds-form-register>
</ng-container>
......
......@@ -21,8 +21,8 @@ export class ProChannelLoginComponent {
return this.service.currentChannel.pro_settings;
}
get referrerGuid() {
return this.service.currentChannel.guid;
get referrer() {
return this.service.currentChannel.username;
}
constructor(
......
import { Inject, Injectable } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';
import { Client } from './api/client';
import { SiteService } from '../common/services/site.service';
@Injectable()
export class AnalyticsService {
private defaultPrevented: boolean = false;
static _(router: Router, client: Client) {
return new AnalyticsService(router, client);
static _(router: Router, client: Client, site: SiteService) {
return new AnalyticsService(router, client, site);
}
constructor(
@Inject(Router) public router: Router,
@Inject(Client) public client: Client
@Inject(Client) public client: Client,
@Inject(SiteService) public site: SiteService
) {
this.onRouterInit();
......@@ -39,8 +41,14 @@ export class AnalyticsService {
onRouteChanged(path) {
if (!this.defaultPrevented) {
let url = path;
if (this.site.isProDomain) {
url = `/pro/${this.site.pro.user_guid}${url}`;
}
this.send('pageview', {
url: path,
url,
referrer: document.referrer,
});
}
......
......@@ -121,7 +121,7 @@ export const MINDS_PROVIDERS: any[] = [
{
provide: AnalyticsService,
useFactory: AnalyticsService._,
deps: [Router, Client],
deps: [Router, Client, SiteService],
},
{
provide: Navigation,
......