Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Photo upload #1755

Merged
merged 29 commits into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3a907a9
photos can be displayed in details and child block component with cac…
TheSlimvReal Mar 6, 2023
a91c902
refactored queue to not send multiple similar requests at the same time
TheSlimvReal Mar 7, 2023
a1f591d
added edit file dialog to photo component
TheSlimvReal Mar 7, 2023
a0605e1
Merge branch 'master' into photo_upload
TheSlimvReal Mar 16, 2023
41e4c4c
ci: update docker repository (#1792)
TheSlimvReal Mar 20, 2023
75a34ac
Merge branch 'master' into photo_upload
TheSlimvReal Mar 20, 2023
bb0c675
Merge remote-tracking branch 'origin/master' into photo_upload
TheSlimvReal Mar 23, 2023
12d0e39
Merge remote-tracking branch 'origin/photo_upload' into photo_upload
TheSlimvReal Mar 23, 2023
fda5556
added compression and mock implementation to photo upload
TheSlimvReal Mar 27, 2023
e0b06bc
implemented compressed upload for couchdb file service
TheSlimvReal Mar 27, 2023
b60c337
demo code for uploading children pictures
TheSlimvReal Mar 27, 2023
d8d46ef
Revert "ci: update docker repository (#1792)"
TheSlimvReal Mar 27, 2023
fa561a5
improved general support of child photos
TheSlimvReal Mar 27, 2023
44c5958
only loading pictures if component is shown
TheSlimvReal Mar 27, 2023
b87ccef
improved usability of new photo component
TheSlimvReal Mar 28, 2023
dbea3b8
fixed tests
TheSlimvReal Mar 29, 2023
f052195
added tests for new photo component
TheSlimvReal Mar 29, 2023
3b61b2f
added tests for couchdb file service
TheSlimvReal Mar 30, 2023
8c5dd1a
added test for file resize utility
TheSlimvReal Mar 30, 2023
27d0ce9
removed old photo functionality
TheSlimvReal Mar 30, 2023
b6f931e
Merge branch 'master' into photo_upload
TheSlimvReal Mar 30, 2023
034fb15
undone change
TheSlimvReal Apr 4, 2023
70aabde
Merge remote-tracking branch 'origin/master' into photo_upload
TheSlimvReal Apr 4, 2023
f0fdb50
moved compression to component level
TheSlimvReal Apr 4, 2023
0975060
added sw caching for attachments
TheSlimvReal Apr 4, 2023
f4861ed
improved caching path
TheSlimvReal Apr 4, 2023
67ae86a
improved cache strategy for more up-to-date images
TheSlimvReal Apr 5, 2023
724ef72
Merge branch 'master' into photo_upload
TheSlimvReal Apr 5, 2023
e4dd10f
added popup for profile pictures
TheSlimvReal Apr 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .storybook/utils/addDefaultChildPhoto.ts

This file was deleted.

9 changes: 5 additions & 4 deletions ngsw-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@
}
},
{
"name": "childPhotos",
"name": "attachments",
"urls": [
"**/child-photos/**"
"**/app-attachments/*/*"
],
"cacheConfig": {
"maxSize": 500,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these values (size 500 max age 10 days) still make sense? This means users will have an old image for up to 10 days.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if I understand the docs correctly, after remaining 10 days offline the image will not be displayed at all anymore ("considered invalid and eviced": https://angular.io/guide/service-worker-config#maxage)? In that sense, a big maxAge makes sense for offline support.

Maybe we should change this to the mentioned "staleWhileRevalidate" strategy though? In combination with our in-memory cache that could be a better fit?

"maxAge": "10d",
"strategy": "performance"
"maxAge": "100d",
"strategy": "freshness",
"timeout": "0u"
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { moduleMetadata } from "@storybook/angular";
import { ActivityCardComponent } from "./activity-card.component";
import { Note } from "../../notes/model/note";
import { DemoChildGenerator } from "../../children/demo-data-generators/demo-child-generator.service";
import { addDefaultChildPhoto } from "../../../../../.storybook/utils/addDefaultChildPhoto";
import { MatCardModule } from "@angular/material/card";
import { RecurringActivity } from "../model/recurring-activity";
import { MatTooltipModule } from "@angular/material/tooltip";
Expand Down Expand Up @@ -37,7 +36,6 @@ const demoChildren = [
DemoChildGenerator.generateEntity("2"),
DemoChildGenerator.generateEntity("3"),
];
demoChildren.forEach((c) => addDefaultChildPhoto(c));

const simpleEvent = Note.create(new Date(), "some meeting");
demoChildren.forEach((c) => simpleEvent.addChild(c.getId()));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Meta, Story } from "@storybook/angular/types-6-0";
import { DemoChildGenerator } from "../../../children/demo-data-generators/demo-child-generator.service";
import { addDefaultChildPhoto } from "../../../../../../.storybook/utils/addDefaultChildPhoto";
import { moduleMetadata } from "@storybook/angular";
import { RollCallSetupComponent } from "./roll-call-setup.component";
import moment from "moment";
Expand Down Expand Up @@ -32,7 +31,6 @@ const demoChildren = [
DemoChildGenerator.generateEntity("2"),
DemoChildGenerator.generateEntity("3"),
];
demoChildren.forEach((c) => addDefaultChildPhoto(c));
demoChildren.forEach((c) => demoEvent.addChild(c.getId()));

const demoActivities = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<img [src]="entity?.photo?.photo?.value" class="child-pic" alt=""/>
<app-fa-dynamic-icon *ngIf="!imgPath" [icon]="icon"/>
<img *ngIf="imgPath" [src]="imgPath" class="child-pic" alt=""/>
<div>
<!-- Font-weight is applied as style to override the default -->
<h3 style="font-weight: bold">{{ entity?.name }}</h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { ComponentFixture, TestBed } from "@angular/core/testing";

import { ChildBlockTooltipComponent } from "./child-block-tooltip.component";
import { FontAwesomeTestingModule } from "@fortawesome/angular-fontawesome/testing";
import { FileService } from "../../../../features/file/file.service";
import { Child } from "../../model/child";

describe("ChildBlockTooltipComponent", () => {
let component: ChildBlockTooltipComponent;
Expand All @@ -10,12 +12,14 @@ describe("ChildBlockTooltipComponent", () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [ChildBlockTooltipComponent, FontAwesomeTestingModule],
providers: [{ provide: FileService, useValue: {} }],
}).compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(ChildBlockTooltipComponent);
component = fixture.componentInstance;
component.entity = new Child();
fixture.detectChanges();
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { Component, Input } from "@angular/core";
import { Component, Input, OnInit } from "@angular/core";
import { Child } from "../../model/child";
import { FontAwesomeModule } from "@fortawesome/angular-fontawesome";
import { NgForOf, NgIf } from "@angular/common";
import { SchoolBlockComponent } from "../../../schools/school-block/school-block.component";
import { FaDynamicIconComponent } from "../../../../core/view/fa-dynamic-icon/fa-dynamic-icon.component";
import { SafeUrl } from "@angular/platform-browser";
import { FileService } from "../../../../features/file/file.service";

/**
* Tooltip that is shown when hovering over a child block and the tooltip is enabled.
Expand All @@ -11,10 +14,28 @@ import { SchoolBlockComponent } from "../../../schools/school-block/school-block
selector: "app-child-block-tooltip",
templateUrl: "./child-block-tooltip.component.html",
styleUrls: ["./child-block-tooltip.component.scss"],
imports: [FontAwesomeModule, NgIf, SchoolBlockComponent, NgForOf],
imports: [
FontAwesomeModule,
NgIf,
SchoolBlockComponent,
NgForOf,
FaDynamicIconComponent,
],
standalone: true,
})
export class ChildBlockTooltipComponent {
export class ChildBlockTooltipComponent implements OnInit {
/** The entity to show the tooltip for */
@Input() entity: Child;
icon = Child.icon;
imgPath: SafeUrl;

constructor(private fileService: FileService) {}

ngOnInit() {
if (this.entity.photo) {
this.fileService
.loadFile(this.entity, "photo")
.subscribe((res) => (this.imgPath = res));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Story, Meta } from "@storybook/angular/types-6-0";
import { Child } from "../../model/child";
import { moduleMetadata } from "@storybook/angular";
import { CommonModule } from "@angular/common";
import { addDefaultChildPhoto } from "../../../../../../.storybook/utils/addDefaultChildPhoto";
import { StorybookBaseModule } from "../../../../utils/storybook-base.module";
import { ChildBlockTooltipComponent } from "./child-block-tooltip.component";
import { FontAwesomeModule } from "@fortawesome/angular-fontawesome";
Expand All @@ -19,7 +18,6 @@ export default {

const demoChild = new Child("1");
demoChild.name = "John Doe";
addDefaultChildPhoto(demoChild);
demoChild.projectNumber = "99";
demoChild.phone = "+49 199 1234567";
demoChild.schoolClass = "5";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
[class.inactive]="!entity.isActive"
class="truncate-text container"
>
<img [src]="entity.photo?.photo?.value" class="child-pic" alt=""/>
<app-fa-dynamic-icon *ngIf="!imgPath" [icon]="icon" class="margin-right-small"/>
<img *ngIf="imgPath" [src]="imgPath" class="child-pic" alt=""/>
<span class="font-size-rel">{{ entity?.toString() }}</span>
<span class="subnote" *ngIf="entity?.projectNumber"> ({{ entity?.projectNumber }})</span>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ChildBlockComponent } from "./child-block.component";
import { RouterTestingModule } from "@angular/router/testing";
import { ChildrenService } from "../children.service";
import { Child } from "../model/child";
import { FileService } from "app/features/file/file.service";

describe("ChildBlockComponent", () => {
let component: ChildBlockComponent;
Expand All @@ -18,7 +19,10 @@ describe("ChildBlockComponent", () => {

TestBed.configureTestingModule({
imports: [ChildBlockComponent, RouterTestingModule],
providers: [{ provide: ChildrenService, useValue: mockChildrenService }],
providers: [
{ provide: ChildrenService, useValue: mockChildrenService },
{ provide: FileService, useValue: {} },
],
}).compileComponents();
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@ import { DynamicComponent } from "../../../core/view/dynamic-components/dynamic-
import { NgIf } from "@angular/common";
import { TemplateTooltipDirective } from "../../../core/common-components/template-tooltip/template-tooltip.directive";
import { ChildBlockTooltipComponent } from "./child-block-tooltip/child-block-tooltip.component";
import { SafeUrl } from "@angular/platform-browser";
import { FileService } from "../../../features/file/file.service";
import { FaDynamicIconComponent } from "../../../core/view/fa-dynamic-icon/fa-dynamic-icon.component";

@DynamicComponent("ChildBlock")
@Component({
selector: "app-child-block",
templateUrl: "./child-block.component.html",
styleUrls: ["./child-block.component.scss"],
imports: [NgIf, TemplateTooltipDirective, ChildBlockTooltipComponent],
imports: [
NgIf,
TemplateTooltipDirective,
ChildBlockTooltipComponent,
FaDynamicIconComponent,
],
standalone: true,
})
export class ChildBlockComponent implements OnInit {
Expand All @@ -24,11 +32,22 @@ export class ChildBlockComponent implements OnInit {
/** prevent additional details to be displayed in a tooltip on mouse over */
@Input() tooltipDisabled: boolean;

constructor(@Optional() private childrenService: ChildrenService) {}
imgPath: SafeUrl;
icon = Child.icon;
sleidig marked this conversation as resolved.
Show resolved Hide resolved

constructor(
private fileService: FileService,
@Optional() private childrenService: ChildrenService
) {}

async ngOnInit() {
if (this.entityId) {
this.entity = await this.childrenService.getChild(this.entityId);
}
if (this.entity.photo) {
this.fileService
.loadFile(this.entity, "photo")
.subscribe((res) => (this.imgPath = res));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { ChildBlockComponent } from "./child-block.component";
import { Child } from "../model/child";
import { moduleMetadata } from "@storybook/angular";
import { CommonModule } from "@angular/common";
import { addDefaultChildPhoto } from "../../../../../.storybook/utils/addDefaultChildPhoto";
import { StorybookBaseModule } from "../../../utils/storybook-base.module";

export default {
Expand All @@ -18,7 +17,6 @@ export default {

const demoChild = new Child("1");
demoChild.name = "John Doe";
addDefaultChildPhoto(demoChild);
demoChild.projectNumber = "99";
demoChild.phone = "+49 199 1234567";
demoChild.schoolClass = "5";
Expand Down

This file was deleted.

This file was deleted.

Loading