Skip to content

Commit

Permalink
Remove hard string and update cms
Browse files Browse the repository at this point in the history
  • Loading branch information
ndkhanh-axonivy committed Mar 5, 2024
1 parent f615a8c commit 800b493
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 20 deletions.
18 changes: 18 additions & 0 deletions open-weather-connector-demo/cms/cms_en.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Dialogs:
com:
axonivy:
connector:
openweather:
demo:
ui:
ForecastWeatherDemo:
CityNameLabel: City name
CountryCodeLabel: Country code
Header: Find Weather Forecasts in Any City
HumidityLabel: Humidity
PrecipitationLabel: Precipitation
SearchLabel: Search
StateCodeLabel: State code
TemperatureLabel: Temperature
Title: ForecastWeatherDemo
WindSpeedLabel: Wind speed
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"type" : "DialogCall",
"name" : "ForecastWeatherDemo",
"config" : {
"dialogId" : "com.axonivy.connector.openweather.open.weather.connector.demo.ui.ForecastWeatherDemo",
"dialogId" : "com.axonivy.connector.openweather.demo.ui.ForecastWeatherDemo",
"startMethod" : "start()"
},
"visual" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import org.openweathermap.api.data2_5.client.Forecast;

import com.axonivy.connector.openweather.util.Constants;

import ch.ivyteam.ivy.process.call.SubProcessCall;
import ch.ivyteam.ivy.process.call.SubProcessCallResult;

