mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-03-14 02:32:50 +00:00
Compare commits
2 Commits
189-add-su
...
192-fix-te
| Author | SHA1 | Date | |
|---|---|---|---|
|
180491cdd2
|
|||
|
|
689ac68be3 |
9
.changeset/fair-monkeys-tickle.md
Normal file
9
.changeset/fair-monkeys-tickle.md
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
"@openstapps/node-builder": patch
|
||||
"@openstapps/database": patch
|
||||
"@openstapps/node-base": patch
|
||||
"@openstapps/backend": patch
|
||||
"@openstapps/app": patch
|
||||
---
|
||||
|
||||
pin alpine version to 3.18 and add healthchecks
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"@openstapps/prettier-config": patch
|
||||
---
|
||||
|
||||
Update Prettier to 3.1.1
|
||||
@@ -1,6 +0,0 @@
|
||||
---
|
||||
"@openstapps/backend": minor
|
||||
"@openstapps/core": minor
|
||||
---
|
||||
|
||||
Add the ability to filter by existence of a field
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"@openstapps/backend": patch
|
||||
---
|
||||
|
||||
Backend unit tests break every year
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -24,7 +24,6 @@ report-junit.xml
|
||||
# NixOS flake
|
||||
result
|
||||
hsperfdata_root
|
||||
.direnv/
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/** @type {import('syncpack').RcFile} */
|
||||
const config = {
|
||||
semverGroups: [{range: ''}],
|
||||
semverRange: '',
|
||||
source: ['package.json', '**/package.json'],
|
||||
indent: ' ',
|
||||
sortFirst: [
|
||||
@@ -49,7 +49,7 @@ const config = {
|
||||
{
|
||||
label: 'Packages should use workspace version',
|
||||
dependencies: ['@openstapps/**'],
|
||||
dependencyTypes: ['prod', 'dev', 'peer'],
|
||||
dependencyTypes: ['prod', 'dev'],
|
||||
packages: ['**'],
|
||||
pinVersion: 'workspace:*',
|
||||
},
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
nodejs 18.16.1
|
||||
pnpm 8.8.0
|
||||
python 3.11.5
|
||||
@@ -9,4 +9,6 @@ ENV NODE_ENV=production
|
||||
WORKDIR /app
|
||||
|
||||
EXPOSE 3000
|
||||
HEALTHCHECK --interval=10s --timeout=10s --start-period=10s --retries=12 CMD curl -s --fail --request POST --data '{}' --header 'Content-Type: application/json' http://localhost:3000/ >/dev/null || exit 1
|
||||
|
||||
ENTRYPOINT ["node", "app.js"]
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// @ts-check
|
||||
|
||||
/**
|
||||
* This is the database configuration for the technical university of berlin
|
||||
*
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
import {SCSettingInputType, SCThingOriginType, SCThingType} from '@openstapps/core';
|
||||
|
||||
/** @type {import('@openstapps/core').SCLanguageSetting} */
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
/** @type {import('@openstapps/core').SCAppConfigurationMenuCategory[]} */
|
||||
const menus = [
|
||||
{
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
import {SCSettingInputType, SCThingOriginType, SCThingType} from '@openstapps/core';
|
||||
|
||||
/** @type {import('@openstapps/core').SCUserGroupSetting} */
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
import {SCThingType} from '@openstapps/core';
|
||||
|
||||
/** @type {import('@openstapps/core').SCBackendAggregationConfiguration[]} */
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
import {
|
||||
month,
|
||||
sommerRange,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
import {SCThingType} from '@openstapps/core';
|
||||
import aggregations from './aggregations.js';
|
||||
import boostings from './boostings.js';
|
||||
@@ -16,7 +17,7 @@ export const backend = {
|
||||
hiddenTypes: [SCThingType.DateSeries, SCThingType.Diff, SCThingType.Floor],
|
||||
mappingIgnoredTags: ['minlength', 'pattern', 'see', 'tjs-format'],
|
||||
maxMultiSearchRouteQueries: 5,
|
||||
maxRequestBodySize: 2e6,
|
||||
maxRequestBodySize: 2 * 10 ** 6,
|
||||
name: 'Goethe-Universität Frankfurt am Main',
|
||||
namespace: '909a8cbc-8520-456c-b474-ef1525f14209',
|
||||
sortableFields: [
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
import app from './app/index.js';
|
||||
import {backend, internal} from './backend/index.js';
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// @ts-check
|
||||
|
||||
/**
|
||||
* This is the default configuration for elasticsearch (a database)
|
||||
*
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
import {readFile} from 'fs/promises';
|
||||
import {SCAboutPageContentType} from '@openstapps/core';
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
/**
|
||||
* Generates a range of numbers that represent consecutive calendar months
|
||||
*
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
import {readFile, readdir} from 'fs/promises';
|
||||
import url from 'url';
|
||||
import path from 'path';
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
import {SCAboutPageContentType} from '@openstapps/core';
|
||||
import {markdown} from '../../default/tools/markdown.js';
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
import {SCAboutPageContentType} from '@openstapps/core';
|
||||
|
||||
/** @type {import('@openstapps/core').SCAboutPage} */
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
import about from './about.js';
|
||||
import imprint from './imprint.js';
|
||||
import privacy from './privacy.js';
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
import {markdown} from '../../default/tools/markdown.js';
|
||||
|
||||
/** @type {import('@openstapps/core').SCAboutPage} */
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
import aboutPages from './about-pages/index.js';
|
||||
import defaultApp from '../default/app/index.js';
|
||||
import {backend as defaultBackend, internal as defaultInternal} from '../default/backend/index.js';
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
import {versions} from '../../default/tools/version.js';
|
||||
|
||||
/** @type {import('@openstapps/core').SCAppVersionInfo[]} */
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
"start:debug": "cross-env STAPPS_LOG_LEVEL=31 NODE_CONFIG_ENV=elasticsearch ALLOW_NO_TRANSPORT=true node app.js",
|
||||
"test": "pnpm run test:unit",
|
||||
"test:integration": "sh integration-test.sh",
|
||||
"test:unit": "cross-env NODE_CONFIG_ENV=elasticsearch ALLOW_NO_TRANSPORT=true STAPPS_LOG_LEVEL=0 mocha --exit"
|
||||
"test:unit": "cross-env NODE_CONFIG_ENV=elasticsearch ALLOW_NO_TRANSPORT=true STAPPS_LOG_LEVEL=0 c8 mocha"
|
||||
},
|
||||
"dependencies": {
|
||||
"@elastic/elasticsearch": "8.4.0",
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
import {Logger, SMTP} from '@openstapps/logger';
|
||||
import {MailOptions} from 'nodemailer/lib/sendmail-transport';
|
||||
import Queue from 'promise-queue';
|
||||
|
||||
/**
|
||||
* A queue that can send mails in serial
|
||||
*/
|
||||
@@ -32,80 +32,45 @@ export class MailQueue {
|
||||
static readonly VERIFICATION_TIMEOUT = 5000;
|
||||
|
||||
/**
|
||||
* A queue that saves mails, before the transport is ready. When
|
||||
* the transport gets ready this mails are getting pushed in to
|
||||
* the normal queue.
|
||||
* A promise that resolves when the last mail was sent
|
||||
*/
|
||||
dryQueue: MailOptions[];
|
||||
|
||||
/**
|
||||
* A queue that saves mails, that are being sent in series
|
||||
*/
|
||||
queue: Queue;
|
||||
|
||||
/**
|
||||
* A counter for the number of verifications that failed
|
||||
*/
|
||||
verificationCounter: number;
|
||||
last?: Promise<string>;
|
||||
|
||||
/**
|
||||
* Creates a mail queue
|
||||
* @param transport Transport which is used for sending mails
|
||||
*/
|
||||
constructor(private readonly transport: SMTP) {
|
||||
this.queue = new Queue(1);
|
||||
|
||||
// this queue saves all request when the transport is not ready yet
|
||||
this.dryQueue = [];
|
||||
|
||||
this.verificationCounter = 0;
|
||||
|
||||
// if the transport can be verified it should check if it was done...
|
||||
this.checkForVerification();
|
||||
}
|
||||
constructor(private readonly transport: SMTP) {}
|
||||
|
||||
/**
|
||||
* Adds a mail into the queue so it gets send when the queue is ready
|
||||
* @param mail Information required for sending a mail
|
||||
* Wait for the transport to be verified
|
||||
*/
|
||||
private async addToQueue(mail: MailOptions) {
|
||||
return this.queue.add<string>(() => this.transport.sendMail(mail));
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the given transport
|
||||
*/
|
||||
private checkForVerification() {
|
||||
if (this.verificationCounter >= MailQueue.MAX_VERIFICATION_ATTEMPTS) {
|
||||
throw new Error('Failed to initialize the SMTP transport for the mail queue');
|
||||
}
|
||||
|
||||
if (this.transport.isVerified()) {
|
||||
Logger.ok('Transport for mail queue was verified. We can send mails now');
|
||||
// if the transport finally was verified send all our mails from the dry queue
|
||||
for (const mail of this.dryQueue) {
|
||||
void this.addToQueue(mail);
|
||||
private async waitForVerification() {
|
||||
for (let i = 0; i < MailQueue.MAX_VERIFICATION_ATTEMPTS; i++) {
|
||||
if (this.transport.isVerified()) {
|
||||
Logger.ok('Transport for mail queue was verified. We can send mails now');
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
this.verificationCounter++;
|
||||
setTimeout(() => {
|
||||
Logger.warn('Transport not verified yet. Trying to send mails here...');
|
||||
this.checkForVerification();
|
||||
}, MailQueue.VERIFICATION_TIMEOUT);
|
||||
await new Promise(resolve => setTimeout(resolve, MailQueue.VERIFICATION_TIMEOUT));
|
||||
Logger.warn('Transport not verified yet. Trying to send mails here...');
|
||||
}
|
||||
throw new Error('Failed to initialize the SMTP transport for the mail queue');
|
||||
}
|
||||
|
||||
/**
|
||||
* Push a mail into the queue so it gets send when the queue is ready
|
||||
* @param mail Information required for sending a mail
|
||||
*/
|
||||
public async push(mail: MailOptions) {
|
||||
if (this.transport.isVerified()) {
|
||||
await this.addToQueue(mail);
|
||||
} else {
|
||||
// the transport has verification, but is not verified yet
|
||||
// push to a dry queue which gets pushed to the real queue when the transport is verified
|
||||
this.dryQueue.push(mail);
|
||||
}
|
||||
public async push(mail: MailOptions): Promise<string> {
|
||||
const previousQueue = this.last ?? this.waitForVerification();
|
||||
this.last = previousQueue.then(() =>
|
||||
Promise.race([
|
||||
this.transport.sendMail(mail),
|
||||
new Promise<string>((_, reject) =>
|
||||
setTimeout(() => reject(new Error('Timeout')), MailQueue.VERIFICATION_TIMEOUT),
|
||||
),
|
||||
]),
|
||||
);
|
||||
return this.last;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,31 +21,16 @@ import {QueryDslSpecificQueryContainer} from '../../types/util.js';
|
||||
*/
|
||||
export function buildValueFilter(
|
||||
filter: SCSearchValueFilter,
|
||||
):
|
||||
| QueryDslSpecificQueryContainer<'exists'>
|
||||
| QueryDslSpecificQueryContainer<'term'>
|
||||
| QueryDslSpecificQueryContainer<'terms'> {
|
||||
switch (typeof filter.arguments.value) {
|
||||
case 'undefined': {
|
||||
return {
|
||||
exists: {
|
||||
field: filter.arguments.field,
|
||||
): QueryDslSpecificQueryContainer<'term'> | QueryDslSpecificQueryContainer<'terms'> {
|
||||
return Array.isArray(filter.arguments.value)
|
||||
? {
|
||||
terms: {
|
||||
[`${filter.arguments.field}.raw`]: filter.arguments.value,
|
||||
},
|
||||
};
|
||||
}
|
||||
case 'string': {
|
||||
return {
|
||||
}
|
||||
: {
|
||||
term: {
|
||||
[`${filter.arguments.field}.raw`]: filter.arguments.value,
|
||||
},
|
||||
};
|
||||
}
|
||||
case 'object': {
|
||||
return {
|
||||
terms: {
|
||||
[`${filter.arguments.field}.raw`]: filter.arguments.value,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ describe('MailQueue', async function () {
|
||||
clock.tick(MailQueue.VERIFICATION_TIMEOUT * (MailQueue.MAX_VERIFICATION_ATTEMPTS + 1));
|
||||
};
|
||||
|
||||
expect(() => test()).to.throw();
|
||||
expect(test).to.throw();
|
||||
expect(loggerStub.callCount).to.be.equal(MailQueue.MAX_VERIFICATION_ATTEMPTS);
|
||||
});
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {
|
||||
SCBook,
|
||||
SCBulkAddRoute,
|
||||
SCBulkDoneRoute,
|
||||
SCBulkRequest,
|
||||
@@ -24,30 +23,29 @@ import {
|
||||
import {expect} from 'chai';
|
||||
import {bulk, DEFAULT_TEST_TIMEOUT} from '../common.js';
|
||||
import {testApp} from '../tests-setup.js';
|
||||
import {readFile} from 'fs/promises';
|
||||
import {v4} from 'uuid';
|
||||
import bookFile from '@openstapps/core/test/resources/indexable/Book.2.json' assert {type: 'json'};
|
||||
|
||||
const book = bookFile.instance as SCBook;
|
||||
const book = JSON.parse(
|
||||
await readFile('node_modules/@openstapps/core/test/resources/indexable/Book.2.json', 'utf8'),
|
||||
).instance;
|
||||
|
||||
describe('Bulk routes', async function () {
|
||||
// increase timeout for the suite
|
||||
this.timeout(DEFAULT_TEST_TIMEOUT);
|
||||
|
||||
let request: SCBulkRequest;
|
||||
let bulkRoute: SCBulkRoute;
|
||||
let bulkAddRoute: SCBulkAddRoute;
|
||||
let bulkDoneRoute: SCBulkDoneRoute;
|
||||
const request: SCBulkRequest = {
|
||||
expiration: bulk.expiration,
|
||||
source: bulk.source,
|
||||
type: bulk.type,
|
||||
};
|
||||
const bulkRoute = new SCBulkRoute();
|
||||
const bulkAddRoute = new SCBulkAddRoute();
|
||||
const bulkDoneRoute = new SCBulkDoneRoute();
|
||||
|
||||
before(function () {
|
||||
request = {
|
||||
expiration: bulk.expiration,
|
||||
source: bulk.source,
|
||||
type: bulk.type,
|
||||
};
|
||||
bulkRoute = new SCBulkRoute();
|
||||
bulkAddRoute = new SCBulkAddRoute();
|
||||
bulkDoneRoute = new SCBulkDoneRoute();
|
||||
});
|
||||
// afterEach(async function() {
|
||||
// TODO: Delete saved bulks
|
||||
// });
|
||||
|
||||
it('should create bulk', async function () {
|
||||
const {status, body, error} = await testApp
|
||||
|
||||
@@ -21,12 +21,7 @@ import {expect} from 'chai';
|
||||
describe('Index route', async function () {
|
||||
// increase timeout for the suite
|
||||
this.timeout(DEFAULT_TEST_TIMEOUT);
|
||||
|
||||
let indexRoute: SCIndexRoute;
|
||||
|
||||
before(function () {
|
||||
indexRoute = new SCIndexRoute();
|
||||
});
|
||||
const indexRoute = new SCIndexRoute();
|
||||
|
||||
it('should respond with both app and backend configuration', async function () {
|
||||
const request: SCIndexRequest = {};
|
||||
|
||||
@@ -30,11 +30,15 @@ import chaiAsPromised from 'chai-as-promised';
|
||||
import {DEFAULT_TEST_TIMEOUT} from '../common.js';
|
||||
import {testApp} from '../tests-setup.js';
|
||||
import {backendConfig} from '../../src/config.js';
|
||||
import registerRequest from '@openstapps/core/test/resources/PluginRegisterRequest.1.json' assert {type: 'json'};
|
||||
import {readFile} from 'fs/promises';
|
||||
|
||||
// for using promises in expectations (to.eventually.be...)
|
||||
use(chaiAsPromised);
|
||||
|
||||
const registerRequest = JSON.parse(
|
||||
await readFile('node_modules/@openstapps/core/test/resources/PluginRegisterRequest.1.json', 'utf8'),
|
||||
);
|
||||
|
||||
// cast it because of "TS2322: Type 'string' is not assignable to type '"add"'"
|
||||
export const registerAddRequest: SCPluginAdd = registerRequest.instance as SCPluginAdd;
|
||||
|
||||
|
||||
@@ -47,8 +47,8 @@ describe('Create route', async function () {
|
||||
const statusCodeSuccess = 222;
|
||||
const bodySuccess = {foo: true};
|
||||
const sandbox = sinon.createSandbox();
|
||||
let validationError: SCValidationErrorResponse;
|
||||
let internalServerError: SCInternalServerErrorResponse;
|
||||
const validationError = new SCValidationErrorResponse([]);
|
||||
const internalServerError = new SCInternalServerErrorResponse();
|
||||
|
||||
beforeEach(function () {
|
||||
app = express();
|
||||
@@ -64,9 +64,6 @@ describe('Create route', async function () {
|
||||
handler = (_request, _app) => {
|
||||
return Promise.resolve(bodySuccess);
|
||||
};
|
||||
|
||||
validationError = new SCValidationErrorResponse([]);
|
||||
internalServerError = new SCInternalServerErrorResponse();
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
|
||||
@@ -29,19 +29,11 @@ import {backendConfig} from '../../src/config.js';
|
||||
describe('Search route', async function () {
|
||||
// increase timeout for the suite
|
||||
this.timeout(DEFAULT_TEST_TIMEOUT);
|
||||
let searchRoute: SCSearchRoute;
|
||||
let multiSearchRoute: SCMultiSearchRoute;
|
||||
let syntaxError: SCSyntaxErrorResponse;
|
||||
let methodNotAllowedError: SCMethodNotAllowedErrorResponse;
|
||||
let tooManyRequestsError: SCTooManyRequestsErrorResponse;
|
||||
|
||||
before(function () {
|
||||
searchRoute = new SCSearchRoute();
|
||||
multiSearchRoute = new SCMultiSearchRoute();
|
||||
syntaxError = new SCSyntaxErrorResponse('Foo Message');
|
||||
methodNotAllowedError = new SCMethodNotAllowedErrorResponse();
|
||||
tooManyRequestsError = new SCTooManyRequestsErrorResponse();
|
||||
});
|
||||
const searchRoute = new SCSearchRoute();
|
||||
const multiSearchRoute = new SCMultiSearchRoute();
|
||||
const syntaxError = new SCSyntaxErrorResponse('Foo Message');
|
||||
const methodNotAllowedError = new SCMethodNotAllowedErrorResponse();
|
||||
const tooManyRequestsError = new SCTooManyRequestsErrorResponse();
|
||||
|
||||
it('should reject GET, PUT with a valid search query', async function () {
|
||||
// const expectedParams = JSON.parse(JSON.stringify(defaultParams));
|
||||
|
||||
@@ -13,25 +13,23 @@
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCBook, SCThingUpdateRoute} from '@openstapps/core';
|
||||
import {SCThingUpdateRoute} from '@openstapps/core';
|
||||
import chaiAsPromised from 'chai-as-promised';
|
||||
import {bulkStorageMock, DEFAULT_TEST_TIMEOUT} from '../common.js';
|
||||
import {expect, use} from 'chai';
|
||||
import {testApp} from '../tests-setup.js';
|
||||
import bookFile from '@openstapps/core/test/resources/indexable/Book.1.json' assert {type: 'json'};
|
||||
import {readFile} from 'fs/promises';
|
||||
|
||||
use(chaiAsPromised);
|
||||
|
||||
const book = bookFile.instance as SCBook;
|
||||
const book = JSON.parse(
|
||||
await readFile('node_modules/@openstapps/core/test/resources/indexable/Book.1.json', 'utf8'),
|
||||
).instance;
|
||||
|
||||
describe('Thing update route', async function () {
|
||||
// increase timeout for the suite
|
||||
this.timeout(DEFAULT_TEST_TIMEOUT);
|
||||
let thingUpdateRoute: SCThingUpdateRoute;
|
||||
|
||||
before(function () {
|
||||
thingUpdateRoute = new SCThingUpdateRoute();
|
||||
});
|
||||
const thingUpdateRoute = new SCThingUpdateRoute();
|
||||
|
||||
it('should update a thing', async function () {
|
||||
const thingUpdateRouteurlPath = thingUpdateRoute.urlPath
|
||||
|
||||
@@ -49,11 +49,8 @@ import {
|
||||
} from '../../../src/storage/elasticsearch/util/index.js';
|
||||
import cron from 'node-cron';
|
||||
import {query} from './query.js';
|
||||
import messageFile from '@openstapps/core/test/resources/indexable/Message.1.json' assert {type: 'json'};
|
||||
import bookFile from '@openstapps/core/test/resources/indexable/Book.1.json' assert {type: 'json'};
|
||||
|
||||
const message = messageFile.instance as SCMessage;
|
||||
const book = bookFile.instance as SCBook;
|
||||
import message from '@openstapps/core/test/resources/indexable/Message.1.json' assert {type: 'json'};
|
||||
import book from '@openstapps/core/test/resources/indexable/Book.1.json' assert {type: 'json'};
|
||||
|
||||
use(chaiAsPromised);
|
||||
|
||||
@@ -70,16 +67,7 @@ describe('Elasticsearch', function () {
|
||||
const sandbox = sinon.createSandbox();
|
||||
|
||||
before(function () {
|
||||
// eslint-disable-next-line no-console
|
||||
sandbox.stub(fs, 'readFileSync').returns('{}');
|
||||
sandbox.stub(backendConfig.internal.boostings.default[0], 'fields').value({
|
||||
'academicTerms.acronym': {
|
||||
'SS 2023': 1.05,
|
||||
'WS 2023/24': 1.1,
|
||||
'SoSe 2023': 1.05,
|
||||
'WiSe 2023/24': 1.1,
|
||||
},
|
||||
});
|
||||
});
|
||||
after(function () {
|
||||
sandbox.restore();
|
||||
@@ -273,7 +261,7 @@ describe('Elasticsearch', function () {
|
||||
return expect(es.init()).to.be.rejected;
|
||||
});
|
||||
|
||||
it('should setup the monitoring if there is monitoring is set and mail queue is defined', function () {
|
||||
it('should setup the monitoring if there is monitoring is set and mail queue is defined', async function () {
|
||||
const config: SCConfigFile = {
|
||||
...backendConfig,
|
||||
internal: {
|
||||
@@ -295,7 +283,7 @@ describe('Elasticsearch', function () {
|
||||
const cronSetupStub = sandbox.stub(cron, 'schedule');
|
||||
|
||||
const es = new Elasticsearch(config, new MailQueue(getTransport(false) as unknown as SMTP));
|
||||
es.init();
|
||||
await es.init();
|
||||
|
||||
expect(cronSetupStub.called).to.be.true;
|
||||
});
|
||||
@@ -449,7 +437,7 @@ describe('Elasticsearch', function () {
|
||||
_id: '',
|
||||
_index: '',
|
||||
_score: 0,
|
||||
_source: message,
|
||||
_source: message.instance as SCMessage,
|
||||
};
|
||||
sandbox.stub(es.client, 'search').resolves(searchResponse(foundObject));
|
||||
|
||||
@@ -479,7 +467,7 @@ describe('Elasticsearch', function () {
|
||||
const object: SearchHit<SCMessage> = {
|
||||
_id: '',
|
||||
_index: oldIndex,
|
||||
_source: message,
|
||||
_source: message.instance as SCMessage,
|
||||
};
|
||||
sandbox.stub(es.client, 'search').resolves(searchResponse<SCMessage>(object));
|
||||
sandbox.stub(es, 'prepareBulkWrite').resolves(index);
|
||||
@@ -493,7 +481,7 @@ describe('Elasticsearch', function () {
|
||||
sandbox.stub(es.client, 'create').resolves({result: 'not_found'} as CreateResponse);
|
||||
|
||||
await es.init();
|
||||
return expect(es.post(message, bulk)).to.rejectedWith('creation');
|
||||
return expect(es.post(message.instance as SCMessage, bulk)).to.rejectedWith('creation');
|
||||
});
|
||||
|
||||
it('should create a new object', async function () {
|
||||
@@ -506,11 +494,11 @@ describe('Elasticsearch', function () {
|
||||
});
|
||||
|
||||
await es.init();
|
||||
await es.post(message, bulk);
|
||||
await es.post(message.instance as SCMessage, bulk);
|
||||
|
||||
expect(createStub.called).to.be.true;
|
||||
expect(caughtParameter.document).to.be.eql({
|
||||
...message,
|
||||
...message.instance,
|
||||
creation_date: caughtParameter.document.creation_date,
|
||||
});
|
||||
});
|
||||
@@ -531,7 +519,7 @@ describe('Elasticsearch', function () {
|
||||
_id: '',
|
||||
_index: getIndex(),
|
||||
_score: 0,
|
||||
_source: message,
|
||||
_source: message.instance as SCMessage,
|
||||
};
|
||||
sandbox.stub(es.client, 'search').resolves(searchResponse());
|
||||
|
||||
@@ -545,7 +533,7 @@ describe('Elasticsearch', function () {
|
||||
_id: '',
|
||||
_index: getIndex(),
|
||||
_score: 0,
|
||||
_source: message,
|
||||
_source: message.instance as SCMessage,
|
||||
};
|
||||
sandbox.stub(es.client, 'search').resolves(searchResponse(object));
|
||||
// @ts-expect-error unused
|
||||
@@ -568,13 +556,13 @@ describe('Elasticsearch', function () {
|
||||
_id: '123',
|
||||
_index: getIndex(),
|
||||
_score: 0,
|
||||
_source: message,
|
||||
_source: message.instance as SCMessage,
|
||||
};
|
||||
const objectBook: SearchHit<SCBook> = {
|
||||
_id: '321',
|
||||
_index: getIndex(),
|
||||
_score: 0,
|
||||
_source: book,
|
||||
_source: book.instance as SCBook,
|
||||
};
|
||||
const fakeEsAggregations = {
|
||||
'@all': {
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
"extends": "@openstapps/tsconfig",
|
||||
"compilerOptions": {
|
||||
"resolveJsonModule": true,
|
||||
"useUnknownInCatchVariables": false
|
||||
"useUnknownInCatchVariables": false,
|
||||
"allowJs": true,
|
||||
"checkJs": true
|
||||
},
|
||||
"exclude": ["lib", "app.js"]
|
||||
"exclude": ["app.js", "lib/"]
|
||||
}
|
||||
|
||||
@@ -14,4 +14,6 @@ RUN chown elasticsearch:elasticsearch config/elasticsearch.yml
|
||||
|
||||
USER elasticsearch
|
||||
|
||||
HEALTHCHECK --interval=10s --timeout=10s --start-period=60s --retries=12 CMD curl --fail -s http://localhost:9200/ >/dev/null || exit 1
|
||||
|
||||
CMD ["/usr/share/elasticsearch/bin/elasticsearch"]
|
||||
|
||||
@@ -3,3 +3,4 @@ discovery.type: "single-node"
|
||||
cluster.routing.allocation.disk.threshold_enabled: false
|
||||
network.bind_host: 0.0.0.0
|
||||
xpack.security.enabled: false
|
||||
ingest.geoip.downloader.enabled: false
|
||||
@@ -2,9 +2,6 @@
|
||||
"name": "@openstapps/database",
|
||||
"version": "3.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "docker run -it -p 9200:9200 $(docker build -q .)"
|
||||
},
|
||||
"files": [
|
||||
"config",
|
||||
"Dockerfile",
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
nginx &
|
||||
node ./lib/cli.js
|
||||
node ./app.js
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// ESM is not supported, and cts is not detected, so we use type-checked cjs instead.
|
||||
/** @type {import('../src/common').ConfigFile} */
|
||||
const configFile = {
|
||||
activeVersions: ['1\\.0\\.\\d+', '2\\.0\\.\\d+'],
|
||||
@@ -46,7 +46,6 @@
|
||||
"@types/dockerode": "3.3.17",
|
||||
"@types/node": "18.15.3",
|
||||
"@types/sha1": "1.1.3",
|
||||
"config": "3.3.9",
|
||||
"dockerode": "3.3.5",
|
||||
"is-cidr": "4.0.2",
|
||||
"mustache": "4.2.0",
|
||||
@@ -59,7 +58,6 @@
|
||||
"@openstapps/prettier-config": "workspace:*",
|
||||
"@openstapps/tsconfig": "workspace:*",
|
||||
"@types/chai": "4.3.5",
|
||||
"@types/config": "3.3.0",
|
||||
"@types/dockerode": "3.3.17",
|
||||
"@types/mocha": "10.0.1",
|
||||
"@types/mustache": "4.2.2",
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Logger, SMTP} from '@openstapps/logger';
|
||||
import config from 'config';
|
||||
import {existsSync} from 'fs';
|
||||
|
||||
// set transport on logger
|
||||
@@ -163,7 +162,7 @@ ssl_stapling_verify on;`;
|
||||
/**
|
||||
* Config file
|
||||
*/
|
||||
export const configFile: ConfigFile = config.util.toObject();
|
||||
export const configFile: ConfigFile = await import('../config/default.js').then(it => it.default);
|
||||
|
||||
/**
|
||||
* Check if path is a specific file type
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"extends": "@openstapps/tsconfig",
|
||||
"exclude": ["config", "lib", "app.js"]
|
||||
"exclude": ["./config/", "./lib/"]
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
const fs = require("fs");
|
||||
const path = require("node:path");
|
||||
const child_process = require("child_process");
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
"use strict"
|
||||
|
||||
const rule = require('./copyright-header-rule')
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// @ts-check
|
||||
|
||||
/** @type {import('eslint').Linter.Config} */
|
||||
const config = {
|
||||
root: true,
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
"test": "prettier --config index.js --check \"test/*.js\""
|
||||
},
|
||||
"devDependencies": {
|
||||
"prettier": "3.1.1"
|
||||
"prettier": "3.1.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"prettier": "3.1.1"
|
||||
"prettier": "3.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
{
|
||||
"extends": "@openstapps/tsconfig",
|
||||
"exclude": ["lib", "app.js"]
|
||||
"extends": "@openstapps/tsconfig"
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"isolatedModules": true,
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
"resolveJsonModule": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"noImplicitAny": true,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
{
|
||||
"extends": "@openstapps/tsconfig",
|
||||
"exclude": ["lib", "app.js"]
|
||||
"extends": "@openstapps/tsconfig"
|
||||
}
|
||||
|
||||
@@ -1,62 +1,44 @@
|
||||
version: '3.7'
|
||||
|
||||
x-development-variables: &development-variables
|
||||
NODE_ENV: "development"
|
||||
ALLOW_NO_TRANSPORT: "true"
|
||||
|
||||
services:
|
||||
database:
|
||||
image: registry.gitlab.com/openstapps/openstapps/database:3.0.0
|
||||
# If you need persistence for debugging purposes uncomment the following lines
|
||||
#volumes:
|
||||
# - ./database:/usr/share/elasticsearch/data
|
||||
image: registry.gitlab.com/openstapps/openstapps/database:2.0.0
|
||||
volumes:
|
||||
- ./database:/usr/share/elasticsearch/data
|
||||
expose:
|
||||
- 9200
|
||||
ports:
|
||||
- 127.0.0.1:9200:9200
|
||||
environment:
|
||||
- bootstrap.memory_lock=true
|
||||
- "ES_JAVA_OPTS=-Xms2g -Xmx2g"
|
||||
- discovery.type=single-node
|
||||
ulimits:
|
||||
memlock:
|
||||
soft: -1
|
||||
hard: -1
|
||||
- "9200"
|
||||
restart: unless-stopped
|
||||
|
||||
backend:
|
||||
image: registry.gitlab.com/openstapps/openstapps/backend:3.1.0
|
||||
image: registry.gitlab.com/openstapps/openstapps/backend:3.0.0-next.0
|
||||
environment:
|
||||
<<: *development-variables
|
||||
ES_ADDR: "http://database:9200"
|
||||
NODE_CONFIG_ENV: "elasticsearch"
|
||||
NODE_APP_INSTANCE: "f-u"
|
||||
PROMETHEUS_MIDDLEWARE: "false"
|
||||
ALLOW_NO_TRANSPORT: "true"
|
||||
expose:
|
||||
- 3000
|
||||
ports:
|
||||
- 127.0.0.1:3000:3000
|
||||
- 3000:3000
|
||||
links:
|
||||
- "database"
|
||||
labels:
|
||||
- stapps.version=4.1.0
|
||||
- stapps.version=1.0.0
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- database
|
||||
|
||||
api:
|
||||
image: registry.gitlab.com/openstapps/openstapps/api:3.0.0-next.0
|
||||
links:
|
||||
- database
|
||||
- "backend"
|
||||
|
||||
# api:
|
||||
# image: registry.gitlab.com/openstapps/openstapps/api:3.0.0
|
||||
# links:
|
||||
# - backend
|
||||
minimal-connector:
|
||||
image: registry.gitlab.com/openstapps/minimal-connector:core-0.23
|
||||
container_name: minimal-connector-0.23
|
||||
command: ["http://backend:3000", "minimal-connector", "f-u"]
|
||||
|
||||
# minimal-connector:
|
||||
# image: registry.gitlab.com/openstapps/minimal-connector:core-0.23
|
||||
# container_name: minimal-connector-0.23
|
||||
# command: ["http://backend:3000", "minimal-connector", "f-u"]
|
||||
|
||||
# app:
|
||||
# image: registry.gitlab.com/openstapps/app/executable:core-0.23
|
||||
# expose:
|
||||
# - 8100
|
||||
# ports:
|
||||
# - 8100:8100
|
||||
app:
|
||||
image: registry.gitlab.com/openstapps/app/executable:core-0.23
|
||||
expose:
|
||||
- 8100
|
||||
ports:
|
||||
- 8100:8100
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
{
|
||||
"extends": "@openstapps/tsconfig",
|
||||
"exclude": ["lib", "app.js"]
|
||||
"extends": "@openstapps/tsconfig"
|
||||
}
|
||||
|
||||
34
flake.lock
generated
34
flake.lock
generated
@@ -1,23 +1,5 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1701680307,
|
||||
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1701626906,
|
||||
@@ -36,24 +18,8 @@
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
|
||||
142
flake.nix
142
flake.nix
@@ -1,75 +1,77 @@
|
||||
{
|
||||
description = "A Nix-flake-based development environment for OpenStApps";
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
}: let
|
||||
aapt2buildToolsVersion = "33.0.2";
|
||||
in
|
||||
flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
(final: prev: rec {
|
||||
fontMin = prev.python311.withPackages (ps: with ps; [brotli fonttools] ++ (with fonttools.optional-dependencies; [woff]));
|
||||
android = prev.androidenv.composeAndroidPackages {
|
||||
buildToolsVersions = ["30.0.3" aapt2buildToolsVersion];
|
||||
platformVersions = ["33"];
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
outputs = { self, nixpkgs }:
|
||||
let
|
||||
buildToolsVersion = "30.0.3";
|
||||
overlays = [
|
||||
(final: prev: rec {
|
||||
nodejs = prev.nodejs-18_x;
|
||||
pnpm = prev.nodePackages.pnpm;
|
||||
chrome = prev.google-chrome;
|
||||
firefox = prev.firefox;
|
||||
webkit = prev.epiphany; # Safari-ish browser
|
||||
android = prev.androidenv.composeAndroidPackages {
|
||||
buildToolsVersions = [ "${buildToolsVersion}" ];
|
||||
platformVersions = [ "33" ];
|
||||
};
|
||||
cypress = prev.cypress.overrideAttrs(cyPrev: rec {
|
||||
version = "13.2.0";
|
||||
src = prev.fetchzip {
|
||||
url = "https://cdn.cypress.io/desktop/${version}/linux-x64/cypress.zip";
|
||||
hash = "sha256-9o0nprGcJhudS1LNm+T7Vf0Dwd1RBauYKI+w1FBQ3ZM=";
|
||||
};
|
||||
cypress = prev.cypress.overrideAttrs (cyPrev: rec {
|
||||
version = "13.2.0";
|
||||
src = prev.fetchzip {
|
||||
url = "https://cdn.cypress.io/desktop/${version}/linux-x64/cypress.zip";
|
||||
hash = "sha256-9o0nprGcJhudS1LNm+T7Vf0Dwd1RBauYKI+w1FBQ3ZM=";
|
||||
};
|
||||
});
|
||||
})
|
||||
];
|
||||
config = {
|
||||
allowUnfree = true;
|
||||
android_sdk.accept_license = true;
|
||||
});
|
||||
})
|
||||
];
|
||||
# TODO: aarch64-linux, x68_64-darwin, aarch64-darwin
|
||||
supportedSystems = [ "x86_64-linux" ];
|
||||
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
|
||||
pkgs = import nixpkgs {
|
||||
inherit overlays system;
|
||||
config = {
|
||||
allowUnfree = true;
|
||||
android_sdk.accept_license = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
androidFhs = pkgs.buildFHSUserEnv {
|
||||
name = "android-env";
|
||||
targetPkgs = pkgs: with pkgs; [];
|
||||
runScript = "bash";
|
||||
profile = ''
|
||||
export ALLOW_NINJA_ENV=true
|
||||
export USE_CCACHE=1
|
||||
export LD_LIBRARY_PATH=/usr/lib:/usr/lib32
|
||||
'';
|
||||
};
|
||||
in {
|
||||
devShell = pkgs.mkShell rec {
|
||||
nativeBuildInputs = [androidFhs];
|
||||
buildInputs = with pkgs; [
|
||||
nodejs-18_x
|
||||
nodePackages.pnpm
|
||||
# tools
|
||||
curl
|
||||
jq
|
||||
fontMin
|
||||
# browsers
|
||||
firefox
|
||||
google-chrome
|
||||
epiphany # Safari-ish browser
|
||||
cypress
|
||||
# android
|
||||
jdk17
|
||||
android.androidsdk
|
||||
musl
|
||||
];
|
||||
ANDROID_JAVA_HOME = "${pkgs.jdk.home}";
|
||||
ANDROID_SDK_ROOT = "${pkgs.android.androidsdk}/libexec/android-sdk";
|
||||
GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${ANDROID_SDK_ROOT}/build-tools/${aapt2buildToolsVersion}/aapt2";
|
||||
CYPRESS_INSTALL_BINARY = "0";
|
||||
CYPRESS_RUN_BINARY = "${pkgs.cypress}/bin/Cypress";
|
||||
};
|
||||
});
|
||||
});
|
||||
in
|
||||
{
|
||||
devShells = forEachSupportedSystem ({ pkgs }:
|
||||
let
|
||||
python = (pkgs.python311.withPackages(ps: with ps; [ brotli fonttools ] ++ (with fonttools.optional-dependencies; [ ufo lxml unicode woff ])));
|
||||
in
|
||||
{
|
||||
default = (pkgs.buildFHSUserEnv {
|
||||
name = "StApps Dev";
|
||||
targetPkgs = pkgs: with pkgs; [
|
||||
nodejs
|
||||
pnpm
|
||||
python
|
||||
docker
|
||||
# tools
|
||||
curl
|
||||
jq
|
||||
# browsers
|
||||
firefox
|
||||
chrome
|
||||
webkit
|
||||
cypress
|
||||
# android
|
||||
jdk17
|
||||
android.androidsdk
|
||||
musl
|
||||
];
|
||||
runScript = "bash";
|
||||
profile = ''
|
||||
export CYPRESS_INSTALL_BINARY=0
|
||||
export CYPRESS_RUN_BINARY=${pkgs.cypress}/bin/Cypress
|
||||
export ANDROID_SDK_ROOT=${pkgs.android.androidsdk}/libexec/android-sdk
|
||||
export ANDROID_JAVA_HOME=${pkgs.jdk.home}
|
||||
export DOCKER_HOST=unix:///run/user/1000/docker.sock
|
||||
{ dockerd-rootless & } 2>/dev/null
|
||||
'';
|
||||
}).env;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Creates a docker image with only the app as an executable unit
|
||||
# Dependencies need to be installed beforehand
|
||||
# Needs to be build beforehand
|
||||
FROM node:18-alpine
|
||||
FROM node:18-alpine3.18
|
||||
|
||||
WORKDIR /app
|
||||
COPY www/ /app/www
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
/*
|
||||
* Copyright (C) 2022 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
@@ -12,9 +13,8 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import type {IconConfig} from './scripts/icon-config';
|
||||
|
||||
const config: IconConfig = {
|
||||
/** @type {import('./scripts/icon-config').IconConfig} */
|
||||
const config = {
|
||||
inputPath: 'node_modules/material-symbols/material-symbols-rounded.woff2',
|
||||
outputPath: 'src/assets/icons.min.woff2',
|
||||
htmlGlob: 'src/**/*.html',
|
||||
@@ -25,7 +25,7 @@ def capacitor_pods
|
||||
pod 'CapacitorPreferences', :path => '../../../../node_modules/.pnpm/@capacitor+preferences@5.0.6_@capacitor+core@5.5.0/node_modules/@capacitor/preferences'
|
||||
pod 'CapacitorShare', :path => '../../../../node_modules/.pnpm/@capacitor+share@5.0.6_@capacitor+core@5.5.0/node_modules/@capacitor/share'
|
||||
pod 'CapacitorSplashScreen', :path => '../../../../node_modules/.pnpm/@capacitor+splash-screen@5.0.6_@capacitor+core@5.5.0/node_modules/@capacitor/splash-screen'
|
||||
pod 'TransistorsoftCapacitorBackgroundFetch', :path => '../../../../node_modules/.pnpm/@transistorsoft+capacitor-background-fetch@5.1.1_@capacitor+core@5.5.0/node_modules/@transistorsoft/capacitor-background-fetch'
|
||||
pod 'TransistorsoftCapacitorBackgroundFetch', :path => '../../../../node_modules/.pnpm/@transistorsoft+capacitor-background-fetch@1.0.2_@capacitor+core@5.5.0/node_modules/@transistorsoft/capacitor-background-fetch'
|
||||
pod 'CapacitorSecureStoragePlugin', :path => '../../../../node_modules/.pnpm/capacitor-secure-storage-plugin@0.9.0_@capacitor+core@5.5.0/node_modules/capacitor-secure-storage-plugin'
|
||||
pod 'CordovaPlugins', :path => '../capacitor-cordova-ios-plugins'
|
||||
end
|
||||
|
||||
@@ -36,7 +36,7 @@ PODS:
|
||||
- CordovaPlugins (5.5.0):
|
||||
- CapacitorCordova
|
||||
- SwiftKeychainWrapper (4.0.1)
|
||||
- TransistorsoftCapacitorBackgroundFetch (5.1.1):
|
||||
- TransistorsoftCapacitorBackgroundFetch (1.0.2):
|
||||
- Capacitor
|
||||
|
||||
DEPENDENCIES:
|
||||
@@ -58,7 +58,7 @@ DEPENDENCIES:
|
||||
- "CapacitorShare (from `../../../../node_modules/.pnpm/@capacitor+share@5.0.6_@capacitor+core@5.5.0/node_modules/@capacitor/share`)"
|
||||
- "CapacitorSplashScreen (from `../../../../node_modules/.pnpm/@capacitor+splash-screen@5.0.6_@capacitor+core@5.5.0/node_modules/@capacitor/splash-screen`)"
|
||||
- CordovaPlugins (from `../capacitor-cordova-ios-plugins`)
|
||||
- "TransistorsoftCapacitorBackgroundFetch (from `../../../../node_modules/.pnpm/@transistorsoft+capacitor-background-fetch@5.1.1_@capacitor+core@5.5.0/node_modules/@transistorsoft/capacitor-background-fetch`)"
|
||||
- "TransistorsoftCapacitorBackgroundFetch (from `../../../../node_modules/.pnpm/@transistorsoft+capacitor-background-fetch@1.0.2_@capacitor+core@5.5.0/node_modules/@transistorsoft/capacitor-background-fetch`)"
|
||||
|
||||
SPEC REPOS:
|
||||
trunk:
|
||||
@@ -102,7 +102,7 @@ EXTERNAL SOURCES:
|
||||
CordovaPlugins:
|
||||
:path: "../capacitor-cordova-ios-plugins"
|
||||
TransistorsoftCapacitorBackgroundFetch:
|
||||
:path: "../../../../node_modules/.pnpm/@transistorsoft+capacitor-background-fetch@5.1.1_@capacitor+core@5.5.0/node_modules/@transistorsoft/capacitor-background-fetch"
|
||||
:path: "../../../../node_modules/.pnpm/@transistorsoft+capacitor-background-fetch@1.0.2_@capacitor+core@5.5.0/node_modules/@transistorsoft/capacitor-background-fetch"
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
Capacitor: 57890b363df14d5d2d5d8461aa23e886cb34da2a
|
||||
@@ -124,8 +124,8 @@ SPEC CHECKSUMS:
|
||||
CapacitorSplashScreen: 5fa2ab5e46cf5cc530cf16a51c80c7a986579ccd
|
||||
CordovaPlugins: de5669381702d76ed5b1d442177a6a5fc3252a9d
|
||||
SwiftKeychainWrapper: 807ba1d63c33a7d0613288512399cd1eda1e470c
|
||||
TransistorsoftCapacitorBackgroundFetch: ce4b3e01b898cef516e68485d2160a078016ee97
|
||||
TransistorsoftCapacitorBackgroundFetch: 74ca62dae7ec78639eaf3d0d1e24c595ada213dd
|
||||
|
||||
PODFILE CHECKSUM: 229278f2c257e8ab555325c7115b2e187e8e628d
|
||||
PODFILE CHECKSUM: 073b899f90bacc5049101cb9c562a168757d554e
|
||||
|
||||
COCOAPODS: 1.13.0
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
/*
|
||||
* Copyright (C) 2022 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
"build:prod": "ng build --configuration=production",
|
||||
"build:stats": "ng build --configuration=production --stats-json",
|
||||
"changelog": "conventional-changelog -p angular -i src/assets/about/CHANGELOG.md -s -r 0",
|
||||
"check-icons": "ts-node-esm scripts/check-icon-correctness.ts",
|
||||
"check-icons": "node scripts/check-icon-correctness.mjs",
|
||||
"chromium:no-cors": "chromium --disable-web-security --user-data-dir=\".browser-data/chromium\"",
|
||||
"chromium:virtual-host": "chromium --host-resolver-rules=\"MAP mobile.app.uni-frankfurt.de:* localhost:8100\" --ignore-certificate-errors",
|
||||
"cypress:open": "cypress open",
|
||||
@@ -38,7 +38,7 @@
|
||||
"licenses": "license-checker --json > src/assets/about/licenses.json && ts-node ./scripts/accumulate-licenses.ts && git add src/assets/about/licenses.json",
|
||||
"lint": "ng lint && stylelint \"**/*.scss\"",
|
||||
"lint:fix": "eslint --fix -c .eslintrc.json --ignore-path .eslintignore --ext .ts,.html src/ && stylelint --fix \"**/*.scss\"",
|
||||
"minify-icons": "ts-node-esm scripts/minify-icon-font.ts",
|
||||
"minify-icons": "node scripts/minify-icon-font.mjs",
|
||||
"postinstall": "jetify && echo \"skipping jetify in production mode\"",
|
||||
"preview": "http-server www --p 8101 -o",
|
||||
"push": "git push && git push origin \"v$npm_package_version\"",
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
/*
|
||||
* Copyright (C) 2022 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
@@ -13,13 +14,14 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import fs from 'fs';
|
||||
import {omit} from '../src/app/_helpers/collections/omit';
|
||||
import {pickBy} from '../src/app/_helpers/collections/pick';
|
||||
import {omit, pickBy} from '@openstapps/collection-utils';
|
||||
|
||||
/**
|
||||
* accumulate and transform licenses based on two license files
|
||||
* @param {string} path
|
||||
* @param {string} additionalLicensesPath
|
||||
*/
|
||||
function accumulateFile(path: string, additionalLicensesPath: string) {
|
||||
function accumulateFile(path, additionalLicensesPath) {
|
||||
const packageJson = JSON.parse(fs.readFileSync('./package.json').toString());
|
||||
const dependencies = packageJson.dependencies;
|
||||
|
||||
@@ -28,10 +30,9 @@ function accumulateFile(path: string, additionalLicensesPath: string) {
|
||||
fs.writeFileSync(
|
||||
path,
|
||||
JSON.stringify(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
Object.entries<any>({
|
||||
...pickBy(JSON.parse(fs.readFileSync(path).toString()), (_, key: string) => {
|
||||
const parts = key.split('@');
|
||||
Object.entries({
|
||||
...pickBy(JSON.parse(fs.readFileSync(path).toString()), (_, key) => {
|
||||
const parts = /** @type {string} */ (key).split('@');
|
||||
|
||||
return dependencies[parts.slice(0, -1).join('@')] === parts[parts.length - 1];
|
||||
}),
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
/*
|
||||
* Copyright (C) 2022 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
@@ -12,18 +13,18 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import fontkit, {Font} from 'fontkit';
|
||||
import config from '../icons.config';
|
||||
import {openSync} from 'fontkit';
|
||||
import config from '../icons.config.mjs';
|
||||
import {existsSync} from 'fs';
|
||||
import {getUsedIconsHtml, getUsedIconsTS} from './gather-used-icons';
|
||||
import {getUsedIconsHtml, getUsedIconsTS} from './gather-used-icons.mjs';
|
||||
|
||||
const commandName = '"npm run minify-icons"';
|
||||
const originalFont = fontkit.openSync(config.inputPath);
|
||||
const originalFont = openSync(config.inputPath);
|
||||
if (!existsSync(config.outputPath)) {
|
||||
console.error(`Minified font not found. Run ${commandName} first.`);
|
||||
process.exit(-1);
|
||||
}
|
||||
const modifiedFont = fontkit.openSync(config.outputPath);
|
||||
const modifiedFont = openSync(config.outputPath);
|
||||
|
||||
let success = true;
|
||||
|
||||
@@ -48,9 +49,9 @@ async function checkAll() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Record<string, string[]>} icons
|
||||
*/
|
||||
function check(icons: Record<string, string[]>) {
|
||||
function check(icons) {
|
||||
for (const [purpose, iconSet] of Object.entries(icons)) {
|
||||
for (const icon of iconSet) {
|
||||
if (!hasIcon(originalFont, icon)) {
|
||||
@@ -65,8 +66,9 @@ function check(icons: Record<string, string[]>) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import('fontkit').Font} font
|
||||
* @param {string} icon
|
||||
*/
|
||||
function hasIcon(font: Font, icon: string) {
|
||||
function hasIcon(font, icon) {
|
||||
return font.layout(icon).glyphs.some(it => it.isLigature);
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
/*
|
||||
* Copyright (C) 2022 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
@@ -14,31 +15,33 @@
|
||||
*/
|
||||
import {glob} from 'glob';
|
||||
import {readFileSync} from 'fs';
|
||||
import {matchPropertyContent, matchTagProperties} from '../src/app/util/ion-icon/icon-match';
|
||||
import {matchPropertyContent, matchTagProperties} from '../src/app/util/ion-icon/icon-match.mjs';
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns {Promise<Record<string, string[]>>}
|
||||
*/
|
||||
export async function getUsedIconsHtml(pattern = 'src/**/*.html'): Promise<Record<string, string[]>> {
|
||||
export async function getUsedIconsHtml(pattern = 'src/**/*.html') {
|
||||
return Object.fromEntries(
|
||||
(await glob(pattern))
|
||||
.map(file => [
|
||||
file,
|
||||
(readFileSync(file, 'utf8')
|
||||
.match(matchTagProperties('ion-icon'))
|
||||
?.flatMap(match => {
|
||||
return match.match(matchPropertyContent(['name', 'md', 'ios']));
|
||||
})
|
||||
.filter(it => !!it) as string[]) || [],
|
||||
/** @type {string[]} */ (
|
||||
readFileSync(file, 'utf8')
|
||||
.match(matchTagProperties('ion-icon'))
|
||||
?.flatMap(match => {
|
||||
return match.match(matchPropertyContent(['name', 'md', 'ios']));
|
||||
})
|
||||
.filter(it => !!it)
|
||||
) || [],
|
||||
])
|
||||
.filter(([, values]) => values.length > 0),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns {Promise<Record<string, string[]>>}
|
||||
*/
|
||||
export async function getUsedIconsTS(pattern = 'src/**/*.ts'): Promise<Record<string, string[]>> {
|
||||
export async function getUsedIconsTS(pattern = 'src/**/*.ts') {
|
||||
return Object.fromEntries(
|
||||
(await glob(pattern))
|
||||
.map(file => [file, readFileSync(file, 'utf8').match(/(?<=Icon`)[\w-]+(?=`)/g) || []])
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
/*
|
||||
* Copyright (C) 2022 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
@@ -12,18 +13,17 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||
import fontkit from 'fontkit';
|
||||
import {openSync} from 'fontkit';
|
||||
import {exec} from 'child_process';
|
||||
import config from '../icons.config';
|
||||
import config from '../icons.config.mjs';
|
||||
import {statSync} from 'fs';
|
||||
import {getUsedIconsHtml, getUsedIconsTS} from './gather-used-icons';
|
||||
import {getUsedIconsHtml, getUsedIconsTS} from './gather-used-icons.mjs';
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string[] | string} command
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
async function run(command: string[] | string): Promise<string> {
|
||||
async function run(command) {
|
||||
const fullCommand = Array.isArray(command) ? command.join(' ') : command;
|
||||
console.log(`>> ${fullCommand}`);
|
||||
|
||||
@@ -44,7 +44,8 @@ async function run(command: string[] | string): Promise<string> {
|
||||
*
|
||||
*/
|
||||
async function minifyIconFont() {
|
||||
const icons = new Set<string>();
|
||||
/** @type {Set<string>} */
|
||||
const icons = new Set();
|
||||
|
||||
for (const iconSet of [
|
||||
...Object.values(config.additionalIcons || []),
|
||||
@@ -57,9 +58,10 @@ async function minifyIconFont() {
|
||||
}
|
||||
|
||||
console.log('Icons used:', [...icons.values()].sort());
|
||||
const font = fontkit.openSync(config.inputPath);
|
||||
const font = openSync(config.inputPath);
|
||||
|
||||
const glyphs: string[] = ['5f-7a', '30-39'];
|
||||
/** @type {string[]} */
|
||||
const glyphs = ['5f-7a', '30-39'];
|
||||
for (const icon of icons) {
|
||||
const iconGlyphs = font.layout(icon).glyphs;
|
||||
if (iconGlyphs.length === 0) {
|
||||
@@ -70,7 +72,7 @@ async function minifyIconFont() {
|
||||
const codePoints = iconGlyphs
|
||||
.flatMap(it => font.stringsForGlyph(it.id))
|
||||
.flatMap(it => [...it])
|
||||
.map(it => it.codePointAt(0)!.toString(16));
|
||||
.map(it => it.codePointAt(0).toString(16));
|
||||
|
||||
if (codePoints.length === 0) {
|
||||
if (config.codePoints?.[icon]) {
|
||||
@@ -114,8 +116,10 @@ minifyIconFont();
|
||||
|
||||
/**
|
||||
* Bytes to respective units
|
||||
* @param {number} value
|
||||
* @returns {string}
|
||||
*/
|
||||
function toByteUnit(value: number): string {
|
||||
function toByteUnit(value) {
|
||||
if (value < 1024) {
|
||||
return `${value}B`;
|
||||
} else if (value < 1024 * 1024) {
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"extends": "@openstapps/tsconfig",
|
||||
"compilerOptions": {
|
||||
"module": "CommonJS",
|
||||
"moduleResolution": "Node"
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
SCThingOriginType,
|
||||
SCThingType,
|
||||
} from '@openstapps/core';
|
||||
import {CORE_VERSION} from '@openstapps/core';
|
||||
import packageInfo from '@openstapps/core/package.json';
|
||||
import {Polygon} from 'geojson';
|
||||
|
||||
// provides sample aggregations to be used in tests or backendless development
|
||||
@@ -195,7 +195,7 @@ export const sampleIndexResponse: SCIndexResponse = {
|
||||
},
|
||||
auth: {},
|
||||
backend: {
|
||||
SCVersion: CORE_VERSION,
|
||||
SCVersion: packageInfo.version,
|
||||
externalRequestTimeout: 5000,
|
||||
hiddenTypes: [SCThingType.DateSeries, SCThingType.Diff, SCThingType.Floor],
|
||||
mappingIgnoredTags: [],
|
||||
|
||||
@@ -70,7 +70,6 @@ import {setDefaultOptions} from 'date-fns';
|
||||
import {DateFnsConfigurationService} from 'ngx-date-fns';
|
||||
import {Capacitor} from '@capacitor/core';
|
||||
import {SplashScreen} from '@capacitor/splash-screen';
|
||||
import {SportCoursesModule} from './modules/sport-courses/sport-courses.module';
|
||||
|
||||
registerLocaleData(localeDe);
|
||||
|
||||
@@ -171,7 +170,6 @@ export function createTranslateLoader(http: HttpClient) {
|
||||
ScheduleModule,
|
||||
SettingsModule,
|
||||
StorageModule,
|
||||
SportCoursesModule,
|
||||
ThingTranslateModule.forRoot(),
|
||||
TranslateModule.forRoot({
|
||||
defaultLanguage: 'en',
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Client} from '@openstapps/api';
|
||||
import {SCAppConfiguration, SCIndexResponse} from '@openstapps/core';
|
||||
import {CORE_VERSION} from '@openstapps/core';
|
||||
import packageInfo from '@openstapps/core/package.json';
|
||||
import {NGXLogger} from 'ngx-logger';
|
||||
import {environment} from '../../../environments/environment';
|
||||
import {StAppsWebHttpClient} from '../data/stapps-web-http-client.provider';
|
||||
@@ -55,7 +55,7 @@ export class ConfigProvider {
|
||||
/**
|
||||
* Version of the @openstapps/core package that app is using
|
||||
*/
|
||||
scVersion = CORE_VERSION;
|
||||
scVersion = packageInfo.version;
|
||||
|
||||
/**
|
||||
* First session indicator (config not found in storage)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Component, Input} from '@angular/core';
|
||||
import {SCThingType, SCThings} from '@openstapps/core';
|
||||
import {SCDateSeries, SCThingType, SCThings} from '@openstapps/core';
|
||||
|
||||
/**
|
||||
* Shows a horizontal list of action chips
|
||||
@@ -47,7 +47,9 @@ export class ActionChipListComponent {
|
||||
const isNullIsland = maybeCoords ? maybeCoords[0] === 0 && maybeCoords[1] === 0 : false;
|
||||
this.applicable = {
|
||||
locate: false, // TODO: reimplement this at a later date
|
||||
event: item.type === SCThingType.AcademicEvent || item.type === SCThingType.SportCourse,
|
||||
event:
|
||||
item.type === SCThingType.AcademicEvent ||
|
||||
(item.type === SCThingType.DateSeries && (item as SCDateSeries).dates.length > 0),
|
||||
navigate: (hasDirectGeo || isInPlace) && !isNullIsland,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ export const DataIcons: Record<SCThingType, string> = {
|
||||
'room': SCIcon`meeting_room`,
|
||||
'semester': SCIcon`date_range`,
|
||||
'setting': SCIcon`settings`,
|
||||
'sport course': SCIcon`sports_gymnastics`,
|
||||
'sport course': SCIcon`sports_soccer`,
|
||||
'study module': SCIcon`view_module`,
|
||||
'ticket': SCIcon`confirmation_number`,
|
||||
'todo': SCIcon`task`,
|
||||
|
||||
@@ -107,8 +107,6 @@ import {SemesterListItemComponent} from './types/semester/semester-list-item.com
|
||||
import {VideoDetailContentComponent} from './types/video/video-detail-content.component';
|
||||
import {VideoListItemComponent} from './types/video/video-list-item.component';
|
||||
import {ShareButtonComponent} from './elements/share-button.component';
|
||||
import {SanitizeHtmlPipe} from '../../util/sanitize-html.pipe';
|
||||
import {BypassTrustUrlPipe} from '../../util/bypass-trust-url.pipe';
|
||||
|
||||
/**
|
||||
* Module for handling data
|
||||
@@ -195,8 +193,6 @@ import {BypassTrustUrlPipe} from '../../util/bypass-trust-url.pipe';
|
||||
MarkdownModule.forRoot(),
|
||||
MenuModule,
|
||||
IonIconModule,
|
||||
SanitizeHtmlPipe,
|
||||
BypassTrustUrlPipe,
|
||||
MomentModule.forRoot({
|
||||
relativeTimeThresholdOptions: {
|
||||
m: 59,
|
||||
|
||||
@@ -13,23 +13,12 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Component, Input} from '@angular/core';
|
||||
import {SCAcademicPriceGroup, SCThingThatCanBeOffered, SCThingType, SCThings} from '@openstapps/core';
|
||||
import {SimpleBrowser} from 'src/app/util/browser.factory';
|
||||
|
||||
type WithRequired<T, K extends keyof T> = T & {[P in K]-?: T[P]};
|
||||
import {SCAcademicPriceGroup, SCThingThatCanBeOfferedOffer} from '@openstapps/core';
|
||||
|
||||
@Component({
|
||||
selector: 'stapps-offers-detail',
|
||||
templateUrl: 'offers-detail.html',
|
||||
})
|
||||
export class OffersDetailComponent {
|
||||
@Input() item: SCThings & WithRequired<SCThingThatCanBeOffered<SCAcademicPriceGroup>, 'offers'>;
|
||||
|
||||
constructor(readonly browser: SimpleBrowser) {}
|
||||
|
||||
async submit(id: string) {
|
||||
if (this.item.type === SCThingType.DateSeries && this.item.event.type === SCThingType.SportCourse) {
|
||||
this.browser.open(`${this.item.event.sameAs}#${id}`);
|
||||
}
|
||||
}
|
||||
@Input() offers: Array<SCThingThatCanBeOfferedOffer<SCAcademicPriceGroup>>;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<ion-card>
|
||||
<ion-card-header>{{ 'data.detail.offers.TITLE' | translate | titlecase }}</ion-card-header>
|
||||
<ion-card-content>
|
||||
<div *ngFor="let offer of item.offers">
|
||||
<div *ngFor="let offer of offers">
|
||||
<ion-grid>
|
||||
<ion-row>
|
||||
<ion-col *ngIf="offer.inPlace">
|
||||
@@ -45,24 +45,16 @@
|
||||
</ng-container>
|
||||
</ion-row>
|
||||
</ion-grid>
|
||||
<ion-button
|
||||
*ngIf="item.identifiers?.zfh as id; else availability"
|
||||
(click)="submit(id)"
|
||||
[color]="offer.availability === 'out of stock' ? 'danger' : offer.availability === 'limited availability' ? 'warning' : 'primary'"
|
||||
>{{'data.detail.offers.' + offer.availability | translate}}</ion-button
|
||||
>
|
||||
<ng-template #availability>
|
||||
<ion-grid *ngIf="offer.availability === 'out of stock'">
|
||||
<ion-row>
|
||||
<ion-col></ion-col>
|
||||
<ion-col width-20 text-right>
|
||||
<ion-text color="danger">
|
||||
<p>{{ 'data.detail.offers.' + offer.availability | translate }}</p>
|
||||
</ion-text>
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
</ion-grid>
|
||||
</ng-template>
|
||||
<ion-grid *ngIf="offer.availability === 'out of stock'">
|
||||
<ion-row>
|
||||
<ion-col></ion-col>
|
||||
<ion-col width-20 text-right>
|
||||
<ion-text color="danger">
|
||||
<p>{{ 'data.detail.offers.sold_out' | translate }}</p>
|
||||
</ion-text>
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
</ion-grid>
|
||||
</div>
|
||||
</ion-card-content>
|
||||
</ion-card>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<h2>{{ price | currency : 'EUR' : 'symbol' : undefined : 'de' }}</h2>
|
||||
</ion-text>
|
||||
<ion-text *ngIf="soldOut" color="danger" class="sold-out" style="white-space: nowrap">
|
||||
<h2>{{ 'data.detail.offers.out of stock' | translate }}</h2>
|
||||
<h2>{{ 'data.detail.offers.sold_out' | translate }}</h2>
|
||||
</ion-text>
|
||||
<p *ngIf="_offers[0].inPlace && !soldOut" class="place" style="white-space: nowrap">
|
||||
<ion-icon name="pin_drop"></ion-icon>{{ _offers[0].inPlace.name }}<span *ngIf="_offers.length > 1"
|
||||
|
||||
@@ -30,5 +30,20 @@
|
||||
<div *ngIf="$any(item).openingHours as openingHours" class="opening-hours">
|
||||
<stapps-opening-hours [openingHours]="openingHours"></stapps-opening-hours>
|
||||
</div>
|
||||
<!-- TODO obviously this is bad style. Tbd where to put the differentiation. Job Postings always have a description, but it's going to be shown in `stapps-job-posting-detail-content` anyways, no need to repeat here. For this view, I would use other fields of the schema.org JobPosting like the `ThingWithCategory.category` -->
|
||||
<div *ngIf="item.description && item.type !== 'job posting'" class="description">
|
||||
<div class="text-accordion" [style.-webkit-line-clamp]="descriptionLinesToDisplay" #accordionTextArea>
|
||||
{{ 'description' | thingTranslate: item }}
|
||||
</div>
|
||||
</div>
|
||||
<!-- TODO see above -->
|
||||
<ion-button
|
||||
expand="full"
|
||||
fill="clear"
|
||||
*ngIf="item.description && item.type !== 'job posting' && buttonShown"
|
||||
(click)="toggleDescriptionAccordion()"
|
||||
>
|
||||
<ion-icon [name]="buttonState" size="large"></ion-icon>
|
||||
</ion-button>
|
||||
</ion-card-content>
|
||||
</ion-card>
|
||||
|
||||
@@ -13,6 +13,14 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
.text-accordion {
|
||||
overflow: hidden;
|
||||
display: -webkit-box;
|
||||
text-overflow: ellipsis;
|
||||
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
|
||||
ion-card {
|
||||
--background: var(--ion-color-primary);
|
||||
|
||||
@@ -32,6 +40,10 @@ ion-card {
|
||||
ion-card-content {
|
||||
padding: 0 0 var(--header-spacing-bottom);
|
||||
|
||||
.description * {
|
||||
color: var(--ion-color-primary-contrast);
|
||||
}
|
||||
|
||||
.opening-hours {
|
||||
color: var(--ion-color-primary-contrast);
|
||||
}
|
||||
|
||||
@@ -13,17 +13,81 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {Component, Input} from '@angular/core';
|
||||
import {Component, ElementRef, HostListener, Input, OnChanges, OnInit, ViewChild} from '@angular/core';
|
||||
import {SCThings} from '@openstapps/core';
|
||||
import {SCIcon} from '../../../util/ion-icon/icon';
|
||||
|
||||
const AccordionButtonState = {
|
||||
collapsed: SCIcon`expand_more`,
|
||||
expanded: SCIcon`expand_less`,
|
||||
};
|
||||
|
||||
@Component({
|
||||
selector: 'stapps-title-card',
|
||||
templateUrl: './title-card.component.html',
|
||||
styleUrls: ['./title-card.component.scss'],
|
||||
})
|
||||
export class TitleCardComponent {
|
||||
export class TitleCardComponent implements OnInit, OnChanges {
|
||||
/**
|
||||
* The item whose title (and description) to display
|
||||
*/
|
||||
@Input() item: SCThings;
|
||||
|
||||
@ViewChild('accordionTextArea') accordionTextArea: ElementRef;
|
||||
|
||||
buttonState = AccordionButtonState.collapsed;
|
||||
|
||||
buttonShown = true;
|
||||
|
||||
descriptionLinesShown: number;
|
||||
|
||||
descriptionLinesTotal: number;
|
||||
|
||||
descriptionPreviewLines = 3;
|
||||
|
||||
descriptionLinesToDisplay = 0;
|
||||
|
||||
ngOnInit(): void {
|
||||
if (this.item.description) {
|
||||
this.descriptionLinesToDisplay = this.descriptionPreviewLines;
|
||||
setTimeout(() => this.checkTextElipsis(), 100);
|
||||
}
|
||||
}
|
||||
|
||||
ngOnChanges() {
|
||||
this.checkTextElipsis();
|
||||
}
|
||||
|
||||
@HostListener('window:resize', ['$event'])
|
||||
checkTextElipsis() {
|
||||
if (this.accordionTextArea === undefined) {
|
||||
return;
|
||||
}
|
||||
const element = this.accordionTextArea.nativeElement as HTMLElement;
|
||||
|
||||
const lineHeight = Number.parseInt(getComputedStyle(element).getPropertyValue('line-height'));
|
||||
this.descriptionLinesTotal = element?.scrollHeight / lineHeight;
|
||||
this.descriptionLinesShown = element?.offsetHeight / lineHeight;
|
||||
if (this.buttonState === AccordionButtonState.expanded) {
|
||||
this.descriptionLinesToDisplay = this.descriptionLinesTotal;
|
||||
}
|
||||
const isElipsed = element?.offsetHeight < element?.scrollHeight;
|
||||
this.buttonShown =
|
||||
(isElipsed && this.buttonState === AccordionButtonState.collapsed) ||
|
||||
(!isElipsed && this.buttonState === AccordionButtonState.expanded);
|
||||
}
|
||||
|
||||
toggleDescriptionAccordion() {
|
||||
if (this.descriptionLinesToDisplay > 0) {
|
||||
this.descriptionLinesToDisplay =
|
||||
this.descriptionLinesToDisplay === this.descriptionPreviewLines
|
||||
? this.descriptionLinesTotal
|
||||
: this.descriptionPreviewLines;
|
||||
}
|
||||
this.buttonState =
|
||||
this.buttonState === AccordionButtonState.collapsed
|
||||
? AccordionButtonState.expanded
|
||||
: AccordionButtonState.collapsed;
|
||||
setTimeout(() => this.checkTextElipsis(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ const DataListItemIndex: Partial<Record<SCThingType, Type<DataListItem>>> = {
|
||||
[SCThingType.Dish]: DishListItemComponent,
|
||||
[SCThingType.DateSeries]: DateSeriesListItemComponent,
|
||||
[SCThingType.AcademicEvent]: EventListItemComponent,
|
||||
[SCThingType.SportCourse]: EventListItemComponent,
|
||||
[SCThingType.SportCourse]: DateSeriesListItemComponent,
|
||||
[SCThingType.Favorite]: FavoriteListItemComponent,
|
||||
[SCThingType.Message]: MessageListItemComponent,
|
||||
[SCThingType.Organization]: OrganizationListItemComponent,
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
[title]="'performers' | propertyNameTranslate : item | titlecase"
|
||||
[content]="item.performers"
|
||||
></stapps-simple-card>
|
||||
<stapps-offers-detail *ngIf="item.offers" [item]="$any(item)"></stapps-offers-detail>
|
||||
<stapps-offers-detail *ngIf="item.offers" [offers]="item.offers"></stapps-offers-detail>
|
||||
<ion-card>
|
||||
<ion-card-header> {{ 'event' | propertyNameTranslate : item | titlecase }} </ion-card-header>
|
||||
<ion-card-content>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<ion-label class="title">{{ 'event.name' | thingTranslate : item }}</ion-label>
|
||||
<p>
|
||||
<ion-icon name="calendar_today"></ion-icon>
|
||||
<span *ngIf="item.dates && item.dates[0] && item.dates[item.dates.length - 1]">
|
||||
<span *ngIf="item.dates[0] && item.dates[item.dates.length - 1]">
|
||||
<span *ngIf="item.repeatFrequency">
|
||||
{{ item.repeatFrequency | durationLocalized : true | sentencecase }}, {{ item.dates[0] |
|
||||
dateFormat : 'weekday:long' }}
|
||||
@@ -30,7 +30,7 @@
|
||||
</span>
|
||||
</span>
|
||||
</p>
|
||||
<ion-note *ngIf="item.event?.type === 'academic event'"
|
||||
<ion-note *ngIf="item.event.type === 'academic event'"
|
||||
>{{ 'categories' | thingTranslate : item.event | join : ', ' }}</ion-note
|
||||
>
|
||||
</div>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
-->
|
||||
|
||||
<stapps-dish-characteristics *ngIf="item.characteristics" [item]="item"></stapps-dish-characteristics>
|
||||
<stapps-offers-detail *ngIf="item.offers" [item]="$any(item)"></stapps-offers-detail>
|
||||
<stapps-offers-detail *ngIf="item.offers" [offers]="item.offers"></stapps-offers-detail>
|
||||
<stapps-certifications-in-detail
|
||||
*ngIf="item.certifications"
|
||||
[certifications]="item.certifications"
|
||||
|
||||
@@ -13,15 +13,7 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Component, Input} from '@angular/core';
|
||||
import {
|
||||
SCAcademicEvent,
|
||||
SCDateSeries,
|
||||
SCSportCourse,
|
||||
SCThing,
|
||||
SCThingType,
|
||||
SCTranslations,
|
||||
} from '@openstapps/core';
|
||||
import {DataProvider} from '../../data.provider';
|
||||
import {SCAcademicEvent, SCSportCourse, SCThing, SCThingTranslator, SCTranslations} from '@openstapps/core';
|
||||
|
||||
/**
|
||||
* TODO
|
||||
@@ -32,41 +24,30 @@ import {DataProvider} from '../../data.provider';
|
||||
styleUrls: ['event-detail-content.scss'],
|
||||
})
|
||||
export class EventDetailContentComponent {
|
||||
@Input() set item(value: SCAcademicEvent | SCSportCourse) {
|
||||
this._item = value;
|
||||
this.dateSeries = this.dataProvider
|
||||
.search({
|
||||
filter: {
|
||||
type: 'boolean',
|
||||
arguments: {
|
||||
operation: 'and',
|
||||
filters: [
|
||||
{
|
||||
type: 'value',
|
||||
arguments: {
|
||||
field: 'type',
|
||||
value: SCThingType.DateSeries,
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'value',
|
||||
arguments: {
|
||||
field: 'event.uid',
|
||||
value: value.uid,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
})
|
||||
.then(result => result.data as SCDateSeries[]);
|
||||
}
|
||||
|
||||
_item: SCAcademicEvent | SCSportCourse;
|
||||
|
||||
dateSeries: Promise<SCDateSeries[]>;
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
@Input() item: SCAcademicEvent | SCSportCourse;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
@Input() language: keyof SCTranslations<SCThing>;
|
||||
|
||||
constructor(readonly dataProvider: DataProvider) {}
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
objectKeys = Object.keys;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
translator: SCThingTranslator;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
constructor() {
|
||||
this.translator = new SCThingTranslator(this.language);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,39 +12,39 @@
|
||||
~ You should have received a copy of the GNU General Public License along with
|
||||
~ this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<p *ngIf="'description' | thingTranslate: _item as description" [innerHtml]="description | sanitizeHtml"></p>
|
||||
|
||||
<stapps-simple-card
|
||||
*ngIf="_item.type === 'academic event' && _item.categories"
|
||||
[title]="'categories' | propertyNameTranslate : _item | titlecase"
|
||||
[content]="'categories' | thingTranslate : _item"
|
||||
*ngIf="item.type === 'academic event' && item.categories"
|
||||
[title]="'categories' | propertyNameTranslate : item | titlecase"
|
||||
[content]="'categories' | thingTranslate : item"
|
||||
>
|
||||
</stapps-simple-card>
|
||||
|
||||
<stapps-add-event-action-chip [item]="_item"></stapps-add-event-action-chip>
|
||||
<stapps-add-event-action-chip *ngIf="item.type === 'academic event'" [item]="item">
|
||||
</stapps-add-event-action-chip>
|
||||
|
||||
<stapps-simple-card
|
||||
*ngIf="_item.performers"
|
||||
[title]="'performers' | propertyNameTranslate : _item | titlecase"
|
||||
[content]="_item.performers"
|
||||
*ngIf="item.performers"
|
||||
[title]="'performers' | propertyNameTranslate : item | titlecase"
|
||||
[content]="item.performers"
|
||||
></stapps-simple-card>
|
||||
<stapps-simple-card
|
||||
*ngIf="_item.organizers"
|
||||
[title]="'organizers' | propertyNameTranslate : _item | titlecase"
|
||||
[content]="_item.organizers"
|
||||
*ngIf="item.organizers"
|
||||
[title]="'organizers' | propertyNameTranslate : item | titlecase"
|
||||
[content]="item.organizers"
|
||||
></stapps-simple-card>
|
||||
<ng-container *ngIf="_item.type === 'academic event'">
|
||||
<ng-container *ngIf="item.type === 'academic event'">
|
||||
<stapps-simple-card
|
||||
*ngIf="_item.majors"
|
||||
[title]="'majors' | propertyNameTranslate : _item"
|
||||
[content]="_item.majors"
|
||||
*ngIf="item.majors"
|
||||
[title]="'majors' | propertyNameTranslate : item"
|
||||
[content]="item.majors"
|
||||
></stapps-simple-card>
|
||||
</ng-container>
|
||||
<ion-card *ngIf="_item.catalogs">
|
||||
<ion-card *ngIf="item.catalogs">
|
||||
<ion-card-header>{{ 'superCatalogs' | propertyNameTranslate : 'catalog' | titlecase }}</ion-card-header>
|
||||
<ion-card-content>
|
||||
<event-route-path
|
||||
*ngFor="let item of _item.catalogs"
|
||||
*ngFor="let item of item.catalogs"
|
||||
[maxItems]="1"
|
||||
[itemsAfterCollapse]="1"
|
||||
[itemsBeforeCollapse]="0"
|
||||
@@ -54,4 +54,3 @@
|
||||
</event-route-path>
|
||||
</ion-card-content>
|
||||
</ion-card>
|
||||
<stapps-simple-data-list [items]="dateSeries"></stapps-simple-data-list>
|
||||
|
||||
@@ -13,10 +13,6 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
p {
|
||||
margin-inline: var(--spacing-md);
|
||||
}
|
||||
|
||||
stapps-add-event-action-chip {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
|
||||
@@ -22,7 +22,6 @@ import {DataListItemComponent} from '../../list/data-list-item.component';
|
||||
@Component({
|
||||
selector: 'stapps-event-list-item',
|
||||
templateUrl: 'event-list-item.html',
|
||||
styleUrls: ['event-list-item.scss'],
|
||||
})
|
||||
export class EventListItemComponent extends DataListItemComponent {
|
||||
/**
|
||||
|
||||
@@ -14,25 +14,27 @@
|
||||
-->
|
||||
|
||||
<ion-grid>
|
||||
<ion-row>
|
||||
<ion-row *ngIf="item.type === 'academic event'">
|
||||
<ion-col>
|
||||
<div class="ion-text-wrap">
|
||||
<ion-label class="title">{{ 'name' | thingTranslate: item }}</ion-label>
|
||||
<p
|
||||
*ngIf="'description' | thingTranslate: item as description"
|
||||
class="title-sub"
|
||||
[innerHtml]="description | sanitizeHtml"
|
||||
></p>
|
||||
<p *ngIf="item.description" class="title-sub">{{ 'description' | thingTranslate: item }}</p>
|
||||
<p *ngIf="item.academicTerms" class="title-sub">
|
||||
{{ 'name' | thingTranslate: item.academicTerms[0] }}
|
||||
</p>
|
||||
<ng-container *ngIf="item.type === 'academic event'">
|
||||
<ion-note *ngIf="!item.categories">{{ 'type' | thingTranslate: item | titlecase }}</ion-note>
|
||||
<ion-note *ngIf="item.categories">
|
||||
{{ 'categories' | thingTranslate: item | join: ', ' | titlecase }}
|
||||
</ion-note>
|
||||
</ng-container>
|
||||
<ion-note *ngIf="!item.categories">{{ 'type' | thingTranslate: item | titlecase }}</ion-note>
|
||||
<ion-note *ngIf="item.categories">
|
||||
{{ 'categories' | thingTranslate: item | join: ', ' | titlecase }}
|
||||
</ion-note>
|
||||
</div>
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
<ion-row *ngIf="item.type === 'sport course'">
|
||||
<ion-col>
|
||||
<ion-label class="title">{{ 'name' | thingTranslate: item }}</ion-label>
|
||||
<p *ngIf="item.description" class="title-sub">{{ 'description' | thingTranslate: item }}</p>
|
||||
<p *ngIf="item.academicTerms" class="title-sub">{{ 'name' | thingTranslate: item.academicTerms[0] }}</p>
|
||||
<ion-note>{{ 'type' | thingTranslate: item }}</ion-note>
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
</ion-grid>
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
.title-sub {
|
||||
max-height: 2.8rem;
|
||||
overflow: hidden;
|
||||
opacity: 0.8;
|
||||
}
|
||||
@@ -29,4 +29,4 @@
|
||||
[content]="item.datePublished | amDateFormat : 'll'"
|
||||
>
|
||||
</stapps-simple-card>
|
||||
<stapps-offers-detail *ngIf="item.offers" [item]="$any(item)"></stapps-offers-detail>
|
||||
<stapps-offers-detail *ngIf="item.offers" [offers]="item.offers"></stapps-offers-detail>
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {DataModule} from '../data/data.module';
|
||||
import {TranslateModule} from '@ngx-translate/core';
|
||||
import {SCSearchFilter, SCThingType} from '@openstapps/core';
|
||||
|
||||
@Component({
|
||||
selector: 'stapps-sport-course-search-page',
|
||||
templateUrl: 'sport-course-search-page.html',
|
||||
standalone: true,
|
||||
imports: [DataModule, TranslateModule],
|
||||
})
|
||||
export class SportCourseSearchPageComponent {
|
||||
forcedFilter: SCSearchFilter = {
|
||||
type: 'value',
|
||||
arguments: {
|
||||
field: 'type',
|
||||
value: SCThingType.SportCourse,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
<stapps-search-page
|
||||
[title]="'sportCourses.title' | translate"
|
||||
[placeholder]="'sportCourses.placeholder' | translate"
|
||||
[showDefaultData]="true"
|
||||
[forcedFilter]="forcedFilter"
|
||||
></stapps-search-page>
|
||||
@@ -1,8 +0,0 @@
|
||||
import {NgModule} from '@angular/core';
|
||||
import {RouterModule} from '@angular/router';
|
||||
import {SportCourseSearchPageComponent} from './sport-course-search-page.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild([{path: 'sport-courses', component: SportCourseSearchPageComponent}])],
|
||||
})
|
||||
export class SportCoursesModule {}
|
||||
@@ -45,7 +45,7 @@ export class ThingTranslateDefaultParser extends ThingTranslateParser {
|
||||
let property = instance as any;
|
||||
|
||||
for (const key of keyPathChain) {
|
||||
property = property?.[key] ?? undefined;
|
||||
property = property[key] ?? undefined;
|
||||
}
|
||||
|
||||
return property;
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
import {Pipe, PipeTransform} from '@angular/core';
|
||||
import {DomSanitizer} from '@angular/platform-browser';
|
||||
|
||||
@Pipe({
|
||||
name: 'bypassSecurityTrustResourceUrl',
|
||||
standalone: true,
|
||||
pure: true,
|
||||
})
|
||||
export class BypassTrustUrlPipe implements PipeTransform {
|
||||
constructor(private sanitizer: DomSanitizer) {}
|
||||
|
||||
transform(url: string) {
|
||||
return this.sanitizer.bypassSecurityTrustUrl(url);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
/*
|
||||
* Copyright (C) 2022 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
@@ -14,16 +15,16 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} tag
|
||||
*/
|
||||
export function matchTagProperties(tag: string) {
|
||||
export function matchTagProperties(tag) {
|
||||
return new RegExp(`(?<=<${tag})[\\s\\S]*?(?=>\\s*<\\/${tag}\\s*>)`, 'g');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string[]} properties
|
||||
*/
|
||||
export function matchPropertyContent(properties: string[]) {
|
||||
export function matchPropertyContent(properties) {
|
||||
const names = properties.join('|');
|
||||
|
||||
return new RegExp(`((?<=(${names})=")[\\w-]+(?="))|((?<=\\[(${names})]="')[\\w-]+(?='"))`, 'g');
|
||||
@@ -13,8 +13,7 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/* eslint-disable unicorn/no-null */
|
||||
|
||||
import {matchPropertyContent, matchTagProperties} from './icon-match';
|
||||
import {matchPropertyContent, matchTagProperties} from './icon-match.mjs';
|
||||
|
||||
describe('matchTagProperties', function () {
|
||||
const regex = matchTagProperties('test');
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user