<div class="cd-navbar-main">
- <cd-notification-panel *ngIf="isNotifPanelOpen"></cd-notification-panel>
+ <!-- ************************ -->
+ <!-- NOTIFICATION PANEL -->
+ <!-- ************************ -->
+ <cd-notification-panel
+ *ngIf="isNotifPanelOpen"
+ [isPanelOpen]="isNotifPanelOpen"></cd-notification-panel>
<!-- ************************ -->
<!-- HEADER -->
<!-- ************************ -->
-<div class="notification-panel">
- <cd-notification-header></cd-notification-header>
+<cds-modal
+ [open]="isPanelOpen"
+ size="xs"
+ cdsTheme="g10"
+ class="notification-panel__container"
+ hasScrollingContent="true"
+ @panelAnimation>
+ <cds-modal-header
+ [showCloseButton]="true">
+ <cd-notification-header></cd-notification-header>
+ </cds-modal-header>
<cd-notification-area></cd-notification-area>
- <cd-notification-footer></cd-notification-footer>
-</div>
+ <cds-modal-footer>
+ <cd-notification-footer></cd-notification-footer>
+ </cds-modal-footer>
+</cds-modal>
-@use '@carbon/styles/scss/theme';
@use '@carbon/styles/scss/spacing';
-@use '@carbon/styles/scss/themes';
-@use '@carbon/styles/scss/theme' as *;
+@use '@carbon/styles/scss/motion' as *;
-.notification-panel {
- @include theme.theme(themes.$g10);
+$block-class: notification-panel;
+$block-size: 38.5rem;
+.#{$block-class}__container {
position: fixed;
- top: spacing.$spacing-09;
- right: 0;
- width: 400px;
- height: 700px;
- background-color: $layer-01;
- box-shadow: $shadow;
- border: 1px solid $border-subtle-01;
- z-index: 6000;
- color: $text-primary;
- display: flex;
- flex-direction: column;
- overflow: hidden;
-
- cd-notification-header {
- flex: 0 0 auto;
- }
-
- cd-notification-area {
- flex: 1 1 auto;
- overflow-y: auto;
- min-height: 0; // Failing in firefox without this
- }
+ z-index: 2;
+ overflow: auto;
+ background-color: var(--cds-layer-01);
+ border-block-end: 1px solid var(--cds-border-subtle-02);
+ border-inline-start: 1px solid var(--cds-border-subtle-02);
+ box-shadow: 0 0.125rem 0.25rem var(--cds-overlay);
+ min-block-size: $block-size;
+ min-inline-size: 20rem;
+ inset-block-start: 3rem;
+ inset-inline-end: 0;
+ max-block-size: $block-size;
+ max-inline-size: 22.75rem;
}
-import { Component, ElementRef, HostListener } from '@angular/core';
+import { Component, Input } from '@angular/core';
import { NotificationService } from '~/app/shared/services/notification.service';
+import { trigger, transition, style, animate } from '@angular/animations';
@Component({
selector: 'cd-notification-panel',
templateUrl: './notification-panel.component.html',
styleUrls: ['./notification-panel.component.scss'],
- standalone: false
+ standalone: false,
+ animations: [
+ trigger('panelAnimation', [
+ transition(':enter', [
+ style({ opacity: 0, transform: 'translateY(-38.5rem)' }),
+ animate(
+ '240ms cubic-bezier(0.2, 0, 0.38, 0.9)',
+ style({ opacity: 1, transform: 'translateY(0)' })
+ )
+ ])
+ ])
+ ]
})
export class NotificationPanelComponent {
- constructor(public notificationService: NotificationService, private elementRef: ElementRef) {}
+ @Input() isPanelOpen: boolean = true;
- @HostListener('document:click', ['$event'])
- handleClickOutside(event: Event) {
- const clickedInside = this.elementRef.nativeElement.contains(event.target);
- if (!clickedInside) {
- this.notificationService.toggleSidebar(false, true);
- }
- }
+ constructor(public notificationService: NotificationService) {}
}
-import { Component, Input, OnDestroy, OnInit } from '@angular/core';
+import { Component, OnDestroy, OnInit } from '@angular/core';
import { Subscription } from 'rxjs';
import { ICON_TYPE, IconSize } from '~/app/shared/enum/icons.enum';
-import { CdNotification } from '~/app/shared/models/cd-notification';
import { NotificationService } from '~/app/shared/services/notification.service';
import { SummaryService } from '~/app/shared/services/summary.service';
standalone: false
})
export class NotificationsComponent implements OnInit, OnDestroy {
- @Input() isPanelOpen: boolean = false;
icons = ICON_TYPE;
iconSize = IconSize.size20;
hasRunningTasks = false;
hasNotifications = false;
- notificationCount = 0;
isMuted = false;
private subs = new Subscription();
this.subs.add(
this.summaryService.subscribe((summary) => {
this.hasRunningTasks = summary.executing_tasks.length > 0;
- })
- );
-
- this.subs.add(
- this.notificationService.data$.subscribe((notifications: CdNotification[]) => {
- this.hasNotifications = notifications.length > 0;
- this.notificationCount = notifications.length;
+ // TODO: when notifications are mute - show unread icon too
})
);
private activeToasts: ToastContent[] = [];
KEY = 'cdNotifications';
MUTE_KEY = 'cdNotificationsMuted';
- private readonly MAX_NOTIFICATIONS = 10;
constructor(
private taskMessageService: TaskMessageService,
const notifications = this.dataSource.getValue();
notifications.push(notification);
notifications.sort((a, b) => (a.timestamp > b.timestamp ? -1 : 1));
- while (notifications.length > this.MAX_NOTIFICATIONS) {
- notifications.pop();
- }
this.dataSource.next(notifications);
this.persistNotifications(notifications);
}