-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1899 from DSD-DBS/license-indicator
feat: Add indicator to warn when most T4C licenses are being used
- Loading branch information
Showing
12 changed files
with
402 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 16 additions & 16 deletions
32
frontend/src/app/openapi/api/settings-modelsources-t4-c-license-servers.service.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
frontend/src/app/sessions/license-indicator/license-indicator.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!-- | ||
~ SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors | ||
~ SPDX-License-Identifier: Apache-2.0 | ||
--> | ||
|
||
<div | ||
class="max-h-0 overflow-hidden transition-all duration-700" | ||
[ngClass]="{ | ||
'max-h-[100vh]': | ||
((licenseUsageWrapperService.licenseServerUsage$ | async)?.length ?? -1) > | ||
0, | ||
}" | ||
> | ||
@if ((licenseUsageWrapperService.licenseServerUsage$ | async) !== undefined) { | ||
@for ( | ||
licenseServer of licenseUsageWrapperService.licenseServerUsage$ | async; | ||
track licenseServer.id | ||
) { | ||
@if (licenseServer.usage) { | ||
<div | ||
class="mt-2 flex items-center gap-2 rounded border p-2 text-sm shadow" | ||
[class]="getLevel(licenseServer.usage)?.classes" | ||
> | ||
<mat-icon class="shrink-0">{{ | ||
getLevel(licenseServer.usage)?.icon | ||
}}</mat-icon> | ||
<span>{{ getLevel(licenseServer.usage)?.text }}</span> | ||
</div> | ||
} | ||
} | ||
} | ||
</div> |
47 changes: 47 additions & 0 deletions
47
frontend/src/app/sessions/license-indicator/license-indicator.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
import { AsyncPipe, NgClass } from '@angular/common'; | ||
import { Component } from '@angular/core'; | ||
import { MatIcon } from '@angular/material/icon'; | ||
import { T4CLicenseServerUsage } from '../../openapi'; | ||
import { LicenseUsageWrapperService } from './license-usage.service'; | ||
|
||
@Component({ | ||
selector: 'app-license-indicator', | ||
standalone: true, | ||
imports: [MatIcon, AsyncPipe, NgClass], | ||
templateUrl: './license-indicator.component.html', | ||
}) | ||
export class LicenseIndicatorComponent { | ||
constructor(public licenseUsageWrapperService: LicenseUsageWrapperService) {} | ||
|
||
getLevel(usage: T4CLicenseServerUsage) { | ||
const usagePercentage = (usage.total - usage.free) / usage.total; | ||
return this.levels.find( | ||
(level) => usagePercentage * 100 >= level.percentage, | ||
); | ||
} | ||
|
||
levels = [ | ||
{ | ||
percentage: 100, | ||
text: 'All TeamForCapella licenses are currently in use. You can start new sessions, but may encounter the error "Invalid license" when trying to use TeamForCapella. Please make sure to terminate your sessions after use.', | ||
icon: 'error', | ||
classes: 'bg-red-500 text-white', | ||
}, | ||
{ | ||
percentage: 75, | ||
text: 'Most TeamForCapella licenses are currently in use. Please make sure to terminate your sessions after use.', | ||
icon: 'warning', | ||
classes: 'bg-yellow-300', | ||
}, | ||
{ | ||
percentage: 0, | ||
text: 'TeamForCapella licenses are available. We do not expect any license issues in the session.', | ||
icon: 'check_circle', | ||
classes: '', | ||
}, | ||
]; | ||
} |
Oops, something went wrong.