diff --git a/dist/app/directives/login/login.component.d.ts b/dist/app/directives/login/login.component.d.ts index 2d48936f..2ebcc71c 100644 --- a/dist/app/directives/login/login.component.d.ts +++ b/dist/app/directives/login/login.component.d.ts @@ -4,7 +4,7 @@ import { FormBuilder, Control, ControlGroup } from '@angular/common'; import { TwAPIService } from './../../services/twapi.service'; export declare class LoginComponent implements OnInit { private translate; - private twapi; + protected twapi: TwAPIService; private builder; loginForm: ControlGroup; email: Control; diff --git a/dist/app/directives/login/login.component.js.map b/dist/app/directives/login/login.component.js.map index fd8703e4..569030b5 100644 --- a/dist/app/directives/login/login.component.js.map +++ b/dist/app/directives/login/login.component.js.map @@ -1 +1 @@ -{"version":3,"file":"login.component.js","sourceRoot":"","sources":["login.component.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,qBAAwD,eAAe,CAAC,CAAA;AACxE,8BAA2G,6BAA6B,CAAC,CAAA;AACzI,uBAA+E,iBAAiB,CAAC,CAAA;AACjG,8BAA2B,gCAC3B,CAAC,CAD0D;AAC3D,qBAA6C,eAAe,CAAC,CAAA;AAC7D,uBAAqC,2BAA2B,CAAC,CAAA;AACjE,iCAAgC,uBAAuB,CAAC,CAAA;AACxD,2BAA0B,6BAA6B,CAAC,CAAA;AAexD;IAYE;;;;;OAKG;IACH,wBAAoB,SAA2B,EACrC,KAAmB,EAAU,OAAoB;QADvC,cAAS,GAAT,SAAS,CAAkB;QACrC,UAAK,GAAL,KAAK,CAAc;QAAU,YAAO,GAAP,OAAO,CAAa;QAd3D,kBAAa,GAAW,KAAK,CAAC;QAC9B,iBAAY,GAAG,KAAK,CAAC;QACrB,UAAK,GAAG,KAAK,CAAC;QACJ,eAAU,GAAG,IAAI,mBAAY,EAAE,CAAC;QAChC,iBAAY,GAAG,IAAI,mBAAY,EAAE,CAAC;QAClC,eAAU,GAAG,IAAI,mBAAY,EAAE,CAAC;QAWxC,iBAAiB;QAClB,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAC/B,SAAS,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gBAE9B,MAAM,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;oBACnB,KAAK,GAAG;wBACN,KAAI,CAAC,YAAY,GAAG,IAAI,CAAC;wBACzB,KAAK,CAAC;oBACR;wBACE,KAAI,CAAC,KAAK,GAAG,IAAI,CAAC;wBAClB,KAAK,CAAC;gBACV,CAAC;YACH,CAAC,CACF,CAAC;QACJ,CAAC;QAAA,IAAI,CAAA,CAAC;YACJ,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAED,iCAAQ,GAAR;IACA,CAAC;IAlED;QAAC,aAAM,EAAE;;sDAAA;IACT;QAAC,aAAM,EAAE;;wDAAA;IACT;QAAC,aAAM,EAAE;;sDAAA;IAtBX;QAAC,gBAAS,CAAC;YACT,QAAQ,EAAE,WAAW;YACrB,WAAW,EAAE,2CAA2C;YACxD,SAAS,EAAE,CAAC,0CAA0C,CAAC;YACvD,KAAK,EAAE,CAAC,6BAAa,CAAC;YACtB,SAAS,EAAE,CAAC,4BAAY,EAAE,qBAAc,CAAC;YACzC,UAAU,EAAE,CAAC,wBAAe,EAAE,6BAAoB,CAAC;SACpD,CAAC;;sBAAA;IAiFF,qBAAC;AAAD,CAAC,AA5ED,IA4EC;AA5EY,sBAAc,iBA4E1B,CAAA","sourcesContent":["import { Component, Output, OnInit, EventEmitter } from '@angular/core';\nimport {TRANSLATE_PROVIDERS, TranslateService, TranslatePipe, TranslateLoader, TranslateStaticLoader} from 'ng2-translate/ng2-translate';\nimport {FORM_DIRECTIVES, FormBuilder, Control, ControlGroup, Validators} from '@angular/common';\nimport {TwAPIService} from './../../services/twapi.service'\nimport {Http, HTTP_PROVIDERS, Headers} from '@angular/http';\nimport { MD_BUTTON_DIRECTIVES } from '@angular2-material/button';\nimport { GlobalValidator } from './../global-validator';\nimport { GAService } from './../../services/ga.service';\n\n\n@Component({\n selector: 'app-login',\n templateUrl: 'app/directives/login/login.component.html',\n styleUrls: ['app/directives/login/login.component.css'],\n pipes: [TranslatePipe],\n providers: [TwAPIService, HTTP_PROVIDERS],\n directives: [FORM_DIRECTIVES, MD_BUTTON_DIRECTIVES]\n})\n/**\n * Login component. Provides a login form with controlled and\n * emits a User ($event userLogged) on successful login.\n */\nexport class LoginComponent implements OnInit {\n\n loginForm: ControlGroup;\n email:Control;\n password: Control;\n submitAttempt:boolean = false;\n credientials = false;\n error = false;\n @Output() userLogged = new EventEmitter();\n @Output() loginAttempt = new EventEmitter();\n @Output() loginError = new EventEmitter();\n\n /**\n * Constructor w/ service injection\n * @param {TranslateService} private translate [description]\n * @param {TwAPIService} private twapi [description]\n * @param {FormBuilder} private builder [description]\n */\n constructor(private translate: TranslateService, \n private twapi: TwAPIService, private builder: FormBuilder) { \n \t\n //Lang definition\n\t translate.setDefaultLang('en');\n\t translate.use('en');\n\n //Form constraints\n this.password = new Control('', Validators.required);\n this.email = new Control('', Validators.compose([Validators.required, GlobalValidator.mailFormat]));\n\n this.loginForm = builder.group({\n email: this.email,\n password: this.password\n });\n }\n\n /**\n * Form submit\n * @param {string}} user [description]\n */\n onSubmit(user:{email:string, password:string}){\n\n this.loginAttempt.emit(true);\n\n this.submitAttempt = true;\n this.error = false;\n this.credientials = false;\n\n //Form constraints are ok\n if(this.loginForm.valid){\n this.twapi.login(user.email, user.password).then(\n res => { \n this.userLogged.emit(res);\n GAService.event('CTA', 'LOGIN', 'SUCCESS');\n }, \n err => {\n GAService.event('CTA', 'LOGIN', 'FAIL');\n this.loginAttempt.emit(false);\n\n switch (err.status) {\n case 401:\n this.credientials = true;\n break;\n default:\n this.error = true;\n break;\n }\n }\n );\n }else{\n this.loginAttempt.emit(false);\n }\n }\n\n ngOnInit() {\n }\n\n}\n"]} \ No newline at end of file +{"version":3,"file":"login.component.js","sourceRoot":"","sources":["login.component.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,qBAAwD,eAAe,CAAC,CAAA;AACxE,8BAA2G,6BAA6B,CAAC,C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AAE,2CAA2C;YACxD,SAAS,EAAE,CAAC,0CAA0C,CAAC;YACvD,KAAK,EAAE,CAAC,6BAAa,CAAC;YACtB,SAAS,EAAE,CAAC,4BAAY,EAAE,qBAAc,CAAC;YACzC,UAAU,EAAE,CAAC,wBAAe,EAAE,6BAAoB,CAAC;SACpD,CAAC;;sBAAA;IAiFF,qBAAC;AAAD,CAAC,AA5ED,IA4EC;AA5EY,sBAAc,iBA4E1B,CAAA","sourcesContent":["import { Component, Output, OnInit, EventEmitter } from '@angular/core';\nimport {TRANSLATE_PROVIDERS, TranslateService, TranslatePipe, TranslateLoader, TranslateStaticLoader} from 'ng2-translate/ng2-translate';\nimport {FORM_DIRECTIVES, FormBuilder, Control, ControlGroup, Validators} from '@angular/common';\nimport {TwAPIService} from './../../services/twapi.service'\nimport {Http, HTTP_PROVIDERS, Headers} from '@angular/http';\nimport { MD_BUTTON_DIRECTIVES } from '@angular2-material/button';\nimport { GlobalValidator } from './../global-validator';\nimport { GAService } from './../../services/ga.service';\n\n\n@Component({\n selector: 'app-login',\n templateUrl: 'app/directives/login/login.component.html',\n styleUrls: ['app/directives/login/login.component.css'],\n pipes: [TranslatePipe],\n providers: [TwAPIService, HTTP_PROVIDERS],\n directives: [FORM_DIRECTIVES, MD_BUTTON_DIRECTIVES]\n})\n/**\n * Login component. Provides a login form with controlled and\n * emits a User ($event userLogged) on successful login.\n */\nexport class LoginComponent implements OnInit {\n\n loginForm: ControlGroup;\n email:Control;\n password: Control;\n submitAttempt:boolean = false;\n credientials = false;\n error = false;\n @Output() userLogged = new EventEmitter();\n @Output() loginAttempt = new EventEmitter();\n @Output() loginError = new EventEmitter();\n\n /**\n * Constructor w/ service injection\n * @param {TranslateService} private translate [description]\n * @param {TwAPIService} private twapi [description]\n * @param {FormBuilder} private builder [description]\n */\n constructor(private translate: TranslateService, \n protected twapi: TwAPIService, private builder: FormBuilder) { \n \t\n //Lang definition\n\t translate.setDefaultLang('en');\n\t translate.use('en');\n\n //Form constraints\n this.password = new Control('', Validators.required);\n this.email = new Control('', Validators.compose([Validators.required, GlobalValidator.mailFormat]));\n\n this.loginForm = builder.group({\n email: this.email,\n password: this.password\n });\n }\n\n /**\n * Form submit\n * @param {string}} user [description]\n */\n onSubmit(user:{email:string, password:string}){\n\n this.loginAttempt.emit(true);\n\n this.submitAttempt = true;\n this.error = false;\n this.credientials = false;\n\n //Form constraints are ok\n if(this.loginForm.valid){\n this.twapi.login(user.email, user.password).then(\n res => { \n this.userLogged.emit(res);\n GAService.event('CTA', 'LOGIN', 'SUCCESS');\n }, \n err => {\n GAService.event('CTA', 'LOGIN', 'FAIL');\n this.loginAttempt.emit(false);\n\n switch (err.status) {\n case 401:\n this.credientials = true;\n break;\n default:\n this.error = true;\n break;\n }\n }\n );\n }else{\n this.loginAttempt.emit(false);\n }\n }\n\n ngOnInit() {\n }\n\n}\n"]} \ No newline at end of file diff --git a/dist/app/services/twapi.service.d.ts b/dist/app/services/twapi.service.d.ts index 76ad0877..3b102a6b 100644 --- a/dist/app/services/twapi.service.d.ts +++ b/dist/app/services/twapi.service.d.ts @@ -136,6 +136,12 @@ export declare class TwAPIService { * @return {Promise} */ login(email: string, password: string): Promise; + /** + * Get an user using his API key + * @param {string} key [description] + * @return {Promise} [description] + */ + getUser(key: string): Promise; /** * Registers a new user * @param {string} email diff --git a/dist/app/services/twapi.service.js b/dist/app/services/twapi.service.js index 1d92492d..f0d60e23 100644 --- a/dist/app/services/twapi.service.js +++ b/dist/app/services/twapi.service.js @@ -39,7 +39,6 @@ var TwAPIService = (function () { return this.http.put(this.baseUrl + "users", JSON.stringify(creds), TwAPIService.options) .map(function (res) { return model_factory_1.ModelFactory.buildUser(res.json()); }) .toPromise().then(function (res) { - console.log("works"); ga_service_1.GAService.event('API', 'LOGIN'); TwAPIService.apikey = res.key; TwAPIService.headers.delete('X-API-KEY'); @@ -48,6 +47,24 @@ var TwAPIService = (function () { return res; }, function (err) { return _this.handleError(err); }); }; + /** + * Get an user using his API key + * @param {string} key [description] + * @return {Promise} [description] + */ + TwAPIService.prototype.getUser = function (key) { + var _this = this; + TwAPIService.apikey = key; + TwAPIService.headers.delete('X-API-KEY'); + TwAPIService.headers.append('X-API-KEY', TwAPIService.apikey); + return this.http.get(this.baseUrl + "users", TwAPIService.options) + .map(function (res) { return model_factory_1.ModelFactory.buildUser(res.json()); }) + .toPromise().then(function (res) { + ga_service_1.GAService.event('API', 'AUTOLOGIN'); + TwAPIService.user = res; + return res; + }, function (err) { return _this.handleError(err); }); + }; /** * Registers a new user * @param {string} email diff --git a/dist/app/services/twapi.service.js.map b/dist/app/services/twapi.service.js.map index 494bb47a..22a836a9 100644 --- a/dist/app/services/twapi.service.js.map +++ b/dist/app/services/twapi.service.js.map @@ -1 +1 @@ -{"version":3,"file":"twapi.service.js","sourceRoot":"","sources":["twapi.service.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,qBAA2B,eAAe,CAAC,CAAA;AAC3C,qBAAyE,eAAe,CAAC,CAAA;AAEzF,4BAAoC,yBAAyB,CAAC,CAAA;AAE9D,8BAA8B,2BAA2B,CAAC,CAAA;AAE1D,2BAA0B,cAAc,CAAC,CAAA;AAEzC,QAAO,6BAA6B,CAAC,CAAA;AAOrC;IAsJC;;;OAGG;IACH,sBAAoB,IAAU;QAAV,SAAI,GAAJ,IAAI,CAAM;QARtB,YAAO,GAAU,2BAA2B,CAAC;QAUpD,IAAI,CAAC,YAAY,EAAE,CAAC;IACrB,CAAC;IAEa,sBAAS,GAAvB;QACC,YAAY,CAAC,IAAI,GAAG,SAAS,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACH,4BAAK,GAAL,UAAM,KAAa,EAAE,QAAgB;QAArC,iBAsBC;QApBA,IAAI,KAAK,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;QACjD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACnB,IAAI,CAAC,OAAO,GAAG,OAAO,EACtB,IAAI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AAG,CAAC;IAC/B,iCAAoB,GAAG,GAAG,CAAC;IAC3B,uCAA0B,GAAG,GAAG,CAAC;IACjC,sDAAyC,GAAG,GAAG,CAAC,CAAwB,UAAU;IAClF,sCAAyB,GAAG,GAAG,CAAC,CAAwC,UAAU;IAClF,+BAAkB,GAAG,GAAG,CAAC,CAA+C,UAAU;IAClF,8BAAiB,GAAG,GAAG,CAAC,CAAgD,UAAU;IAClF,iDAAoC,GAAG,GAAG,CAAC;IAS5D,qCAAqC;IACtB,oBAAO,GAAY,IAAI,cAAO,CAAC,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC,CAAC;IACvE,oBAAO,GAAmB,IAAI,qBAAc,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,OAAO,EAAE,CAAC,CAAC;IAGjF,sBAAS,GAAG,YAAY,CAAA;IAxJvC;QAAC,iBAAU,EAAE;;oBAAA;IA+lBb,mBAAC;AAAD,CAAC,AA1lBD,IA0lBC;AA1lBY,oBAAY,eA0lBxB,CAAA","sourcesContent":["import { Injectable } from '@angular/core';\nimport { Http, HTTP_PROVIDERS, RequestOptions, Headers, Response } from '@angular/http';\nimport { User } from './../models/user.model';\nimport { Watch, WatchAction } from './../models/watch.model';\nimport { Measure, MeasureStatus } from './../models/measure.model';\nimport { ModelFactory } from './../models/model.factory';\nimport { BlogPost } from './../models/blog-post.model'\nimport { GAService } from './ga.service';\n\nimport 'rxjs/add/operator/toPromise';\n\n@Injectable()\n/**\n * Exposes the Toolwatch API.\n * Returns promeses on domain objects\n */\nexport class TwAPIService {\n\n\t/**\n\t * All the HTTP code used by the toolwatch API are defined here.\n\t * Http codes can be to refine the error types\n\t */\n\tpublic static HTTP_CONTINUE = 100;\n public static HTTP_SWITCHING_PROTOCOLS = 101;\n public static HTTP_PROCESSING = 102; // RFC2518\n\n // Success\n\n /**\n * The request has succeeded\n */\n public static HTTP_OK = 200;\n\n /**\n * The server successfully created a new resource\n */\n public static HTTP_CREATED = 201;\n public static HTTP_ACCEPTED = 202;\n public static HTTP_NON_AUTHORITATIVE_INFORMATION = 203;\n\n /**\n * The server successfully processed the request, though no content is returned\n */\n public static HTTP_NO_CONTENT = 204;\n public static HTTP_RESET_CONTENT = 205;\n public static HTTP_PARTIAL_CONTENT = 206;\n public static HTTP_MULTI_STATUS = 207; // RFC4918\n public static HTTP_ALREADY_REPORTED = 208; // RFC5842\n public static HTTP_IM_USED = 226; // RFC3229\n\n // Redirection\n\n public static HTTP_MULTIPLE_CHOICES = 300;\n public static HTTP_MOVED_PERMANENTLY = 301;\n public static HTTP_FOUND = 302;\n public static HTTP_SEE_OTHER = 303;\n\n /**\n * The resource has not been modified since the last request\n */\n public static HTTP_NOT_MODIFIED = 304;\n public static HTTP_USE_PROXY = 305;\n public static HTTP_RESERVED = 306;\n public static HTTP_TEMPORARY_REDIRECT = 307;\n public static HTTP_PERMANENTLY_REDIRECT = 308; // RFC7238\n\n // Client Error\n\n /**\n * The request cannot be fulfilled due to multiple errors\n */\n public static HTTP_BAD_REQUEST = 400;\n\n /**\n * The user is unauthorized to access the requested resource\n */\n public static HTTP_UNAUTHORIZED = 401;\n public static HTTP_PAYMENT_REQUIRED = 402;\n\n /**\n * The requested resource is unavailable at this present time\n */\n public static HTTP_FORBIDDEN = 403;\n\n /**\n * The requested resource could not be found\n *\n * Note: This is sometimes used to mask if there was an UNAUTHORIZED (401) or\n * FORBIDDEN (403) error, for security reasons\n */\n public static HTTP_NOT_FOUND = 404;\n\n /**\n * The request method is not supported by the following resource\n */\n public static HTTP_METHOD_NOT_ALLOWED = 405;\n\n /**\n * The request was not acceptable\n */\n public static HTTP_NOT_ACCEPTABLE = 406;\n public static HTTP_PROXY_AUTHENTICATION_REQUIRED = 407;\n public static HTTP_REQUEST_TIMEOUT = 408;\n\n /**\n * The request could not be completed due to a conflict with the current state\n * of the resource\n */\n public static HTTP_CONFLICT = 409;\n public static HTTP_GONE = 410;\n public static HTTP_LENGTH_REQUIRED = 411;\n public static HTTP_PRECONDITION_FAILED = 412;\n public static HTTP_REQUEST_ENTITY_TOO_LARGE = 413;\n public static HTTP_REQUEST_URI_TOO_LONG = 414;\n public static HTTP_UNSUPPORTED_MEDIA_TYPE = 415;\n public static HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = 416;\n public static HTTP_EXPECTATION_FAILED = 417;\n public static HTTP_I_AM_A_TEAPOT = 418; // RFC2324\n public static HTTP_UNPROCESSABLE_ENTITY = 422; // RFC4918\n public static HTTP_LOCKED = 423; // RFC4918\n public static HTTP_FAILED_DEPENDENCY = 424; // RFC4918\n public static HTTP_RESERVED_FOR_WEBDAV_ADVANCED_COLLECTIONS_EXPIRED_PROPOSAL = 425; // RFC2817\n public static HTTP_UPGRADE_REQUIRED = 426; // RFC2817\n public static HTTP_PRECONDITION_REQUIRED = 428; // RFC6585\n public static HTTP_TOO_MANY_REQUESTS = 429; // RFC6585\n public static HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = 431; // RFC6585\n\n // Server Error\n\n /**\n * The server encountered an unexpected error\n *\n * Note: This is a generic error message when no specific message\n * is suitable\n */\n public static HTTP_INTERNAL_SERVER_ERROR = 500;\n\n /**\n * The server does not recognise the request method\n */\n public static HTTP_NOT_IMPLEMENTED = 501;\n public static HTTP_BAD_GATEWAY = 502;\n public static HTTP_SERVICE_UNAVAILABLE = 503;\n public static HTTP_GATEWAY_TIMEOUT = 504;\n public static HTTP_VERSION_NOT_SUPPORTED = 505;\n public static HTTP_VARIANT_ALSO_NEGOTIATES_EXPERIMENTAL = 506; // RFC2295\n public static HTTP_INSUFFICIENT_STORAGE = 507; // RFC4918\n public static HTTP_LOOP_DETECTED = 508; // RFC5842\n public static HTTP_NOT_EXTENDED = 510; // RFC2774\n public static HTTP_NETWORK_AUTHENTICATION_REQUIRED = 511;\n\n public static user:User;\n private static time:{\n \tsyncDate:Date,\n \tsyncAnchor:number,\n \toffset:number\n }\n\n\t//Defines headers and request options\n\tprivate static headers: Headers = new Headers({ 'Content-Type': 'application/json' });\n\tprivate static options: RequestOptions = new RequestOptions({ headers: TwAPIService.headers });\n\t\n\tprivate baseUrl:string = \"https://toolwatch.io/api/\";\n\tpublic static assetsUrl = \"app/assets\"\n\tprivate static apikey:string;\n\n\t/**\n\t * Inject http service\n\t * @param {Http} private http \n\t */\n\tconstructor(private http: Http) {\n\n\t\tthis.accurateTime();\n\t}\n\n\tpublic static resetTime(){\n\t\tTwAPIService.time = undefined;\n\t}\n\n\t/**\n\t * Log a user using email and password\n\t * @param {string} email \n\t * @param {string} password\n\t * @return {Promise} \n\t */\n\tlogin(email: string, password: string): Promise {\n\n\t\tlet creds = { email: email, password: password };\n\t\treturn this.http.put(\n\t\t\tthis.baseUrl + \"users\", \n\t\t\tJSON.stringify(creds), \n\t\t\tTwAPIService.options\n\t\t)\n\t\t.map((res) => { return ModelFactory.buildUser(res.json()); })\n\t\t.toPromise().then(\n\t\t\tres => {\n console.log(\"works\");\n\n GAService.event('API', 'LOGIN');\n\t\t\t\tTwAPIService.apikey = res.key;\n\t\t\t\tTwAPIService.headers.delete('X-API-KEY');\n\t\t\t\tTwAPIService.headers.append('X-API-KEY', TwAPIService.apikey);\n\t\t\t\tTwAPIService.user = res;\n\t\t\t\treturn res;\n\t\t\t},\n err => this.handleError(err)\n\t\t)\n\t} \n\n\t/**\n\t * Registers a new user\n\t * @param {string} email \n\t * @param {string} password\n\t * @param {string} name \n\t * @param {string} lastname\n\t * @param {string} country \n\t * @return {Promise} \n\t */\n\tsignup(email: string, password: string, name?: string, lastname?: string, country?: string): Promise {\n\n\t\treturn this.http.post(\n\t\t\tthis.baseUrl + \"users\",\n\t\t\tJSON.stringify({\n\t\t\t\temail: email, \n\t\t\t\tpassword: password,\n\t\t\t\tname: name,\n\t\t\t\tlastname: lastname,\n\t\t\t\tcountry:country\n\t\t\t}),\n\t\t\tTwAPIService.options\n\t\t)\n\t\t.map((res) => { return ModelFactory.buildUser(res.json()); })\n\t\t.toPromise().then(\n\t\t\tres => {\n GAService.event('API', 'SIGNUP');\n return res;\n }\n\t\t);\n\t}\n\n\t/**\n\t * Deletes the account currently logged in.\n\t * @return {Promise}\n\t */\n\tdeleteAccount():Promise{\n\n\t\treturn this.http.delete(\n\t\t\tthis.baseUrl + \"users\",\n\t\t\tTwAPIService.options\n\t\t).toPromise().then(\n\t\t\tresponse => {\n GAService.event('API', 'DELETE_ACCOUNT');\n return true;\n }\n\t\t).catch(this.handleError);\n\t}\n\n\tgetWatches(): Promise{\n\t\treturn this.http.get(\n\t\t\tthis.baseUrl + \"watches\",\n\t\t\tTwAPIService.options)\n\t\t.map((res) => { return ModelFactory.buildWatches(res.json()); })\n\t\t.toPromise().then(\n\t\t\tres => {\n GAService.event('API', 'WATCHES', 'GET');\n return res\n }\n\t\t);\n\t}\n\n\t/**\n\t * Update or insert a watch\n\t * @param {Watch} watch\n\t * @return {Promise} \n\t */\n\tupsertWatch(watch: Watch): Promise {\n\n\t\tif(watch.id == null){\n\t\t\treturn this.insertWatch(watch);\n\t\t}else{\n\t\t\treturn this.updateWatch(watch);\n\t\t}\n\t}\n\n\t/**\n\t * Deletes a watch and update the user accordingly\n\t * @param {User} user \n\t * @param {Watch} watch \n\t * @return {Promise} \n\t */\n\tdeleteWatch(user:User, watch:Watch):Promise{\n\t\tlet deleteOptions = new RequestOptions({ headers: TwAPIService.headers });\n\t\tdeleteOptions.body = JSON.stringify({ watchId: watch.id });\n\n\t\treturn this.http.delete(\n\t\t\tthis.baseUrl + \"watches\",\n\t\t\tdeleteOptions\n\t\t).toPromise().then(\n\t\t\tresponse => {\n\n\t\t\t\tuser.watches = user.watches.filter(\n\t\t\t\t\tfunction(filter: Watch) {\n\t\t\t\t\t\treturn filter.id != watch.id;\n\t\t\t\t\t}\n\t\t\t\t);\n\n GAService.event('API', 'WATCHES', 'DELETE');\n\n\t\t\t\treturn user;\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Insert or update a measure and the related watch\n\t * @param {Watch} watch \n\t * @param {Measure} measure\n\t * @return {Promise} \n\t */\n\tupsertMeasure(watch: Watch, measure: Measure): Promise {\n\t\tif(measure.id == null){\n\t\t\treturn this.insertMeasure(watch, measure);\n\t\t}else{\n\t\t\treturn this.updateMeasure(watch, measure);\n\t\t}\n\t}\n\n\t/**\n\t * Delete a measure and the update the related watch\n\t * @param {Watch} watch \n\t * @param {Measure} measure\n\t * @return {Promise} \n\t */\n\tdeleteMeasure(watch: Watch, measure: Measure): Promise {\n\n\t\tlet deleteOptions = new RequestOptions({ headers: TwAPIService.headers });\n\t\tdeleteOptions.body = JSON.stringify({measureId:measure.id});\n\n\t\treturn this.http.delete(\n\t\t\tthis.baseUrl + \"measures\",\n\t\t\tdeleteOptions\n\t\t).toPromise().then(\n\t\t\tresponse => {\n\n\t\t\t\twatch.measures = watch.measures.filter(\n\t\t\t\t\tfunction(filter: Measure) {\n\t\t\t\t\t\treturn filter.id != measure.id;\n\t\t\t\t\t}\n\t\t\t\t);\n\n GAService.event('API', 'MEASURE', 'DELETE');\n\n\t\t\t\treturn watch;\n\t\t\t}\n\t\t).catch(this.handleError);\n\t}\n\n\tgetBlogPosts(): Promise{\n\t\treturn this.http.get(\n\t\t\t\"https://blog.toolwatch.io/?json=1\"\n\t\t)\n\t\t.map((res) => { return ModelFactory.buildPosts(res.json()); })\n\t\t.toPromise().then(\n\t\t\tres => {\n GAService.event('API', 'BLOG', 'GET');\n return res\n }\n\t\t);\n\t}\n\n\t/**\n\t * Return known brands\n\t * @return {Promise} \n\t */\n\tgetBrands(): Promise<[{ name: string, icon: string, models:string}]> {\n\t\treturn this.http.get(\n\t\t\tTwAPIService.assetsUrl + '/json/watch-brand.json')\n\t\t.map(res => res.json())\n\t\t.toPromise().then(\n\t\t\tbrands => {\n GAService.event('API', 'BRANDS', 'GET');\n return brands;\n }\n\t\t);\n\t}\n\n\t/**\n\t * Returns model of a given brand\n\t * @param {string} brand\n\t * @return {Promise} \n\t */\n\tgetModels(brand:string): Promise<[string]> {\n\t\treturn this.http.get(\n\t\t\tTwAPIService.assetsUrl + '/json/watch-models/' + brand + \".json\")\n\t\t\t.map(res => res.json())\n\t\t\t.toPromise().then(\n\t\t\tmodels => {\n GAService.event('API', 'MODELS', 'GET');\n return models\n }\n\t\t);\n\t}\n\n\t/**\n\t * Gets the previously computed offset\n\t * @return {number} [description]\n\t */\n\tgetOffsetTime():number{\n\t\treturn TwAPIService.time.offset;\n\t}\n\n\t/**\n\t * Retrieve atomic clock time adjusted for network latency\n\t * @param {()=>void} statusCallback Called at each partial complete\n\t * @param {number = 0} precison How many calls we want to aveage\n\t * @return {Promise} \n\t */\n\taccurateTime(statusCallback?:()=>void, \n\t\tprecison:number = 10): Promise{\n\n GAService.event('API', 'TIME', 'GET');\n\n\n\t\t//If we aren't already sync'ed\n\t\tif(TwAPIService.time === undefined){\n\t\t\t//Stores each Promise in array\n\t\t\tlet promises:Promise[] = [];\n\t\t\tfor (var i = 0; i < precison; ++i) {\n\t\t\t\tpromises.push(this.fetchTime(statusCallback));\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Promise.all() is the Promise equivalent of thread.join().\n\t\t\t * It'll wait for all promises to be received. \n\t\t\t *\n\t\t\t * Returns a date adjusted w/ the median offset between \n\t\t\t * atomic clock and js time. \n\t\t\t * The offset received in each promise also accounts for\n\t\t\t * the network roundtrip time.\n\t\t\t */\n\t\t\treturn Promise.all(promises).then((results:any[]) => {\n\t\t\t\tresults.sort(function(a: any, b: any) { return a - b; });\n\n\t\t\t\tlet half: number = Math.floor(results.length / 2);\n\t\t\t\tlet medianOffset;\n\n\t\t\t\tif (results.length % 2) {\n\t\t\t\t\tmedianOffset = results[half];\n\t\t\t\t} else {\n\t\t\t\t\tmedianOffset = (results[half - 1] + results[half]) / 2.0;\n\t\t\t\t}\n\n\t\t\t\tTwAPIService.time = {\n\t\t\t\t\tsyncDate: new Date(Date.now() - medianOffset),\n\t\t\t\t\tsyncAnchor: window.performance.now(),\n\t\t\t\t\toffset:medianOffset\n\t\t\t\t};\n\n\t\t\t\tconsole.log(TwAPIService.time);\n\n\t\t\t\treturn TwAPIService.time.syncDate;\n\t\t\t});\n\t\t//Only compute the difference from last time;\n\t\t}else{\n\n\t\t\tTwAPIService.time.syncDate = new Date(\n\t\t\t\tTwAPIService.time.syncDate.getTime() +\n\t\t\t\twindow.performance.now() - TwAPIService.time.syncAnchor\n\t\t\t);\n\t\t\t\n\t\t\tTwAPIService.time.syncAnchor = window.performance.now();\n\n\t\t\treturn new Promise(\n\t\t\t\t(resolve, reject) => { \n\t\t\t\t\tconsole.log(TwAPIService.time);\n\t\t\t\t\tresolve(TwAPIService.time.syncDate); \n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Fetch offset between atomic clock and js time\n\t * @param {() => void} statusCallback\n\t */\n\tprivate fetchTime(statusCallback?: () => void)\n\t\t: Promise {\n\n\t\tlet beforeTime: number = window.performance.now();\n\t\treturn this.http.get(\n\t\t\tthis.baseUrl + \"time\",\n\t\t\tTwAPIService.options).toPromise().then(\n\t\t\tresponse => {\n\n\t\t\t\tif (statusCallback !== undefined){\n\t\t\t\t\tstatusCallback();\n\t\t\t\t}\n\n\t\t\t\tlet now: number = window.performance.now();\n\t\t\t\tlet timeDiff = (now - beforeTime) / 2;\n\t\t\t\tlet serverTime = response.json().time - timeDiff;\n\t\t\t\treturn Date.now() - serverTime;\n\t\t\t}\n\t\t).catch(this.handleError);\n\t}\n\n\t/**\n\t * Update a measure and the watch it belongs to\n\t * @param {Watch} watch \n\t * @param {Measure} measure\n\t * @return {Promise} \n\t */\n\tprivate updateMeasure(watch: Watch, measure: Measure): Promise {\n\t\treturn this.http.put(\n\t\t\tthis.baseUrl + \"measures\",\n\t\t\tJSON.stringify({\n\t\t\t\tmeasureId: measure.id,\n\t\t\t\treferenceTime: measure.accuracyReferenceTime,\n\t\t\t\tuserTime: measure.accuracyUserTime\n\t\t\t}),\n\t\t\tTwAPIService.options\n\t\t).toPromise().then(\n\t\t\tresponse => {\n GAService.event('API', 'MEASURE', 'SECOND');\n\t\t\t\tlet json = response.json().result;\n\t\t\t\tmeasure.addAccuracy(json.accuracy, json.accuracyAge, json.percentile);\n\t\t\t\twatch.upsertMeasure(measure);\n\t\t\t\twatch.next = WatchAction.Measure;\n\t\t\t\treturn watch;\n\t\t\t}\n\t\t).catch(this.handleError);\n\t}\n\n\t/**\n\t * Insert a measure and the watch it belongs to\n\t * @param {Watch} watch \n\t * @param {Measure} measure\n\t * @return {Promise} \n\t */\n\tprivate insertMeasure(watch: Watch, measure: Measure): Promise {\n\t\treturn this.http.post(\n\t\t\tthis.baseUrl + \"measures\",\n\t\t\tJSON.stringify({\n\t\t\t\twatchId: watch.id,\n\t\t\t\treferenceTime: measure.measureReferenceTime,\n\t\t\t\tuserTime: measure.measureUserTime\n\t\t\t}),\n\t\t\tTwAPIService.options\n\t\t).toPromise().then(\n\t\t\tresponse => {\n GAService.event('API', 'MEASURE', 'FIRST');\n\t\t\t\tmeasure.id = response.json().measureId;\n\t\t\t\twatch.measures.push(measure);\n\t\t\t\treturn watch;\n\t\t\t}\n\t\t).catch(this.handleError);\n\t}\n\n\t/**\n\t * Insert a watch\n\t * @param {Watch} watch\n\t * @return {Promise} \n\t */\n\tprivate insertWatch(watch: Watch):Promise{\n\t\treturn this.http.post(\n\t\t\tthis.baseUrl + \"watches\",\n\t\t\tJSON.stringify({\n\t\t\t\tbrand: watch.brand,\n\t\t\t\tname:watch.name,\n\t\t\t\tyearOfBuy:watch.yearOfBuy,\n\t\t\t\tserial: watch.serial,\n\t\t\t\tcaliber:watch.caliber\n\t\t\t}),\n\t\t\tTwAPIService.options\n\t\t).toPromise().then(\n\t\t\tresponse => {\n\t\t\t\twatch.id = response.json().id;\n GAService.event('API', 'WATCH', 'PUT');\n\t\t\t\treturn watch;\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Update a watch\n\t * @param {Watch} watch\n\t * @return {Promise} \n\t */\n\tprivate updateWatch(watch: Watch): Promise {\n\t\treturn this.http.put(\n\t\t\tthis.baseUrl + \"watches\",\n\t\t\tJSON.stringify({\n\t\t\t\tid: watch.id,\n\t\t\t\tbrand: watch.brand,\n\t\t\t\tname: watch.name,\n\t\t\t\tyearOfBuy: watch.yearOfBuy,\n\t\t\t\tserial: watch.serial,\n\t\t\t\tcaliber: watch.caliber\n\t\t\t}),\n\t\t\tTwAPIService.options\n\t\t).toPromise().then(\n\t\t\tresponse => {\n GAService.event('API', 'WATCH', 'UPDATE');\n\t\t\t\treturn watch;\n\t\t\t}\n\t\t);\n\t}\n\n\n\t/**\n\t * Log error to console\n\t * @param {any} error [description]\n\t */\n\tprivate handleError(error: any) {\n\t\tconsole.error('An error occurred', error);\n return Promise.reject(error.message || error);\n\t}\n\n}\n"]} \ No newline at end of file +{"version":3,"file":"twapi.service.js","sourceRoot":"","sources":["twapi.service.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,qBAA2B,eAAe,CAAC,CAAA;AAC3C,qBAAyE,eAAe,CAAC,CAAA;AAEzF,4BAAoC,yBAAyB,CAAC,CAAA;AAE9D,8BAA8B,2BAA2B,CAAC,CAAA;AAE1D,2BAA0B,cAAc,CAAC,CAAA;AAEzC,QAAO,6BAA6B,CAAC,CAAA;AAOrC;IAsJC;;;OAGG;IACH,sBAAoB,IAAU;QAAV,SAAI,GAAJ,IAAI,CAAM;QARtB,YAAO,GAAU,2BAA2B,CAAC;QAUpD,IAAI,CAAC,YAAY,EAAE,CAAC;IACrB,CAAC;IAEa,sBAAS,GAAvB;QACC,YAAY,CAAC,IAAI,GAAG,SAAS,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACH,4BAAK,GAAL,UAAM,KAAa,EAAE,QAAgB;QAArC,iBAoBC;QAlBA,IAAI,KAAK,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;QACjD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACnB,IAAI,CAAC,OAAO,GAAG,OAAO,EACtB,IAAI,CAAC,SAAS,C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,YAAY,CAAA;IAxJvC;QAAC,iBAAU,EAAE;;oBAAA;IA4nBb,mBAAC;AAAD,CAAC,AAvnBD,IAunBC;AAvnBY,oBAAY,eAunBxB,CAAA","sourcesContent":["import { Injectable } from '@angular/core';\nimport { Http, HTTP_PROVIDERS, RequestOptions, Headers, Response } from '@angular/http';\nimport { User } from './../models/user.model';\nimport { Watch, WatchAction } from './../models/watch.model';\nimport { Measure, MeasureStatus } from './../models/measure.model';\nimport { ModelFactory } from './../models/model.factory';\nimport { BlogPost } from './../models/blog-post.model'\nimport { GAService } from './ga.service';\n\nimport 'rxjs/add/operator/toPromise';\n\n@Injectable()\n/**\n * Exposes the Toolwatch API.\n * Returns promeses on domain objects\n */\nexport class TwAPIService {\n\n\t/**\n\t * All the HTTP code used by the toolwatch API are defined here.\n\t * Http codes can be to refine the error types\n\t */\n\tpublic static HTTP_CONTINUE = 100;\n public static HTTP_SWITCHING_PROTOCOLS = 101;\n public static HTTP_PROCESSING = 102; // RFC2518\n\n // Success\n\n /**\n * The request has succeeded\n */\n public static HTTP_OK = 200;\n\n /**\n * The server successfully created a new resource\n */\n public static HTTP_CREATED = 201;\n public static HTTP_ACCEPTED = 202;\n public static HTTP_NON_AUTHORITATIVE_INFORMATION = 203;\n\n /**\n * The server successfully processed the request, though no content is returned\n */\n public static HTTP_NO_CONTENT = 204;\n public static HTTP_RESET_CONTENT = 205;\n public static HTTP_PARTIAL_CONTENT = 206;\n public static HTTP_MULTI_STATUS = 207; // RFC4918\n public static HTTP_ALREADY_REPORTED = 208; // RFC5842\n public static HTTP_IM_USED = 226; // RFC3229\n\n // Redirection\n\n public static HTTP_MULTIPLE_CHOICES = 300;\n public static HTTP_MOVED_PERMANENTLY = 301;\n public static HTTP_FOUND = 302;\n public static HTTP_SEE_OTHER = 303;\n\n /**\n * The resource has not been modified since the last request\n */\n public static HTTP_NOT_MODIFIED = 304;\n public static HTTP_USE_PROXY = 305;\n public static HTTP_RESERVED = 306;\n public static HTTP_TEMPORARY_REDIRECT = 307;\n public static HTTP_PERMANENTLY_REDIRECT = 308; // RFC7238\n\n // Client Error\n\n /**\n * The request cannot be fulfilled due to multiple errors\n */\n public static HTTP_BAD_REQUEST = 400;\n\n /**\n * The user is unauthorized to access the requested resource\n */\n public static HTTP_UNAUTHORIZED = 401;\n public static HTTP_PAYMENT_REQUIRED = 402;\n\n /**\n * The requested resource is unavailable at this present time\n */\n public static HTTP_FORBIDDEN = 403;\n\n /**\n * The requested resource could not be found\n *\n * Note: This is sometimes used to mask if there was an UNAUTHORIZED (401) or\n * FORBIDDEN (403) error, for security reasons\n */\n public static HTTP_NOT_FOUND = 404;\n\n /**\n * The request method is not supported by the following resource\n */\n public static HTTP_METHOD_NOT_ALLOWED = 405;\n\n /**\n * The request was not acceptable\n */\n public static HTTP_NOT_ACCEPTABLE = 406;\n public static HTTP_PROXY_AUTHENTICATION_REQUIRED = 407;\n public static HTTP_REQUEST_TIMEOUT = 408;\n\n /**\n * The request could not be completed due to a conflict with the current state\n * of the resource\n */\n public static HTTP_CONFLICT = 409;\n public static HTTP_GONE = 410;\n public static HTTP_LENGTH_REQUIRED = 411;\n public static HTTP_PRECONDITION_FAILED = 412;\n public static HTTP_REQUEST_ENTITY_TOO_LARGE = 413;\n public static HTTP_REQUEST_URI_TOO_LONG = 414;\n public static HTTP_UNSUPPORTED_MEDIA_TYPE = 415;\n public static HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = 416;\n public static HTTP_EXPECTATION_FAILED = 417;\n public static HTTP_I_AM_A_TEAPOT = 418; // RFC2324\n public static HTTP_UNPROCESSABLE_ENTITY = 422; // RFC4918\n public static HTTP_LOCKED = 423; // RFC4918\n public static HTTP_FAILED_DEPENDENCY = 424; // RFC4918\n public static HTTP_RESERVED_FOR_WEBDAV_ADVANCED_COLLECTIONS_EXPIRED_PROPOSAL = 425; // RFC2817\n public static HTTP_UPGRADE_REQUIRED = 426; // RFC2817\n public static HTTP_PRECONDITION_REQUIRED = 428; // RFC6585\n public static HTTP_TOO_MANY_REQUESTS = 429; // RFC6585\n public static HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = 431; // RFC6585\n\n // Server Error\n\n /**\n * The server encountered an unexpected error\n *\n * Note: This is a generic error message when no specific message\n * is suitable\n */\n public static HTTP_INTERNAL_SERVER_ERROR = 500;\n\n /**\n * The server does not recognise the request method\n */\n public static HTTP_NOT_IMPLEMENTED = 501;\n public static HTTP_BAD_GATEWAY = 502;\n public static HTTP_SERVICE_UNAVAILABLE = 503;\n public static HTTP_GATEWAY_TIMEOUT = 504;\n public static HTTP_VERSION_NOT_SUPPORTED = 505;\n public static HTTP_VARIANT_ALSO_NEGOTIATES_EXPERIMENTAL = 506; // RFC2295\n public static HTTP_INSUFFICIENT_STORAGE = 507; // RFC4918\n public static HTTP_LOOP_DETECTED = 508; // RFC5842\n public static HTTP_NOT_EXTENDED = 510; // RFC2774\n public static HTTP_NETWORK_AUTHENTICATION_REQUIRED = 511;\n\n public static user:User;\n private static time:{\n \tsyncDate:Date,\n \tsyncAnchor:number,\n \toffset:number\n }\n\n\t//Defines headers and request options\n\tprivate static headers: Headers = new Headers({ 'Content-Type': 'application/json' });\n\tprivate static options: RequestOptions = new RequestOptions({ headers: TwAPIService.headers });\n\t\n\tprivate baseUrl:string = \"https://toolwatch.io/api/\";\n\tpublic static assetsUrl = \"app/assets\"\n\tprivate static apikey:string;\n\n\t/**\n\t * Inject http service\n\t * @param {Http} private http \n\t */\n\tconstructor(private http: Http) {\n\n\t\tthis.accurateTime();\n\t}\n\n\tpublic static resetTime(){\n\t\tTwAPIService.time = undefined;\n\t}\n\n\t/**\n\t * Log a user using email and password\n\t * @param {string} email \n\t * @param {string} password\n\t * @return {Promise} \n\t */\n\tlogin(email: string, password: string): Promise {\n\n\t\tlet creds = { email: email, password: password };\n\t\treturn this.http.put(\n\t\t\tthis.baseUrl + \"users\", \n\t\t\tJSON.stringify(creds), \n\t\t\tTwAPIService.options\n\t\t)\n\t\t.map((res) => { return ModelFactory.buildUser(res.json()); })\n\t\t.toPromise().then(\n\t\t\tres => {\n GAService.event('API', 'LOGIN');\n\t\t\t\tTwAPIService.apikey = res.key;\n\t\t\t\tTwAPIService.headers.delete('X-API-KEY');\n\t\t\t\tTwAPIService.headers.append('X-API-KEY', TwAPIService.apikey);\n\t\t\t\tTwAPIService.user = res;\n\t\t\t\treturn res;\n\t\t\t},\n err => this.handleError(err)\n\t\t)\n\t} \n\n\n /**\n * Get an user using his API key\n * @param {string} key [description]\n * @return {Promise} [description]\n */\n getUser(key:string):Promise {\n\n \n TwAPIService.apikey = key;\n TwAPIService.headers.delete('X-API-KEY');\n TwAPIService.headers.append('X-API-KEY', TwAPIService.apikey);\n \n\n return this.http.get(\n this.baseUrl + \"users\", \n TwAPIService.options\n )\n .map((res) => { return ModelFactory.buildUser(res.json()); })\n .toPromise().then(\n res => {\n\n GAService.event('API', 'AUTOLOGIN');\n TwAPIService.user = res;\n return res;\n },\n err => this.handleError(err)\n )\n\n }\n\n\t/**\n\t * Registers a new user\n\t * @param {string} email \n\t * @param {string} password\n\t * @param {string} name \n\t * @param {string} lastname\n\t * @param {string} country \n\t * @return {Promise} \n\t */\n\tsignup(email: string, password: string, name?: string, lastname?: string, country?: string): Promise {\n\n\t\treturn this.http.post(\n\t\t\tthis.baseUrl + \"users\",\n\t\t\tJSON.stringify({\n\t\t\t\temail: email, \n\t\t\t\tpassword: password,\n\t\t\t\tname: name,\n\t\t\t\tlastname: lastname,\n\t\t\t\tcountry:country\n\t\t\t}),\n\t\t\tTwAPIService.options\n\t\t)\n\t\t.map((res) => { return ModelFactory.buildUser(res.json()); })\n\t\t.toPromise().then(\n\t\t\tres => {\n GAService.event('API', 'SIGNUP');\n return res;\n }\n\t\t);\n\t}\n\n\t/**\n\t * Deletes the account currently logged in.\n\t * @return {Promise}\n\t */\n\tdeleteAccount():Promise{\n\n\t\treturn this.http.delete(\n\t\t\tthis.baseUrl + \"users\",\n\t\t\tTwAPIService.options\n\t\t).toPromise().then(\n\t\t\tresponse => {\n GAService.event('API', 'DELETE_ACCOUNT');\n return true;\n }\n\t\t).catch(this.handleError);\n\t}\n\n\tgetWatches(): Promise{\n\t\treturn this.http.get(\n\t\t\tthis.baseUrl + \"watches\",\n\t\t\tTwAPIService.options)\n\t\t.map((res) => { return ModelFactory.buildWatches(res.json()); })\n\t\t.toPromise().then(\n\t\t\tres => {\n GAService.event('API', 'WATCHES', 'GET');\n return res\n }\n\t\t);\n\t}\n\n\t/**\n\t * Update or insert a watch\n\t * @param {Watch} watch\n\t * @return {Promise} \n\t */\n\tupsertWatch(watch: Watch): Promise {\n\n\t\tif(watch.id == null){\n\t\t\treturn this.insertWatch(watch);\n\t\t}else{\n\t\t\treturn this.updateWatch(watch);\n\t\t}\n\t}\n\n\t/**\n\t * Deletes a watch and update the user accordingly\n\t * @param {User} user \n\t * @param {Watch} watch \n\t * @return {Promise} \n\t */\n\tdeleteWatch(user:User, watch:Watch):Promise{\n\t\tlet deleteOptions = new RequestOptions({ headers: TwAPIService.headers });\n\t\tdeleteOptions.body = JSON.stringify({ watchId: watch.id });\n\n\t\treturn this.http.delete(\n\t\t\tthis.baseUrl + \"watches\",\n\t\t\tdeleteOptions\n\t\t).toPromise().then(\n\t\t\tresponse => {\n\n\t\t\t\tuser.watches = user.watches.filter(\n\t\t\t\t\tfunction(filter: Watch) {\n\t\t\t\t\t\treturn filter.id != watch.id;\n\t\t\t\t\t}\n\t\t\t\t);\n\n GAService.event('API', 'WATCHES', 'DELETE');\n\n\t\t\t\treturn user;\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Insert or update a measure and the related watch\n\t * @param {Watch} watch \n\t * @param {Measure} measure\n\t * @return {Promise} \n\t */\n\tupsertMeasure(watch: Watch, measure: Measure): Promise {\n\t\tif(measure.id == null){\n\t\t\treturn this.insertMeasure(watch, measure);\n\t\t}else{\n\t\t\treturn this.updateMeasure(watch, measure);\n\t\t}\n\t}\n\n\t/**\n\t * Delete a measure and the update the related watch\n\t * @param {Watch} watch \n\t * @param {Measure} measure\n\t * @return {Promise} \n\t */\n\tdeleteMeasure(watch: Watch, measure: Measure): Promise {\n\n\t\tlet deleteOptions = new RequestOptions({ headers: TwAPIService.headers });\n\t\tdeleteOptions.body = JSON.stringify({measureId:measure.id});\n\n\t\treturn this.http.delete(\n\t\t\tthis.baseUrl + \"measures\",\n\t\t\tdeleteOptions\n\t\t).toPromise().then(\n\t\t\tresponse => {\n\n\t\t\t\twatch.measures = watch.measures.filter(\n\t\t\t\t\tfunction(filter: Measure) {\n\t\t\t\t\t\treturn filter.id != measure.id;\n\t\t\t\t\t}\n\t\t\t\t);\n\n GAService.event('API', 'MEASURE', 'DELETE');\n\n\t\t\t\treturn watch;\n\t\t\t}\n\t\t).catch(this.handleError);\n\t}\n\n\tgetBlogPosts(): Promise{\n\t\treturn this.http.get(\n\t\t\t\"https://blog.toolwatch.io/?json=1\"\n\t\t)\n\t\t.map((res) => { return ModelFactory.buildPosts(res.json()); })\n\t\t.toPromise().then(\n\t\t\tres => {\n GAService.event('API', 'BLOG', 'GET');\n return res\n }\n\t\t);\n\t}\n\n\t/**\n\t * Return known brands\n\t * @return {Promise} \n\t */\n\tgetBrands(): Promise<[{ name: string, icon: string, models:string}]> {\n\t\treturn this.http.get(\n\t\t\tTwAPIService.assetsUrl + '/json/watch-brand.json')\n\t\t.map(res => res.json())\n\t\t.toPromise().then(\n\t\t\tbrands => {\n GAService.event('API', 'BRANDS', 'GET');\n return brands;\n }\n\t\t);\n\t}\n\n\t/**\n\t * Returns model of a given brand\n\t * @param {string} brand\n\t * @return {Promise} \n\t */\n\tgetModels(brand:string): Promise<[string]> {\n\t\treturn this.http.get(\n\t\t\tTwAPIService.assetsUrl + '/json/watch-models/' + brand + \".json\")\n\t\t\t.map(res => res.json())\n\t\t\t.toPromise().then(\n\t\t\tmodels => {\n GAService.event('API', 'MODELS', 'GET');\n return models\n }\n\t\t);\n\t}\n\n\t/**\n\t * Gets the previously computed offset\n\t * @return {number} [description]\n\t */\n\tgetOffsetTime():number{\n\t\treturn TwAPIService.time.offset;\n\t}\n\n\t/**\n\t * Retrieve atomic clock time adjusted for network latency\n\t * @param {()=>void} statusCallback Called at each partial complete\n\t * @param {number = 0} precison How many calls we want to aveage\n\t * @return {Promise} \n\t */\n\taccurateTime(statusCallback?:()=>void, \n\t\tprecison:number = 10): Promise{\n\n GAService.event('API', 'TIME', 'GET');\n\n\n\t\t//If we aren't already sync'ed\n\t\tif(TwAPIService.time === undefined){\n\t\t\t//Stores each Promise in array\n\t\t\tlet promises:Promise[] = [];\n\t\t\tfor (var i = 0; i < precison; ++i) {\n\t\t\t\tpromises.push(this.fetchTime(statusCallback));\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Promise.all() is the Promise equivalent of thread.join().\n\t\t\t * It'll wait for all promises to be received. \n\t\t\t *\n\t\t\t * Returns a date adjusted w/ the median offset between \n\t\t\t * atomic clock and js time. \n\t\t\t * The offset received in each promise also accounts for\n\t\t\t * the network roundtrip time.\n\t\t\t */\n\t\t\treturn Promise.all(promises).then((results:any[]) => {\n\t\t\t\tresults.sort(function(a: any, b: any) { return a - b; });\n\n\t\t\t\tlet half: number = Math.floor(results.length / 2);\n\t\t\t\tlet medianOffset;\n\n\t\t\t\tif (results.length % 2) {\n\t\t\t\t\tmedianOffset = results[half];\n\t\t\t\t} else {\n\t\t\t\t\tmedianOffset = (results[half - 1] + results[half]) / 2.0;\n\t\t\t\t}\n\n\t\t\t\tTwAPIService.time = {\n\t\t\t\t\tsyncDate: new Date(Date.now() - medianOffset),\n\t\t\t\t\tsyncAnchor: window.performance.now(),\n\t\t\t\t\toffset:medianOffset\n\t\t\t\t};\n\n\t\t\t\tconsole.log(TwAPIService.time);\n\n\t\t\t\treturn TwAPIService.time.syncDate;\n\t\t\t});\n\t\t//Only compute the difference from last time;\n\t\t}else{\n\n\t\t\tTwAPIService.time.syncDate = new Date(\n\t\t\t\tTwAPIService.time.syncDate.getTime() +\n\t\t\t\twindow.performance.now() - TwAPIService.time.syncAnchor\n\t\t\t);\n\t\t\t\n\t\t\tTwAPIService.time.syncAnchor = window.performance.now();\n\n\t\t\treturn new Promise(\n\t\t\t\t(resolve, reject) => { \n\t\t\t\t\tconsole.log(TwAPIService.time);\n\t\t\t\t\tresolve(TwAPIService.time.syncDate); \n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Fetch offset between atomic clock and js time\n\t * @param {() => void} statusCallback\n\t */\n\tprivate fetchTime(statusCallback?: () => void)\n\t\t: Promise {\n\n\t\tlet beforeTime: number = window.performance.now();\n\t\treturn this.http.get(\n\t\t\tthis.baseUrl + \"time\",\n\t\t\tTwAPIService.options).toPromise().then(\n\t\t\tresponse => {\n\n\t\t\t\tif (statusCallback !== undefined){\n\t\t\t\t\tstatusCallback();\n\t\t\t\t}\n\n\t\t\t\tlet now: number = window.performance.now();\n\t\t\t\tlet timeDiff = (now - beforeTime) / 2;\n\t\t\t\tlet serverTime = response.json().time - timeDiff;\n\t\t\t\treturn Date.now() - serverTime;\n\t\t\t}\n\t\t).catch(this.handleError);\n\t}\n\n\t/**\n\t * Update a measure and the watch it belongs to\n\t * @param {Watch} watch \n\t * @param {Measure} measure\n\t * @return {Promise} \n\t */\n\tprivate updateMeasure(watch: Watch, measure: Measure): Promise {\n\t\treturn this.http.put(\n\t\t\tthis.baseUrl + \"measures\",\n\t\t\tJSON.stringify({\n\t\t\t\tmeasureId: measure.id,\n\t\t\t\treferenceTime: measure.accuracyReferenceTime,\n\t\t\t\tuserTime: measure.accuracyUserTime\n\t\t\t}),\n\t\t\tTwAPIService.options\n\t\t).toPromise().then(\n\t\t\tresponse => {\n GAService.event('API', 'MEASURE', 'SECOND');\n\t\t\t\tlet json = response.json().result;\n\t\t\t\tmeasure.addAccuracy(json.accuracy, json.accuracyAge, json.percentile);\n\t\t\t\twatch.upsertMeasure(measure);\n\t\t\t\twatch.next = WatchAction.Measure;\n\t\t\t\treturn watch;\n\t\t\t}\n\t\t).catch(this.handleError);\n\t}\n\n\t/**\n\t * Insert a measure and the watch it belongs to\n\t * @param {Watch} watch \n\t * @param {Measure} measure\n\t * @return {Promise} \n\t */\n\tprivate insertMeasure(watch: Watch, measure: Measure): Promise {\n\t\treturn this.http.post(\n\t\t\tthis.baseUrl + \"measures\",\n\t\t\tJSON.stringify({\n\t\t\t\twatchId: watch.id,\n\t\t\t\treferenceTime: measure.measureReferenceTime,\n\t\t\t\tuserTime: measure.measureUserTime\n\t\t\t}),\n\t\t\tTwAPIService.options\n\t\t).toPromise().then(\n\t\t\tresponse => {\n GAService.event('API', 'MEASURE', 'FIRST');\n\t\t\t\tmeasure.id = response.json().measureId;\n\t\t\t\twatch.measures.push(measure);\n\t\t\t\treturn watch;\n\t\t\t}\n\t\t).catch(this.handleError);\n\t}\n\n\t/**\n\t * Insert a watch\n\t * @param {Watch} watch\n\t * @return {Promise} \n\t */\n\tprivate insertWatch(watch: Watch):Promise{\n\t\treturn this.http.post(\n\t\t\tthis.baseUrl + \"watches\",\n\t\t\tJSON.stringify({\n\t\t\t\tbrand: watch.brand,\n\t\t\t\tname:watch.name,\n\t\t\t\tyearOfBuy:watch.yearOfBuy,\n\t\t\t\tserial: watch.serial,\n\t\t\t\tcaliber:watch.caliber\n\t\t\t}),\n\t\t\tTwAPIService.options\n\t\t).toPromise().then(\n\t\t\tresponse => {\n\t\t\t\twatch.id = response.json().id;\n GAService.event('API', 'WATCH', 'PUT');\n\t\t\t\treturn watch;\n\t\t\t}\n\t\t);\n\t}\n\n\t/**\n\t * Update a watch\n\t * @param {Watch} watch\n\t * @return {Promise} \n\t */\n\tprivate updateWatch(watch: Watch): Promise {\n\t\treturn this.http.put(\n\t\t\tthis.baseUrl + \"watches\",\n\t\t\tJSON.stringify({\n\t\t\t\tid: watch.id,\n\t\t\t\tbrand: watch.brand,\n\t\t\t\tname: watch.name,\n\t\t\t\tyearOfBuy: watch.yearOfBuy,\n\t\t\t\tserial: watch.serial,\n\t\t\t\tcaliber: watch.caliber\n\t\t\t}),\n\t\t\tTwAPIService.options\n\t\t).toPromise().then(\n\t\t\tresponse => {\n GAService.event('API', 'WATCH', 'UPDATE');\n\t\t\t\treturn watch;\n\t\t\t}\n\t\t);\n\t}\n\n\n\t/**\n\t * Log error to console\n\t * @param {any} error [description]\n\t */\n\tprivate handleError(error: any) {\n\t\tconsole.error('An error occurred', error);\n return Promise.reject(error.message || error);\n\t}\n\n}\n"]} \ No newline at end of file diff --git a/src/app/directives/login/login.component.ts b/src/app/directives/login/login.component.ts index 12b4078a..0015734f 100644 --- a/src/app/directives/login/login.component.ts +++ b/src/app/directives/login/login.component.ts @@ -39,7 +39,7 @@ export class LoginComponent implements OnInit { * @param {FormBuilder} private builder [description] */ constructor(private translate: TranslateService, - private twapi: TwAPIService, private builder: FormBuilder) { + protected twapi: TwAPIService, private builder: FormBuilder) { //Lang definition translate.setDefaultLang('en'); diff --git a/src/app/services/twapi.service.ts b/src/app/services/twapi.service.ts index 069a0d51..5479ef27 100755 --- a/src/app/services/twapi.service.ts +++ b/src/app/services/twapi.service.ts @@ -194,8 +194,6 @@ export class TwAPIService { .map((res) => { return ModelFactory.buildUser(res.json()); }) .toPromise().then( res => { - console.log("works"); - GAService.event('API', 'LOGIN'); TwAPIService.apikey = res.key; TwAPIService.headers.delete('X-API-KEY'); @@ -207,6 +205,37 @@ export class TwAPIService { ) } + + /** + * Get an user using his API key + * @param {string} key [description] + * @return {Promise} [description] + */ + getUser(key:string):Promise { + + + TwAPIService.apikey = key; + TwAPIService.headers.delete('X-API-KEY'); + TwAPIService.headers.append('X-API-KEY', TwAPIService.apikey); + + + return this.http.get( + this.baseUrl + "users", + TwAPIService.options + ) + .map((res) => { return ModelFactory.buildUser(res.json()); }) + .toPromise().then( + res => { + + GAService.event('API', 'AUTOLOGIN'); + TwAPIService.user = res; + return res; + }, + err => this.handleError(err) + ) + + } + /** * Registers a new user * @param {string} email