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

Replacing app icon with new outline camera + raspberry head icon #702

Merged
merged 1 commit into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 2 additions & 3 deletions src/backend/model/fileprocessing/PhotoProcessing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,8 @@ export class PhotoProcessing {
// run on other thread
const input = {
type: ThumbnailSourceType.Photo,
svgString: `<svg width="${size}" height="${size}" xmlns="http://www.w3.org/2000/svg"
viewBox="${Config.Server.svgIcon.viewBox || '0 0 512 512'}">
<path fill="${color}" d="${Config.Server.svgIcon.path}"/></svg>`,
svgString: `<svg fill="${color}" width="${size}" height="${size}" xmlns="http://www.w3.org/2000/svg"
viewBox="${Config.Server.svgIcon.viewBox || '0 0 512 512'}">d="${Config.Server.svgIcon.items}</svg>`,
size: size,
outPath,
makeSquare: false,
Expand Down
12 changes: 6 additions & 6 deletions src/backend/routes/PublicRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class PublicRouter {
res.header('Content-Type', 'image/svg+xml');
res.send('<svg xmlns="http://www.w3.org/2000/svg"' +
' viewBox="' + (Config.Server.svgIcon.viewBox || '0 0 512 512') + '">' +
'<path d="' + Config.Server.svgIcon.path + '"/></svg>');
Config.Server.svgIcon.items + '</svg>');
});


Expand All @@ -155,24 +155,24 @@ export class PublicRouter {
res.send('<svg xmlns="http://www.w3.org/2000/svg"' +
' viewBox="' + (Config.Server.svgIcon.viewBox || '0 0 512 512') + '">' +
'<style>' +
' path {' +
' path, circle {' +
' fill: black;' +
' }' +
' @media (prefers-color-scheme: dark) {' +
' path {' +
' path, circle {' +
' fill: white;' +
' }' +
' }' +
' </style>' +
'<path d="' + Config.Server.svgIcon.path + '"/></svg>');
Config.Server.svgIcon.items + '</svg>');
});

app.get('/icon_inv.svg', (req: Request, res: Response) => {
res.set('Cache-control', 'public, max-age=31536000');
res.header('Content-Type', 'image/svg+xml');
res.send('<svg xmlns="http://www.w3.org/2000/svg"' +
res.send('<svg style="fill:white" xmlns="http://www.w3.org/2000/svg"' +
' viewBox="' + (Config.Server.svgIcon.viewBox || '0 0 512 512') + '">' +
'<path style="fill:white" d="' + Config.Server.svgIcon.path + '"/></svg>');
Config.Server.svgIcon.items + '</svg>');
});


Expand Down
28 changes: 14 additions & 14 deletions src/common/config/public/ClientConfig.ts

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/frontend/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ import {
ionWarningOutline
} from '@ng-icons/ionicons';
import {SortingMethodIconComponent} from './ui/sorting-method-icon/sorting-method-icon.component';
import {SafeHtmlPipe} from './pipes/SafeHTMLPipe';

