-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from DariuS231/favourites
Favourites
- Loading branch information
Showing
42 changed files
with
537 additions
and
316 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
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 |
---|---|---|
@@ -1,75 +1,76 @@ | ||
{ | ||
"name": "chromesppropertiesadmin", | ||
"version": "0.0.1", | ||
"description": "Google Chrome extension that opens a Property bag Modal dialog administration", | ||
"scripts": { | ||
"start": "set NODE_ENV=development && node server.js", | ||
"bundleActions": "set NODE_ENV=production && webpack --progress --config ./webpack/webpack.config.actions.prod.js", | ||
"bundleChromeExtension": "set NODE_ENV=production && gulp build-chromeExt", | ||
"generate": "set NODE_ENV=production && gulp generate-chrome-dev", | ||
"generateZip": "set NODE_ENV=production && gulp generate-chrome-package" | ||
}, | ||
"dependencies": { | ||
"axios": "^0.15.3", | ||
"office-ui-fabric-react": "^1.5.0", | ||
"react": "^15.3.2", | ||
"react-dom": "^15.3.2", | ||
"react-router": "^3.0.2", | ||
"redux-thunk": "^2.1.0" | ||
}, | ||
"devDependencies": { | ||
"@types/axios": "^0.9.35", | ||
"@types/chrome": "0.0.35", | ||
"@types/core-js": "^0.9.34", | ||
"@types/microsoft-ajax": "0.0.31", | ||
"@types/react": "^0.14.46", | ||
"@types/react-dom": "^0.14.18", | ||
"@types/react-redux": "^4.4.35", | ||
"@types/react-router": "2.0.29", | ||
"@types/redux-immutable-state-invariant": "^1.2.29", | ||
"@types/redux-thunk": "^2.1.32", | ||
"@types/sharepoint": "^2013.1.2", | ||
"awesome-typescript-loader": "^3.0.0-beta.18", | ||
"css-loader": "^0.26.1", | ||
"es6-promise": "4.0.5", | ||
"extract-text-webpack-plugin": "^2.0.0-rc.2", | ||
"gulp": "^3.9.1", | ||
"gulp-util": "^3.0.8", | ||
"gulp-zip": "^3.2.0", | ||
"http-server": "^0.9.0", | ||
"immutable": "^3.8.1", | ||
"node-sass": "^4.4.0", | ||
"opener": "^1.4.2", | ||
"path": "^0.12.7", | ||
"react-redux": "^5.0.1", | ||
"redux": "^3.6.0", | ||
"redux-immutable-state-invariant": "^1.2.4", | ||
"sass-loader": "^4.1.1", | ||
"source-map-loader": "^0.1.6", | ||
"style-loader": "^0.13.1", | ||
"tslint": "^4.4.2", | ||
"tslint-react": "^2.3.0", | ||
"typescript": "2.3.4", | ||
"webpack": "^2.2.1", | ||
"webpack-dev-server": "^2.2.1", | ||
"whatwg-fetch": "1.0.0" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/DariuS231/ChromeSPPropertiesAdmin.git" | ||
}, | ||
"keywords": [ | ||
"SharePoint", | ||
"PropertyBag", | ||
"CSOM", | ||
"JavaScript", | ||
"Google Chrome", | ||
"Chrome Extension" | ||
], | ||
"author": "Darius231", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/DariuS231/ChromeSPPropertiesAdmin/issues" | ||
}, | ||
"homepage": "https://github.com/DariuS231/ChromeSPPropertiesAdmin#readme" | ||
} | ||
"name": "chromesppropertiesadmin", | ||
"version": "0.0.1", | ||
"description": "Google Chrome extension that opens a Property bag Modal dialog administration", | ||
"scripts": { | ||
"start": "set NODE_ENV=development && node server.js", | ||
"bundleActions": "set NODE_ENV=production && webpack --progress --config ./webpack/webpack.config.actions.prod.js", | ||
"bundleChromeExtension": "set NODE_ENV=production && gulp build-chromeExt", | ||
"generate": "set NODE_ENV=production && gulp generate-chrome-dev", | ||
"generateZip": "set NODE_ENV=production && gulp generate-chrome-package" | ||
}, | ||
"dependencies": { | ||
"axios": "^0.15.3", | ||
"office-ui-fabric-react": "^1.5.0", | ||
"react": "^15.3.2", | ||
"react-dom": "^15.3.2", | ||
"react-router": "^3.0.2", | ||
"redux-thunk": "^2.1.0", | ||
"sp-pnp-js": "^3.0.1" | ||
}, | ||
"devDependencies": { | ||
"@types/axios": "^0.9.35", | ||
"@types/chrome": "0.0.35", | ||
"@types/core-js": "^0.9.34", | ||
"@types/microsoft-ajax": "0.0.31", | ||
"@types/react": "^0.14.46", | ||
"@types/react-dom": "^0.14.18", | ||
"@types/react-redux": "^4.4.35", | ||
"@types/react-router": "2.0.29", | ||
"@types/redux-immutable-state-invariant": "^1.2.29", | ||
"@types/redux-thunk": "^2.1.32", | ||
"@types/sharepoint": "^2013.1.2", | ||
"awesome-typescript-loader": "^3.0.0-beta.18", | ||
"css-loader": "^0.26.1", | ||
"es6-promise": "4.0.5", | ||
"extract-text-webpack-plugin": "^2.0.0-rc.2", | ||
"gulp": "^3.9.1", | ||
"gulp-util": "^3.0.8", | ||
"gulp-zip": "^3.2.0", | ||
"http-server": "^0.9.0", | ||
"immutable": "^3.8.1", | ||
"node-sass": "^4.4.0", | ||
"opener": "^1.4.2", | ||
"path": "^0.12.7", | ||
"react-redux": "^5.0.1", | ||
"redux": "^3.6.0", | ||
"redux-immutable-state-invariant": "^1.2.4", | ||
"sass-loader": "^4.1.1", | ||
"source-map-loader": "^0.1.6", | ||
"style-loader": "^0.13.1", | ||
"tslint": "^4.4.2", | ||
"tslint-react": "^2.3.0", | ||
"typescript": "2.3.4", | ||
"webpack": "^2.2.1", | ||
"webpack-dev-server": "^2.2.1", | ||
"whatwg-fetch": "1.0.0" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/DariuS231/ChromeSPPropertiesAdmin.git" | ||
}, | ||
"keywords": [ | ||
"SharePoint", | ||
"PropertyBag", | ||
"CSOM", | ||
"JavaScript", | ||
"Google Chrome", | ||
"Chrome Extension" | ||
], | ||
"author": "Darius231", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/DariuS231/ChromeSPPropertiesAdmin/issues" | ||
}, | ||
"homepage": "https://github.com/DariuS231/ChromeSPPropertiesAdmin#readme" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
|
||
import { constants } from "./constants"; | ||
|
||
class Cache { | ||
private _keyPrefix: string = "spChromeDevTool_"; | ||
private _isSupportedStorage: boolean = null; | ||
|
||
public get isSupportedStorage(): boolean { | ||
if (this._isSupportedStorage === null) { | ||
this._isSupportedStorage = this.checkIfStorageIsSupported(); | ||
} | ||
return this._isSupportedStorage; | ||
} | ||
public clear(key: string): void { | ||
const completeKey: string = this.addKeyPrefix(key); | ||
this.CacheObject.removeItem(completeKey); | ||
} | ||
|
||
public get<T>(key: string): T { | ||
const completeKey: string = this.addKeyPrefix(key); | ||
if (this.isSupportedStorage) { | ||
const cachedDataStr = this.CacheObject.getItem(completeKey); | ||
|
||
if (typeof cachedDataStr === constants.TYPE_OF_STRING) { | ||
const cacheDataObj = JSON.parse(cachedDataStr); | ||
if (cacheDataObj.expiryTime > (new Date())) { | ||
return cacheDataObj.data; | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
public set(key: string, valueObj: any, expireMinutes?: number) { | ||
const completeKey: string = this.addKeyPrefix(key); | ||
let didSetInCache = false; | ||
if (this.isSupportedStorage && valueObj !== undefined) { | ||
const nowDt = new Date(); | ||
const expiryTime: number = (typeof expireMinutes !== constants.TYPE_OF_UNDEFINED) | ||
? nowDt.setMinutes(nowDt.getMinutes() + expireMinutes) | ||
: 8640000000000000; | ||
const cacheDataObj: any = { data: valueObj, expiryTime }; | ||
this.CacheObject.setItem(completeKey, JSON.stringify(cacheDataObj)); | ||
|
||
didSetInCache = true; | ||
|
||
} | ||
return didSetInCache; | ||
} | ||
|
||
private addKeyPrefix(key: string): string { | ||
return this._keyPrefix + window.location.href.replace(/:\/\/|\/|\./g, "_") + "_" + key; | ||
} | ||
|
||
private get CacheObject(): Storage { | ||
return window.localStorage; | ||
} | ||
private checkIfStorageIsSupported() { | ||
const cacheObj = this.CacheObject; | ||
const supportsStorage = cacheObj && JSON | ||
&& typeof JSON.parse === constants.TYPE_OF_FUNCTION | ||
&& typeof JSON.stringify === constants.TYPE_OF_FUNCTION; | ||
if (supportsStorage) { | ||
try { | ||
const testKey = this._keyPrefix + "testingCache"; | ||
cacheObj.setItem(testKey, "1"); | ||
cacheObj.removeItem(testKey); | ||
return true; | ||
} catch (ex) { | ||
console.log("Local Storage not supported by the browser."); | ||
} | ||
} | ||
return false; | ||
} | ||
} | ||
|
||
export const AppCache: Cache = new Cache(); |
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,12 @@ | ||
import * as React from "react"; | ||
import { IconButton } from "./iconButton"; | ||
|
||
interface IFavouriteButtonProps { | ||
onClick: React.EventHandler<React.MouseEvent<HTMLAnchorElement>>; | ||
isFavourite: boolean; | ||
} | ||
export const FavouriteButton: React.StatelessComponent<IFavouriteButtonProps> = (props: IFavouriteButtonProps) => { | ||
const title: string = props.isFavourite ? "Unpin favourite" : "Pin as favourites"; | ||
const starType: string = props.isFavourite ? "FavoriteStarFill" : "FavoriteStar"; | ||
return <IconButton icon={starType} title={title} onClick={props.onClick} />; | ||
}; |
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,31 @@ | ||
|
||
import { AppCache } from "./cache"; | ||
|
||
export class FavouritesBase { | ||
private _favouriteArray: string[] = null; | ||
private _favouriteCacheKey: string; | ||
|
||
constructor(cacheKey: string) { | ||
this._favouriteCacheKey = cacheKey; | ||
} | ||
public get Favourites(): string[]{ | ||
if (this._favouriteArray === null) { | ||
this._favouriteArray = AppCache.get<string[]>(this._favouriteCacheKey) || []; | ||
} | ||
return this._favouriteArray; | ||
} | ||
|
||
public addToFavourites(guid: string) { | ||
if (this.Favourites.indexOf(guid) === -1) { | ||
this.Favourites.push(guid); | ||
AppCache.set(this._favouriteCacheKey, this.Favourites); | ||
} | ||
} | ||
public removeFromFavourites(guid: string) { | ||
const index = this.Favourites.indexOf(guid); | ||
if (index >= -1) { | ||
this.Favourites.splice(index, 1); | ||
AppCache.set(this._favouriteCacheKey, this.Favourites); | ||
} | ||
} | ||
} |
Oops, something went wrong.