Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
app_examples
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vtap
app_examples
Commits
232f515b
Commit
232f515b
authored
Sep 23, 2021
by
Vikas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added weatherwidgetcontent component
parent
c18cecb7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
0 deletions
+45
-0
WeatherWidgetContents.js
openweathermap.org/WeatherWidgetContents.js
+45
-0
No files found.
openweathermap.org/WeatherWidgetContents.js
0 → 100644
View file @
232f515b
var
Contacts_Component_WeatherWidgetContents
=
VTAP
.
Component
.
Core
.
extend
({
data
()
{
weather_data
:
''
},
created
()
{
VTAP
.
Detail
.
Record
().
then
(
(
record
)
=>
{
//fetch weather details from openweathermap
VTAP
.
CustomApi
.
Get
(
'get_weather'
,
{
'city'
:
record
.
mailingcity
},
(
error
,
response
)
=>
{
if
(
response
&&
response
.
content
)
{
this
.
weather_data
=
JSON
.
parse
(
response
.
content
);
}
});
});
},
methods
:
{
getDisplayTime
(
timestamp
)
{
let
d
=
new
Date
(
timestamp
*
1000
).
toISOString
().
slice
(
0
,
19
).
replace
(
'T'
,
' '
).
split
(
' '
);
return
d
[
1
];
},
getDisplayTemperature
(
temp
)
{
return
Math
.
round
(
temp
-
273.15
);
}
},
template
:
`<div class='p-2 bg-white'>
<div class='p-2 d-flex align-items-center justify-content-center'><h4>Weather details</h4></div>
<div class='row' v-if="weather_data">
<div class='col-12'>
<table class='table table-striped'>
<tr><th>Properties</th><th>Value</th></tr>
<tr><td>Current Time</td><td>{{getDisplayTime(weather_data.dt+weather_data.timezone)}}</td></tr>
<tr><td>Sunrise Time</td><td>{{getDisplayTime(weather_data.sys.sunrise+weather_data.timezone)}}</td></tr>
<tr><td>Sunset Time</td><td>{{getDisplayTime(weather_data.sys.sunset+weather_data.timezone)}}</td></tr>
<tr><td>Max Temp</td><td>{{getDisplayTemperature(weather_data.main.temp_min)}} C</td></tr>
<tr><td>Min Temp</td><td>{{getDisplayTemperature(weather_data.main.temp_max)}} C</td></tr>
<tr><td>Weather description</td><td>{{weather_data.weather[0].description}}</td></tr>
</table>
</div>
</div>
<div v-else class='d-flex justify-content-center align-items-center' style='min-height:100px;'>
<b-spinner label="loading"></b-spinner>
</div>
</div>`
});
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment