This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
let student = { | |
name: 'Mike', | |
age: 23, | |
gender: 'Male', | |
department: 'English', | |
car: 'Honda' | |
}; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
(function(window) { | |
var s = document.createElement('script'); | |
s.type = 'text/javascript'; | |
s.async = true; | |
s.src = | |
'https://test-hosting-leifer.s3-us-west-2.amazonaws.com/sdk-test.js'; | |
var x = document.getElementsByTagName('script')[0]; | |
x.parentNode.insertBefore(s, x); | |
})(window); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const invalidHost = [ | |
'aoniqrgga', | |
'js-ezdmowa' | |
] | |
const URL = 'http://localhost:4200'; | |
var queryParams, lmBubble, lmBubbleCta, lmOverError, lmCancelBtn, lmContinueBtn, lmAgainBtn; | |
const styles = `.lm { | |
font-family: Arial, Helvetica, sans-serif; | |
background-color: white; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
(function () { | |
/** getElementById('btn-email') lo puedes dejar o cambiar por lo que quieres ejemplo getElementById('boton-call-to-action') **/ | |
/** En tu HTML ejemplo <button id="boton-call-to-action">Click</button> **/ | |
const btnEmail = document.querySelectorAll('.btn-call-action-form-custom'); | |
[...btnEmail].forEach((btn) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Injectable} from '@angular/core'; | |
import {HttpClient} from "@angular/common/http"; | |
import {Observable} from "rxjs"; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class LoginSService { | |
private url = 'http://localhost:3000' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Injectable} from '@angular/core'; | |
import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree} from '@angular/router'; | |
import {Observable} from 'rxjs'; | |
import {UserService} from './user.service'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class RolesGuard implements CanActivate { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Directive, Input, OnInit, TemplateRef, ViewContainerRef} from '@angular/core'; | |
import {RoleUser} from './app.component'; | |
import {UserService} from './user.service'; | |
@Directive({ | |
selector: '[appRole]' | |
}) | |
export class RoleDirective implements OnInit { | |
private currentUser: RoleUser; | |
private permissions = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
searchTenant(text) { | |
// debounce | |
return timer(100) | |
.pipe( | |
switchMap(() => { | |
// Check if username is available | |
return this.post(`check`, {domain: text}) | |
}) | |
); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tenantValidator(): AsyncValidatorFn { | |
return (control: AbstractControl): Observable<{ [key: string]: any } | null> => { | |
return this.searchTenant(control.value) | |
.pipe( | |
map(res => { | |
if (res.errors) { | |
return {tenantIdExists: false}; | |
} | |
}) | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.form = this.formBuilder.group({ | |
tenantId: [ | |
null, | |
Validators.compose( | |
[Validators.required, | |
Validators.minLength(3), | |
Validators.maxLength(15), | |
Validators.pattern('^[a-zA-Z0-9]+$')], | |
), | |
this.rest.tenantValidator() |