Compare commits

..

1 Commits

Author SHA1 Message Date
Rainer Killinger
1214b31cfc refactor: overhaul minimal-deployment compose file
fix: changeset crashes because it uses internal prettier version

refactor: add asdf tool versioning file

fix: iOS build resources

fix: backend tests break every year

refactor: update some backend unit tests

feat: add direnv for nix

feat: update nix flake to not rely on buildFHSUserEnv

feat: enable checkJs by default

feat: custom ion-icon package

feat: custom ion-icon package

feat: custom ion-icon element

feat: custom ion-icon element

feat: custom ion-icon element

feat: custom ion icon element

fix: e2e tests
2024-04-16 13:19:01 +02:00
217 changed files with 2431 additions and 3507 deletions

View File

@@ -0,0 +1,9 @@
---
"@openstapps/node-builder": patch
"@openstapps/database": patch
"@openstapps/node-base": patch
"@openstapps/backend": patch
"@openstapps/app": patch
---
pin alpine version to 3.18 and add healthchecks

View File

@@ -0,0 +1,5 @@
---
"@openstapps/prettier-config": patch
---
Update Prettier to 3.1.1

View File

@@ -0,0 +1,6 @@
---
"@openstapps/backend": minor
"@openstapps/core": minor
---
Add the ability to filter by existence of a field

View File

@@ -0,0 +1,5 @@
---
"@openstapps/backend": patch
---
Backend unit tests break every year

1
.gitignore vendored
View File

@@ -102,6 +102,7 @@ typings/
# ignore lib
lib
dist
# ignore docs
docs

View File

