Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Dashboard PV278
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Polaško
Dashboard PV278
Commits
a5ccbdcb
There was an error fetching the commit references. Please try again later.
Unverified
Commit
a5ccbdcb
authored
1 year ago
by
Karel Hala
Browse files
Options
Downloads
Patches
Plain Diff
Enable energy data Rest API
parent
80a96278
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/react-auth0-spa.js
+9
-31
9 additions, 31 deletions
src/react-auth0-spa.js
src/utils/helpers.js
+2
-30
2 additions, 30 deletions
src/utils/helpers.js
with
11 additions
and
61 deletions
src/react-auth0-spa.js
+
9
−
31
View file @
a5ccbdcb
...
...
@@ -15,36 +15,21 @@ export const Auth0Provider = ({ children, onRedirectCallback = DEFAULT_REDIRECT_
const
[
auth0Client
,
setAuth0
]
=
useState
();
const
[
loading
,
setLoading
]
=
useState
(
true
);
const
[
popupOpen
,
setPopupOpen
]
=
useState
(
false
);
const
[{
apiSun
,
apiTemp
,
apiAir
,
apiGermany
,
apiAustria
,
apiCroatia
,
apiCzechia
,
apiSlovakia
,
apiPoland
,
apiFrance
,
apiSweden
},
setAllApis
]
=
useState
({
apiSun
:
{},
apiTemp
:
{},
apiAir
:
{},
apiGermany
:
{},
apiAustria
:
{},
apiCroatia
:
{},
apiCzechia
:
{},
apiSlovakia
:
{},
apiPoland
:
{},
apiFrance
:
{},
apiSweden
:
{},
});
const
[{
apiSun
,
apiTemp
,
apiAir
,
apiEnergy
},
setAllApis
]
=
useState
({
apiSun
:
{},
apiTemp
:
{},
apiAir
:
{},
apiEnergy
:
{},
});
useEffect
(()
=>
{
if
(
user
)
{
const
{
sun
,
air
,
temp
,
germany
,
austria
,
croatia
,
czechia
,
slovakia
,
poland
,
france
,
sweden
}
=
user
;
const
{
sun
,
air
,
temp
,
energy
}
=
user
;
setAllApis
({
apiSun
:
createInstance
(
sun
),
apiTemp
:
createInstance
(
temp
),
apiAir
:
createInstance
(
air
),
apiGermany
:
createInstance
(
germany
),
apiAustria
:
createInstance
(
austria
),
apiCroatia
:
createInstance
(
croatia
),
apiCzechia
:
createInstance
(
czechia
),
apiSlovakia
:
createInstance
(
slovakia
),
apiPoland
:
createInstance
(
poland
),
apiFrance
:
createInstance
(
france
),
apiSweden
:
createInstance
(
sweden
),
apiEnergy
:
createInstance
(
energy
),
});
}
},
[
user
]);
...
...
@@ -133,14 +118,7 @@ export const Auth0Provider = ({ children, onRedirectCallback = DEFAULT_REDIRECT_
apiSun
,
apiAir
,
apiTemp
,
apiGermany
,
apiAustria
,
apiCroatia
,
apiCzechia
,
apiSlovakia
,
apiPoland
,
apiFrance
,
apiSweden
,
apiEnergy
,
loading
,
popupOpen
,
loginWithPopup
,
...
...
This diff is collapsed.
Click to expand it.
src/utils/helpers.js
+
2
−
30
View file @
a5ccbdcb
...
...
@@ -11,7 +11,7 @@ export const useType = () => {
};
export
const
useRest
=
(
type
)
=>
{
const
{
apiSun
,
apiTemp
,
apiAir
,
api
Germany
,
apiAustria
,
apiCroatia
,
apiCzechia
,
apiSlovakia
,
apiPoland
,
apiFrance
,
apiSweden
}
=
useAuth0
();
const
{
apiSun
,
apiTemp
,
apiAir
,
api
Energy
}
=
useAuth0
();
const
[{
resource
,
rest
},
setRestApi
]
=
useState
({});
const
typeMapper
=
useCallback
((
resourceType
)
=>
{
const
apiTypes
=
{
...
...
@@ -28,37 +28,9 @@ export const useRest = (type) => {
rest
:
'
temp-avg
'
,
},
germany
:
{
resource
:
api
German
y
,
resource
:
api
Energ
y
,
rest
:
'
germany
'
,
},
austria
:
{
resource
:
apiAustria
,
rest
:
'
austria
'
,
},
france
:
{
resource
:
apiFrance
,
rest
:
'
france
'
,
},
poland
:
{
resource
:
apiPoland
,
rest
:
'
poland
'
,
},
sweden
:
{
resource
:
apiSweden
,
rest
:
'
sweden
'
,
},
croatia
:
{
resource
:
apiCroatia
,
rest
:
'
croatia
'
,
},
czechia
:
{
resource
:
apiCzechia
,
rest
:
'
czechia
'
,
},
slovakia
:
{
resource
:
apiSlovakia
,
rest
:
'
slovakia
'
,
},
};
return
apiTypes
[
resourceType
]
||
apiTypes
.
sunshine
;
},
[]);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment