mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2025-12-30 01:52:53 +00:00
Compare commits
18 Commits
@openstapp
...
63-replace
| Author | SHA1 | Date | |
|---|---|---|---|
|
b33beeb669
|
|||
|
d2d577c012
|
|||
|
fe517fb4aa
|
|||
|
9e26fa7a1a
|
|||
|
38fb7a398d
|
|||
|
a99e08cd68
|
|||
| a5c9d22016 | |||
|
3c49c4cf6d
|
|||
|
f2c4ee308f
|
|||
| bd09b36620 | |||
|
ca146b7761
|
|||
|
|
001f978bf9 | ||
|
|
57a5b6061b | ||
|
|
4fb5941c56 | ||
|
|
314e6a6e86 | ||
|
|
e1cc33bba2 | ||
|
|
9abd397578 | ||
|
|
69fe8c6ac8 |
5
.changeset/chilly-goats-cough.md
Normal file
5
.changeset/chilly-goats-cough.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@openstapps/app': minor
|
||||
---
|
||||
|
||||
Detail views now won't load data again if it is being navigated to from a list item
|
||||
11
.changeset/cold-squids-remain.md
Normal file
11
.changeset/cold-squids-remain.md
Normal file
@@ -0,0 +1,11 @@
|
||||
---
|
||||
'@openstapps/app': patch
|
||||
---
|
||||
|
||||
Refactored Opening Hours
|
||||
|
||||
- Migrated Opening Hours to use OnPush change detection
|
||||
- Fixed a bug where opening hours would not update correctly
|
||||
- Lazy-load opening hours module to keep it out of the main bundle
|
||||
- Added e2e tests to verify functionality
|
||||
- Changed live update status to show exact minutes starting one hour before the next change
|
||||
5
.changeset/fair-colts-explain.md
Normal file
5
.changeset/fair-colts-explain.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@openstapps/app': patch
|
||||
---
|
||||
|
||||
Use observable chains instead of change detection in the rating component
|
||||
5
.changeset/fluffy-lamps-count.md
Normal file
5
.changeset/fluffy-lamps-count.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@openstapps/app': minor
|
||||
---
|
||||
|
||||
Added the ability to remove and add date series from their detail page
|
||||
5
.changeset/forty-eagles-cough.md
Normal file
5
.changeset/forty-eagles-cough.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@openstapps/app': patch
|
||||
---
|
||||
|
||||
Add a way to hide action chips on list items
|
||||
5
.changeset/orange-knives-happen.md
Normal file
5
.changeset/orange-knives-happen.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@openstapps/app': minor
|
||||
---
|
||||
|
||||
Add directions to inPlace and place list items
|
||||
9
.changeset/pink-sheep-relax.md
Normal file
9
.changeset/pink-sheep-relax.md
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
'@openstapps/app': minor
|
||||
---
|
||||
|
||||
Improved calendar descriptions
|
||||
|
||||
- The dashboard quick link now has a more intuitive icon
|
||||
- "Recurring" has been renamed to "Week Overview"
|
||||
- Long words in calendar tabs will now break instead of overflowing
|
||||
@@ -14,7 +14,6 @@
|
||||
"@openstapps/minimal-deployment": "2.0.0",
|
||||
"@openstapps/minimal-plugin": "2.0.0",
|
||||
"@openstapps/app": "2.0.0",
|
||||
"@openstapps/app-release-template": "2.0.0",
|
||||
"@openstapps/api": "2.0.0",
|
||||
"@openstapps/api-cli": "2.0.0",
|
||||
"@openstapps/api-plugin": "2.0.0",
|
||||
@@ -24,9 +23,13 @@
|
||||
"@openstapps/easy-ast": "2.0.0",
|
||||
"@openstapps/es-mapping-generator": "2.0.0",
|
||||
"@openstapps/gitlab-api": "2.0.0",
|
||||
"@openstapps/logger": "2.0.0"
|
||||
"@openstapps/logger": "2.0.0",
|
||||
"@openstapps/app-builder-image": "3.0.0-next.3",
|
||||
"@openstapps/node-base": "3.0.0-next.3",
|
||||
"@openstapps/node-builder": "3.0.0-next.3"
|
||||
},
|
||||
"changesets": [
|
||||
"bright-dryers-act",
|
||||
"cool-jars-kiss",
|
||||
"cuddly-bobcats-roll",
|
||||
"dull-news-appear",
|
||||
@@ -40,9 +43,14 @@
|
||||
"moody-parrots-develop",
|
||||
"neat-hats-trade",
|
||||
"new-pianos-joke",
|
||||
"pretty-timers-complain",
|
||||
"proud-wolves-end",
|
||||
"quick-houses-count",
|
||||
"rare-squids-bake",
|
||||
"serious-meals-sin",
|
||||
"silent-maps-float",
|
||||
"silly-news-punch",
|
||||
"smart-ghosts-shout",
|
||||
"soft-donuts-fail",
|
||||
"sour-coins-visit",
|
||||
"spicy-snails-sort",
|
||||
@@ -51,6 +59,7 @@
|
||||
"tall-ducks-dream",
|
||||
"tame-mayflies-hug",
|
||||
"tame-rings-dream",
|
||||
"tasty-islands-smell",
|
||||
"thick-weeks-compete",
|
||||
"thin-camels-give",
|
||||
"tidy-buses-reflect",
|
||||
|
||||
13
.changeset/pretty-wombats-double.md
Normal file
13
.changeset/pretty-wombats-double.md
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
'@openstapps/app': minor
|
||||
---
|
||||
|
||||
Revamp "My Courses" section on profile page
|
||||
|
||||
The "My Courses" section on the profile page has been improved
|
||||
|
||||
- It will now show the upcoming courses for the next five days
|
||||
- The section header is now consistent with the other sections
|
||||
- The section now uses standard list items instead of the custom solution
|
||||
|
||||
Additionally, the profile page component has been cleaned up.
|
||||
8
.changeset/proud-cameras-fail.md
Normal file
8
.changeset/proud-cameras-fail.md
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
'@openstapps/app': minor
|
||||
---
|
||||
|
||||
Adjust map button and item behavior on different screen sizes
|
||||
|
||||
- Small screens will show the item without margins below the map actions
|
||||
- Large screens will show the list item on the left side
|
||||
@@ -1,7 +1,6 @@
|
||||
---
|
||||
'@openstapps/projectmanagement': patch
|
||||
'@openstapps/prettier-config': patch
|
||||
'@openstapps/app-release-template': patch
|
||||
'@openstapps/es-mapping-generator': patch
|
||||
'@openstapps/backend-config': patch
|
||||
'@openstapps/eslint-config': patch
|
||||
|
||||
5
.changeset/sour-carpets-flash.md
Normal file
5
.changeset/sour-carpets-flash.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@openstapps/app': patch
|
||||
---
|
||||
|
||||
Fixed an issue that caused double and triple loading of data detail items through the route stack service
|
||||
5
.changeset/thick-mails-peel.md
Normal file
5
.changeset/thick-mails-peel.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@openstapps/app': minor
|
||||
---
|
||||
|
||||
Map items are now native list items
|
||||
5
.changeset/tricky-garlics-hope.md
Normal file
5
.changeset/tricky-garlics-hope.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@openstapps/app': minor
|
||||
---
|
||||
|
||||
Replaced simple links with list items in date-series detail
|
||||
5
.changeset/wet-houses-provide.md
Normal file
5
.changeset/wet-houses-provide.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@openstapps/app': minor
|
||||
---
|
||||
|
||||
Use event title for date series instead of the generic date series title
|
||||
5
.changeset/wicked-cheetahs-prove.md
Normal file
5
.changeset/wicked-cheetahs-prove.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@openstapps/app': minor
|
||||
---
|
||||
|
||||
Replace moment.js with date-fns
|
||||
@@ -7,14 +7,18 @@
|
||||
# ```
|
||||
# To your pipeline.
|
||||
# https://docs.gitlab.com/ee/ci/pipelines/merge_request_pipelines.html#use-rules-to-add-jobs
|
||||
|
||||
.limit_pipelines:
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' || $CI_COMMIT_BRANCH == 'main' || $CI_COMMIT_BRANCH == 'develop'
|
||||
when: on_success
|
||||
- when: never
|
||||
|
||||
include:
|
||||
- local: /backend/backend/.gitlab-ci.yml
|
||||
- local: /frontend/app/.gitlab-ci.yml
|
||||
- local: /.gitlab/schedules.gitlab-ci.yml
|
||||
- local: /.gitlab/publishing.gitlab-ci.yml
|
||||
rules:
|
||||
- if: '$CI_COMMIT_MESSAGE =~ /ci: publish release$/'
|
||||
when: always
|
||||
|
||||
variables:
|
||||
TURBO_CACHE_BYPASS:
|
||||
@@ -28,7 +32,7 @@ variables:
|
||||
default:
|
||||
image: registry.gitlab.com/openstapps/openstapps/node-builder
|
||||
tags:
|
||||
- performance
|
||||
- saas-linux-xlarge-amd64
|
||||
interruptible: true
|
||||
before_script:
|
||||
- corepack enable
|
||||
@@ -76,13 +80,14 @@ build:
|
||||
rules: &deploy-rules
|
||||
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
|
||||
variables:
|
||||
DEPLOY_ID: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
|
||||
DEPLOY_ID: $CI_MERGE_REQUEST_IID
|
||||
- if: $CI_COMMIT_BRANCH == 'main'
|
||||
variables:
|
||||
DEPLOY_ID: production
|
||||
- if: $CI_COMMIT_BRANCH == 'develop'
|
||||
variables:
|
||||
DEPLOY_ID: staging
|
||||
- !reference [.limit_pipelines, rules]
|
||||
|
||||
stop review:
|
||||
stage: build
|
||||
@@ -121,15 +126,15 @@ unit:
|
||||
coverage_format: cobertura
|
||||
path: coverage.xml
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' || $CI_COMMIT_BRANCH == 'main' || $CI_COMMIT_BRANCH == 'develop'
|
||||
- !reference [.limit_pipelines, rules]
|
||||
|
||||
audit:
|
||||
stage: audit
|
||||
allow_failure: true
|
||||
needs: []
|
||||
script:
|
||||
- pnpm audit --prod
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' || $CI_COMMIT_BRANCH == 'develop'
|
||||
allow_failure: true
|
||||
- if: $CI_COMMIT_BRANCH == 'main'
|
||||
allow_failure: false
|
||||
- !reference [.limit_pipelines, rules]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.limit_publishing:
|
||||
- if: $CI_PIPELINE_SOURCE != "schedule"
|
||||
when: on_success
|
||||
.limit_publish_pipelines:
|
||||
rules:
|
||||
- if: '($CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "develop") && $CI_COMMIT_MESSAGE =~ /ci: publish release/ && $CI_PIPELINE_SOURCE != "schedule"'
|
||||
|
||||
deploy:
|
||||
stage: publish
|
||||
@@ -12,7 +12,8 @@ deploy:
|
||||
paths:
|
||||
- ./.deploy
|
||||
- ./frontend/app/www
|
||||
rules: !reference [.limit_publishing]
|
||||
rules:
|
||||
- !reference [.limit_publish_pipelines, rules]
|
||||
|
||||
publish image:
|
||||
stage: publish
|
||||
@@ -23,14 +24,15 @@ publish image:
|
||||
image:
|
||||
name: gcr.io/kaniko-project/executor:v1.12.1-debug
|
||||
entrypoint: [""]
|
||||
variables:
|
||||
PUBLISH_TAG: next
|
||||
script:
|
||||
- >
|
||||
/kaniko/executor
|
||||
--context "${CI_PROJECT_DIR}/${DEPLOY_DIR}"
|
||||
--dockerfile "${CI_PROJECT_DIR}/${DEPLOY_DIR}/Dockerfile"
|
||||
--destination "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:$(grep -o '"version": "[^"]*' "${DEPLOY_DIR}/package.json" | cut -d'"' -f4)"
|
||||
--destination "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:latest"
|
||||
rules: !reference [.limit_publishing]
|
||||
--destination "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${PUBLISH_TAG}"
|
||||
parallel:
|
||||
matrix:
|
||||
- IMAGE_NAME: database
|
||||
@@ -47,6 +49,11 @@ publish image:
|
||||
DEPLOY_DIR: .deploy/minimal-plugin
|
||||
- IMAGE_NAME: app
|
||||
DEPLOY_DIR: frontend/app
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == 'main'
|
||||
variables:
|
||||
PUBLISH_TAG: latest
|
||||
- !reference [.limit_publish_pipelines, rules]
|
||||
|
||||
publish packages:
|
||||
stage: publish
|
||||
@@ -54,18 +61,17 @@ publish packages:
|
||||
variables:
|
||||
GIT_STRATEGY: clone
|
||||
GIT_DEPTH: 0
|
||||
PUBLISH_TAG: next
|
||||
script:
|
||||
- pnpm install
|
||||
- pnpm build
|
||||
- pnpm publish -r --publish-branch ${PUBLISH_BRANCH} --tag ${PUBLISH_TAG} --no-git-checks # TODO: Git checks...
|
||||
- pnpm config set '//registry.npmjs.org/:_authToken' "${NPM_AUTH_TOKEN}"
|
||||
- pnpm publish -r --publish-branch ${CI_COMMIT_BRANCH} --tag ${PUBLISH_TAG} --no-git-checks # TODO: Git checks...
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == 'main'
|
||||
variables:
|
||||
PUBLISH_BRANCH: main
|
||||
PUBLISH_TAG: latest
|
||||
- variables:
|
||||
PUBLISH_BRANCH: $CI_COMMIT_BRANCH
|
||||
PUBLISH_TAG: next
|
||||
- !reference [.limit_publish_pipelines, rules]
|
||||
|
||||
publish docs:
|
||||
stage: publish
|
||||
@@ -77,3 +83,6 @@ publish docs:
|
||||
artifacts:
|
||||
paths:
|
||||
- public
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == 'main'
|
||||
- !reference [.limit_publish_pipelines, rules]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.limit_base_image_publishing:
|
||||
- if: $CI_PIPELINE_SOURCE == "schedule" && $CI_COMMIT_BRANCH == 'main'
|
||||
when: always
|
||||
.limit_scheduled_pipelines:
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == 'main' && $CI_PIPELINE_SOURCE == "schedule"
|
||||
|
||||
base image:
|
||||
image: docker
|
||||
@@ -18,10 +18,9 @@ base image:
|
||||
docker build
|
||||
-t "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:$(grep -o '"version": "[^"]*' "${DEPLOY_DIR}/package.json" | cut -d'"' -f4)"
|
||||
-t "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:latest" "${CI_PROJECT_DIR}/${DEPLOY_DIR}" &&
|
||||
docker push "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}"
|
||||
docker push "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}" --all-tags
|
||||
cache: {} # disable irrelevant cache for this job
|
||||
before_script: [] # do not run irrelevant before script for this job
|
||||
rules: !reference [.limit_base_image_publishing]
|
||||
parallel:
|
||||
matrix:
|
||||
- IMAGE_NAME: node-base
|
||||
@@ -30,4 +29,7 @@ base image:
|
||||
DEPLOY_DIR: images/node-builder
|
||||
- IMAGE_NAME: app-builder
|
||||
DEPLOY_DIR: images/app-builder
|
||||
|
||||
- IMAGE_NAME: app-cypress
|
||||
DEPLOY_DIR: images/app-cypress
|
||||
rules:
|
||||
- !reference [.limit_scheduled_pipelines, rules]
|
||||
@@ -19,4 +19,4 @@ integration:
|
||||
junit:
|
||||
- backend/backend/coverage/integration-report-junit.xml
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' || $CI_COMMIT_BRANCH == 'main' || $CI_COMMIT_BRANCH == 'develop'
|
||||
- !reference [.limit_pipelines, rules]
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
# @openstapps/backend
|
||||
|
||||
## 3.0.0-next.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 23481d0d: Update to TypeScript 5.1.6
|
||||
- Updated dependencies [23481d0d]
|
||||
- @openstapps/core-tools@3.0.0-next.4
|
||||
- @openstapps/logger@3.0.0-next.4
|
||||
- @openstapps/core@3.0.0-next.4
|
||||
|
||||
## 3.0.0-next.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@openstapps/backend",
|
||||
"description": "A reference implementation for a StApps backend",
|
||||
"version": "3.0.0-next.0",
|
||||
"version": "3.0.0-next.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"license": "AGPL-3.0-only",
|
||||
|
||||
7
backend/database/CHANGELOG.md
Normal file
7
backend/database/CHANGELOG.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# @openstapps/database
|
||||
|
||||
## 3.0.0-next.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 23481d0d: Update to TypeScript 5.1.6
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@openstapps/database",
|
||||
"version": "2.0.0",
|
||||
"version": "3.0.0-next.4",
|
||||
"private": true,
|
||||
"files": [
|
||||
"config",
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# @openstapps/proxy
|
||||
|
||||
## 3.0.0-next.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 23481d0d: Update to TypeScript 5.1.6
|
||||
- Updated dependencies [23481d0d]
|
||||
- @openstapps/logger@3.0.0-next.4
|
||||
|
||||
## 3.0.0-next.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@openstapps/proxy",
|
||||
"description": "NGINX proxy that is dynamically configured by a Node.js script",
|
||||
"version": "3.0.0-next.0",
|
||||
"version": "3.0.0-next.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"license": "AGPL-3.0-only",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @openstapps/backend-config
|
||||
|
||||
## 3.0.0-next.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 23481d0d: Update to TypeScript 5.1.6
|
||||
|
||||
## 3.0.0-next.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@openstapps/backend-config",
|
||||
"description": "Backend Configuration for OpenStApps",
|
||||
"version": "3.0.0-next.0",
|
||||
"version": "3.0.0-next.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"license": "GPL-3.0-only",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @openstapps/eslint-config
|
||||
|
||||
## 3.0.0-next.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 23481d0d: Update to TypeScript 5.1.6
|
||||
|
||||
## 3.0.0-next.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@openstapps/eslint-config",
|
||||
"description": "A collection of configuration base files for StApps projects. Just an (unused) experiment for now.",
|
||||
"version": "3.0.0-next.0",
|
||||
"version": "3.0.0-next.4",
|
||||
"type": "commonjs",
|
||||
"license": "GPL-3.0-only",
|
||||
"repository": "git@gitlab.com:openstapps/eslint-config.git",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @openstapps/prettier-config
|
||||
|
||||
## 3.0.0-next.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 23481d0d: Update to TypeScript 5.1.6
|
||||
|
||||
## 3.0.0-next.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@openstapps/prettier-config",
|
||||
"description": "StApps Prettier Config",
|
||||
"version": "3.0.0-next.0",
|
||||
"version": "3.0.0-next.4",
|
||||
"type": "module",
|
||||
"license": "GPL-3.0-only",
|
||||
"repository": "git@gitlab.com:openstapps/prettier-config.git",
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# @openstapps/projectmanagement
|
||||
|
||||
## 3.0.0-next.4
|
||||
|
||||
### Major Changes
|
||||
|
||||
- 11c9d742: Move images to separate packages
|
||||
|
||||
Removed builder image due to migration to Kaniko
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 4e4c7b5c: Update release configs
|
||||
- 23481d0d: Update to TypeScript 5.1.6
|
||||
- Updated dependencies [23481d0d]
|
||||
- @openstapps/collection-utils@3.0.0-next.4
|
||||
- @openstapps/gitlab-api@3.0.0-next.4
|
||||
- @openstapps/logger@3.0.0-next.4
|
||||
|
||||
## 3.0.0-next.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@openstapps/projectmanagement",
|
||||
"description": "Main documentation and scripts for maintenance.",
|
||||
"version": "3.0.0-next.3",
|
||||
"version": "3.0.0-next.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"license": "GPL-3.0-only",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @openstapps/tsconfig
|
||||
|
||||
## 3.0.0-next.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 23481d0d: Update to TypeScript 5.1.6
|
||||
|
||||
## 3.0.0-next.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@openstapps/tsconfig",
|
||||
"description": "The tsconfig for the openstapps project",
|
||||
"version": "3.0.0-next.0",
|
||||
"version": "3.0.0-next.4",
|
||||
"type": "commonjs",
|
||||
"license": "GPL-3.0-only",
|
||||
"repository": "git@gitlab.com:openstapps/eslint-config.git",
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
# @openstapps/minimal-connector
|
||||
|
||||
## 3.0.0-next.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 23481d0d: Update to TypeScript 5.1.6
|
||||
- Updated dependencies [23481d0d]
|
||||
- @openstapps/logger@3.0.0-next.4
|
||||
- @openstapps/core@3.0.0-next.4
|
||||
- @openstapps/api@3.0.0-next.4
|
||||
|
||||
## 3.0.0-next.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@openstapps/minimal-connector",
|
||||
"description": "This is a minimal connector which serves as an example",
|
||||
"version": "3.0.0-next.0",
|
||||
"version": "3.0.0-next.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"license": "GPL-3.0-only",
|
||||
|
||||
7
examples/minimal-deployment/CHANGELOG.md
Normal file
7
examples/minimal-deployment/CHANGELOG.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# @openstapps/minimal-deployment
|
||||
|
||||
## 3.0.0-next.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 23481d0d: Update to TypeScript 5.1.6
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@openstapps/minimal-deployment",
|
||||
"version": "2.0.0",
|
||||
"version": "3.0.0-next.4",
|
||||
"private": true,
|
||||
"files": [
|
||||
"database",
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
# @openstapps/minimal-plugin
|
||||
|
||||
## 3.0.0-next.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 23481d0d: Update to TypeScript 5.1.6
|
||||
- Updated dependencies [23481d0d]
|
||||
- @openstapps/api-plugin@3.0.0-next.4
|
||||
- @openstapps/core-tools@3.0.0-next.4
|
||||
- @openstapps/logger@3.0.0-next.4
|
||||
- @openstapps/core@3.0.0-next.4
|
||||
- @openstapps/api@3.0.0-next.4
|
||||
|
||||
## 3.0.0-next.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@openstapps/minimal-plugin",
|
||||
"description": "Minimal Plugin",
|
||||
"version": "3.0.0-next.0",
|
||||
"version": "3.0.0-next.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"license": "GPL-3.0-only",
|
||||
|
||||
@@ -15,8 +15,12 @@
|
||||
buildToolsVersions = [ "${buildToolsVersion}" ];
|
||||
platformVersions = [ "32" ];
|
||||
};
|
||||
cypress = prev.cypress.overrideAttrs(prev: {
|
||||
version = "12.17.1";
|
||||
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=";
|
||||
};
|
||||
});
|
||||
})
|
||||
];
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2020,
|
||||
"sourceType": "module",
|
||||
"project": ["tsconfig.json", "tsconfig.spec.json", "e2e/tsconfig.e2e.json"],
|
||||
"project": ["tsconfig.json", "tsconfig.spec.json", "cypress/tsconfig.json"],
|
||||
"createDefaultProgram": true
|
||||
},
|
||||
"extends": [
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
e2e:
|
||||
image: cypress/browsers:latest # https://hub.docker.com/r/cypress/browsers/tags/
|
||||
image: registry.gitlab.com/openstapps/openstapps/app-cypress:node-18
|
||||
stage: test
|
||||
script:
|
||||
- pnpm --filter=@openstapps/app install
|
||||
- pnpm --filter=@openstapps/app exec cypress install
|
||||
- cd node_modules/.pnpm/re2*/node_modules/re2
|
||||
- npm run install
|
||||
- cd $CI_PROJECT_DIR
|
||||
- pnpm test:integration:app
|
||||
artifacts:
|
||||
when: on_failure
|
||||
@@ -19,4 +22,4 @@ e2e:
|
||||
- BROWSER: chrome
|
||||
- BROWSER: firefox
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' || $CI_COMMIT_BRANCH == 'main' || $CI_COMMIT_BRANCH == 'develop'
|
||||
- !reference [.limit_pipelines, rules]
|
||||
|
||||
@@ -1,5 +1,29 @@
|
||||
# @openstapps/app
|
||||
|
||||
## 3.0.0-next.4
|
||||
|
||||
### Major Changes
|
||||
|
||||
- 23481d0d: Update to Angular 16.1
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 23481d0d: Migrate to Ionic 7
|
||||
|
||||
- Migrate uses of `<ion-label>` with inputs to new syntax
|
||||
- Fix infinite loop in schedule date picker (`datetime.confirm()` to `datetime.cancel()`)
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 23481d0d: Update to TypeScript 5.1.6
|
||||
- bebee6b4: Migrate collection helpers to use @openstapps/collection-utils
|
||||
- 107a7c5e: Migrate unit tests to karma-coverage and junit reports.
|
||||
Fixes an issue where coverage reports would not be generated.
|
||||
- Updated dependencies [23481d0d]
|
||||
- @openstapps/collection-utils@3.0.0-next.4
|
||||
- @openstapps/core@3.0.0-next.4
|
||||
- @openstapps/api@3.0.0-next.4
|
||||
|
||||
## 3.0.0-next.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
@@ -42,3 +42,23 @@ The command `ionic cordova run ios` runs into the error `/platforms/ios/build/em
|
||||
|
||||
- Either use the command: `ionic cordova emulate ios -- --buildFlag="-UseModernBuildSystem=0"`
|
||||
- Or open the iOS project in Xcode and change build system in workspace settings to `Lagacy Build System`. Then the normal run command works also.
|
||||
|
||||
## Cypress
|
||||
|
||||
#### Problem
|
||||
|
||||
The browser doesn't open or the tests don't connect to a browser
|
||||
|
||||
#### Cause
|
||||
|
||||
Cypress was installed to a read-only location, see
|
||||
[this issue](https://github.com/cypress-io/cypress/issues/18893).
|
||||
This can be the case if you use NixOS.
|
||||
|
||||
#### Solution
|
||||
|
||||
Make sure the cypress folder is writable before each launch
|
||||
|
||||
```shell
|
||||
chmod -R +rw ~/.config/Cypress
|
||||
```
|
||||
|
||||
@@ -182,6 +182,7 @@
|
||||
"builder": "@cypress/schematic:cypress",
|
||||
"options": {
|
||||
"devServerTarget": "app:serve",
|
||||
"liveReload": false,
|
||||
"watch": true,
|
||||
"headless": false
|
||||
},
|
||||
|
||||
@@ -18,14 +18,18 @@
|
||||
|
||||
describe('dashboard', async function () {
|
||||
describe('schedule section', function () {
|
||||
it('should lead to the schedule', function () {
|
||||
it('should lead to the week overview', function () {
|
||||
cy.visit('/overview');
|
||||
cy.get('.schedule').contains('a', 'Stundenplan').click();
|
||||
cy.url().should('include', '/schedule/recurring');
|
||||
cy.get('.schedule')
|
||||
.contains('a', /Wochen.*übersicht/)
|
||||
.click();
|
||||
cy.url().should('include', '/schedule/week-overview');
|
||||
});
|
||||
|
||||
it('should lead to the calendar', function () {
|
||||
cy.visit('/overview');
|
||||
cy.get('.schedule').contains('a', 'Kein Eintrag gefunden').click();
|
||||
cy.url().should('include', '/schedule/recurring');
|
||||
cy.url().should('include', '/schedule/calendar');
|
||||
});
|
||||
|
||||
// TODO: Reenable and stabilize tests
|
||||
|
||||
@@ -30,14 +30,14 @@ describe('ical', function () {
|
||||
|
||||
cy.get('ion-app > ion-modal').within(() => {
|
||||
cy.get('ion-footer > ion-toolbar > ion-button').should('have.attr', 'disabled');
|
||||
cy.contains('ion-item', /19\.\s+Januar\s+2059,\s+\d{2}:00\s+-\s+\d{2}:00/).click();
|
||||
cy.contains('ion-item', /1\s+Stunde\s+Sonntag,\s+19\.\s+Januar\s+2059\s+um\s+\d{2}:00/).click();
|
||||
cy.get('ion-footer > ion-toolbar > ion-button').should('not.have.attr', 'disabled');
|
||||
cy.get('ion-footer > ion-toolbar > ion-button').click();
|
||||
});
|
||||
|
||||
cy.get('add-event-review-modal').within(() => {
|
||||
cy.get('ion-item-group').should('contain', 'UNIcert (Test)');
|
||||
cy.contains('ion-item-group', /19\.\s+Jan\.\s+2059,\s+\d{2}:00/);
|
||||
cy.contains('ion-item-group', /19\.\s+Januar\s+2059\s+um\s+\d{2}:00/);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
141
frontend/app/cypress/integration/opening-hours.spec.ts
Normal file
141
frontend/app/cypress/integration/opening-hours.spec.ts
Normal file
@@ -0,0 +1,141 @@
|
||||
describe('opening hours', () => {
|
||||
beforeEach(function () {
|
||||
cy.intercept('POST', 'https://mobile.server.uni-frankfurt.de/search', {
|
||||
fixture: 'search/types/canteen/canteen-search-result.json',
|
||||
}).as('search');
|
||||
});
|
||||
|
||||
it('should specify relative closing time', () => {
|
||||
cy.clock(new Date(2023, 9, 16, 15, 29), ['Date']);
|
||||
cy.visit('/canteen');
|
||||
|
||||
cy.get('stapps-opening-hours')
|
||||
.first()
|
||||
.should('contain', 'Geöffnet')
|
||||
.should('contain', 'Schließt heute um 22:00');
|
||||
});
|
||||
|
||||
it('should specify relative opening time', () => {
|
||||
cy.clock(new Date(2023, 9, 16, 6, 29), ['Date']);
|
||||
cy.visit('/canteen');
|
||||
|
||||
cy.get('stapps-opening-hours')
|
||||
.first()
|
||||
.should('contain', 'Geschlossen')
|
||||
.should('contain', 'Öffnet heute um 08:30');
|
||||
});
|
||||
|
||||
it('should specify soon opening time', () => {
|
||||
cy.clock(new Date(2023, 9, 16, 8, 0), ['Date']);
|
||||
cy.visit('/canteen');
|
||||
|
||||
cy.get('stapps-opening-hours')
|
||||
.first()
|
||||
.should('contain', 'Geschlossen')
|
||||
.should('contain', 'Öffnet in 30 Minuten');
|
||||
});
|
||||
|
||||
it('should specify soon closing time', () => {
|
||||
cy.clock(new Date(2023, 9, 16, 21, 30), ['Date']);
|
||||
cy.visit('/canteen');
|
||||
|
||||
cy.get('stapps-opening-hours')
|
||||
.first()
|
||||
.should('contain', 'Geöffnet')
|
||||
.should('contain', 'Schließt in 30 Minuten');
|
||||
});
|
||||
|
||||
it('should update the soon closing time every minute', () => {
|
||||
cy.clock(new Date(2023, 9, 16, 21, 30));
|
||||
cy.visit('/canteen');
|
||||
cy.tick(500);
|
||||
|
||||
cy.get('stapps-opening-hours')
|
||||
.first()
|
||||
.should('contain', 'Geöffnet')
|
||||
.should('contain', 'Schließt in 30 Minuten');
|
||||
|
||||
cy.tick(60_000);
|
||||
cy.tick(50);
|
||||
|
||||
cy.get('stapps-opening-hours')
|
||||
.first()
|
||||
.should('contain', 'Geöffnet')
|
||||
.should('contain', 'Schließt in 29 Minuten');
|
||||
});
|
||||
|
||||
it('should update the status when it changes', () => {
|
||||
cy.clock(new Date(2023, 9, 16, 21, 59));
|
||||
cy.visit('/canteen');
|
||||
cy.tick(500);
|
||||
|
||||
cy.get('stapps-opening-hours')
|
||||
.first()
|
||||
.should('contain', 'Geöffnet')
|
||||
.should('contain', 'Schließt in 1 Minute');
|
||||
|
||||
cy.tick(60_000);
|
||||
|
||||
cy.get('stapps-opening-hours')
|
||||
.first()
|
||||
.should('contain', 'Geschlossen')
|
||||
.should('contain', 'Öffnet morgen um 08:30');
|
||||
});
|
||||
|
||||
// This one takes long to execute!
|
||||
it('should update as expected', () => {
|
||||
cy.clock(new Date(2023, 9, 16, 20, 59));
|
||||
cy.visit('/canteen');
|
||||
cy.tick(500);
|
||||
|
||||
cy.get('stapps-opening-hours')
|
||||
.first()
|
||||
.should('contain', 'Geöffnet')
|
||||
.should('contain', 'Schließt heute um 22:00');
|
||||
|
||||
cy.tick(60_000);
|
||||
|
||||
cy.get('stapps-opening-hours')
|
||||
.first()
|
||||
.should('contain', 'Geöffnet')
|
||||
.should('contain', 'Schließt in 60 Minuten');
|
||||
|
||||
cy.tick(30 * 60_000);
|
||||
|
||||
cy.get('stapps-opening-hours')
|
||||
.first()
|
||||
.should('contain', 'Geöffnet')
|
||||
.should('contain', 'Schließt in 30 Minuten');
|
||||
|
||||
cy.tick(30 * 60_000);
|
||||
|
||||
cy.get('stapps-opening-hours')
|
||||
.first()
|
||||
.should('contain', 'Geschlossen')
|
||||
.should('contain', 'Öffnet morgen um 08:30');
|
||||
|
||||
cy.tick(9.5 * 60 * 60_000);
|
||||
|
||||
cy.get('stapps-opening-hours')
|
||||
.first()
|
||||
.should('contain', 'Geschlossen')
|
||||
.should('contain', 'Öffnet in 60 Minuten');
|
||||
|
||||
cy.tick(30 * 60_000);
|
||||
|
||||
cy.get('stapps-opening-hours')
|
||||
.first()
|
||||
.should('contain', 'Geschlossen')
|
||||
.should('contain', 'Öffnet in 30 Minuten');
|
||||
|
||||
cy.tick(30 * 60_000);
|
||||
|
||||
cy.get('stapps-opening-hours')
|
||||
.first()
|
||||
.should('contain', 'Geöffnet')
|
||||
.should('contain', 'Schließt heute um 22:00');
|
||||
|
||||
// Long tick warps will cause network requests to time out
|
||||
cy.get('@consoleError').invoke('resetHistory');
|
||||
});
|
||||
});
|
||||
@@ -25,7 +25,7 @@ describe('schedule', function () {
|
||||
|
||||
it('should respect the url', function () {
|
||||
cy.visit('/schedule/calendar/2022-01-19');
|
||||
cy.get('#date-select-button0').should('contain', '19.01.22');
|
||||
cy.get('#date-select-button0').should('contain', '19.01.2022');
|
||||
});
|
||||
|
||||
it('should navigate a full page', function () {
|
||||
@@ -66,13 +66,13 @@ describe('schedule', function () {
|
||||
|
||||
it('should navigate to a specific date', function () {
|
||||
cy.visit('/schedule/calendar/2059-01-19');
|
||||
cy.contains('#date-select-button0', '19.01.59').click();
|
||||
cy.contains('#date-select-button0', '19.01.2059').click();
|
||||
cy.wait(2000);
|
||||
cy.get('button[data-day=1][data-month=1][data-year=2059]', {
|
||||
includeShadowDom: true,
|
||||
}).click();
|
||||
cy.wait(2000);
|
||||
cy.contains('#date-select-button0', '01.01.59').click();
|
||||
cy.contains('#date-select-button0', '01.01.2059').click();
|
||||
});
|
||||
|
||||
// TODO: Reenable and stabilize tests
|
||||
|
||||
@@ -31,36 +31,24 @@
|
||||
// When a command from ./commands is ready to use, import with `import './commands'` syntax
|
||||
// import './commands';
|
||||
|
||||
beforeEach(async function () {
|
||||
let databases: string[];
|
||||
if (window.indexedDB.databases) {
|
||||
databases = (await window.indexedDB.databases()).map(it => it.name);
|
||||
console.log('Trying to clear all databases');
|
||||
} else {
|
||||
console.log("Browser doesn't support database enumeration, deleting just ionic storage");
|
||||
databases = ['_ionicstorage'];
|
||||
}
|
||||
for (const database of databases) {
|
||||
if (database) {
|
||||
console.log(`Deleting database ${database}`);
|
||||
await new Promise(resolve => (window.indexedDB.deleteDatabase(database).onsuccess = resolve));
|
||||
console.log(`Deleted database ${database}`);
|
||||
}
|
||||
}
|
||||
beforeEach(function () {
|
||||
cy.wrap(
|
||||
new Promise(resolve => {
|
||||
window.indexedDB.deleteDatabase('_ionicstorage').onsuccess = resolve;
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
Cypress.on('window:before:load', window => {
|
||||
// Fake that user is using its browser in german language
|
||||
// Fake that user is using its browser in German
|
||||
Object.defineProperty(window.navigator, 'language', {value: 'de-DE'});
|
||||
Object.defineProperty(window.navigator, 'languages', [{value: 'de-DE'}]);
|
||||
|
||||
// Fail tests on console error
|
||||
cy.stub(window.console, 'error').callsFake(message => {
|
||||
// log out to the terminal
|
||||
cy.now('task', 'error', message);
|
||||
// log to Command Log and fail the test
|
||||
throw new Error(message);
|
||||
});
|
||||
cy.spy(window.console, 'error').as('consoleError');
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
cy.get('@consoleError').should('not.have.been.called');
|
||||
});
|
||||
|
||||
Cypress.on('uncaught:exception', error => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@openstapps/app",
|
||||
"description": "The generic app tailored to fulfill needs of German universities, written using Ionic Framework.",
|
||||
"version": "3.0.0-next.0",
|
||||
"version": "3.0.0-next.4",
|
||||
"private": true,
|
||||
"license": "GPL-3.0-only",
|
||||
"author": "Karl-Philipp Wulfert <krlwlfrt@gmail.com>",
|
||||
@@ -15,7 +15,7 @@
|
||||
],
|
||||
"scripts": {
|
||||
"analyze": "webpack-bundle-analyzer www/stats.json",
|
||||
"build": "pnpm check-icons && ng build --configuration=production --stats-json && webpack-bundle-analyzer www/stats.json --mode static --report www/bundle-info.html",
|
||||
"build": "pnpm check-icons && ng build --configuration=production --stats-json && webpack-bundle-analyzer --no-open www/stats.json --mode static --report www/bundle-info.html",
|
||||
"build:analyze": "npm run build:stats && npm run analyze",
|
||||
"build:android": "ionic capacitor build android --no-open && cd android && ./gradlew clean assembleDebug && cd ..",
|
||||
"build:prod": "ng build --configuration=production",
|
||||
@@ -63,6 +63,7 @@
|
||||
"@awesome-cordova-plugins/core": "5.45.0",
|
||||
"@capacitor/app": "4.1.1",
|
||||
"@capacitor/browser": "4.1.0",
|
||||
"@capacitor/clipboard": "4.1.0",
|
||||
"@capacitor/core": "4.6.1",
|
||||
"@capacitor/device": "4.1.0",
|
||||
"@capacitor/dialog": "4.1.0",
|
||||
@@ -84,11 +85,14 @@
|
||||
"@ngx-translate/http-loader": "8.0.0",
|
||||
"@openid/appauth": "1.3.1",
|
||||
"@openstapps/api": "workspace:*",
|
||||
"@openstapps/core": "workspace:*",
|
||||
"@openstapps/collection-utils": "workspace:*",
|
||||
"@openstapps/core": "workspace:*",
|
||||
"@transistorsoft/capacitor-background-fetch": "1.0.2",
|
||||
"@types/dom-view-transitions": "1.0.1",
|
||||
"capacitor-secure-storage-plugin": "0.8.1",
|
||||
"cordova-plugin-calendar": "5.1.6",
|
||||
"date-fns": "2.30.0",
|
||||
"duration-fns": "3.0.2",
|
||||
"deepmerge": "4.3.1",
|
||||
"form-data": "4.0.0",
|
||||
"geojson": "0.5.0",
|
||||
@@ -97,10 +101,9 @@
|
||||
"leaflet": "1.9.3",
|
||||
"leaflet.markercluster": "1.5.3",
|
||||
"material-symbols": "0.10.0",
|
||||
"moment": "2.29.4",
|
||||
"ngx-date-fns": "10.0.1",
|
||||
"ngx-logger": "5.0.12",
|
||||
"ngx-markdown": "16.0.0",
|
||||
"ngx-moment": "6.0.2",
|
||||
"opening_hours": "3.8.0",
|
||||
"rxjs": "7.8.1",
|
||||
"swiper": "8.4.5",
|
||||
@@ -146,7 +149,7 @@
|
||||
"@typescript-eslint/eslint-plugin": "5.60.1",
|
||||
"@typescript-eslint/parser": "5.60.1",
|
||||
"cordova-res": "0.15.4",
|
||||
"cypress": "12.17.1",
|
||||
"cypress": "13.2.0",
|
||||
"eslint": "8.43.0",
|
||||
"eslint-plugin-jsdoc": "46.4.2",
|
||||
"eslint-plugin-prettier": "4.2.1",
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
/* eslint-disable */
|
||||
|
||||
import moment from 'moment';
|
||||
import {addDays, endOfToday, formatISO, startOfToday} from 'date-fns';
|
||||
|
||||
export const sampleResources = [
|
||||
{
|
||||
@@ -793,8 +793,8 @@ export const sampleResources = [
|
||||
offers: [
|
||||
{
|
||||
availability: 'in stock',
|
||||
availabilityStarts: moment().startOf('day').add(2, 'days').toISOString(),
|
||||
availabilityEnds: moment().endOf('day').add(2, 'days').toISOString(),
|
||||
availabilityStarts: formatISO(addDays(startOfToday(), 2)),
|
||||
availabilityEnds: formatISO(addDays(endOfToday(), 2)),
|
||||
prices: {
|
||||
default: 6.5,
|
||||
student: 5,
|
||||
@@ -904,8 +904,8 @@ export const sampleResources = [
|
||||
offers: [
|
||||
{
|
||||
availability: 'in stock',
|
||||
availabilityStarts: moment().startOf('day').toISOString(),
|
||||
availabilityEnds: moment().endOf('day').add(2, 'days').toISOString(),
|
||||
availabilityStarts: formatISO(startOfToday()),
|
||||
availabilityEnds: formatISO(addDays(endOfToday(), 2)),
|
||||
prices: {
|
||||
default: 4.85,
|
||||
student: 2.85,
|
||||
@@ -984,8 +984,8 @@ export const sampleResources = [
|
||||
uid: '3b9b3df6-3a7a-58cc-922f-c7335c002634',
|
||||
},
|
||||
availability: 'in stock',
|
||||
availabilityStarts: moment().startOf('day').add(2, 'days').toISOString(),
|
||||
availabilityEnds: moment().endOf('day').add(2, 'days').toISOString(),
|
||||
availabilityStarts: formatISO(addDays(startOfToday(), 2)),
|
||||
availabilityEnds: formatISO(addDays(endOfToday(), 2)),
|
||||
inPlace: {
|
||||
geo: {
|
||||
point: {
|
||||
@@ -1046,8 +1046,8 @@ export const sampleResources = [
|
||||
],
|
||||
offers: [
|
||||
{
|
||||
availabilityEnds: moment().endOf('day').toISOString(),
|
||||
availabilityStarts: moment().startOf('day').toISOString(),
|
||||
availabilityEnds: formatISO(endOfToday()),
|
||||
availabilityStarts: formatISO(startOfToday()),
|
||||
availability: 'in stock',
|
||||
inPlace: {
|
||||
type: 'room',
|
||||
|
||||
@@ -21,11 +21,8 @@ import {RouteReuseStrategy} from '@angular/router';
|
||||
import {IonicModule, IonicRouteStrategy, Platform} from '@ionic/angular';
|
||||
import {TranslateLoader, TranslateModule, TranslateService} from '@ngx-translate/core';
|
||||
import {TranslateHttpLoader} from '@ngx-translate/http-loader';
|
||||
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';
|
||||
@@ -58,12 +55,15 @@ import {StorageProvider} from './modules/storage/storage.provider';
|
||||
import {AssessmentsModule} from './modules/assessments/assessments.module';
|
||||
import {ServiceHandlerInterceptor} from './_helpers/service-handler.interceptor';
|
||||
import {RoutingStackService} from './util/routing-stack.service';
|
||||
import {SCSettingValue} from '@openstapps/core';
|
||||
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, DateFnsModule} from 'ngx-date-fns';
|
||||
|
||||
registerLocaleData(localeDe);
|
||||
|
||||
@@ -71,12 +71,6 @@ SwiperCore.use([FreeMode, Navigation]);
|
||||
|
||||
/**
|
||||
* Initializes data needed on startup
|
||||
* @param storageProvider provider of the saved data (using framework's storage)
|
||||
* @param logger TODO
|
||||
* @param settingsProvider provider of settings (e.g. language that has been set)
|
||||
* @param configProvider TODO
|
||||
* @param translateService TODO
|
||||
* @param _routingStackService Just for init and to track the stack from the get go
|
||||
*/
|
||||
export function initializerFactory(
|
||||
storageProvider: StorageProvider,
|
||||
@@ -87,6 +81,7 @@ export function initializerFactory(
|
||||
_routingStackService: RoutingStackService,
|
||||
defaultAuthService: DefaultAuthService,
|
||||
paiaAuthService: PAIAAuthService,
|
||||
dateFnsConfigurationService: DateFnsConfigurationService,
|
||||
) {
|
||||
return async () => {
|
||||
initLogger(logger);
|
||||
@@ -106,7 +101,10 @@ export function initializerFactory(
|
||||
// this language will be used as a fallback when a translation isn't found in the current language
|
||||
translateService.setDefaultLang('en');
|
||||
translateService.use(languageCode);
|
||||
moment.locale(languageCode);
|
||||
const dateFnsLocale = await getDateFnsLocale(languageCode as SCLanguageCode, translateService);
|
||||
setDefaultOptions({locale: dateFnsLocale});
|
||||
dateFnsConfigurationService.setLocale(dateFnsLocale);
|
||||
|
||||
await defaultAuthService.init();
|
||||
await paiaAuthService.init();
|
||||
} catch (error) {
|
||||
@@ -142,6 +140,7 @@ export function createTranslateLoader(http: HttpClient) {
|
||||
ConfigModule,
|
||||
DashboardModule,
|
||||
DataModule,
|
||||
DateFnsModule.forRoot(),
|
||||
HebisModule,
|
||||
IonicModule.forRoot(),
|
||||
IonIconModule,
|
||||
@@ -198,6 +197,7 @@ export function createTranslateLoader(http: HttpClient) {
|
||||
RoutingStackService,
|
||||
DefaultAuthService,
|
||||
PAIAAuthService,
|
||||
DateFnsConfigurationService,
|
||||
],
|
||||
useFactory: initializerFactory,
|
||||
},
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
* 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 {AssessmentListItemComponent} from './types/assessment/assessment-list-item.component';
|
||||
import {AssessmentBaseInfoComponent} from './types/assessment/assessment-base-info.component';
|
||||
@@ -27,7 +26,6 @@ import {CourseOfStudyAssessmentComponent} from './types/course-of-study/course-o
|
||||
import {AssessmentsPageComponent} from './page/assessments-page.component';
|
||||
import {RouterModule} from '@angular/router';
|
||||
import {AuthGuardService} from '../auth/auth-guard.service';
|
||||
import {MomentModule} from 'ngx-moment';
|
||||
import {AssessmentsListItemComponent} from './list/assessments-list-item.component';
|
||||
import {AssessmentsDataListComponent} from './list/assessments-data-list.component';
|
||||
import {AssessmentsDetailComponent} from './detail/assessments-detail.component';
|
||||
@@ -37,6 +35,7 @@ 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';
|
||||
import {FormatPurePipeModule, ParseIsoPipeModule} from 'ngx-date-fns';
|
||||
|
||||
const routes: ProtectedRoutes = [
|
||||
{
|
||||
@@ -75,8 +74,9 @@ const routes: ProtectedRoutes = [
|
||||
TranslateModule,
|
||||
DataModule,
|
||||
ThingTranslateModule,
|
||||
MomentModule,
|
||||
UtilModule,
|
||||
ParseIsoPipeModule,
|
||||
FormatPurePipeModule,
|
||||
],
|
||||
providers: [AssessmentsProvider],
|
||||
exports: [],
|
||||
|
||||
@@ -17,7 +17,7 @@ import {Component, DestroyRef, inject, Input, OnInit, ViewChild} from '@angular/
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {AssessmentsProvider} from '../assessments.provider';
|
||||
import {DataDetailComponent, ExternalDataLoadEvent} from '../../data/detail/data-detail.component';
|
||||
import {NavController, ViewWillEnter} from '@ionic/angular';
|
||||
import {NavController} from '@ionic/angular';
|
||||
import {DataRoutingService} from '../../data/data-routing.service';
|
||||
import {SCAssessment} from '@openstapps/core';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
@@ -27,7 +27,7 @@ import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
templateUrl: 'assessments-detail.html',
|
||||
styleUrls: ['assessments-detail.scss'],
|
||||
})
|
||||
export class AssessmentsDetailComponent implements ViewWillEnter, OnInit {
|
||||
export class AssessmentsDetailComponent implements OnInit {
|
||||
destroy$ = inject(DestroyRef);
|
||||
|
||||
constructor(
|
||||
@@ -67,8 +67,4 @@ export class AssessmentsDetailComponent implements ViewWillEnter, OnInit {
|
||||
event.resolve(this.item);
|
||||
});
|
||||
}
|
||||
|
||||
async ionViewWillEnter() {
|
||||
await this.detailComponent.ionViewWillEnter();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ export class AssessmentsSimpleDataListComponent implements OnInit {
|
||||
queryParams: {
|
||||
token: this.activatedRoute.snapshot.queryParamMap.get('token'),
|
||||
},
|
||||
state: {item: thing},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@ export class AssessmentsPageComponent implements OnInit, AfterViewInit {
|
||||
queryParams: {
|
||||
token: this.activatedRoute.snapshot.queryParamMap.get('token'),
|
||||
},
|
||||
state: {item: thing},
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
-->
|
||||
|
||||
<div class="container">
|
||||
<h2 class="name">{{ 'name' | thingTranslate : item }} {{ item.date ? (item.date | amDateFormat) : '' }}</h2>
|
||||
<h2 class="name">
|
||||
{{ 'name' | thingTranslate : item }} {{ item.date ? (item.date | dfnsParseIso | dfnsFormatPure : 'Pp') :
|
||||
'' }}
|
||||
</h2>
|
||||
<assessment-base-info [item]="item"></assessment-base-info>
|
||||
</div>
|
||||
|
||||
@@ -12,10 +12,8 @@
|
||||
* 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 {ScheduleSyncService} from './schedule/schedule-sync.service';
|
||||
import {DateFormatPipe, DurationPipe} from 'ngx-moment';
|
||||
import {CalendarModule} from '../calendar/calendar.module';
|
||||
import {ScheduleProvider} from '../calendar/schedule.provider';
|
||||
import {StorageProvider} from '../storage/storage.provider';
|
||||
@@ -27,13 +25,6 @@ import {CalendarService} from '../calendar/calendar.service';
|
||||
@NgModule({
|
||||
declarations: [],
|
||||
imports: [CalendarModule],
|
||||
providers: [
|
||||
DurationPipe,
|
||||
DateFormatPipe,
|
||||
ScheduleProvider,
|
||||
StorageProvider,
|
||||
CalendarService,
|
||||
ScheduleSyncService,
|
||||
],
|
||||
providers: [ScheduleProvider, StorageProvider, CalendarService, ScheduleSyncService],
|
||||
})
|
||||
export class BackgroundModule {}
|
||||
|
||||
@@ -22,7 +22,6 @@ import {
|
||||
import {SCDateSeries, SCThingType, SCUuid} from '@openstapps/core';
|
||||
import {LocalNotifications} from '@capacitor/local-notifications';
|
||||
import {ThingTranslateService} from '../../../translation/thing-translate.service';
|
||||
import {DateFormatPipe, DurationPipe} from 'ngx-moment';
|
||||
import {BackgroundFetch} from '@transistorsoft/capacitor-background-fetch';
|
||||
import {StorageProvider} from '../../storage/storage.provider';
|
||||
import {CalendarService} from '../../calendar/calendar.service';
|
||||
@@ -46,8 +45,6 @@ export class ScheduleSyncService {
|
||||
private scheduleProvider: ScheduleProvider,
|
||||
private storageProvider: StorageProvider,
|
||||
private translator: ThingTranslateService,
|
||||
private dateFormatPipe: DateFormatPipe,
|
||||
private durationFormatPipe: DurationPipe,
|
||||
private calendar: CalendarService,
|
||||
) {}
|
||||
|
||||
@@ -136,11 +133,7 @@ export class ScheduleSyncService {
|
||||
change =>
|
||||
`${
|
||||
this.translator.translator.translatedPropertyNames<SCDateSeries>(SCThingType.DateSeries)?.[change]
|
||||
}: ${formatRelevantKeys[change](
|
||||
changes.new[change] as never,
|
||||
this.dateFormatPipe,
|
||||
this.durationFormatPipe,
|
||||
)}`,
|
||||
}: ${formatRelevantKeys[change](changes.new[change] as never)}`,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import {
|
||||
toICal,
|
||||
toICalUpdates,
|
||||
} from './ical/ical';
|
||||
import moment from 'moment';
|
||||
import {Share} from '@capacitor/share';
|
||||
import {Directory, Encoding, Filesystem} from '@capacitor/filesystem';
|
||||
import {Device} from '@capacitor/device';
|
||||
@@ -44,8 +43,6 @@ interface ICalInfo {
|
||||
styleUrls: ['add-event-review-modal.scss'],
|
||||
})
|
||||
export class AddEventReviewModalComponent implements OnInit {
|
||||
moment = moment;
|
||||
|
||||
@Input() dismissAction: () => void;
|
||||
|
||||
@Input() dateSeries: SCDateSeries[];
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<s *ngIf="iCalEvent.cancelled; else date"
|
||||
><ng-container [ngTemplateOutlet]="date"></ng-container>
|
||||
</s>
|
||||
<ng-template #date> {{ moment(iCalEvent.start) | amDateFormat : 'll, HH:mm' }} </ng-template>
|
||||
<ng-template #date> {{ iCalEvent.start | dfnsParseIso | dfnsFormatPure : 'PPPp' }} </ng-template>
|
||||
</ion-label>
|
||||
<ion-note *ngIf="iCalEvent.rrule">
|
||||
{{ iCalEvent.rrule.interval }} {{ iCalEvent.rrule.freq | sentencecase }}
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
* 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 {AddEventReviewModalComponent} from './add-event-review-modal.component';
|
||||
import {Calendar} from '@awesome-cordova-plugins/calendar/ngx';
|
||||
@@ -23,9 +22,9 @@ import {TranslateModule} from '@ngx-translate/core';
|
||||
import {ThingTranslateModule} from '../../translation/thing-translate.module';
|
||||
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';
|
||||
import {FormatPurePipeModule, ParseIsoPipeModule} from 'ngx-date-fns';
|
||||
|
||||
@NgModule({
|
||||
declarations: [AddEventReviewModalComponent],
|
||||
@@ -36,8 +35,9 @@ import {IonIconModule} from '../../util/ion-icon/ion-icon.module';
|
||||
IonIconModule,
|
||||
FormsModule,
|
||||
CommonModule,
|
||||
MomentModule,
|
||||
UtilModule,
|
||||
ParseIsoPipeModule,
|
||||
FormatPurePipeModule,
|
||||
],
|
||||
exports: [],
|
||||
providers: [Calendar, CalendarService, ScheduleProvider],
|
||||
|
||||
@@ -16,17 +16,18 @@
|
||||
import {Calendar} from '@awesome-cordova-plugins/calendar/ngx';
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ICalEvent} from './ical/ical';
|
||||
import moment, {duration, Moment, unitOfTime} from 'moment';
|
||||
import {Dialog} from '@capacitor/dialog';
|
||||
import {CalendarInfo} from './calendar-info';
|
||||
import {Subject} from 'rxjs';
|
||||
import {ConfigProvider} from '../config/config.provider';
|
||||
import {add, differenceInDays, parseISO, startOfToday} from 'date-fns';
|
||||
import {parse as parseISODuration} from 'duration-fns';
|
||||
|
||||
const RECURRENCE_PATTERNS: Partial<Record<unitOfTime.Diff, string | undefined>> = {
|
||||
year: 'yearly',
|
||||
month: 'monthly',
|
||||
week: 'weekly',
|
||||
day: 'daily',
|
||||
const RECURRENCE_PATTERNS: Partial<Record<keyof Duration, string | undefined>> = {
|
||||
years: 'yearly',
|
||||
months: 'monthly',
|
||||
weeks: 'weekly',
|
||||
days: 'daily',
|
||||
};
|
||||
|
||||
@Injectable()
|
||||
@@ -85,7 +86,7 @@ export class CalendarService {
|
||||
iCalEvent.geo,
|
||||
iCalEvent.description,
|
||||
new Date(start),
|
||||
moment(start).add(duration(iCalEvent.duration)).toDate(),
|
||||
add(parseISO(start), parseISODuration(iCalEvent.duration!)),
|
||||
{
|
||||
id: `${iCalEvent.uuid}-${start}`,
|
||||
url: iCalEvent.url,
|
||||
@@ -107,8 +108,8 @@ export class CalendarService {
|
||||
* Emit the calendar index corresponding to the input date.
|
||||
* @param date Moment - date the calendar should go to
|
||||
*/
|
||||
emitGoToDate(date: Moment) {
|
||||
const index = date.diff(moment().startOf('day'), 'days');
|
||||
emitGoToDate(date: Date) {
|
||||
const index = differenceInDays(date, startOfToday());
|
||||
this.goToDate.next(index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,61 +13,59 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {findRRules, RRule} from './ical';
|
||||
import moment, {unitOfTime} from 'moment';
|
||||
import {SCISO8601Date} from '@openstapps/core';
|
||||
import {shuffle} from '@openstapps/collection-utils';
|
||||
import {add, addWeeks, formatISO, isEqual, parseISO} from 'date-fns';
|
||||
import {normalize} from 'duration-fns';
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function expandRRule(rule: RRule): SCISO8601Date[] {
|
||||
const initial = moment(rule.from);
|
||||
const initial = parseISO(rule.from);
|
||||
const interval = rule.interval ?? 1;
|
||||
const dates = [initial];
|
||||
while (!isEqual(dates.at(-1)!, parseISO(rule.until))) {
|
||||
dates.push(add(dates.at(-1)!, normalize({[rule.freq ?? 'days']: interval}, dates.at(-1))));
|
||||
}
|
||||
|
||||
return shuffle(
|
||||
Array.from({
|
||||
length: Math.floor(moment(rule.until).diff(initial, rule.freq, true) / interval) + 1,
|
||||
}).map((_, i) =>
|
||||
initial
|
||||
.clone()
|
||||
.add(interval * i, rule.freq ?? 'day')
|
||||
.toISOString(),
|
||||
),
|
||||
);
|
||||
return shuffle(dates.map(date => formatISO(date)));
|
||||
}
|
||||
|
||||
describe('iCal', () => {
|
||||
it('should find simple recurrence patterns', () => {
|
||||
for (const freq of ['day', 'week', 'month', 'year'] as unitOfTime.Diff[]) {
|
||||
for (const interval of [1, 2, 3]) {
|
||||
for (const freq of ['days', 'weeks', 'months', 'years'] as const) {
|
||||
for (const interval of [1, 2, 3]) {
|
||||
it(`should find ${interval} ${freq} recurrence patterns`, () => {
|
||||
const pattern: RRule = {
|
||||
freq: freq,
|
||||
interval: interval,
|
||||
from: moment('2021-09-01T10:00').toISOString(),
|
||||
until: moment('2021-09-01T10:00')
|
||||
.add(4 * interval, freq)
|
||||
.toISOString(),
|
||||
from: formatISO(parseISO('2021-09-01T10:00Z')),
|
||||
until: formatISO(
|
||||
add(parseISO('2021-09-01T10:00Z'), normalize({[freq]: 4 * interval}, '2021-09-01')),
|
||||
),
|
||||
};
|
||||
|
||||
console.log(expandRRule(pattern));
|
||||
|
||||
expect(findRRules(expandRRule(pattern))).toEqual([pattern]);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
it('should find missing recurrence patterns', () => {
|
||||
const pattern: SCISO8601Date = moment('2021-09-01T10:00').toISOString();
|
||||
const pattern: SCISO8601Date = formatISO(parseISO('2021-09-01T10:00'));
|
||||
|
||||
expect(findRRules([pattern])).toEqual([pattern]);
|
||||
});
|
||||
|
||||
it('should find mixed recurrence patterns', () => {
|
||||
const singlePattern: SCISO8601Date = moment('2021-09-01T09:00').toISOString();
|
||||
const singlePattern: SCISO8601Date = formatISO(parseISO('2021-09-01T09:00'));
|
||||
|
||||
const weeklyPattern: RRule = {
|
||||
freq: 'week',
|
||||
freq: 'weeks',
|
||||
interval: 1,
|
||||
from: moment('2021-09-03T10:00').toISOString(),
|
||||
until: moment('2021-09-03T10:00').add(4, 'weeks').toISOString(),
|
||||
from: formatISO(parseISO('2021-09-03T10:00')),
|
||||
until: formatISO(addWeeks(parseISO('2021-09-03T10:00'), 4)),
|
||||
};
|
||||
|
||||
expect(findRRules(shuffle([singlePattern, ...expandRRule(weeklyPattern)]))).toEqual([
|
||||
|
||||
@@ -20,8 +20,10 @@ import {
|
||||
SCThingWithCategories,
|
||||
SCUuid,
|
||||
} from '@openstapps/core';
|
||||
import moment, {unitOfTime} from 'moment';
|
||||
import {minBy, mapValues} from '@openstapps/collection-utils';
|
||||
import type {Duration} from 'date-fns';
|
||||
import {formatISO, intervalToDuration, parseISO} from 'date-fns';
|
||||
import {toUnit} from 'duration-fns';
|
||||
|
||||
export interface ICalEvent {
|
||||
name?: string;
|
||||
@@ -55,19 +57,25 @@ export type ICalLike = ICalKeyValuePair[];
|
||||
function timeDistance(
|
||||
current: SCISO8601Date,
|
||||
next: SCISO8601Date | undefined,
|
||||
recurrence: unitOfTime.Diff,
|
||||
recurrence: keyof Duration,
|
||||
): number | undefined {
|
||||
if (!next) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const diff = moment(next).diff(moment(current), recurrence, true);
|
||||
const diff = toUnit(
|
||||
intervalToDuration({
|
||||
start: parseISO(next),
|
||||
end: parseISO(current),
|
||||
}),
|
||||
recurrence,
|
||||
);
|
||||
|
||||
return Math.floor(diff) === diff ? diff : undefined;
|
||||
}
|
||||
|
||||
export interface RRule {
|
||||
freq: unitOfTime.Diff; // 'SECONDLY' | 'HOURLY' | 'DAILY' | 'WEEKLY' | 'MONTHLY' | 'YEARLY';
|
||||
freq: keyof Duration;
|
||||
interval: number;
|
||||
from: SCISO8601Date;
|
||||
until: SCISO8601Date;
|
||||
@@ -97,7 +105,7 @@ export function mergeRRules(rules: Array<RRule | SCISO8601Date>, allowExceptions
|
||||
* Find RRules in a list of dates
|
||||
*/
|
||||
export function findRRules(dates: SCISO8601Date[]): Array<RRule | SCISO8601Date> {
|
||||
const sorted = dates.sort((a, b) => moment(a).unix() - moment(b).unix());
|
||||
const sorted = dates.sort();
|
||||
|
||||
const output: Optional<RRule, 'freq'>[] = [
|
||||
{
|
||||
@@ -112,7 +120,9 @@ export function findRRules(dates: SCISO8601Date[]): Array<RRule | SCISO8601Date>
|
||||
const next = sorted[i + 1] as SCISO8601Date | undefined;
|
||||
const element = output.at(-1);
|
||||
|
||||
const units: unitOfTime.Diff[] = element?.freq ? [element.freq] : ['day', 'week', 'month', 'year'];
|
||||
const units: Array<keyof Duration> = element?.freq
|
||||
? [element.freq]
|
||||
: ['days', 'weeks', 'months', 'years'];
|
||||
const freq = minBy(
|
||||
units.map(recurrence => ({
|
||||
recurrence: recurrence,
|
||||
@@ -226,14 +236,14 @@ export function toICalUpdates(dateSeries: SCDateSeries, translator: SCThingTrans
|
||||
export function iso8601ToICalDateTime<T extends SCISO8601Date | undefined>(
|
||||
date: T,
|
||||
): T extends SCISO8601Date ? string : undefined {
|
||||
return (date ? `${moment(date).utc().format('YYYYMMDDTHHmmss')}Z` : undefined) as never;
|
||||
return (date ? formatISO(parseISO(date), {format: 'basic'}) : undefined) as never;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an ISO8601 date to a string in the format YYYYMMDD
|
||||
*/
|
||||
export function iso8601ToICalDate(date: SCISO8601Date): string {
|
||||
return `${moment(date).utc().format('YYYYMMDD')}`;
|
||||
return formatISO(parseISO(date), {format: 'basic', representation: 'date'});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -266,11 +276,11 @@ export function normalizeICalDates(iCal: ICalEvent): ICalEvent {
|
||||
};
|
||||
}
|
||||
|
||||
const REPEAT_FREQUENCIES: Partial<Record<unitOfTime.Diff, string>> = {
|
||||
day: 'DAILY',
|
||||
week: 'WEEKLY',
|
||||
month: 'MONTHLY',
|
||||
year: 'YEARLY',
|
||||
const REPEAT_FREQUENCIES: Partial<Record<keyof Duration, string>> = {
|
||||
days: 'DAILY',
|
||||
weeks: 'WEEKLY',
|
||||
months: 'MONTHLY',
|
||||
years: 'YEARLY',
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -308,7 +318,7 @@ export function serializeICalEvent(iCal: ICalEvent): ICalLike {
|
||||
'BEGIN:VEVENT',
|
||||
`DTSTART:${normalized.start}`,
|
||||
`DURATION:${normalized.duration}`,
|
||||
`DTSTAMP:${moment().utc().format('YYYYMMDDTHHmmss')}Z`,
|
||||
`DTSTAMP:${formatISO(Date.now(), {format: 'basic'})}`,
|
||||
`UID:${normalized.uuid}`,
|
||||
`RECURRENCE-ID:${normalized.recurrenceId}`,
|
||||
`CATEGORIES:${normalized.categories?.join(',')}`,
|
||||
|
||||
@@ -26,9 +26,10 @@ import {
|
||||
import {BehaviorSubject, Observable} from 'rxjs';
|
||||
import {DataProvider} from '../data/data.provider';
|
||||
import {map} from 'rxjs/operators';
|
||||
import {DateFormatPipe, DurationPipe} from 'ngx-moment';
|
||||
import {pick} from '@openstapps/collection-utils';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
import {format, formatDuration, parseISO} from 'date-fns';
|
||||
import {parse as parseISODuration} from 'duration-fns';
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -48,17 +49,13 @@ export const dateSeriesRelevantKeys: Array<DateSeriesRelevantKeys> = [
|
||||
];
|
||||
|
||||
export const formatRelevantKeys: {
|
||||
[key in DateSeriesRelevantKeys]: (
|
||||
value: SCDateSeries[key],
|
||||
dateFormatter: DateFormatPipe,
|
||||
durationFormatter: DurationPipe,
|
||||
) => string;
|
||||
[key in DateSeriesRelevantKeys]: (value: SCDateSeries[key]) => string;
|
||||
} = {
|
||||
uid: value => value,
|
||||
dates: (value, dateFormatter) => `[${value.map(it => dateFormatter.transform(it)).join(', ')}]`,
|
||||
exceptions: (value, dateFormatter) => `[${value?.map(it => dateFormatter.transform(it)).join(', ') ?? ''}]`,
|
||||
repeatFrequency: (value, _, durationFormatter) => durationFormatter.transform(value),
|
||||
duration: (value, _, durationFormatter) => durationFormatter.transform(value),
|
||||
dates: value => `[${value.map(it => format(parseISO(it), 'PPp')).join(', ')}]`,
|
||||
exceptions: value => `[${value?.map(it => format(parseISO(it), 'PPp')).join(', ') ?? ''}]`,
|
||||
repeatFrequency: value => (value ? formatDuration(parseISODuration(value)) : ''),
|
||||
duration: value => formatDuration(parseISODuration(value)),
|
||||
};
|
||||
|
||||
export type DateSeriesRelevantData = Pick<SCDateSeries, DateSeriesRelevantKeys>;
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Router, ActivatedRoute} from '@angular/router';
|
||||
import {SCCatalog, SCSemester} from '@openstapps/core';
|
||||
import moment from 'moment';
|
||||
import {CatalogProvider} from './catalog.provider';
|
||||
import {NGXLogger} from 'ngx-logger';
|
||||
import {Location} from '@angular/common';
|
||||
import {DataRoutingService} from '../data/data-routing.service';
|
||||
import {formatISO, startOfToday} from 'date-fns';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
|
||||
@Component({
|
||||
@@ -65,7 +65,7 @@ export class CatalogComponent implements OnInit {
|
||||
.itemSelectListener()
|
||||
.pipe(takeUntilDestroyed())
|
||||
.subscribe(item => {
|
||||
void this.router.navigate(['data-detail', item.uid]);
|
||||
void this.router.navigate(['data-detail', item.uid], {state: {item}});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ export class CatalogComponent implements OnInit {
|
||||
}
|
||||
|
||||
async fetchSemesters(): Promise<void> {
|
||||
const today = moment().startOf('day').toISOString();
|
||||
const today = formatISO(startOfToday());
|
||||
const semesters = await this.catalogProvider.getRelevantSemesters();
|
||||
const currentSemester = semesters.find(
|
||||
semester => semester.startDate <= today && semester.endDate > today,
|
||||
|
||||
@@ -18,7 +18,6 @@ import {FormsModule} from '@angular/forms';
|
||||
import {RouterModule, Routes} from '@angular/router';
|
||||
import {IonicModule} from '@ionic/angular';
|
||||
import {TranslateModule} from '@ngx-translate/core';
|
||||
import {MomentModule} from 'ngx-moment';
|
||||
import {DataModule} from '../data/data.module';
|
||||
import {SettingsProvider} from '../settings/settings.provider';
|
||||
import {CatalogComponent} from './catalog.component';
|
||||
@@ -42,7 +41,6 @@ const catalogRoutes: Routes = [
|
||||
RouterModule.forChild(catalogRoutes),
|
||||
IonIconModule,
|
||||
CommonModule,
|
||||
MomentModule,
|
||||
DataModule,
|
||||
UtilModule,
|
||||
],
|
||||
|
||||
@@ -19,20 +19,21 @@
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
<div #schedule class="schedule">
|
||||
<a [routerLink]="['/schedule/recurring']">
|
||||
<ion-icon size="40" weight="300" name="grid_view"></ion-icon>
|
||||
<ion-label>{{ 'schedule.recurring' | translate }}</ion-label>
|
||||
<a [routerLink]="['/schedule/week-overview']">
|
||||
<ion-icon size="36" 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 -->
|
||||
<a
|
||||
[routerLink]="nextEvent?.event ? ['/data-detail', nextEvent!.event.uid] : ['/schedule/recurring']"
|
||||
[routerLink]="nextEvent ? ['/data-detail', nextEvent!.uid] : ['/schedule/calendar']"
|
||||
[state]="{item: nextEvent}"
|
||||
class="schedule-item-button"
|
||||
>
|
||||
<ion-label>{{ 'dashboard.schedule.title' | translate }}</ion-label>
|
||||
<ion-label>
|
||||
{{
|
||||
nextEvent?.event
|
||||
? (nextEvent!.dates | nextDateInList | amDateFormat : 'll, HH:mm')
|
||||
nextEvent
|
||||
? (nextEvent!.dates.sort().at(-1) | dfnsParseIso | dfnsFormatRelativePure : (now | async))
|
||||
: ('dashboard.schedule.noEvent' | translate)
|
||||
}}
|
||||
</ion-label>
|
||||
|
||||
@@ -117,6 +117,7 @@ ion-content {
|
||||
ion-label {
|
||||
font-size: var(--font-size-xxs);
|
||||
font-weight: var(--font-weight-semi-bold);
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
&:hover ::ng-deep stapps-icon {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
import {Component, DestroyRef, ElementRef, inject, NgZone, OnDestroy, OnInit, ViewChild} from '@angular/core';
|
||||
import {Router} from '@angular/router';
|
||||
import {Location} from '@angular/common';
|
||||
import moment from 'moment';
|
||||
import {timer} from 'rxjs';
|
||||
import {SCDateSeries, SCUuid} from '@openstapps/core';
|
||||
import {SplashScreen} from '@capacitor/splash-screen';
|
||||
import {DataRoutingService} from '../data/data-routing.service';
|
||||
@@ -24,6 +24,10 @@ import {AnimationController, IonContent} from '@ionic/angular';
|
||||
import {DashboardCollapse} from './dashboard-collapse';
|
||||
import {BreakpointObserver} from '@angular/cdk/layout';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
import {formatISO, minutesToMilliseconds, startOfWeek} from 'date-fns';
|
||||
import {map} from 'rxjs/operators';
|
||||
|
||||
// const scrollTimeline = new ScrollTimeline();
|
||||
|
||||
@Component({
|
||||
selector: 'app-dashboard',
|
||||
@@ -63,6 +67,8 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
||||
|
||||
destroy$ = inject(DestroyRef);
|
||||
|
||||
now = timer(0, minutesToMilliseconds(1)).pipe(map(() => Date.now()));
|
||||
|
||||
constructor(
|
||||
private readonly dataRoutingService: DataRoutingService,
|
||||
private scheduleProvider: ScheduleProvider,
|
||||
@@ -76,7 +82,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
||||
.itemSelectListener()
|
||||
.pipe(takeUntilDestroyed())
|
||||
.subscribe(item => {
|
||||
void this.router.navigate(['data-detail', item.uid]);
|
||||
void this.router.navigate(['data-detail', item.uid], {state: {item}});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -108,7 +114,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
||||
const dataSeries = await this.scheduleProvider.getDateSeries(
|
||||
this.eventUuids,
|
||||
undefined,
|
||||
moment(moment.now()).startOf('week').toISOString(),
|
||||
formatISO(startOfWeek(Date.now())),
|
||||
);
|
||||
|
||||
this.nextEvent = dataSeries.dates
|
||||
|
||||
@@ -19,7 +19,6 @@ import {RouterModule, Routes} from '@angular/router';
|
||||
import {IonicModule} from '@ionic/angular';
|
||||
import {SwiperModule} from 'swiper/angular';
|
||||
import {TranslateModule, TranslatePipe} from '@ngx-translate/core';
|
||||
import {MomentModule} from 'ngx-moment';
|
||||
import {DataModule} from '../data/data.module';
|
||||
import {SettingsProvider} from '../settings/settings.provider';
|
||||
import {DashboardComponent} from './dashboard.component';
|
||||
@@ -32,6 +31,7 @@ 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 {FormatRelativePurePipeModule, ParseIsoPipeModule} from 'ngx-date-fns';
|
||||
|
||||
const catalogRoutes: Routes = [
|
||||
{
|
||||
@@ -59,12 +59,13 @@ const catalogRoutes: Routes = [
|
||||
TranslateModule.forChild(),
|
||||
RouterModule.forChild(catalogRoutes),
|
||||
CommonModule,
|
||||
MomentModule,
|
||||
DataModule,
|
||||
SwiperModule,
|
||||
ThingTranslateModule.forChild(),
|
||||
UtilModule,
|
||||
NewsModule,
|
||||
ParseIsoPipeModule,
|
||||
FormatRelativePurePipeModule,
|
||||
],
|
||||
providers: [SettingsProvider, TranslatePipe],
|
||||
})
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
<stapps-data-list-item
|
||||
*ngFor="let dish of dishes"
|
||||
[hideThumbnail]="true"
|
||||
[favoriteButton]="false"
|
||||
[item]="dish"
|
||||
appearance="square"
|
||||
></stapps-data-list-item>
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
import {ChangeDetectionStrategy, Component, Input} from '@angular/core';
|
||||
import {SCDish, SCPlace, SCThings} from '@openstapps/core';
|
||||
import {PlaceMensaService} from '../../../data/types/place/special/mensa/place-mensa-service';
|
||||
import moment from 'moment';
|
||||
import {fadeAnimation} from '../../fade.animation';
|
||||
import {isToday, parseISO} from 'date-fns';
|
||||
|
||||
/**
|
||||
* Shows a section with meals of the chosen mensa
|
||||
@@ -38,10 +38,10 @@ export class MensaSectionContentComponent {
|
||||
@Input() set item(value: SCThings) {
|
||||
if (!value) return;
|
||||
this.dishes = this.mensaService.getAllDishes(value as SCPlace, 1).then(it => {
|
||||
const closestDayWithDishes = Object.keys(it)
|
||||
.filter(key => it[key].length > 0)
|
||||
.find(key => moment(key).isSame(moment(), 'day'));
|
||||
return closestDayWithDishes ? it[closestDayWithDishes] : [];
|
||||
const days = Object.entries(it);
|
||||
console.assert(days.length <= 1);
|
||||
console.assert(!days[0] || isToday(parseISO(days[0][0])));
|
||||
return days[0]?.[1] ?? [];
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ export class ActionChipListComponent {
|
||||
event:
|
||||
item.type === SCThingType.AcademicEvent ||
|
||||
(item.type === SCThingType.DateSeries && (item as SCDateSeries).dates.length > 0),
|
||||
navigate: ('inPlace' in item && item.inPlace && 'geo' in item.inPlace) || 'geo' in item,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -14,5 +14,6 @@
|
||||
-->
|
||||
|
||||
<stapps-locate-action-chip *ngIf="applicable.locate" [item]="item"></stapps-locate-action-chip>
|
||||
<stapps-navigate-action-chip *ngIf="applicable.navigate" [item]="$any(item)"></stapps-navigate-action-chip>
|
||||
<!-- Add Event Chip needs to load data and should be the last -->
|
||||
<stapps-add-event-action-chip *ngIf="applicable.event" [item]="item"></stapps-add-event-action-chip>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 StApps
|
||||
* Copyright (C) 2023 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.
|
||||
@@ -13,19 +13,23 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Component, Input} from '@angular/core';
|
||||
import {SCPlace} from '@openstapps/core';
|
||||
import {ModalController} from '@ionic/angular';
|
||||
import {SCPlaceWithoutReferences, SCThings} from '@openstapps/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-map-single-modal',
|
||||
templateUrl: './map-single.html',
|
||||
styleUrls: ['./map-single.scss'],
|
||||
selector: 'stapps-navigate-action-chip',
|
||||
templateUrl: 'navigate-action-chip.html',
|
||||
styleUrls: ['navigate-action-chip.scss'],
|
||||
})
|
||||
export class MapSingleModalComponent {
|
||||
/**
|
||||
* The item to be shown
|
||||
*/
|
||||
@Input() item: SCPlace;
|
||||
export class NavigateActionChipComponent {
|
||||
place: SCPlaceWithoutReferences;
|
||||
|
||||
constructor(readonly modalController: ModalController) {}
|
||||
@Input({required: true}) set item(value: SCThings) {
|
||||
if ('geo' in value) {
|
||||
this.place = value;
|
||||
} else if ('inPlace' in value && value.inPlace && 'geo' in value.inPlace) {
|
||||
this.place = value.inPlace;
|
||||
} else {
|
||||
console.error('Invalid place', value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
<!--
|
||||
~ Copyright (C) 2022 StApps
|
||||
~ Copyright (C) 2023 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.
|
||||
@@ -12,15 +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/>.
|
||||
-->
|
||||
|
||||
<ion-header translucent>
|
||||
<ion-toolbar color="primary" mode="ios">
|
||||
<ion-title>{{ 'map.modals.single.TITLE' | translate }}</ion-title>
|
||||
<ion-buttons slot="end">
|
||||
<ion-button (click)="modalController.dismiss()">{{ 'app.ui.CLOSE' | translate }}</ion-button>
|
||||
</ion-buttons>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
<ion-content>
|
||||
<stapps-data-detail-content [item]="$any(item)" [openAsModal]="true"></stapps-data-detail-content>
|
||||
</ion-content>
|
||||
<ion-chip [color]="'primary'" [outline]="true" [geoNavigation]="place">
|
||||
<ion-icon name="directions"></ion-icon>
|
||||
<ion-label>{{'map.directions.TITLE' | translate}}</ion-label>
|
||||
</ion-chip>
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 StApps
|
||||
/*!
|
||||
* Copyright (C) 2023 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.
|
||||
@@ -12,16 +12,3 @@
|
||||
* 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 {Pipe, PipeTransform} from '@angular/core';
|
||||
import {Moment} from 'moment';
|
||||
|
||||
@Pipe({
|
||||
name: 'dateFromIndex',
|
||||
pure: true,
|
||||
})
|
||||
export class DateFromIndexPipe implements PipeTransform {
|
||||
transform(index: number, baseline: Moment): Moment {
|
||||
return baseline.clone().add(index, 'days');
|
||||
}
|
||||
}
|
||||
@@ -32,8 +32,8 @@
|
||||
>
|
||||
<ion-list-header>
|
||||
{{ frequency.children[0].item.repeatFrequency ? (frequency.children[0].item.repeatFrequency |
|
||||
durationLocalized: true | sentencecase) : ('data.chips.add_events.popover.SINGLE' | translate |
|
||||
titlecase) }}
|
||||
dfnsParseDuration | dfnsFormatFrequencyPure | sentencecase) :
|
||||
('data.chips.add_events.popover.SINGLE' | translate | titlecase) }}
|
||||
</ion-list-header>
|
||||
</ion-checkbox>
|
||||
</ion-item>
|
||||
@@ -44,18 +44,19 @@
|
||||
>
|
||||
<ng-container *ngIf="date.item.dates.length > 1; else single_event">
|
||||
<ion-text>
|
||||
{{ date.item.dates[0] | amDateFormat: 'dddd, LT' }} - {{ date.item.dates[0] | amAdd:
|
||||
date.item.duration | amDateFormat: 'LT' }}
|
||||
<b>{{ date.item.duration | dfnsParseDuration | dfnsFormatDurationPure }}</b>
|
||||
{{ date.item.dates[0] | dfnsParseIso | dfnsFormatPure: 'EEEE, p' }}
|
||||
</ion-text>
|
||||
<br />
|
||||
<ion-text>
|
||||
{{ date.item.dates[0] | amDateFormat: 'LL' }} - {{ date.item.dates[date.item.dates.length - 1] |
|
||||
amDateFormat: 'LL' }}
|
||||
{{ date.item.dates[0] | dfnsParseIso | dfnsFormatPure: 'PPP' }} - {{
|
||||
date.item.dates[date.item.dates.length - 1] | dfnsParseIso | dfnsFormatPure: 'PPP' }}
|
||||
</ion-text>
|
||||
</ng-container>
|
||||
<ng-template #single_event>
|
||||
<ion-text *ngIf="date.item.dates[0] as time; else noDates">
|
||||
{{ time | amDateFormat: 'LL, LT' }} - {{ time | amAdd: date.item.duration | amDateFormat: 'LT' }}
|
||||
<b>{{ date.item.duration |dfnsParseDuration | dfnsFormatDurationPure}}</b>
|
||||
{{ time | dfnsParseIso | dfnsFormatPure: 'PPPPp' }}
|
||||
</ion-text>
|
||||
<ng-template #noDates>
|
||||
<ion-text color="danger">{{ 'data.chips.add_events.popover.DATA_ERROR' | translate }}</ion-text>
|
||||
|
||||
@@ -20,7 +20,6 @@ import {FormsModule} from '@angular/forms';
|
||||
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 {MenuModule} from '../menu/menu.module';
|
||||
import {ScheduleProvider} from '../calendar/schedule.provider';
|
||||
@@ -102,6 +101,17 @@ import {StappsRatingComponent} from './elements/rating.component';
|
||||
import {DishCharacteristicsComponent} from './types/dish/dish-characteristics.component';
|
||||
import {SkeletonListComponent} from './list/skeleton-list.component';
|
||||
import {CertificationsInDetailComponent} from './elements/certifications-in-detail.component';
|
||||
import {GeoNavigationDirective} from '../map/geo-navigation.directive';
|
||||
import {NavigateActionChipComponent} from './chips/data/navigate-action-chip.component';
|
||||
import {
|
||||
FormatDurationPurePipeModule,
|
||||
FormatPurePipeModule,
|
||||
FormatRelativeToNowPurePipeModule,
|
||||
ParseIsoPipeModule,
|
||||
} from 'ngx-date-fns';
|
||||
import {ParseDurationPipe} from '../../translation/date-time/parse-duration.pipe';
|
||||
import {DfnsFormatFrequencyPurePipe} from '../../translation/date-time/format-frequency.pipe';
|
||||
import {DfnsFormatRelativeDatePurePipe} from '../../translation/date-time/format-relative-date.pipe';
|
||||
|
||||
/**
|
||||
* Module for handling data
|
||||
@@ -110,6 +120,7 @@ import {CertificationsInDetailComponent} from './elements/certifications-in-deta
|
||||
declarations: [
|
||||
ActionChipListComponent,
|
||||
AddEventActionChipComponent,
|
||||
NavigateActionChipComponent,
|
||||
EditEventSelectionComponent,
|
||||
AddressDetailComponent,
|
||||
CatalogDetailContentComponent,
|
||||
@@ -184,16 +195,19 @@ import {CertificationsInDetailComponent} from './elements/certifications-in-deta
|
||||
MarkdownModule.forRoot(),
|
||||
MenuModule,
|
||||
IonIconModule,
|
||||
MomentModule.forRoot({
|
||||
relativeTimeThresholdOptions: {
|
||||
m: 59,
|
||||
},
|
||||
}),
|
||||
ScrollingModule,
|
||||
StorageModule,
|
||||
TranslateModule.forChild(),
|
||||
ThingTranslateModule.forChild(),
|
||||
UtilModule,
|
||||
GeoNavigationDirective,
|
||||
ParseIsoPipeModule,
|
||||
ParseDurationPipe,
|
||||
DfnsFormatFrequencyPurePipe,
|
||||
DfnsFormatRelativeDatePurePipe,
|
||||
FormatPurePipeModule,
|
||||
FormatDurationPurePipeModule,
|
||||
FormatRelativeToNowPurePipeModule,
|
||||
],
|
||||
providers: [
|
||||
CoordinatedSearchProvider,
|
||||
|
||||
@@ -95,7 +95,7 @@ describe('DataDetailComponent', () => {
|
||||
fixture = TestBed.createComponent(DataDetailComponent);
|
||||
comp = fixture.componentInstance;
|
||||
detailPage = fixture.debugElement;
|
||||
translateService.use('foo');
|
||||
translateService.use('en');
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
@@ -111,8 +111,8 @@ describe('DataDetailComponent', () => {
|
||||
expect(DataDetailComponent.prototype.getItem).toHaveBeenCalledWith(sampleThing.uid, false);
|
||||
});
|
||||
|
||||
it('should get a data item when the view is entered', () => {
|
||||
comp.ionViewWillEnter();
|
||||
it('should get a data item when initialized', () => {
|
||||
comp.ngOnInit();
|
||||
expect(DataDetailComponent.prototype.getItem).toHaveBeenCalledWith(sampleThing.uid, false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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 {Component, ContentChild, EventEmitter, Input, Output, TemplateRef} from '@angular/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {ModalController, ViewWillEnter} from '@ionic/angular';
|
||||
import {Component, ContentChild, EventEmitter, Input, OnInit, Output, TemplateRef} from '@angular/core';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {ModalController} from '@ionic/angular';
|
||||
import {LangChangeEvent, TranslateService} from '@ngx-translate/core';
|
||||
import {SCLanguageCode, SCSaveableThing, SCThings, SCUuid} from '@openstapps/core';
|
||||
import {DataProvider, DataScope} from '../data.provider';
|
||||
@@ -37,7 +37,7 @@ export interface ExternalDataLoadEvent {
|
||||
styleUrls: ['data-detail.scss'],
|
||||
templateUrl: 'data-detail.html',
|
||||
})
|
||||
export class DataDetailComponent implements ViewWillEnter {
|
||||
export class DataDetailComponent implements OnInit {
|
||||
/**
|
||||
* The associated item
|
||||
*
|
||||
@@ -84,21 +84,15 @@ export class DataDetailComponent implements ViewWillEnter {
|
||||
return (thing as SCSaveableThing).data !== undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param route the route the page was accessed from
|
||||
* @param dataProvider the data provider
|
||||
* @param favoritesService the favorites provider
|
||||
* @param modalController the modal controller
|
||||
* @param translateService he translate provider
|
||||
*/
|
||||
constructor(
|
||||
protected readonly route: ActivatedRoute,
|
||||
router: Router,
|
||||
private readonly dataProvider: DataProvider,
|
||||
private readonly favoritesService: FavoritesService,
|
||||
readonly modalController: ModalController,
|
||||
translateService: TranslateService,
|
||||
) {
|
||||
this.inputItem = router.getCurrentNavigation()?.extras.state?.item;
|
||||
this.language = translateService.currentLang as SCLanguageCode;
|
||||
translateService.onLangChange.subscribe((event: LangChangeEvent) => {
|
||||
this.language = event.lang as SCLanguageCode;
|
||||
@@ -138,10 +132,7 @@ export class DataDetailComponent implements ViewWillEnter {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
async ionViewWillEnter() {
|
||||
async ngOnInit() {
|
||||
const uid = this.route.snapshot.paramMap.get('uid') || '';
|
||||
await this.getItem(uid ?? '', false);
|
||||
// fallback to the saved item (from favorites)
|
||||
|
||||
@@ -37,32 +37,22 @@ export class DataPathComponent implements OnInit {
|
||||
@Input() maxItems = 2;
|
||||
|
||||
@Input() set item(item: SCThings) {
|
||||
// eslint-disable-next-line unicorn/prefer-ternary
|
||||
if (item.type === SCThingType.Catalog && item.superCatalogs) {
|
||||
this.path = new Promise(resolve =>
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
resolve([...item.superCatalogs!, item]),
|
||||
);
|
||||
this.path = Promise.resolve([...item.superCatalogs!, item]);
|
||||
} else if (item.type === SCThingType.Assessment && item.superAssessments) {
|
||||
this.path = new Promise(resolve =>
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
resolve([...item.superAssessments!, item]),
|
||||
);
|
||||
this.path = Promise.resolve([...item.superAssessments!, item]);
|
||||
} else if (
|
||||
item.type === SCThingType.AcademicEvent &&
|
||||
item.catalogs &&
|
||||
(item.catalogs.length === 1 || this.routeStack.lastDataDetail)
|
||||
) {
|
||||
const catalogWithoutReferences = item.catalogs[0];
|
||||
const catalogPromise = (
|
||||
item.catalogs.length === 1
|
||||
? this.dataProvider.get(catalogWithoutReferences.uid, DataScope.Remote)
|
||||
: this.routeStack.lastDataDetail
|
||||
) as Promise<SCCatalog>;
|
||||
|
||||
this.path = new Promise(async resolve => {
|
||||
const catalog = await catalogPromise;
|
||||
const superCatalogs = catalog.superCatalogs;
|
||||
const catalogWithoutReferences = item.catalogs![0];
|
||||
const catalog =
|
||||
item.catalogs!.length === 1
|
||||
? await this.dataProvider.get(catalogWithoutReferences.uid, DataScope.Remote)
|
||||
: this.routeStack.lastDataDetail;
|
||||
const superCatalogs = (catalog as SCCatalog).superCatalogs;
|
||||
|
||||
resolve(
|
||||
superCatalogs
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
*ngIf="offer.availabilityRange.gt ? offer.availabilityRange.gt : offer.availabilityRange.gte"
|
||||
>
|
||||
{{ (offer.availabilityRange.gt ? offer.availabilityRange.gt : offer.availabilityRange.gte) |
|
||||
amDateFormat : 'll' }}
|
||||
dfnsParseIso | dfnsFormatPure : 'PPP' }}
|
||||
</span>
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
|
||||
@@ -20,16 +20,16 @@
|
||||
>
|
||||
<ion-card-content>
|
||||
<p>
|
||||
{{ 'data.types.origin.detail.CREATED' | translate | titlecase }}: {{ origin.created | amDateFormat :
|
||||
'll' }}
|
||||
{{ 'data.types.origin.detail.CREATED' | translate | titlecase }}: {{ origin.created | dfnsParseIso |
|
||||
dfnsFormatPure : 'PPP' }}
|
||||
</p>
|
||||
<p *ngIf="origin.updated">
|
||||
{{ 'data.types.origin.detail.UPDATED' | translate | titlecase }}: {{ origin.updated | amDateFormat :
|
||||
'll' }}
|
||||
{{ 'data.types.origin.detail.UPDATED' | translate | titlecase }}: {{ origin.updated | dfnsParseIso |
|
||||
dfnsFormatPure : 'PPP' }}
|
||||
</p>
|
||||
<p *ngIf="origin.modified">
|
||||
{{ 'data.types.origin.detail.MODIFIED' | translate | titlecase }}: {{ origin.modified | amDateFormat :
|
||||
'll' }}
|
||||
{{ 'data.types.origin.detail.MODIFIED' | translate | titlecase }}: {{ origin.modified | dfnsParseIso |
|
||||
dfnsFormatPure : 'PPP' }}
|
||||
</p>
|
||||
<p *ngIf="origin.name">{{ 'data.types.origin.detail.MAINTAINER' | translate }}: {{ origin.name }}</p>
|
||||
<p *ngIf="origin.maintainer">
|
||||
@@ -46,12 +46,12 @@
|
||||
>
|
||||
<ion-card-content>
|
||||
<p>
|
||||
{{ 'data.types.origin.detail.INDEXED' | translate | titlecase }}: {{ origin.indexed | amDateFormat :
|
||||
'll' }}
|
||||
{{ 'data.types.origin.detail.INDEXED' | translate | titlecase }}: {{ origin.indexed | dfnsParseIso |
|
||||
dfnsFormatPure : 'PPP'}}
|
||||
</p>
|
||||
<p *ngIf="origin.modified">
|
||||
{{ 'data.types.origin.detail.MODIFIED' | translate | titlecase }}: {{ origin.modified | amDateFormat :
|
||||
'll' }}
|
||||
{{ 'data.types.origin.detail.MODIFIED' | translate | titlecase }}: {{ origin.modified | dfnsParseIso |
|
||||
dfnsFormatPure : 'PPP' }}
|
||||
</p>
|
||||
<p *ngIf="origin.name">{{ 'data.types.origin.detail.MAINTAINER' | translate }}: {{ origin.name }}</p>
|
||||
<p *ngIf="origin.maintainer">
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable unicorn/no-useless-undefined */
|
||||
/*
|
||||
* Copyright (C) 2023 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
@@ -12,60 +13,51 @@
|
||||
* 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 {Component, ElementRef, HostListener, Input} from '@angular/core';
|
||||
import {SCDish, SCRatingRequest, SCUuid} from '@openstapps/core';
|
||||
import {ChangeDetectionStrategy, Component, ElementRef, HostListener, Input} from '@angular/core';
|
||||
import {SCDish, SCRatingRequest} from '@openstapps/core';
|
||||
import {RatingProvider} from '../rating.provider';
|
||||
import {ratingAnimation} from './rating.animation';
|
||||
import {BehaviorSubject, filter, merge, mergeMap, of, ReplaySubject, withLatestFrom} from 'rxjs';
|
||||
import {catchError, map} from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
selector: 'stapps-rating',
|
||||
templateUrl: 'rating.html',
|
||||
styleUrls: ['rating.scss'],
|
||||
animations: [ratingAnimation],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class StappsRatingComponent {
|
||||
rate = false;
|
||||
performRating = new BehaviorSubject(false);
|
||||
|
||||
rated = false;
|
||||
userRating = new BehaviorSubject<number | undefined>(undefined);
|
||||
|
||||
canBeRated = false;
|
||||
dish = new ReplaySubject<SCDish>(1);
|
||||
|
||||
uid: SCUuid;
|
||||
wasAlreadyRated = merge(
|
||||
this.dish.pipe(mergeMap(({uid}) => this.ratingProvider.hasRated(uid))),
|
||||
this.userRating.pipe(
|
||||
filter(it => it !== undefined),
|
||||
withLatestFrom(this.dish),
|
||||
mergeMap(([rating, {uid}]) => this.ratingProvider.rate(uid, rating as SCRatingRequest['rating'])),
|
||||
map(() => true),
|
||||
catchError(() => of(false)),
|
||||
),
|
||||
);
|
||||
|
||||
rating?: number;
|
||||
canBeRated = this.dish.pipe(mergeMap(dish => this.ratingProvider.canRate(dish)));
|
||||
|
||||
@Input() set item(value: SCDish) {
|
||||
this.uid = value.uid;
|
||||
|
||||
Promise.all([this.ratingProvider.canRate(value), this.ratingProvider.hasRated(this.uid)] as const).then(
|
||||
([canRate, hasRated]) => {
|
||||
this.canBeRated = canRate;
|
||||
this.rated = hasRated;
|
||||
},
|
||||
);
|
||||
@Input({required: true}) set item(value: SCDish) {
|
||||
this.dish.next(value);
|
||||
}
|
||||
|
||||
constructor(readonly elementRef: ElementRef, readonly ratingProvider: RatingProvider) {}
|
||||
|
||||
async submitRating(rating: number) {
|
||||
this.rating = rating;
|
||||
try {
|
||||
await this.ratingProvider.rate(this.uid, rating as SCRatingRequest['rating']);
|
||||
this.rated = true;
|
||||
} catch {
|
||||
this.rating = undefined;
|
||||
// allow change detection to catch up first
|
||||
setTimeout(() => {
|
||||
this.rate = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@HostListener('document:mousedown', ['$event'])
|
||||
clickOutside(event: MouseEvent) {
|
||||
if (this.rating) return;
|
||||
if (this.userRating.value) return;
|
||||
if (!this.elementRef.nativeElement.contains(event.target)) {
|
||||
this.rate = false;
|
||||
this.performRating.next(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,19 +14,23 @@
|
||||
-->
|
||||
|
||||
<ion-button
|
||||
*ngIf="canBeRated"
|
||||
*ngIf="canBeRated | async"
|
||||
fill="clear"
|
||||
(click)="$event.stopPropagation(); rate = true"
|
||||
[disabled]="rated"
|
||||
(click)="$event.stopPropagation(); performRating.next(true)"
|
||||
[disabled]="wasAlreadyRated | async"
|
||||
>
|
||||
<ion-icon slot="icon-only" color="medium" name="thumbs_up_down"></ion-icon>
|
||||
</ion-button>
|
||||
|
||||
<div class="rating-stars" *ngIf="rate && !rated" [@rating]="rating ? 'rated' : 'abandoned'">
|
||||
<div
|
||||
class="rating-stars"
|
||||
*ngIf="(performRating | async) && (wasAlreadyRated | async) !== true"
|
||||
[@rating]="(userRating | async) === undefined ? 'abandoned' : 'rated'"
|
||||
>
|
||||
<ion-icon
|
||||
[class.rated-value]="rating === i"
|
||||
[class.rated-value]="(userRating | async) === i"
|
||||
*ngFor="let i of [5, 4, 3, 2, 1]"
|
||||
(click)="$event.stopPropagation(); submitRating(i)"
|
||||
(click)="$event.stopPropagation(); userRating.next(i)"
|
||||
slot="icon-only"
|
||||
size="32"
|
||||
color="medium"
|
||||
|
||||
@@ -38,6 +38,8 @@ export class DataListItemComponent {
|
||||
|
||||
@Input() listItemEndInteraction = true;
|
||||
|
||||
@Input() listItemChipInteraction = true;
|
||||
|
||||
@Input() lines = 'inset';
|
||||
|
||||
@Input() forceHeight = false;
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<div>
|
||||
<ng-template [dataListItemHost]="item"></ng-template>
|
||||
<stapps-action-chip-list
|
||||
*ngIf="appearance !== 'square'"
|
||||
*ngIf="listItemChipInteraction && appearance !== 'square'"
|
||||
slot="end"
|
||||
[item]="item"
|
||||
></stapps-action-chip-list>
|
||||
|
||||
@@ -12,109 +12,96 @@
|
||||
* 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 {Component, OnInit} from '@angular/core';
|
||||
import {MapPosition} from '../../map/position.service';
|
||||
import {SearchPageComponent} from './search-page.component';
|
||||
import {ChangeDetectionStrategy, Component} from '@angular/core';
|
||||
import {MapPosition, PositionService} from '../../map/position.service';
|
||||
import {Geolocation} from '@capacitor/geolocation';
|
||||
import {BehaviorSubject} from 'rxjs';
|
||||
import {pauseWhen} from '../../../util/pause-when';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
import {BehaviorSubject, from} from 'rxjs';
|
||||
import {pauseWhen} from '../../../util/rxjs/pause-when';
|
||||
import {map, retry, startWith, take} from 'rxjs/operators';
|
||||
import {SCSearchFilter, SCSearchSort} from '@openstapps/core';
|
||||
|
||||
/**
|
||||
* Presents a list of places for eating/drinking
|
||||
*/
|
||||
@Component({
|
||||
templateUrl: 'search-page.html',
|
||||
styleUrls: ['../../data/list/search-page.scss'],
|
||||
selector: 'stapps-food-data-list',
|
||||
templateUrl: 'food-data-list.html',
|
||||
styleUrls: ['food-data-list.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class FoodDataListComponent extends SearchPageComponent implements OnInit {
|
||||
title = 'canteens.title';
|
||||
|
||||
showNavigation = false;
|
||||
|
||||
export class FoodDataListComponent {
|
||||
isNotInView$ = new BehaviorSubject(true);
|
||||
|
||||
/**
|
||||
* Sets the forced filter to present only places for eating/drinking
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.positionService
|
||||
.watchCurrentLocation({enableHighAccuracy: false, maximumAge: 1000})
|
||||
.pipe(pauseWhen(this.isNotInView$), takeUntilDestroyed(this.destroy$))
|
||||
.subscribe({
|
||||
next: (position: MapPosition) => {
|
||||
this.positionService.position = position;
|
||||
forcedFilter: SCSearchFilter = {
|
||||
arguments: {
|
||||
filters: [
|
||||
{
|
||||
arguments: {
|
||||
field: 'categories',
|
||||
value: 'canteen',
|
||||
},
|
||||
type: 'value',
|
||||
},
|
||||
error: async _error => {
|
||||
this.positionService.position = undefined;
|
||||
await Geolocation.checkPermissions();
|
||||
{
|
||||
arguments: {
|
||||
field: 'categories',
|
||||
value: 'student canteen',
|
||||
},
|
||||
type: 'value',
|
||||
},
|
||||
});
|
||||
this.showDefaultData = true;
|
||||
{
|
||||
arguments: {
|
||||
field: 'categories',
|
||||
value: 'cafe',
|
||||
},
|
||||
type: 'value',
|
||||
},
|
||||
{
|
||||
arguments: {
|
||||
field: 'categories',
|
||||
value: 'restaurant',
|
||||
},
|
||||
type: 'value',
|
||||
},
|
||||
],
|
||||
operation: 'or',
|
||||
},
|
||||
type: 'boolean',
|
||||
};
|
||||
|
||||
this.sortQuery = [
|
||||
{
|
||||
arguments: {field: 'name'},
|
||||
order: 'asc',
|
||||
type: 'ducet',
|
||||
},
|
||||
];
|
||||
|
||||
this.forcedFilter = {
|
||||
arguments: {
|
||||
filters: [
|
||||
{
|
||||
arguments: {
|
||||
field: 'categories',
|
||||
value: 'canteen',
|
||||
},
|
||||
type: 'value',
|
||||
},
|
||||
{
|
||||
arguments: {
|
||||
field: 'categories',
|
||||
value: 'student canteen',
|
||||
},
|
||||
type: 'value',
|
||||
},
|
||||
{
|
||||
arguments: {
|
||||
field: 'categories',
|
||||
value: 'cafe',
|
||||
},
|
||||
type: 'value',
|
||||
},
|
||||
{
|
||||
arguments: {
|
||||
field: 'categories',
|
||||
value: 'restaurant',
|
||||
},
|
||||
type: 'value',
|
||||
},
|
||||
],
|
||||
operation: 'or',
|
||||
},
|
||||
type: 'boolean',
|
||||
};
|
||||
|
||||
if (this.positionService.position) {
|
||||
this.sortQuery = [
|
||||
sortQuery = this.positionService
|
||||
.watchCurrentLocation({
|
||||
enableHighAccuracy: false,
|
||||
maximumAge: 1000,
|
||||
})
|
||||
.pipe(
|
||||
pauseWhen(this.isNotInView$),
|
||||
retry({
|
||||
delay: () => from(Geolocation.checkPermissions()),
|
||||
}),
|
||||
map<MapPosition, SCSearchSort[]>(({longitude, latitude}) => [
|
||||
{
|
||||
type: 'distance',
|
||||
order: 'asc',
|
||||
arguments: {
|
||||
field: 'geo',
|
||||
position: [this.positionService.position.longitude, this.positionService.position.latitude],
|
||||
position: [longitude, latitude],
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
]),
|
||||
take(1),
|
||||
startWith<SCSearchSort[]>([
|
||||
{
|
||||
arguments: {field: 'name'},
|
||||
order: 'asc',
|
||||
type: 'ducet',
|
||||
},
|
||||
]),
|
||||
);
|
||||
|
||||
super.ngOnInit();
|
||||
}
|
||||
constructor(private readonly positionService: PositionService) {}
|
||||
|
||||
async ionViewWillEnter() {
|
||||
await super.ionViewWillEnter();
|
||||
this.isNotInView$.next(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<stapps-search-page
|
||||
[forcedFilter]="forcedFilter"
|
||||
[sortQuery]="sortQuery | async"
|
||||
[title]="'canteens.title'"
|
||||
[showNavigation]="false"
|
||||
[showDefaultData]="true"
|
||||
>
|
||||
</stapps-search-page>
|
||||
@@ -0,0 +1,3 @@
|
||||
:host {
|
||||
display: contents;
|
||||
}
|
||||
@@ -16,11 +16,13 @@
|
||||
import type {AnimationBuilder} from '@ionic/angular';
|
||||
import {AnimationController} from '@ionic/angular';
|
||||
import type {AnimationOptions} from '@ionic/angular/providers/nav-controller';
|
||||
import {inject} from '@angular/core';
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export function searchPageSwitchAnimation(animationController: AnimationController): AnimationBuilder {
|
||||
export function searchPageSwitchAnimation(): AnimationBuilder {
|
||||
const animationController = inject(AnimationController);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return (_baseElement: HTMLElement, options: AnimationOptions | any) => {
|
||||
const rootTransition = animationController
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
* 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 {Component, DestroyRef, inject, Input, OnInit} from '@angular/core';
|
||||
import {Component, DestroyRef, inject, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {Keyboard} from '@capacitor/keyboard';
|
||||
import {AlertController, AnimationBuilder, AnimationController} from '@ionic/angular';
|
||||
import {AlertController} from '@ionic/angular';
|
||||
import {Capacitor} from '@capacitor/core';
|
||||
import {
|
||||
SCFacet,
|
||||
@@ -32,7 +32,6 @@ import {ContextMenuService} from '../../menu/context/context-menu.service';
|
||||
import {SettingsProvider} from '../../settings/settings.provider';
|
||||
import {DataRoutingService} from '../data-routing.service';
|
||||
import {DataProvider} from '../data.provider';
|
||||
import {PositionService} from '../../map/position.service';
|
||||
import {ConfigProvider} from '../../config/config.provider';
|
||||
import {searchPageSwitchAnimation} from './search-page-switch-animation';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
@@ -46,7 +45,7 @@ import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
styleUrls: ['search-page.scss'],
|
||||
providers: [ContextMenuService],
|
||||
})
|
||||
export class SearchPageComponent implements OnInit {
|
||||
export class SearchPageComponent implements OnInit, OnChanges {
|
||||
@Input() title = 'search.title';
|
||||
|
||||
@Input() placeholder = 'search.search_bar.placeholder';
|
||||
@@ -140,25 +139,12 @@ export class SearchPageComponent implements OnInit {
|
||||
/**
|
||||
* Api query sorting
|
||||
*/
|
||||
sortQuery: SCSearchSort[] | undefined;
|
||||
@Input() sortQuery: SCSearchSort[] | undefined;
|
||||
|
||||
destroy$ = inject(DestroyRef);
|
||||
|
||||
routeAnimation: AnimationBuilder;
|
||||
routeAnimation = searchPageSwitchAnimation();
|
||||
|
||||
/**
|
||||
* Injects the providers and creates subscriptions
|
||||
* @param alertController AlertController
|
||||
* @param dataProvider DataProvider
|
||||
* @param contextMenuService ContextMenuService
|
||||
* @param settingsProvider SettingsProvider
|
||||
* @param logger An angular logger
|
||||
* @param dataRoutingService DataRoutingService
|
||||
* @param router Router
|
||||
* @param route ActivatedRoute
|
||||
* @param positionService PositionService
|
||||
* @param configProvider ConfigProvider
|
||||
*/
|
||||
constructor(
|
||||
protected readonly alertController: AlertController,
|
||||
protected dataProvider: DataProvider,
|
||||
@@ -168,18 +154,20 @@ export class SearchPageComponent implements OnInit {
|
||||
protected dataRoutingService: DataRoutingService,
|
||||
protected router: Router,
|
||||
private readonly route: ActivatedRoute,
|
||||
protected positionService: PositionService,
|
||||
private readonly configProvider: ConfigProvider,
|
||||
animationController: AnimationController,
|
||||
) {
|
||||
this.routeAnimation = searchPageSwitchAnimation(animationController);
|
||||
) {}
|
||||
|
||||
async ngOnChanges(changes: SimpleChanges) {
|
||||
if ('sortQuery' in changes) {
|
||||
await this.fetchAndUpdateItems();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches items with set query configuration
|
||||
* @param append If true fetched data gets appended to existing, override otherwise (default false)
|
||||
*/
|
||||
protected async fetchAndUpdateItems(append = false): Promise<void> {
|
||||
async fetchAndUpdateItems(append = false): Promise<void> {
|
||||
// build query search options
|
||||
const searchOptions: SCSearchQuery = {
|
||||
from: this.from,
|
||||
@@ -342,7 +330,7 @@ export class SearchPageComponent implements OnInit {
|
||||
.pipe(takeUntilDestroyed(this.destroy$))
|
||||
.subscribe(item => {
|
||||
if (this.itemRouting) {
|
||||
void this.router.navigate(['/data-detail', item.uid]);
|
||||
void this.router.navigate(['/data-detail', item.uid], {state: {item}});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ export class SimpleDataListComponent implements OnInit {
|
||||
.itemSelectListener()
|
||||
.pipe(takeUntilDestroyed(this.destroy$))
|
||||
.subscribe(item => {
|
||||
void this.router.navigate(['/data-detail', item.uid]);
|
||||
void this.router.navigate(['/data-detail', item.uid], {state: {item}});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user