Merge branch 'rc'

This commit is contained in:
Igor Kulikov 2024-12-06 13:06:24 +02:00
commit f21275b4bd
5 changed files with 31 additions and 10 deletions

View File

@ -64,7 +64,7 @@ public class OAuth2ClientServiceImpl extends AbstractEntityService implements OA
@Override @Override
public List<OAuth2ClientLoginInfo> findOAuth2ClientLoginInfosByMobilePkgNameAndPlatformType(String pkgName, PlatformType platformType) { public List<OAuth2ClientLoginInfo> findOAuth2ClientLoginInfosByMobilePkgNameAndPlatformType(String pkgName, PlatformType platformType) {
log.trace("Executing findOAuth2ClientLoginInfosByMobilePkgNameAndPlatformType pkgName=[{}] platformType=[{}]",pkgName, platformType); log.trace("Executing findOAuth2ClientLoginInfosByMobilePkgNameAndPlatformType pkgName=[{}] platformType=[{}]", pkgName, platformType);
return oauth2ClientDao.findEnabledByPkgNameAndPlatformType(pkgName, platformType) return oauth2ClientDao.findEnabledByPkgNameAndPlatformType(pkgName, platformType)
.stream() .stream()
.map(OAuth2Utils::toClientLoginInfo) .map(OAuth2Utils::toClientLoginInfo)

View File

@ -31,6 +31,7 @@ import org.thingsboard.server.dao.oauth2.OAuth2ClientDao;
import org.thingsboard.server.dao.sql.JpaAbstractDao; import org.thingsboard.server.dao.sql.JpaAbstractDao;
import org.thingsboard.server.dao.util.SqlDao; import org.thingsboard.server.dao.util.SqlDao;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -65,8 +66,17 @@ public class JpaOAuth2ClientDao extends JpaAbstractDao<OAuth2ClientEntity, OAuth
@Override @Override
public List<OAuth2Client> findEnabledByPkgNameAndPlatformType(String pkgName, PlatformType platformType) { public List<OAuth2Client> findEnabledByPkgNameAndPlatformType(String pkgName, PlatformType platformType) {
return DaoUtil.convertDataList(repository.findEnabledByPkgNameAndPlatformType(pkgName, List<OAuth2ClientEntity> clientEntities;
platformType != null ? platformType.name() : null)); if (platformType != null) {
clientEntities = switch (platformType) {
case ANDROID -> repository.findEnabledByAndroidPkgNameAndPlatformType(pkgName, platformType.name());
case IOS -> repository.findEnabledByIosPkgNameAndPlatformType(pkgName, platformType.name());
default -> Collections.emptyList();
};
} else {
clientEntities = Collections.emptyList();
}
return DaoUtil.convertDataList(clientEntities);
} }
@Override @Override

View File

@ -49,10 +49,20 @@ public interface OAuth2ClientRepository extends JpaRepository<OAuth2ClientEntity
"FROM OAuth2ClientEntity c " + "FROM OAuth2ClientEntity c " +
"LEFT JOIN MobileAppBundleOauth2ClientEntity ac ON c.id = ac.oauth2ClientId " + "LEFT JOIN MobileAppBundleOauth2ClientEntity ac ON c.id = ac.oauth2ClientId " +
"LEFT JOIN MobileAppBundleEntity b ON ac.mobileAppBundleId = b.id " + "LEFT JOIN MobileAppBundleEntity b ON ac.mobileAppBundleId = b.id " +
"LEFT JOIN MobileAppEntity andApp ON b.androidAppId = andApp.id LEFT JOIN MobileAppEntity iosApp ON b.iosAppID = iosApp.id " + "LEFT JOIN MobileAppEntity andApp ON b.androidAppId = andApp.id " +
"WHERE andApp.pkgName = :pkgName OR iosApp.pkgName = :pkgName AND b.oauth2Enabled = true " + "WHERE andApp.pkgName = :pkgName AND b.oauth2Enabled = true " +
"AND (:platformFilter IS NULL OR c.platforms IS NULL OR c.platforms = '' OR ilike(c.platforms, CONCAT('%', :platformFilter, '%')) = true)") "AND (:platformFilter IS NULL OR c.platforms IS NULL OR c.platforms = '' OR ilike(c.platforms, CONCAT('%', :platformFilter, '%')) = true)")
List<OAuth2ClientEntity> findEnabledByPkgNameAndPlatformType(@Param("pkgName") String pkgName, List<OAuth2ClientEntity> findEnabledByAndroidPkgNameAndPlatformType(@Param("pkgName") String pkgName,
@Param("platformFilter") String platformFilter);
@Query("SELECT c " +
"FROM OAuth2ClientEntity c " +
"LEFT JOIN MobileAppBundleOauth2ClientEntity ac ON c.id = ac.oauth2ClientId " +
"LEFT JOIN MobileAppBundleEntity b ON ac.mobileAppBundleId = b.id " +
"LEFT JOIN MobileAppEntity iosApp ON b.iosAppID = iosApp.id " +
"WHERE iosApp.pkgName = :pkgName AND b.oauth2Enabled = true " +
"AND (:platformFilter IS NULL OR c.platforms IS NULL OR c.platforms = '' OR ilike(c.platforms, CONCAT('%', :platformFilter, '%')) = true)")
List<OAuth2ClientEntity> findEnabledByIosPkgNameAndPlatformType(@Param("pkgName") String pkgName,
@Param("platformFilter") String platformFilter); @Param("platformFilter") String platformFilter);
@Query("SELECT c " + @Query("SELECT c " +

View File

@ -131,10 +131,10 @@ class ThingsboardSchemaForm extends React.Component<JsonFormProps, any> {
} }
if (form.condition) { if (form.condition) {
this.hasConditions = true; this.hasConditions = true;
if (!this.conditionFunction) { if (!form.conditionFunction) {
this.conditionFunction = new Function('form', 'model', 'index', `return ${form.condition};`); form.conditionFunction = new Function('form', 'model', 'index', `return ${form.condition};`);
} }
if (this.conditionFunction(form, model, index) === false) { if (form.conditionFunction(form, model, index) === false) {
return null; return null;
} }
} }

View File

@ -87,6 +87,7 @@ export interface JsonFormData {
required: boolean; required: boolean;
default?: any; default?: any;
condition?: string; condition?: string;
conditionFunction?: Function;
style?: any; style?: any;
rows?: number; rows?: number;
rowsMax?: number; rowsMax?: number;