mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2025-12-25 23:56:17 +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:
|
||||
image: registry.gitlab.com/openstapps/openstapps/node-builder
|
||||
tags:
|
||||
- performance
|
||||
- saas-linux-xlarge-amd64
|
||||
interruptible: true
|
||||
before_script:
|
||||
- corepack enable
|
||||
@@ -80,7 +80,7 @@ build:
|
||||
rules: &deploy-rules
|
||||
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
|
||||
variables:
|
||||
DEPLOY_ID: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
|
||||
DEPLOY_ID: $CI_MERGE_REQUEST_IID
|
||||
- if: $CI_COMMIT_BRANCH == 'main'
|
||||
variables:
|
||||
DEPLOY_ID: production
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.limit_publish_pipelines:
|
||||
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:
|
||||
stage: publish
|
||||
|
||||
@@ -18,7 +18,7 @@ base image:
|
||||
docker build
|
||||
-t "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:$(grep -o '"version": "[^"]*' "${DEPLOY_DIR}/package.json" | cut -d'"' -f4)"
|
||||
-t "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:latest" "${CI_PROJECT_DIR}/${DEPLOY_DIR}" &&
|
||||
docker push "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}"
|
||||
docker push "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}" --all-tags
|
||||
cache: {} # disable irrelevant cache for this job
|
||||
before_script: [] # do not run irrelevant before script for this job
|
||||
parallel:
|
||||
@@ -29,5 +29,7 @@ base image:
|
||||
DEPLOY_DIR: images/node-builder
|
||||
- IMAGE_NAME: app-builder
|
||||
DEPLOY_DIR: images/app-builder
|
||||
- IMAGE_NAME: app-cypress
|
||||
DEPLOY_DIR: images/app-cypress
|
||||
rules:
|
||||
- !reference [.limit_scheduled_pipelines, rules]
|
||||
@@ -15,8 +15,12 @@
|
||||
buildToolsVersions = [ "${buildToolsVersion}" ];
|
||||
platformVersions = [ "32" ];
|
||||
};
|
||||
cypress = prev.cypress.overrideAttrs(prev: {
|
||||
version = "12.17.1";
|
||||
cypress = prev.cypress.overrideAttrs(cyPrev: rec {
|
||||
version = "13.2.0";
|
||||
src = prev.fetchzip {
|
||||
url = "https://cdn.cypress.io/desktop/${version}/linux-x64/cypress.zip";
|
||||
hash = "sha256-9o0nprGcJhudS1LNm+T7Vf0Dwd1RBauYKI+w1FBQ3ZM=";
|
||||
};
|
||||
});
|
||||
})
|
||||
];
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2020,
|
||||
"sourceType": "module",
|
||||
"project": ["tsconfig.json", "tsconfig.spec.json", "e2e/tsconfig.e2e.json"],
|
||||
"project": ["tsconfig.json", "tsconfig.spec.json", "cypress/tsconfig.json"],
|
||||
"createDefaultProgram": true
|
||||
},
|
||||
"extends": [
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
e2e:
|
||||
image: cypress/browsers:latest # https://hub.docker.com/r/cypress/browsers/tags/
|
||||
image: registry.gitlab.com/openstapps/openstapps/app-cypress:node-18
|
||||
stage: test
|
||||
script:
|
||||
- pnpm --filter=@openstapps/app install
|
||||
- pnpm --filter=@openstapps/app exec cypress install
|
||||
- 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
|
||||
artifacts:
|
||||
when: on_failure
|
||||
@@ -18,5 +23,6 @@ e2e:
|
||||
matrix:
|
||||
- BROWSER: chrome
|
||||
- BROWSER: firefox
|
||||
- BROWSER: webkit
|
||||
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"`
|
||||
- Or open the iOS project in Xcode and change build system in workspace settings to `Lagacy Build System`. Then the normal run command works also.
|
||||
|
||||
## Cypress
|
||||
|
||||
#### Problem
|
||||
|
||||
The browser doesn't open or the tests don't connect to a browser
|
||||
|
||||
#### Cause
|
||||
|
||||
Cypress was installed to a read-only location, see
|
||||
[this issue](https://github.com/cypress-io/cypress/issues/18893).
|
||||
This can be the case if you use NixOS.
|
||||
|
||||
#### Solution
|
||||
|
||||
Make sure the cypress folder is writable before each launch
|
||||
|
||||
```shell
|
||||
chmod -R +rw ~/.config/Cypress
|
||||
```
|
||||
|
||||
@@ -182,6 +182,7 @@
|
||||
"builder": "@cypress/schematic:cypress",
|
||||
"options": {
|
||||
"devServerTarget": "app:serve",
|
||||
"liveReload": false,
|
||||
"watch": true,
|
||||
"headless": false
|
||||
},
|
||||
|
||||
@@ -28,6 +28,7 @@ export default defineConfig({
|
||||
fixturesFolder: 'cypress/fixtures',
|
||||
defaultCommandTimeout: 20_000,
|
||||
specPattern: 'cypress/integration/**/*.spec.ts',
|
||||
experimentalWebKitSupport: true,
|
||||
/*setupNodeEvents(on, config) {
|
||||
on('task', {
|
||||
log(message) {
|
||||
|
||||
@@ -18,14 +18,18 @@
|
||||
|
||||
describe('dashboard', async function () {
|
||||
describe('schedule section', function () {
|
||||
it('should lead to the schedule', function () {
|
||||
it('should lead to the week overview', function () {
|
||||
cy.visit('/overview');
|
||||
cy.get('.schedule').contains('a', 'Stundenplan').click();
|
||||
cy.url().should('include', '/schedule/recurring');
|
||||
cy.get('.schedule')
|
||||
.contains('a', /Wochen.*übersicht/)
|
||||
.click();
|
||||
cy.url().should('include', '/schedule/week-overview');
|
||||
});
|
||||
|
||||
it('should lead to the calendar', function () {
|
||||
cy.visit('/overview');
|
||||
cy.get('.schedule').contains('a', 'Kein Eintrag gefunden').click();
|
||||
cy.url().should('include', '/schedule/recurring');
|
||||
cy.url().should('include', '/schedule/calendar');
|
||||
});
|
||||
|
||||
// TODO: Reenable and stabilize tests
|
||||
@@ -172,7 +176,7 @@ describe('dashboard', async function () {
|
||||
cy.visit('/overview');
|
||||
|
||||
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 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
|
||||
// import './commands';
|
||||
|
||||
beforeEach(async function () {
|
||||
let databases: string[];
|
||||
if (window.indexedDB.databases) {
|
||||
databases = (await window.indexedDB.databases()).map(it => it.name);
|
||||
console.log('Trying to clear all databases');
|
||||
} else {
|
||||
console.log("Browser doesn't support database enumeration, deleting just ionic storage");
|
||||
databases = ['_ionicstorage'];
|
||||
}
|
||||
for (const database of databases) {
|
||||
if (database) {
|
||||
console.log(`Deleting database ${database}`);
|
||||
await new Promise(resolve => (window.indexedDB.deleteDatabase(database).onsuccess = resolve));
|
||||
console.log(`Deleted database ${database}`);
|
||||
}
|
||||
}
|
||||
beforeEach(function () {
|
||||
cy.wrap(
|
||||
new Promise(resolve => {
|
||||
window.indexedDB.deleteDatabase('_ionicstorage').onsuccess = resolve;
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
Cypress.on('window:before:load', window => {
|
||||
// Fake that user is using its browser in german language
|
||||
// Fake that user is using its browser in German
|
||||
Object.defineProperty(window.navigator, 'language', {value: 'de-DE'});
|
||||
Object.defineProperty(window.navigator, 'languages', [{value: 'de-DE'}]);
|
||||
|
||||
// Fail tests on console error
|
||||
cy.stub(window.console, 'error').callsFake(message => {
|
||||
// log out to the terminal
|
||||
cy.now('task', 'error', message);
|
||||
// log to Command Log and fail the test
|
||||
throw new Error(message);
|
||||
});
|
||||
cy.spy(window.console, 'error').as('consoleError');
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
cy.get('@consoleError').should('not.have.been.called');
|
||||
});
|
||||
|
||||
Cypress.on('uncaught:exception', error => {
|
||||
|
||||
@@ -63,6 +63,7 @@
|
||||
"@awesome-cordova-plugins/core": "5.45.0",
|
||||
"@capacitor/app": "4.1.1",
|
||||
"@capacitor/browser": "4.1.0",
|
||||
"@capacitor/clipboard": "4.1.0",
|
||||
"@capacitor/core": "4.6.1",
|
||||
"@capacitor/device": "4.1.0",
|
||||
"@capacitor/dialog": "4.1.0",
|
||||
@@ -87,8 +88,11 @@
|
||||
"@openstapps/collection-utils": "workspace:*",
|
||||
"@openstapps/core": "workspace:*",
|
||||
"@transistorsoft/capacitor-background-fetch": "1.0.2",
|
||||
"@types/dom-view-transitions": "1.0.1",
|
||||
"capacitor-secure-storage-plugin": "0.8.1",
|
||||
"cordova-plugin-calendar": "5.1.6",
|
||||
"date-fns": "2.30.0",
|
||||
"ngx-date-fns": "10.0.1",
|
||||
"deepmerge": "4.3.1",
|
||||
"form-data": "4.0.0",
|
||||
"geojson": "0.5.0",
|
||||
@@ -126,7 +130,7 @@
|
||||
"@capacitor/cli": "4.6.1",
|
||||
"@capacitor/ios": "4.6.1",
|
||||
"@compodoc/compodoc": "1.1.19",
|
||||
"@cypress/schematic": "1.7.0",
|
||||
"@cypress/schematic": "2.5.1",
|
||||
"@ionic/angular-toolkit": "10.0.0",
|
||||
"@ionic/cli": "7.1.1",
|
||||
"@openstapps/prettier-config": "workspace:*",
|
||||
@@ -146,7 +150,7 @@
|
||||
"@typescript-eslint/eslint-plugin": "5.60.1",
|
||||
"@typescript-eslint/parser": "5.60.1",
|
||||
"cordova-res": "0.15.4",
|
||||
"cypress": "12.17.1",
|
||||
"cypress": "13.2.0",
|
||||
"eslint": "8.43.0",
|
||||
"eslint-plugin-jsdoc": "46.4.2",
|
||||
"eslint-plugin-prettier": "4.2.1",
|
||||
@@ -166,6 +170,7 @@
|
||||
"karma-junit-reporter": "2.0.1",
|
||||
"karma-mocha-reporter": "2.2.5",
|
||||
"license-checker": "25.0.1",
|
||||
"playwright-webkit": "1.38.0",
|
||||
"stylelint": "15.10.1",
|
||||
"stylelint-config-clean-order": "5.0.1",
|
||||
"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 {ServiceHandlerInterceptor} from './_helpers/service-handler.interceptor';
|
||||
import {RoutingStackService} from './util/routing-stack.service';
|
||||
import {SCSettingValue} from '@openstapps/core';
|
||||
import {SCLanguageCode, SCSettingValue} from '@openstapps/core';
|
||||
import {DefaultAuthService} from './modules/auth/default-auth.service';
|
||||
import {PAIAAuthService} from './modules/auth/paia/paia-auth.service';
|
||||
import {IonIconModule} from './util/ion-icon/ion-icon.module';
|
||||
import {NavigationModule} from './modules/menu/navigation/navigation.module';
|
||||
import {browserFactory, SimpleBrowser} from './util/browser.factory';
|
||||
import {getDateFnsLocale} from './translation/dfns-locale';
|
||||
import {setDefaultOptions} from 'date-fns';
|
||||
import {DateFnsConfigurationService} from 'ngx-date-fns';
|
||||
|
||||
registerLocaleData(localeDe);
|
||||
|
||||
@@ -71,12 +74,6 @@ SwiperCore.use([FreeMode, Navigation]);
|
||||
|
||||
/**
|
||||
* Initializes data needed on startup
|
||||
* @param storageProvider provider of the saved data (using framework's storage)
|
||||
* @param logger TODO
|
||||
* @param settingsProvider provider of settings (e.g. language that has been set)
|
||||
* @param configProvider TODO
|
||||
* @param translateService TODO
|
||||
* @param _routingStackService Just for init and to track the stack from the get go
|
||||
*/
|
||||
export function initializerFactory(
|
||||
storageProvider: StorageProvider,
|
||||
@@ -87,6 +84,7 @@ export function initializerFactory(
|
||||
_routingStackService: RoutingStackService,
|
||||
defaultAuthService: DefaultAuthService,
|
||||
paiaAuthService: PAIAAuthService,
|
||||
dateFnsConfigurationService: DateFnsConfigurationService,
|
||||
) {
|
||||
return async () => {
|
||||
initLogger(logger);
|
||||
@@ -107,6 +105,10 @@ export function initializerFactory(
|
||||
translateService.setDefaultLang('en');
|
||||
translateService.use(languageCode);
|
||||
moment.locale(languageCode);
|
||||
const dateFnsLocale = await getDateFnsLocale(languageCode as SCLanguageCode);
|
||||
setDefaultOptions({locale: dateFnsLocale});
|
||||
dateFnsConfigurationService.setLocale(dateFnsLocale);
|
||||
|
||||
await defaultAuthService.init();
|
||||
await paiaAuthService.init();
|
||||
} catch (error) {
|
||||
@@ -198,6 +200,7 @@ export function createTranslateLoader(http: HttpClient) {
|
||||
RoutingStackService,
|
||||
DefaultAuthService,
|
||||
PAIAAuthService,
|
||||
DateFnsConfigurationService,
|
||||
],
|
||||
useFactory: initializerFactory,
|
||||
},
|
||||
|
||||
@@ -17,7 +17,7 @@ import {Component, DestroyRef, inject, Input, OnInit, ViewChild} from '@angular/
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {AssessmentsProvider} from '../assessments.provider';
|
||||
import {DataDetailComponent, ExternalDataLoadEvent} from '../../data/detail/data-detail.component';
|
||||
import {NavController, ViewWillEnter} from '@ionic/angular';
|
||||
import {NavController} from '@ionic/angular';
|
||||
import {DataRoutingService} from '../../data/data-routing.service';
|
||||
import {SCAssessment} from '@openstapps/core';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
@@ -27,7 +27,7 @@ import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
templateUrl: 'assessments-detail.html',
|
||||
styleUrls: ['assessments-detail.scss'],
|
||||
})
|
||||
export class AssessmentsDetailComponent implements ViewWillEnter, OnInit {
|
||||
export class AssessmentsDetailComponent implements OnInit {
|
||||
destroy$ = inject(DestroyRef);
|
||||
|
||||
constructor(
|
||||
@@ -67,8 +67,4 @@ export class AssessmentsDetailComponent implements ViewWillEnter, OnInit {
|
||||
event.resolve(this.item);
|
||||
});
|
||||
}
|
||||
|
||||
async ionViewWillEnter() {
|
||||
await this.detailComponent.ionViewWillEnter();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ export class AssessmentsSimpleDataListComponent implements OnInit {
|
||||
queryParams: {
|
||||
token: this.activatedRoute.snapshot.queryParamMap.get('token'),
|
||||
},
|
||||
state: {item: thing},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@ export class AssessmentsPageComponent implements OnInit, AfterViewInit {
|
||||
queryParams: {
|
||||
token: this.activatedRoute.snapshot.queryParamMap.get('token'),
|
||||
},
|
||||
state: {item: thing},
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ export class CatalogComponent implements OnInit {
|
||||
.itemSelectListener()
|
||||
.pipe(takeUntilDestroyed())
|
||||
.subscribe(item => {
|
||||
void this.router.navigate(['data-detail', item.uid]);
|
||||
void this.router.navigate(['data-detail', item.uid], {state: {item}});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -19,19 +19,20 @@
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
<div #schedule class="schedule">
|
||||
<a [routerLink]="['/schedule/recurring']">
|
||||
<ion-icon size="40" weight="300" name="grid_view"></ion-icon>
|
||||
<ion-label>{{ 'schedule.recurring' | translate }}</ion-label>
|
||||
<a [routerLink]="['/schedule/week-overview']">
|
||||
<ion-icon size="36" weight="300" name="calendar_month"></ion-icon>
|
||||
<ion-label [innerHTML]="'schedule.recurring' | translate"></ion-label>
|
||||
</a>
|
||||
<!-- Avoid structural directives here, they might interfere with the collapse animation -->
|
||||
<a
|
||||
[routerLink]="nextEvent?.event ? ['/data-detail', nextEvent!.event.uid] : ['/schedule/recurring']"
|
||||
[routerLink]="nextEvent ? ['/data-detail', nextEvent!.uid] : ['/schedule/calendar']"
|
||||
[state]="{item: nextEvent}"
|
||||
class="schedule-item-button"
|
||||
>
|
||||
<ion-label>{{ 'dashboard.schedule.title' | translate }}</ion-label>
|
||||
<ion-label>
|
||||
{{
|
||||
nextEvent?.event
|
||||
nextEvent
|
||||
? (nextEvent!.dates | nextDateInList | amDateFormat : 'll, HH:mm')
|
||||
: ('dashboard.schedule.noEvent' | translate)
|
||||
}}
|
||||
|
||||
@@ -117,6 +117,7 @@ ion-content {
|
||||
ion-label {
|
||||
font-size: var(--font-size-xxs);
|
||||
font-weight: var(--font-weight-semi-bold);
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
&:hover ::ng-deep stapps-icon {
|
||||
|
||||
@@ -76,7 +76,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
||||
.itemSelectListener()
|
||||
.pipe(takeUntilDestroyed())
|
||||
.subscribe(item => {
|
||||
void this.router.navigate(['data-detail', item.uid]);
|
||||
void this.router.navigate(['data-detail', item.uid], {state: {item}});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
<stapps-data-list-item
|
||||
*ngFor="let dish of dishes"
|
||||
[hideThumbnail]="true"
|
||||
[favoriteButton]="false"
|
||||
[item]="dish"
|
||||
appearance="square"
|
||||
></stapps-data-list-item>
|
||||
|
||||
@@ -42,6 +42,7 @@ export class ActionChipListComponent {
|
||||
event:
|
||||
item.type === SCThingType.AcademicEvent ||
|
||||
(item.type === SCThingType.DateSeries && (item as SCDateSeries).dates.length > 0),
|
||||
navigate: ('inPlace' in item && item.inPlace && 'geo' in item.inPlace) || 'geo' in item,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -14,5 +14,6 @@
|
||||
-->
|
||||
|
||||
<stapps-locate-action-chip *ngIf="applicable.locate" [item]="item"></stapps-locate-action-chip>
|
||||
<stapps-navigate-action-chip *ngIf="applicable.navigate" [item]="$any(item)"></stapps-navigate-action-chip>
|
||||
<!-- Add Event Chip needs to load data and should be the last -->
|
||||
<stapps-add-event-action-chip *ngIf="applicable.event" [item]="item"></stapps-add-event-action-chip>
|
||||
|
||||
@@ -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
|
||||
~ under the terms of the GNU General Public License as published by the Free
|
||||
~ Software Foundation, version 3.
|
||||
@@ -12,15 +12,7 @@
|
||||
~ You should have received a copy of the GNU General Public License along with
|
||||
~ this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<ion-header translucent>
|
||||
<ion-toolbar color="primary" mode="ios">
|
||||
<ion-title>{{ 'map.modals.single.TITLE' | translate }}</ion-title>
|
||||
<ion-buttons slot="end">
|
||||
<ion-button (click)="modalController.dismiss()">{{ 'app.ui.CLOSE' | translate }}</ion-button>
|
||||
</ion-buttons>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
<ion-content>
|
||||
<stapps-data-detail-content [item]="$any(item)" [openAsModal]="true"></stapps-data-detail-content>
|
||||
</ion-content>
|
||||
<ion-chip [color]="'primary'" [outline]="true" [geoNavigation]="place">
|
||||
<ion-icon name="directions"></ion-icon>
|
||||
<ion-label>{{'map.directions.TITLE' | translate}}</ion-label>
|
||||
</ion-chip>
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 StApps
|
||||
/*!
|
||||
* Copyright (C) 2023 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
@@ -12,20 +12,3 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {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 {SkeletonListComponent} from './list/skeleton-list.component';
|
||||
import {CertificationsInDetailComponent} from './elements/certifications-in-detail.component';
|
||||
import {GeoNavigationDirective} from '../map/geo-navigation.directive';
|
||||
import {NavigateActionChipComponent} from './chips/data/navigate-action-chip.component';
|
||||
|
||||
/**
|
||||
* Module for handling data
|
||||
@@ -110,6 +112,7 @@ import {CertificationsInDetailComponent} from './elements/certifications-in-deta
|
||||
declarations: [
|
||||
ActionChipListComponent,
|
||||
AddEventActionChipComponent,
|
||||
NavigateActionChipComponent,
|
||||
EditEventSelectionComponent,
|
||||
AddressDetailComponent,
|
||||
CatalogDetailContentComponent,
|
||||
@@ -194,6 +197,7 @@ import {CertificationsInDetailComponent} from './elements/certifications-in-deta
|
||||
TranslateModule.forChild(),
|
||||
ThingTranslateModule.forChild(),
|
||||
UtilModule,
|
||||
GeoNavigationDirective,
|
||||
],
|
||||
providers: [
|
||||
CoordinatedSearchProvider,
|
||||
|
||||
@@ -111,8 +111,8 @@ describe('DataDetailComponent', () => {
|
||||
expect(DataDetailComponent.prototype.getItem).toHaveBeenCalledWith(sampleThing.uid, false);
|
||||
});
|
||||
|
||||
it('should get a data item when the view is entered', () => {
|
||||
comp.ionViewWillEnter();
|
||||
it('should get a data item when initialized', () => {
|
||||
comp.ngOnInit();
|
||||
expect(DataDetailComponent.prototype.getItem).toHaveBeenCalledWith(sampleThing.uid, false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Component, ContentChild, EventEmitter, Input, Output, TemplateRef} from '@angular/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {ModalController, ViewWillEnter} from '@ionic/angular';
|
||||
import {Component, ContentChild, EventEmitter, Input, OnInit, Output, TemplateRef} from '@angular/core';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {ModalController} from '@ionic/angular';
|
||||
import {LangChangeEvent, TranslateService} from '@ngx-translate/core';
|
||||
import {SCLanguageCode, SCSaveableThing, SCThings, SCUuid} from '@openstapps/core';
|
||||
import {DataProvider, DataScope} from '../data.provider';
|
||||
@@ -37,7 +37,7 @@ export interface ExternalDataLoadEvent {
|
||||
styleUrls: ['data-detail.scss'],
|
||||
templateUrl: 'data-detail.html',
|
||||
})
|
||||
export class DataDetailComponent implements ViewWillEnter {
|
||||
export class DataDetailComponent implements OnInit {
|
||||
/**
|
||||
* The associated item
|
||||
*
|
||||
@@ -84,21 +84,15 @@ export class DataDetailComponent implements ViewWillEnter {
|
||||
return (thing as SCSaveableThing).data !== undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param route the route the page was accessed from
|
||||
* @param dataProvider the data provider
|
||||
* @param favoritesService the favorites provider
|
||||
* @param modalController the modal controller
|
||||
* @param translateService he translate provider
|
||||
*/
|
||||
constructor(
|
||||
protected readonly route: ActivatedRoute,
|
||||
router: Router,
|
||||
private readonly dataProvider: DataProvider,
|
||||
private readonly favoritesService: FavoritesService,
|
||||
readonly modalController: ModalController,
|
||||
translateService: TranslateService,
|
||||
) {
|
||||
this.inputItem = router.getCurrentNavigation()?.extras.state?.item;
|
||||
this.language = translateService.currentLang as SCLanguageCode;
|
||||
translateService.onLangChange.subscribe((event: LangChangeEvent) => {
|
||||
this.language = event.lang as SCLanguageCode;
|
||||
@@ -138,10 +132,7 @@ export class DataDetailComponent implements ViewWillEnter {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
async ionViewWillEnter() {
|
||||
async ngOnInit() {
|
||||
const uid = this.route.snapshot.paramMap.get('uid') || '';
|
||||
await this.getItem(uid ?? '', false);
|
||||
// fallback to the saved item (from favorites)
|
||||
|
||||
@@ -37,32 +37,22 @@ export class DataPathComponent implements OnInit {
|
||||
@Input() maxItems = 2;
|
||||
|
||||
@Input() set item(item: SCThings) {
|
||||
// eslint-disable-next-line unicorn/prefer-ternary
|
||||
if (item.type === SCThingType.Catalog && item.superCatalogs) {
|
||||
this.path = new Promise(resolve =>
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
resolve([...item.superCatalogs!, item]),
|
||||
);
|
||||
this.path = Promise.resolve([...item.superCatalogs!, item]);
|
||||
} else if (item.type === SCThingType.Assessment && item.superAssessments) {
|
||||
this.path = new Promise(resolve =>
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
resolve([...item.superAssessments!, item]),
|
||||
);
|
||||
this.path = Promise.resolve([...item.superAssessments!, item]);
|
||||
} else if (
|
||||
item.type === SCThingType.AcademicEvent &&
|
||||
item.catalogs &&
|
||||
(item.catalogs.length === 1 || this.routeStack.lastDataDetail)
|
||||
) {
|
||||
const catalogWithoutReferences = item.catalogs[0];
|
||||
const catalogPromise = (
|
||||
item.catalogs.length === 1
|
||||
? this.dataProvider.get(catalogWithoutReferences.uid, DataScope.Remote)
|
||||
: this.routeStack.lastDataDetail
|
||||
) as Promise<SCCatalog>;
|
||||
|
||||
this.path = new Promise(async resolve => {
|
||||
const catalog = await catalogPromise;
|
||||
const superCatalogs = catalog.superCatalogs;
|
||||
const catalogWithoutReferences = item.catalogs![0];
|
||||
const catalog =
|
||||
item.catalogs!.length === 1
|
||||
? await this.dataProvider.get(catalogWithoutReferences.uid, DataScope.Remote)
|
||||
: this.routeStack.lastDataDetail;
|
||||
const superCatalogs = (catalog as SCCatalog).superCatalogs;
|
||||
|
||||
resolve(
|
||||
superCatalogs
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable unicorn/no-useless-undefined */
|
||||
/*
|
||||
* Copyright (C) 2023 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
@@ -12,60 +13,51 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Component, ElementRef, HostListener, Input} from '@angular/core';
|
||||
import {SCDish, SCRatingRequest, SCUuid} from '@openstapps/core';
|
||||
import {ChangeDetectionStrategy, Component, ElementRef, HostListener, Input} from '@angular/core';
|
||||
import {SCDish, SCRatingRequest} from '@openstapps/core';
|
||||
import {RatingProvider} from '../rating.provider';
|
||||
import {ratingAnimation} from './rating.animation';
|
||||
import {BehaviorSubject, filter, merge, mergeMap, of, ReplaySubject, withLatestFrom} from 'rxjs';
|
||||
import {catchError, map} from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
selector: 'stapps-rating',
|
||||
templateUrl: 'rating.html',
|
||||
styleUrls: ['rating.scss'],
|
||||
animations: [ratingAnimation],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class StappsRatingComponent {
|
||||
rate = false;
|
||||
performRating = new BehaviorSubject(false);
|
||||
|
||||
rated = false;
|
||||
userRating = new BehaviorSubject<number | undefined>(undefined);
|
||||
|
||||
canBeRated = false;
|
||||
dish = new ReplaySubject<SCDish>(1);
|
||||
|
||||
uid: SCUuid;
|
||||
wasAlreadyRated = merge(
|
||||
this.dish.pipe(mergeMap(({uid}) => this.ratingProvider.hasRated(uid))),
|
||||
this.userRating.pipe(
|
||||
filter(it => it !== undefined),
|
||||
withLatestFrom(this.dish),
|
||||
mergeMap(([rating, {uid}]) => this.ratingProvider.rate(uid, rating as SCRatingRequest['rating'])),
|
||||
map(() => true),
|
||||
catchError(() => of(false)),
|
||||
),
|
||||
);
|
||||
|
||||
rating?: number;
|
||||
canBeRated = this.dish.pipe(mergeMap(dish => this.ratingProvider.canRate(dish)));
|
||||
|
||||
@Input() set item(value: SCDish) {
|
||||
this.uid = value.uid;
|
||||
|
||||
Promise.all([this.ratingProvider.canRate(value), this.ratingProvider.hasRated(this.uid)] as const).then(
|
||||
([canRate, hasRated]) => {
|
||||
this.canBeRated = canRate;
|
||||
this.rated = hasRated;
|
||||
},
|
||||
);
|
||||
@Input({required: true}) set item(value: SCDish) {
|
||||
this.dish.next(value);
|
||||
}
|
||||
|
||||
constructor(readonly elementRef: ElementRef, readonly ratingProvider: RatingProvider) {}
|
||||
|
||||
async submitRating(rating: number) {
|
||||
this.rating = rating;
|
||||
try {
|
||||
await this.ratingProvider.rate(this.uid, rating as SCRatingRequest['rating']);
|
||||
this.rated = true;
|
||||
} catch {
|
||||
this.rating = undefined;
|
||||
// allow change detection to catch up first
|
||||
setTimeout(() => {
|
||||
this.rate = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@HostListener('document:mousedown', ['$event'])
|
||||
clickOutside(event: MouseEvent) {
|
||||
if (this.rating) return;
|
||||
if (this.userRating.value) return;
|
||||
if (!this.elementRef.nativeElement.contains(event.target)) {
|
||||
this.rate = false;
|
||||
this.performRating.next(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,19 +14,23 @@
|
||||
-->
|
||||
|
||||
<ion-button
|
||||
*ngIf="canBeRated"
|
||||
*ngIf="canBeRated | async"
|
||||
fill="clear"
|
||||
(click)="$event.stopPropagation(); rate = true"
|
||||
[disabled]="rated"
|
||||
(click)="$event.stopPropagation(); performRating.next(true)"
|
||||
[disabled]="wasAlreadyRated | async"
|
||||
>
|
||||
<ion-icon slot="icon-only" color="medium" name="thumbs_up_down"></ion-icon>
|
||||
</ion-button>
|
||||
|
||||
<div class="rating-stars" *ngIf="rate && !rated" [@rating]="rating ? 'rated' : 'abandoned'">
|
||||
<div
|
||||
class="rating-stars"
|
||||
*ngIf="(performRating | async) && (wasAlreadyRated | async) !== true"
|
||||
[@rating]="(userRating | async) === undefined ? 'abandoned' : 'rated'"
|
||||
>
|
||||
<ion-icon
|
||||
[class.rated-value]="rating === i"
|
||||
[class.rated-value]="(userRating | async) === i"
|
||||
*ngFor="let i of [5, 4, 3, 2, 1]"
|
||||
(click)="$event.stopPropagation(); submitRating(i)"
|
||||
(click)="$event.stopPropagation(); userRating.next(i)"
|
||||
slot="icon-only"
|
||||
size="32"
|
||||
color="medium"
|
||||
|
||||
@@ -38,6 +38,8 @@ export class DataListItemComponent {
|
||||
|
||||
@Input() listItemEndInteraction = true;
|
||||
|
||||
@Input() listItemChipInteraction = true;
|
||||
|
||||
@Input() lines = 'inset';
|
||||
|
||||
@Input() forceHeight = false;
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<div>
|
||||
<ng-template [dataListItemHost]="item"></ng-template>
|
||||
<stapps-action-chip-list
|
||||
*ngIf="appearance !== 'square'"
|
||||
*ngIf="listItemChipInteraction && appearance !== 'square'"
|
||||
slot="end"
|
||||
[item]="item"
|
||||
></stapps-action-chip-list>
|
||||
|
||||
@@ -17,7 +17,7 @@ import {MapPosition} from '../../map/position.service';
|
||||
import {SearchPageComponent} from './search-page.component';
|
||||
import {Geolocation} from '@capacitor/geolocation';
|
||||
import {BehaviorSubject} from 'rxjs';
|
||||
import {pauseWhen} from '../../../util/pause-when';
|
||||
import {pauseWhen} from '../../../util/rxjs/pause-when';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
|
||||
/**
|
||||
|
||||
@@ -342,7 +342,7 @@ export class SearchPageComponent implements OnInit {
|
||||
.pipe(takeUntilDestroyed(this.destroy$))
|
||||
.subscribe(item => {
|
||||
if (this.itemRouting) {
|
||||
void this.router.navigate(['/data-detail', item.uid]);
|
||||
void this.router.navigate(['/data-detail', item.uid], {state: {item}});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ export class SimpleDataListComponent implements OnInit {
|
||||
.itemSelectListener()
|
||||
.pipe(takeUntilDestroyed(this.destroy$))
|
||||
.subscribe(item => {
|
||||
void this.router.navigate(['/data-detail', item.uid]);
|
||||
void this.router.navigate(['/data-detail', item.uid], {state: {item}});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,16 +13,16 @@
|
||||
~ 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>
|
||||
<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
|
||||
*ngTemplateOutlet="listItemTemplateRef || defaultListItem; context: {$implicit: item}"
|
||||
></ng-container>
|
||||
</ng-container>
|
||||
</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
|
||||
>
|
||||
</ng-container>
|
||||
|
||||
@@ -13,94 +13,93 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Component, Input, OnInit} from '@angular/core';
|
||||
import {SCCatalog, SCSearchBooleanFilter, SCDucetSort} from '@openstapps/core';
|
||||
import {SearchPageComponent} from '../../list/search-page.component';
|
||||
import {SCCatalog, SCThings} from '@openstapps/core';
|
||||
import {DataProvider} from '../../data.provider';
|
||||
|
||||
@Component({
|
||||
selector: 'stapps-catalog-detail-content',
|
||||
templateUrl: 'catalog-detail-content.html',
|
||||
styleUrls: ['catalog-detail-content.scss'],
|
||||
})
|
||||
export class CatalogDetailContentComponent extends SearchPageComponent implements OnInit {
|
||||
export class CatalogDetailContentComponent implements OnInit {
|
||||
/**
|
||||
* SCCatalog to display
|
||||
*/
|
||||
@Input() item: SCCatalog;
|
||||
|
||||
ngOnInit() {
|
||||
super.ngOnInit();
|
||||
}
|
||||
items: Promise<SCThings[]>;
|
||||
|
||||
initialize() {
|
||||
this.showDefaultData = true;
|
||||
this.pageSize = 100;
|
||||
constructor(private dataProvider: DataProvider) {}
|
||||
|
||||
const nameSort: SCDucetSort = {
|
||||
arguments: {field: 'name'},
|
||||
order: 'asc',
|
||||
type: 'ducet',
|
||||
};
|
||||
|
||||
const typeSort: SCDucetSort = {
|
||||
arguments: {field: 'type'},
|
||||
order: 'desc',
|
||||
type: 'ducet',
|
||||
};
|
||||
|
||||
this.sortQuery = [typeSort, nameSort];
|
||||
|
||||
const subCatalogFilter: SCSearchBooleanFilter = {
|
||||
arguments: {
|
||||
operation: 'and',
|
||||
filters: [
|
||||
async ngOnInit() {
|
||||
this.items = this.dataProvider
|
||||
.search({
|
||||
size: 100,
|
||||
sort: [
|
||||
{
|
||||
type: 'value',
|
||||
arguments: {
|
||||
field: 'type',
|
||||
value: 'catalog',
|
||||
},
|
||||
arguments: {field: 'type'},
|
||||
order: 'desc',
|
||||
type: 'ducet',
|
||||
},
|
||||
{
|
||||
type: 'value',
|
||||
arguments: {
|
||||
field: 'superCatalog.uid',
|
||||
value: this.item.uid,
|
||||
},
|
||||
arguments: {field: 'name'},
|
||||
order: 'asc',
|
||||
type: 'ducet',
|
||||
},
|
||||
],
|
||||
},
|
||||
type: 'boolean',
|
||||
};
|
||||
|
||||
const subEventsFilter: SCSearchBooleanFilter = {
|
||||
arguments: {
|
||||
operation: 'and',
|
||||
filters: [
|
||||
{
|
||||
type: 'value',
|
||||
arguments: {
|
||||
field: 'type',
|
||||
value: 'academic event',
|
||||
},
|
||||
filter: {
|
||||
arguments: {
|
||||
filters: [
|
||||
{
|
||||
arguments: {
|
||||
operation: 'and',
|
||||
filters: [
|
||||
{
|
||||
type: 'value',
|
||||
arguments: {
|
||||
field: 'type',
|
||||
value: 'catalog',
|
||||
},
|
||||
},
|
||||
{
|
||||
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: 'value',
|
||||
arguments: {
|
||||
field: 'catalogs.uid',
|
||||
value: this.item.uid,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
type: 'boolean',
|
||||
};
|
||||
|
||||
this.forcedFilter = {
|
||||
arguments: {
|
||||
filters: [subCatalogFilter, subEventsFilter],
|
||||
operation: 'or',
|
||||
},
|
||||
type: 'boolean',
|
||||
};
|
||||
type: 'boolean',
|
||||
},
|
||||
})
|
||||
.then(({data}) => data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,19 +12,49 @@
|
||||
* 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 {Component, Input, OnInit} from '@angular/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({
|
||||
selector: 'stapps-date-series-detail-content',
|
||||
templateUrl: 'date-series-detail-content.html',
|
||||
styleUrls: ['date-series-detail-content.scss'],
|
||||
})
|
||||
export class DateSeriesDetailContentComponent {
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
export class DateSeriesDetailContentComponent implements OnInit {
|
||||
@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
|
||||
~ this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<ion-card>
|
||||
<ion-card-header> {{ 'event' | propertyNameTranslate : item | titlecase }} </ion-card-header>
|
||||
<ion-card-content>
|
||||
<a [routerLink]="['/data-detail', item.event.uid]">{{ 'name' | thingTranslate : item.event }}</a>
|
||||
</ion-card-content>
|
||||
</ion-card>
|
||||
<ion-card *ngIf="item.inPlace">
|
||||
<ion-card-header> {{ 'inPlace' | propertyNameTranslate : item | titlecase }} </ion-card-header>
|
||||
<ion-card-content>
|
||||
<ion-icon name="pin_drop"> </ion-icon>
|
||||
<a [routerLink]="['/data-detail', item.inPlace.uid]">{{ 'name' | thingTranslate : item.inPlace }}</a>
|
||||
<stapps-address-detail
|
||||
*ngIf="item.inPlace.address"
|
||||
[address]="item.inPlace.address"
|
||||
></stapps-address-detail>
|
||||
</ion-card-content>
|
||||
</ion-card>
|
||||
<ng-container *ngIf="isInCalendar | async; else add">
|
||||
<ion-chip outline="true" color="success" (click)="removeFromCalendar()">
|
||||
<ion-icon name="event_available" fill="true"></ion-icon>
|
||||
<ion-label>{{'chips.addEvent.addedToEvents' | translate}}</ion-label>
|
||||
</ion-chip>
|
||||
</ng-container>
|
||||
<ng-template #add>
|
||||
<ion-chip outline="true" color="primary" (click)="addToCalendar()">
|
||||
<ion-icon name="calendar_today"></ion-icon>
|
||||
<ion-label>{{'chips.addEvent.addEvent' | translate}}</ion-label>
|
||||
</ion-chip>
|
||||
</ng-template>
|
||||
<stapps-simple-card
|
||||
title="{{ 'duration' | propertyNameTranslate : item | titlecase }}"
|
||||
[content]="[item.duration | amDuration : 'minutes']"
|
||||
@@ -56,3 +51,16 @@
|
||||
[content]="item.performers"
|
||||
></stapps-simple-card>
|
||||
<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-col>
|
||||
<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>
|
||||
<ion-icon name="calendar_today"></ion-icon>
|
||||
<span *ngIf="item.dates[0] && item.dates[item.dates.length - 1]">
|
||||
|
||||
@@ -59,7 +59,7 @@ export class PlaceDetailContentComponent implements OnInit {
|
||||
.itemSelectListener()
|
||||
.pipe(takeUntilDestroyed())
|
||||
.subscribe(item => {
|
||||
void router.navigate(['/data-detail', item.uid]);
|
||||
void router.navigate(['/data-detail', item.uid], {state: {item}});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -38,9 +38,5 @@
|
||||
</ion-card>
|
||||
</ng-container>
|
||||
<ng-container *ngIf="hasValidLocation">
|
||||
<stapps-map-widget
|
||||
class="map-widget expand-when-space"
|
||||
[place]="item"
|
||||
expandable="true"
|
||||
></stapps-map-widget>
|
||||
<stapps-map-widget [place]="item" expandable="true"></stapps-map-widget>
|
||||
</ng-container>
|
||||
|
||||
@@ -12,10 +12,3 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
.map-widget {
|
||||
position: relative;
|
||||
width: auto;
|
||||
height: 300px;
|
||||
min-height: 300px;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ export class PlaceMensaDetailComponent implements AfterViewInit {
|
||||
.itemSelectListener()
|
||||
.pipe(takeUntilDestroyed(this.destroy$))
|
||||
.subscribe(item => {
|
||||
void this.router.navigate(['/data-detail', item.uid]);
|
||||
void this.router.navigate(['/data-detail', item.uid], {state: {item}});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -112,12 +112,15 @@ export class FavoritesPageComponent extends SearchPageComponent implements OnIni
|
||||
.subscribe(item => {
|
||||
if (this.itemRouting) {
|
||||
if ([SCThingType.Book, SCThingType.Periodical, SCThingType.Article].includes(item.type)) {
|
||||
void this.router.navigate([
|
||||
'hebis-detail',
|
||||
(item.origin && 'originalId' in item.origin && item.origin['originalId']) || '',
|
||||
]);
|
||||
void this.router.navigate(
|
||||
[
|
||||
'hebis-detail',
|
||||
(item.origin && 'originalId' in item.origin && item.origin['originalId']) || '',
|
||||
],
|
||||
{state: {item}},
|
||||
);
|
||||
} 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
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {TranslateService} from '@ngx-translate/core';
|
||||
import {Component, inject, OnInit} from '@angular/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 {DaiaDataProvider} from '../daia-data.provider';
|
||||
import {DaiaHolding} from '../protocol/response';
|
||||
import {ModalController} from '@ionic/angular';
|
||||
import {groupByStable} from '@openstapps/collection-utils';
|
||||
|
||||
/**
|
||||
@@ -37,28 +32,10 @@ export class DaiaAvailabilityComponent extends DataDetailComponent implements On
|
||||
|
||||
holdingsByDepartments?: Map<DaiaHolding['department']['id'], DaiaHolding[]>;
|
||||
|
||||
/**
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
private daiaDataProvider = inject(DaiaDataProvider);
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
* @override
|
||||
*/
|
||||
async ngOnInit() {
|
||||
const uid = this.route.snapshot.paramMap.get('uid');
|
||||
|
||||
@@ -107,8 +107,8 @@ describe('HebisDetailComponent', () => {
|
||||
expect(HebisDetailComponent.prototype.getItem).toHaveBeenCalledWith(sampleThing.uid, false);
|
||||
});
|
||||
|
||||
it('should get a data item when the view is entered', () => {
|
||||
comp.ionViewWillEnter();
|
||||
it('should get a data item when initialized', () => {
|
||||
comp.ngOnInit();
|
||||
expect(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
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Component} from '@angular/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {TranslateService} from '@ngx-translate/core';
|
||||
import {Component, inject, OnInit} from '@angular/core';
|
||||
import {SCUuid} from '@openstapps/core';
|
||||
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 {DaiaHolding} from '../protocol/response';
|
||||
import {ModalController} from '@ionic/angular';
|
||||
|
||||
/**
|
||||
* A Component to display an SCThing detailed
|
||||
@@ -31,33 +26,15 @@ import {ModalController} from '@ionic/angular';
|
||||
styleUrls: ['hebis-detail.scss'],
|
||||
templateUrl: 'hebis-detail.html',
|
||||
})
|
||||
export class HebisDetailComponent extends DataDetailComponent {
|
||||
export class HebisDetailComponent extends DataDetailComponent implements OnInit {
|
||||
holdings: DaiaHolding[];
|
||||
|
||||
/**
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
private hebisDataProvider = inject(HebisDataProvider);
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
* @override
|
||||
*/
|
||||
async ionViewWillEnter() {
|
||||
async ngOnInit() {
|
||||
const uid = this.route.snapshot.paramMap.get('uid') || '';
|
||||
await this.getItem(uid ?? '', false);
|
||||
}
|
||||
@@ -68,9 +45,11 @@ export class HebisDetailComponent extends DataDetailComponent {
|
||||
* @param _forceReload Ignore any cached data
|
||||
*/
|
||||
async getItem(uid: SCUuid, _forceReload: boolean) {
|
||||
this.hebisDataProvider.hebisSearch({query: uid, page: 0}).then(result => {
|
||||
// eslint-disable-next-line unicorn/no-null
|
||||
this.item = (result.data && result.data[0]) || null;
|
||||
});
|
||||
this.item = await (this.inputItem ??
|
||||
this.hebisDataProvider.hebisSearch({query: uid, page: 0}).then(
|
||||
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/>.
|
||||
*/
|
||||
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 {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 {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 {DataProvider} from '../../data/data.provider';
|
||||
|
||||
/**
|
||||
* 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',
|
||||
templateUrl: 'hebis-search-page.html',
|
||||
styleUrls: ['../../data/list/search-page.scss'],
|
||||
providers: [{provide: DataProvider, useClass: HebisDataProvider}],
|
||||
})
|
||||
export class HebisSearchPageComponent extends SearchPageComponent implements OnInit {
|
||||
/**
|
||||
@@ -46,47 +40,6 @@ export class HebisSearchPageComponent extends SearchPageComponent implements OnI
|
||||
*/
|
||||
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
|
||||
* @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;
|
||||
}
|
||||
|
||||
return this.dataProvider.hebisSearch(searchOptions).then(
|
||||
return (this.dataProvider as HebisDataProvider).hebisSearch(searchOptions).then(
|
||||
async result => {
|
||||
/*this.singleTypeResponse =
|
||||
result.facets.find(facet => facet.field === 'type')?.buckets
|
||||
@@ -176,10 +129,10 @@ export class HebisSearchPageComponent extends SearchPageComponent implements OnI
|
||||
.pipe(takeUntilDestroyed(this.destroy$))
|
||||
.subscribe(async item => {
|
||||
if (this.itemRouting) {
|
||||
void this.router.navigate([
|
||||
'hebis-detail',
|
||||
(item.origin && 'originalId' in item.origin && item.origin['originalId']) || '',
|
||||
]);
|
||||
void this.router.navigate(
|
||||
['hebis-detail', (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 {MapProvider} from './map.provider';
|
||||
import {MapPageComponent} from './page/map-page.component';
|
||||
import {MapListModalComponent} from './page/modals/map-list-modal.component';
|
||||
import {MapSingleModalComponent} from './page/modals/map-single-modal.component';
|
||||
import {MapItemComponent} from './item/map-item.component';
|
||||
import {MapListModalComponent} from './page/map-list-modal.component';
|
||||
import {NgModule} from '@angular/core';
|
||||
import {UtilModule} from '../../util/util.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)
|
||||
@@ -56,7 +55,7 @@ const mapRoutes: Routes = [
|
||||
* Module containing map related stuff
|
||||
*/
|
||||
@NgModule({
|
||||
declarations: [MapPageComponent, MapListModalComponent, MapSingleModalComponent, MapItemComponent],
|
||||
declarations: [MapPageComponent, MapListModalComponent],
|
||||
exports: [],
|
||||
imports: [
|
||||
CommonModule,
|
||||
@@ -71,6 +70,8 @@ const mapRoutes: Routes = [
|
||||
FormsModule,
|
||||
ThingTranslateModule,
|
||||
UtilModule,
|
||||
GeoNavigationDirective,
|
||||
GeoNavigationDirective,
|
||||
],
|
||||
providers: [Geolocation, MapProvider, DataProvider, DataFacetsProvider, StAppsWebHttpClient],
|
||||
})
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
import {Component, Input, OnInit} from '@angular/core';
|
||||
import {SCSearchBooleanFilter, SCPlace, SCSearchFilter} from '@openstapps/core';
|
||||
import {MapProvider} from '../../map.provider';
|
||||
import {MapProvider} from '../map.provider';
|
||||
import {ModalController} from '@ionic/angular';
|
||||
import {LatLngBounds} from 'leaflet';
|
||||
|
||||
@@ -23,8 +23,8 @@ import {LatLngBounds} from 'leaflet';
|
||||
*/
|
||||
@Component({
|
||||
selector: 'map-list-modal',
|
||||
templateUrl: 'map-list.html',
|
||||
styleUrls: ['map-list.scss'],
|
||||
templateUrl: 'map-list-modal.html',
|
||||
styleUrls: ['map-list-modal.scss'],
|
||||
})
|
||||
export class MapListModalComponent implements OnInit {
|
||||
/**
|
||||
@@ -27,8 +27,9 @@ import {MapProvider} from '../map.provider';
|
||||
import {MapPosition, PositionService} from '../position.service';
|
||||
import {Geolocation, PermissionStatus} from '@capacitor/geolocation';
|
||||
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 {startViewTransition} from '../../../util/view-transition';
|
||||
|
||||
/**
|
||||
* The main page of the map
|
||||
@@ -100,7 +101,17 @@ export class MapPageComponent implements OnInit {
|
||||
/**
|
||||
* 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
|
||||
@@ -134,20 +145,7 @@ export class MapPageComponent implements OnInit {
|
||||
private dataRoutingService: DataRoutingService,
|
||||
private positionService: PositionService,
|
||||
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() {
|
||||
this.dataRoutingService
|
||||
@@ -158,7 +156,7 @@ export class MapPageComponent implements OnInit {
|
||||
if (this.items.length > 1) {
|
||||
await Promise.all([this.modalController.dismiss(), this.showItem(item.uid)]);
|
||||
} else {
|
||||
void this.router.navigate(['/data-detail', item.uid]);
|
||||
void this.router.navigate(['/data-detail', item.uid], {state: {item}});
|
||||
}
|
||||
});
|
||||
this.positionService
|
||||
@@ -305,6 +303,7 @@ export class MapPageComponent implements OnInit {
|
||||
*/
|
||||
async onMapReady(map: Map) {
|
||||
this.map = map;
|
||||
this.map.attributionControl.setPosition('topright');
|
||||
const interval = window.setInterval(() =>
|
||||
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)
|
||||
*/
|
||||
async resetView() {
|
||||
this.location.go('/map');
|
||||
await this.fetchAndUpdateItems(this.items.length > 0);
|
||||
startViewTransition(async () => {
|
||||
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
|
||||
*/
|
||||
async showItem(uid: SCUuid) {
|
||||
const response = await this.mapProvider.searchPlace(uid);
|
||||
this.items = response.data as SCPlace[];
|
||||
this.distance = this.positionService.getDistance(this.items[0].geo.point);
|
||||
this.addToMap(this.items, true);
|
||||
this.ref.detectChanges();
|
||||
const url = this.router.createUrlTree(['/map', uid]).toString();
|
||||
this.location.go(url);
|
||||
// center the selected place
|
||||
this.focus(geoJSON(this.items[0].geo.point).getBounds().getCenter());
|
||||
startViewTransition(async () => {
|
||||
const response = await this.mapProvider.searchPlace(uid);
|
||||
this.items = response.data as SCPlace[];
|
||||
this.distance = this.positionService.getDistance(this.items[0].geo.point);
|
||||
this.addToMap(this.items, true);
|
||||
this.ref.detectChanges();
|
||||
const url = this.router.createUrlTree(['/map', uid]).toString();
|
||||
this.location.go(url);
|
||||
// center the selected place
|
||||
this.focus(geoJSON(this.items[0].geo.point).getBounds().getCenter());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
||||
<ion-content fullscreen id="map">
|
||||
<ion-content id="map">
|
||||
<div
|
||||
class="map-container"
|
||||
#mapContainer
|
||||
@@ -57,7 +57,7 @@
|
||||
<div *ngIf="position" [leafletLayer]="positionMarker"></div>
|
||||
</div>
|
||||
<div class="floating-content">
|
||||
<div class="map-buttons above">
|
||||
<div class="map-buttons">
|
||||
<ion-button
|
||||
*ngIf="items.length > 1"
|
||||
color="light"
|
||||
@@ -67,7 +67,13 @@
|
||||
>
|
||||
<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-button
|
||||
color="light"
|
||||
shape="round"
|
||||
size="small"
|
||||
(click)="onPositionClick()"
|
||||
class="location-button"
|
||||
>
|
||||
<ion-icon *ngIf="position !== null; else noLocationIcon" name="my_location"></ion-icon>
|
||||
<ng-template #noLocationIcon>
|
||||
<ion-icon
|
||||
@@ -80,30 +86,12 @@
|
||||
</ng-template>
|
||||
</ion-button>
|
||||
</div>
|
||||
<stapps-map-item *ngIf="items.length === 1" [item]="items[0]" (onClose)="resetView()"></stapps-map-item>
|
||||
</div>
|
||||
<div class="map-buttons floating-buttons">
|
||||
<ion-button
|
||||
*ngIf="items.length > 1"
|
||||
color="light"
|
||||
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>
|
||||
<ion-card class="map-item">
|
||||
<stapps-data-list-item *ngIf="items.length === 1" [item]="$any(items[0])"></stapps-data-list-item>
|
||||
<ion-button fill="clear" class="close" (click)="resetView()">
|
||||
<ion-icon size="22" name="close" slot="icon-only"></ion-icon>
|
||||
</ion-button>
|
||||
</ion-card>
|
||||
</div>
|
||||
|
||||
<ion-modal [canDismiss]="true" #mapListModal>
|
||||
|
||||
@@ -12,113 +12,87 @@
|
||||
* 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';
|
||||
|
||||
ion-content {
|
||||
// fixes the unexpected issue that the content is not fullscreen (behind the header)
|
||||
position: absolute;
|
||||
$bottom-offset: 7px; // no idea what happened here
|
||||
|
||||
div.map-container {
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
& > div {
|
||||
overflow: hidden;
|
||||
}
|
||||
.map-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
ion-toolbar:first-of-type {
|
||||
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 {
|
||||
// important for iOS
|
||||
// TODO: find an option that is better suited for the iOS theme
|
||||
--box-shadow: var(--map-box-shadow);
|
||||
|
||||
align-self: flex-end;
|
||||
margin: 4px;
|
||||
margin: var(--spacing-md);
|
||||
|
||||
&.location-button {
|
||||
view-transition-name: location-button;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
::ng-deep {
|
||||
.stapps-location {
|
||||
ion-icon {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
color: #fd435c;
|
||||
}
|
||||
}
|
||||
.map-item {
|
||||
position: relative;
|
||||
max-width: 550px;
|
||||
margin: var(--spacing-md);
|
||||
|
||||
.stapps-device-location {
|
||||
ion-icon {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
color: #4387fd;
|
||||
}
|
||||
}
|
||||
|
||||
div.floating-content {
|
||||
position: fixed;
|
||||
z-index: 1000;
|
||||
.close {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
display: block;
|
||||
justify-content: center;
|
||||
::ng-deep ion-item {
|
||||
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%;
|
||||
padding: 0 var(--spacing-md) 8vh;
|
||||
max-width: unset;
|
||||
margin: 0;
|
||||
|
||||
ion-card {
|
||||
margin: 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;
|
||||
border-bottom-right-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
* 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 {SCPlace} from '@openstapps/core';
|
||||
import {SCPlaceWithoutReferences, SCThingWithoutReferences} from '@openstapps/core';
|
||||
import {geoJSON, Map, MapOptions, tileLayer} from 'leaflet';
|
||||
import {MapProvider} from '../map.provider';
|
||||
|
||||
@@ -27,6 +27,8 @@ import {MapProvider} from '../map.provider';
|
||||
templateUrl: './map-widget.html',
|
||||
})
|
||||
export class MapWidgetComponent implements OnInit {
|
||||
@HostBinding('class.expand-when-space') expandWhenSpace = true;
|
||||
|
||||
/**
|
||||
* A leaflet map showed
|
||||
*/
|
||||
@@ -45,7 +47,7 @@ export class MapWidgetComponent implements OnInit {
|
||||
/**
|
||||
* 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
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
[leafletOptions]="options"
|
||||
></div>
|
||||
<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-icon name="zoom_out_map"></ion-icon>
|
||||
</ion-button>
|
||||
|
||||
@@ -12,6 +12,12 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
:host {
|
||||
position: relative;
|
||||
width: auto;
|
||||
height: 300px;
|
||||
min-height: 300px;
|
||||
}
|
||||
|
||||
div.map-container {
|
||||
pointer-events: none;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
<ion-card
|
||||
[routerLink]="['/data-detail', item.uid]"
|
||||
[state]="{item}"
|
||||
class="card"
|
||||
[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
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {firstValueFrom, Observable, of, Subscription} from 'rxjs';
|
||||
import {Component} from '@angular/core';
|
||||
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 {ScheduleProvider} from '../../calendar/schedule.provider';
|
||||
import moment from 'moment';
|
||||
import {SCIcon} from '../../../util/ion-icon/icon';
|
||||
import {profilePageSections} from '../../../../config/profile-page-sections';
|
||||
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({
|
||||
selector: 'app-home',
|
||||
templateUrl: 'profile-page.html',
|
||||
styleUrls: ['profile-page.scss'],
|
||||
})
|
||||
export class ProfilePageComponent implements OnInit {
|
||||
data: {
|
||||
[key in SCAuthorizationProviderType]: {loggedIn$: Observable<boolean>};
|
||||
} = {
|
||||
default: {loggedIn$: of(false)},
|
||||
paia: {loggedIn$: of(false)},
|
||||
};
|
||||
|
||||
export class ProfilePageComponent {
|
||||
user$ = this.authHelper.getProvider('default').user$.pipe(
|
||||
filter(user => user !== undefined),
|
||||
map(userInfo => {
|
||||
@@ -58,59 +37,18 @@ export class ProfilePageComponent implements OnInit {
|
||||
|
||||
logins: SCAuthorizationProviderType[] = [];
|
||||
|
||||
originPath: string | null;
|
||||
|
||||
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(
|
||||
private authHelper: AuthHelperService,
|
||||
private route: ActivatedRoute,
|
||||
protected readonly scheduleProvider: ScheduleProvider,
|
||||
readonly authHelper: AuthHelperService,
|
||||
readonly activatedRoute: ActivatedRoute,
|
||||
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) {
|
||||
await this.handleOriginPath();
|
||||
this.authHelper.getProvider(providerType).signIn();
|
||||
const originPath = this.activatedRoute.snapshot.queryParamMap.get('origin_path');
|
||||
await (originPath ? this.authHelper.setOriginPath(originPath) : this.authHelper.deleteOriginPath());
|
||||
await this.authHelper.getProvider(providerType).signIn();
|
||||
}
|
||||
|
||||
async signOut(providerType: SCAuthorizationProviderType) {
|
||||
@@ -118,25 +56,6 @@ export class ProfilePageComponent implements OnInit {
|
||||
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() {
|
||||
this.authHelper
|
||||
.getProvider('default')
|
||||
|
||||
@@ -23,76 +23,53 @@
|
||||
</ion-header>
|
||||
|
||||
<ion-content color="light" parallax [parallaxSize]="130">
|
||||
<section class="user-card-wrapper">
|
||||
<ion-card class="user-card">
|
||||
<ion-card-header>
|
||||
<ion-img src="assets/imgs/header.svg"></ion-img>
|
||||
<span *ngIf="user$ | async as userInfo">
|
||||
{{ userInfo.role ? (userInfo?.role | titlecase) : ('profile.role_guest' | translate | titlecase) }}
|
||||
</span>
|
||||
</ion-card-header>
|
||||
<ion-card-content>
|
||||
<ion-img class="profile-card-img" src="assets/imgs/profile-card-head.svg"></ion-img>
|
||||
<ion-grid>
|
||||
<ion-row>
|
||||
<ion-col size="3"></ion-col>
|
||||
<ion-col
|
||||
*ngIf="data.default.loggedIn$ | async as loggedIn; else logInPrompt"
|
||||
size="9"
|
||||
class="main-info"
|
||||
>
|
||||
<ng-container *ngIf="user$ | async as userInfo">
|
||||
<ion-text class="full-name"> {{ userInfo?.name }} </ion-text>
|
||||
<div class="matriculation-number">
|
||||
<ion-label> {{ 'profile.userInfo.studentId' | translate | uppercase }} </ion-label>
|
||||
<ion-text> {{ userInfo?.studentId }} </ion-text>
|
||||
</div>
|
||||
<div class="user-name">
|
||||
<ion-label> {{ 'profile.userInfo.username' | translate | uppercase }} </ion-label>
|
||||
<ion-text>{{ userInfo?.id }}</ion-text>
|
||||
</div>
|
||||
<div class="email">
|
||||
<ion-label> {{ 'profile.userInfo.email' | translate | uppercase }} </ion-label>
|
||||
<ion-text> {{ userInfo?.email }} </ion-text>
|
||||
</div>
|
||||
</ng-container>
|
||||
<ion-card class="user-card">
|
||||
<ion-card-header>
|
||||
<ion-img src="assets/imgs/header.svg"></ion-img>
|
||||
<span *ngIf="user$ | async as userInfo">
|
||||
{{ userInfo.role ? (userInfo?.role | titlecase) : ('profile.role_guest' | translate | titlecase) }}
|
||||
</span>
|
||||
</ion-card-header>
|
||||
<ion-card-content>
|
||||
<ion-img class="profile-card-img" src="assets/imgs/profile-card-head.svg"></ion-img>
|
||||
<ion-grid>
|
||||
<ion-row>
|
||||
<ion-col size="3"></ion-col>
|
||||
<ion-col
|
||||
*ngIf="authHelper.getProvider('default').isAuthenticated$ | async as loggedIn; else logInPrompt"
|
||||
size="9"
|
||||
class="main-info"
|
||||
>
|
||||
<ng-container *ngIf="user$ | async as userInfo">
|
||||
<ion-text class="full-name"> {{ userInfo?.name }} </ion-text>
|
||||
<div class="matriculation-number">
|
||||
<ion-label> {{ 'profile.userInfo.studentId' | translate | uppercase }} </ion-label>
|
||||
<ion-text> {{ userInfo?.studentId }} </ion-text>
|
||||
</div>
|
||||
<div class="user-name">
|
||||
<ion-label> {{ 'profile.userInfo.username' | translate | uppercase }} </ion-label>
|
||||
<ion-text>{{ userInfo?.id }}</ion-text>
|
||||
</div>
|
||||
<div class="email">
|
||||
<ion-label> {{ 'profile.userInfo.email' | translate | uppercase }} </ion-label>
|
||||
<ion-text> {{ userInfo?.email }} </ion-text>
|
||||
</div>
|
||||
</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>
|
||||
<ng-template #logInPrompt>
|
||||
<ion-col size="9">
|
||||
<ion-text class="log-in-prompt"> {{ 'profile.userInfo.logInPrompt' | translate }} </ion-text>
|
||||
</ion-col>
|
||||
</ng-template>
|
||||
</ion-row>
|
||||
</ion-grid>
|
||||
</ion-card-content>
|
||||
</ion-card>
|
||||
</section>
|
||||
</ng-template>
|
||||
</ion-row>
|
||||
</ion-grid>
|
||||
</ion-card-content>
|
||||
</ion-card>
|
||||
<stapps-profile-page-section
|
||||
*ngFor="let section of sections"
|
||||
[item]="section"
|
||||
></stapps-profile-page-section>
|
||||
<section class="courses">
|
||||
<ion-label class="section-headline"> {{ 'profile.titleCourses' | translate | uppercase }} </ion-label>
|
||||
<ion-card class="courses-card">
|
||||
<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>
|
||||
<stapps-section [title]="'profile.titleCourses' | translate">
|
||||
<my-courses [visibleDays]="5"></my-courses>
|
||||
</stapps-section>
|
||||
</ion-content>
|
||||
|
||||
@@ -12,216 +12,106 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
:host {
|
||||
section {
|
||||
margin-bottom: calc(2 * var(--spacing-lg) - var(--spacing-md));
|
||||
padding: var(--spacing-md);
|
||||
// TODO: clean up this mess
|
||||
.user-card {
|
||||
position: relative;
|
||||
|
||||
&:last-of-type {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
max-width: 400px;
|
||||
margin: var(--spacing-xl);
|
||||
|
||||
.section-headline {
|
||||
margin-bottom: var(--spacing-md);
|
||||
}
|
||||
border-radius: var(--border-radius-default);
|
||||
box-shadow: var(--shadow-profile-card);
|
||||
|
||||
.user-card-wrapper {
|
||||
margin-bottom: 0;
|
||||
ion-card-header {
|
||||
--background: var(--ion-color-tertiary);
|
||||
|
||||
.user-card {
|
||||
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 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding-top: var(--spacing-sm);
|
||||
padding-bottom: var(--spacing-sm);
|
||||
|
||||
width: 80%;
|
||||
height: 80%;
|
||||
margin: 0;
|
||||
padding: 10px;
|
||||
|
||||
background: var(--placeholder-gray);
|
||||
border-radius: var(--border-radius-default);
|
||||
|
||||
ion-icon {
|
||||
ion-img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
color: white;
|
||||
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-row.main-info {
|
||||
margin-bottom: 2px;
|
||||
font-weight: bold;
|
||||
}
|
||||
ion-card-content {
|
||||
min-height: 15vh;
|
||||
|
||||
.courses {
|
||||
.courses-card {
|
||||
max-width: 800px;
|
||||
margin: 0;
|
||||
.profile-card-img {
|
||||
position: absolute;
|
||||
|
||||
background-color: unset;
|
||||
border-radius: var(--border-radius-default) var(--border-radius-default) 0 0;
|
||||
box-shadow: none;
|
||||
width: 50%;
|
||||
height: 100%;
|
||||
margin-left: calc(var(--spacing-md) * -4);
|
||||
|
||||
ion-card-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
opacity: 0.13;
|
||||
object-position: left bottom;
|
||||
}
|
||||
|
||||
background-color: var(--ion-item-background);
|
||||
border-radius: var(--border-radius-default) var(--border-radius-default) 0 0;
|
||||
.main-info {
|
||||
display: grid;
|
||||
grid-template-areas:
|
||||
'fullName fullName'
|
||||
'matriculationNumber userName'
|
||||
'email email';
|
||||
|
||||
span {
|
||||
font-size: var(--font-size-lg);
|
||||
font-weight: var(--font-weight-bold);
|
||||
color: var(--ion-item-background-color-contrast);
|
||||
}
|
||||
|
||||
ion-icon {
|
||||
cursor: pointer;
|
||||
color: var(--ion-color-light);
|
||||
}
|
||||
ion-label {
|
||||
display: block;
|
||||
font-size: var(--font-size-sm);
|
||||
font-weight: var(--font-weight-bold);
|
||||
color: var(--ion-color-medium-shade);
|
||||
}
|
||||
|
||||
ion-card-content {
|
||||
overflow: hidden;
|
||||
|
||||
max-height: 0;
|
||||
margin: 0;
|
||||
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);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
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 {ProfilePageSectionComponent} from './page/profile-page-section.component';
|
||||
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 = [
|
||||
{
|
||||
@@ -34,7 +36,7 @@ const routes: Routes = [
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
declarations: [ProfilePageComponent, ProfilePageSectionComponent],
|
||||
declarations: [MyCoursesComponent, ProfilePageComponent, ProfilePageSectionComponent],
|
||||
imports: [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
@@ -45,6 +47,8 @@ const routes: Routes = [
|
||||
SwiperModule,
|
||||
UtilModule,
|
||||
ThingTranslateModule,
|
||||
DataModule,
|
||||
MomentModule,
|
||||
],
|
||||
})
|
||||
export class ProfilePageModule {}
|
||||
|
||||
@@ -136,7 +136,7 @@ export class SchedulePageComponent implements OnInit, AfterViewInit {
|
||||
onInit() {
|
||||
this.tabChoreographer = new SharedAxisChoreographer(this.activatedRoute.snapshot.paramMap.get('mode'), [
|
||||
'calendar',
|
||||
'recurring',
|
||||
'week-overview',
|
||||
'single',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -18,15 +18,18 @@
|
||||
<ion-buttons slot="start">
|
||||
<ion-back-button></ion-back-button>
|
||||
</ion-buttons>
|
||||
<ion-title *ngIf="tabChoreographer.currentValue === 'calendar'"
|
||||
>{{ 'schedule.calendar' | translate | titlecase }}</ion-title
|
||||
>
|
||||
<ion-title *ngIf="tabChoreographer.currentValue === 'recurring'"
|
||||
>{{ 'schedule.recurring' | translate | titlecase }}</ion-title
|
||||
>
|
||||
<ion-title *ngIf="tabChoreographer.currentValue === 'single'"
|
||||
>{{ 'schedule.single' | translate | titlecase }}</ion-title
|
||||
>
|
||||
<ion-title
|
||||
*ngIf="tabChoreographer.currentValue === 'calendar'"
|
||||
[innerHTML]="'schedule.calendar' | translate | titlecase"
|
||||
></ion-title>
|
||||
<ion-title
|
||||
*ngIf="tabChoreographer.currentValue === 'week-overview'"
|
||||
[innerHTML]="'schedule.recurring' | translate | titlecase"
|
||||
></ion-title>
|
||||
<ion-title
|
||||
*ngIf="tabChoreographer.currentValue === 'single'"
|
||||
[innerHTML]="'schedule.single' | translate | titlecase"
|
||||
></ion-title>
|
||||
<ion-buttons slot="end">
|
||||
<ion-button (click)="onTodayClick()">
|
||||
<ion-icon name="today" slot="icon-only"></ion-icon>
|
||||
@@ -36,15 +39,15 @@
|
||||
<ion-toolbar color="primary" mode="md" class="tabs-toolbar">
|
||||
<ion-segment #segment value="calendar" (ionChange)="onSegmentChange()">
|
||||
<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-segment-button>
|
||||
<ion-segment-button value="recurring" layout="icon-start">
|
||||
<ion-label>{{ 'schedule.recurring' | translate }}</ion-label>
|
||||
<ion-segment-button value="week-overview" layout="icon-start">
|
||||
<ion-label class="ion-text-wrap" [innerHTML]="'schedule.recurring' | translate"></ion-label>
|
||||
<ion-icon name="event_repeat"></ion-icon>
|
||||
</ion-segment-button>
|
||||
<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-segment-button>
|
||||
</ion-segment>
|
||||
@@ -59,7 +62,7 @@
|
||||
>
|
||||
<stapps-calendar-view *ngSwitchCase="'calendar'" [layout]="layout"></stapps-calendar-view>
|
||||
<!-- 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>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ import {ChooseEventsPageComponent} from './page/choose-events-page.component';
|
||||
const settingsRoutes: Routes = [
|
||||
{path: 'schedule', 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'},
|
||||
// calendar | recurring | single
|
||||
{path: 'schedule/:mode/:date', component: SchedulePageComponent},
|
||||
|
||||
@@ -12,13 +12,11 @@
|
||||
* 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 {Injectable, OnDestroy, Pipe, PipeTransform} from '@angular/core';
|
||||
import {LangChangeEvent, TranslateService} from '@ngx-translate/core';
|
||||
import moment from 'moment';
|
||||
import {Subscription} from 'rxjs';
|
||||
import {logger} from '../_helpers/ts-logger';
|
||||
import opening_hours from 'opening_hours';
|
||||
|
||||
@Injectable()
|
||||
@Pipe({
|
||||
@@ -110,141 +108,6 @@ export class StringSplitPipe implements PipeTransform {
|
||||
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()
|
||||
@Pipe({
|
||||
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 german from '../../assets/i18n/de.json';
|
||||
|
||||
const exceptions = new Set([
|
||||
'login',
|
||||
'ok',
|
||||
'protein',
|
||||
'feedback',
|
||||
'name',
|
||||
'status',
|
||||
'issn',
|
||||
'ejournal',
|
||||
'backup',
|
||||
'export',
|
||||
'dashboard',
|
||||
'home',
|
||||
'email',
|
||||
'logins',
|
||||
'https://www.swffm.de/essen-trinken/uebersicht/umweltscore',
|
||||
]);
|
||||
const exceptions = new Set(
|
||||
[
|
||||
'login',
|
||||
'ok',
|
||||
'protein',
|
||||
'feedback',
|
||||
'name',
|
||||
'status',
|
||||
'issn',
|
||||
'ejournal',
|
||||
'backup',
|
||||
'export',
|
||||
'dashboard',
|
||||
'home',
|
||||
'email',
|
||||
'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 = [
|
||||
['english', english],
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ModuleWithProviders, NgModule, Provider} from '@angular/core';
|
||||
import {
|
||||
ArrayJoinPipe,
|
||||
@@ -23,7 +22,6 @@ import {
|
||||
IsNumericPipe,
|
||||
MetersLocalizedPipe,
|
||||
NumberLocalizedPipe,
|
||||
OpeningHoursPipe,
|
||||
SentenceCasePipe,
|
||||
StringSplitPipe,
|
||||
ToUnixPipe,
|
||||
@@ -51,7 +49,6 @@ export interface ThingTranslateModuleConfig {
|
||||
ThingTranslatePipe,
|
||||
TranslateSimplePipe,
|
||||
DateLocalizedFormatPipe,
|
||||
OpeningHoursPipe,
|
||||
SentenceCasePipe,
|
||||
ToUnixPipe,
|
||||
EntriesPipe,
|
||||
@@ -69,7 +66,6 @@ export interface ThingTranslateModuleConfig {
|
||||
ThingTranslatePipe,
|
||||
TranslateSimplePipe,
|
||||
DateLocalizedFormatPipe,
|
||||
OpeningHoursPipe,
|
||||
SentenceCasePipe,
|
||||
ToUnixPipe,
|
||||
EntriesPipe,
|
||||
|
||||
@@ -25,6 +25,9 @@ import {
|
||||
import moment from 'moment';
|
||||
import {isDefined, ThingTranslateParser} from './thing-translate.parser';
|
||||
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');
|
||||
|
||||
@@ -40,8 +43,13 @@ export class ThingTranslateService {
|
||||
*
|
||||
* @param translateService Instance of Angular TranslateService
|
||||
* @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(
|
||||
(translateService.currentLang ?? translateService.defaultLang) as SCLanguageCode,
|
||||
);
|
||||
@@ -49,6 +57,10 @@ export class ThingTranslateService {
|
||||
this.translateService.onLangChange.pipe(takeUntilDestroyed()).subscribe((event: LangChangeEvent) => {
|
||||
this.translator.language = event.lang as keyof SCTranslations<SCLanguage>;
|
||||
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
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {Component, ContentChild, Input, OnDestroy, OnInit, TemplateRef} from '@angular/core';
|
||||
import opening_hours from 'opening_hours';
|
||||
import {ChangeDetectionStrategy, Component, ContentChild, Input, TemplateRef} from '@angular/core';
|
||||
import {interval, Observable} from 'rxjs';
|
||||
import {fromOpeningHours} from './opening-hours';
|
||||
import {map, startWith} from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
selector: 'stapps-opening-hours',
|
||||
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>;
|
||||
|
||||
@Input() openingHours?: string;
|
||||
|
||||
@Input() colorize = 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() {
|
||||
if (typeof this.openingHours !== 'string') {
|
||||
return;
|
||||
}
|
||||
clearTimeout(this.timer);
|
||||
|
||||
const ohObject = new opening_hours(this.openingHours, {
|
||||
address: {
|
||||
country_code: 'de',
|
||||
state: 'Hessen',
|
||||
},
|
||||
lon: 8.667_97,
|
||||
lat: 50.129_16,
|
||||
});
|
||||
|
||||
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);
|
||||
@Input() set openingHours(value: string | undefined) {
|
||||
if (!value) return;
|
||||
this.openingHours$ = fromOpeningHours(value).pipe(
|
||||
map(({isUnknown, isOpen, changesSoon, nextChange, comment}) => ({
|
||||
color: isUnknown ? 'light' : changesSoon ? 'warning' : isOpen ? 'success' : 'danger',
|
||||
statusName: `common.openingHours.state_${isUnknown ? 'maybe' : isOpen ? 'open' : 'closed'}`,
|
||||
statusText: comment,
|
||||
nextChangeAction: isOpen ? 'closing' : 'opening',
|
||||
nextChangeSoon: changesSoon
|
||||
? interval(60_000).pipe(
|
||||
startWith(nextChange),
|
||||
map(() => nextChange),
|
||||
)
|
||||
: undefined,
|
||||
nextChange,
|
||||
})),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,18 +13,20 @@
|
||||
~ this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<ng-container *ngIf="openingHours">
|
||||
<div>
|
||||
<ng-template [ngIf]="colorize" [ngIfElse]="blank">
|
||||
<ion-badge
|
||||
[color]="openingHours | openingHours | slice : 0 : 1 | join : ' '"
|
||||
slot="start"
|
||||
style="vertical-align: bottom"
|
||||
>
|
||||
{{ openingHours | openingHours | slice : 1 : 2 }}
|
||||
</ion-badge>
|
||||
</ng-template>
|
||||
<ng-template #blank> {{ openingHours | openingHours | slice : 1 : 2 }} </ng-template>
|
||||
<ng-container *ngIf="showNextChange"> {{ openingHours | openingHours | slice : 2 : 3 }} </ng-container>
|
||||
</div>
|
||||
</ng-container>
|
||||
<div *ngIf="openingHours$ | async as openingHours">
|
||||
<ion-badge *ngIf="colorize; else blank" [color]="openingHours.color" slot="start">
|
||||
{{ openingHours.statusName | translate }}
|
||||
</ion-badge>
|
||||
<ng-template #blank>{{ openingHours.statusName | translate }}</ng-template>
|
||||
<ng-container *ngIf="openingHours.statusText; else nextChange"> {{openingHours.statusText}} </ng-container>
|
||||
<ng-template #nextChange>
|
||||
<ng-container *ngIf="showNextChange && openingHours.nextChangeSoon">
|
||||
{{ ('common.openingHours.' + openingHours.nextChangeAction + '_soon') | translate: {duration:
|
||||
(openingHours.nextChangeSoon | async | dfnsFormatDistanceToNowStrict: {unit: 'minute'})} }}
|
||||
</ng-container>
|
||||
<ng-container *ngIf="showNextChange && !openingHours.nextChangeSoon">
|
||||
{{ ('common.openingHours.' + openingHours.nextChangeAction) | translate: {date: openingHours.nextChange
|
||||
| dfnsFormatRelativeToNow} }}
|
||||
</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