-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Milestone Details: https://github.com/mean-expert-official/loopback-sdk-builder/milestone/28?closed=1 - Fix: #268 - Fix: #266 - Fix: #265 - Fix: #264 - Fix: #262 - Fix: #151
- Loading branch information
Jonathan Casarrubias
committed
Dec 21, 2016
1 parent
295759d
commit 81405ee
Showing
24 changed files
with
382 additions
and
131 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* tslint:disable */ | ||
import { Injectable } from '@angular/core'; | ||
/** | ||
* @module StorageBrowser | ||
* @author Jonathan Casarrubias | ||
* @license MIT | ||
* @description | ||
* Stand-alone cookie service for browsers | ||
**/ | ||
@Injectable() | ||
export class StorageBrowser { | ||
set(key: string, value: any) { | ||
localStorage.setItem( | ||
key, | ||
typeof value === 'object' ? JSON.stringify(value) : value | ||
); | ||
} | ||
get(key: string): any { | ||
let data: string = localStorage.getItem(key); | ||
return this.isJSON(data) ? JSON.parse(data) : data; | ||
} | ||
remove(key: string): any { | ||
if (localStorage[key]) { | ||
localStorage.removeItem(key); | ||
} else { | ||
console.log('Trying to remove unexisting key: ', key); | ||
} | ||
} | ||
private isJSON(str) { | ||
try { | ||
JSON.parse(str); | ||
} catch (e) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* @module Storage | ||
* @author Jonathan Casarrubias <t: johncasarrubias, gh: mean-expert-official> | ||
* @license MIT | ||
* @description | ||
* The InternalStorage class is used for dependency injection swapping. | ||
* It will be provided using factory method from different sources. | ||
**/ | ||
class Storage { | ||
get(key: string): any {} | ||
set(key: string, value: any): any {} | ||
remove(key: string): any {} | ||
} | ||
/** | ||
* @module InternalStorage | ||
* @author Jonathan Casarrubias <t: johncasarrubias, gh: mean-expert-official> | ||
* @license MIT | ||
* @description | ||
* The InternalStorage class is used for dependency injection swapping. | ||
* It will be provided using factory method from different sources. | ||
* This is mainly required because Angular Universal integration. | ||
* It does inject a CookieStorage instead of LocalStorage. | ||
**/ | ||
export class InternalStorage extends Storage {} | ||
/** | ||
* @module SDKStorage | ||
* @author Jonathan Casarrubias <t: johncasarrubias, gh: mean-expert-official> | ||
* @license MIT | ||
* @description | ||
* The SDKStorage class is used for dependency injection swapping. | ||
* It will be provided using factory method according the right environment. | ||
* This is created for public usage, to allow persisting custom data | ||
* Into the local storage API. | ||
**/ | ||
export class SDKStorage extends Storage {} |
Oops, something went wrong.