This file contains 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
/** | |
* Created by zevisert on 2017-03-27. | |
* This file merges mailgun validation functionality with jQueryValidationPlugin's surprisingly | |
* poor async validation customizability. Much of this code has been borrowed from | |
* * jQuery Validation remote method | |
* - https://github.com/jquery-validation/jquery-validation/blob/master/src/core.js#L1477 | |
* * Mailgun validator jquery plugin | |
* - https://github.com/mailgun/validator-demo/blob/master/mailgun_validator.js#L30 | |
* | |
* |
This file contains 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
function test_service(place, i) { | |
return fetch(`https://recollect.net/api/places/${place}/services/${i}`).then(response => { | |
if (response.ok){ | |
return response.json(); | |
} else return {}; | |
}); | |
} | |
function discover_services(place) { | |
let existing_services = {}; |
This file contains 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
@Injectable() | |
export class AuthService { | |
... | |
validate(pattern: string, route: string): void { | |
let body: AuthBody = { type: "Anonymous", payload: pattern }; | |
// Fire off a request to the server to see if the pattern entered is valid | |
this.postAuth(body) |
This file contains 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
@Injectable() | |
export class BlogService { | |
private allPostsUrl = "api/posts"; | |
private singlePostUrl = "api/post/"; | |
private cachedPosts: PostData[]; | |
private cachedPromise: Promise<PostData[]>; | |
// Angular2-jwt nicely attaches the token to every request for us | |
constructor(@Inject(AuthHttp) private http: AuthHttp) { } |
This file contains 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
@Component({...}) | |
export class PostComponent implements OnInit { | |
post: Post; | |
constructor( | |
@Inject(BlogService) private blogService: BlogService, | |
@Inject(ActivatedRoute) private activatedRoute: ActivatedRoute | |
) { } |
NewerOlder