mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-18 23:52:52 +00:00
Compare commits
21 Commits
@openstapp
...
143-add-we
| Author | SHA1 | Date | |
|---|---|---|---|
|
829350e6aa
|
|||
|
b5ddb323e6
|
|||
|
e9630ce95e
|
|||
|
a0415df09d
|
|||
|
3b73ec1298
|
|||
|
0477c3d69e
|
|||
|
879ccc5031
|
|||
|
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
|
||||||
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
|
||||||
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
|
||||||
@@ -32,7 +32,7 @@ variables:
|
|||||||
default:
|
default:
|
||||||
image: registry.gitlab.com/openstapps/openstapps/node-builder
|
image: registry.gitlab.com/openstapps/openstapps/node-builder
|
||||||
tags:
|
tags:
|
||||||
- performance
|
- saas-linux-xlarge-amd64
|
||||||
interruptible: true
|
interruptible: true
|
||||||
before_script:
|
before_script:
|
||||||
- corepack enable
|
- corepack enable
|
||||||
@@ -80,7 +80,7 @@ build:
|
|||||||
rules: &deploy-rules
|
rules: &deploy-rules
|
||||||
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
|
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
|
||||||
variables:
|
variables:
|
||||||
DEPLOY_ID: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
|
DEPLOY_ID: $CI_MERGE_REQUEST_IID
|
||||||
- if: $CI_COMMIT_BRANCH == 'main'
|
- if: $CI_COMMIT_BRANCH == 'main'
|
||||||
variables:
|
variables:
|
||||||
DEPLOY_ID: production
|
DEPLOY_ID: production
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
.limit_publish_pipelines:
|
.limit_publish_pipelines:
|
||||||
rules:
|
rules:
|
||||||
- if: '($CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "develop") && $CI_COMMIT_MESSAGE =~ /^ci: publish release/ && $CI_PIPELINE_SOURCE != "schedule"'
|
- if: '($CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "develop") && $CI_COMMIT_MESSAGE =~ /ci: publish release/ && $CI_PIPELINE_SOURCE != "schedule"'
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
stage: publish
|
stage: publish
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ base image:
|
|||||||
docker build
|
docker build
|
||||||
-t "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:$(grep -o '"version": "[^"]*' "${DEPLOY_DIR}/package.json" | cut -d'"' -f4)"
|
-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}" &&
|
-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
|
cache: {} # disable irrelevant cache for this job
|
||||||
before_script: [] # do not run irrelevant before script for this job
|
before_script: [] # do not run irrelevant before script for this job
|
||||||
parallel:
|
parallel:
|
||||||
@@ -29,5 +29,7 @@ base image:
|
|||||||
DEPLOY_DIR: images/node-builder
|
DEPLOY_DIR: images/node-builder
|
||||||
- IMAGE_NAME: app-builder
|
- IMAGE_NAME: app-builder
|
||||||
DEPLOY_DIR: images/app-builder
|
DEPLOY_DIR: images/app-builder
|
||||||
|
- IMAGE_NAME: app-cypress
|
||||||
|
DEPLOY_DIR: images/app-cypress
|
||||||
rules:
|
rules:
|
||||||
- !reference [.limit_scheduled_pipelines, rules]
|
- !reference [.limit_scheduled_pipelines, rules]
|
||||||
@@ -15,8 +15,12 @@
|
|||||||
buildToolsVersions = [ "${buildToolsVersion}" ];
|
buildToolsVersions = [ "${buildToolsVersion}" ];
|
||||||
platformVersions = [ "32" ];
|
platformVersions = [ "32" ];
|
||||||
};
|
};
|
||||||
cypress = prev.cypress.overrideAttrs(prev: {
|
cypress = prev.cypress.overrideAttrs(cyPrev: rec {
|
||||||
version = "12.17.1";
|
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": {
|
"parserOptions": {
|
||||||
"ecmaVersion": 2020,
|
"ecmaVersion": 2020,
|
||||||
"sourceType": "module",
|
"sourceType": "module",
|
||||||
"project": ["tsconfig.json", "tsconfig.spec.json", "e2e/tsconfig.e2e.json"],
|
"project": ["tsconfig.json", "tsconfig.spec.json", "cypress/tsconfig.json"],
|
||||||
"createDefaultProgram": true
|
"createDefaultProgram": true
|
||||||
},
|
},
|
||||||
"extends": [
|
"extends": [
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
e2e:
|
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
|
stage: test
|
||||||
script:
|
script:
|
||||||
- pnpm --filter=@openstapps/app install
|
- pnpm --filter=@openstapps/app install
|
||||||
- pnpm --filter=@openstapps/app exec cypress install
|
- pnpm --filter=@openstapps/app exec cypress install
|
||||||
|
- npx playwright install-deps webkit
|
||||||
|
- npx playwright install
|
||||||
|
- cd node_modules/.pnpm/re2*/node_modules/re2
|
||||||
|
- npm run install
|
||||||
|
- cd $CI_PROJECT_DIR
|
||||||
- pnpm test:integration:app
|
- pnpm test:integration:app
|
||||||
artifacts:
|
artifacts:
|
||||||
when: on_failure
|
when: on_failure
|
||||||
@@ -18,5 +23,6 @@ e2e:
|
|||||||
matrix:
|
matrix:
|
||||||
- BROWSER: chrome
|
- BROWSER: chrome
|
||||||
- BROWSER: firefox
|
- BROWSER: firefox
|
||||||
|
- BROWSER: webkit
|
||||||
rules:
|
rules:
|
||||||
- !reference [.limit_pipelines, rules]
|
- !reference [.limit_pipelines, rules]
|
||||||
|
|||||||
@@ -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"`
|
- 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.
|
- 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",
|
"builder": "@cypress/schematic:cypress",
|
||||||
"options": {
|
"options": {
|
||||||
"devServerTarget": "app:serve",
|
"devServerTarget": "app:serve",
|
||||||
|
"liveReload": false,
|
||||||
"watch": true,
|
"watch": true,
|
||||||
"headless": false
|
"headless": false
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ export default defineConfig({
|
|||||||
fixturesFolder: 'cypress/fixtures',
|
fixturesFolder: 'cypress/fixtures',
|
||||||
defaultCommandTimeout: 20_000,
|
defaultCommandTimeout: 20_000,
|
||||||
specPattern: 'cypress/integration/**/*.spec.ts',
|
specPattern: 'cypress/integration/**/*.spec.ts',
|
||||||
|
experimentalWebKitSupport: true,
|
||||||
/*setupNodeEvents(on, config) {
|
/*setupNodeEvents(on, config) {
|
||||||
on('task', {
|
on('task', {
|
||||||
log(message) {
|
log(message) {
|
||||||
|
|||||||
@@ -18,14 +18,18 @@
|
|||||||
|
|
||||||
describe('dashboard', async function () {
|
describe('dashboard', async function () {
|
||||||
describe('schedule section', function () {
|
describe('schedule section', function () {
|
||||||
it('should lead to the schedule', function () {
|
it('should lead to the week overview', function () {
|
||||||
cy.visit('/overview');
|
cy.visit('/overview');
|
||||||
cy.get('.schedule').contains('a', 'Stundenplan').click();
|
cy.get('.schedule')
|
||||||
cy.url().should('include', '/schedule/recurring');
|
.contains('a', /Wochen.*übersicht/)
|
||||||
|
.click();
|
||||||
|
cy.url().should('include', '/schedule/week-overview');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should lead to the calendar', function () {
|
||||||
cy.visit('/overview');
|
cy.visit('/overview');
|
||||||
cy.get('.schedule').contains('a', 'Kein Eintrag gefunden').click();
|
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
|
// TODO: Reenable and stabilize tests
|
||||||
@@ -172,7 +176,7 @@ describe('dashboard', async function () {
|
|||||||
cy.visit('/overview');
|
cy.visit('/overview');
|
||||||
|
|
||||||
cy.get('ion-searchbar').click({scrollBehavior: 'center'});
|
cy.get('ion-searchbar').click({scrollBehavior: 'center'});
|
||||||
cy.url().should('eq', Cypress.config().baseUrl + '/search');
|
cy.url().should('eq', `${Cypress.config().baseUrl?.replace(/\/$/, '')}/search`);
|
||||||
cy.get('ion-searchbar').should('not.have.value');
|
cy.get('ion-searchbar').should('not.have.value');
|
||||||
cy.get('ion-searchbar input.searchbar-input').should('have.focus');
|
cy.get('ion-searchbar input.searchbar-input').should('have.focus');
|
||||||
|
|
||||||
|
|||||||
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');
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -31,36 +31,24 @@
|
|||||||
// When a command from ./commands is ready to use, import with `import './commands'` syntax
|
// When a command from ./commands is ready to use, import with `import './commands'` syntax
|
||||||
// import './commands';
|
// import './commands';
|
||||||
|
|
||||||
beforeEach(async function () {
|
beforeEach(function () {
|
||||||
let databases: string[];
|
cy.wrap(
|
||||||
if (window.indexedDB.databases) {
|
new Promise(resolve => {
|
||||||
databases = (await window.indexedDB.databases()).map(it => it.name);
|
window.indexedDB.deleteDatabase('_ionicstorage').onsuccess = resolve;
|
||||||
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}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Cypress.on('window:before:load', window => {
|
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, 'language', {value: 'de-DE'});
|
||||||
Object.defineProperty(window.navigator, 'languages', [{value: 'de-DE'}]);
|
Object.defineProperty(window.navigator, 'languages', [{value: 'de-DE'}]);
|
||||||
|
|
||||||
// Fail tests on console error
|
cy.spy(window.console, 'error').as('consoleError');
|
||||||
cy.stub(window.console, 'error').callsFake(message => {
|
});
|
||||||
// log out to the terminal
|
|
||||||
cy.now('task', 'error', message);
|
afterEach(function () {
|
||||||
// log to Command Log and fail the test
|
cy.get('@consoleError').should('not.have.been.called');
|
||||||
throw new Error(message);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Cypress.on('uncaught:exception', error => {
|
Cypress.on('uncaught:exception', error => {
|
||||||
|
|||||||
@@ -63,6 +63,7 @@
|
|||||||
"@awesome-cordova-plugins/core": "5.45.0",
|
"@awesome-cordova-plugins/core": "5.45.0",
|
||||||
"@capacitor/app": "4.1.1",
|
"@capacitor/app": "4.1.1",
|
||||||
"@capacitor/browser": "4.1.0",
|
"@capacitor/browser": "4.1.0",
|
||||||
|
"@capacitor/clipboard": "4.1.0",
|
||||||
"@capacitor/core": "4.6.1",
|
"@capacitor/core": "4.6.1",
|
||||||
"@capacitor/device": "4.1.0",
|
"@capacitor/device": "4.1.0",
|
||||||
"@capacitor/dialog": "4.1.0",
|
"@capacitor/dialog": "4.1.0",
|
||||||
@@ -87,8 +88,11 @@
|
|||||||
"@openstapps/collection-utils": "workspace:*",
|
"@openstapps/collection-utils": "workspace:*",
|
||||||
"@openstapps/core": "workspace:*",
|
"@openstapps/core": "workspace:*",
|
||||||
"@transistorsoft/capacitor-background-fetch": "1.0.2",
|
"@transistorsoft/capacitor-background-fetch": "1.0.2",
|
||||||
|
"@types/dom-view-transitions": "1.0.1",
|
||||||
"capacitor-secure-storage-plugin": "0.8.1",
|
"capacitor-secure-storage-plugin": "0.8.1",
|
||||||
"cordova-plugin-calendar": "5.1.6",
|
"cordova-plugin-calendar": "5.1.6",
|
||||||
|
"date-fns": "2.30.0",
|
||||||
|
"ngx-date-fns": "10.0.1",
|
||||||
"deepmerge": "4.3.1",
|
"deepmerge": "4.3.1",
|
||||||
"form-data": "4.0.0",
|
"form-data": "4.0.0",
|
||||||
"geojson": "0.5.0",
|
"geojson": "0.5.0",
|
||||||
@@ -126,7 +130,7 @@
|
|||||||
"@capacitor/cli": "4.6.1",
|
"@capacitor/cli": "4.6.1",
|
||||||
"@capacitor/ios": "4.6.1",
|
"@capacitor/ios": "4.6.1",
|
||||||
"@compodoc/compodoc": "1.1.19",
|
"@compodoc/compodoc": "1.1.19",
|
||||||
"@cypress/schematic": "1.7.0",
|
"@cypress/schematic": "2.5.1",
|
||||||
"@ionic/angular-toolkit": "10.0.0",
|
"@ionic/angular-toolkit": "10.0.0",
|
||||||
"@ionic/cli": "7.1.1",
|
"@ionic/cli": "7.1.1",
|
||||||
"@openstapps/prettier-config": "workspace:*",
|
"@openstapps/prettier-config": "workspace:*",
|
||||||
@@ -146,7 +150,7 @@
|
|||||||
"@typescript-eslint/eslint-plugin": "5.60.1",
|
"@typescript-eslint/eslint-plugin": "5.60.1",
|
||||||
"@typescript-eslint/parser": "5.60.1",
|
"@typescript-eslint/parser": "5.60.1",
|
||||||
"cordova-res": "0.15.4",
|
"cordova-res": "0.15.4",
|
||||||
"cypress": "12.17.1",
|
"cypress": "13.2.0",
|
||||||
"eslint": "8.43.0",
|
"eslint": "8.43.0",
|
||||||
"eslint-plugin-jsdoc": "46.4.2",
|
"eslint-plugin-jsdoc": "46.4.2",
|
||||||
"eslint-plugin-prettier": "4.2.1",
|
"eslint-plugin-prettier": "4.2.1",
|
||||||
@@ -166,6 +170,7 @@
|
|||||||
"karma-junit-reporter": "2.0.1",
|
"karma-junit-reporter": "2.0.1",
|
||||||
"karma-mocha-reporter": "2.2.5",
|
"karma-mocha-reporter": "2.2.5",
|
||||||
"license-checker": "25.0.1",
|
"license-checker": "25.0.1",
|
||||||
|
"playwright-webkit": "1.38.0",
|
||||||
"stylelint": "15.10.1",
|
"stylelint": "15.10.1",
|
||||||
"stylelint-config-clean-order": "5.0.1",
|
"stylelint-config-clean-order": "5.0.1",
|
||||||
"stylelint-config-prettier-scss": "1.0.0",
|
"stylelint-config-prettier-scss": "1.0.0",
|
||||||
|
|||||||
@@ -58,12 +58,15 @@ import {StorageProvider} from './modules/storage/storage.provider';
|
|||||||
import {AssessmentsModule} from './modules/assessments/assessments.module';
|
import {AssessmentsModule} from './modules/assessments/assessments.module';
|
||||||
import {ServiceHandlerInterceptor} from './_helpers/service-handler.interceptor';
|
import {ServiceHandlerInterceptor} from './_helpers/service-handler.interceptor';
|
||||||
import {RoutingStackService} from './util/routing-stack.service';
|
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 {DefaultAuthService} from './modules/auth/default-auth.service';
|
||||||
import {PAIAAuthService} from './modules/auth/paia/paia-auth.service';
|
import {PAIAAuthService} from './modules/auth/paia/paia-auth.service';
|
||||||
import {IonIconModule} from './util/ion-icon/ion-icon.module';
|
import {IonIconModule} from './util/ion-icon/ion-icon.module';
|
||||||
import {NavigationModule} from './modules/menu/navigation/navigation.module';
|
import {NavigationModule} from './modules/menu/navigation/navigation.module';
|
||||||
import {browserFactory, SimpleBrowser} from './util/browser.factory';
|
import {browserFactory, SimpleBrowser} from './util/browser.factory';
|
||||||
|
import {getDateFnsLocale} from './translation/dfns-locale';
|
||||||
|
import {setDefaultOptions} from 'date-fns';
|
||||||
|
import {DateFnsConfigurationService} from 'ngx-date-fns';
|
||||||
|
|
||||||
registerLocaleData(localeDe);
|
registerLocaleData(localeDe);
|
||||||
|
|
||||||
@@ -71,12 +74,6 @@ SwiperCore.use([FreeMode, Navigation]);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes data needed on startup
|
* 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(
|
export function initializerFactory(
|
||||||
storageProvider: StorageProvider,
|
storageProvider: StorageProvider,
|
||||||
@@ -87,6 +84,7 @@ export function initializerFactory(
|
|||||||
_routingStackService: RoutingStackService,
|
_routingStackService: RoutingStackService,
|
||||||
defaultAuthService: DefaultAuthService,
|
defaultAuthService: DefaultAuthService,
|
||||||
paiaAuthService: PAIAAuthService,
|
paiaAuthService: PAIAAuthService,
|
||||||
|
dateFnsConfigurationService: DateFnsConfigurationService,
|
||||||
) {
|
) {
|
||||||
return async () => {
|
return async () => {
|
||||||
initLogger(logger);
|
initLogger(logger);
|
||||||
@@ -107,6 +105,10 @@ export function initializerFactory(
|
|||||||
translateService.setDefaultLang('en');
|
translateService.setDefaultLang('en');
|
||||||
translateService.use(languageCode);
|
translateService.use(languageCode);
|
||||||
moment.locale(languageCode);
|
moment.locale(languageCode);
|
||||||
|
const dateFnsLocale = await getDateFnsLocale(languageCode as SCLanguageCode);
|
||||||
|
setDefaultOptions({locale: dateFnsLocale});
|
||||||
|
dateFnsConfigurationService.setLocale(dateFnsLocale);
|
||||||
|
|
||||||
await defaultAuthService.init();
|
await defaultAuthService.init();
|
||||||
await paiaAuthService.init();
|
await paiaAuthService.init();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -198,6 +200,7 @@ export function createTranslateLoader(http: HttpClient) {
|
|||||||
RoutingStackService,
|
RoutingStackService,
|
||||||
DefaultAuthService,
|
DefaultAuthService,
|
||||||
PAIAAuthService,
|
PAIAAuthService,
|
||||||
|
DateFnsConfigurationService,
|
||||||
],
|
],
|
||||||
useFactory: initializerFactory,
|
useFactory: initializerFactory,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import {Component, DestroyRef, inject, Input, OnInit, ViewChild} from '@angular/
|
|||||||
import {ActivatedRoute} from '@angular/router';
|
import {ActivatedRoute} from '@angular/router';
|
||||||
import {AssessmentsProvider} from '../assessments.provider';
|
import {AssessmentsProvider} from '../assessments.provider';
|
||||||
import {DataDetailComponent, ExternalDataLoadEvent} from '../../data/detail/data-detail.component';
|
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 {DataRoutingService} from '../../data/data-routing.service';
|
||||||
import {SCAssessment} from '@openstapps/core';
|
import {SCAssessment} from '@openstapps/core';
|
||||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
@@ -27,7 +27,7 @@ import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
|||||||
templateUrl: 'assessments-detail.html',
|
templateUrl: 'assessments-detail.html',
|
||||||
styleUrls: ['assessments-detail.scss'],
|
styleUrls: ['assessments-detail.scss'],
|
||||||
})
|
})
|
||||||
export class AssessmentsDetailComponent implements ViewWillEnter, OnInit {
|
export class AssessmentsDetailComponent implements OnInit {
|
||||||
destroy$ = inject(DestroyRef);
|
destroy$ = inject(DestroyRef);
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@@ -67,8 +67,4 @@ export class AssessmentsDetailComponent implements ViewWillEnter, OnInit {
|
|||||||
event.resolve(this.item);
|
event.resolve(this.item);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async ionViewWillEnter() {
|
|
||||||
await this.detailComponent.ionViewWillEnter();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ export class AssessmentsSimpleDataListComponent implements OnInit {
|
|||||||
queryParams: {
|
queryParams: {
|
||||||
token: this.activatedRoute.snapshot.queryParamMap.get('token'),
|
token: this.activatedRoute.snapshot.queryParamMap.get('token'),
|
||||||
},
|
},
|
||||||
|
state: {item: thing},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ export class AssessmentsPageComponent implements OnInit, AfterViewInit {
|
|||||||
queryParams: {
|
queryParams: {
|
||||||
token: this.activatedRoute.snapshot.queryParamMap.get('token'),
|
token: this.activatedRoute.snapshot.queryParamMap.get('token'),
|
||||||
},
|
},
|
||||||
|
state: {item: thing},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ export class CatalogComponent implements OnInit {
|
|||||||
.itemSelectListener()
|
.itemSelectListener()
|
||||||
.pipe(takeUntilDestroyed())
|
.pipe(takeUntilDestroyed())
|
||||||
.subscribe(item => {
|
.subscribe(item => {
|
||||||
void this.router.navigate(['data-detail', item.uid]);
|
void this.router.navigate(['data-detail', item.uid], {state: {item}});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,19 +19,20 @@
|
|||||||
</ion-toolbar>
|
</ion-toolbar>
|
||||||
</ion-header>
|
</ion-header>
|
||||||
<div #schedule class="schedule">
|
<div #schedule class="schedule">
|
||||||
<a [routerLink]="['/schedule/recurring']">
|
<a [routerLink]="['/schedule/week-overview']">
|
||||||
<ion-icon size="40" weight="300" name="grid_view"></ion-icon>
|
<ion-icon size="36" weight="300" name="calendar_month"></ion-icon>
|
||||||
<ion-label>{{ 'schedule.recurring' | translate }}</ion-label>
|
<ion-label [innerHTML]="'schedule.recurring' | translate"></ion-label>
|
||||||
</a>
|
</a>
|
||||||
<!-- Avoid structural directives here, they might interfere with the collapse animation -->
|
<!-- Avoid structural directives here, they might interfere with the collapse animation -->
|
||||||
<a
|
<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"
|
class="schedule-item-button"
|
||||||
>
|
>
|
||||||
<ion-label>{{ 'dashboard.schedule.title' | translate }}</ion-label>
|
<ion-label>{{ 'dashboard.schedule.title' | translate }}</ion-label>
|
||||||
<ion-label>
|
<ion-label>
|
||||||
{{
|
{{
|
||||||
nextEvent?.event
|
nextEvent
|
||||||
? (nextEvent!.dates | nextDateInList | amDateFormat : 'll, HH:mm')
|
? (nextEvent!.dates | nextDateInList | amDateFormat : 'll, HH:mm')
|
||||||
: ('dashboard.schedule.noEvent' | translate)
|
: ('dashboard.schedule.noEvent' | translate)
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ ion-content {
|
|||||||
ion-label {
|
ion-label {
|
||||||
font-size: var(--font-size-xxs);
|
font-size: var(--font-size-xxs);
|
||||||
font-weight: var(--font-weight-semi-bold);
|
font-weight: var(--font-weight-semi-bold);
|
||||||
|
word-break: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover ::ng-deep stapps-icon {
|
&:hover ::ng-deep stapps-icon {
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
|||||||
.itemSelectListener()
|
.itemSelectListener()
|
||||||
.pipe(takeUntilDestroyed())
|
.pipe(takeUntilDestroyed())
|
||||||
.subscribe(item => {
|
.subscribe(item => {
|
||||||
void this.router.navigate(['data-detail', item.uid]);
|
void this.router.navigate(['data-detail', item.uid], {state: {item}});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
<stapps-data-list-item
|
<stapps-data-list-item
|
||||||
*ngFor="let dish of dishes"
|
*ngFor="let dish of dishes"
|
||||||
[hideThumbnail]="true"
|
[hideThumbnail]="true"
|
||||||
[favoriteButton]="false"
|
|
||||||
[item]="dish"
|
[item]="dish"
|
||||||
appearance="square"
|
appearance="square"
|
||||||
></stapps-data-list-item>
|
></stapps-data-list-item>
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ export class ActionChipListComponent {
|
|||||||
event:
|
event:
|
||||||
item.type === SCThingType.AcademicEvent ||
|
item.type === SCThingType.AcademicEvent ||
|
||||||
(item.type === SCThingType.DateSeries && (item as SCDateSeries).dates.length > 0),
|
(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-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 -->
|
<!-- 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>
|
<stapps-add-event-action-chip *ngIf="applicable.event" [item]="item"></stapps-add-event-action-chip>
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
import {Component, Input} from '@angular/core';
|
||||||
|
import {SCPlaceWithoutReferences, SCThings} from '@openstapps/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'stapps-navigate-action-chip',
|
||||||
|
templateUrl: 'navigate-action-chip.html',
|
||||||
|
styleUrls: ['navigate-action-chip.scss'],
|
||||||
|
})
|
||||||
|
export class NavigateActionChipComponent {
|
||||||
|
place: SCPlaceWithoutReferences;
|
||||||
|
|
||||||
|
@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
|
~ 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
|
~ under the terms of the GNU General Public License as published by the Free
|
||||||
~ Software Foundation, version 3.
|
~ Software Foundation, version 3.
|
||||||
@@ -12,15 +12,7 @@
|
|||||||
~ You should have received a copy of the GNU General Public License along with
|
~ You should have received a copy of the GNU General Public License along with
|
||||||
~ this program. If not, see <https://www.gnu.org/licenses/>.
|
~ this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
|
<ion-chip [color]="'primary'" [outline]="true" [geoNavigation]="place">
|
||||||
<ion-header translucent>
|
<ion-icon name="directions"></ion-icon>
|
||||||
<ion-toolbar color="primary" mode="ios">
|
<ion-label>{{'map.directions.TITLE' | translate}}</ion-label>
|
||||||
<ion-title>{{ 'map.modals.single.TITLE' | translate }}</ion-title>
|
</ion-chip>
|
||||||
<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>
|
|
||||||
@@ -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
|
* 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
|
* under the terms of the GNU General Public License as published by the Free
|
||||||
* Software Foundation, version 3.
|
* Software Foundation, version 3.
|
||||||
@@ -12,20 +12,3 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* 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';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-map-single-modal',
|
|
||||||
templateUrl: './map-single.html',
|
|
||||||
styleUrls: ['./map-single.scss'],
|
|
||||||
})
|
|
||||||
export class MapSingleModalComponent {
|
|
||||||
/**
|
|
||||||
* The item to be shown
|
|
||||||
*/
|
|
||||||
@Input() item: SCPlace;
|
|
||||||
|
|
||||||
constructor(readonly modalController: ModalController) {}
|
|
||||||
}
|
|
||||||
@@ -102,6 +102,8 @@ import {StappsRatingComponent} from './elements/rating.component';
|
|||||||
import {DishCharacteristicsComponent} from './types/dish/dish-characteristics.component';
|
import {DishCharacteristicsComponent} from './types/dish/dish-characteristics.component';
|
||||||
import {SkeletonListComponent} from './list/skeleton-list.component';
|
import {SkeletonListComponent} from './list/skeleton-list.component';
|
||||||
import {CertificationsInDetailComponent} from './elements/certifications-in-detail.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';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module for handling data
|
* Module for handling data
|
||||||
@@ -110,6 +112,7 @@ import {CertificationsInDetailComponent} from './elements/certifications-in-deta
|
|||||||
declarations: [
|
declarations: [
|
||||||
ActionChipListComponent,
|
ActionChipListComponent,
|
||||||
AddEventActionChipComponent,
|
AddEventActionChipComponent,
|
||||||
|
NavigateActionChipComponent,
|
||||||
EditEventSelectionComponent,
|
EditEventSelectionComponent,
|
||||||
AddressDetailComponent,
|
AddressDetailComponent,
|
||||||
CatalogDetailContentComponent,
|
CatalogDetailContentComponent,
|
||||||
@@ -194,6 +197,7 @@ import {CertificationsInDetailComponent} from './elements/certifications-in-deta
|
|||||||
TranslateModule.forChild(),
|
TranslateModule.forChild(),
|
||||||
ThingTranslateModule.forChild(),
|
ThingTranslateModule.forChild(),
|
||||||
UtilModule,
|
UtilModule,
|
||||||
|
GeoNavigationDirective,
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
CoordinatedSearchProvider,
|
CoordinatedSearchProvider,
|
||||||
|
|||||||
@@ -111,8 +111,8 @@ describe('DataDetailComponent', () => {
|
|||||||
expect(DataDetailComponent.prototype.getItem).toHaveBeenCalledWith(sampleThing.uid, false);
|
expect(DataDetailComponent.prototype.getItem).toHaveBeenCalledWith(sampleThing.uid, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get a data item when the view is entered', () => {
|
it('should get a data item when initialized', () => {
|
||||||
comp.ionViewWillEnter();
|
comp.ngOnInit();
|
||||||
expect(DataDetailComponent.prototype.getItem).toHaveBeenCalledWith(sampleThing.uid, false);
|
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
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {Component, ContentChild, EventEmitter, Input, Output, TemplateRef} from '@angular/core';
|
import {Component, ContentChild, EventEmitter, Input, OnInit, Output, TemplateRef} from '@angular/core';
|
||||||
import {ActivatedRoute} from '@angular/router';
|
import {ActivatedRoute, Router} from '@angular/router';
|
||||||
import {ModalController, ViewWillEnter} from '@ionic/angular';
|
import {ModalController} from '@ionic/angular';
|
||||||
import {LangChangeEvent, TranslateService} from '@ngx-translate/core';
|
import {LangChangeEvent, TranslateService} from '@ngx-translate/core';
|
||||||
import {SCLanguageCode, SCSaveableThing, SCThings, SCUuid} from '@openstapps/core';
|
import {SCLanguageCode, SCSaveableThing, SCThings, SCUuid} from '@openstapps/core';
|
||||||
import {DataProvider, DataScope} from '../data.provider';
|
import {DataProvider, DataScope} from '../data.provider';
|
||||||
@@ -37,7 +37,7 @@ export interface ExternalDataLoadEvent {
|
|||||||
styleUrls: ['data-detail.scss'],
|
styleUrls: ['data-detail.scss'],
|
||||||
templateUrl: 'data-detail.html',
|
templateUrl: 'data-detail.html',
|
||||||
})
|
})
|
||||||
export class DataDetailComponent implements ViewWillEnter {
|
export class DataDetailComponent implements OnInit {
|
||||||
/**
|
/**
|
||||||
* The associated item
|
* The associated item
|
||||||
*
|
*
|
||||||
@@ -84,21 +84,15 @@ export class DataDetailComponent implements ViewWillEnter {
|
|||||||
return (thing as SCSaveableThing).data !== undefined;
|
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(
|
constructor(
|
||||||
protected readonly route: ActivatedRoute,
|
protected readonly route: ActivatedRoute,
|
||||||
|
router: Router,
|
||||||
private readonly dataProvider: DataProvider,
|
private readonly dataProvider: DataProvider,
|
||||||
private readonly favoritesService: FavoritesService,
|
private readonly favoritesService: FavoritesService,
|
||||||
readonly modalController: ModalController,
|
readonly modalController: ModalController,
|
||||||
translateService: TranslateService,
|
translateService: TranslateService,
|
||||||
) {
|
) {
|
||||||
|
this.inputItem = router.getCurrentNavigation()?.extras.state?.item;
|
||||||
this.language = translateService.currentLang as SCLanguageCode;
|
this.language = translateService.currentLang as SCLanguageCode;
|
||||||
translateService.onLangChange.subscribe((event: LangChangeEvent) => {
|
translateService.onLangChange.subscribe((event: LangChangeEvent) => {
|
||||||
this.language = event.lang as SCLanguageCode;
|
this.language = event.lang as SCLanguageCode;
|
||||||
@@ -138,10 +132,7 @@ export class DataDetailComponent implements ViewWillEnter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
async ngOnInit() {
|
||||||
* Initialize
|
|
||||||
*/
|
|
||||||
async ionViewWillEnter() {
|
|
||||||
const uid = this.route.snapshot.paramMap.get('uid') || '';
|
const uid = this.route.snapshot.paramMap.get('uid') || '';
|
||||||
await this.getItem(uid ?? '', false);
|
await this.getItem(uid ?? '', false);
|
||||||
// fallback to the saved item (from favorites)
|
// fallback to the saved item (from favorites)
|
||||||
|
|||||||
@@ -37,32 +37,22 @@ export class DataPathComponent implements OnInit {
|
|||||||
@Input() maxItems = 2;
|
@Input() maxItems = 2;
|
||||||
|
|
||||||
@Input() set item(item: SCThings) {
|
@Input() set item(item: SCThings) {
|
||||||
// eslint-disable-next-line unicorn/prefer-ternary
|
|
||||||
if (item.type === SCThingType.Catalog && item.superCatalogs) {
|
if (item.type === SCThingType.Catalog && item.superCatalogs) {
|
||||||
this.path = new Promise(resolve =>
|
this.path = Promise.resolve([...item.superCatalogs!, item]);
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
||||||
resolve([...item.superCatalogs!, item]),
|
|
||||||
);
|
|
||||||
} else if (item.type === SCThingType.Assessment && item.superAssessments) {
|
} else if (item.type === SCThingType.Assessment && item.superAssessments) {
|
||||||
this.path = new Promise(resolve =>
|
this.path = Promise.resolve([...item.superAssessments!, item]);
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
||||||
resolve([...item.superAssessments!, item]),
|
|
||||||
);
|
|
||||||
} else if (
|
} else if (
|
||||||
item.type === SCThingType.AcademicEvent &&
|
item.type === SCThingType.AcademicEvent &&
|
||||||
item.catalogs &&
|
item.catalogs &&
|
||||||
(item.catalogs.length === 1 || this.routeStack.lastDataDetail)
|
(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 => {
|
this.path = new Promise(async resolve => {
|
||||||
const catalog = await catalogPromise;
|
const catalogWithoutReferences = item.catalogs![0];
|
||||||
const superCatalogs = catalog.superCatalogs;
|
const catalog =
|
||||||
|
item.catalogs!.length === 1
|
||||||
|
? await this.dataProvider.get(catalogWithoutReferences.uid, DataScope.Remote)
|
||||||
|
: this.routeStack.lastDataDetail;
|
||||||
|
const superCatalogs = (catalog as SCCatalog).superCatalogs;
|
||||||
|
|
||||||
resolve(
|
resolve(
|
||||||
superCatalogs
|
superCatalogs
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable unicorn/no-useless-undefined */
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2023 StApps
|
* Copyright (C) 2023 StApps
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* 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
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {Component, ElementRef, HostListener, Input} from '@angular/core';
|
import {ChangeDetectionStrategy, Component, ElementRef, HostListener, Input} from '@angular/core';
|
||||||
import {SCDish, SCRatingRequest, SCUuid} from '@openstapps/core';
|
import {SCDish, SCRatingRequest} from '@openstapps/core';
|
||||||
import {RatingProvider} from '../rating.provider';
|
import {RatingProvider} from '../rating.provider';
|
||||||
import {ratingAnimation} from './rating.animation';
|
import {ratingAnimation} from './rating.animation';
|
||||||
|
import {BehaviorSubject, filter, merge, mergeMap, of, ReplaySubject, withLatestFrom} from 'rxjs';
|
||||||
|
import {catchError, map} from 'rxjs/operators';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'stapps-rating',
|
selector: 'stapps-rating',
|
||||||
templateUrl: 'rating.html',
|
templateUrl: 'rating.html',
|
||||||
styleUrls: ['rating.scss'],
|
styleUrls: ['rating.scss'],
|
||||||
animations: [ratingAnimation],
|
animations: [ratingAnimation],
|
||||||
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class StappsRatingComponent {
|
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) {
|
@Input({required: true}) set item(value: SCDish) {
|
||||||
this.uid = value.uid;
|
this.dish.next(value);
|
||||||
|
|
||||||
Promise.all([this.ratingProvider.canRate(value), this.ratingProvider.hasRated(this.uid)] as const).then(
|
|
||||||
([canRate, hasRated]) => {
|
|
||||||
this.canBeRated = canRate;
|
|
||||||
this.rated = hasRated;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(readonly elementRef: ElementRef, readonly ratingProvider: RatingProvider) {}
|
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'])
|
@HostListener('document:mousedown', ['$event'])
|
||||||
clickOutside(event: MouseEvent) {
|
clickOutside(event: MouseEvent) {
|
||||||
if (this.rating) return;
|
if (this.userRating.value) return;
|
||||||
if (!this.elementRef.nativeElement.contains(event.target)) {
|
if (!this.elementRef.nativeElement.contains(event.target)) {
|
||||||
this.rate = false;
|
this.performRating.next(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,19 +14,23 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<ion-button
|
<ion-button
|
||||||
*ngIf="canBeRated"
|
*ngIf="canBeRated | async"
|
||||||
fill="clear"
|
fill="clear"
|
||||||
(click)="$event.stopPropagation(); rate = true"
|
(click)="$event.stopPropagation(); performRating.next(true)"
|
||||||
[disabled]="rated"
|
[disabled]="wasAlreadyRated | async"
|
||||||
>
|
>
|
||||||
<ion-icon slot="icon-only" color="medium" name="thumbs_up_down"></ion-icon>
|
<ion-icon slot="icon-only" color="medium" name="thumbs_up_down"></ion-icon>
|
||||||
</ion-button>
|
</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
|
<ion-icon
|
||||||
[class.rated-value]="rating === i"
|
[class.rated-value]="(userRating | async) === i"
|
||||||
*ngFor="let i of [5, 4, 3, 2, 1]"
|
*ngFor="let i of [5, 4, 3, 2, 1]"
|
||||||
(click)="$event.stopPropagation(); submitRating(i)"
|
(click)="$event.stopPropagation(); userRating.next(i)"
|
||||||
slot="icon-only"
|
slot="icon-only"
|
||||||
size="32"
|
size="32"
|
||||||
color="medium"
|
color="medium"
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ export class DataListItemComponent {
|
|||||||
|
|
||||||
@Input() listItemEndInteraction = true;
|
@Input() listItemEndInteraction = true;
|
||||||
|
|
||||||
|
@Input() listItemChipInteraction = true;
|
||||||
|
|
||||||
@Input() lines = 'inset';
|
@Input() lines = 'inset';
|
||||||
|
|
||||||
@Input() forceHeight = false;
|
@Input() forceHeight = false;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<ng-template [dataListItemHost]="item"></ng-template>
|
<ng-template [dataListItemHost]="item"></ng-template>
|
||||||
<stapps-action-chip-list
|
<stapps-action-chip-list
|
||||||
*ngIf="appearance !== 'square'"
|
*ngIf="listItemChipInteraction && appearance !== 'square'"
|
||||||
slot="end"
|
slot="end"
|
||||||
[item]="item"
|
[item]="item"
|
||||||
></stapps-action-chip-list>
|
></stapps-action-chip-list>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import {MapPosition} from '../../map/position.service';
|
|||||||
import {SearchPageComponent} from './search-page.component';
|
import {SearchPageComponent} from './search-page.component';
|
||||||
import {Geolocation} from '@capacitor/geolocation';
|
import {Geolocation} from '@capacitor/geolocation';
|
||||||
import {BehaviorSubject} from 'rxjs';
|
import {BehaviorSubject} from 'rxjs';
|
||||||
import {pauseWhen} from '../../../util/pause-when';
|
import {pauseWhen} from '../../../util/rxjs/pause-when';
|
||||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -342,7 +342,7 @@ export class SearchPageComponent implements OnInit {
|
|||||||
.pipe(takeUntilDestroyed(this.destroy$))
|
.pipe(takeUntilDestroyed(this.destroy$))
|
||||||
.subscribe(item => {
|
.subscribe(item => {
|
||||||
if (this.itemRouting) {
|
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()
|
.itemSelectListener()
|
||||||
.pipe(takeUntilDestroyed(this.destroy$))
|
.pipe(takeUntilDestroyed(this.destroy$))
|
||||||
.subscribe(item => {
|
.subscribe(item => {
|
||||||
void this.router.navigate(['/data-detail', item.uid]);
|
void this.router.navigate(['/data-detail', item.uid], {state: {item}});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,16 +13,16 @@
|
|||||||
~ this program. If not, see <https://www.gnu.org/licenses/>.
|
~ this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<ng-container *ngIf="items as items; else loading">
|
<ng-container *ngIf="items | async as items; else loading">
|
||||||
<ion-list>
|
<ion-list>
|
||||||
<ng-container *ngIf="!listHeader; else header"></ng-container>
|
<ng-container *ngIf="!listHeader; else header"></ng-container>
|
||||||
<ng-container *ngFor="let item of items | async">
|
<ng-container *ngFor="let item of items">
|
||||||
<ng-container
|
<ng-container
|
||||||
*ngTemplateOutlet="listItemTemplateRef || defaultListItem; context: {$implicit: item}"
|
*ngTemplateOutlet="listItemTemplateRef || defaultListItem; context: {$implicit: item}"
|
||||||
></ng-container>
|
></ng-container>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</ion-list>
|
</ion-list>
|
||||||
<ion-label class="empty-list-message" *ngIf="emptyListMessage && (items | async)?.length === 0"
|
<ion-label class="empty-list-message" *ngIf="emptyListMessage && items.length === 0"
|
||||||
>{{ emptyListMessage }}</ion-label
|
>{{ emptyListMessage }}</ion-label
|
||||||
>
|
>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|||||||
@@ -13,94 +13,93 @@
|
|||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {Component, Input, OnInit} from '@angular/core';
|
import {Component, Input, OnInit} from '@angular/core';
|
||||||
import {SCCatalog, SCSearchBooleanFilter, SCDucetSort} from '@openstapps/core';
|
import {SCCatalog, SCThings} from '@openstapps/core';
|
||||||
import {SearchPageComponent} from '../../list/search-page.component';
|
import {DataProvider} from '../../data.provider';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'stapps-catalog-detail-content',
|
selector: 'stapps-catalog-detail-content',
|
||||||
templateUrl: 'catalog-detail-content.html',
|
templateUrl: 'catalog-detail-content.html',
|
||||||
styleUrls: ['catalog-detail-content.scss'],
|
styleUrls: ['catalog-detail-content.scss'],
|
||||||
})
|
})
|
||||||
export class CatalogDetailContentComponent extends SearchPageComponent implements OnInit {
|
export class CatalogDetailContentComponent implements OnInit {
|
||||||
/**
|
/**
|
||||||
* SCCatalog to display
|
* SCCatalog to display
|
||||||
*/
|
*/
|
||||||
@Input() item: SCCatalog;
|
@Input() item: SCCatalog;
|
||||||
|
|
||||||
ngOnInit() {
|
items: Promise<SCThings[]>;
|
||||||
super.ngOnInit();
|
|
||||||
}
|
|
||||||
|
|
||||||
initialize() {
|
constructor(private dataProvider: DataProvider) {}
|
||||||
this.showDefaultData = true;
|
|
||||||
this.pageSize = 100;
|
|
||||||
|
|
||||||
const nameSort: SCDucetSort = {
|
async ngOnInit() {
|
||||||
arguments: {field: 'name'},
|
this.items = this.dataProvider
|
||||||
order: 'asc',
|
.search({
|
||||||
type: 'ducet',
|
size: 100,
|
||||||
};
|
sort: [
|
||||||
|
|
||||||
const typeSort: SCDucetSort = {
|
|
||||||
arguments: {field: 'type'},
|
|
||||||
order: 'desc',
|
|
||||||
type: 'ducet',
|
|
||||||
};
|
|
||||||
|
|
||||||
this.sortQuery = [typeSort, nameSort];
|
|
||||||
|
|
||||||
const subCatalogFilter: SCSearchBooleanFilter = {
|
|
||||||
arguments: {
|
|
||||||
operation: 'and',
|
|
||||||
filters: [
|
|
||||||
{
|
{
|
||||||
type: 'value',
|
arguments: {field: 'type'},
|
||||||
arguments: {
|
order: 'desc',
|
||||||
field: 'type',
|
type: 'ducet',
|
||||||
value: 'catalog',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'value',
|
arguments: {field: 'name'},
|
||||||
arguments: {
|
order: 'asc',
|
||||||
field: 'superCatalog.uid',
|
type: 'ducet',
|
||||||
value: this.item.uid,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
filter: {
|
||||||
type: 'boolean',
|
arguments: {
|
||||||
};
|
filters: [
|
||||||
|
{
|
||||||
const subEventsFilter: SCSearchBooleanFilter = {
|
arguments: {
|
||||||
arguments: {
|
operation: 'and',
|
||||||
operation: 'and',
|
filters: [
|
||||||
filters: [
|
{
|
||||||
{
|
type: 'value',
|
||||||
type: 'value',
|
arguments: {
|
||||||
arguments: {
|
field: 'type',
|
||||||
field: 'type',
|
value: 'catalog',
|
||||||
value: 'academic event',
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type: 'value',
|
||||||
|
arguments: {
|
||||||
|
field: 'superCatalog.uid',
|
||||||
|
value: this.item.uid,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
type: 'boolean',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arguments: {
|
||||||
|
operation: 'and',
|
||||||
|
filters: [
|
||||||
|
{
|
||||||
|
type: 'value',
|
||||||
|
arguments: {
|
||||||
|
field: 'type',
|
||||||
|
value: 'academic event',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'value',
|
||||||
|
arguments: {
|
||||||
|
field: 'catalogs.uid',
|
||||||
|
value: this.item.uid,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
type: 'boolean',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
operation: 'or',
|
||||||
},
|
},
|
||||||
{
|
type: 'boolean',
|
||||||
type: 'value',
|
},
|
||||||
arguments: {
|
})
|
||||||
field: 'catalogs.uid',
|
.then(({data}) => data);
|
||||||
value: this.item.uid,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
type: 'boolean',
|
|
||||||
};
|
|
||||||
|
|
||||||
this.forcedFilter = {
|
|
||||||
arguments: {
|
|
||||||
filters: [subCatalogFilter, subEventsFilter],
|
|
||||||
operation: 'or',
|
|
||||||
},
|
|
||||||
type: 'boolean',
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,19 +12,49 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {Component, Input} from '@angular/core';
|
import {Component, Input, OnInit} from '@angular/core';
|
||||||
import {SCDateSeries} from '@openstapps/core';
|
import {SCDateSeries} from '@openstapps/core';
|
||||||
|
import {ScheduleProvider, toDateSeriesRelevantData} from '../../../calendar/schedule.provider';
|
||||||
|
import {Observable} from 'rxjs';
|
||||||
|
import {map} from 'rxjs/operators';
|
||||||
|
import {DataRoutingService} from '../../data-routing.service';
|
||||||
|
import {Router} from '@angular/router';
|
||||||
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO
|
|
||||||
*/
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'stapps-date-series-detail-content',
|
selector: 'stapps-date-series-detail-content',
|
||||||
templateUrl: 'date-series-detail-content.html',
|
templateUrl: 'date-series-detail-content.html',
|
||||||
|
styleUrls: ['date-series-detail-content.scss'],
|
||||||
})
|
})
|
||||||
export class DateSeriesDetailContentComponent {
|
export class DateSeriesDetailContentComponent implements OnInit {
|
||||||
/**
|
|
||||||
* TODO
|
|
||||||
*/
|
|
||||||
@Input() item: SCDateSeries;
|
@Input() item: SCDateSeries;
|
||||||
|
|
||||||
|
isInCalendar: Observable<boolean>;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
readonly scheduleProvider: ScheduleProvider,
|
||||||
|
dataRoutingService: DataRoutingService,
|
||||||
|
router: Router,
|
||||||
|
) {
|
||||||
|
dataRoutingService
|
||||||
|
.itemSelectListener()
|
||||||
|
.pipe(takeUntilDestroyed())
|
||||||
|
.subscribe(item => {
|
||||||
|
void router.navigate(['/data-detail', item.uid], {state: {item}});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.isInCalendar = this.scheduleProvider.uuids$.pipe(map(it => it.includes(this.item.uid)));
|
||||||
|
}
|
||||||
|
|
||||||
|
addToCalendar() {
|
||||||
|
const current = this.scheduleProvider.partialEvents$.value;
|
||||||
|
this.scheduleProvider.partialEvents$.next([...current, toDateSeriesRelevantData(this.item)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
removeFromCalendar() {
|
||||||
|
const filtered = this.scheduleProvider.partialEvents$.value.filter(it => it.uid !== this.item.uid);
|
||||||
|
this.scheduleProvider.partialEvents$.next(filtered);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,23 +12,18 @@
|
|||||||
~ You should have received a copy of the GNU General Public License along with
|
~ You should have received a copy of the GNU General Public License along with
|
||||||
~ this program. If not, see <https://www.gnu.org/licenses/>.
|
~ this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
<ion-card>
|
<ng-container *ngIf="isInCalendar | async; else add">
|
||||||
<ion-card-header> {{ 'event' | propertyNameTranslate : item | titlecase }} </ion-card-header>
|
<ion-chip outline="true" color="success" (click)="removeFromCalendar()">
|
||||||
<ion-card-content>
|
<ion-icon name="event_available" fill="true"></ion-icon>
|
||||||
<a [routerLink]="['/data-detail', item.event.uid]">{{ 'name' | thingTranslate : item.event }}</a>
|
<ion-label>{{'chips.addEvent.addedToEvents' | translate}}</ion-label>
|
||||||
</ion-card-content>
|
</ion-chip>
|
||||||
</ion-card>
|
</ng-container>
|
||||||
<ion-card *ngIf="item.inPlace">
|
<ng-template #add>
|
||||||
<ion-card-header> {{ 'inPlace' | propertyNameTranslate : item | titlecase }} </ion-card-header>
|
<ion-chip outline="true" color="primary" (click)="addToCalendar()">
|
||||||
<ion-card-content>
|
<ion-icon name="calendar_today"></ion-icon>
|
||||||
<ion-icon name="pin_drop"> </ion-icon>
|
<ion-label>{{'chips.addEvent.addEvent' | translate}}</ion-label>
|
||||||
<a [routerLink]="['/data-detail', item.inPlace.uid]">{{ 'name' | thingTranslate : item.inPlace }}</a>
|
</ion-chip>
|
||||||
<stapps-address-detail
|
</ng-template>
|
||||||
*ngIf="item.inPlace.address"
|
|
||||||
[address]="item.inPlace.address"
|
|
||||||
></stapps-address-detail>
|
|
||||||
</ion-card-content>
|
|
||||||
</ion-card>
|
|
||||||
<stapps-simple-card
|
<stapps-simple-card
|
||||||
title="{{ 'duration' | propertyNameTranslate : item | titlecase }}"
|
title="{{ 'duration' | propertyNameTranslate : item | titlecase }}"
|
||||||
[content]="[item.duration | amDuration : 'minutes']"
|
[content]="[item.duration | amDuration : 'minutes']"
|
||||||
@@ -56,3 +51,16 @@
|
|||||||
[content]="item.performers"
|
[content]="item.performers"
|
||||||
></stapps-simple-card>
|
></stapps-simple-card>
|
||||||
<stapps-offers-detail *ngIf="item.offers" [offers]="item.offers"></stapps-offers-detail>
|
<stapps-offers-detail *ngIf="item.offers" [offers]="item.offers"></stapps-offers-detail>
|
||||||
|
<ion-card>
|
||||||
|
<ion-card-header> {{ 'event' | propertyNameTranslate : item | titlecase }} </ion-card-header>
|
||||||
|
<ion-card-content>
|
||||||
|
<stapps-data-list-item [item]="$any(item.event)"></stapps-data-list-item>
|
||||||
|
</ion-card-content>
|
||||||
|
</ion-card>
|
||||||
|
<ion-card *ngIf="item.inPlace">
|
||||||
|
<ion-card-header> {{ 'inPlace' | propertyNameTranslate : item | titlecase }} </ion-card-header>
|
||||||
|
<ion-card-content>
|
||||||
|
<stapps-data-list-item [item]="$any(item.inPlace)"></stapps-data-list-item>
|
||||||
|
</ion-card-content>
|
||||||
|
</ion-card>
|
||||||
|
<stapps-map-widget *ngIf="item.inPlace?.geo" [place]="item.inPlace"></stapps-map-widget>
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
ion-chip {
|
||||||
|
position: absolute;
|
||||||
|
z-index: 1;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
<ion-row>
|
<ion-row>
|
||||||
<ion-col>
|
<ion-col>
|
||||||
<div class="ion-text-wrap">
|
<div class="ion-text-wrap">
|
||||||
<ion-label class="title">{{ 'name' | thingTranslate : item }}</ion-label>
|
<ion-label class="title">{{ 'event.name' | thingTranslate : item }}</ion-label>
|
||||||
<p>
|
<p>
|
||||||
<ion-icon name="calendar_today"></ion-icon>
|
<ion-icon name="calendar_today"></ion-icon>
|
||||||
<span *ngIf="item.dates[0] && item.dates[item.dates.length - 1]">
|
<span *ngIf="item.dates[0] && item.dates[item.dates.length - 1]">
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ export class PlaceDetailContentComponent implements OnInit {
|
|||||||
.itemSelectListener()
|
.itemSelectListener()
|
||||||
.pipe(takeUntilDestroyed())
|
.pipe(takeUntilDestroyed())
|
||||||
.subscribe(item => {
|
.subscribe(item => {
|
||||||
void router.navigate(['/data-detail', item.uid]);
|
void router.navigate(['/data-detail', item.uid], {state: {item}});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,9 +38,5 @@
|
|||||||
</ion-card>
|
</ion-card>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container *ngIf="hasValidLocation">
|
<ng-container *ngIf="hasValidLocation">
|
||||||
<stapps-map-widget
|
<stapps-map-widget [place]="item" expandable="true"></stapps-map-widget>
|
||||||
class="map-widget expand-when-space"
|
|
||||||
[place]="item"
|
|
||||||
expandable="true"
|
|
||||||
></stapps-map-widget>
|
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|||||||
@@ -12,10 +12,3 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.map-widget {
|
|
||||||
position: relative;
|
|
||||||
width: auto;
|
|
||||||
height: 300px;
|
|
||||||
min-height: 300px;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ export class PlaceMensaDetailComponent implements AfterViewInit {
|
|||||||
.itemSelectListener()
|
.itemSelectListener()
|
||||||
.pipe(takeUntilDestroyed(this.destroy$))
|
.pipe(takeUntilDestroyed(this.destroy$))
|
||||||
.subscribe(item => {
|
.subscribe(item => {
|
||||||
void this.router.navigate(['/data-detail', item.uid]);
|
void this.router.navigate(['/data-detail', item.uid], {state: {item}});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,12 +112,15 @@ export class FavoritesPageComponent extends SearchPageComponent implements OnIni
|
|||||||
.subscribe(item => {
|
.subscribe(item => {
|
||||||
if (this.itemRouting) {
|
if (this.itemRouting) {
|
||||||
if ([SCThingType.Book, SCThingType.Periodical, SCThingType.Article].includes(item.type)) {
|
if ([SCThingType.Book, SCThingType.Periodical, SCThingType.Article].includes(item.type)) {
|
||||||
void this.router.navigate([
|
void this.router.navigate(
|
||||||
'hebis-detail',
|
[
|
||||||
(item.origin && 'originalId' in item.origin && item.origin['originalId']) || '',
|
'hebis-detail',
|
||||||
]);
|
(item.origin && 'originalId' in item.origin && item.origin['originalId']) || '',
|
||||||
|
],
|
||||||
|
{state: {item}},
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
void this.router.navigate(['data-detail', item.uid]);
|
void this.router.navigate(['data-detail', item.uid], {state: {item}});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,16 +12,11 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {Component, OnInit} from '@angular/core';
|
import {Component, inject, OnInit} from '@angular/core';
|
||||||
import {ActivatedRoute} from '@angular/router';
|
|
||||||
import {TranslateService} from '@ngx-translate/core';
|
|
||||||
import {SCUuid} from '@openstapps/core';
|
import {SCUuid} from '@openstapps/core';
|
||||||
import {FavoritesService} from '../../favorites/favorites.service';
|
|
||||||
import {DataProvider} from '../../data/data.provider';
|
|
||||||
import {DataDetailComponent} from '../../data/detail/data-detail.component';
|
import {DataDetailComponent} from '../../data/detail/data-detail.component';
|
||||||
import {DaiaDataProvider} from '../daia-data.provider';
|
import {DaiaDataProvider} from '../daia-data.provider';
|
||||||
import {DaiaHolding} from '../protocol/response';
|
import {DaiaHolding} from '../protocol/response';
|
||||||
import {ModalController} from '@ionic/angular';
|
|
||||||
import {groupByStable} from '@openstapps/collection-utils';
|
import {groupByStable} from '@openstapps/collection-utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,28 +32,10 @@ export class DaiaAvailabilityComponent extends DataDetailComponent implements On
|
|||||||
|
|
||||||
holdingsByDepartments?: Map<DaiaHolding['department']['id'], DaiaHolding[]>;
|
holdingsByDepartments?: Map<DaiaHolding['department']['id'], DaiaHolding[]>;
|
||||||
|
|
||||||
/**
|
private daiaDataProvider = inject(DaiaDataProvider);
|
||||||
*
|
|
||||||
* @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
|
|
||||||
* @param daiaDataProvider DaiaDataProvider
|
|
||||||
*/
|
|
||||||
constructor(
|
|
||||||
route: ActivatedRoute,
|
|
||||||
dataProvider: DataProvider,
|
|
||||||
favoritesService: FavoritesService,
|
|
||||||
modalController: ModalController,
|
|
||||||
translateService: TranslateService,
|
|
||||||
private daiaDataProvider: DaiaDataProvider,
|
|
||||||
) {
|
|
||||||
super(route, dataProvider, favoritesService, modalController, translateService);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize
|
* @override
|
||||||
*/
|
*/
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
const uid = this.route.snapshot.paramMap.get('uid');
|
const uid = this.route.snapshot.paramMap.get('uid');
|
||||||
|
|||||||
@@ -107,8 +107,8 @@ describe('HebisDetailComponent', () => {
|
|||||||
expect(HebisDetailComponent.prototype.getItem).toHaveBeenCalledWith(sampleThing.uid, false);
|
expect(HebisDetailComponent.prototype.getItem).toHaveBeenCalledWith(sampleThing.uid, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get a data item when the view is entered', () => {
|
it('should get a data item when initialized', () => {
|
||||||
comp.ionViewWillEnter();
|
comp.ngOnInit();
|
||||||
expect(HebisDetailComponent.prototype.getItem).toHaveBeenCalledWith(sampleThing.uid, false);
|
expect(HebisDetailComponent.prototype.getItem).toHaveBeenCalledWith(sampleThing.uid, false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,16 +12,11 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {Component} from '@angular/core';
|
import {Component, inject, OnInit} from '@angular/core';
|
||||||
import {ActivatedRoute} from '@angular/router';
|
|
||||||
import {TranslateService} from '@ngx-translate/core';
|
|
||||||
import {SCUuid} from '@openstapps/core';
|
import {SCUuid} from '@openstapps/core';
|
||||||
import {HebisDataProvider} from '../hebis-data.provider';
|
import {HebisDataProvider} from '../hebis-data.provider';
|
||||||
import {FavoritesService} from '../../favorites/favorites.service';
|
|
||||||
import {DataProvider} from '../../data/data.provider';
|
|
||||||
import {DataDetailComponent} from '../../data/detail/data-detail.component';
|
import {DataDetailComponent} from '../../data/detail/data-detail.component';
|
||||||
import {DaiaHolding} from '../protocol/response';
|
import {DaiaHolding} from '../protocol/response';
|
||||||
import {ModalController} from '@ionic/angular';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Component to display an SCThing detailed
|
* A Component to display an SCThing detailed
|
||||||
@@ -31,33 +26,15 @@ import {ModalController} from '@ionic/angular';
|
|||||||
styleUrls: ['hebis-detail.scss'],
|
styleUrls: ['hebis-detail.scss'],
|
||||||
templateUrl: 'hebis-detail.html',
|
templateUrl: 'hebis-detail.html',
|
||||||
})
|
})
|
||||||
export class HebisDetailComponent extends DataDetailComponent {
|
export class HebisDetailComponent extends DataDetailComponent implements OnInit {
|
||||||
holdings: DaiaHolding[];
|
holdings: DaiaHolding[];
|
||||||
|
|
||||||
/**
|
private hebisDataProvider = inject(HebisDataProvider);
|
||||||
*
|
|
||||||
* @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
|
|
||||||
* @param hebisDataProvider HebisDataProvider
|
|
||||||
*/
|
|
||||||
constructor(
|
|
||||||
route: ActivatedRoute,
|
|
||||||
dataProvider: DataProvider,
|
|
||||||
favoritesService: FavoritesService,
|
|
||||||
modalController: ModalController,
|
|
||||||
translateService: TranslateService,
|
|
||||||
private hebisDataProvider: HebisDataProvider,
|
|
||||||
) {
|
|
||||||
super(route, dataProvider, favoritesService, modalController, translateService);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize
|
* @override
|
||||||
*/
|
*/
|
||||||
async ionViewWillEnter() {
|
async ngOnInit() {
|
||||||
const uid = this.route.snapshot.paramMap.get('uid') || '';
|
const uid = this.route.snapshot.paramMap.get('uid') || '';
|
||||||
await this.getItem(uid ?? '', false);
|
await this.getItem(uid ?? '', false);
|
||||||
}
|
}
|
||||||
@@ -68,9 +45,11 @@ export class HebisDetailComponent extends DataDetailComponent {
|
|||||||
* @param _forceReload Ignore any cached data
|
* @param _forceReload Ignore any cached data
|
||||||
*/
|
*/
|
||||||
async getItem(uid: SCUuid, _forceReload: boolean) {
|
async getItem(uid: SCUuid, _forceReload: boolean) {
|
||||||
this.hebisDataProvider.hebisSearch({query: uid, page: 0}).then(result => {
|
this.item = await (this.inputItem ??
|
||||||
// eslint-disable-next-line unicorn/no-null
|
this.hebisDataProvider.hebisSearch({query: uid, page: 0}).then(
|
||||||
this.item = (result.data && result.data[0]) || null;
|
result =>
|
||||||
});
|
// eslint-disable-next-line unicorn/no-null
|
||||||
|
(result.data && result.data[0]) || null,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,19 +13,12 @@
|
|||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {Component, Input, OnInit} from '@angular/core';
|
import {Component, Input, OnInit} from '@angular/core';
|
||||||
import {ActivatedRoute, Router} from '@angular/router';
|
|
||||||
import {AlertController, AnimationController} from '@ionic/angular';
|
|
||||||
import {NGXLogger} from 'ngx-logger';
|
|
||||||
import {combineLatest} from 'rxjs';
|
import {combineLatest} from 'rxjs';
|
||||||
import {debounceTime, distinctUntilChanged, startWith} from 'rxjs/operators';
|
import {debounceTime, distinctUntilChanged, startWith} from 'rxjs/operators';
|
||||||
import {ContextMenuService} from '../../menu/context/context-menu.service';
|
|
||||||
import {SettingsProvider} from '../../settings/settings.provider';
|
|
||||||
import {DataRoutingService} from '../../data/data-routing.service';
|
|
||||||
import {SearchPageComponent} from '../../data/list/search-page.component';
|
import {SearchPageComponent} from '../../data/list/search-page.component';
|
||||||
import {HebisDataProvider} from '../hebis-data.provider';
|
import {HebisDataProvider} from '../hebis-data.provider';
|
||||||
import {PositionService} from '../../map/position.service';
|
|
||||||
import {ConfigProvider} from '../../config/config.provider';
|
|
||||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
|
import {DataProvider} from '../../data/data.provider';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HebisSearchPageComponent queries things and shows list of things as search results and filter as context menu
|
* HebisSearchPageComponent queries things and shows list of things as search results and filter as context menu
|
||||||
@@ -34,6 +27,7 @@ import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
|||||||
selector: 'stapps-hebissearch-page',
|
selector: 'stapps-hebissearch-page',
|
||||||
templateUrl: 'hebis-search-page.html',
|
templateUrl: 'hebis-search-page.html',
|
||||||
styleUrls: ['../../data/list/search-page.scss'],
|
styleUrls: ['../../data/list/search-page.scss'],
|
||||||
|
providers: [{provide: DataProvider, useClass: HebisDataProvider}],
|
||||||
})
|
})
|
||||||
export class HebisSearchPageComponent extends SearchPageComponent implements OnInit {
|
export class HebisSearchPageComponent extends SearchPageComponent implements OnInit {
|
||||||
/**
|
/**
|
||||||
@@ -46,47 +40,6 @@ export class HebisSearchPageComponent extends SearchPageComponent implements OnI
|
|||||||
*/
|
*/
|
||||||
page = 0;
|
page = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* Injects the providers and creates subscriptions
|
|
||||||
* @param alertController AlertController
|
|
||||||
* @param dataProvider HebisProvider
|
|
||||||
* @param contextMenuService ContextMenuService
|
|
||||||
* @param settingsProvider SettingsProvider
|
|
||||||
* @param logger An angular logger
|
|
||||||
* @param dataRoutingService DataRoutingService
|
|
||||||
* @param router Router
|
|
||||||
* @param route Active Route
|
|
||||||
* @param positionService PositionService
|
|
||||||
* @param configProvider ConfigProvider
|
|
||||||
*/
|
|
||||||
constructor(
|
|
||||||
protected readonly alertController: AlertController,
|
|
||||||
protected dataProvider: HebisDataProvider,
|
|
||||||
protected readonly contextMenuService: ContextMenuService,
|
|
||||||
protected readonly settingsProvider: SettingsProvider,
|
|
||||||
protected readonly logger: NGXLogger,
|
|
||||||
protected dataRoutingService: DataRoutingService,
|
|
||||||
protected router: Router,
|
|
||||||
route: ActivatedRoute,
|
|
||||||
protected positionService: PositionService,
|
|
||||||
configProvider: ConfigProvider,
|
|
||||||
animationController: AnimationController,
|
|
||||||
) {
|
|
||||||
super(
|
|
||||||
alertController,
|
|
||||||
dataProvider,
|
|
||||||
contextMenuService,
|
|
||||||
settingsProvider,
|
|
||||||
logger,
|
|
||||||
dataRoutingService,
|
|
||||||
router,
|
|
||||||
route,
|
|
||||||
positionService,
|
|
||||||
configProvider,
|
|
||||||
animationController,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches items with set query configuration
|
* Fetches items with set query configuration
|
||||||
* @param append If true fetched data gets appended to existing, override otherwise (default false)
|
* @param append If true fetched data gets appended to existing, override otherwise (default false)
|
||||||
@@ -103,7 +56,7 @@ export class HebisSearchPageComponent extends SearchPageComponent implements OnI
|
|||||||
searchOptions.query = this.queryText;
|
searchOptions.query = this.queryText;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.dataProvider.hebisSearch(searchOptions).then(
|
return (this.dataProvider as HebisDataProvider).hebisSearch(searchOptions).then(
|
||||||
async result => {
|
async result => {
|
||||||
/*this.singleTypeResponse =
|
/*this.singleTypeResponse =
|
||||||
result.facets.find(facet => facet.field === 'type')?.buckets
|
result.facets.find(facet => facet.field === 'type')?.buckets
|
||||||
@@ -176,10 +129,10 @@ export class HebisSearchPageComponent extends SearchPageComponent implements OnI
|
|||||||
.pipe(takeUntilDestroyed(this.destroy$))
|
.pipe(takeUntilDestroyed(this.destroy$))
|
||||||
.subscribe(async item => {
|
.subscribe(async item => {
|
||||||
if (this.itemRouting) {
|
if (this.itemRouting) {
|
||||||
void this.router.navigate([
|
void this.router.navigate(
|
||||||
'hebis-detail',
|
['hebis-detail', (item.origin && 'originalId' in item.origin && item.origin['originalId']) || ''],
|
||||||
(item.origin && 'originalId' in item.origin && item.origin['originalId']) || '',
|
{state: {item}},
|
||||||
]);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
92
frontend/app/src/app/modules/map/geo-navigation.directive.ts
Normal file
92
frontend/app/src/app/modules/map/geo-navigation.directive.ts
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
import {Directive, HostListener, Input} from '@angular/core';
|
||||||
|
import {SCPlaceWithoutReferences, SCThings, SCThingWithoutReferences} from '@openstapps/core';
|
||||||
|
import {Device} from '@capacitor/device';
|
||||||
|
import {ActionSheetController, ActionSheetOptions, ToastController} from '@ionic/angular';
|
||||||
|
import {TranslateService} from '@ngx-translate/core';
|
||||||
|
import {ThingTranslateService} from '../../translation/thing-translate.service';
|
||||||
|
import {Clipboard} from '@capacitor/clipboard';
|
||||||
|
import {PositionService} from './position.service';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A button that provides navigation options to the user via an action sheet
|
||||||
|
* @example
|
||||||
|
* <ion-button shape="round" [geoNavigation]="place">
|
||||||
|
* <ion-icon name="directions" slot="start"></ion-icon>
|
||||||
|
* <ion-label>{{'map.directions.TITLE' | translate}}</ion-label>
|
||||||
|
* </ion-button>
|
||||||
|
*/
|
||||||
|
@Directive({
|
||||||
|
selector: '[geoNavigation]',
|
||||||
|
standalone: true,
|
||||||
|
})
|
||||||
|
export class GeoNavigationDirective {
|
||||||
|
@Input({required: true}) geoNavigation: SCThingWithoutReferences &
|
||||||
|
Pick<SCPlaceWithoutReferences, 'geo' | 'address'>;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private actionSheetController: ActionSheetController,
|
||||||
|
private translateService: TranslateService,
|
||||||
|
private thingTranslate: ThingTranslateService,
|
||||||
|
private toastController: ToastController,
|
||||||
|
private positionService: PositionService,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
@HostListener('click', ['$event'])
|
||||||
|
async presentActionSheet(event: Event) {
|
||||||
|
event.stopPropagation();
|
||||||
|
const {operatingSystem} = await Device.getInfo();
|
||||||
|
const [lon, lat] = this.geoNavigation.geo.point.coordinates;
|
||||||
|
|
||||||
|
const supportedMapProviders =
|
||||||
|
operatingSystem === 'mac' || operatingSystem === 'ios'
|
||||||
|
? ['OSM_ROUTING', 'APPLE_MAPS', 'GOOGLE_MAPS']
|
||||||
|
: ['OSM_ROUTING', 'GOOGLE_MAPS'];
|
||||||
|
const address = this.geoNavigation.address
|
||||||
|
? this.translateService.instant(
|
||||||
|
'map.directions.ADDRESS',
|
||||||
|
this.thingTranslate.get(this.geoNavigation as SCThings, 'address'),
|
||||||
|
)
|
||||||
|
: `${lat}, ${lon}`;
|
||||||
|
|
||||||
|
const options: ActionSheetOptions = {
|
||||||
|
header: this.translateService.instant('map.directions.TITLE_LONG', {
|
||||||
|
name: this.thingTranslate.get(this.geoNavigation as SCThings, 'name'),
|
||||||
|
}),
|
||||||
|
subHeader: address,
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
text: this.translateService.instant('map.directions.COPY_ADDRESS'),
|
||||||
|
role: 'selected',
|
||||||
|
handler: async () => {
|
||||||
|
await Clipboard.write({string: address});
|
||||||
|
this.toastController
|
||||||
|
.create({
|
||||||
|
message: this.translateService.instant('map.directions.ADDRESS_COPIED'),
|
||||||
|
duration: 500,
|
||||||
|
})
|
||||||
|
.then(toast => toast.present());
|
||||||
|
},
|
||||||
|
},
|
||||||
|
...supportedMapProviders.map(provider => ({
|
||||||
|
text: this.translateService.instant(`map.directions.${provider}.TITLE`),
|
||||||
|
handler: () => {
|
||||||
|
const url: string = this.translateService.instant(`map.directions.${provider}.URL`, {
|
||||||
|
lat,
|
||||||
|
lon,
|
||||||
|
posLat: this.positionService.position?.latitude ?? 0,
|
||||||
|
posLon: this.positionService.position?.longitude ?? 0,
|
||||||
|
});
|
||||||
|
window.open(url.replace(/&?\w+=0,0/, ''), '_blank', 'noreferrer');
|
||||||
|
},
|
||||||
|
})),
|
||||||
|
{
|
||||||
|
text: this.translateService.instant('abort'),
|
||||||
|
role: 'cancel',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
const actionSheet = await this.actionSheetController.create(options);
|
||||||
|
await actionSheet.present();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
<!--
|
|
||||||
~ Copyright (C) 2022 StApps
|
|
||||||
~ This program is free software: you can redistribute it and/or modify it
|
|
||||||
~ under the terms of the GNU General Public License as published by the Free
|
|
||||||
~ Software Foundation, version 3.
|
|
||||||
~
|
|
||||||
~ This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
~ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
~ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
||||||
~ more details.
|
|
||||||
~
|
|
||||||
~ You should have received a copy of the GNU General Public License along with
|
|
||||||
~ this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<ion-card class="compact">
|
|
||||||
<ion-card-header>
|
|
||||||
<stapps-data-list-item [item]="$any(item)" id="show-more"></stapps-data-list-item>
|
|
||||||
<stapps-skeleton-list-item *ngIf="!item"></stapps-skeleton-list-item>
|
|
||||||
</ion-card-header>
|
|
||||||
<ion-card-content>
|
|
||||||
<ion-note>
|
|
||||||
<span *ngIf="item.address as address">
|
|
||||||
<span *ngIf="$any(item).inPlace">{{ $any(item).inPlace.name }},</span>
|
|
||||||
{{ address.streetAddress }}, {{ address.addressLocality }}
|
|
||||||
</span>
|
|
||||||
</ion-note>
|
|
||||||
<ion-button
|
|
||||||
size="small"
|
|
||||||
class="show-more-button"
|
|
||||||
fill="clear"
|
|
||||||
[routerLink]="['/data-detail', item.uid]"
|
|
||||||
>{{ 'map.page.buttons.MORE' | translate }}</ion-button
|
|
||||||
>
|
|
||||||
</ion-card-content>
|
|
||||||
</ion-card>
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
/*!
|
|
||||||
* Copyright (C) 2022 StApps
|
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License as published by the Free
|
|
||||||
* Software Foundation, version 3.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
||||||
* more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with
|
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@import '../../../../theme/util/mixins';
|
|
||||||
|
|
||||||
:host {
|
|
||||||
display: block;
|
|
||||||
max-width: 100%;
|
|
||||||
|
|
||||||
ion-card {
|
|
||||||
overflow: visible;
|
|
||||||
padding: 0;
|
|
||||||
|
|
||||||
ion-card-header {
|
|
||||||
padding: 0;
|
|
||||||
border-bottom: var(--border-width-default) solid var(--border-color-default);
|
|
||||||
|
|
||||||
stapps-data-list-item {
|
|
||||||
--ion-margin: 0;
|
|
||||||
|
|
||||||
&::ng-deep ion-item {
|
|
||||||
--padding-start: 0;
|
|
||||||
--padding-end: 0;
|
|
||||||
|
|
||||||
ion-label {
|
|
||||||
white-space: break-spaces;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.close {
|
|
||||||
--padding-top: 0;
|
|
||||||
--padding-bottom: 0;
|
|
||||||
--padding-start: 0;
|
|
||||||
--padding-end: 0;
|
|
||||||
|
|
||||||
position: absolute;
|
|
||||||
z-index: 1;
|
|
||||||
top: -15px;
|
|
||||||
right: -15px;
|
|
||||||
|
|
||||||
ion-icon {
|
|
||||||
width: 30px;
|
|
||||||
height: 30px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ion-card-content {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
padding: var(--spacing-md);
|
|
||||||
|
|
||||||
.show-more-button {
|
|
||||||
margin-left: auto;
|
|
||||||
text-transform: uppercase;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2021 StApps
|
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License as published by the Free
|
|
||||||
* Software Foundation, version 3.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
||||||
* more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with
|
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
import {Component, EventEmitter, Input, Output} from '@angular/core';
|
|
||||||
import {SCPlace} from '@openstapps/core';
|
|
||||||
import {IonRouterOutlet} from '@ionic/angular';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'stapps-map-item',
|
|
||||||
templateUrl: './map-item.component.html',
|
|
||||||
styleUrls: ['./map-item.component.scss'],
|
|
||||||
})
|
|
||||||
export class MapItemComponent {
|
|
||||||
/**
|
|
||||||
* An item to show
|
|
||||||
*/
|
|
||||||
@Input() item: SCPlace;
|
|
||||||
|
|
||||||
// eslint-disable-next-line @angular-eslint/no-output-on-prefix
|
|
||||||
@Output() onClose = new EventEmitter<void>();
|
|
||||||
|
|
||||||
constructor(readonly routerOutlet: IonRouterOutlet) {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Action when edit is clicked
|
|
||||||
*/
|
|
||||||
onCloseClick() {
|
|
||||||
this.onClose.emit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -29,12 +29,11 @@ import {StAppsWebHttpClient} from '../data/stapps-web-http-client.provider';
|
|||||||
import {MenuModule} from '../menu/menu.module';
|
import {MenuModule} from '../menu/menu.module';
|
||||||
import {MapProvider} from './map.provider';
|
import {MapProvider} from './map.provider';
|
||||||
import {MapPageComponent} from './page/map-page.component';
|
import {MapPageComponent} from './page/map-page.component';
|
||||||
import {MapListModalComponent} from './page/modals/map-list-modal.component';
|
import {MapListModalComponent} from './page/map-list-modal.component';
|
||||||
import {MapSingleModalComponent} from './page/modals/map-single-modal.component';
|
|
||||||
import {MapItemComponent} from './item/map-item.component';
|
|
||||||
import {NgModule} from '@angular/core';
|
import {NgModule} from '@angular/core';
|
||||||
import {UtilModule} from '../../util/util.module';
|
import {UtilModule} from '../../util/util.module';
|
||||||
import {IonIconModule} from '../../util/ion-icon/ion-icon.module';
|
import {IonIconModule} from '../../util/ion-icon/ion-icon.module';
|
||||||
|
import {GeoNavigationDirective} from './geo-navigation.directive';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the default area to show in advance (before components are initialized)
|
* Initializes the default area to show in advance (before components are initialized)
|
||||||
@@ -56,7 +55,7 @@ const mapRoutes: Routes = [
|
|||||||
* Module containing map related stuff
|
* Module containing map related stuff
|
||||||
*/
|
*/
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [MapPageComponent, MapListModalComponent, MapSingleModalComponent, MapItemComponent],
|
declarations: [MapPageComponent, MapListModalComponent],
|
||||||
exports: [],
|
exports: [],
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
@@ -71,6 +70,8 @@ const mapRoutes: Routes = [
|
|||||||
FormsModule,
|
FormsModule,
|
||||||
ThingTranslateModule,
|
ThingTranslateModule,
|
||||||
UtilModule,
|
UtilModule,
|
||||||
|
GeoNavigationDirective,
|
||||||
|
GeoNavigationDirective,
|
||||||
],
|
],
|
||||||
providers: [Geolocation, MapProvider, DataProvider, DataFacetsProvider, StAppsWebHttpClient],
|
providers: [Geolocation, MapProvider, DataProvider, DataFacetsProvider, StAppsWebHttpClient],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
import {Component, Input, OnInit} from '@angular/core';
|
import {Component, Input, OnInit} from '@angular/core';
|
||||||
import {SCSearchBooleanFilter, SCPlace, SCSearchFilter} from '@openstapps/core';
|
import {SCSearchBooleanFilter, SCPlace, SCSearchFilter} from '@openstapps/core';
|
||||||
import {MapProvider} from '../../map.provider';
|
import {MapProvider} from '../map.provider';
|
||||||
import {ModalController} from '@ionic/angular';
|
import {ModalController} from '@ionic/angular';
|
||||||
import {LatLngBounds} from 'leaflet';
|
import {LatLngBounds} from 'leaflet';
|
||||||
|
|
||||||
@@ -23,8 +23,8 @@ import {LatLngBounds} from 'leaflet';
|
|||||||
*/
|
*/
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'map-list-modal',
|
selector: 'map-list-modal',
|
||||||
templateUrl: 'map-list.html',
|
templateUrl: 'map-list-modal.html',
|
||||||
styleUrls: ['map-list.scss'],
|
styleUrls: ['map-list-modal.scss'],
|
||||||
})
|
})
|
||||||
export class MapListModalComponent implements OnInit {
|
export class MapListModalComponent implements OnInit {
|
||||||
/**
|
/**
|
||||||
@@ -27,8 +27,9 @@ import {MapProvider} from '../map.provider';
|
|||||||
import {MapPosition, PositionService} from '../position.service';
|
import {MapPosition, PositionService} from '../position.service';
|
||||||
import {Geolocation, PermissionStatus} from '@capacitor/geolocation';
|
import {Geolocation, PermissionStatus} from '@capacitor/geolocation';
|
||||||
import {Capacitor} from '@capacitor/core';
|
import {Capacitor} from '@capacitor/core';
|
||||||
import {pauseWhen} from '../../../util/pause-when';
|
import {pauseWhen} from '../../../util/rxjs/pause-when';
|
||||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
|
import {startViewTransition} from '../../../util/view-transition';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main page of the map
|
* The main page of the map
|
||||||
@@ -100,7 +101,17 @@ export class MapPageComponent implements OnInit {
|
|||||||
/**
|
/**
|
||||||
* Options of the leaflet map
|
* Options of the leaflet map
|
||||||
*/
|
*/
|
||||||
options: MapOptions;
|
options: MapOptions = {
|
||||||
|
center: geoJSON(this.mapProvider.defaultPolygon).getBounds().getCenter(),
|
||||||
|
layers: [
|
||||||
|
tileLayer('https://osm.server.uni-frankfurt.de/tiles/roads/x={x}&y={y}&z={z}', {
|
||||||
|
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors',
|
||||||
|
maxZoom: this.MAX_ZOOM,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
zoom: this.DEFAULT_ZOOM,
|
||||||
|
zoomControl: false,
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Position of the user on the map
|
* Position of the user on the map
|
||||||
@@ -134,20 +145,7 @@ export class MapPageComponent implements OnInit {
|
|||||||
private dataRoutingService: DataRoutingService,
|
private dataRoutingService: DataRoutingService,
|
||||||
private positionService: PositionService,
|
private positionService: PositionService,
|
||||||
readonly routerOutlet: IonRouterOutlet,
|
readonly routerOutlet: IonRouterOutlet,
|
||||||
) {
|
) {}
|
||||||
// initialize the options
|
|
||||||
this.options = {
|
|
||||||
center: geoJSON(this.mapProvider.defaultPolygon).getBounds().getCenter(),
|
|
||||||
layers: [
|
|
||||||
tileLayer('https://osm.server.uni-frankfurt.de/tiles/roads/x={x}&y={y}&z={z}', {
|
|
||||||
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors',
|
|
||||||
maxZoom: this.MAX_ZOOM,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
zoom: this.DEFAULT_ZOOM,
|
|
||||||
zoomControl: false,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.dataRoutingService
|
this.dataRoutingService
|
||||||
@@ -158,7 +156,7 @@ export class MapPageComponent implements OnInit {
|
|||||||
if (this.items.length > 1) {
|
if (this.items.length > 1) {
|
||||||
await Promise.all([this.modalController.dismiss(), this.showItem(item.uid)]);
|
await Promise.all([this.modalController.dismiss(), this.showItem(item.uid)]);
|
||||||
} else {
|
} else {
|
||||||
void this.router.navigate(['/data-detail', item.uid]);
|
void this.router.navigate(['/data-detail', item.uid], {state: {item}});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.positionService
|
this.positionService
|
||||||
@@ -305,6 +303,7 @@ export class MapPageComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
async onMapReady(map: Map) {
|
async onMapReady(map: Map) {
|
||||||
this.map = map;
|
this.map = map;
|
||||||
|
this.map.attributionControl.setPosition('topright');
|
||||||
const interval = window.setInterval(() =>
|
const interval = window.setInterval(() =>
|
||||||
MapProvider.invalidateWhenRendered(map, this.mapContainer, interval),
|
MapProvider.invalidateWhenRendered(map, this.mapContainer, interval),
|
||||||
);
|
);
|
||||||
@@ -384,10 +383,12 @@ export class MapPageComponent implements OnInit {
|
|||||||
* Resets the map = fetch all the items based on the filters (and go to component's base location)
|
* Resets the map = fetch all the items based on the filters (and go to component's base location)
|
||||||
*/
|
*/
|
||||||
async resetView() {
|
async resetView() {
|
||||||
this.location.go('/map');
|
startViewTransition(async () => {
|
||||||
await this.fetchAndUpdateItems(this.items.length > 0);
|
this.location.go('/map');
|
||||||
|
await this.fetchAndUpdateItems(this.items.length > 0);
|
||||||
|
|
||||||
this.ref.detectChanges();
|
this.ref.detectChanges();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -414,14 +415,16 @@ export class MapPageComponent implements OnInit {
|
|||||||
* @param uid Uuid of the place
|
* @param uid Uuid of the place
|
||||||
*/
|
*/
|
||||||
async showItem(uid: SCUuid) {
|
async showItem(uid: SCUuid) {
|
||||||
const response = await this.mapProvider.searchPlace(uid);
|
startViewTransition(async () => {
|
||||||
this.items = response.data as SCPlace[];
|
const response = await this.mapProvider.searchPlace(uid);
|
||||||
this.distance = this.positionService.getDistance(this.items[0].geo.point);
|
this.items = response.data as SCPlace[];
|
||||||
this.addToMap(this.items, true);
|
this.distance = this.positionService.getDistance(this.items[0].geo.point);
|
||||||
this.ref.detectChanges();
|
this.addToMap(this.items, true);
|
||||||
const url = this.router.createUrlTree(['/map', uid]).toString();
|
this.ref.detectChanges();
|
||||||
this.location.go(url);
|
const url = this.router.createUrlTree(['/map', uid]).toString();
|
||||||
// center the selected place
|
this.location.go(url);
|
||||||
this.focus(geoJSON(this.items[0].geo.point).getBounds().getCenter());
|
// center the selected place
|
||||||
|
this.focus(geoJSON(this.items[0].geo.point).getBounds().getCenter());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
</ion-toolbar>
|
</ion-toolbar>
|
||||||
</ion-header>
|
</ion-header>
|
||||||
|
|
||||||
<ion-content fullscreen id="map">
|
<ion-content id="map">
|
||||||
<div
|
<div
|
||||||
class="map-container"
|
class="map-container"
|
||||||
#mapContainer
|
#mapContainer
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
<div *ngIf="position" [leafletLayer]="positionMarker"></div>
|
<div *ngIf="position" [leafletLayer]="positionMarker"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="floating-content">
|
<div class="floating-content">
|
||||||
<div class="map-buttons above">
|
<div class="map-buttons">
|
||||||
<ion-button
|
<ion-button
|
||||||
*ngIf="items.length > 1"
|
*ngIf="items.length > 1"
|
||||||
color="light"
|
color="light"
|
||||||
@@ -67,7 +67,13 @@
|
|||||||
>
|
>
|
||||||
<ion-icon name="list"></ion-icon> {{ 'map.page.buttons.SHOW_LIST' | translate }}
|
<ion-icon name="list"></ion-icon> {{ 'map.page.buttons.SHOW_LIST' | translate }}
|
||||||
</ion-button>
|
</ion-button>
|
||||||
<ion-button color="light" shape="round" size="small" (click)="onPositionClick()">
|
<ion-button
|
||||||
|
color="light"
|
||||||
|
shape="round"
|
||||||
|
size="small"
|
||||||
|
(click)="onPositionClick()"
|
||||||
|
class="location-button"
|
||||||
|
>
|
||||||
<ion-icon *ngIf="position !== null; else noLocationIcon" name="my_location"></ion-icon>
|
<ion-icon *ngIf="position !== null; else noLocationIcon" name="my_location"></ion-icon>
|
||||||
<ng-template #noLocationIcon>
|
<ng-template #noLocationIcon>
|
||||||
<ion-icon
|
<ion-icon
|
||||||
@@ -80,30 +86,12 @@
|
|||||||
</ng-template>
|
</ng-template>
|
||||||
</ion-button>
|
</ion-button>
|
||||||
</div>
|
</div>
|
||||||
<stapps-map-item *ngIf="items.length === 1" [item]="items[0]" (onClose)="resetView()"></stapps-map-item>
|
<ion-card class="map-item">
|
||||||
</div>
|
<stapps-data-list-item *ngIf="items.length === 1" [item]="$any(items[0])"></stapps-data-list-item>
|
||||||
<div class="map-buttons floating-buttons">
|
<ion-button fill="clear" class="close" (click)="resetView()">
|
||||||
<ion-button
|
<ion-icon size="22" name="close" slot="icon-only"></ion-icon>
|
||||||
*ngIf="items.length > 1"
|
</ion-button>
|
||||||
color="light"
|
</ion-card>
|
||||||
shape="round"
|
|
||||||
size="small"
|
|
||||||
(click)="mapListModal.present()"
|
|
||||||
>
|
|
||||||
<ion-icon name="list"></ion-icon> {{ 'map.page.buttons.SHOW_LIST' | translate }}
|
|
||||||
</ion-button>
|
|
||||||
<ion-button color="light" shape="round" size="small" (click)="onPositionClick()">
|
|
||||||
<ion-icon *ngIf="position !== null; else noLocationIcon" name="my_location"></ion-icon>
|
|
||||||
<ng-template #noLocationIcon>
|
|
||||||
<ion-icon
|
|
||||||
*ngIf="locationStatus && locationStatus.location === 'denied'; else pendingLocationIcon"
|
|
||||||
name="location_disabled"
|
|
||||||
></ion-icon>
|
|
||||||
</ng-template>
|
|
||||||
<ng-template #pendingLocationIcon>
|
|
||||||
<ion-icon name="location_searching"></ion-icon>
|
|
||||||
</ng-template>
|
|
||||||
</ion-button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ion-modal [canDismiss]="true" #mapListModal>
|
<ion-modal [canDismiss]="true" #mapListModal>
|
||||||
|
|||||||
@@ -12,113 +12,87 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
@import '../../../../theme/util/mixins';
|
||||||
|
|
||||||
ion-content {
|
$bottom-offset: 7px; // no idea what happened here
|
||||||
// fixes the unexpected issue that the content is not fullscreen (behind the header)
|
|
||||||
position: absolute;
|
|
||||||
|
|
||||||
div.map-container {
|
.map-container {
|
||||||
position: fixed;
|
width: 100%;
|
||||||
width: 100%;
|
height: 100%;
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
& > div {
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ion-toolbar:first-of-type {
|
ion-toolbar:first-of-type {
|
||||||
padding: 0 var(--spacing-md) var(--spacing-xs);
|
padding: 0 var(--spacing-md) var(--spacing-xs);
|
||||||
}
|
}
|
||||||
|
|
||||||
div.map-buttons {
|
.floating-content {
|
||||||
|
position: fixed;
|
||||||
|
z-index: 1000;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
flex-flow: row-reverse wrap;
|
||||||
|
align-items: flex-end;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-buttons {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
|
||||||
ion-button {
|
ion-button {
|
||||||
// important for iOS
|
// important for iOS
|
||||||
// TODO: find an option that is better suited for the iOS theme
|
// TODO: find an option that is better suited for the iOS theme
|
||||||
--box-shadow: var(--map-box-shadow);
|
--box-shadow: var(--map-box-shadow);
|
||||||
|
|
||||||
align-self: flex-end;
|
align-self: flex-end;
|
||||||
margin: 4px;
|
margin: var(--spacing-md);
|
||||||
|
|
||||||
|
&.location-button {
|
||||||
|
view-transition-name: location-button;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
::ng-deep {
|
.map-item {
|
||||||
.stapps-location {
|
position: relative;
|
||||||
ion-icon {
|
max-width: 550px;
|
||||||
width: 100%;
|
margin: var(--spacing-md);
|
||||||
height: 100%;
|
|
||||||
color: #fd435c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.stapps-device-location {
|
.close {
|
||||||
ion-icon {
|
position: absolute;
|
||||||
width: 100%;
|
top: 0;
|
||||||
height: 100%;
|
|
||||||
color: #4387fd;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
div.floating-content {
|
|
||||||
position: fixed;
|
|
||||||
z-index: 1000;
|
|
||||||
right: 0;
|
right: 0;
|
||||||
bottom: 0;
|
}
|
||||||
left: 0;
|
|
||||||
|
|
||||||
display: block;
|
::ng-deep ion-item {
|
||||||
justify-content: center;
|
margin: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@include ion-md-down {
|
||||||
|
.md {
|
||||||
|
ion-content {
|
||||||
|
--padding-bottom: $bottom-offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
.floating-content {
|
||||||
|
bottom: $bottom-offset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-buttons ion-button {
|
||||||
|
margin: var(--spacing-sm);
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-item {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 0 var(--spacing-md) 8vh;
|
max-width: unset;
|
||||||
|
margin: 0;
|
||||||
|
|
||||||
ion-card {
|
border-bottom-right-radius: 0;
|
||||||
margin: 0;
|
border-bottom-left-radius: 0;
|
||||||
}
|
|
||||||
|
|
||||||
div.map-buttons {
|
|
||||||
display: flex;
|
|
||||||
justify-content: flex-end;
|
|
||||||
}
|
|
||||||
|
|
||||||
stapps-map-item {
|
|
||||||
position: center;
|
|
||||||
justify-self: center;
|
|
||||||
width: 550px;
|
|
||||||
margin: var(--spacing-sm) auto;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
div.floating-buttons {
|
|
||||||
position: absolute;
|
|
||||||
z-index: 1000;
|
|
||||||
right: 10px;
|
|
||||||
bottom: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.map-buttons.above {
|
|
||||||
display: none;
|
|
||||||
min-width: 70%;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (width <= 667px) {
|
|
||||||
div.map-buttons.above {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.floating-content {
|
|
||||||
justify-content: normal;
|
|
||||||
padding: 0 var(--spacing-md) var(--spacing-lg);
|
|
||||||
|
|
||||||
stapps-map-item {
|
|
||||||
display: grid;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
div.map-buttons.floating-buttons {
|
|
||||||
display: none;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
:host {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
@@ -12,9 +12,9 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {Component, ElementRef, Input, OnInit, ViewChild} from '@angular/core';
|
import {Component, ElementRef, HostBinding, Input, OnInit, ViewChild} from '@angular/core';
|
||||||
import {Router} from '@angular/router';
|
import {Router} from '@angular/router';
|
||||||
import {SCPlace} from '@openstapps/core';
|
import {SCPlaceWithoutReferences, SCThingWithoutReferences} from '@openstapps/core';
|
||||||
import {geoJSON, Map, MapOptions, tileLayer} from 'leaflet';
|
import {geoJSON, Map, MapOptions, tileLayer} from 'leaflet';
|
||||||
import {MapProvider} from '../map.provider';
|
import {MapProvider} from '../map.provider';
|
||||||
|
|
||||||
@@ -27,6 +27,8 @@ import {MapProvider} from '../map.provider';
|
|||||||
templateUrl: './map-widget.html',
|
templateUrl: './map-widget.html',
|
||||||
})
|
})
|
||||||
export class MapWidgetComponent implements OnInit {
|
export class MapWidgetComponent implements OnInit {
|
||||||
|
@HostBinding('class.expand-when-space') expandWhenSpace = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A leaflet map showed
|
* A leaflet map showed
|
||||||
*/
|
*/
|
||||||
@@ -45,7 +47,7 @@ export class MapWidgetComponent implements OnInit {
|
|||||||
/**
|
/**
|
||||||
* A place to show on the map
|
* A place to show on the map
|
||||||
*/
|
*/
|
||||||
@Input() place: SCPlace;
|
@Input() place: SCThingWithoutReferences & Pick<SCPlaceWithoutReferences, 'geo' | 'address'>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if the expand button should be visible
|
* Indicates if the expand button should be visible
|
||||||
|
|||||||
@@ -21,6 +21,10 @@
|
|||||||
[leafletOptions]="options"
|
[leafletOptions]="options"
|
||||||
></div>
|
></div>
|
||||||
<div class="map-buttons" *ngIf="showExpandButton">
|
<div class="map-buttons" *ngIf="showExpandButton">
|
||||||
|
<ion-button color="primary" shape="round" size="small" [geoNavigation]="place">
|
||||||
|
<ion-icon name="directions" slot="start"></ion-icon>
|
||||||
|
{{'map.directions.TITLE' | translate}}
|
||||||
|
</ion-button>
|
||||||
<ion-button color="primary" shape="round" size="small" [routerLink]="['/map', place.uid]">
|
<ion-button color="primary" shape="round" size="small" [routerLink]="['/map', place.uid]">
|
||||||
<ion-icon name="zoom_out_map"></ion-icon>
|
<ion-icon name="zoom_out_map"></ion-icon>
|
||||||
</ion-button>
|
</ion-button>
|
||||||
|
|||||||
@@ -12,6 +12,12 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
:host {
|
||||||
|
position: relative;
|
||||||
|
width: auto;
|
||||||
|
height: 300px;
|
||||||
|
min-height: 300px;
|
||||||
|
}
|
||||||
|
|
||||||
div.map-container {
|
div.map-container {
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
<ion-card
|
<ion-card
|
||||||
[routerLink]="['/data-detail', item.uid]"
|
[routerLink]="['/data-detail', item.uid]"
|
||||||
|
[state]="{item}"
|
||||||
class="card"
|
class="card"
|
||||||
[style.--background]="item.image ? 'url(' + item.image + ')' : undefined"
|
[style.--background]="item.image ? 'url(' + item.image + ')' : undefined"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
import {ChangeDetectionStrategy, Component, Input} from '@angular/core';
|
||||||
|
import {mergeMap, ReplaySubject} from 'rxjs';
|
||||||
|
import {map} from 'rxjs/operators';
|
||||||
|
import {SCDateSeries, SCISO8601Date} from '@openstapps/core';
|
||||||
|
import moment from 'moment/moment';
|
||||||
|
import {ScheduleProvider} from '../../calendar/schedule.provider';
|
||||||
|
|
||||||
|
interface MyCoursesTodayInterface {
|
||||||
|
startTime: string;
|
||||||
|
endTime: string;
|
||||||
|
course: SCDateSeries;
|
||||||
|
}
|
||||||
|
|
||||||
|
type MyCoursesGroup = [SCISO8601Date, MyCoursesTodayInterface[]][];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Groups date series into a list of events happening in the next days
|
||||||
|
* @param dateSeries the date series to group
|
||||||
|
* @param visibleDays the number of days ahead to group
|
||||||
|
*/
|
||||||
|
function groupDays(dateSeries: SCDateSeries[], visibleDays: number): MyCoursesGroup {
|
||||||
|
const courses: [SCISO8601Date, MyCoursesTodayInterface[]][] = [];
|
||||||
|
const dates = Array.from({length: visibleDays}, (_, i) => moment().startOf('day').add(i, 'days'));
|
||||||
|
|
||||||
|
for (const day of dates) {
|
||||||
|
const dayCourses: MyCoursesTodayInterface[] = [];
|
||||||
|
for (const course of dateSeries) {
|
||||||
|
for (const date of course.dates) {
|
||||||
|
if (moment(date).isSame(day, 'day')) {
|
||||||
|
dayCourses.push({
|
||||||
|
startTime: moment(date).toISOString(),
|
||||||
|
endTime: moment(date).add(course.duration).toISOString(),
|
||||||
|
course,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
courses.push([day.toISOString(), dayCourses]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return courses;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'my-courses',
|
||||||
|
templateUrl: 'my-courses.html',
|
||||||
|
styleUrls: ['my-courses.scss'],
|
||||||
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
|
})
|
||||||
|
export class MyCoursesComponent {
|
||||||
|
/**
|
||||||
|
* The number of days from today to display
|
||||||
|
*/
|
||||||
|
@Input({required: true}) set visibleDays(value: number) {
|
||||||
|
this.visibleDays$.next(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly visibleDays$ = new ReplaySubject<number>();
|
||||||
|
|
||||||
|
myCourses = this.visibleDays$.pipe(
|
||||||
|
mergeMap(visibleDays =>
|
||||||
|
this.scheduleProvider.uuids$.pipe(
|
||||||
|
mergeMap(uuids => this.scheduleProvider.getDateSeries(uuids)),
|
||||||
|
map(dateSeries => groupDays(dateSeries.dates, visibleDays)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
constructor(private scheduleProvider: ScheduleProvider) {}
|
||||||
|
}
|
||||||
35
frontend/app/src/app/modules/profile/page/my-courses.html
Normal file
35
frontend/app/src/app/modules/profile/page/my-courses.html
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<ion-accordion-group *ngIf="myCourses | async as myCourses" [value]="myCourses[0][0]">
|
||||||
|
<ion-accordion
|
||||||
|
*ngFor="let myCoursesDay of myCourses"
|
||||||
|
[value]="myCoursesDay[0]"
|
||||||
|
[disabled]="myCoursesDay[1].length === 0"
|
||||||
|
>
|
||||||
|
<ion-item slot="header">
|
||||||
|
<!-- TODO: when using date-fns, use https://date-fns.org/v2.30.0/docs/formatRelative -->
|
||||||
|
<ion-label
|
||||||
|
>{{ myCoursesDay[0] | amDateFormat: 'dddd, ll' }} - {{ ('profile.courses.' + (myCoursesDay[1].length
|
||||||
|
=== 0 ? 'NO' : myCoursesDay[1].length === 1 ? 'ONE' : 'MANY' ) + '_EVENT') | translate: {count:
|
||||||
|
myCoursesDay[1].length} }}</ion-label
|
||||||
|
>
|
||||||
|
<ion-icon class="ion-accordion-toggle-icon" name="expand_more"></ion-icon>
|
||||||
|
</ion-item>
|
||||||
|
<ion-list class="ion-padding" slot="content">
|
||||||
|
<ng-container *ngIf="myCoursesDay[1].length === 0">
|
||||||
|
<div class="no-course">{{ 'profile.courses.no_courses' | translate }}</div>
|
||||||
|
</ng-container>
|
||||||
|
<ng-container *ngFor="let myCourse of myCoursesDay[1]">
|
||||||
|
<ion-item-group>
|
||||||
|
<ion-item-divider
|
||||||
|
>{{myCourse.startTime | amDateFormat: 'LT'}} - {{myCourse.endTime | amDateFormat:
|
||||||
|
'LT'}}</ion-item-divider
|
||||||
|
>
|
||||||
|
<stapps-data-list-item
|
||||||
|
[listItemChipInteraction]="false"
|
||||||
|
[hideThumbnail]="true"
|
||||||
|
[item]="myCourse.course"
|
||||||
|
></stapps-data-list-item>
|
||||||
|
</ion-item-group>
|
||||||
|
</ng-container>
|
||||||
|
</ion-list>
|
||||||
|
</ion-accordion>
|
||||||
|
</ion-accordion-group>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
ion-accordion-group {
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: var(--border-radius-default);
|
||||||
|
}
|
||||||
|
|
||||||
|
ion-item-divider {
|
||||||
|
--background: transparent;
|
||||||
|
--color: inherit;
|
||||||
|
}
|
||||||
@@ -12,41 +12,20 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {Component, OnInit} from '@angular/core';
|
import {Component} from '@angular/core';
|
||||||
import {firstValueFrom, Observable, of, Subscription} from 'rxjs';
|
|
||||||
import {AuthHelperService} from '../../auth/auth-helper.service';
|
import {AuthHelperService} from '../../auth/auth-helper.service';
|
||||||
import {SCAuthorizationProviderType, SCDateSeries, SCUserConfiguration} from '@openstapps/core';
|
import {SCAuthorizationProviderType, SCUserConfiguration} from '@openstapps/core';
|
||||||
import {ActivatedRoute} from '@angular/router';
|
import {ActivatedRoute} from '@angular/router';
|
||||||
import {ScheduleProvider} from '../../calendar/schedule.provider';
|
import {ScheduleProvider} from '../../calendar/schedule.provider';
|
||||||
import moment from 'moment';
|
|
||||||
import {SCIcon} from '../../../util/ion-icon/icon';
|
|
||||||
import {profilePageSections} from '../../../../config/profile-page-sections';
|
import {profilePageSections} from '../../../../config/profile-page-sections';
|
||||||
import {filter, map} from 'rxjs/operators';
|
import {filter, map} from 'rxjs/operators';
|
||||||
|
|
||||||
const CourseCard = {
|
|
||||||
collapsed: SCIcon`expand_more`,
|
|
||||||
expanded: SCIcon`expand_less`,
|
|
||||||
};
|
|
||||||
|
|
||||||
interface MyCoursesTodayInterface {
|
|
||||||
startTime: string;
|
|
||||||
endTime: string;
|
|
||||||
course: SCDateSeries;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-home',
|
selector: 'app-home',
|
||||||
templateUrl: 'profile-page.html',
|
templateUrl: 'profile-page.html',
|
||||||
styleUrls: ['profile-page.scss'],
|
styleUrls: ['profile-page.scss'],
|
||||||
})
|
})
|
||||||
export class ProfilePageComponent implements OnInit {
|
export class ProfilePageComponent {
|
||||||
data: {
|
|
||||||
[key in SCAuthorizationProviderType]: {loggedIn$: Observable<boolean>};
|
|
||||||
} = {
|
|
||||||
default: {loggedIn$: of(false)},
|
|
||||||
paia: {loggedIn$: of(false)},
|
|
||||||
};
|
|
||||||
|
|
||||||
user$ = this.authHelper.getProvider('default').user$.pipe(
|
user$ = this.authHelper.getProvider('default').user$.pipe(
|
||||||
filter(user => user !== undefined),
|
filter(user => user !== undefined),
|
||||||
map(userInfo => {
|
map(userInfo => {
|
||||||
@@ -58,59 +37,18 @@ export class ProfilePageComponent implements OnInit {
|
|||||||
|
|
||||||
logins: SCAuthorizationProviderType[] = [];
|
logins: SCAuthorizationProviderType[] = [];
|
||||||
|
|
||||||
originPath: string | null;
|
|
||||||
|
|
||||||
userInfo?: SCUserConfiguration;
|
userInfo?: SCUserConfiguration;
|
||||||
|
|
||||||
courseCardEnum = CourseCard;
|
|
||||||
|
|
||||||
courseCardState = CourseCard.expanded;
|
|
||||||
|
|
||||||
todayDate = moment().startOf('day').add(0, 'day').format(); // moment().startOf('day').format(); '2022-05-03T00:00:00+02:00'
|
|
||||||
|
|
||||||
myCoursesToday: MyCoursesTodayInterface[] = [];
|
|
||||||
|
|
||||||
subscriptions: Subscription[] = [];
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private authHelper: AuthHelperService,
|
readonly authHelper: AuthHelperService,
|
||||||
private route: ActivatedRoute,
|
readonly activatedRoute: ActivatedRoute,
|
||||||
protected readonly scheduleProvider: ScheduleProvider,
|
readonly scheduleProvider: ScheduleProvider,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
this.data.default.loggedIn$ = this.authHelper.getProvider('default').isAuthenticated$;
|
|
||||||
this.data.paia.loggedIn$ = this.authHelper.getProvider('paia').isAuthenticated$;
|
|
||||||
|
|
||||||
this.subscriptions.push(
|
|
||||||
this.route.queryParamMap.subscribe(queryParameters => {
|
|
||||||
this.originPath = queryParameters.get('origin_path');
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
this.getMyCourses();
|
|
||||||
}
|
|
||||||
|
|
||||||
async getMyCourses() {
|
|
||||||
const result = await firstValueFrom(this.scheduleProvider.uuids$);
|
|
||||||
const courses = await this.scheduleProvider.getDateSeries(result);
|
|
||||||
|
|
||||||
for (const course of courses.dates) {
|
|
||||||
for (const date of course.dates) {
|
|
||||||
if (moment(date).startOf('day').format() === this.todayDate) {
|
|
||||||
this.myCoursesToday[this.myCoursesToday.length] = {
|
|
||||||
startTime: moment(date).format('LT'),
|
|
||||||
endTime: moment(date).add(course.duration).format('LT'),
|
|
||||||
course,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async signIn(providerType: SCAuthorizationProviderType) {
|
async signIn(providerType: SCAuthorizationProviderType) {
|
||||||
await this.handleOriginPath();
|
const originPath = this.activatedRoute.snapshot.queryParamMap.get('origin_path');
|
||||||
this.authHelper.getProvider(providerType).signIn();
|
await (originPath ? this.authHelper.setOriginPath(originPath) : this.authHelper.deleteOriginPath());
|
||||||
|
await this.authHelper.getProvider(providerType).signIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
async signOut(providerType: SCAuthorizationProviderType) {
|
async signOut(providerType: SCAuthorizationProviderType) {
|
||||||
@@ -118,25 +56,6 @@ export class ProfilePageComponent implements OnInit {
|
|||||||
this.userInfo = undefined;
|
this.userInfo = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleCourseCardState() {
|
|
||||||
if (this.courseCardState === CourseCard.expanded) {
|
|
||||||
const card: HTMLElement | null = document.querySelector('.course-card');
|
|
||||||
const height = card?.scrollHeight;
|
|
||||||
if (card && height) {
|
|
||||||
card.style.setProperty('--max-height', height + 'px');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.courseCardState =
|
|
||||||
this.courseCardState === CourseCard.expanded ? CourseCard.collapsed : CourseCard.expanded;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async handleOriginPath() {
|
|
||||||
this.originPath
|
|
||||||
? await this.authHelper.setOriginPath(this.originPath)
|
|
||||||
: await this.authHelper.deleteOriginPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
ionViewWillEnter() {
|
ionViewWillEnter() {
|
||||||
this.authHelper
|
this.authHelper
|
||||||
.getProvider('default')
|
.getProvider('default')
|
||||||
|
|||||||
@@ -23,76 +23,53 @@
|
|||||||
</ion-header>
|
</ion-header>
|
||||||
|
|
||||||
<ion-content color="light" parallax [parallaxSize]="130">
|
<ion-content color="light" parallax [parallaxSize]="130">
|
||||||
<section class="user-card-wrapper">
|
<ion-card class="user-card">
|
||||||
<ion-card class="user-card">
|
<ion-card-header>
|
||||||
<ion-card-header>
|
<ion-img src="assets/imgs/header.svg"></ion-img>
|
||||||
<ion-img src="assets/imgs/header.svg"></ion-img>
|
<span *ngIf="user$ | async as userInfo">
|
||||||
<span *ngIf="user$ | async as userInfo">
|
{{ userInfo.role ? (userInfo?.role | titlecase) : ('profile.role_guest' | translate | titlecase) }}
|
||||||
{{ userInfo.role ? (userInfo?.role | titlecase) : ('profile.role_guest' | translate | titlecase) }}
|
</span>
|
||||||
</span>
|
</ion-card-header>
|
||||||
</ion-card-header>
|
<ion-card-content>
|
||||||
<ion-card-content>
|
<ion-img class="profile-card-img" src="assets/imgs/profile-card-head.svg"></ion-img>
|
||||||
<ion-img class="profile-card-img" src="assets/imgs/profile-card-head.svg"></ion-img>
|
<ion-grid>
|
||||||
<ion-grid>
|
<ion-row>
|
||||||
<ion-row>
|
<ion-col size="3"></ion-col>
|
||||||
<ion-col size="3"></ion-col>
|
<ion-col
|
||||||
<ion-col
|
*ngIf="authHelper.getProvider('default').isAuthenticated$ | async as loggedIn; else logInPrompt"
|
||||||
*ngIf="data.default.loggedIn$ | async as loggedIn; else logInPrompt"
|
size="9"
|
||||||
size="9"
|
class="main-info"
|
||||||
class="main-info"
|
>
|
||||||
>
|
<ng-container *ngIf="user$ | async as userInfo">
|
||||||
<ng-container *ngIf="user$ | async as userInfo">
|
<ion-text class="full-name"> {{ userInfo?.name }} </ion-text>
|
||||||
<ion-text class="full-name"> {{ userInfo?.name }} </ion-text>
|
<div class="matriculation-number">
|
||||||
<div class="matriculation-number">
|
<ion-label> {{ 'profile.userInfo.studentId' | translate | uppercase }} </ion-label>
|
||||||
<ion-label> {{ 'profile.userInfo.studentId' | translate | uppercase }} </ion-label>
|
<ion-text> {{ userInfo?.studentId }} </ion-text>
|
||||||
<ion-text> {{ userInfo?.studentId }} </ion-text>
|
</div>
|
||||||
</div>
|
<div class="user-name">
|
||||||
<div class="user-name">
|
<ion-label> {{ 'profile.userInfo.username' | translate | uppercase }} </ion-label>
|
||||||
<ion-label> {{ 'profile.userInfo.username' | translate | uppercase }} </ion-label>
|
<ion-text>{{ userInfo?.id }}</ion-text>
|
||||||
<ion-text>{{ userInfo?.id }}</ion-text>
|
</div>
|
||||||
</div>
|
<div class="email">
|
||||||
<div class="email">
|
<ion-label> {{ 'profile.userInfo.email' | translate | uppercase }} </ion-label>
|
||||||
<ion-label> {{ 'profile.userInfo.email' | translate | uppercase }} </ion-label>
|
<ion-text> {{ userInfo?.email }} </ion-text>
|
||||||
<ion-text> {{ userInfo?.email }} </ion-text>
|
</div>
|
||||||
</div>
|
</ng-container>
|
||||||
</ng-container>
|
</ion-col>
|
||||||
|
<ng-template #logInPrompt>
|
||||||
|
<ion-col size="9">
|
||||||
|
<ion-text class="log-in-prompt"> {{ 'profile.userInfo.logInPrompt' | translate }} </ion-text>
|
||||||
</ion-col>
|
</ion-col>
|
||||||
<ng-template #logInPrompt>
|
</ng-template>
|
||||||
<ion-col size="9">
|
</ion-row>
|
||||||
<ion-text class="log-in-prompt"> {{ 'profile.userInfo.logInPrompt' | translate }} </ion-text>
|
</ion-grid>
|
||||||
</ion-col>
|
</ion-card-content>
|
||||||
</ng-template>
|
</ion-card>
|
||||||
</ion-row>
|
|
||||||
</ion-grid>
|
|
||||||
</ion-card-content>
|
|
||||||
</ion-card>
|
|
||||||
</section>
|
|
||||||
<stapps-profile-page-section
|
<stapps-profile-page-section
|
||||||
*ngFor="let section of sections"
|
*ngFor="let section of sections"
|
||||||
[item]="section"
|
[item]="section"
|
||||||
></stapps-profile-page-section>
|
></stapps-profile-page-section>
|
||||||
<section class="courses">
|
<stapps-section [title]="'profile.titleCourses' | translate">
|
||||||
<ion-label class="section-headline"> {{ 'profile.titleCourses' | translate | uppercase }} </ion-label>
|
<my-courses [visibleDays]="5"></my-courses>
|
||||||
<ion-card class="courses-card">
|
</stapps-section>
|
||||||
<ion-card-header (click)="toggleCourseCardState()">
|
|
||||||
<span>{{ 'profile.courses.today' | translate | uppercase }}</span>
|
|
||||||
<ion-icon [name]="courseCardState" color="dark" size="20"></ion-icon>
|
|
||||||
</ion-card-header>
|
|
||||||
<ion-card-content class="course-card" [class.show-card]="courseCardState === courseCardEnum.expanded">
|
|
||||||
<ng-container *ngIf="myCoursesToday.length === 0">
|
|
||||||
<div class="no-course">{{ 'profile.courses.no_courses' | translate }}</div>
|
|
||||||
</ng-container>
|
|
||||||
<ng-container *ngFor="let myCourse of myCoursesToday">
|
|
||||||
<div class="clickable" [routerLink]="['/data-detail', myCourse.course.event.uid]">
|
|
||||||
<div>{{ myCourse?.startTime }} - {{ myCourse?.endTime }}</div>
|
|
||||||
<div>{{ myCourse?.course.event?.originalCategory }}</div>
|
|
||||||
<div [class.last]="!myCourse?.course.inPlace?.name">{{ myCourse.course?.event?.name }}</div>
|
|
||||||
<div *ngIf="myCourse.course?.inPlace?.name" [class.last]="myCourse.course?.inPlace?.name">
|
|
||||||
{{ myCourse.course?.inPlace.name }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</ng-container>
|
|
||||||
</ion-card-content>
|
|
||||||
</ion-card>
|
|
||||||
</section>
|
|
||||||
</ion-content>
|
</ion-content>
|
||||||
|
|||||||
@@ -12,216 +12,106 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
:host {
|
// TODO: clean up this mess
|
||||||
section {
|
.user-card {
|
||||||
margin-bottom: calc(2 * var(--spacing-lg) - var(--spacing-md));
|
position: relative;
|
||||||
padding: var(--spacing-md);
|
|
||||||
|
|
||||||
&:last-of-type {
|
max-width: 400px;
|
||||||
margin-bottom: 0;
|
margin: var(--spacing-xl);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.section-headline {
|
border-radius: var(--border-radius-default);
|
||||||
margin-bottom: var(--spacing-md);
|
box-shadow: var(--shadow-profile-card);
|
||||||
}
|
|
||||||
|
|
||||||
.user-card-wrapper {
|
ion-card-header {
|
||||||
margin-bottom: 0;
|
--background: var(--ion-color-tertiary);
|
||||||
|
|
||||||
.user-card {
|
display: flex;
|
||||||
position: relative;
|
|
||||||
|
|
||||||
max-width: 400px;
|
|
||||||
margin: 0;
|
|
||||||
|
|
||||||
border-radius: var(--border-radius-default);
|
|
||||||
box-shadow: var(--shadow-profile-card);
|
|
||||||
|
|
||||||
ion-card-header {
|
|
||||||
--background: var(--ion-color-tertiary);
|
|
||||||
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
padding-top: var(--spacing-sm);
|
|
||||||
padding-bottom: var(--spacing-sm);
|
|
||||||
|
|
||||||
ion-img {
|
|
||||||
display: block;
|
|
||||||
height: 36px;
|
|
||||||
margin-right: auto;
|
|
||||||
object-position: left 50%;
|
|
||||||
}
|
|
||||||
|
|
||||||
span {
|
|
||||||
padding-top: 3px;
|
|
||||||
|
|
||||||
font-size: var(--font-size-lg);
|
|
||||||
font-weight: var(--font-weight-bold);
|
|
||||||
line-height: 1;
|
|
||||||
color: var(--ion-color-light);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ion-card-content {
|
|
||||||
min-height: 15vh;
|
|
||||||
|
|
||||||
.profile-card-img {
|
|
||||||
position: absolute;
|
|
||||||
|
|
||||||
width: 50%;
|
|
||||||
height: 100%;
|
|
||||||
margin-left: calc(var(--spacing-md) * -4);
|
|
||||||
|
|
||||||
opacity: 0.13;
|
|
||||||
object-position: left bottom;
|
|
||||||
}
|
|
||||||
|
|
||||||
.main-info {
|
|
||||||
display: grid;
|
|
||||||
grid-template-areas:
|
|
||||||
'fullName fullName'
|
|
||||||
'matriculationNumber userName'
|
|
||||||
'email email';
|
|
||||||
|
|
||||||
ion-label {
|
|
||||||
display: block;
|
|
||||||
font-size: var(--font-size-sm);
|
|
||||||
font-weight: var(--font-weight-bold);
|
|
||||||
color: var(--ion-color-medium-shade);
|
|
||||||
}
|
|
||||||
|
|
||||||
ion-text {
|
|
||||||
display: block;
|
|
||||||
font-size: var(--font-size-md);
|
|
||||||
font-weight: var(--font-weight-bold);
|
|
||||||
color: var(--ion-color-text);
|
|
||||||
}
|
|
||||||
|
|
||||||
.full-name {
|
|
||||||
display: block;
|
|
||||||
grid-area: fullName;
|
|
||||||
|
|
||||||
margin-bottom: var(--spacing-sm);
|
|
||||||
|
|
||||||
font-size: var(--font-size-lg);
|
|
||||||
font-weight: var(--font-weight-bold);
|
|
||||||
}
|
|
||||||
|
|
||||||
.matriculation-number {
|
|
||||||
grid-area: matriculationNumber;
|
|
||||||
margin-bottom: var(--spacing-sm);
|
|
||||||
}
|
|
||||||
|
|
||||||
.user-name {
|
|
||||||
grid-area: userName;
|
|
||||||
margin-bottom: var(--spacing-sm);
|
|
||||||
}
|
|
||||||
|
|
||||||
.email {
|
|
||||||
grid-area: email;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.log-in-prompt {
|
|
||||||
margin: auto 0;
|
|
||||||
font-size: var(--font-size-lg);
|
|
||||||
font-weight: var(--font-weight-semi-bold);
|
|
||||||
color: var(--ion-color-text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ion-thumbnail {
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
padding-top: var(--spacing-sm);
|
||||||
|
padding-bottom: var(--spacing-sm);
|
||||||
|
|
||||||
width: 80%;
|
ion-img {
|
||||||
height: 80%;
|
|
||||||
margin: 0;
|
|
||||||
padding: 10px;
|
|
||||||
|
|
||||||
background: var(--placeholder-gray);
|
|
||||||
border-radius: var(--border-radius-default);
|
|
||||||
|
|
||||||
ion-icon {
|
|
||||||
display: block;
|
display: block;
|
||||||
width: 100%;
|
height: 36px;
|
||||||
height: 100%;
|
margin-right: auto;
|
||||||
color: white;
|
object-position: left 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
span {
|
||||||
|
padding-top: 3px;
|
||||||
|
|
||||||
|
font-size: var(--font-size-lg);
|
||||||
|
font-weight: var(--font-weight-bold);
|
||||||
|
line-height: 1;
|
||||||
|
color: var(--ion-color-light);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ion-row.main-info {
|
ion-card-content {
|
||||||
margin-bottom: 2px;
|
min-height: 15vh;
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.courses {
|
.profile-card-img {
|
||||||
.courses-card {
|
position: absolute;
|
||||||
max-width: 800px;
|
|
||||||
margin: 0;
|
|
||||||
|
|
||||||
background-color: unset;
|
width: 50%;
|
||||||
border-radius: var(--border-radius-default) var(--border-radius-default) 0 0;
|
height: 100%;
|
||||||
box-shadow: none;
|
margin-left: calc(var(--spacing-md) * -4);
|
||||||
|
|
||||||
ion-card-header {
|
opacity: 0.13;
|
||||||
display: flex;
|
object-position: left bottom;
|
||||||
align-items: center;
|
}
|
||||||
justify-content: space-between;
|
|
||||||
|
|
||||||
background-color: var(--ion-item-background);
|
.main-info {
|
||||||
border-radius: var(--border-radius-default) var(--border-radius-default) 0 0;
|
display: grid;
|
||||||
|
grid-template-areas:
|
||||||
|
'fullName fullName'
|
||||||
|
'matriculationNumber userName'
|
||||||
|
'email email';
|
||||||
|
|
||||||
span {
|
ion-label {
|
||||||
font-size: var(--font-size-lg);
|
display: block;
|
||||||
font-weight: var(--font-weight-bold);
|
font-size: var(--font-size-sm);
|
||||||
color: var(--ion-item-background-color-contrast);
|
font-weight: var(--font-weight-bold);
|
||||||
}
|
color: var(--ion-color-medium-shade);
|
||||||
|
|
||||||
ion-icon {
|
|
||||||
cursor: pointer;
|
|
||||||
color: var(--ion-color-light);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ion-card-content {
|
ion-text {
|
||||||
overflow: hidden;
|
display: block;
|
||||||
|
font-size: var(--font-size-md);
|
||||||
max-height: 0;
|
font-weight: var(--font-weight-bold);
|
||||||
margin: 0;
|
color: var(--ion-color-text);
|
||||||
padding: 0;
|
|
||||||
|
|
||||||
background-color: var(--ion-item-background);
|
|
||||||
border-radius: var(--border-radius-default);
|
|
||||||
|
|
||||||
transition: max-height 250ms ease-in-out, padding 250ms ease-in-out, margin 250ms ease-in-out;
|
|
||||||
|
|
||||||
&.show-card {
|
|
||||||
display: block;
|
|
||||||
|
|
||||||
height: 100%;
|
|
||||||
max-height: var(--max-height);
|
|
||||||
margin: var(--spacing-xxl);
|
|
||||||
padding: var(--spacing-md);
|
|
||||||
}
|
|
||||||
|
|
||||||
div {
|
|
||||||
font-size: var(--font-size-md);
|
|
||||||
font-weight: var(--font-weight-black);
|
|
||||||
color: var(--ion-item-background-color-contrast);
|
|
||||||
text-align: center;
|
|
||||||
|
|
||||||
&.no-course {
|
|
||||||
padding: var(--spacing-xxl) var(--spacing-lg);
|
|
||||||
}
|
|
||||||
|
|
||||||
&.last {
|
|
||||||
margin-bottom: var(--spacing-xl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.full-name {
|
||||||
|
display: block;
|
||||||
|
grid-area: fullName;
|
||||||
|
|
||||||
|
margin-bottom: var(--spacing-sm);
|
||||||
|
|
||||||
|
font-size: var(--font-size-lg);
|
||||||
|
font-weight: var(--font-weight-bold);
|
||||||
|
}
|
||||||
|
|
||||||
|
.matriculation-number {
|
||||||
|
grid-area: matriculationNumber;
|
||||||
|
margin-bottom: var(--spacing-sm);
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-name {
|
||||||
|
grid-area: userName;
|
||||||
|
margin-bottom: var(--spacing-sm);
|
||||||
|
}
|
||||||
|
|
||||||
|
.email {
|
||||||
|
grid-area: email;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-in-prompt {
|
||||||
|
margin: auto 0;
|
||||||
|
font-size: var(--font-size-lg);
|
||||||
|
font-weight: var(--font-weight-semi-bold);
|
||||||
|
color: var(--ion-color-text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {NgModule} from '@angular/core';
|
import {NgModule} from '@angular/core';
|
||||||
import {CommonModule} from '@angular/common';
|
import {CommonModule} from '@angular/common';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
@@ -25,6 +24,9 @@ import {UtilModule} from '../../util/util.module';
|
|||||||
import {IonIconModule} from '../../util/ion-icon/ion-icon.module';
|
import {IonIconModule} from '../../util/ion-icon/ion-icon.module';
|
||||||
import {ProfilePageSectionComponent} from './page/profile-page-section.component';
|
import {ProfilePageSectionComponent} from './page/profile-page-section.component';
|
||||||
import {ThingTranslateModule} from '../../translation/thing-translate.module';
|
import {ThingTranslateModule} from '../../translation/thing-translate.module';
|
||||||
|
import {DataModule} from '../data/data.module';
|
||||||
|
import {MyCoursesComponent} from './page/my-courses.component';
|
||||||
|
import {MomentModule} from 'ngx-moment';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{
|
{
|
||||||
@@ -34,7 +36,7 @@ const routes: Routes = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [ProfilePageComponent, ProfilePageSectionComponent],
|
declarations: [MyCoursesComponent, ProfilePageComponent, ProfilePageSectionComponent],
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
@@ -45,6 +47,8 @@ const routes: Routes = [
|
|||||||
SwiperModule,
|
SwiperModule,
|
||||||
UtilModule,
|
UtilModule,
|
||||||
ThingTranslateModule,
|
ThingTranslateModule,
|
||||||
|
DataModule,
|
||||||
|
MomentModule,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class ProfilePageModule {}
|
export class ProfilePageModule {}
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ export class SchedulePageComponent implements OnInit, AfterViewInit {
|
|||||||
onInit() {
|
onInit() {
|
||||||
this.tabChoreographer = new SharedAxisChoreographer(this.activatedRoute.snapshot.paramMap.get('mode'), [
|
this.tabChoreographer = new SharedAxisChoreographer(this.activatedRoute.snapshot.paramMap.get('mode'), [
|
||||||
'calendar',
|
'calendar',
|
||||||
'recurring',
|
'week-overview',
|
||||||
'single',
|
'single',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,15 +18,18 @@
|
|||||||
<ion-buttons slot="start">
|
<ion-buttons slot="start">
|
||||||
<ion-back-button></ion-back-button>
|
<ion-back-button></ion-back-button>
|
||||||
</ion-buttons>
|
</ion-buttons>
|
||||||
<ion-title *ngIf="tabChoreographer.currentValue === 'calendar'"
|
<ion-title
|
||||||
>{{ 'schedule.calendar' | translate | titlecase }}</ion-title
|
*ngIf="tabChoreographer.currentValue === 'calendar'"
|
||||||
>
|
[innerHTML]="'schedule.calendar' | translate | titlecase"
|
||||||
<ion-title *ngIf="tabChoreographer.currentValue === 'recurring'"
|
></ion-title>
|
||||||
>{{ 'schedule.recurring' | translate | titlecase }}</ion-title
|
<ion-title
|
||||||
>
|
*ngIf="tabChoreographer.currentValue === 'week-overview'"
|
||||||
<ion-title *ngIf="tabChoreographer.currentValue === 'single'"
|
[innerHTML]="'schedule.recurring' | translate | titlecase"
|
||||||
>{{ 'schedule.single' | translate | titlecase }}</ion-title
|
></ion-title>
|
||||||
>
|
<ion-title
|
||||||
|
*ngIf="tabChoreographer.currentValue === 'single'"
|
||||||
|
[innerHTML]="'schedule.single' | translate | titlecase"
|
||||||
|
></ion-title>
|
||||||
<ion-buttons slot="end">
|
<ion-buttons slot="end">
|
||||||
<ion-button (click)="onTodayClick()">
|
<ion-button (click)="onTodayClick()">
|
||||||
<ion-icon name="today" slot="icon-only"></ion-icon>
|
<ion-icon name="today" slot="icon-only"></ion-icon>
|
||||||
@@ -36,15 +39,15 @@
|
|||||||
<ion-toolbar color="primary" mode="md" class="tabs-toolbar">
|
<ion-toolbar color="primary" mode="md" class="tabs-toolbar">
|
||||||
<ion-segment #segment value="calendar" (ionChange)="onSegmentChange()">
|
<ion-segment #segment value="calendar" (ionChange)="onSegmentChange()">
|
||||||
<ion-segment-button value="calendar" layout="icon-start">
|
<ion-segment-button value="calendar" layout="icon-start">
|
||||||
<ion-label>{{ 'schedule.calendar' | translate }}</ion-label>
|
<ion-label class="ion-text-wrap" [innerHTML]="'schedule.calendar' | translate"></ion-label>
|
||||||
<ion-icon name="calendar_today"></ion-icon>
|
<ion-icon name="calendar_today"></ion-icon>
|
||||||
</ion-segment-button>
|
</ion-segment-button>
|
||||||
<ion-segment-button value="recurring" layout="icon-start">
|
<ion-segment-button value="week-overview" layout="icon-start">
|
||||||
<ion-label>{{ 'schedule.recurring' | translate }}</ion-label>
|
<ion-label class="ion-text-wrap" [innerHTML]="'schedule.recurring' | translate"></ion-label>
|
||||||
<ion-icon name="event_repeat"></ion-icon>
|
<ion-icon name="event_repeat"></ion-icon>
|
||||||
</ion-segment-button>
|
</ion-segment-button>
|
||||||
<ion-segment-button value="single" layout="icon-start">
|
<ion-segment-button value="single" layout="icon-start">
|
||||||
<ion-label>{{ 'schedule.single' | translate }}</ion-label>
|
<ion-label class="ion-text-wrap" [innerHTML]="'schedule.single' | translate"></ion-label>
|
||||||
<ion-icon name="event_upcoming"></ion-icon>
|
<ion-icon name="event_upcoming"></ion-icon>
|
||||||
</ion-segment-button>
|
</ion-segment-button>
|
||||||
</ion-segment>
|
</ion-segment>
|
||||||
@@ -59,7 +62,7 @@
|
|||||||
>
|
>
|
||||||
<stapps-calendar-view *ngSwitchCase="'calendar'" [layout]="layout"></stapps-calendar-view>
|
<stapps-calendar-view *ngSwitchCase="'calendar'" [layout]="layout"></stapps-calendar-view>
|
||||||
<!-- Schedule view needs full week -->
|
<!-- Schedule view needs full week -->
|
||||||
<stapps-schedule-view *ngSwitchCase="'recurring'" [layout]="layout"></stapps-schedule-view>
|
<stapps-schedule-view *ngSwitchCase="'week-overview'" [layout]="layout"></stapps-schedule-view>
|
||||||
<stapps-single-events *ngSwitchCase="'single'"></stapps-single-events>
|
<stapps-single-events *ngSwitchCase="'single'"></stapps-single-events>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ import {ChooseEventsPageComponent} from './page/choose-events-page.component';
|
|||||||
const settingsRoutes: Routes = [
|
const settingsRoutes: Routes = [
|
||||||
{path: 'schedule', redirectTo: 'schedule/calendar/now'},
|
{path: 'schedule', redirectTo: 'schedule/calendar/now'},
|
||||||
{path: 'schedule/calendar', redirectTo: 'schedule/calendar/now'},
|
{path: 'schedule/calendar', redirectTo: 'schedule/calendar/now'},
|
||||||
{path: 'schedule/recurring', redirectTo: 'schedule/recurring/now'},
|
{path: 'schedule/week-overview', redirectTo: 'schedule/week-overview/now'},
|
||||||
{path: 'schedule/single', redirectTo: 'schedule/single/now'},
|
{path: 'schedule/single', redirectTo: 'schedule/single/now'},
|
||||||
// calendar | recurring | single
|
// calendar | recurring | single
|
||||||
{path: 'schedule/:mode/:date', component: SchedulePageComponent},
|
{path: 'schedule/:mode/:date', component: SchedulePageComponent},
|
||||||
|
|||||||
@@ -12,13 +12,11 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Injectable, OnDestroy, Pipe, PipeTransform} from '@angular/core';
|
import {Injectable, OnDestroy, Pipe, PipeTransform} from '@angular/core';
|
||||||
import {LangChangeEvent, TranslateService} from '@ngx-translate/core';
|
import {LangChangeEvent, TranslateService} from '@ngx-translate/core';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import {Subscription} from 'rxjs';
|
import {Subscription} from 'rxjs';
|
||||||
import {logger} from '../_helpers/ts-logger';
|
import {logger} from '../_helpers/ts-logger';
|
||||||
import opening_hours from 'opening_hours';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@Pipe({
|
@Pipe({
|
||||||
@@ -110,141 +108,6 @@ export class StringSplitPipe implements PipeTransform {
|
|||||||
return this.value as never;
|
return this.value as never;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
@Pipe({
|
|
||||||
name: 'openingHours',
|
|
||||||
pure: true,
|
|
||||||
})
|
|
||||||
export class OpeningHoursPipe implements PipeTransform, OnDestroy {
|
|
||||||
locale: string;
|
|
||||||
|
|
||||||
onLangChange?: Subscription;
|
|
||||||
|
|
||||||
value: string[] = [];
|
|
||||||
|
|
||||||
constructor(private readonly translate: TranslateService) {
|
|
||||||
this.locale = translate.currentLang;
|
|
||||||
}
|
|
||||||
|
|
||||||
private _dispose(): void {
|
|
||||||
if (this.onLangChange?.closed === false) {
|
|
||||||
this.onLangChange?.unsubscribe();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
|
||||||
this._dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
transform(aString: string | unknown): string[] {
|
|
||||||
this.updateValue(aString);
|
|
||||||
this._dispose();
|
|
||||||
if (this.onLangChange?.closed === true) {
|
|
||||||
this.onLangChange = this.translate.onLangChange.subscribe((event: LangChangeEvent) => {
|
|
||||||
this.locale = event.lang;
|
|
||||||
this.updateValue(aString);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
updateValue(aString: string | unknown) {
|
|
||||||
if (typeof aString !== 'string') {
|
|
||||||
logger.warn(`openingHours pipe unable to parse input: ${aString}`);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let openingHours;
|
|
||||||
|
|
||||||
try {
|
|
||||||
openingHours = new opening_hours(aString, {
|
|
||||||
address: {
|
|
||||||
country_code: 'de',
|
|
||||||
state: 'Hessen',
|
|
||||||
},
|
|
||||||
lon: 8.667_97,
|
|
||||||
lat: 50.129_16,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
logger.warn(error);
|
|
||||||
this.value = [];
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const isOpen: boolean = openingHours.getState();
|
|
||||||
const isUnknown: boolean = openingHours.getUnknown();
|
|
||||||
|
|
||||||
const nextChange = openingHours.getNextChange();
|
|
||||||
const nextChangeIsOpen: boolean = openingHours.getState(nextChange);
|
|
||||||
const nextChangeUnknown: boolean = openingHours.getUnknown(nextChange);
|
|
||||||
const nextChangeIsToday: boolean = moment().isSame(nextChange, 'day');
|
|
||||||
|
|
||||||
let stateKey = isOpen ? 'common.openingHours.state_open' : 'common.openingHours.state_closed';
|
|
||||||
|
|
||||||
stateKey = isUnknown ? 'common.openingHours.state_maybe' : stateKey;
|
|
||||||
|
|
||||||
this.value = [isOpen ? 'success' : 'danger', `${this.translate.instant(stateKey)}`];
|
|
||||||
|
|
||||||
if (isUnknown) {
|
|
||||||
const comment = openingHours.getComment();
|
|
||||||
this.value = ['light', `${this.translate.instant(stateKey)}`];
|
|
||||||
if (typeof comment === 'string') {
|
|
||||||
this.value.push(comment);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nextChangeUnknown) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let nextChangeKey: string | undefined;
|
|
||||||
|
|
||||||
let formattedCalender = moment(nextChange).calendar();
|
|
||||||
|
|
||||||
if (moment(nextChange).isBefore(moment().add(1, 'hours'))) {
|
|
||||||
this.value[0] = 'warning';
|
|
||||||
nextChangeKey = nextChangeIsOpen
|
|
||||||
? 'common.openingHours.opening_soon_warning'
|
|
||||||
: 'common.openingHours.closing_soon_warning';
|
|
||||||
this.value.push(
|
|
||||||
`${this.translate.instant(nextChangeKey, {
|
|
||||||
time: new Intl.DateTimeFormat(this.locale, {
|
|
||||||
timeStyle: 'short',
|
|
||||||
}).format(nextChange),
|
|
||||||
})}`,
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nextChangeIsToday) {
|
|
||||||
nextChangeKey = nextChangeIsOpen
|
|
||||||
? 'common.openingHours.opening_today'
|
|
||||||
: 'common.openingHours.closing_today';
|
|
||||||
this.value.push(
|
|
||||||
`${this.translate.instant(nextChangeKey, {
|
|
||||||
time: new Intl.DateTimeFormat(this.locale, {
|
|
||||||
timeStyle: 'short',
|
|
||||||
}).format(nextChange),
|
|
||||||
})}`,
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
nextChangeKey = nextChangeIsOpen ? 'common.openingHours.opening' : 'common.openingHours.closing';
|
|
||||||
formattedCalender = formattedCalender.slice(0, 1).toUpperCase() + formattedCalender.slice(1);
|
|
||||||
this.value.push(
|
|
||||||
`${this.translate.instant(nextChangeKey, {
|
|
||||||
relativeDateTime: formattedCalender,
|
|
||||||
})}`,
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@Pipe({
|
@Pipe({
|
||||||
name: 'durationLocalized',
|
name: 'durationLocalized',
|
||||||
|
|||||||
35
frontend/app/src/app/translation/dfns-locale.ts
Normal file
35
frontend/app/src/app/translation/dfns-locale.ts
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
import {SCLanguageCode} from '@openstapps/core';
|
||||||
|
import type {Locale} from 'date-fns';
|
||||||
|
|
||||||
|
type LocalesMap = Record<SCLanguageCode, () => Promise<{default: Locale}>>;
|
||||||
|
|
||||||
|
const LOCALES = {
|
||||||
|
en: () => import('date-fns/locale/en-GB'),
|
||||||
|
de: () => import('date-fns/locale/de'),
|
||||||
|
} satisfies Partial<LocalesMap>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a Date Fns Locale
|
||||||
|
*/
|
||||||
|
export async function getDateFnsLocale(code: SCLanguageCode): Promise<Locale> {
|
||||||
|
if (code in LOCALES) {
|
||||||
|
return LOCALES[code as keyof typeof LOCALES]().then(it => it.default);
|
||||||
|
} else {
|
||||||
|
console.warn(`Unknown Locale "${code}" for Date Fns. Falling back to English.`);
|
||||||
|
return LOCALES.en().then(it => it.default);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,23 +17,31 @@
|
|||||||
import english from '../../assets/i18n/en.json';
|
import english from '../../assets/i18n/en.json';
|
||||||
import german from '../../assets/i18n/de.json';
|
import german from '../../assets/i18n/de.json';
|
||||||
|
|
||||||
const exceptions = new Set([
|
const exceptions = new Set(
|
||||||
'login',
|
[
|
||||||
'ok',
|
'login',
|
||||||
'protein',
|
'ok',
|
||||||
'feedback',
|
'protein',
|
||||||
'name',
|
'feedback',
|
||||||
'status',
|
'name',
|
||||||
'issn',
|
'status',
|
||||||
'ejournal',
|
'issn',
|
||||||
'backup',
|
'ejournal',
|
||||||
'export',
|
'backup',
|
||||||
'dashboard',
|
'export',
|
||||||
'home',
|
'dashboard',
|
||||||
'email',
|
'home',
|
||||||
'logins',
|
'email',
|
||||||
'https://www.swffm.de/essen-trinken/uebersicht/umweltscore',
|
'logins',
|
||||||
]);
|
'google maps',
|
||||||
|
'apple maps',
|
||||||
|
'openstreetmaps routing',
|
||||||
|
'https://www.swffm.de/essen-trinken/uebersicht/umweltscore',
|
||||||
|
'https://www.google.com/maps/dir/?api=1&destination={{lat}},{{lon}}&origin={{posLat}},{{posLon}}',
|
||||||
|
'https://maps.apple.com/?daddr={{lat}},{{lon}}&saddr={{posLat}},{{posLon}}',
|
||||||
|
'https://www.openstreetmap.org/directions?from={{posLat}},{{posLon}}&to={{lat}},{{lon}}#map=15/{{lat}}/{{lon}}',
|
||||||
|
].map(it => it.toLowerCase()),
|
||||||
|
);
|
||||||
|
|
||||||
const languages = [
|
const languages = [
|
||||||
['english', english],
|
['english', english],
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ModuleWithProviders, NgModule, Provider} from '@angular/core';
|
import {ModuleWithProviders, NgModule, Provider} from '@angular/core';
|
||||||
import {
|
import {
|
||||||
ArrayJoinPipe,
|
ArrayJoinPipe,
|
||||||
@@ -23,7 +22,6 @@ import {
|
|||||||
IsNumericPipe,
|
IsNumericPipe,
|
||||||
MetersLocalizedPipe,
|
MetersLocalizedPipe,
|
||||||
NumberLocalizedPipe,
|
NumberLocalizedPipe,
|
||||||
OpeningHoursPipe,
|
|
||||||
SentenceCasePipe,
|
SentenceCasePipe,
|
||||||
StringSplitPipe,
|
StringSplitPipe,
|
||||||
ToUnixPipe,
|
ToUnixPipe,
|
||||||
@@ -51,7 +49,6 @@ export interface ThingTranslateModuleConfig {
|
|||||||
ThingTranslatePipe,
|
ThingTranslatePipe,
|
||||||
TranslateSimplePipe,
|
TranslateSimplePipe,
|
||||||
DateLocalizedFormatPipe,
|
DateLocalizedFormatPipe,
|
||||||
OpeningHoursPipe,
|
|
||||||
SentenceCasePipe,
|
SentenceCasePipe,
|
||||||
ToUnixPipe,
|
ToUnixPipe,
|
||||||
EntriesPipe,
|
EntriesPipe,
|
||||||
@@ -69,7 +66,6 @@ export interface ThingTranslateModuleConfig {
|
|||||||
ThingTranslatePipe,
|
ThingTranslatePipe,
|
||||||
TranslateSimplePipe,
|
TranslateSimplePipe,
|
||||||
DateLocalizedFormatPipe,
|
DateLocalizedFormatPipe,
|
||||||
OpeningHoursPipe,
|
|
||||||
SentenceCasePipe,
|
SentenceCasePipe,
|
||||||
ToUnixPipe,
|
ToUnixPipe,
|
||||||
EntriesPipe,
|
EntriesPipe,
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ import {
|
|||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import {isDefined, ThingTranslateParser} from './thing-translate.parser';
|
import {isDefined, ThingTranslateParser} from './thing-translate.parser';
|
||||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
|
import {setDefaultOptions} from 'date-fns';
|
||||||
|
import {DateFnsConfigurationService} from 'ngx-date-fns';
|
||||||
|
import {getDateFnsLocale} from './dfns-locale';
|
||||||
|
|
||||||
// export const DEFAULT_LANGUAGE = new InjectionToken<string>('DEFAULT_LANGUAGE');
|
// export const DEFAULT_LANGUAGE = new InjectionToken<string>('DEFAULT_LANGUAGE');
|
||||||
|
|
||||||
@@ -40,8 +43,13 @@ export class ThingTranslateService {
|
|||||||
*
|
*
|
||||||
* @param translateService Instance of Angular TranslateService
|
* @param translateService Instance of Angular TranslateService
|
||||||
* @param parser An instance of the parser currently used
|
* @param parser An instance of the parser currently used
|
||||||
|
* @param dfnsConfiguration the date fns configuration
|
||||||
*/
|
*/
|
||||||
constructor(private readonly translateService: TranslateService, public parser: ThingTranslateParser) {
|
constructor(
|
||||||
|
private readonly translateService: TranslateService,
|
||||||
|
public parser: ThingTranslateParser,
|
||||||
|
private dfnsConfiguration: DateFnsConfigurationService,
|
||||||
|
) {
|
||||||
this.translator = new SCThingTranslator(
|
this.translator = new SCThingTranslator(
|
||||||
(translateService.currentLang ?? translateService.defaultLang) as SCLanguageCode,
|
(translateService.currentLang ?? translateService.defaultLang) as SCLanguageCode,
|
||||||
);
|
);
|
||||||
@@ -49,6 +57,10 @@ export class ThingTranslateService {
|
|||||||
this.translateService.onLangChange.pipe(takeUntilDestroyed()).subscribe((event: LangChangeEvent) => {
|
this.translateService.onLangChange.pipe(takeUntilDestroyed()).subscribe((event: LangChangeEvent) => {
|
||||||
this.translator.language = event.lang as keyof SCTranslations<SCLanguage>;
|
this.translator.language = event.lang as keyof SCTranslations<SCLanguage>;
|
||||||
moment.locale(event.lang);
|
moment.locale(event.lang);
|
||||||
|
getDateFnsLocale(event.lang as SCLanguageCode).then(locale => {
|
||||||
|
setDefaultOptions({locale});
|
||||||
|
this.dfnsConfiguration.setLocale(locale);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,64 +12,49 @@
|
|||||||
* You should have received a copy of the GNU General Public License along with
|
* You should have received a copy of the GNU General Public License along with
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
import {ChangeDetectionStrategy, Component, ContentChild, Input, TemplateRef} from '@angular/core';
|
||||||
import {Component, ContentChild, Input, OnDestroy, OnInit, TemplateRef} from '@angular/core';
|
import {interval, Observable} from 'rxjs';
|
||||||
import opening_hours from 'opening_hours';
|
import {fromOpeningHours} from './opening-hours';
|
||||||
|
import {map, startWith} from 'rxjs/operators';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'stapps-opening-hours',
|
selector: 'stapps-opening-hours',
|
||||||
templateUrl: 'opening-hours.html',
|
templateUrl: 'opening-hours.html',
|
||||||
|
styleUrls: ['opening-hours.scss'],
|
||||||
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class OpeningHoursComponent implements OnDestroy, OnInit {
|
export class OpeningHoursComponent {
|
||||||
@ContentChild(TemplateRef) content: TemplateRef<unknown>;
|
@ContentChild(TemplateRef) content: TemplateRef<unknown>;
|
||||||
|
|
||||||
@Input() openingHours?: string;
|
|
||||||
|
|
||||||
@Input() colorize = true;
|
@Input() colorize = true;
|
||||||
|
|
||||||
@Input() showNextChange = true;
|
@Input() showNextChange = true;
|
||||||
|
|
||||||
timer: NodeJS.Timeout;
|
openingHours$?: Observable<{
|
||||||
|
color: 'light' | 'warning' | 'success' | 'danger';
|
||||||
|
statusName: string;
|
||||||
|
statusText?: string;
|
||||||
|
nextChangeAction: 'closing' | 'opening';
|
||||||
|
nextChangeSoon?: Observable<Date | undefined>;
|
||||||
|
nextChange?: Date;
|
||||||
|
}>;
|
||||||
|
|
||||||
updateTimer() {
|
@Input() set openingHours(value: string | undefined) {
|
||||||
if (typeof this.openingHours !== 'string') {
|
if (!value) return;
|
||||||
return;
|
this.openingHours$ = fromOpeningHours(value).pipe(
|
||||||
}
|
map(({isUnknown, isOpen, changesSoon, nextChange, comment}) => ({
|
||||||
clearTimeout(this.timer);
|
color: isUnknown ? 'light' : changesSoon ? 'warning' : isOpen ? 'success' : 'danger',
|
||||||
|
statusName: `common.openingHours.state_${isUnknown ? 'maybe' : isOpen ? 'open' : 'closed'}`,
|
||||||
const ohObject = new opening_hours(this.openingHours, {
|
statusText: comment,
|
||||||
address: {
|
nextChangeAction: isOpen ? 'closing' : 'opening',
|
||||||
country_code: 'de',
|
nextChangeSoon: changesSoon
|
||||||
state: 'Hessen',
|
? interval(60_000).pipe(
|
||||||
},
|
startWith(nextChange),
|
||||||
lon: 8.667_97,
|
map(() => nextChange),
|
||||||
lat: 50.129_16,
|
)
|
||||||
});
|
: undefined,
|
||||||
|
nextChange,
|
||||||
const millisecondsRemaining =
|
})),
|
||||||
// eslint-disable-next-line unicorn/prefer-date-now
|
);
|
||||||
(ohObject.getNextChange()?.getTime() ?? 0) - new Date().getTime() + 1000;
|
|
||||||
|
|
||||||
if (millisecondsRemaining > 1_209_600_000) {
|
|
||||||
// setTimeout has upper bound of 0x7FFFFFFF
|
|
||||||
// ignore everything over a week
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (millisecondsRemaining > 0) {
|
|
||||||
this.timer = setTimeout(() => {
|
|
||||||
// pseudo update value to tigger openingHours pipe
|
|
||||||
this.openingHours = `${this.openingHours}`;
|
|
||||||
this.updateTimer();
|
|
||||||
}, millisecondsRemaining);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
this.updateTimer();
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnDestroy() {
|
|
||||||
clearTimeout(this.timer);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,18 +13,20 @@
|
|||||||
~ this program. If not, see <https://www.gnu.org/licenses/>.
|
~ this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<ng-container *ngIf="openingHours">
|
<div *ngIf="openingHours$ | async as openingHours">
|
||||||
<div>
|
<ion-badge *ngIf="colorize; else blank" [color]="openingHours.color" slot="start">
|
||||||
<ng-template [ngIf]="colorize" [ngIfElse]="blank">
|
{{ openingHours.statusName | translate }}
|
||||||
<ion-badge
|
</ion-badge>
|
||||||
[color]="openingHours | openingHours | slice : 0 : 1 | join : ' '"
|
<ng-template #blank>{{ openingHours.statusName | translate }}</ng-template>
|
||||||
slot="start"
|
<ng-container *ngIf="openingHours.statusText; else nextChange"> {{openingHours.statusText}} </ng-container>
|
||||||
style="vertical-align: bottom"
|
<ng-template #nextChange>
|
||||||
>
|
<ng-container *ngIf="showNextChange && openingHours.nextChangeSoon">
|
||||||
{{ openingHours | openingHours | slice : 1 : 2 }}
|
{{ ('common.openingHours.' + openingHours.nextChangeAction + '_soon') | translate: {duration:
|
||||||
</ion-badge>
|
(openingHours.nextChangeSoon | async | dfnsFormatDistanceToNowStrict: {unit: 'minute'})} }}
|
||||||
</ng-template>
|
</ng-container>
|
||||||
<ng-template #blank> {{ openingHours | openingHours | slice : 1 : 2 }} </ng-template>
|
<ng-container *ngIf="showNextChange && !openingHours.nextChangeSoon">
|
||||||
<ng-container *ngIf="showNextChange"> {{ openingHours | openingHours | slice : 2 : 3 }} </ng-container>
|
{{ ('common.openingHours.' + openingHours.nextChangeAction) | translate: {date: openingHours.nextChange
|
||||||
</div>
|
| dfnsFormatRelativeToNow} }}
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
</ng-template>
|
||||||
|
</div>
|
||||||
|
|||||||
3
frontend/app/src/app/util/opening-hours.scss
Normal file
3
frontend/app/src/app/util/opening-hours.scss
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
ion-badge {
|
||||||
|
vertical-align: bottom;
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user