Add lastStamp to availability and show it on people tiles

Server query extended with MAX(BU_BU) per user as LAST_STAMP,
exposed via the Availability model. Client formats it as
DD.MM. HH:mm next to the loggedIn dot, replacing the mocked time.
This commit is contained in:
2026-04-13 12:29:43 +02:00
parent 235b7cba18
commit 74992a020f
5 changed files with 23 additions and 4 deletions
+7 -2
View File
@@ -853,8 +853,13 @@ class Availability {
return; return;
} }
var dotClass = entry.loggedIn ? 'tapi-dot-on' : 'tapi-dot-off'; var dotClass = entry.loggedIn ? 'tapi-dot-on' : 'tapi-dot-off';
var mockedTime = '13.04. 08:30'; var time = '';
indicator.innerHTML = '<span class="tapi-dot ' + dotClass + '"></span><small>' + mockedTime + '</small>'; if (entry.lastStamp) {
var d = new Date(entry.lastStamp);
var pad = (n) => n.toString().padStart(2, '0');
time = pad(d.getDate()) + '.' + pad(d.getMonth() + 1) + '. ' + pad(d.getHours()) + ':' + pad(d.getMinutes());
}
indicator.innerHTML = '<span class="tapi-dot ' + dotClass + '"></span><small>' + time + '</small>';
} }
updateSquare(square) { updateSquare(square) {
var extension = square.dataset.tapiExtension; var extension = square.dataset.tapiExtension;
+1
View File
@@ -2,4 +2,5 @@ export class AvailabilityInfo {
public user: string; public user: string;
public loggedIn: boolean; public loggedIn: boolean;
public extension: string; public extension: string;
public lastStamp: string;
} }
+7 -2
View File
@@ -65,8 +65,13 @@ export class Availability {
return return
} }
var dotClass = entry.loggedIn ? 'tapi-dot-on' : 'tapi-dot-off' var dotClass = entry.loggedIn ? 'tapi-dot-on' : 'tapi-dot-off'
var mockedTime = '13.04. 08:30' var time = ''
indicator.innerHTML = '<span class="tapi-dot ' + dotClass + '"></span><small>' + mockedTime + '</small>' if (entry.lastStamp) {
var d = new Date(entry.lastStamp)
var pad = (n: number) => n.toString().padStart(2, '0')
time = pad(d.getDate()) + '.' + pad(d.getMonth() + 1) + '. ' + pad(d.getHours()) + ':' + pad(d.getMinutes())
}
indicator.innerHTML = '<span class="tapi-dot ' + dotClass + '"></span><small>' + time + '</small>'
} }
private updateSquare(square: HTMLElement) { private updateSquare(square: HTMLElement) {
@@ -11,4 +11,6 @@ public class Availability
public bool LOGGED_IN { get; set; } public bool LOGGED_IN { get; set; }
[JsonPropertyName("extension")] [JsonPropertyName("extension")]
public string? US_EXTENSION { get; set; } public string? US_EXTENSION { get; set; }
[JsonPropertyName("lastStamp")]
public DateTime? LAST_STAMP { get; set; }
} }
@@ -11,6 +11,7 @@ internal class ZeitConsensRepository(IConfiguration config) : Repository(config)
ma.MA_USER_NAME ma.MA_USER_NAME
,bu.LOGGED_IN ,bu.LOGGED_IN
,us.US_EXTENSION ,us.US_EXTENSION
,buLastStamp.LAST_STAMP
FROM dbo.MA_DATEN ma FROM dbo.MA_DATEN ma
INNER JOIN projectmanagement.dbo.CP_USER us on us.US_LOGINNAME = ma.MA_USER_NAME INNER JOIN projectmanagement.dbo.CP_USER us on us.US_LOGINNAME = ma.MA_USER_NAME
OUTER APPLY ( OUTER APPLY (
@@ -20,6 +21,11 @@ internal class ZeitConsensRepository(IConfiguration config) : Repository(config)
AND AND
BU_BU >= @from AND BU_BU < @to BU_BU >= @from AND BU_BU < @to
) bu ) bu
OUTER APPLY (
SELECT MAX(BU_BU) AS LAST_STAMP
FROM dbo.BU
WHERE bu.BU_MA_NR = ma.MA_NR
) buLastStamp
WHERE WHERE
ma.MA_USER_AKTIV = 1 ma.MA_USER_AKTIV = 1
"""; """;