Expand All @@ -20,13 +22,15 @@ public static ForecastService getInstance() {

public Optional<Forecast> fetchForecastThreeHourlyFiveDay(String searchCityName, String searchCountryCode,
String searchStateCode, String units) {
SubProcessCallResult callResult = SubProcessCall.withPath("connector/ForecastWeather")
.withStartName("getForecastWeatherByLocationName").withParam("cityName", searchCityName)
.withParam("countryCode", searchCountryCode).withParam("stateCode", searchStateCode)
.withParam("units", units).call();
SubProcessCallResult callResult = SubProcessCall.withPath(Constants.FORECAST_WEATHER_CONNECTOR)
.withStartName(Constants.GET_FORECAST_WEATHER_BY_LOCATION_START_NAME)
.withParam(Constants.CITY_NAME_PARAM_NAME, searchCityName)
.withParam(Constants.COUNTRY_CODE_PARAM_NAME, searchCountryCode)
.withParam(Constants.STATE_CODE_PARAM_NAME, searchStateCode)
.withParam(Constants.UNITS_PARAM_NAME, units).call();

if (callResult != null) {
Object forecastWeather = callResult.get("forecastWeather");
Object forecastWeather = callResult.get(Constants.FORECAST_WEATHER_RESULT_NAME);
if (forecastWeather instanceof Forecast) {
return Optional.of((Forecast) forecastWeather);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ public class Constants {
public static final String DEFAULT_TYPE_OF_DEGREE = CELSIUS_TYPE_OF_DEGREE;
public static final String DEFAULT_SPEED_UNIT = SPEED_METER_UNIT;
public static final int DEFAULT_CHART_WINDOW_SIZE = 8;

public static final String FORECAST_WEATHER_CONNECTOR = "connector/ForecastWeather";
public static final String GET_FORECAST_WEATHER_BY_LOCATION_START_NAME = "getForecastWeatherByLocationName";
public static final String CITY_NAME_PARAM_NAME = "cityName";
public static final String COUNTRY_CODE_PARAM_NAME = "countryCode";
public static final String STATE_CODE_PARAM_NAME = "stateCode";
public static final String UNITS_PARAM_NAME = "units";
public static final String FORECAST_WEATHER_RESULT_NAME = "forecastWeather";

private Constants() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
xmlns:pe="http://primefaces.org/ui/extensions">
<h:body>
<ui:composition template="/layouts/frame-10.xhtml">
<ui:define name="title">ForecastWeatherDemo</ui:define>
<ui:define name="title">#{ivy.cms.co('/Dialogs/com/axonivy/connector/openweather/demo/ui/ForecastWeatherDemo/Title')}</ui:define>
<ui:define name="content">
<h:outputStylesheet name="layouts/styles/forecastweather.css" />
<p:outputPanel styleClass="forecast-weather-panel">
<h1>Find Weather Forecasts in Any City</h1>
<h1>#{ivy.cms.co('/Dialogs/com/axonivy/connector/openweather/demo/ui/ForecastWeatherDemo/Header')}</h1>

<p:spacer height="20" />

Expand All @@ -32,20 +32,25 @@

<h:panelGroup styleClass="ui-float-label">
<p:inputText value="#{forecastWeatherBean.searchCityName}" />
<p:outputLabel for="@previous" value="City name" />
<p:outputLabel for="@previous"
value="#{ivy.cms.co('/Dialogs/com/axonivy/connector/openweather/demo/ui/ForecastWeatherDemo/CityNameLabel')}" />
</h:panelGroup>

<h:panelGroup styleClass="ui-float-label">
<p:inputText value="#{forecastWeatherBean.searchCountryCode}" />
<p:outputLabel for="@previous" value="Country code" />
<p:outputLabel for="@previous"
value="#{ivy.cms.co('/Dialogs/com/axonivy/connector/openweather/demo/ui/ForecastWeatherDemo/CountryCodeLabel')}" />
</h:panelGroup>

<h:panelGroup styleClass="ui-float-label">
<p:inputText value="#{forecastWeatherBean.searchStateCode}" />
<p:outputLabel for="@previous" value="State code" />
<p:outputLabel for="@previous"
value="#{ivy.cms.co('/Dialogs/com/axonivy/connector/openweather/demo/ui/ForecastWeatherDemo/StateCodeLabel')}" />
</h:panelGroup>

<p:commandButton value="Search" icon="pi pi-search" update="form"
<p:commandButton
value="#{ivy.cms.co('/Dialogs/com/axonivy/connector/openweather/demo/ui/ForecastWeatherDemo/SearchLabel')}"
icon="pi pi-search" update="form"
actionListener="#{forecastWeatherBean.search}" />
</p:panelGrid>

Expand Down Expand Up @@ -94,11 +99,11 @@
styleClass="weather-other-detail-container p-mt-4"
columnClasses="ui-g-6, ui-g-6">
<p:outputPanel>
<div>Humidity</div>
<div>#{ivy.cms.co('/Dialogs/com/axonivy/connector/openweather/demo/ui/ForecastWeatherDemo/HumidityLabel')}</div>
<div class="weather-humidity-detail">#{forecastWeatherBean.currentHumidity}%</div>
</p:outputPanel>
<p:outputPanel>
<div>Wind speed</div>
<div>#{ivy.cms.co('/Dialogs/com/axonivy/connector/openweather/demo/ui/ForecastWeatherDemo/WindSpeedLabel')}</div>
<div class="weather-windspeed-detail">#{forecastWeatherBean.currentWindSpeed}#{forecastWeatherBean.speedUnit}</div>
</p:outputPanel>
</p:panelGrid>
Expand All @@ -107,14 +112,16 @@
<p:outputPanel styleClass="weather-chart-btn-container">
<p:tabView id="weather-chart-panel" styleClass="weather-tab-view">
<p:ajax event="tabChange" oncomplete="panChartByCurrentValue()" />
<p:tab title="Temperature">
<p:tab
title="#{ivy.cms.co('/Dialogs/com/axonivy/connector/openweather/demo/ui/ForecastWeatherDemo/TemperatureLabel')}">
<p:lineChart id="temp-chart" widgetVar="tempChartWidgetVar"
model="#{forecastWeatherBean.temperatureModel}"
style="cursor: pointer; width: 20px; height: 5px;"
styleClass="weather-chart" />
</p:tab>

<p:tab title="Precipitation">
<p:tab
title="#{ivy.cms.co('/Dialogs/com/axonivy/connector/openweather/demo/ui/ForecastWeatherDemo/PrecipitationLabel')}">
<p:barChart id="pop-chart" widgetVar="popChartWidgetVar"
model="#{forecastWeatherBean.precipitationModel}"
style="cursor: pointer; width: 20px; height: 5px;"
Expand All @@ -129,7 +136,8 @@
<h:commandLink
styleClass="weather-date-btn #{status.index == forecastWeatherBean.selectedDateIndex ? 'weather-date-selected' : ''}"
action="#{forecastWeatherBean.setSelectedDateIndex(status.index)}">
<p:ajax update=":form:forecast-panel :form:forecast-btn-panel :form:property-panel"
<p:ajax
update=":form:forecast-panel :form:forecast-btn-panel :form:property-panel"
oncomplete="panChart(#{dailyForecastDisplayInfo.chartWindowStartX}, #{dailyForecastDisplayInfo.chartWindowEndX})" />
<p:outputPanel styleClass="p-mb-2">
<span class="weather-date-btn-label">#{status.first ?
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ForecastWeatherDemoData #class
com.axonivy.connector.openweather.demo.ui.ForecastWeatherDemo #namespace
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"id" : "18D69D45CF17FC2E",
"kind" : "HTML_DIALOG",
"config" : {
"data" : "com.axonivy.connector.openweather.open.weather.connector.demo.ui.ForecastWeatherDemo.ForecastWeatherDemoData"
"data" : "com.axonivy.connector.openweather.demo.ui.ForecastWeatherDemo.ForecastWeatherDemoData"
},
"elements" : [ {
"id" : "f0",
Expand Down

This file was deleted.

0 comments on commit 800b493

Please sign in to comment.