@@ -2,13 +2,7 @@
/** @type {import('syncpack').RcFile} */
const config = {
semverGroups: [
{
range: '',
dependencies: ['**'],
packages: ['**'],
}
],
semverGroups: [{range: ''}],
source: ['package.json', '**/package.json'],
indent: ' ',
sortFirst: [

View File

@@ -1,3 +1,3 @@
nodejs 22.2.0
nodejs 18.19.1
pnpm 8.15.4
python 3.11.5
python 3.11.5

View File

@@ -1,20 +1,5 @@
# @openstapps/backend
## 3.2.0
### Minor Changes
- 912ae422: Add the ability to filter by existence of a field
### Patch Changes
- 689ac68b: pin alpine version to 3.18 and add healthchecks
- e8d72683: Backend unit tests break every year
- Updated dependencies [912ae422]
- @openstapps/core@4.0.0
- @openstapps/core-tools@3.0.0
- @openstapps/logger@3.0.0
## 3.1.2
### Patch Changes

View File

@@ -1,15 +0,0 @@
# Goethe-Uni App 2.5
Die Goethe-Uni App ist noch besser geworden!
## Komplett neue Kartenansicht
Wir haben die Karte überarbeitet, um eine klarere und schnellere Übersicht zu bieten.
## Deutschlandticket mit an Bord
Wenn du das Upgrade des Semesterticket zum Deutschlandticket gemacht hast und eingeloggt bist, findet es sich jetzt auch in der App.
## Bibliotheksdienste sind wieder voll funktionsfähig
Aufgrund einiger Adhoc-Änderungen im Bibliothekssystem haben wir die App so angepasst, dass sie damit umgehen kann.

View File

@@ -1,15 +0,0 @@
# Goethe-Uni App 2.5
The Goethe-Uni App got even better!
## Completelty new map view
We overhauled the map to offer you a clearer and faster and overview.
## Deutschlandticket included
If you upgraded your Semesterticket to a Deutschlandticket it will now reside in the App if you are logged in.
## Library services are fully functional again
Due to some adhoc changes in the library system we adjusted the app to handle them properly.

View File

@@ -1,7 +1,7 @@
{
"name": "@openstapps/backend",
"description": "A reference implementation for a StApps backend",
"version": "3.2.0",
"version": "3.1.2",
"private": true,
"type": "module",
"license": "AGPL-3.0-only",

View File

@@ -13,34 +13,15 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {
SCConfigFile,
SCPlace,
SCPlaceWithoutReferences,
SCSearchQuery,
SCSearchResponse,
SCThingWithCategoriesWithoutReferences,
SCThings,
SCUuid,
} from '@openstapps/core';
import {SCConfigFile, SCSearchQuery, SCSearchResponse, SCThings, SCUuid} from '@openstapps/core';
import {MailQueue} from '../notification/mail-queue.js';
import {Bulk} from './bulk-storage.js';
import {FeatureCollection, Point, Polygon} from 'geojson';
/**
* Creates an instance of a database
*/
export type DatabaseConstructor = new (config: SCConfigFile, mailQueue?: MailQueue) => Database;
export type SupplementaryGeoJSON = FeatureCollection<Point | Polygon, SupplementaryGeoJSONThing>;
export type SupplementaryGeoJSONThing = Pick<
Extract<SCThings, SCPlace>,
Exclude<
keyof SCPlaceWithoutReferences | keyof SCThingWithCategoriesWithoutReferences<never, never>,
'geo' | 'origin' | 'translations'
>
>;
/**
* Defines what one database class needs to have defined
*/
@@ -101,9 +82,4 @@ export interface Database {
* @param params Parameters which form a search query to search the backend data
*/
search(parameters: SCSearchQuery): Promise<SCSearchResponse>;
/**
* Get geo info for display on a map
*/
geo(): Promise<SupplementaryGeoJSON>;
}

View File

@@ -26,7 +26,7 @@ import {Logger} from '@openstapps/logger';
import moment from 'moment';
import {MailQueue} from '../../notification/mail-queue.js';
import {Bulk} from '../bulk-storage.js';
import {Database, SupplementaryGeoJSON, SupplementaryGeoJSONThing} from '../database.js';
import {Database} from '../database.js';
import {parseAggregations} from './aggregations.js';
import * as Monitoring from './monitoring.js';
import {buildQuery} from './query/query.js';
@@ -46,7 +46,6 @@ import {
} from './util/index.js';
import {noUndefined} from './util/no-undefined.js';
import {retryCatch, RetryOptions} from './util/retry.js';
import {Feature, Point, Polygon} from 'geojson';
/**
* A database interface for elasticsearch
@@ -406,49 +405,4 @@ export class Elasticsearch implements Database {
},
};
}
async geo(): Promise<SupplementaryGeoJSON> {
const searchResponse = await this.client.search<Extract<SCThings, {geo: unknown}>>({
body: {
query: {
exists: {
field: 'geo',
},
},
},
from: 0,
allow_no_indices: true,
index: ACTIVE_INDICES_ALIAS,
size: 1,
});
return {
type: 'FeatureCollection',
features: searchResponse.hits.hits
.map(thing => {
return thing._source?.geo
? ({
id: Number(thing._source.identifiers?.['OSM']) || undefined,
type: 'Feature',
geometry: thing._source.geo.polygon ?? thing._source.geo.point,
properties: {
name: thing._source.name,
sameAs: thing._source.sameAs,
image: thing._source.image,
alternateNames: thing._source.alternateNames,
description: thing._source.description,
identifiers: thing._source.identifiers,
categories: thing._source.categories,
categorySpecificValues: thing._source.categorySpecificValues,
openingHours: thing._source.openingHours,
address: thing._source.address,
uid: thing._source.uid,
type: thing._source.type,
},
} satisfies Feature<Polygon | Point, SupplementaryGeoJSONThing>)
: undefined;
})
.filter(noUndefined),
};
}
}

View File

@@ -19,29 +19,14 @@ import {QueryDslSpecificQueryContainer} from '../../types/util.js';
* Converts a geo filter to elasticsearch syntax
* @param filter A search filter for the retrieval of the data
*/
export function buildGeoFilter(filter: SCGeoFilter): QueryDslSpecificQueryContainer<'bool'> {
export function buildGeoFilter(filter: SCGeoFilter): QueryDslSpecificQueryContainer<'geo_shape'> {
return {
bool: {
should: [
{
geo_shape: {
ignore_unmapped: true,
[`${filter.arguments.field}.polygon`]: {
shape: filter.arguments.shape,
relation: filter.arguments.spatialRelation,
},
},
} satisfies QueryDslSpecificQueryContainer<'geo_shape'>,
{
geo_shape: {
ignore_unmapped: true,
[`${filter.arguments.field}.point`]: {
shape: filter.arguments.shape,
relation: filter.arguments.spatialRelation,
},
},
} satisfies QueryDslSpecificQueryContainer<'geo_shape'>,
],
geo_shape: {
ignore_unmapped: true,
[`${filter.arguments.field}.polygon`]: {
shape: filter.arguments.shape,
relation: filter.arguments.spatialRelation,
},
},
};
}

View File

@@ -22,7 +22,7 @@ import http from 'http';
import {MailQueue} from '../src/notification/mail-queue.js';
import {Bulk, BulkStorage} from '../src/storage/bulk-storage.js';
import getPort from 'get-port';
import {Database, SupplementaryGeoJSON} from '../src/storage/database.js';
import {Database} from '../src/storage/database.js';
import {v4} from 'uuid';
import {backendConfig} from '../src/config.js';
import {getIndexUID} from '../src/storage/elasticsearch/util/index.js';
@@ -58,6 +58,7 @@ export async function startApp(): Promise<Express> {
* An elasticsearch mock
*/
export class ElasticsearchMock implements Database {
// @ts-expect-error never read
private bulk: Bulk | undefined;
private storageMock = new Map<string, SCThings>();
@@ -66,10 +67,6 @@ export class ElasticsearchMock implements Database {
// Nothing to do here
}
geo(): Promise<SupplementaryGeoJSON> {
throw new Error('Method not implemented.');
}
bulkCreated(bulk: Bulk): Promise<void> {
this.bulk = bulk;
return Promise.resolve(undefined);

View File

@@ -44,6 +44,7 @@ describe('Search route', async function () {
});
it('should reject GET, PUT with a valid search query', async function () {
// const expectedParams = JSON.parse(JSON.stringify(defaultParams));
const {status} = await testApp.get('/search').set('Accept', 'application/json').send({
query: 'Some search terms',
});

View File

@@ -479,39 +479,18 @@ describe('Query', function () {
it('should build geo filter for shapes and points', function () {
const filter = buildFilter(searchFilters.geoPoint);
const expectedFilter = {
bool: {
should: [
{
geo_shape: {
'geo.polygon': {
relation: undefined,
shape: {
coordinates: [
[50.123, 8.123],
[50.123, 8.123],
],
type: 'envelope',
},
},
'ignore_unmapped': true,
},
geo_shape: {
'geo.polygon': {
relation: undefined,
shape: {
type: 'envelope',
coordinates: [
[50.123, 8.123],
[50.123, 8.123],
],
},
{
geo_shape: {
'geo.point': {
relation: undefined,
shape: {
coordinates: [
[50.123, 8.123],
[50.123, 8.123],
],
type: 'envelope',
},
},
'ignore_unmapped': true,
},
},
],
},
'ignore_unmapped': true,
},
};
@@ -521,39 +500,18 @@ describe('Query', function () {
it('should build geo filter for shapes only', function () {
const filter = buildFilter(searchFilters.geoShape);
const expectedFilter = {
bool: {
should: [
{
geo_shape: {
'geo.polygon': {
relation: 'contains',
shape: {
coordinates: [
[50.123, 8.123],
[50.123, 8.123],
],
type: 'envelope',
},
},
'ignore_unmapped': true,
},
geo_shape: {
'geo.polygon': {
relation: 'contains',
shape: {
type: 'envelope',
coordinates: [
[50.123, 8.123],
[50.123, 8.123],
],
},
{
geo_shape: {
'geo.point': {
relation: 'contains',
shape: {
coordinates: [
[50.123, 8.123],
[50.123, 8.123],
],
type: 'envelope',
},
},
'ignore_unmapped': true,
},
},
],
},
'ignore_unmapped': true,
},
};

View File

@@ -1,11 +1,5 @@
# @openstapps/database
## 3.2.0
### Patch Changes
- 689ac68b: pin alpine version to 3.18 and add healthchecks
## 3.0.0
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@openstapps/database",
"version": "3.2.0",
"version": "3.0.0",
"private": true,
"files": [
"config",

View File

@@ -1,11 +1,5 @@
# @openstapps/prettier-config
## 3.2.0
### Patch Changes
- dbb55850: Update Prettier to 3.1.1
## 3.0.0
### Major Changes
@@ -36,7 +30,7 @@
```js
#!/usr/bin/env node
import "./lib/app.js";
import './lib/app.js';
```
- 64caebaf: Migrate to ESM
@@ -75,14 +69,11 @@
- 64caebaf: Migrated changelogs to changeset format
```js
import fs from "fs";
import fs from 'fs';
const path = "packages/logger/CHANGELOG.md";
const path = 'packages/logger/CHANGELOG.md';
fs.writeFileSync(
path,
fs.readFileSync(path, "utf8").replace(/^#+\s+\[/gm, "## ["),
);
fs.writeFileSync(path, fs.readFileSync(path, 'utf8').replace(/^#+\s+\[/gm, '## ['));
```
- 98546a97: Migrate away from @openstapps/configuration
@@ -124,7 +115,7 @@
```js
#!/usr/bin/env node
import "./lib/app.js";
import './lib/app.js';
```
- 64caebaf: Migrate to ESM
@@ -163,14 +154,11 @@
- 64caebaf: Migrated changelogs to changeset format
```js
import fs from "fs";
import fs from 'fs';
const path = "packages/logger/CHANGELOG.md";
const path = 'packages/logger/CHANGELOG.md';
fs.writeFileSync(
path,
fs.readFileSync(path, "utf8").replace(/^#+\s+\[/gm, "## ["),
);
fs.writeFileSync(path, fs.readFileSync(path, 'utf8').replace(/^#+\s+\[/gm, '## ['));
```
- 98546a97: Migrate away from @openstapps/configuration

View File

@@ -1,7 +1,7 @@
{
"name": "@openstapps/prettier-config",
"description": "StApps Prettier Config",
"version": "3.2.0",
"version": "3.0.0",
"type": "module",
"license": "GPL-3.0-only",
"repository": "git@gitlab.com:openstapps/prettier-config.git",

View File

@@ -19,21 +19,15 @@
"allowSyntheticDefaultImports": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noUnusedLocals": true,
"noUnusedParameters": true,
"outDir": "../../../lib/",
"lib": [
"ES2022",
"DOM"
],
"lib": ["ES2022", "DOM"],
"strict": true,
"target": "ES2022"
},
"ts-node": {
"transpileOnly": true
},
"exclude": [
"../../../app.js",
"../../../lib/"
]
"exclude": ["../../../app.js", "../../../lib/"]
}

View File

@@ -1,14 +1,5 @@
# @openstapps/minimal-connector
## 3.2.0
### Patch Changes
- Updated dependencies [912ae422]
- @openstapps/core@4.0.0
- @openstapps/api@4.0.0
- @openstapps/logger@3.0.0
## 3.1.1
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "@openstapps/minimal-connector",
"description": "This is a minimal connector which serves as an example",
"version": "3.2.0",
"version": "3.1.1",
"private": true,
"type": "module",
"license": "GPL-3.0-only",

View File

@@ -1,16 +1,5 @@
# @openstapps/minimal-plugin
## 3.2.0
### Patch Changes
- Updated dependencies [912ae422]
- @openstapps/core@4.0.0
- @openstapps/api@4.0.0
- @openstapps/api-plugin@4.0.0
- @openstapps/core-tools@3.0.0
- @openstapps/logger@3.0.0
## 3.1.1
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "@openstapps/minimal-plugin",
"description": "Minimal Plugin",
"version": "3.2.0",
"version": "3.1.1",
"private": true,
"type": "module",
"license": "GPL-3.0-only",

12
flake.lock generated
View File

@@ -5,11 +5,11 @@
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"lastModified": 1701680307,
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
"type": "github"
},
"original": {
@@ -20,11 +20,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1717112898,
"narHash": "sha256-7R2ZvOnvd9h8fDd65p0JnB7wXfUvreox3xFdYWd1BnY=",
"lastModified": 1701626906,
"narHash": "sha256-ugr1QyzzwNk505ICE4VMQzonHQ9QS5W33xF2FXzFQ00=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "6132b0f6e344ce2fe34fc051b72fb46e34f668e0",
"rev": "0c6d8c783336a59f4c59d4a6daed6ab269c4b361",
"type": "github"
},
"original": {

145
flake.nix
View File

@@ -4,85 +4,72 @@
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
flake-utils,
}:
let
aapt2buildToolsVersion = "33.0.2";
in
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
(final: prev: rec {
fontMin = prev.python311.withPackages (
ps:
with ps;
[
brotli
fonttools
]
++ (with fonttools.optional-dependencies; [ woff ])
);
android = prev.androidenv.composeAndroidPackages {
buildToolsVersions = [
"30.0.3"
aapt2buildToolsVersion
];
platformVersions = [ "33" ];
outputs = {
self,
nixpkgs,
flake-utils,
}: let
aapt2buildToolsVersion = "33.0.2";
in
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [
(final: prev: rec {
fontMin = prev.python311.withPackages (ps: with ps; [brotli fonttools] ++ (with fonttools.optional-dependencies; [woff]));
android = prev.androidenv.composeAndroidPackages {
buildToolsVersions = ["30.0.3" aapt2buildToolsVersion];
platformVersions = ["33"];
};
cypress = prev.cypress.overrideAttrs (cyPrev: rec {
version = "13.2.0";
src = prev.fetchzip {
url = "https://cdn.cypress.io/desktop/${version}/linux-x64/cypress.zip";
hash = "sha256-9o0nprGcJhudS1LNm+T7Vf0Dwd1RBauYKI+w1FBQ3ZM=";
};
cypress = prev.cypress.overrideAttrs (cyPrev: rec {
version = "13.2.0";
src = prev.fetchzip {
url = "https://cdn.cypress.io/desktop/${version}/linux-x64/cypress.zip";
hash = "sha256-9o0nprGcJhudS1LNm+T7Vf0Dwd1RBauYKI+w1FBQ3ZM=";
};
});
nodejs = prev.nodejs_22;
})
];
config = {
allowUnfree = true;
android_sdk.accept_license = true;
};
});
})
];
config = {
allowUnfree = true;
android_sdk.accept_license = true;
};
androidFhs = pkgs.buildFHSUserEnv {
name = "android-env";
targetPkgs = pkgs: with pkgs; [ ];
runScript = "bash";
profile = ''
export ALLOW_NINJA_ENV=true
export USE_CCACHE=1
export LD_LIBRARY_PATH=/usr/lib:/usr/lib32
'';
};
in
{
devShell = pkgs.mkShell rec {
nativeBuildInputs = [ androidFhs ];
buildInputs = with pkgs; [
nodejs
corepack
# tools
curl
jq
fontMin
cypress
# android
jdk17
android.androidsdk
];
ANDROID_JAVA_HOME = "${pkgs.jdk.home}";
ANDROID_SDK_ROOT = "${pkgs.android.androidsdk}/libexec/android-sdk";
GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${ANDROID_SDK_ROOT}/build-tools/${aapt2buildToolsVersion}/aapt2";
CYPRESS_INSTALL_BINARY = "0";
CYPRESS_RUN_BINARY = "${pkgs.cypress}/bin/Cypress";
};
}
);
};
androidFhs = pkgs.buildFHSUserEnv {
name = "android-env";
targetPkgs = pkgs: with pkgs; [];
runScript = "bash";
profile = ''
export ALLOW_NINJA_ENV=true
export USE_CCACHE=1
export LD_LIBRARY_PATH=/usr/lib:/usr/lib32
'';
};
in {
devShell = pkgs.mkShell rec {
nativeBuildInputs = [androidFhs];
buildInputs = with pkgs; [
nodejs-18_x
nodePackages.pnpm
# tools
curl
jq
fontMin
# browsers
firefox
google-chrome
epiphany # Safari-ish browser
cypress
# android
jdk17
android.androidsdk
musl
];
ANDROID_JAVA_HOME = "${pkgs.jdk.home}";
ANDROID_SDK_ROOT = "${pkgs.android.androidsdk}/libexec/android-sdk";
GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${ANDROID_SDK_ROOT}/build-tools/${aapt2buildToolsVersion}/aapt2";
CYPRESS_INSTALL_BINARY = "0";
CYPRESS_RUN_BINARY = "${pkgs.cypress}/bin/Cypress";
};
});
}

View File

@@ -11,6 +11,7 @@ log.txt
*.sublime-workspace
.vscode/*
npm-debug.log*
.browser-data
# This file is sometimes created automatically, even though
# we actually use the capacitor.config.ts

View File

@@ -1,15 +1,5 @@
# @openstapps/app
## 3.2.0
### Patch Changes
- 689ac68b: pin alpine version to 3.18 and add healthchecks
- Updated dependencies [912ae422]
- @openstapps/core@4.0.0
- @openstapps/api@4.0.0
- @openstapps/collection-utils@3.0.0
## 3.1.2
### Patch Changes

View File

@@ -21,10 +21,10 @@ as usual.
The modified `ion-icon` comes with a few extra features:
- `[fill]` controls the fill color of the icon.
- `[weight]` controls the font weight of the icon.
- `[size]` controls the font size of the icon.
- `[grade]` controls the font grade of the icon.
- `[style.--fill]` controls the fill color of the icon.
- `[style.--weight]` controls the font weight of the icon.
- `[style.--size]` controls the font size of the icon.
- `[style.--grade]` controls the font grade of the icon.
All of these attributes are animated as described
[here](https://developers.google.com/fonts/docs/material_symbols).
@@ -50,8 +50,7 @@ the config file.
Icon font minification is done automatically, but requires you to
follow a few simple rules:
1. Use the type-safe proxy for referencing icon names in
TypeScript files and code
1. Use the Proxy object to reference icon names in TypeScript files and code
```ts
SCIcon.icon_name;

View File

@@ -21,13 +21,10 @@
"allowedCommonJsDependencies": [
"moment",
"opening_hours",
"localforage",
"i18next",
"semver",
"suncalc",
"guid-typescript",
"fast-deep-equal",
"maplibre-gl"
"leaflet",
"leaflet.markercluster",
"localforge",
"guid-typescript"
],
"aot": true,
"assets": [
@@ -35,13 +32,24 @@
"glob": "**/*",
"input": "src/assets",
"output": "assets"
},
{
"glob": "**/*",
"input": "./node_modules/leaflet/dist/images",
"output": "assets/"
}
],
"styles": [
{
"input": "src/theme/variables.scss",
"inject": true
},
{
"input": "src/global.scss",
"inject": true
}
},
"./node_modules/leaflet/dist/leaflet.css",
"./node_modules/leaflet.markercluster/dist/MarkerCluster.Default.css"
]
},
"configurations": {
@@ -124,6 +132,11 @@
"glob": "**/*",
"input": "src/assets",
"output": "/assets"
},
{
"glob": "**/*",
"input": "./node_modules/leaflet/dist/images",
"output": "assets/"
}
]
}

View File

@@ -16,7 +16,7 @@
describe('favorites', function () {
beforeEach(() => {
cy.interceptSearch({
extends: {query: 'test'},
extends: {query: 'a'},
fixture: 'search/generic',
alias: 'search',
});
@@ -29,7 +29,7 @@ describe('favorites', function () {
it('should add a favorite', function () {
cy.visit('/search');
cy.patchSearchPage();
cy.get('ion-searchbar').type('test');
cy.get('ion-searchbar').type('a');
let text!: string;
cy.get('stapps-data-list-item')
.first()
@@ -40,9 +40,7 @@ describe('favorites', function () {
text = it;
});
cy.get('stapps-favorite-button').click();
cy.get('stapps-favorite-button > ion-button > ion-icon')
.invoke('attr', 'ng-reflect-fill')
.should('eq', 'true');
cy.get('stapps-favorite-button > ion-button > ion-icon').should('have.class', 'selected');
});
cy.visit('/favorites');
cy.get('stapps-data-list-item').within(() => {

View File

@@ -12,9 +12,9 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import type {IconConfig} from './scripts/icon-config';
/** @type {import('./scripts/icon-config').IconConfig} */
const config = {
const config: IconConfig = {
inputPath: 'node_modules/material-symbols/material-symbols-rounded.woff2',
outputPath: 'src/assets/icons.min.woff2',
htmlGlob: 'src/**/*.html',
@@ -38,6 +38,10 @@ const config = {
'work',
],
},
codePoints: {
ios_share: 'e6b8',
fact_check: 'f0c5',
},
};
export default config;

View File

@@ -1,7 +1,7 @@
{
"name": "@openstapps/app",
"description": "The generic app tailored to fulfill needs of German universities, written using Ionic Framework.",
"version": "3.2.0",
"version": "3.1.2",
"private": true,
"license": "GPL-3.0-only",
"author": "Karl-Philipp Wulfert <krlwlfrt@gmail.com>",
@@ -21,7 +21,7 @@
"build:prod": "ng build --configuration=production",
"build:stats": "ng build --configuration=production --stats-json",
"changelog": "conventional-changelog -p angular -i src/assets/about/CHANGELOG.md -s -r 0",
"check-icons": "node scripts/check-icon-correctness.mjs",
"check-icons": "ts-node scripts/check-icon-correctness.ts",
"chromium:no-cors": "chromium --disable-web-security --user-data-dir=\".browser-data/chromium\"",
"chromium:virtual-host": "chromium --host-resolver-rules=\"MAP mobile.app.uni-frankfurt.de:* localhost:8100\" --ignore-certificate-errors",
"cypress:open": "cypress open",
@@ -35,10 +35,10 @@
"e2e": "ng e2e",
"format": "prettier . -c",
"format:fix": "prettier --write .",
"licenses": "license-checker --json > src/assets/about/licenses.json && node ./scripts/accumulate-licenses.mjs && git add src/assets/about/licenses.json",
"licenses": "license-checker --json > src/assets/about/licenses.json && ts-node ./scripts/accumulate-licenses.ts && git add src/assets/about/licenses.json",
"lint": "ng lint && stylelint \"**/*.scss\"",
"lint:fix": "eslint --fix -c .eslintrc.json --ignore-path .eslintignore --ext .ts,.html src/ && stylelint --fix \"**/*.scss\"",
"minify-icons": "node scripts/minify-icon-font.mjs",
"minify-icons": "ts-node-esm scripts/minify-icon-font.ts",
"postinstall": "jetify && echo \"skipping jetify in production mode\"",
"preview": "http-server www --p 8101 -o",
"push": "git push && git push origin \"v$npm_package_version\"",
@@ -59,6 +59,8 @@
"@angular/forms": "17.3.0",
"@angular/platform-browser": "17.3.0",
"@angular/router": "17.3.0",
"@asymmetrik/ngx-leaflet": "17.0.0",
"@asymmetrik/ngx-leaflet-markercluster": "17.0.0",
"@awesome-cordova-plugins/calendar": "6.6.0",
"@awesome-cordova-plugins/core": "6.6.0",
"@capacitor/app": "5.0.7",
@@ -79,7 +81,6 @@
"@ionic-native/core": "5.36.0",
"@ionic/angular": "7.8.0",
"@ionic/storage-angular": "4.0.0",
"@maplibre/ngx-maplibre-gl": "17.4.1",
"@ngx-translate/core": "15.0.0",
"@ngx-translate/http-loader": "8.0.0",
"@openid/appauth": "1.3.1",
@@ -95,16 +96,17 @@
"form-data": "4.0.0",
"geojson": "0.5.0",
"ionic-appauth": "0.9.0",
"ionicons": "7.2.1",
"jsonpath-plus": "6.0.1",
"maplibre-gl": "4.0.2",
"material-symbols": "0.17.1",
"leaflet": "1.9.4",
"leaflet.markercluster": "1.5.3",
"material-symbols": "0.17.0",
"moment": "2.30.1",
"ngx-date-fns": "11.0.0",
"ngx-logger": "5.0.12",
"ngx-markdown": "17.1.1",
"ngx-moment": "6.0.2",
"opening_hours": "3.8.0",
"pmtiles": "3.0.3",
"rxjs": "7.8.1",
"semver": "7.6.0",
"swiper": "8.4.5",
@@ -146,6 +148,8 @@
"@types/karma": "6.3.8",
"@types/karma-coverage": "2.0.3",
"@types/karma-jasmine": "4.0.5",
"@types/leaflet": "1.9.8",
"@types/leaflet.markercluster": "1.5.4",
"@types/node": "18.15.3",
"@types/semver": "7.5.8",
"@typescript-eslint/eslint-plugin": "7.2.0",
@@ -172,7 +176,7 @@
"karma-junit-reporter": "2.0.1",
"karma-mocha-reporter": "2.2.5",
"license-checker": "25.0.1",
"stylelint": "16.3.1",
"stylelint": "16.2.1",
"stylelint-config-clean-order": "5.4.1",
"stylelint-config-prettier-scss": "1.0.0",
"stylelint-config-recommended-scss": "14.0.0",

View File

@@ -12,34 +12,33 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {readFileSync, writeFileSync} from 'fs';
import {omit, pickBy} from '@openstapps/collection-utils';
import fs from 'fs';
import {omit} from '../src/app/_helpers/collections/omit';
import {pickBy} from '../src/app/_helpers/collections/pick';
/**
* accumulate and transform licenses based on two license files
* @param {string} path
* @param {string} additionalLicensesPath
*/
function accumulateFile(path, additionalLicensesPath) {
const packageJson = JSON.parse(readFileSync('./package.json').toString());
function accumulateFile(path: string, additionalLicensesPath: string) {
const packageJson = JSON.parse(fs.readFileSync('./package.json').toString());
const dependencies = packageJson.dependencies;
console.log(`Accumulating licenses from ${path}`);
writeFileSync(
fs.writeFileSync(
path,
JSON.stringify(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Object.entries({
...pickBy(JSON.parse(readFileSync(path).toString()), (_, key) => {
const parts = /** @type {string} */ (key).split('@');
Object.entries<any>({
...pickBy(JSON.parse(fs.readFileSync(path).toString()), (_, key: string) => {
const parts = key.split('@');
return dependencies[parts.slice(0, -1).join('@')] === parts[parts.length - 1];
}),
...JSON.parse(readFileSync(additionalLicensesPath).toString()),
...JSON.parse(fs.readFileSync(additionalLicensesPath).toString()),
})
.map(([key, value]) => ({
licenseText: value.licenseFile && readFileSync(value.licenseFile, 'utf8'),
licenseText: value.licenseFile && fs.readFileSync(value.licenseFile, 'utf8'),
name: key,
...omit(value, 'licenseFile', 'path'),
}))

View File

@@ -12,20 +12,18 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {openSync} from 'fontkit';
import config from '../icons.config.mjs';
import fontkit, {Font} from 'fontkit';
import config from '../icons.config';
import {existsSync} from 'fs';
import {getUsedIconsHtml, getUsedIconsTS} from './gather-used-icons.mjs';
import {fetchCodePointMap} from './get-code-points.mjs';
import {getUsedIconsHtml, getUsedIconsTS} from './gather-used-icons';
const commandName = '"npm run minify-icons"';
const originalFont = fontkit.openSync(config.inputPath);
if (!existsSync(config.outputPath)) {
console.error(`Minified font not found. Run ${commandName} first.`);
process.exit(-1);
}
/** @type {import('fontkit').Font} */
const modifiedFont = openSync(config.outputPath);
const modifiedFont = fontkit.openSync(config.outputPath);
let success = true;
@@ -50,16 +48,25 @@ async function checkAll() {
}
/**
* @param {Record<string, string[]>} icons
*
*/
async function check(icons) {
const codePoints = await fetchCodePointMap();
for (const icon of Object.values(icons).flat()) {
const codePoint = codePoints.get(icon);
if (!codePoint) throw new Error(`"${icon}" is not a valid icon`);
if (!modifiedFont.getGlyph(Number.parseInt(codePoint, 16))) {
throw new Error(`"${icon}" (code point ${codePoint}) is missing`);
function check(icons: Record<string, string[]>) {
for (const [purpose, iconSet] of Object.entries(icons)) {
for (const icon of iconSet) {
if (!hasIcon(originalFont, icon)) {
success = false;
console.error(`${purpose}: ${icon} does not exist. Typo?`);
} else if (!hasIcon(modifiedFont, icon)) {
success = false;
console.error(`${purpose}: ${icon} not found in minified font. Run ${commandName} to regenerate it.`);
}
}
}
}
/**
*
*/
function hasIcon(font: Font, icon: string) {
return font.layout(icon).glyphs.some(it => it.isLigature);
}

View File

@@ -14,39 +14,34 @@
*/
import {glob} from 'glob';
import {readFileSync} from 'fs';
import {
matchPropertyAccess,
matchPropertyContent,
matchTagProperties,
} from '../src/app/util/ion-icon/icon-match.mjs';
import {matchPropertyContent, matchTagProperties} from '../src/app/util/ion-icon/icon-match';
/**
* @returns {Promise<Record<string, string[]>>}
*
*/
export async function getUsedIconsHtml(pattern = 'src/**/*.html') {
export async function getUsedIconsHtml(pattern = 'src/**/*.html'): Promise<Record<string, string[]>> {
return Object.fromEntries(
(await glob(pattern))
.map(file => [
file,
readFileSync(file, 'utf8')
(readFileSync(file, 'utf8')
.match(matchTagProperties('ion-icon'))
?.flatMap(match => {
return match.match(matchPropertyContent(['name', 'md', 'ios']));
})
.filter(it => !!it) || [],
.filter(it => !!it) as string[]) || [],
])
.filter(([, values]) => values && values.length > 0),
.filter(([, values]) => values.length > 0),
);
}
/**
* @returns {Promise<Record<string, string[]>>}
*
*/
export async function getUsedIconsTS(pattern = 'src/**/*.ts') {
const regex = matchPropertyAccess('SCIcon');
export async function getUsedIconsTS(pattern = 'src/**/*.ts'): Promise<Record<string, string[]>> {
return Object.fromEntries(
(await glob(pattern))
.map(file => [file, readFileSync(file, 'utf8').match(regex) || []])
.filter(([, values]) => values && values.length > 0),
.map(file => [file, readFileSync(file, 'utf8').match(/(?<=Icon`)[\w-]+(?=`)/g) || []])
.filter(([, values]) => values.length > 0),
);
}

View File

@@ -1,23 +0,0 @@
const url =
'https://raw.githubusercontent.com/google/material-design-icons/master/' +
'variablefont/MaterialSymbolsRounded%5BFILL%2CGRAD%2Copsz%2Cwght%5D.codepoints';
export async function fetchCodePointMap() {
const icons = await fetch(url)
.then(it => it.text())
.then(it => new Map(it.split('\n').map(it => /** @type {[string, string]} */ (it.split(' ')))));
if (icons.size < 100) throw new Error(`Code point map is very small, is the URL incorrect? ${url}`);
return icons;
}
/**
* @param {string[]} icons
*/
export async function getCodePoints(icons) {
const codePoints = await fetchCodePointMap();
return icons.map(icon => {
const code = codePoints.get(icon);
if (!code) throw new Error(`Code point for icon ${icon} not found`);
return code;
});
}

View File

@@ -19,4 +19,5 @@ export interface IconConfig {
inputPath: string;
outputPath: string;
additionalIcons?: {[purpose: string]: string[]};
codePoints?: {[name: string]: string};
}

View File

@@ -14,17 +14,16 @@
*/
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import fontkit from 'fontkit';
import {exec} from 'child_process';
import config from '../icons.config.mjs';
import config from '../icons.config';
import {statSync} from 'fs';
import {getUsedIconsHtml, getUsedIconsTS} from './gather-used-icons.mjs';
import {getCodePoints} from './get-code-points.mjs';
import {getUsedIconsHtml, getUsedIconsTS} from './gather-used-icons';
/**
* @param {string[] | string} command
* @returns {Promise<string>}
*
*/
async function run(command) {
async function run(command: string[] | string): Promise<string> {
const fullCommand = Array.isArray(command) ? command.join(' ') : command;
console.log(`>> ${fullCommand}`);
@@ -45,8 +44,7 @@ async function run(command) {
*
*/
async function minifyIconFont() {
/** @type {Set<string>} */
const icons = new Set();
const icons = new Set<string>();
for (const iconSet of [
...Object.values(config.additionalIcons || []),
@@ -58,7 +56,35 @@ async function minifyIconFont() {
}
}
const glyphs = ['5f-7a', '30-39', ...(await getCodePoints([...icons]))].sort();
console.log('Icons used:', [...icons.values()].sort());
const font = fontkit.openSync(config.inputPath);
const glyphs: string[] = ['5f-7a', '30-39'];
for (const icon of icons) {
const iconGlyphs = font.layout(icon).glyphs;
if (iconGlyphs.length === 0) {
console.error(`${icon} not found in font. Typo?`);
process.exit(-1);
}
const codePoints = iconGlyphs
.flatMap(it => font.stringsForGlyph(it.id))
.flatMap(it => [...it])
.map(it => it.codePointAt(0)!.toString(16));
if (codePoints.length === 0) {
if (config.codePoints?.[icon]) {
glyphs.push(config.codePoints[icon]);
} else {
console.log();
console.error(`${icon} code point could not be determined. Add it to config.codePoints.`);
process.exit(-1);
}
}
glyphs.push(...codePoints);
}
glyphs.sort();
console.log(
await run([
@@ -88,10 +114,8 @@ minifyIconFont();
/**
* Bytes to respective units
* @param {number} value
* @returns {string}
*/
function toByteUnit(value) {
function toByteUnit(value: number): string {
if (value < 1024) {
return `${value}B`;
} else if (value < 1024 * 1024) {

View File

@@ -25,11 +25,11 @@ import moment from 'moment';
import 'moment/min/locales';
import {LoggerModule, NGXLogger, NgxLoggerLevel} from 'ngx-logger';
import SwiperCore, {FreeMode, Navigation} from 'swiper';
import {environment} from '../environments/environment';
import {AppRoutingModule} from './app-routing.module';
import {AppComponent} from './app.component';
import {CatalogModule} from './modules/catalog/catalog.module';
import {ConfigModule} from './modules/config/config.module';
import {ConfigProvider} from './modules/config/config.provider';
import {DashboardModule} from './modules/dashboard/dashboard.module';
import {DataModule} from './modules/data/data.module';
@@ -61,16 +61,14 @@ import {RoutingStackService} from './util/routing-stack.service';
import {SCLanguageCode, SCSettingValue} from '@openstapps/core';
import {DefaultAuthService} from './modules/auth/default-auth.service';
import {PAIAAuthService} from './modules/auth/paia/paia-auth.service';
import {IonIconModule} from './util/ion-icon/ion-icon.module';
import {NavigationModule} from './modules/menu/navigation/navigation.module';
import {browserFactory, SimpleBrowser} from './util/browser.factory';
import {getDateFnsLocale} from './translation/dfns-locale';
import {setDefaultOptions} from 'date-fns';
import {DateFnsConfigurationService} from 'ngx-date-fns';
import {SCIcon} from './util/ion-icon/icon';
import {Capacitor} from '@capacitor/core';
import {SplashScreen} from '@capacitor/splash-screen';
import maplibregl from 'maplibre-gl';
import {Protocol} from 'pmtiles';
registerLocaleData(localeDe);
@@ -92,7 +90,6 @@ export function initializerFactory(
) {
return async () => {
try {
maplibregl.addProtocol('pmtiles', new Protocol().tile);
initLogger(logger);
await storageProvider.init();
await configProvider.init();
@@ -153,11 +150,13 @@ export function createTranslateLoader(http: HttpClient) {
BrowserAnimationsModule,
CatalogModule,
CommonModule,
ConfigModule,
DashboardModule,
DataModule,
HebisModule,
IonicModule.forRoot(),
IonIconModule,
IonicModule.forRoot({
backButtonIcon: SCIcon.arrow_back,
}),
JobModule,
FavoritesModule,
LibraryModule,

View File

@@ -29,7 +29,12 @@
<ion-card-header>
<ion-card-title>
{{ license.name }}
<ion-icon [size]="16" [weight]="300" class="supertext-icon" name="open_in_browser"></ion-icon>
<ion-icon
[size]="16"
[style.--weight]="300"
class="supertext-icon"
name="open_in_browser"
></ion-icon>
</ion-card-title>
@if (license.authors || license.publisher) {
<ion-card-subtitle> {{ license.authors || license.publisher }} </ion-card-subtitle>

View File

@@ -49,7 +49,7 @@
@if (content.type === 'router link') {
<ion-item [routerLink]="content.link">
@if (content.icon) {
<ion-icon [name]="$any(content.icon)" slot="start"></ion-icon>
<ion-icon [name]="content.icon" slot="start"></ion-icon>
}
<ion-label>{{ 'title' | translateSimple: content }}</ion-label>
</ion-item>

View File

@@ -19,6 +19,7 @@ import {FormsModule} from '@angular/forms';
import {IonicModule} from '@ionic/angular';
import {TranslateModule} from '@ngx-translate/core';
import {ThingTranslateModule} from '../../translation/thing-translate.module';
import {ConfigProvider} from '../config/config.provider';
import {AboutPageComponent} from './about-page/about-page.component';
import {MarkdownModule} from 'ngx-markdown';
import {AboutPageContentComponent} from './about-page/about-page-content.component';
@@ -28,7 +29,6 @@ import {ScrollingModule} from '@angular/cdk/scrolling';
import {AboutLicenseModalComponent} from './about-license-modal.component';
import {AboutChangelogComponent} from './about-changelog.component';
import {UtilModule} from '../../util/util.module';
import {IonIconModule} from '../../util/ion-icon/ion-icon.module';
const settingsRoutes: Routes = [
{path: 'about', component: AboutPageComponent},
@@ -52,9 +52,8 @@ const settingsRoutes: Routes = [
],
imports: [
CommonModule,
IonIconModule,
FormsModule,
IonicModule.forRoot(),
IonicModule,
TranslateModule.forChild(),
ThingTranslateModule.forChild(),
RouterModule.forChild(settingsRoutes),
@@ -63,5 +62,6 @@ const settingsRoutes: Routes = [
ScrollingModule,
UtilModule,
],
providers: [ConfigProvider],
})
export class AboutModule {}

View File

@@ -35,7 +35,6 @@ import {AssessmentsProvider} from './assessments.provider';
import {AssessmentsSimpleDataListComponent} from './list/assessments-simple-data-list.component';
import {ProtectedRoutes} from '../auth/protected.routes';
import {AssessmentsTreeListComponent} from './list/assessments-tree-list.component';
import {IonIconModule} from '../../util/ion-icon/ion-icon.module';
import {UtilModule} from '../../util/util.module';
const routes: ProtectedRoutes = [
@@ -69,7 +68,6 @@ const routes: ProtectedRoutes = [
imports: [
CommonModule,
FormsModule,
IonIconModule,
IonicModule,
RouterModule.forChild(routes),
TranslateModule,

View File

@@ -67,7 +67,7 @@
<div class="horizontal-flex">
<ion-button fill="clear" (click)="export()">
{{ 'share' | translate }}
<ion-icon slot="end" md="share" ios="ios_share"></ion-icon>
<ion-icon slot="end" name="share"></ion-icon>
</ion-button>
@if (isWeb) {
<ion-button fill="outline" (click)="download()">

View File

@@ -25,15 +25,13 @@ import {FormsModule} from '@angular/forms';
import {CommonModule} from '@angular/common';
import {MomentModule} from 'ngx-moment';
import {UtilModule} from '../../util/util.module';
import {IonIconModule} from '../../util/ion-icon/ion-icon.module';
@NgModule({
declarations: [AddEventReviewModalComponent],
imports: [
IonicModule.forRoot(),
IonicModule,
TranslateModule.forChild(),
ThingTranslateModule.forChild(),
IonIconModule,
FormsModule,
CommonModule,
MomentModule,

View File

@@ -15,6 +15,7 @@
ion-segment-button {
max-width: 100%;
text-transform: none;
}
.margin-top {

View File

@@ -23,7 +23,6 @@ import {DataModule} from '../data/data.module';
import {SettingsProvider} from '../settings/settings.provider';
import {CatalogComponent} from './catalog.component';
import {UtilModule} from '../../util/util.module';
import {IonIconModule} from '../../util/ion-icon/ion-icon.module';
const catalogRoutes: Routes = [
{path: 'catalog', component: CatalogComponent},
@@ -36,11 +35,10 @@ const catalogRoutes: Routes = [
@NgModule({
declarations: [CatalogComponent],
imports: [
IonicModule.forRoot(),
IonicModule,
FormsModule,
TranslateModule.forChild(),
RouterModule.forChild(catalogRoutes),
IonIconModule,
CommonModule,
MomentModule,
DataModule,

View File

@@ -0,0 +1,27 @@
/*
* Copyright (C) 2019 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {NgModule} from '@angular/core';
import {DataModule} from '../data/data.module';
import {StorageModule} from '../storage/storage.module';
import {ConfigProvider} from './config.provider';
/**
* TODO
*/
@NgModule({
imports: [StorageModule, DataModule],
providers: [ConfigProvider],
})
export class ConfigModule {}

View File

@@ -104,9 +104,9 @@ describe('ConfigProvider', () => {
it('should throw error on wrong config version in storage', async () => {
storageProviderSpy.has.and.returnValue(Promise.resolve(true));
const wrongConfig = structuredClone(sampleIndexResponse);
const wrongConfig = JSON.parse(JSON.stringify(sampleIndexResponse));
wrongConfig.backend.SCVersion = '0.1.0';
storageProviderSpy.get.and.returnValue(Promise.resolve(wrongConfig));
storageProviderSpy.get.and.returnValue(wrongConfig);
spyOn(configProvider.client, 'handshake').and.returnValue(Promise.resolve(sampleIndexResponse));
await configProvider.init();

View File

@@ -73,7 +73,6 @@ export class ConfigProvider {
swHttpClient: StAppsWebHttpClient,
private readonly logger: NGXLogger,
) {
console.log('config init');
this.client = new Client(swHttpClient, environment.backend_url, environment.backend_version);
}

View File

@@ -20,7 +20,7 @@
</ion-header>
<div #schedule class="schedule">
<a [routerLink]="['/schedule/week-overview']">
<ion-icon [size]="36" [weight]="300" name="calendar_month"></ion-icon>
<ion-icon [size]="36" [style.--weight]="300" name="calendar_month"></ion-icon>
<ion-label [innerHTML]="'schedule.recurring' | translate"></ion-label>
</a>
<!-- Avoid structural directives here, they might interfere with the collapse animation -->

View File

@@ -30,7 +30,6 @@ import {MensaSectionContentComponent} from './sections/mensa-section/mensa-secti
import {FavoritesSectionComponent} from './sections/favorites-section/favorites-section.component';
import {ThingTranslateModule} from '../../translation/thing-translate.module';
import {UtilModule} from '../../util/util.module';
import {IonIconModule} from '../../util/ion-icon/ion-icon.module';
import {NewsModule} from '../news/news.module';
import {JobSectionComponent} from './sections/jobs-section/job-section.component';
import {JobModule} from '../jobs/jobs.module';
@@ -56,8 +55,7 @@ const catalogRoutes: Routes = [
JobSectionComponent,
],
imports: [
IonicModule.forRoot(),
IonIconModule,
IonicModule,
FormsModule,
TranslateModule.forChild(),
RouterModule.forChild(catalogRoutes),

View File

@@ -26,7 +26,6 @@ import {AddEventStates, AddEventStatesMap} from './add-event-action-chip.config'
import {EditEventSelectionComponent} from '../edit-event-selection.component';
import {AddEventReviewModalComponent} from '../../../calendar/add-event-review-modal.component';
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
import {MaterialSymbol} from 'material-symbols';
/**
* Shows a horizontal list of action chips
@@ -56,12 +55,12 @@ export class AddEventActionChipComponent {
/**
* Icon
*/
icon: MaterialSymbol;
icon: string;
/**
* Current state of icon fill
*/
iconFill: boolean;
iconFill: 1 | 0;
/**
* Label

View File

@@ -25,30 +25,30 @@ export enum AddEventStates {
export const AddEventStatesMap = {
[AddEventStates.ADDED_ALL]: {
icon: SCIcon.event_available,
fill: true,
fill: 1,
label: 'data.chips.add_events.ADDED_ALL',
disabled: false,
color: 'success',
},
[AddEventStates.ADDED_SOME]: {
icon: SCIcon.event,
fill: true,
fill: 1,
label: 'data.chips.add_events.ADDED_SOME',
disabled: false,
color: 'success',
},
[AddEventStates.REMOVED_ALL]: {
icon: SCIcon.calendar_today,
fill: false,
fill: 0,
label: 'data.chips.add_events.REMOVED_ALL',
disabled: false,
color: 'primary',
},
[AddEventStates.UNAVAILABLE]: {
icon: SCIcon.event_busy,
fill: false,
fill: 0,
label: 'data.chips.add_events.UNAVAILABLE',
disabled: true,
color: 'dark',
},
};
} as const;

View File

@@ -22,7 +22,7 @@
[color]="color"
[outline]="true"
>
<ion-icon [name]="icon" [fill]="iconFill"></ion-icon>
<ion-icon [name]="icon" [style.--fill]="iconFill"></ion-icon>
<ion-label>{{ label | translate }}</ion-label>
<stapps-edit-modal #editModal (save)="selection.save()">
<ng-template>

View File

@@ -14,9 +14,8 @@
*/
import {SCThingType} from '@openstapps/core';
import {SCIcon} from '../../util/ion-icon/icon';
import {MaterialSymbol} from 'material-symbols';
export const DataIcons = {
export const DataIcons: Record<SCThingType, string> = {
'academic event': SCIcon.school,
'assessment': SCIcon.fact_check,
'article': SCIcon.article,
@@ -48,4 +47,4 @@ export const DataIcons = {
'video': SCIcon.movie,
'diff': SCIcon.difference,
'job posting': SCIcon.work,
} satisfies Record<SCThingType, MaterialSymbol>;
};

View File

@@ -31,7 +31,7 @@ export class DataIconPipe implements PipeTransform {
/**
* Provide the icon name from the data type
*/
transform(type: SCThingType) {
transform(type: SCThingType): string {
return this.typeIconMap[type];
}
}

View File

@@ -17,19 +17,19 @@ import {CommonModule} from '@angular/common';
import {HttpClientModule} from '@angular/common/http';
import {NgModule} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {LeafletModule} from '@asymmetrik/ngx-leaflet';
import {IonicModule, Platform} from '@ionic/angular';
import {TranslateModule} from '@ngx-translate/core';
import {MarkdownModule} from 'ngx-markdown';
import {MomentModule} from 'ngx-moment';
import {ThingTranslateModule} from '../../translation/thing-translate.module';
import {SimpleBrowser, browserFactory} from '../../util/browser.factory';
import {IonIconModule} from '../../util/ion-icon/ion-icon.module';
import {RoutingStackService} from '../../util/routing-stack.service';
import {UtilModule} from '../../util/util.module';
import {CalendarService} from '../calendar/calendar.service';
import {ScheduleProvider} from '../calendar/schedule.provider';
import {GeoNavigationDirective} from '../map/geo-navigation.directive';
import {MapWidgetComponent} from '../map/map-widget.component';
import {MapWidgetComponent} from '../map/widget/map-widget.component';
import {MenuModule} from '../menu/menu.module';
import {SettingsProvider} from '../settings/settings.provider';
import {StorageModule} from '../storage/storage.module';
@@ -141,6 +141,7 @@ import {ShareButtonComponent} from './elements/share-button.component';
FoodDataListComponent,
LocateActionChipComponent,
LongInlineTextComponent,
MapWidgetComponent,
MessageDetailContentComponent,
MessageListItemComponent,
JobPostingDetailContentComponent,
@@ -185,12 +186,11 @@ import {ShareButtonComponent} from './elements/share-button.component';
CommonModule,
DataRoutingModule,
FormsModule,
MapWidgetComponent,
HttpClientModule,
IonicModule.forRoot(),
IonicModule,
LeafletModule,
MarkdownModule.forRoot(),
MenuModule,
IonIconModule,
MomentModule.forRoot({
relativeTimeThresholdOptions: {
m: 59,

View File

@@ -14,10 +14,6 @@
*/
@import '../../../../theme/util/mixins';
:host {
display: contents;
}
stapps-origin-detail {
// css hack to make the element stick to the bottom of the scroll container even
// when the content is not filling it
@@ -53,10 +49,13 @@ stapps-origin-detail {
background: var(--ion-color-primary);
}
& > .expand-when-space,
&:has(> .expand-when-space) {
flex: 1;
height: unset;
// Firefox doesn't support this yet...
@supports selector(:has(*)) {
& > .expand-when-space,
&:has(> .expand-when-space) {
flex: 1;
height: unset;
}
}
}
}

View File

@@ -17,6 +17,7 @@ ion-content > div {
display: flex;
flex: 1;
flex-direction: column;
min-height: 100%;
}
ion-title {

View File

@@ -13,11 +13,10 @@
~ this program. If not, see <https://www.gnu.org/licenses/>.
-->
<ion-button (click)="toggle($event)" fill="clear" shape="round">
<ion-button (click)="toggle($event)" color="medium" size="small" fill="clear">
<ion-icon
slot="icon-only"
[size]="24"
[fill]="(isFavorite$ | async) || false"
[style.--fill]="(isFavorite$ | async) ? 1 : 0"
[class.selected]="isFavorite$ | async"
name="grade"
></ion-icon>

View File

@@ -13,25 +13,22 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
ion-button {
--background-activated: currentcolor;
--background-hover: currentcolor;
--background-focused: currentcolor;
:host {
ion-button {
--border-radius: 50%;
aspect-ratio: 1;
color: inherit;
}
width: 50px;
height: 50px;
}
.selected {
color: #fbc02d;
}
.selected {
// TODO
color: #fbc02d;
}
@media (hover: hover) {
ion-button:hover ::ng-deep stapps-icon {
--fill: 1 !important;
@media (hover: hover) {
ion-button:hover ::ng-deep stapps-icon {
--fill: 1;
}
}
}
::ng-deep ion-item stapps-favorite-button ion-button {
color: var(--ion-color-medium) !important;
}

View File

@@ -12,7 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {ChangeDetectionStrategy, Component, Input} from '@angular/core';
import {Component, Input} from '@angular/core';
import {SCIndexableThings} from '@openstapps/core';
import {FavoritesService} from '../../favorites/favorites.service';
import {Observable} from 'rxjs';
@@ -25,7 +25,6 @@ import {map, take} from 'rxjs/operators';
selector: 'stapps-favorite-button',
templateUrl: './favorite-button.component.html',
styleUrls: ['./favorite-button.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class FavoriteButtonComponent {
/**

View File

@@ -21,7 +21,6 @@ import {SCThingUserOrigin, SCThingRemoteOrigin} from '@openstapps/core';
@Component({
selector: 'stapps-origin-detail',
templateUrl: 'origin-detail.html',
styleUrl: 'origin-detail.scss',
})
export class OriginDetailComponent {
/**

View File

@@ -14,61 +14,71 @@
-->
@if (origin.type === 'user') {
<h3>
{{ 'data.types.origin.TITLE' | translate | sentencecase }}:
{{ 'data.types.origin.USER' | translate | sentencecase }}
</h3>
<p>
{{ 'data.types.origin.detail.CREATED' | translate | sentencecase }}:
{{ origin.created | amDateFormat: 'll' }}
</p>
@if (origin.updated) {
<p>
{{ 'data.types.origin.detail.UPDATED' | translate | sentencecase }}:
{{ origin.updated | amDateFormat: 'll' }}
</p>
}
@if (origin.modified) {
<p>
{{ 'data.types.origin.detail.MODIFIED' | translate | sentencecase }}:
{{ origin.modified | amDateFormat: 'll' }}
</p>
}
@if (origin.maintainer) {
<p>
{{ 'data.types.origin.detail.MAINTAINER' | translate | sentencecase }}:
<a [routerLink]="['/data-detail', origin.maintainer.uid]">{{ origin.maintainer.name }}</a>
</p>
}
<ion-card>
<ion-card-header
>{{ 'data.types.origin.TITLE' | translate | titlecase }}:
{{ 'data.types.origin.USER' | translate | titlecase }}</ion-card-header
>
<ion-card-content>
<p>
{{ 'data.types.origin.detail.CREATED' | translate | titlecase }}:
{{ origin.created | amDateFormat: 'll' }}
</p>
@if (origin.updated) {
<p>
{{ 'data.types.origin.detail.UPDATED' | translate | titlecase }}:
{{ origin.updated | amDateFormat: 'll' }}
</p>
}
@if (origin.modified) {
<p>
{{ 'data.types.origin.detail.MODIFIED' | translate | titlecase }}:
{{ origin.modified | amDateFormat: 'll' }}
</p>
}
@if (origin.maintainer) {
<p>
{{ 'data.types.origin.detail.MAINTAINER' | translate }}:
<a [routerLink]="['/data-detail', origin.maintainer.uid]">{{ origin.maintainer.name }}</a>
</p>
}
</ion-card-content>
</ion-card>
}
@if (origin.type === 'remote') {
<h3>
{{ 'data.types.origin.TITLE' | translate | sentencecase }}:
{{ 'data.types.origin.REMOTE' | translate | sentencecase }}
</h3>
<p>
{{ 'data.types.origin.detail.INDEXED' | translate | sentencecase }}:
{{ origin.indexed | amDateFormat: 'll' }}
</p>
@if (origin.modified) {
<p>
{{ 'data.types.origin.detail.MODIFIED' | translate | sentencecase }}:
{{ origin.modified | amDateFormat: 'll' }}
</p>
}
@if (origin.name) {
<p>{{ 'data.types.origin.detail.MAINTAINER' | translate | sentencecase }}: {{ origin.name }}</p>
}
@if (origin.maintainer) {
<p>
{{ 'data.types.origin.detail.MAINTAINER' | translate | sentencecase }}:
<a [routerLink]="['/data-detail', origin.maintainer.uid]">{{ origin.maintainer.name }}</a>
</p>
}
@if (origin.responsibleEntity) {
<p>
{{ 'data.types.origin.detail.RESPONSIBLE' | translate | sentencecase }}:
<a [routerLink]="['/data-detail', origin.responsibleEntity.uid]">{{ origin.responsibleEntity.name }}</a>
</p>
}
<ion-card>
<ion-card-header
>{{ 'data.types.origin.TITLE' | translate | titlecase }}:
{{ 'data.types.origin.REMOTE' | translate | titlecase }}</ion-card-header
>
<ion-card-content>
<p>
{{ 'data.types.origin.detail.INDEXED' | translate | titlecase }}:
{{ origin.indexed | amDateFormat: 'll' }}
</p>
@if (origin.modified) {
<p>
{{ 'data.types.origin.detail.MODIFIED' | translate | titlecase }}:
{{ origin.modified | amDateFormat: 'll' }}
</p>
}
@if (origin.name) {
<p>{{ 'data.types.origin.detail.MAINTAINER' | translate }}: {{ origin.name }}</p>
}
@if (origin.maintainer) {
<p>
{{ 'data.types.origin.detail.MAINTAINER' | translate | titlecase }}:
<a [routerLink]="['/data-detail', origin.maintainer.uid]">{{ origin.maintainer.name }}</a>
</p>
}
@if (origin.responsibleEntity) {
<p>
{{ 'data.types.origin.detail.RESPONSIBLE' | translate | titlecase }}:
<a [routerLink]="['/data-detail', origin.responsibleEntity.uid]">{{
origin.responsibleEntity.name
}}</a>
</p>
}
</ion-card-content>
</ion-card>
}

View File

@@ -1,15 +0,0 @@
:host {
padding: var(--spacing-lg);
padding-top: 0;
}
h3 {
font-weight: bold;
}
h3,
p {
margin: 0;
font-size: 0.8em;
opacity: 0.8;
}

View File

@@ -1,4 +1,4 @@
<ion-button size="small" fill="clear" (click)="share() && toast.present()">
<ion-icon [size]="24" slot="icon-only" name="share" ios="ios_share"></ion-icon>
<ion-icon [size]="24" slot="icon-only" name="share"></ion-icon>
</ion-button>
<ion-toast [message]="'toast.TITLE_COPIED' | translate" #toast [duration]="2000"></ion-toast>

View File

@@ -16,6 +16,7 @@
import {Component, ElementRef, HostListener, Input, OnChanges, OnInit, ViewChild} from '@angular/core';
import {SCThings} from '@openstapps/core';
import {SCIcon} from '../../../util/ion-icon/icon';
import {MaterialSymbol} from 'material-symbols';
const AccordionButtonState = {
collapsed: SCIcon.expand_more,
@@ -35,8 +36,7 @@ export class TitleCardComponent implements OnInit, OnChanges {
@ViewChild('accordionTextArea') accordionTextArea: ElementRef;
buttonState: (typeof AccordionButtonState)[keyof typeof AccordionButtonState] =
AccordionButtonState.collapsed;
buttonState: MaterialSymbol = AccordionButtonState.collapsed;
buttonShown = true;

View File

@@ -38,6 +38,7 @@ ion-toolbar:first-of-type {
ion-button {
width: 50%;
margin: 0;
text-transform: none;
}
}
}

View File

@@ -14,7 +14,7 @@
-->
@if (isInCalendar | async) {
<ion-chip outline="true" color="success" (click)="removeFromCalendar()">
<ion-icon name="event_available" [fill]="true"></ion-icon>
<ion-icon name="event_available" [style.--fill]="1"></ion-icon>
<ion-label>{{ 'chips.addEvent.addedToEvents' | translate }}</ion-label>
</ion-chip>
} @else {
@@ -68,5 +68,5 @@
</ion-card>
}
@if (item.inPlace && item.inPlace.geo) {
<stapps-map-widget [place]="$any(item.inPlace)"></stapps-map-widget>
<stapps-map-widget [place]="item.inPlace"></stapps-map-widget>
}

View File

@@ -17,6 +17,7 @@ import {PositionService} from '../../../map/position.service';
import {filter, Observable} from 'rxjs';
import {hasValidLocation, isSCFloor, PlaceTypes, PlaceTypesWithDistance} from './place-types';
import {map} from 'rxjs/operators';
import {LatLng, geoJSON} from 'leaflet';
import {trigger, transition, style, animate} from '@angular/animations';
/**
@@ -38,14 +39,13 @@ export class PlaceListItemComponent {
@Input() set item(item: PlaceTypes) {
this._item = item;
if (!isSCFloor(item) && hasValidLocation(item)) {
this.distance = this.positionService.geoLocation.pipe(
map(
position =>
Math.hypot(
position.coords.latitude - item.geo.point.coordinates[1],
position.coords.longitude - item.geo.point.coordinates[0],
) * 111_139,
this.distance = this.positionService.watchCurrentLocation().pipe(
map(position =>
new LatLng(position.latitude, position.longitude).distanceTo(
geoJSON(item.geo.point).getBounds().getCenter(),
),
),
filter(it => it !== undefined),
);
}

View File

@@ -12,6 +12,7 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import moment, {Moment} from 'moment';
import {AfterViewInit, Component, DestroyRef, inject, Input} from '@angular/core';
import {SCDish, SCISO8601Date, SCPlace} from '@openstapps/core';
import {PlaceMensaService} from './place-mensa-service';
@@ -52,6 +53,11 @@ export class PlaceMensaDetailComponent implements AfterViewInit {
*/
selectedDay: string;
/**
* First day to display menu items for
*/
startingDay: Moment;
destroy$ = inject(DestroyRef);
constructor(
@@ -59,7 +65,9 @@ export class PlaceMensaDetailComponent implements AfterViewInit {
protected router: Router,
readonly routerOutlet: IonRouterOutlet,
private readonly dataRoutingService: DataRoutingService,
) {}
) {
this.startingDay = moment().startOf('day');
}
ngAfterViewInit() {
if (!this.openAsModal) {

View File

@@ -13,6 +13,10 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
ion-segment-button {
text-transform: none;
}
ion-segment {
overflow: auto;
justify-content: space-between;

View File

@@ -22,7 +22,6 @@ import {MenuModule} from '../menu/menu.module';
import {TranslateModule} from '@ngx-translate/core';
import {DataModule} from '../data/data.module';
import {UtilModule} from '../../util/util.module';
import {IonIconModule} from '../../util/ion-icon/ion-icon.module';
const favoritesRoutes: Routes = [
{
@@ -40,7 +39,6 @@ const favoritesRoutes: Routes = [
MenuModule,
TranslateModule,
DataModule,
IonIconModule,
UtilModule,
],
declarations: [FavoritesPageComponent],

View File

@@ -21,7 +21,6 @@ import {RouterModule, Routes} from '@angular/router';
import {TranslateModule} from '@ngx-translate/core';
import {MarkdownModule} from 'ngx-markdown';
import {UtilModule} from '../../util/util.module';
import {IonIconModule} from '../../util/ion-icon/ion-icon.module';
const feedbackRoutes: Routes = [
{
@@ -35,7 +34,6 @@ const feedbackRoutes: Routes = [
CommonModule,
FormsModule,
IonicModule,
IonIconModule,
RouterModule.forChild(feedbackRoutes),
TranslateModule,
MarkdownModule,

View File

@@ -27,7 +27,6 @@ import {HebisDetailComponent} from './hebis-detail.component';
import {Observable, of} from 'rxjs';
import {StorageProvider} from '../../storage/storage.provider';
import {IonicModule} from '@ionic/angular';
import {IonIconModule} from '../../../util/ion-icon/ion-icon.module';
import {LoggerModule, NgxLoggerLevel} from 'ngx-logger';
const translations: any = {data: {detail: {TITLE: 'Foo'}}};
@@ -69,7 +68,6 @@ describe('HebisDetailComponent', () => {
HebisRoutingModule,
HebisModule,
IonicModule,
IonIconModule,
TranslateModule.forRoot({
loader: {provide: TranslateLoader, useClass: TranslateFakeLoader},
}),

View File

@@ -34,7 +34,6 @@ import {HebisRoutingModule} from './hebis-routing.module';
import {DataModule} from '../data/data.module';
import {DaiaAvailabilityComponent} from './daia-availability/daia-availability.component';
import {UtilModule} from '../../util/util.module';
import {IonIconModule} from '../../util/ion-icon/ion-icon.module';
import {DaiaHoldingComponent} from './daia-availability/daia-holding.component';
/**
@@ -53,9 +52,8 @@ import {DaiaHoldingComponent} from './daia-availability/daia-holding.component';
DataModule,
FormsModule,
HebisRoutingModule,
IonIconModule,
HttpClientModule,
IonicModule.forRoot(),
IonicModule,
MarkdownModule.forRoot(),
MenuModule,
MomentModule.forRoot({

View File

@@ -5,7 +5,7 @@ import {TranslateModule} from '@ngx-translate/core';
import {MomentModule} from 'ngx-moment';
import {DataModule} from '../data/data.module';
import {UtilModule} from '../../util/util.module';
import {IonIconModule} from '../../util/ion-icon/ion-icon.module';
import {ConfigProvider} from '../config/config.provider';
import {ThingTranslateModule} from '../../translation/thing-translate.module';
import {RouterModule, Routes} from '@angular/router';
import {JobsPageComponent} from './page/jobs-page.component';
@@ -15,15 +15,15 @@ const jobsRoutes: Routes = [{path: 'jobs', component: JobsPageComponent}];
@NgModule({
declarations: [JobsPageComponent],
imports: [
IonicModule.forRoot(),
IonicModule,
ThingTranslateModule.forChild(),
TranslateModule.forChild(),
RouterModule.forChild(jobsRoutes),
IonIconModule,
CommonModule,
MomentModule,
DataModule,
UtilModule,
],
providers: [ConfigProvider],
})
export class JobModule {}

View File

@@ -32,7 +32,6 @@ import {MomentModule} from 'ngx-moment';
import {FeeItemComponent} from './account/elements/fee-item/fee-item.component';
import {DataModule} from '../data/data.module';
import {UtilModule} from '../../util/util.module';
import {IonIconModule} from '../../util/ion-icon/ion-icon.module';
const routes: ProtectedRoutes | Routes = [
{
@@ -72,7 +71,6 @@ const routes: ProtectedRoutes | Routes = [
CommonModule,
FormsModule,
IonicModule,
IonIconModule,
RouterModule.forChild(routes),
TranslateModule,
MomentModule,

View File

@@ -1,51 +0,0 @@
import {Pipe, PipeTransform} from '@angular/core';
import {MapService} from '@maplibre/ngx-maplibre-gl';
import {Feature, Point} from 'geojson';
import {MapGeoJSONFeature, type GeoJSONSource} from 'maplibre-gl';
import {combineLatest, distinctUntilChanged, map, mergeMap, from, Observable, ReplaySubject} from 'rxjs';
import {SCFeatureProperties} from './feature-collection.pipe';
@Pipe({
name: 'mglClusterLeaves',
standalone: true,
pure: true,
})
export class MglClusterLeavesPipe implements PipeTransform {
source = new ReplaySubject<string>(1);
feature = new ReplaySubject<MapGeoJSONFeature>(1);
limit = new ReplaySubject<number>(1);
offset = new ReplaySubject<number>(1);
leaves: Observable<Feature<Point, SCFeatureProperties>[]> = combineLatest([
this.source.pipe(
distinctUntilChanged(),
map(source => this.mapService.getSource(source) as GeoJSONSource),
),
this.feature.pipe(distinctUntilChanged(it => it.properties.cluster_id)),
this.limit.pipe(distinctUntilChanged()),
this.offset.pipe(distinctUntilChanged()),
]).pipe(
mergeMap(([source, feature, limit, offset]) =>
from(source.getClusterLeaves(feature.properties.cluster_id, limit, offset)),
),
);
constructor(private mapService: MapService) {}
transform(
source: string,
feature: MapGeoJSONFeature,
limit = 0,
offset = 0,
): Observable<Feature<Point, SCFeatureProperties>[]> {
// MapLibre triggers change detection when the map moves, so this is to prevent flicker
this.source.next(source);
this.feature.next(feature);
this.limit.next(limit);
this.offset.next(offset);
return this.leaves;
}
}

View File

@@ -1,38 +0,0 @@
import {animate, style, transition, trigger} from '@angular/animations';
import {AsyncPipe} from '@angular/common';
import {ChangeDetectionStrategy, Component, Input, inject} from '@angular/core';
import {IonicModule} from '@ionic/angular';
import {MapService} from '@maplibre/ngx-maplibre-gl';
import {map, delay, Subject, race, mergeWith} from 'rxjs';
import {IonIconModule} from 'src/app/util/ion-icon/ion-icon.module';
@Component({
selector: 'stapps-map-attribution',
templateUrl: './attribution.html',
styleUrl: './attribution.scss',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [IonicModule, IonIconModule, AsyncPipe],
animations: [
trigger('fade', [
transition(':enter', [
style({opacity: 0, scale: '0.8 1'}),
animate('0.2s ease', style({opacity: 1, scale: 1})),
]),
transition(':leave', [
style({opacity: 1, scale: 1}),
animate('0.2s ease', style({opacity: 0, scale: '0.8 1'})),
]),
]),
],
})
export class AttributionComponent {
@Input() direction: 'left' | 'right' = 'right';
manualVisible = new Subject<void>();
hideAttribution = race(
this.manualVisible,
inject(MapService).mapCreated$.pipe(delay(5000), mergeWith(this.manualVisible)),
).pipe(map((_, i) => i % 2 === 0));
}

View File

@@ -1,8 +0,0 @@
@if ((hideAttribution | async) === null) {
<ion-button [attr.direction]="direction" @fade class="attribution" color="light"
>© OpenStreetMap</ion-button
>
}
<ion-button class="info" shape="round" color="light" (click)="this.manualVisible.next()">
<ion-icon slot="icon-only" name="info"></ion-icon>
</ion-button>

View File

@@ -1,36 +0,0 @@
:host {
position: relative;
}
ion-button {
height: 28px;
min-height: 28px;
margin: 0;
font-size: 10px;
}
ion-button.info {
--padding-start: 4px;
--padding-end: 4px;
}
ion-button.attribution {
position: absolute;
top: -3px;
&[direction='right'] {
--border-radius: 0 14px 14px 0;
--padding-start: 14px;
left: 16px;
transform-origin: 0 0;
}
&[direction='left'] {
--border-radius: 14px 0 0 14px;
--padding-end: 14px;
right: 16px;
transform-origin: 100% 0;
}
}

View File

@@ -1,40 +0,0 @@
import {AsyncPipe} from '@angular/common';
import {ChangeDetectionStrategy, Component} from '@angular/core';
import {IonicModule} from '@ionic/angular';
import {MapService} from '@maplibre/ngx-maplibre-gl';
import {MapEventType} from 'maplibre-gl';
import {map, mergeMap, fromEventPattern, merge} from 'rxjs';
import {IonIconModule} from 'src/app/util/ion-icon/ion-icon.module';
@Component({
selector: 'stapps-compass-control',
templateUrl: './compass-control.html',
styleUrl: './compass-control.scss',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [AsyncPipe, IonicModule, IonIconModule],
})
export class CompassControlComponent {
transform = this.mapService.mapCreated$.pipe(
mergeMap(() =>
merge(
fromEventPattern<MapEventType['rotate']>(
handler => this.mapService.mapInstance.on('rotate', handler),
handler => this.mapService.mapInstance.off('rotate', handler),
),
fromEventPattern<MapEventType['pitch']>(
handler => this.mapService.mapInstance.on('pitch', handler),
handler => this.mapService.mapInstance.off('pitch', handler),
),
),
),
map(event => {
const pitch = event.target.transform.pitch;
const angle = event.target.transform.angle;
return `rotateX(${pitch}deg) rotateZ(${angle}rad)`;
}),
);
constructor(readonly mapService: MapService) {}
}

View File

@@ -1,7 +0,0 @@
<ion-fab-button (click)="mapService.mapInstance.resetNorthPitch()" size="small" color="light">
<svg [style.transform]="transform | async" width="24" height="24" viewBox="0 0 32 32">
>
<path d="m8.5 15 6.56-13.13a1.05 1.05 180 0 1 1.88 0L23.5 15 16 12.5Z" />
<path d="m8.5 15 6.56-13.13a1.05 1.05 180 0 1 1.88 0L23.5 15 16 12.5Z" transform="rotate(180 16 16)" />
</svg>
</ion-fab-button>

View File

@@ -1,11 +0,0 @@
path {
stroke: none;
&:first-child {
fill: var(--ion-color-primary);
}
&:last-child {
fill: var(--ion-color-medium);
}
}

View File

@@ -1,91 +0,0 @@
import {AsyncPipe} from '@angular/common';
import {
AfterContentInit,
ChangeDetectionStrategy,
Component,
ElementRef,
Input,
OnDestroy,
ViewChild,
} from '@angular/core';
import {IonicModule} from '@ionic/angular';
import {MapService} from '@maplibre/ngx-maplibre-gl';
import {FitBoundsOptions, GeolocateControl, GeolocateControlOptions} from 'maplibre-gl';
import {Map as MapLibre} from 'maplibre-gl';
import {BehaviorSubject} from 'rxjs';
import {IonIconModule} from 'src/app/util/ion-icon/ion-icon.module';
type WatchState = InstanceType<typeof GeolocateControl>['_watchState'];
class CustomGeolocateControl extends GeolocateControl {
constructor(
public _container: HTMLElement,
watchState: BehaviorSubject<WatchState>,
options: GeolocateControlOptions,
) {
super(options);
Object.defineProperty(this, '_watchState', {
get() {
return watchState.value;
},
set(value: WatchState) {
watchState.next(value);
},
});
}
override onAdd(map: MapLibre): HTMLElement {
const container = this._container;
this._container = document.createElement('div');
this._map = map;
this._setupUI(true);
this._container = container;
return this._container;
}
override onRemove() {}
}
@Component({
selector: 'stapps-geolocate-control',
templateUrl: './geolocate-control.html',
styleUrl: './geolocate-control.scss',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [AsyncPipe, IonicModule, IonIconModule],
})
export class GeolocateControlComponent implements AfterContentInit, OnDestroy {
@Input() position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
@Input() positionOptions?: PositionOptions;
@Input() fitBoundsOptions?: FitBoundsOptions;
@Input() trackUserLocation?: boolean;
@Input() showUserLocation?: boolean;
@ViewChild('content', {static: true}) content: ElementRef;
watchState = new BehaviorSubject<WatchState>('OFF');
control: CustomGeolocateControl;
constructor(private mapService: MapService) {}
ngAfterContentInit() {
this.control = new CustomGeolocateControl(this.content.nativeElement, this.watchState, {
positionOptions: this.positionOptions,
fitBoundsOptions: this.fitBoundsOptions,
trackUserLocation: this.trackUserLocation,
showUserLocation: this.showUserLocation,
});
this.mapService.mapCreated$.subscribe(() => {
this.mapService.addControl(this.control, this.position);
});
}
ngOnDestroy(): void {
this.mapService.removeControl(this.control);
}
}

View File

@@ -1,18 +0,0 @@
<div #content class="maplibregl-ctrl">
<ion-fab-button color="light" (click)="control.trigger()">
@switch (watchState | async) {
@case ('ACTIVE_LOCK') {
<ion-icon name="my_location" color="primary"></ion-icon>
}
@case ('BACKGROUND') {
<ion-icon name="location_searching"></ion-icon>
}
@case ('WAITING_ACTIVE') {
<ion-icon name="location_searching"></ion-icon>
}
@default {
<ion-icon name="location_disabled"></ion-icon>
}
}
</ion-fab-button>
</div>

View File

@@ -1,86 +0,0 @@
import {ChangeDetectionStrategy, Component, Input, Optional} from '@angular/core';
import {GeoJSONSourceComponent, LayerComponent, MapService} from '@maplibre/ngx-maplibre-gl';
import {FeatureCollection, Polygon} from 'geojson';
import {SCFeatureProperties} from '../feature-collection.pipe';
import {
FillLayerSpecification,
LineLayerSpecification,
MapLayerMouseEvent,
SymbolLayerSpecification,
} from 'maplibre-gl';
import {DataRoutingService} from '../../data/data-routing.service';
import {MapDataProvider} from '../map-data.provider';
import {fromEvent, map, startWith, Observable} from 'rxjs';
import {AsyncPipe} from '@angular/common';
/**
* Get a CCS variable value
*/
function getCssVariable(color: string) {
return getComputedStyle(document.documentElement).getPropertyValue(color);
}
@Component({
selector: 'stapps-building-markers',
templateUrl: './building-markers.html',
styleUrl: './building-markers.scss',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [GeoJSONSourceComponent, LayerComponent, AsyncPipe],
})
export class BuildingMarkersComponent {
accentColor = getCssVariable('--ion-color-primary');
haloColor = fromEvent<MediaQueryListEvent>(
window.matchMedia('(prefers-color-scheme: dark)'),
'change',
).pipe(
map(() => getCssVariable('--ion-background-color')),
startWith(getCssVariable('--ion-background-color')),
);
buildingPaint: LineLayerSpecification['paint'] = {
'line-color': this.accentColor,
'line-width': 2,
};
buildingFillPaint: FillLayerSpecification['paint'] = {
'fill-color': `${this.accentColor}22`,
};
buildingLabelLayout: SymbolLayerSpecification['layout'] = {
'text-field': '{name}',
'text-font': ['barlow-700-normal'],
'text-max-width': 8,
'text-size': 13,
};
buildingLabelPaint: Observable<SymbolLayerSpecification['paint']> = this.haloColor.pipe(
map(haloColor => ({
'text-color': this.accentColor,
'text-halo-color': haloColor,
'text-halo-width': 1,
})),
);
@Input({required: true}) data: FeatureCollection<Polygon, SCFeatureProperties>;
constructor(
@Optional() readonly dataProvider: MapDataProvider | null,
readonly dataRoutingService: DataRoutingService,
readonly mapService: MapService,
) {}
async featureClick(event: MapLayerMouseEvent) {
if (this.dataProvider === null) return;
if (event.originalEvent.target !== event.target._canvas) return;
const feature = event.features?.[0];
if (!feature) return;
const item = this.dataProvider.current.value?.data.find(it => it.uid === feature.properties.uid);
if (item === undefined) return;
this.dataRoutingService.emitChildEvent(item);
}
}

View File

@@ -1,26 +0,0 @@
<mgl-geojson-source id="polygons" [data]="data"></mgl-geojson-source>
<mgl-layer
id="stapps-building-fill"
type="fill"
source="polygons"
before="poi_label"
[paint]="buildingFillPaint"
(layerClick)="featureClick($event)"
(layerMouseEnter)="dataProvider !== null && mapService.changeCanvasCursor('pointer')"
(layerMouseLeave)="dataProvider !== null && mapService.changeCanvasCursor('grab')"
></mgl-layer>
<mgl-layer
id="stapps-building-outline"
type="line"
source="polygons"
before="poi_label"
[paint]="buildingPaint"
></mgl-layer>
<mgl-layer
id="stapps-building-label"
type="symbol"
source="polygons"
after="poi_label"
[paint]="(buildingLabelPaint | async) || {}"
[layout]="buildingLabelLayout"
></mgl-layer>

View File

@@ -1,43 +0,0 @@
import {ChangeDetectionStrategy, Component, HostBinding, Input, OnInit, Optional} from '@angular/core';
import {IonicModule} from '@ionic/angular';
import {IonIconModule} from 'src/app/util/ion-icon/ion-icon.module';
import {MapIconDirective} from '../map-icon.directive';
import {Feature, Point} from 'geojson';
import {SCFeatureProperties} from '../feature-collection.pipe';
import {MapDataProvider} from '../map-data.provider';
import {DataRoutingService} from '../../data/data-routing.service';
import {AddWordBreakOpportunitiesPipe} from '../../../util/word-break-opportunities.pipe';
@Component({
selector: 'stapps-poi-marker',
templateUrl: './poi-marker.html',
styleUrl: './poi-marker.scss',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [IonicModule, IonIconModule, MapIconDirective, AddWordBreakOpportunitiesPipe],
})
export class PoiMarkerComponent implements OnInit {
@Input({required: true}) feature: Feature<Point, SCFeatureProperties>;
@HostBinding('disabled') disabled = this.dataProvider === null;
fontSize = 0;
constructor(
@Optional() readonly dataProvider: MapDataProvider | null,
readonly dataRoutingService: DataRoutingService,
) {}
async featureClick() {
if (this.dataProvider === null) return;
const item = this.dataProvider.current.value?.data.find(it => it.uid === this.feature.properties.uid);
if (item === undefined) return;
this.dataRoutingService.emitChildEvent(item);
}
ngOnInit() {
this.fontSize = Math.max(10, 12 - Math.max(0, this.feature.properties.name.length - 16));
}
}

View File

@@ -1,9 +0,0 @@
<ion-button shape="round" (click)="featureClick()">
<ion-icon
slot="start"
[size]="16"
[fill]="true"
[name]="feature.properties.category | stappsMapIcon"
></ion-icon>
<ion-label>{{ feature.properties.name | addWordBreakOpportunities }}</ion-label>
</ion-button>

View File

@@ -1,38 +0,0 @@
ion-button {
--padding-top: 0;
--padding-bottom: 0;
--padding-start: var(--spacing-md);
--padding-end: var(--spacing-sm);
max-width: 120px;
min-height: 0;
margin: 0;
margin-block-end: 4px;
font: inherit;
font-size: 0.9em;
font-weight: bold;
&::part(native) {
height: 32px;
line-height: 1.2;
}
}
ion-icon {
flex-shrink: 0;
}
ion-label {
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
padding: 4px 0;
text-align: left;
overflow-wrap: normal;
white-space: wrap;
-webkit-line-clamp: 2;
}

View File

@@ -1,43 +0,0 @@
import {ChangeDetectionStrategy, Component, Input} from '@angular/core';
import {MapIconDirective} from '../map-icon.directive';
import {FeatureCollection, Point} from 'geojson';
import {SCFeatureProperties} from '../feature-collection.pipe';
import {animate, style, transition, trigger} from '@angular/animations';
import {MglClusterLeavesPipe} from '../cluster-leaves.pipe';
import {
ClusterPointDirective,
GeoJSONSourceComponent,
MarkersForClustersComponent,
PointDirective,
} from '@maplibre/ngx-maplibre-gl';
import {AsyncPipe} from '@angular/common';
import {PoiMarkerComponent} from './poi-marker.component';
@Component({
selector: 'stapps-poi-markers',
templateUrl: './poi-markers.html',
styleUrl: './poi-markers.scss',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [
MapIconDirective,
MglClusterLeavesPipe,
GeoJSONSourceComponent,
MarkersForClustersComponent,
AsyncPipe,
ClusterPointDirective,
PointDirective,
PoiMarkerComponent,
],
animations: [
trigger('fade', [
transition(':enter', [style({opacity: 0}), animate('200ms', style({opacity: 1}))]),
transition(':leave', [style({opacity: 1}), animate('200ms', style({opacity: 0}))]),
]),
],
})
export class PoiMarkersComponent {
@Input({required: true}) data: FeatureCollection<Point, SCFeatureProperties>;
@Input() clusterPreviewCount = 3;
}

View File

@@ -1,33 +0,0 @@
<mgl-geojson-source
id="pois"
[cluster]="true"
[clusterMaxZoom]="20"
[clusterRadius]="100"
[data]="data"
></mgl-geojson-source>
<mgl-markers-for-clusters source="pois">
<ng-template mglPoint let-feature>
<div class="marker">
<stapps-poi-marker @fade [feature]="feature"></stapps-poi-marker>
</div>
</ng-template>
<ng-template mglClusterPoint let-feature>
<div class="marker">
@if (
'pois'
| mglClusterLeaves
: feature
: clusterPreviewCount - (feature.properties.point_count > clusterPreviewCount ? 1 : 0)
| async;
as leaves
) {
@for (feature of leaves; track feature.id) {
<stapps-poi-marker @fade [feature]="feature"></stapps-poi-marker>
}
@if (feature.properties.point_count > leaves.length) {
<div @fade class="ellipsis">+{{ feature.properties.point_count - leaves.length }}</div>
}
}
</div>
</ng-template>
</mgl-markers-for-clusters>

Some files were not shown because too many files have changed in this diff Show More