added services grid view

This commit is contained in:
_Bastler
2021-09-26 13:32:14 +02:00
parent 1c0be5e1ea
commit 44524d0165
8 changed files with 143 additions and 15 deletions
@@ -0,0 +1,31 @@
<div fxLayout="row wrap" fxLayoutGap="24px grid">
<div fxFlex="33%" fxFlex.sm="50%" fxFlex.xs="100%" *ngFor="let service of services">
<mat-card>
<a *ngIf="service.url" href="{{service.url}}" [target]="service.sameSite ? '_self' : '_blank'"
color="accent">
<mat-card-header>
<mat-icon mat-card-avatar>{{'services.' + service.name + '.icon' | i18n}}</mat-icon>
<mat-card-title> <strong>{{'services.' + service.name + '.title' | i18n}}</strong>
<mat-icon *ngIf="!service.sameSite" inline="true">
open_in_new</mat-icon>
</mat-card-title>
<mat-card-subtitle>{{'services.' + service.name + '.subtitle' | i18n}}</mat-card-subtitle>
</mat-card-header>
</a>
<mat-card-header *ngIf="!service.url">
<mat-icon mat-card-avatar>{{'services.' + service.name + '.icon' | i18n}}</mat-icon>
<mat-card-title> <strong>{{'services.' + service.name + '.title' | i18n}}</strong>
</mat-card-title>
<mat-card-subtitle>{{'services.' + service.name + '.subtitle' | i18n}}</mat-card-subtitle>
</mat-card-header>
<mat-card-content>
<p>
{{ 'services.' + service.name + '.text' | i18n}}
</p>
</mat-card-content>
<mat-card-actions>
</mat-card-actions>
</mat-card>
</div>
</div>
@@ -0,0 +1,22 @@
@import '../../../variables.scss';
mat-card {
display: flex;
flex-direction: column;
height: 100%;
a {
text-decoration: none;
color: inherit;
mat-card-title {
color: $accent;
}
}
mat-card-content {
flex-grow: 1;
overflow: auto;
}
}
@@ -0,0 +1,39 @@
import { Component, OnInit, Input } from '@angular/core';
import { Sort } from '@angular/material/sort';
import { I18nService } from '../../services/i18n.service';
@Component({
selector: 'app-services-grid',
templateUrl: './servicesgrid.component.html',
styleUrls: [ './servicesgrid.component.scss' ]
})
export class ServicesGridComponent implements OnInit {
@Input() services;
constructor(private i18n: I18nService) { }
ngOnInit(): void {
this.sortData({ "active": "name", "direction": "asc" });
}
sortData(sort: Sort) {
const data = this.services.slice();
if (!sort.active || sort.direction === '') {
this.services = data;
return;
}
this.services = data.sort((a, b) => {
const isAsc = sort.direction === 'asc';
switch (sort.active) {
case 'name': return this.compare(this.i18n.get('services.' + a.name + '.title', []), this.i18n.get('services.' + b.name + '.title', []), isAsc);
default: return 0;
}
});
}
compare(a: number | string | String, b: number | string | String, isAsc: boolean) {
return (a < b ? -1 : 1) * (isAsc ? 1 : -1);
}
}