Skip to content

Commit 72cdb59

Browse files
committed
node.js support Added.
1 parent deaf331 commit 72cdb59

29 files changed

+2216
-1526
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.env

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
TOKEN_KEY=123,
2+
TOKEN_VALUE=123

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ typings/
6969
.yarn-integrity
7070

7171
# dotenv environment variables file
72-
.env
72+
7373
.env.test
7474

7575
# parcel-bundler cache (https://parceljs.org/)

dist/grandeur-cjs.js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/grandeur-cjs.js.LICENSE.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* [hi-base32]{@link https://github.com/emn178/hi-base32}
3+
*
4+
* @version 0.5.0
5+
* @author Chen, Yi-Cyuan [[email protected]]
6+
* @copyright Chen, Yi-Cyuan 2015-2018
7+
* @license MIT
8+
*/
9+
10+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */

dist/grandeur-cjs.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/grandeur-react.js

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/grandeur-react.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/grandeur.js

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/grandeur.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

distributions/react.js

+3-13
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ const GrandeurContext = React.createContext(null);
2727
// Default Grandeur Provider Component
2828
export function Grandeur(props) {
2929
// Pass the plugins to sdk
30-
grandeur.extend
31-
? grandeur.extend(props.extensions ? props.extensions : {})
32-
: null;
30+
grandeur.extend ? grandeur.extend(props.extensions ? props.extensions : {}) : null;
3331

3432
// init
3533
var project = grandeur.init(props.apiKey, props.secretKey);
@@ -39,15 +37,7 @@ export function Grandeur(props) {
3937
grandeur: project,
4038
};
4139

42-
return (
43-
<GrandeurContext.Provider value={state.grandeur}>
44-
{props.children}
45-
</GrandeurContext.Provider>
46-
);
40+
return <GrandeurContext.Provider value={state.grandeur}>{props.children}</GrandeurContext.Provider>;
4741
}
4842

49-
export const withGrandeur = (Component) => (props) => (
50-
<GrandeurContext.Consumer>
51-
{(grandeur) => <Component {...props} grandeur={grandeur} />}
52-
</GrandeurContext.Consumer>
53-
);
43+
export const withGrandeur = (Component) => (props) => <GrandeurContext.Consumer>{(grandeur) => <Component {...props} grandeur={grandeur} />}</GrandeurContext.Consumer>;

examples/create-react-app/package-lock.json

+9-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/create-react-app/src/components/Devices/Devices.js

+3-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import ButtonOn from "../../buttonOn.svg";
77
import { useNavigate } from "react-router-dom";
88

99
function Device(props) {
10-
const deviceID = "DeviceID";
10+
const deviceID = "devicelesd875d7mgp0jjp6wic58io";
1111
const navigate = useNavigate();
1212
const [deviceName, setDeviceNameState] = useState("");
1313
const [data, setButtonState] = useState(0);
@@ -59,10 +59,7 @@ function Device(props) {
5959
<>
6060
<Header></Header>
6161
<div className="flex w-screen h-screen bg-gray-50 justify-center items-center">
62-
<div
63-
id="device"
64-
className="h-96 w-96 flex flex-col justify-center items-center content-around"
65-
>
62+
<div id="device" className="h-96 w-96 flex flex-col justify-center items-center content-around">
6663
{!deviceName ? (
6764
<div id="device-loading" className="w-20 h-auto">
6865
<img src={Loading} alt="ReactLogo" />
@@ -73,10 +70,7 @@ function Device(props) {
7370
<img src={!data ? ButtonOff : ButtonOn} alt="" />
7471
</div>
7572

76-
<div
77-
className="text-gray-900 font-sans text-md font-bold mt-10 text-center"
78-
id="device-name"
79-
>
73+
<div className="text-gray-900 font-sans text-md font-bold mt-10 text-center" id="device-name">
8074
{!deviceName ? "Device" : deviceName}
8175
</div>
8276
</div>

examples/create-react-app/src/components/Header/Header.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,8 @@ function Header(props) {
1212
}
1313
return (
1414
<div className="absolute inset-0 flex w-full h-12 items-center justify-between px-6 bg-gray-300 drop-shadow-md border-box">
15-
<div className="text-gray-600 font-sans text-md font-bold">
16-
Internet Switch
17-
</div>
18-
<button
19-
id="logout"
20-
onClick={logout}
21-
className="h-8 text-gray-600 bg-gray-200 rounded-md px-5 text-sm font-sans font-bold cursor-pointer"
22-
>
15+
<div className="text-gray-600 font-sans text-md font-bold">Internet Switch</div>
16+
<button id="logout" onClick={logout} className="h-8 text-gray-600 bg-gray-200 rounded-md px-5 text-sm font-sans font-bold cursor-pointer">
2317
Logout
2418
</button>
2519
</div>

examples/create-react-app/src/components/Login/Login.js

+5-24
Original file line numberDiff line numberDiff line change
@@ -39,33 +39,14 @@ function Login(props) {
3939
<div className="p-6 space-y-4 md:space-y-6 sm:p-8">
4040
<form className="space-y-4 md:space-y-6" onSubmit={login}>
4141
<div>
42-
<label className="block mb-2 text-sm font-medium text-gray-900">
43-
Email
44-
</label>
45-
<input
46-
ref={emailRef}
47-
type="email"
48-
id="email"
49-
className="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5"
50-
placeholder="[email protected]"
51-
/>
42+
<label className="block mb-2 text-sm font-medium text-gray-900">Email</label>
43+
<input ref={emailRef} type="email" id="email" className="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5" placeholder="[email protected]" />
5244
</div>
5345
<div>
54-
<label className="block mb-2 text-sm font-medium text-gray-900">
55-
Password
56-
</label>
57-
<input
58-
ref={passwordRef}
59-
type="password"
60-
id="password"
61-
placeholder="••••••••"
62-
className="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5"
63-
/>
46+
<label className="block mb-2 text-sm font-medium text-gray-900">Password</label>
47+
<input ref={passwordRef} type="password" id="password" placeholder="••••••••" className="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5" />
6448
</div>
65-
<button
66-
type="submit"
67-
className="w-full text-gray-900 bg-primary-600 hover:bg-primary-700 focus:ring-4 focus:outline-none focus:ring-primary-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center "
68-
>
49+
<button type="submit" className="w-full text-gray-900 bg-primary-600 hover:bg-primary-700 focus:ring-4 focus:outline-none focus:ring-primary-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center ">
6950
Sign in
7051
</button>
7152
</form>

examples/create-react-app/src/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import App from "./App";
55
import { Grandeur } from "grandeur-js/react";
66
import { BrowserRouter } from "react-router-dom";
77

8-
const apiKey = "ApiKey";
9-
const token = "SecretKey";
8+
const apiKey = "grandeurlesd86lu7mgj0jjpb3uw0cbb";
9+
const token = "80a923adb1ab257fd51d388a34fe5e03351bd44c2e239bc621d2b064846b43c0";
1010

1111
const root = ReactDOM.createRoot(document.getElementById("root"));
1212
root.render(

examples/test/index.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import grandeur from "grandeur-js";
2+
3+
var project = grandeur.init("grandeurlesd86lu7mgj0jjpb3uw0cbb", "80a923adb1ab257fd51d388a34fe5e03351bd44c2e239bc621d2b064846b43c0");
4+
5+
var deviceID = "devicelesd875d7mgp0jjp6wic58io";
6+
7+
let email = "[email protected]";
8+
let password = "pakistan606";
9+
10+
var res = await project.auth().login(email, password);
11+
12+
var devices = project.devices();
13+
14+
// console.log(process.env);
15+
//
16+
// console.log(await devices.device(deviceID).get(""));
17+
18+
// project.onConnection((update) => console.log(update));
19+
20+
console.log(res);

0 commit comments

Comments
 (0)