@Injectable()
export class MyHammerConfig extends HammerGestureConfig {
Expand Down Expand Up @@ -236,7 +237,7 @@ Marker.prototype.options.icon = MarkerFactory.defIcon;
ionCameraOutline, ionWarningOutline, ionLockClosedOutline, ionChevronUpOutline,
ionFlagOutline, ionGlobeOutline, ionPieChartOutline, ionStopOutline,
ionTimeOutline, ionCheckmarkOutline, ionPulseOutline, ionResizeOutline,
ionCloudOutline, ionChatboxOutline, ionServerOutline, ionFileTrayFullOutline,ionBrushOutline,
ionCloudOutline, ionChatboxOutline, ionServerOutline, ionFileTrayFullOutline, ionBrushOutline,
ionBrowsersOutline
}),
ClipboardModule,
Expand Down Expand Up @@ -321,6 +322,7 @@ Marker.prototype.options.icon = MarkerFactory.defIcon;
UsersComponent,
SharingsListComponent,
SortingMethodIconComponent,
SafeHtmlPipe
],
providers: [
{provide: HTTP_INTERCEPTORS, useClass: CSRFInterceptor, multi: true},
Expand Down
14 changes: 7 additions & 7 deletions src/frontend/app/icon.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import {Config} from '../../common/config/public/Config';
selector: 'app-icon',
styles: [':host {line-height: 0}'],
template: `
<svg xmlns="http://www.w3.org/2000/svg"
[attr.width]="width"
[attr.height]="height"
fill="currentcolor"
[attr.viewBox]="Config.Server.svgIcon.viewBox || '0 0 512 512'">
<path [attr.d]="Config.Server.svgIcon.path"/>
</svg>`,
<svg xmlns="http://www.w3.org/2000/svg"
[attr.width]="width"
[attr.height]="height"
fill="currentcolor"
[attr.viewBox]="Config.Server.svgIcon.viewBox || '0 0 512 512'"
[innerHtml]="Config.Server.svgIcon.items | safeHtml">
</svg>`,
})
export class IconComponent {

Expand Down
12 changes: 12 additions & 0 deletions src/frontend/app/pipes/SafeHTMLPipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {Pipe, PipeTransform, SecurityContext} from '@angular/core';
import {DomSanitizer} from '@angular/platform-browser';

@Pipe({name: 'safeHtml'})
export class SafeHtmlPipe implements PipeTransform {
constructor(private sanitizer: DomSanitizer) {
}

transform(html: string) {
return this.sanitizer.bypassSecurityTrustHtml(html);
}
}
6 changes: 3 additions & 3 deletions src/frontend/app/ui/gallery/map/MarkerFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import {DivIcon, setOptions} from 'leaflet';

export interface SvgIconOptions {
color?: string;
svgPath?: string;
svgItems?: string;
viewBox?: string;
small?: boolean;
}

const SvgIcon: { new(options?: SvgIconOptions): DivIcon } = DivIcon.extend({
initialize: function(options: SvgIconOptions = {}) {
options.color = options.color || 'var(--bs-primary)';
options.svgPath = options.svgPath || 'M256 512c141.4 0 256-114.6 256-256S397.4 0 256 0S0 114.6 0 256S114.6 512 256 512z';
options.svgItems = options.svgItems || '<path d="M256 512c141.4 0 256-114.6 256-256S397.4 0 256 0S0 114.6 0 256S114.6 512 256 512z"/>';
options.viewBox = options.viewBox || '0 0 512 512';
const svg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="' + options.viewBox + '"><path fill="' + options.color + '" d="' + options.svgPath + '"/></svg>';
const svg = '<svg xmlns="http://www.w3.org/2000/svg" fill="' + options.color + '" viewBox="' + options.viewBox + '">' + options.svgItems + '</svg>';
setOptions(this, {
iconSize: options.small ? [15, 15] : [30, 30],
iconAnchor: options.small ? [15, 28] : [15, 35],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export class GalleryMapLightboxComponent implements OnChanges, OnDestroy {
theme: ths.theme,
icon: MarkerFactory.getSvgIcon({
color: ths.theme.color,
svgPath: ths.theme.svgIcon?.path,
svgItems: ths.theme.svgIcon?.items,
viewBox: ths.theme.svgIcon?.viewBox
})
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ <h5 class="modal-title" i18n>Add new theme</h5>
<svg xmlns="http://www.w3.org/2000/svg"
width="1em"
fill="currentcolor"
[attr.viewBox]="state.value.viewBox || '0 0 512 512'">
<path [attr.d]="state.value.path"/>
[attr.viewBox]="state.value.viewBox || '0 0 512 512'"
[innerHtml]="state.value.items | safeHtml">
</svg>
</button>

Expand All @@ -178,8 +178,8 @@ <h5 class="modal-title" i18n>Icon</h5>
<svg xmlns="http://www.w3.org/2000/svg"
width="2em"
fill="currentcolor"
[attr.viewBox]="state.value.viewBox || '0 0 512 512'">
<path [attr.d]="state.value.path"/>
[attr.viewBox]="state.value.viewBox || '0 0 512 512'"
[innerHtml]="state.value.items | safeHtml">
</svg>
</div>
</div>
Expand Down Expand Up @@ -209,10 +209,10 @@ <h5 class="modal-title" i18n>Icon</h5>
(change)="onChange($event)"></app-settings-entry>

<app-settings-entry
[ngModel]="state.value.__state.path"
[ngModel]="state.value.__state.items"
[noChangeDetection]="true"
[name]="'icon_p_'+idName"
[id]="'icon_p_'+idName"
[name]="'icon_i_'+idName"
[id]="'icon_i_'+idName"
(change)="onChange($event)"></app-settings-entry>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {WebConfig} from '../../../../../../common/config/private/WebConfig';
import {JobScheduleConfig, UserConfig} from '../../../../../../common/config/private/PrivateConfig';
import {enumToTranslatedArray} from '../../../EnumTranslations';
import {BsModalService} from '../../../../../../../node_modules/ngx-bootstrap/modal';
import {Config} from '../../../../../../common/config/public/Config';

interface IState {
shouldHide(): boolean;
Expand Down Expand Up @@ -450,8 +451,8 @@ export class SettingsEntryComponent
const doc = parser.parseFromString(reader.result as string, 'image/svg+xml');
try {
const wb = doc.documentElement.getAttribute('viewBox');
const path = doc.documentElement.getElementsByTagName('path')[0].getAttribute('d');
this.state.value.path = path;
const items = doc.documentElement.innerHTML;
this.state.value.items = items;
this.state.value.viewBox = wb;
} catch (e) {
console.error(e);
Expand All @@ -465,6 +466,7 @@ export class SettingsEntryComponent

}

protected readonly Config = Config;
}


Expand Down
2 changes: 1 addition & 1 deletion src/frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
style="width: 200px;max-width: calc(50vw);max-height: calc(50vh);"
fill="currentcolor"
viewBox="<%- Config.Server.svgIcon.viewBox || '0 0 512 512' %>">
<path d="<%- Config.Server.svgIcon.path %>"/>
<%- Config.Server.svgIcon.items %>
</svg>
<h2 style="margin-top: 1em">Loading...</h2>
</div>
Expand Down