Merge pull request #11579 from dashevchenko/oauth2ClientsSortFIx
Added sorting by title for oauth2 clients
This commit is contained in:
commit
b2e002293c
@ -107,8 +107,8 @@ public class DomainControllerTest extends AbstractControllerTest {
|
||||
doPut("/api/domain/" + savedDomain.getId() + "/oauth2Clients", List.of(savedOAuth2Client.getId().getId(), savedOAuth2Client2.getId().getId()));
|
||||
|
||||
DomainInfo retrievedDomainInfo = doGet("/api/domain/info/{id}", DomainInfo.class, savedDomain.getId().getId());
|
||||
assertThat(retrievedDomainInfo).isEqualTo(new DomainInfo(savedDomain, List.of(new OAuth2ClientInfo(savedOAuth2Client),
|
||||
new OAuth2ClientInfo(savedOAuth2Client2))));
|
||||
assertThat(retrievedDomainInfo).isEqualTo(new DomainInfo(savedDomain, List.of(new OAuth2ClientInfo(savedOAuth2Client2),
|
||||
new OAuth2ClientInfo(savedOAuth2Client))));
|
||||
|
||||
doPut("/api/domain/" + savedDomain.getId() + "/oauth2Clients", List.of(savedOAuth2Client2.getId().getId()));
|
||||
DomainInfo retrievedDomainInfo2 = doGet("/api/domain/info/{id}", DomainInfo.class, savedDomain.getId().getId());
|
||||
|
||||
@ -109,8 +109,8 @@ public class MobileAppControllerTest extends AbstractControllerTest {
|
||||
doPut("/api/mobileApp/" + savedMobileApp.getId() + "/oauth2Clients", List.of(savedOAuth2Client.getId().getId(), savedOAuth2Client2.getId().getId()));
|
||||
|
||||
MobileAppInfo retrievedMobileAppInfo = doGet("/api/mobileApp/info/{id}", MobileAppInfo.class, savedMobileApp.getId().getId());
|
||||
assertThat(retrievedMobileAppInfo).isEqualTo(new MobileAppInfo(savedMobileApp, List.of(new OAuth2ClientInfo(savedOAuth2Client),
|
||||
new OAuth2ClientInfo(savedOAuth2Client2))));
|
||||
assertThat(retrievedMobileAppInfo).isEqualTo(new MobileAppInfo(savedMobileApp, List.of(new OAuth2ClientInfo(savedOAuth2Client2),
|
||||
new OAuth2ClientInfo(savedOAuth2Client))));
|
||||
|
||||
doPut("/api/mobileApp/" + savedMobileApp.getId() + "/oauth2Clients", List.of(savedOAuth2Client2.getId().getId()));
|
||||
MobileAppInfo retrievedMobileAppInfo2 = doGet("/api/mobileApp/info/{id}", MobileAppInfo.class, savedMobileApp.getId().getId());
|
||||
|
||||
@ -36,6 +36,7 @@ import org.thingsboard.server.dao.eventsourcing.DeleteEntityEvent;
|
||||
import org.thingsboard.server.dao.eventsourcing.SaveEntityEvent;
|
||||
import org.thingsboard.server.dao.oauth2.OAuth2ClientDao;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@ -149,6 +150,7 @@ public class DomainServiceImpl extends AbstractEntityService implements DomainSe
|
||||
}
|
||||
List<OAuth2ClientInfo> clients = oauth2ClientDao.findByDomainId(domain.getUuidId()).stream()
|
||||
.map(OAuth2ClientInfo::new)
|
||||
.sorted(Comparator.comparing(OAuth2ClientInfo::getTitle))
|
||||
.collect(Collectors.toList());
|
||||
return new DomainInfo(domain, clients);
|
||||
}
|
||||
|
||||
@ -36,6 +36,7 @@ import org.thingsboard.server.dao.eventsourcing.DeleteEntityEvent;
|
||||
import org.thingsboard.server.dao.eventsourcing.SaveEntityEvent;
|
||||
import org.thingsboard.server.dao.oauth2.OAuth2ClientDao;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@ -143,6 +144,7 @@ public class MobileAppServiceImpl extends AbstractEntityService implements Mobil
|
||||
private MobileAppInfo getMobileAppInfo(MobileApp mobileApp) {
|
||||
List<OAuth2ClientInfo> clients = oauth2ClientDao.findByMobileAppId(mobileApp.getUuidId()).stream()
|
||||
.map(OAuth2ClientInfo::new)
|
||||
.sorted(Comparator.comparing(OAuth2ClientInfo::getTitle))
|
||||
.collect(Collectors.toList());
|
||||
return new MobileAppInfo(mobileApp, clients);
|
||||
}
|
||||
|
||||
@ -35,6 +35,7 @@ import org.thingsboard.server.dao.eventsourcing.DeleteEntityEvent;
|
||||
import org.thingsboard.server.dao.eventsourcing.SaveEntityEvent;
|
||||
import org.thingsboard.server.dao.service.DataValidator;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
@ -68,7 +69,6 @@ public class OAuth2ClientServiceImpl extends AbstractEntityService implements OA
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public OAuth2Client saveOAuth2Client(TenantId tenantId, OAuth2Client oAuth2Client) {
|
||||
log.trace("Executing saveOAuth2Client [{}]", oAuth2Client);
|
||||
oAuth2ClientDataValidator.validate(oAuth2Client, OAuth2Client::getTenantId);
|
||||
@ -96,7 +96,6 @@ public class OAuth2ClientServiceImpl extends AbstractEntityService implements OA
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteOAuth2ClientById(TenantId tenantId, OAuth2ClientId oAuth2ClientId) {
|
||||
log.trace("Executing deleteOAuth2ClientById [{}]", oAuth2ClientId);
|
||||
oauth2ClientDao.removeById(tenantId, oAuth2ClientId.getId());
|
||||
@ -126,6 +125,7 @@ public class OAuth2ClientServiceImpl extends AbstractEntityService implements OA
|
||||
return oauth2ClientDao.findByIds(tenantId.getId(), oAuth2ClientIds)
|
||||
.stream()
|
||||
.map(OAuth2ClientInfo::new)
|
||||
.sorted(Comparator.comparing(OAuth2ClientInfo::getTitle))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
@ -64,9 +64,8 @@ export class ClientsTableConfigResolver implements Resolve<EntityTableConfig<OAu
|
||||
|
||||
this.config.columns.push(
|
||||
new DateEntityTableColumn<OAuth2ClientInfo>('createdTime', 'common.created-time', this.datePipe, '170px'),
|
||||
new EntityTableColumn<OAuth2ClientInfo>('title', 'admin.oauth2.title', '35%'),
|
||||
new EntityTableColumn<OAuth2ClientInfo>('providerName', 'admin.oauth2.provider', '170px'),
|
||||
new EntityTableColumn<OAuth2ClientInfo>('platforms', 'admin.oauth2.allowed-platforms', '170px',
|
||||
new EntityTableColumn<OAuth2ClientInfo>('title', 'admin.oauth2.title', '350px'),
|
||||
new EntityTableColumn<OAuth2ClientInfo>('platforms', 'admin.oauth2.allowed-platforms', '100%',
|
||||
(clientInfo) => {
|
||||
return clientInfo.platforms && clientInfo.platforms.length ?
|
||||
clientInfo.platforms.map(platform => this.translate.instant(platformTypeTranslations.get(platform))).join(', ') :
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user