Skip to content

Commit ee60d4b

Browse files
feat(#3798): Show creation and last login date in user configuration … (#3802)
1 parent 396d62a commit ee60d4b

File tree

16 files changed

+102
-38
lines changed

16 files changed

+102
-38
lines changed

streampipes-model-client/src/main/java/org/apache/streampipes/model/client/user/UserAccount.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ public class UserAccount extends Principal {
4242
protected boolean darkMode = false;
4343
protected boolean hasAcknowledged = false;
4444

45+
protected long createdAtMillis;
46+
protected long lastLoginAtMillis;
47+
4548
/**
4649
* The authentication provider (LOCAL or one of the configured OAuth providers
4750
*/
@@ -55,6 +58,7 @@ public UserAccount() {
5558
this.preferredDataProcessors = new ArrayList<>();
5659
this.preferredDataSinks = new ArrayList<>();
5760
this.preferredDataStreams = new ArrayList<>();
61+
this.createdAtMillis = System.currentTimeMillis();
5862
this.provider = UserAccount.LOCAL;
5963
}
6064

@@ -190,4 +194,20 @@ public boolean isHasAcknowledged() {
190194
public void setHasAcknowledged(boolean hasAcknowledged) {
191195
this.hasAcknowledged = hasAcknowledged;
192196
}
197+
198+
public long getCreatedAtMillis() {
199+
return createdAtMillis;
200+
}
201+
202+
public void setCreatedAtMillis(long createdAtMillis) {
203+
this.createdAtMillis = createdAtMillis;
204+
}
205+
206+
public long getLastLoginAtMillis() {
207+
return lastLoginAtMillis;
208+
}
209+
210+
public void setLastLoginAtMillis(long lastLoginAtMillis) {
211+
this.lastLoginAtMillis = lastLoginAtMillis;
212+
}
193213
}

streampipes-resource-management/src/main/java/org/apache/streampipes/resource/management/UserResourceManager.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ public void activateAccount(String activationCode) throws UserNotFoundException
134134
}
135135
}
136136

