Skip to content

Commit

Permalink
Merge branch 'master-qa' into select_no_car
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasBrazi06 authored Dec 9, 2021
2 parents 2214115 + 2319022 commit 970d5d3
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 71 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ android {
applicationId "com.emobility"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 195
versionName "2.0.16"
versionCode 196
versionName "2.0.17"
missingDimensionStrategy 'react-native-camera', 'general'
}
splits {
Expand Down
2 changes: 1 addition & 1 deletion ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ SPEC CHECKSUMS:
DoubleConversion: cf9b38bf0b2d048436d9a82ad2abe1404f11e7de
Fabric: ea977e3cd9c20425516d3dafd3bf8c941c51223f
FBLazyVector: e686045572151edef46010a6f819ade377dfeb4b
FBReactNativeSpec: 52a80ca1a343877d4c72738fffcf539ac4a64dec
FBReactNativeSpec: e30d74099a6ef3e67364c1ecb8ab68197a5eb022
Firebase: 8db6f2d1b2c5e2984efba4949a145875a8f65fe5
FirebaseAnalytics: 5dd088bd2e67bb9d13dbf792d1164ceaf3052193
FirebaseCore: d889d9e12535b7f36ac8bfbf1713a0836a3012cd
Expand Down
4 changes: 2 additions & 2 deletions ios/eMobility.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@
"\"${PODS_CONFIGURATION_BUILD_DIR}/react-native-splash-screen\"",
"\"${PODS_CONFIGURATION_BUILD_DIR}/yoga\"",
);
MARKETING_VERSION = 2.0.16;
MARKETING_VERSION = 2.0.17;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -1100,7 +1100,7 @@
"\"${PODS_CONFIGURATION_BUILD_DIR}/react-native-splash-screen\"",
"\"${PODS_CONFIGURATION_BUILD_DIR}/yoga\"",
);
MARKETING_VERSION = 2.0.16;
MARKETING_VERSION = 2.0.17;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down
1 change: 0 additions & 1 deletion src/components/site-area/SiteAreaComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ interface State {}
export default class SiteAreaComponent extends React.Component<Props, State> {
public state: State;
public props: Props;
private counter = 0;

// eslint-disable-next-line no-useless-constructor
public constructor(props: Props) {
Expand Down
14 changes: 5 additions & 9 deletions src/provider/CentralServerProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export default class CentralServerProvider {
let tenantLogo = this.tenantLogosCache.get(tenant.subdomain);
if (!tenantLogo) {
// Call backend
const result = await this.axiosInstance.get(this.buildUtilRestEndpointUrl(ServerRoute.REST_TENANT_LOGO), {
const result = await this.axiosInstance.get(this.buildUtilRestEndpointUrl(ServerRoute.REST_TENANT_LOGO, null, tenant), {
headers: this.buildHeaders(),
responseType: 'arraybuffer',
params: {
Expand Down Expand Up @@ -1070,12 +1070,8 @@ export default class CentralServerProvider {
return this.tenant?.endpoint + '/v1/api';
}

private buildUtilRestServerURL(): string {
return this.tenant?.endpoint + '/v1/util';
}

private buildCentralRestServerServiceUtilURL(tenant: TenantConnection): string {
return tenant?.endpoint + '/client/util';
private buildUtilRestServerURL(tenant?: TenantConnection): string {
return (tenant?.endpoint ?? this.tenant?.endpoint) + '/v1/util';
}

private buildCentralRestServerServiceSecuredURL(): string {
Expand All @@ -1092,7 +1088,7 @@ export default class CentralServerProvider {
return `${urlPrefix}/${resolvedUrlPattern}`;
}

public buildUtilRestEndpointUrl(urlPatternAsString: ServerRoute, params: { [name: string]: string | number | null } = {}): string {
return this.buildRestEndpointUrl(urlPatternAsString, params, this.buildUtilRestServerURL());
public buildUtilRestEndpointUrl(urlPatternAsString: ServerRoute, params: { [name: string]: string | number | null } = {}, tenant?: TenantConnection): string {
return this.buildRestEndpointUrl(urlPatternAsString, params, this.buildUtilRestServerURL(tenant));
}
}
8 changes: 1 addition & 7 deletions src/screens/auth/eula/Eula.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,12 @@ export default class Eula extends BaseScreen<Props, State> {
<HeaderComponent
navigation={this.props.navigation}
title={I18n.t('authentication.eula')}
leftAction={() => {
this.props.navigation.navigate('Login');
return true;
}}
leftActionIcon={'navigate-before'}
hideHomeAction
/>
{loading ? (
<Spinner style={style.spinner} color="grey" />
) : (
<ScrollView style={style.container}>
<HTMLView value={eulaTextHtml} />
<HTMLView textComponentProps={{style: {color: Utils.getCurrentCommonColor().textColor}}} value={eulaTextHtml} />
</ScrollView>
)}
</Container>
Expand Down
11 changes: 6 additions & 5 deletions src/screens/auth/login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ export default class Login extends BaseScreen<Props, State> {
this.tenants = await this.centralServerProvider.getTenants();
this.setState({
tenantSubDomain: null,
tenantLogo: null,
tenantName: I18n.t('authentication.tenant'),
email: null,
password: null
Expand Down Expand Up @@ -286,17 +287,17 @@ export default class Login extends BaseScreen<Props, State> {
this.setState({
email: credentials.email,
password: credentials.password,
tenantSubDomain: tenant.subdomain,
tenantName: tenant.name,
tenantSubDomain: tenant?.subdomain,
tenantName: tenant?.name,
tenantLogo
});
} else {
// Set Tenant
this.setState({
email: null,
password: null,
tenantSubDomain: tenant.subdomain,
tenantName: tenant.name,
tenantSubDomain: tenant?.subdomain,
tenantName: tenant?.name,
tenantLogo
});
}
Expand Down Expand Up @@ -368,7 +369,7 @@ export default class Login extends BaseScreen<Props, State> {
<Form style={formStyle.form}>
<Button block style={formStyle.button} onPress={() => this.goToTenants()}>
<Text style={formStyle.buttonText} uppercase={false}>
{this.state.tenantName}
{this.state?.tenantName}
</Text>
</Button>
{this.state.errorTenantSubDomain &&
Expand Down
2 changes: 1 addition & 1 deletion src/screens/base-screen/BaseScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import CentralServerProvider from '../../provider/CentralServerProvider';
import ProviderFactory from '../../provider/ProviderFactory';
import SecurityProvider from '../../provider/SecurityProvider';
import BaseProps from '../../types/BaseProps';
import { AppStateStatus, BackHandler, NativeEventSubscription } from 'react-native';
import { BackHandler, NativeEventSubscription } from 'react-native';

export interface Props extends BaseProps {}

Expand Down
3 changes: 2 additions & 1 deletion src/screens/charging-stations/list/ChargingStations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ export default class ChargingStations extends BaseAutoRefreshScreen<Props, State

public async componentDidMount() {
// Get initial filters
await super.componentDidMount();
await super.componentDidMount()
this.siteArea = Utils.getParamFromNavigation(this.props.route, 'siteArea', null) as unknown as SiteArea;
const { navigation } = this.props;
await this.loadInitialFilters();
// Enable swipe for opening sidebar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export default function computeStyleSheet(): StyleSheet.NamedStyles<any> {
},
chargingStationMarker: {
fontSize: '30@s',
backgroundColor: commonColor.listBg
},
qrcodeButton: {
backgroundColor: commonColor.primary,
Expand Down
7 changes: 3 additions & 4 deletions src/screens/sidebar/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export default class SideBar extends React.Component<Props, State> {

public constructor(props: Props) {
super(props);
this.componentFocusUnsubscribe = this.props.navigation?.addListener('focus', () => this.componentDidFocus());
this.componentBlurUnsubscribe = this.props.navigation?.addListener('blur', () => this.componentDidFocus());
// this.componentFocusUnsubscribe = this.props.navigation?.addListener('focus', () => this.componentDidFocus());
// this.componentBlurUnsubscribe = this.props.navigation?.addListener('blur', () => this.componentDidFocus());
this.state = {
userToken: null,
tenantName: '',
Expand All @@ -58,7 +58,7 @@ export default class SideBar extends React.Component<Props, State> {
super.setState(state, callback);
};

public async componentDidFocus(): Promise<void> {
public async componentDidMount() {
this.centralServerProvider = await ProviderFactory.getProvider();
this.securityProvider = this.centralServerProvider?.getSecurityProvider();
await this.getUpdateDate();
Expand All @@ -85,7 +85,6 @@ export default class SideBar extends React.Component<Props, State> {
public getUserInfo = async () => {
// Logoff
const userInfo = this.centralServerProvider.getUserInfo();
// Add sites(
this.setState({
userToken: this.centralServerProvider.getUserInfo(),
isComponentOrganizationActive: this.securityProvider ? this.securityProvider.isComponentOrganizationActive() : false,
Expand Down
6 changes: 4 additions & 2 deletions src/screens/site-areas/SiteAreas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export default class SiteAreas extends BaseAutoRefreshScreen<Props, State> {

public async componentDidMount(triggerRefresh: boolean = true): Promise<void> {
super.componentDidMount(triggerRefresh);
this.site = Utils.getParamFromNavigation(this.props.route, 'site', null) as unknown as Site;
}

public componentDidFocus() {
Expand Down Expand Up @@ -332,12 +333,13 @@ export default class SiteAreas extends BaseAutoRefreshScreen<Props, State> {
renderMarker={(siteArea, index) => (
<Marker
key={`${siteArea.id}${index}${siteArea.name}`}
image={Utils.buildSiteStatusMarker(siteArea?.connectorStats)}
tracksViewChanges={false}
coordinate={{ longitude: siteArea.address.coordinates[0], latitude: siteArea.address.coordinates[1] }}
title={siteArea.name}
onPress={() => this.showMapSiteAreaDetail(siteArea)}
/>
>
<Icon type={'MaterialIcons'} name={'location-pin'} style={[style.siteAreaMarker, Utils.computeSiteMarkerStyle(siteArea?.connectorStats)]} />
</Marker>
)}
initialRegion={this.currentRegion}
onMapRegionChangeComplete={(region) => this.onMapRegionChangeComplete(region)}
Expand Down
3 changes: 3 additions & 0 deletions src/screens/site-areas/SiteAreasStyles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ export default function computeStyleSheet(): StyleSheet.NamedStyles<any> {
outlinedImage: {
borderColor: commonColor.listItemBackground,
borderWidth: 2
},
siteAreaMarker: {
fontSize: '40@s'
}
});
const portraitStyles = {};
Expand Down
13 changes: 11 additions & 2 deletions src/screens/sites/Sites.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ import standardLightLayout from '../../../assets/map/standard-light.png';
import satelliteLayout from '../../../assets/map/satellite.png';
import computeFabStyles from '../../components/fab/FabComponentStyles';
import ThemeManager from '../../custom-theme/ThemeManager';
import ConnectorStats from '../../types/ConnectorStats';
import statusMarkerAvailable from '../../../assets/icon/charging_station_available.png';
import statusMarkerChargingOrOccupied from '../../../assets/icon/charging_station_charging.png';
import statusMarkerUnavailable from '../../../assets/icon/charging_station_unavailable.png';
import computeConnectorStatusStyles
from '../../components/connector-status/ConnectorStatusComponentStyles';

export interface Props extends BaseProps {}

Expand Down Expand Up @@ -335,17 +341,20 @@ export default class Sites extends BaseAutoRefreshScreen<Props, State> {
renderMarker={(site, index) => (
<Marker
key={`${site.id}${index}${site.name}`}
image={Utils.buildSiteStatusMarker(site?.connectorStats)}
tracksViewChanges={false}
coordinate={{ longitude: site.address.coordinates[0], latitude: site.address.coordinates[1] }}
title={site.name}
onPress={() => this.showMapSiteDetail(site)}
/>
>
<Icon type={'MaterialIcons'} name={'location-pin'} style={[style.siteMarker, Utils.computeSiteMarkerStyle(site?.connectorStats)]} />
</Marker>
)}
initialRegion={this.currentRegion}
onMapRegionChangeComplete={(region) => this.onMapRegionChangeComplete(region)}
/>
</View>
)
}


}
5 changes: 4 additions & 1 deletion src/screens/sites/SitesStyles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ export default function computeStyleSheet(): StyleSheet.NamedStyles<any> {
outlinedImage: {
borderColor: commonColor.listItemBackground,
borderWidth: 2
}
},
siteMarker: {
fontSize: '40@s',
},
});
const portraitStyles = {};
const landscapeStyles = {};
Expand Down
40 changes: 8 additions & 32 deletions src/utils/Utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import Constants from './Constants';
import Message from './Message';
import { Region } from 'react-native-maps';
import LocationManager from '../location/LocationManager';
import computeConnectorStatusStyles
from '../components/connector-status/ConnectorStatusComponentStyles';

export default class Utils {
public static getEndpointCloud(): EndpointCloud[] {
Expand Down Expand Up @@ -947,42 +949,16 @@ export default class Utils {
return `${Utils.formatTimer(hours)}:${Utils.formatTimer(minutes)}`;
};

public static buildChargingStationStatusMarker(connectors: Connector[], inactive: boolean): any {
if (inactive) {
//TODO handle reserved status when implemented
return statusMarkerUnavailable;
} else if (connectors.find((connector) => connector.status === ChargePointStatus.AVAILABLE)) {
return statusMarkerAvailable;
} else if (
connectors.find((connector) => connector.status === ChargePointStatus.FINISHING) ||
connectors.find((connector) => connector.status === ChargePointStatus.PREPARING)
) {
return statusMarkerPreparingOrFinishing;
} else if (
connectors.find((connector) => connector.status === ChargePointStatus.CHARGING) ||
connectors.find((connector) => connector.status === ChargePointStatus.OCCUPIED)
) {
return statusMarkerChargingOrOccupied;
} else if (
connectors.find((connector) => connector.status === ChargePointStatus.SUSPENDED_EVSE) ||
connectors.find((connector) => connector.status === ChargePointStatus.SUSPENDED_EV)
) {
return statusMarkerSuspended;
} else if (connectors.find((connector) => connector.status === ChargePointStatus.FAULTED)) {
return statusMarkerFaulted;
}
return statusMarkerUnavailable;
}

public static buildSiteStatusMarker(connectorStats: ConnectorStats): any {
public static computeSiteMarkerStyle(connectorStats: ConnectorStats) {
const connectorStatusStyles = computeConnectorStatusStyles();
if (connectorStats.availableConnectors > 0) {
return statusMarkerAvailable;
return connectorStatusStyles.availableConnectorDescription;
} else if (connectorStats.chargingConnectors > 0) {
return statusMarkerChargingOrOccupied;
return connectorStatusStyles.chargingConnectorDescription;
} else if (connectorStats.unavailableConnectors > 0) {
return statusMarkerUnavailable;
return connectorStatusStyles.unavailableConnectorDescription;
} else {
return statusMarkerUnavailable;
return connectorStatusStyles.unavailableConnectorDescription;
}
}

Expand Down

0 comments on commit 970d5d3

Please sign in to comment.