Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[38648] Loading indicator when loading "all" notifications (content loader component) (#9625)

Behrokh Satarnejadd8a4ddfce35f
diff --git a/frontend/package-lock.json b/frontend/package-lock.json
index 2d724dec95c..617a946667b 100644
--- a/frontend/package-lock.json
+++ b/frontend/package-lock.json
@@ -2216,6 +2216,21 @@
}
}
},
+ "@ngneat/content-loader": {
+ "version": "6.1.0",
+ "resolved": "https://registry.npmjs.org/@ngneat/content-loader/-/content-loader-6.1.0.tgz",
+ "integrity": "sha512-gOidmlCG7ljGD8Sv/or/tU2pVTNFD9fT92KWfw0vlw1Ca7r5oDClA8jwi0GP7KhCb4yfand9B+Ut4B0GoQrstQ==",
+ "requires": {
+ "tslib": "^2.1.0"
+ },
+ "dependencies": {
+ "tslib": {
+ "version": "2.3.1",
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
+ "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
+ }
+ }
+ },
"@ngtools/webpack": {
"version": "12.0.2",
"resolved": "https://registry.npmjs.org/@ngtools/webpack/-/webpack-12.0.2.tgz",
diff --git a/frontend/package.json b/frontend/package.json
index fc6757fa92e..0b66751fdd3 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -79,6 +79,7 @@
"@kolkov/ngx-gallery": "^1.0.11",
"@ng-select/ng-option-highlight": "0.0.5",
"@ng-select/ng-select": "^4.0.4",
+ "@ngneat/content-loader": "^6.1.0",
"@ngx-formly/core": "^5.10.19",
"@sentry/angular": "6.2.3",
"@sentry/tracing": "6.2.3",
diff --git a/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.html b/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.html
index 6c51edb5e83..a18d2baf598 100644
--- a/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.html
+++ b/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.html
@@ -1,4 +1,9 @@
<div class="op-ian-center">
+ <div class="op-ian-center--loading-indicator" *ngIf="loading$ | async">
+ <op-content-loader>
+ <svg:rect x="0" y="0" width="100%" height="100%" rx="1" />
+ </op-content-loader>
+ </div>
<div class="op-ian-center--content">
<ng-container *ngIf="(hasNotifications$ | async) as notifications; else noResults">
<cdk-virtual-scroll-viewport
@@ -14,7 +19,7 @@
</cdk-virtual-scroll-viewport>
</ng-container>
<ng-template #noResults>
- <div class="generic-table--no-results-container">
+ <div class="generic-table--no-results-container" *ngIf="(loading$ | async) === false">
<span
class="generic-table--no-results-title"
>
diff --git a/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.sass b/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.sass
index e6275bf577a..105f2feb00b 100644
--- a/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.sass
+++ b/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.sass
@@ -14,6 +14,11 @@
text-align: center
font-style: italic
+ // While loading, appear to be showing one item row
+ &--loading-indicator
+ height: 90px
+ overflow: hidden // FIXME this shouldn't be necessary with proper svg scaling
+
:host
.-browser-safari &
// Because of Safari's viewport bug, the address bar overlaps content with height: 100vh
diff --git a/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.ts b/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.ts
index ec348e5354e..b92e9bf92dd 100644
--- a/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.ts
+++ b/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.ts
@@ -34,6 +34,8 @@ export class InAppNotificationCenterComponent implements OnInit {
notifications$ = this.storeService.query.notifications$;
+ loading$ = this.storeService.query.selectLoading();
+
noResultText$ = this
.storeService
.query
diff --git a/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts b/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts
index 76e239a5d4c..f1f03c7d138 100644
--- a/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts
+++ b/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts
@@ -8,6 +8,7 @@ import {
} from './ian-center.store';
import {
map,
+ switchMap,
take,
} from 'rxjs/operators';
import {
@@ -16,7 +17,10 @@ import {
} from 'core-app/core/state/in-app-notifications/in-app-notifications.actions';
import { InAppNotification } from 'core-app/core/state/in-app-notifications/in-app-notification.model';
import { IanCenterQuery } from 'core-app/features/in-app-notifications/center/state/ian-center.query';
-import { ID } from '@datorama/akita';
+import {
+ ID,
+ setLoading,
+} from '@datorama/akita';
import {
EffectCallback,
EffectHandler,
@@ -83,12 +87,14 @@ export class IanCenterService {
private reload() {
this.resourceService
.fetchNotifications(this.query.params)
- .subscribe(
- (results) => this.sideLoadInvolvedWorkPackages(results._embedded.elements),
- );
+ .pipe(
+ setLoading(this.store),
+ switchMap((results) => from(this.sideLoadInvolvedWorkPackages(results._embedded.elements))),
+ )
+ .subscribe();
}
- private sideLoadInvolvedWorkPackages(elements:InAppNotification[]):void {
+ private sideLoadInvolvedWorkPackages(elements:InAppNotification[]):Promise<unknown> {
const { cache } = this.apiV3Service.work_packages;
const wpIds = elements
.map((element) => {
@@ -109,5 +115,7 @@ export class IanCenterService {
from(promise).pipe(map(() => cache.current(id)!)),
);
});
+
+ return promise;
}
}
diff --git a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.html b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.html
index c01c766be33..e8b86dc478c 100644
--- a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.html
+++ b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.html
@@ -5,13 +5,13 @@
attr.data-qa-selector="op-ian-notification-item-{{notification.id}}"
[attr.data-qa-ian-read]="notification.readIAN === true || undefined"
>
- <button
+ <ng-container *ngIf="workPackage$ && (workPackage$ | async) as workPackage; else workPackageLoading">
+ <button
type="button"
class="op-ian-item--row"
[class.op-ian-item--row_unexpandable]="unexpandable"
(click)="showDetails()"
>
- <ng-container *ngIf="workPackage$ && (workPackage$ | async) as workPackage; else workPackageLoading">
<div
class="op-ian-item--top-line"
>
@@ -105,14 +105,17 @@
</span>
</div>
</div>
- </ng-container>
-
- <ng-template #workPackageLoading>
- <span
- *ngIf="workPackage$"
- class="op-ian-item--middle-line"
- [textContent]="text.loading"
- ></span>
- </ng-template>
</button>
+ </ng-container>
+ <ng-template #workPackageLoading>
+ <op-content-loader
+ *ngIf="workPackage$"
+ class="op-ian-item--loading"
+ viewBox="0 0 1000 20"
+ >
+ <svg:rect x="0" y="0" width="100%" height="5" rx="1" />
+ <svg:rect x="0" y="7" width="100%" height="5" rx="1" />
+ <svg:rect x="0" y="14" width="100%" height="5" rx="1" />
+ </op-content-loader>
+ </ng-template>
</div>
diff --git a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.sass b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.sass
index dd8329f51f8..e3b3b53ed85 100644
--- a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.sass
+++ b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.sass
@@ -2,6 +2,9 @@
$ian-bg-color: #F9F9F9
$ian-bg-hover-color: #F1F8FF
+// This needs to be set in the itemSize of
+// the virtual scroller
+$ian-height: 90px
$subject-font-size: 14px
.op-ian-item
@@ -11,9 +14,7 @@ $subject-font-size: 14px
font-size: 0.9rem
border: 1px solid var(--content-default-border-color)
border-radius: 2px
- // This needs to be set in the itemSize of
- // the virtual scroller
- height: 90px
+ height: $ian-height
&:hover
background: $ian-bg-hover-color
@@ -98,3 +99,11 @@ $subject-font-size: 14px
&--button
&:hover
color: var(--content-link-hover-active-color)
+
+ &--loading
+ height: 100%
+ display: block
+
+ svg
+ // Height - padding
+ height: calc(#{$ian-height} - 20px)
diff --git a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.ts b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.ts
index 42018ae3570..176a4d55eb0 100644
--- a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.ts
+++ b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.ts
@@ -5,6 +5,7 @@ import {
Input,
OnInit,
Output,
+ ViewEncapsulation,
} from '@angular/core';
import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';
import {
@@ -36,6 +37,7 @@ import { IanCenterService } from 'core-app/features/in-app-notifications/center/
templateUrl: './in-app-notification-entry.component.html',
styleUrls: ['./in-app-notification-entry.component.sass'],
changeDetection: ChangeDetectionStrategy.OnPush,
+ encapsulation: ViewEncapsulation.None,
})
export class InAppNotificationEntryComponent implements OnInit {
@Input() notification:InAppNotification;
diff --git a/frontend/src/app/features/in-app-notifications/in-app-notifications.module.ts b/frontend/src/app/features/in-app-notifications/in-app-notifications.module.ts
index f69f628ec3f..89cfaa51926 100644
--- a/frontend/src/app/features/in-app-notifications/in-app-notifications.module.ts
+++ b/frontend/src/app/features/in-app-notifications/in-app-notifications.module.ts
@@ -16,6 +16,7 @@ import { InAppNotificationStatusComponent } from './entry/status/in-app-notifica
import { NotificationSettingsButtonComponent } from './center/toolbar/settings/notification-settings-button.component';
import { ActivateFacetButtonComponent } from './center/toolbar/facet/activate-facet-button.component';
import { MarkAllAsReadButtonComponent } from './center/toolbar/mark-all-as-read/mark-all-as-read-button.component';
+import { OpenprojectContentLoaderModule } from 'core-app/shared/components/op-content-loader/openproject-content-loader.module';
@NgModule({
declarations: [
@@ -39,6 +40,7 @@ import { MarkAllAsReadButtonComponent } from './center/toolbar/mark-all-as-read/
IconModule,
OpenprojectPrincipalRenderingModule,
OpenprojectWorkPackagesModule,
+ OpenprojectContentLoaderModule,
ScrollingModule,
],
})
diff --git a/frontend/src/app/shared/components/op-content-loader/op-content-loader.component.html b/frontend/src/app/shared/components/op-content-loader/op-content-loader.component.html
new file mode 100644
index 00000000000..c6a7c2adf07
--- /dev/null
+++ b/frontend/src/app/shared/components/op-content-loader/op-content-loader.component.html
@@ -0,0 +1,7 @@
+<content-loader
+ [baseUrl]="baseUrl"
+ [speed]="3"
+ [viewBox]="viewBox"
+>
+ <ng-content></ng-content>
+</content-loader>
diff --git a/frontend/src/app/shared/components/op-content-loader/op-content-loader.component.ts b/frontend/src/app/shared/components/op-content-loader/op-content-loader.component.ts
new file mode 100644
index 00000000000..2f0fd9c9c2a
--- /dev/null
+++ b/frontend/src/app/shared/components/op-content-loader/op-content-loader.component.ts
@@ -0,0 +1,21 @@
+import {
+ ChangeDetectionStrategy,
+ Component,
+ Input,
+ OnInit,
+} from '@angular/core';
+
+@Component({
+ selector: 'op-content-loader',
+ templateUrl: './op-content-loader.component.html',
+ changeDetection: ChangeDetectionStrategy.OnPush,
+})
+export class OpContentLoaderComponent implements OnInit {
+ @Input() public viewBox = '0 0 400 130';
+
+ baseUrl:string;
+
+ ngOnInit():void {
+ this.baseUrl = window.appBasePath;
+ }
+}
diff --git a/frontend/src/app/shared/components/op-content-loader/openproject-content-loader.module.ts b/frontend/src/app/shared/components/op-content-loader/openproject-content-loader.module.ts
new file mode 100644
index 00000000000..24fffe430bf
--- /dev/null
+++ b/frontend/src/app/shared/components/op-content-loader/openproject-content-loader.module.ts
@@ -0,0 +1,19 @@
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { OpContentLoaderComponent } from 'core-app/shared/components/op-content-loader/op-content-loader.component';
+import { ContentLoaderModule } from '@ngneat/content-loader';
+
+@NgModule({
+ declarations: [
+ OpContentLoaderComponent,
+ ],
+ exports: [
+ OpContentLoaderComponent,
+ ],
+ imports: [
+ CommonModule,
+ ContentLoaderModule,
+ ],
+})
+export class OpenprojectContentLoaderModule {
+}
diff --git a/frontend/src/app/shared/shared.module.ts b/frontend/src/app/shared/shared.module.ts
index 422137391f1..8f1f26d819b 100644
--- a/frontend/src/app/shared/shared.module.ts
+++ b/frontend/src/app/shared/shared.module.ts
@@ -26,7 +26,10 @@
// See COPYRIGHT and LICENSE files for more details.
//++
import { FormsModule } from '@angular/forms';
-import { Injector, NgModule } from '@angular/core';
+import {
+ Injector,
+ NgModule,
+} from '@angular/core';
import { NgSelectModule } from '@ng-select/ng-select';
import { DragDropModule } from '@angular/cdk/drag-drop';
import { PortalModule } from '@angular/cdk/portal';
@@ -34,7 +37,10 @@ import { CommonModule } from '@angular/common';
import { NgOptionHighlightModule } from '@ng-select/ng-option-highlight';
import { DragulaModule } from 'ng2-dragula';
import { DynamicModule } from 'ng-dynamic-component';
-import { StateService, UIRouterModule } from '@uirouter/angular';
+import {
+ StateService,
+ UIRouterModule,
+} from '@uirouter/angular';
import { CurrentUserModule } from 'core-app/core/current-user/current-user.module';
import { IconModule } from 'core-app/shared/components/icon/icon.module';
import { AttributeHelpTextModule } from 'core-app/shared/components/attribute-help-texts/attribute-help-text.module';
@@ -51,7 +57,10 @@ import { EnterpriseBannerBootstrapComponent } from 'core-app/shared/components/e
import { HomescreenNewFeaturesBlockComponent } from 'core-app/features/homescreen/blocks/new-features.component';
import { TablePaginationComponent } from 'core-app/shared/components/table-pagination/table-pagination.component';
import { HookService } from 'core-app/features/plugins/hook-service';
-import { highlightColSelector, OpHighlightColDirective } from './directives/highlight-col/highlight-col.directive';
+import {
+ highlightColSelector,
+ OpHighlightColDirective,
+} from './directives/highlight-col/highlight-col.directive';
import { CopyToClipboardDirective } from './components/copy-to-clipboard/copy-to-clipboard.directive';
import { OpDateTimeComponent } from './components/date/op-date-time.component';