137+
public void updateUser(Principal principal) {
138+
db.updateUser(principal);
139+
}
140+
137141
private void createTokenAndSendActivationMail(String username) throws IOException {
138142
String activationCode = TokenUtil.generateToken(RECOVERY_TOKEN_LENGTH);
139143
storeActivationCode(username, activationCode);
@@ -194,7 +198,7 @@ private Environment getEnvironment() {
194198
}
195199

196200

197-
public void registerOauthUser(UserAccount userAccount) {
201+
public void storeUser(UserAccount userAccount) {
198202
db.storeUser(userAccount);
199203
}
200204
}

streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/Authentication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ private ResponseEntity<JwtAuthenticationResponse> processAuth(org.springframewor
157157
Principal principal = ((PrincipalUserDetails<?>) auth.getPrincipal()).getDetails();
158158
if (principal instanceof UserAccount) {
159159
JwtAuthenticationResponse tokenResp = makeJwtResponse(auth);
160+
((UserAccount) principal).setLastLoginAtMillis(System.currentTimeMillis());
161+
getSpResourceManager().manageUsers().updateUser(principal);
160162
return ok(tokenResp);
161163
} else {
162164
throw new BadCredentialsException("Could not create auth token");

streampipes-service-core/src/main/java/org/apache/streampipes/service/core/oauth2/UserService.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,13 @@ public OidcUserAccountDetails processUserRegistration(String registrationId,
9292
);
9393
}
9494
applyRoles(user, oAuthConfig, attributes, false);
95+
user.setLastLoginAtMillis(System.currentTimeMillis());
9596
userStorage.updateUser(user);
9697
} else {
9798
user = toUserAccount(registrationId, principalId, email, fullName);
99+
user.setLastLoginAtMillis(System.currentTimeMillis());
98100
applyRoles(user, oAuthConfig, attributes, true);
99-
new UserResourceManager().registerOauthUser(user);
101+
new UserResourceManager().storeUser(user);
100102
}
101103

102104
user = (UserAccount) userStorage.getUserById(principalId);

ui/projects/streampipes/platform-services/src/lib/model/gen/streampipes-model-client.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19+
1920
/* tslint:disable */
2021
/* eslint-disable */
2122
// @ts-nocheck
22-
// Generated using typescript-generator version 3.2.1263 on 2025-09-09 16:10:12.
23+
// Generated using typescript-generator version 3.2.1263 on 2025-10-01 08:36:56.
2324

24-
import { Storable } from '.streampipes-model';
25+
import { Storable } from './streampipes-model';
2526

2627
export class Group implements Storable {
2728
alternateIds: string[];
@@ -240,11 +241,13 @@ export class ServiceAccount extends Principal {
240241
}
241242

242243
export class UserAccount extends Principal {
244+
createdAtMillis: number;
243245
darkMode: boolean;
244246
externallyManagedRoles: boolean;
245247
fullName: string;
246248
hasAcknowledged: boolean;
247249
hideTutorial: boolean;
250+
lastLoginAtMillis: number;
248251
password: string;
249252
preferredDataProcessors: string[];
250253
preferredDataSinks: string[];
@@ -258,11 +261,13 @@ export class UserAccount extends Principal {
258261
}
259262
const instance = target || new UserAccount();
260263
super.fromData(data, instance);
264+
instance.createdAtMillis = data.createdAtMillis;
261265
instance.darkMode = data.darkMode;
262266
instance.externallyManagedRoles = data.externallyManagedRoles;
263267
instance.fullName = data.fullName;
264268
instance.hasAcknowledged = data.hasAcknowledged;
265269
instance.hideTutorial = data.hideTutorial;
270+
instance.lastLoginAtMillis = data.lastLoginAtMillis;
266271
instance.password = data.password;
267272
instance.preferredDataProcessors = __getCopyArrayFn(
268273
__identity<string>(),

ui/projects/streampipes/platform-services/src/lib/model/gen/streampipes-model.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19+
1920
/* tslint:disable */
2021
/* eslint-disable */
2122
// @ts-nocheck
22-
// Generated using typescript-generator version 3.2.1263 on 2025-09-09 16:10:11.
23+
// Generated using typescript-generator version 3.2.1263 on 2025-10-01 08:36:50.
2324

2425
export class NamedStreamPipesEntity implements Storable {
2526
'@class':

ui/projects/streampipes/shared-ui/src/lib/components/sp-label/sp-label.component.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
border-radius: 15px;
2121
min-width: 50px;
2222
padding: 5px 7px;
23-
border: 1px solid;
2423
display: inline-block;
2524
text-align: center;
2625
}

ui/projects/streampipes/shared-ui/src/lib/components/sp-label/sp-label.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ import { SpColorizationService } from '../../services/colorization.service';
2727
})
2828
export class SpLabelComponent implements OnInit {
2929
@Input()
30-
labelText: string;
30+
labelText: string | number;
3131

3232
@Input()
3333
small = false;
3434

3535
@Input()
3636
size: 'small' | 'medium' | 'large' = 'large';
3737

38-
_labelBackground: string;
38+
_labelBackground: string = 'var(--color-bg-2)';
3939

40-
labelTextColor = '';
40+
labelTextColor = 'var(--color-default-text)';
4141
cssClass = '';
4242

4343
constructor(private colorizationService: SpColorizationService) {}

ui/projects/streampipes/shared-ui/src/lib/components/split-section/split-section.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<div fxFlex="100" fxLayout="column">
2020
<div fxLayout="row">
21-
<div fxFlex="300px" fxLayout="column" class="split-section">
21+
<div fxFlex="250px" fxLayout="column" class="split-section">
2222
<div class="split-section-title">{{ title }}</div>
2323
<div class="split-section-description">{{ subtitle }}</div>
2424
</div>

ui/src/app/configuration/configuration.module.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ import { SpConfigurationLinkSettingsComponent } from './general-configuration/li
8282
import { SitesConfigurationComponent } from './sites-configuration/sites-configuration.component';
8383
import { LocationFeaturesConfigurationComponent } from './sites-configuration/location-features-configuration/location-features-configuration.component';
8484
import { SiteAreaConfigurationComponent } from './sites-configuration/site-area-configuration/site-area-configuration.component';
85-
import { MatSort } from '@angular/material/sort';
85+
import { MatSort, MatSortModule } from '@angular/material/sort';
8686
import { ManageSiteDialogComponent } from './dialog/manage-site/manage-site-dialog.component';
8787
import { EditAssetLocationComponent } from './dialog/manage-site/edit-location/edit-location.component';
8888
import { EditAssetLocationAreaComponent } from './dialog/manage-site/edit-location/edit-location-area/edit-location-area.component';
@@ -129,6 +129,7 @@ import { SelectDataExportComponent } from './dialog/data-retention-dialog/compon
129129
MatPaginatorModule,
130130
MatRadioModule,
131131
MatSelectModule,
132+
MatSortModule,
132133
FormsModule,
133134
DragDropModule,
134135
CoreUiModule,

0 commit comments

Comments
 (0)