mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-19 16:13:06 +00:00
refactor: update openstapps packages
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/*
|
||||
* Copyright (C) 2021 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
@@ -13,6 +12,8 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import {
|
||||
ChangeDetectorRef,
|
||||
Component,
|
||||
@@ -225,9 +226,9 @@ export class AddEventPopoverComponent implements OnInit, OnDestroy {
|
||||
selected: this.uuids.includes(item.uid),
|
||||
item: item,
|
||||
})),
|
||||
it => it.item.frequency,
|
||||
it => it.item.repeatFrequency,
|
||||
),
|
||||
it => it.item.frequency,
|
||||
it => it.item.repeatFrequency,
|
||||
),
|
||||
).map(item => new TreeNode(item, this.ref)),
|
||||
this.ref,
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
<!--
|
||||
~ 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/>.
|
||||
-->
|
||||
|
||||
<ion-card-content>
|
||||
<ion-item-group>
|
||||
<ion-item-divider (click)="selection.click()">
|
||||
@@ -14,7 +29,9 @@
|
||||
<ion-item-group *ngFor="let frequency of selection.children">
|
||||
<ion-item-divider (click)="frequency.click()">
|
||||
<ion-label>{{
|
||||
'frequency' | thingTranslate: frequency.children[0].item | titlecase
|
||||
frequency.children[0].item.repeatFrequency
|
||||
? (frequency.children[0].item.repeatFrequency | amDuration)
|
||||
: ('data.chips.add_events.popover.SINGLE' | translate | titlecase)
|
||||
}}</ion-label>
|
||||
<ion-checkbox
|
||||
slot="start"
|
||||
|
||||
@@ -42,8 +42,10 @@ export class DataIconPipe implements PipeTransform {
|
||||
'floor': 'caret-up-circle',
|
||||
'message': 'newspaper',
|
||||
'organization': 'briefcase',
|
||||
'periodical': 'newspaper',
|
||||
'person': 'person',
|
||||
'point of interest': 'location',
|
||||
'publication event': 'megaphone',
|
||||
'room': 'location',
|
||||
'semester': 'school',
|
||||
'setting': 'settings',
|
||||
|
||||
@@ -23,9 +23,7 @@ import {
|
||||
SCSearchQuery,
|
||||
SCSearchResponse,
|
||||
SCSearchValueFilter,
|
||||
SCThing,
|
||||
SCThingOriginType,
|
||||
SCThings,
|
||||
SCThingType,
|
||||
} from '@openstapps/core';
|
||||
import {sampleThingsMap} from '../../_helpers/data/sample-things';
|
||||
@@ -66,7 +64,7 @@ describe('DataProvider', () => {
|
||||
filter: sampleFilter,
|
||||
};
|
||||
|
||||
const sampleSavable: SCSaveableThing<SCThings> = {
|
||||
const sampleSavable: SCSaveableThing = {
|
||||
data: sampleThing,
|
||||
name: sampleThing.name,
|
||||
origin: {
|
||||
@@ -168,7 +166,7 @@ describe('DataProvider', () => {
|
||||
});
|
||||
|
||||
it('should put an data item into the local database (storage)', async () => {
|
||||
let providedThing: SCSaveableThing<SCThing>;
|
||||
let providedThing: SCSaveableThing;
|
||||
spyOn(storageProvider, 'put' as any).and.callFake(
|
||||
(_id: any, thing: any) => {
|
||||
providedThing = thing;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Client} from '@openstapps/api/lib/client';
|
||||
import {
|
||||
SCIndexableThings,
|
||||
SCMultiSearchRequest,
|
||||
SCMultiSearchResponse,
|
||||
SCSearchRequest,
|
||||
@@ -148,23 +149,18 @@ export class DataProvider {
|
||||
/**
|
||||
* Provides a savable thing from the local database using the provided UID
|
||||
*/
|
||||
async get(
|
||||
uid: string,
|
||||
scope: DataScope.Local,
|
||||
): Promise<SCSaveableThing<SCThings>>;
|
||||
async get(uid: string, scope: DataScope.Local): Promise<SCSaveableThing>;
|
||||
/**
|
||||
* Provides a thing from the backend
|
||||
*/
|
||||
async get(
|
||||
uid: string,
|
||||
scope: DataScope.Remote,
|
||||
): Promise<SCThings | SCSaveableThing<SCThings>>;
|
||||
): Promise<SCThings | SCSaveableThing>;
|
||||
/**
|
||||
* Provides a thing from both local database and backend
|
||||
*/
|
||||
async get(
|
||||
uid: string,
|
||||
): Promise<Map<DataScope, SCThings | SCSaveableThing<SCThings>>>;
|
||||
async get(uid: string): Promise<Map<DataScope, SCThings | SCSaveableThing>>;
|
||||
|
||||
/**
|
||||
* Provides a thing from the local database only, backend only or both, depending on the scope
|
||||
@@ -176,19 +172,15 @@ export class DataProvider {
|
||||
uid: string,
|
||||
scope?: DataScope,
|
||||
): Promise<
|
||||
| SCThings
|
||||
| SCSaveableThing<SCThings>
|
||||
| Map<DataScope, SCThings | SCSaveableThing<SCThings>>
|
||||
SCThings | SCSaveableThing | Map<DataScope, SCThings | SCSaveableThing>
|
||||
> {
|
||||
if (scope === DataScope.Local) {
|
||||
return this.storageProvider.get<SCSaveableThing<SCThings>>(
|
||||
this.getDataKey(uid),
|
||||
);
|
||||
return this.storageProvider.get<SCSaveableThing>(this.getDataKey(uid));
|
||||
}
|
||||
if (scope === DataScope.Remote) {
|
||||
return this.client.getThing(uid);
|
||||
}
|
||||
const map: Map<DataScope, SCThings | SCSaveableThing<SCThings>> = new Map();
|
||||
const map: Map<DataScope, SCThings | SCSaveableThing> = new Map();
|
||||
map.set(DataScope.Local, await this.get(uid, DataScope.Local));
|
||||
map.set(DataScope.Remote, await this.get(uid, DataScope.Remote));
|
||||
|
||||
@@ -198,10 +190,8 @@ export class DataProvider {
|
||||
/**
|
||||
* Provides all things saved in the local database
|
||||
*/
|
||||
async getAll(): Promise<Map<string, SCSaveableThing<SCThings>>> {
|
||||
return this.storageProvider.search<SCSaveableThing<SCThings>>(
|
||||
this.storagePrefix,
|
||||
);
|
||||
async getAll(): Promise<Map<string, SCSaveableThing>> {
|
||||
return this.storageProvider.search<SCSaveableThing>(this.storagePrefix);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -248,10 +238,10 @@ export class DataProvider {
|
||||
* @param [type] Savable type (e.g. 'favorite'); if nothing is provided then type of the thing is used
|
||||
*/
|
||||
async put(
|
||||
item: SCThings,
|
||||
item: SCIndexableThings,
|
||||
type?: SCThingType,
|
||||
): Promise<SCSaveableThing<SCThings>> {
|
||||
const savableItem: SCSaveableThing<SCThings> = {
|
||||
): Promise<SCSaveableThing> {
|
||||
const savableItem: SCSaveableThing = {
|
||||
data: item,
|
||||
name: item.name,
|
||||
origin: {
|
||||
@@ -263,7 +253,7 @@ export class DataProvider {
|
||||
};
|
||||
|
||||
// @TODO: Implementation for saving item into the backend (user's account)
|
||||
return this.storageProvider.put<SCSaveableThing<SCThings>>(
|
||||
return this.storageProvider.put<SCSaveableThing>(
|
||||
this.getDataKey(item.uid),
|
||||
savableItem,
|
||||
);
|
||||
|
||||
@@ -50,9 +50,9 @@ export class DataDetailComponent implements OnInit {
|
||||
* Type guard for SCSavableThing
|
||||
*/
|
||||
static isSCSavableThing(
|
||||
thing: SCThings | SCSaveableThing<SCThings>,
|
||||
): thing is SCSaveableThing<SCThings> {
|
||||
return typeof (thing as SCSaveableThing<SCThings>).data !== 'undefined';
|
||||
thing: SCThings | SCSaveableThing,
|
||||
): thing is SCSaveableThing {
|
||||
return typeof (thing as SCSaveableThing).data !== 'undefined';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
<p>
|
||||
<ion-icon name="calendar"></ion-icon>
|
||||
<span>
|
||||
{{ item.frequency }}, {{ item.dates[0] | amDateFormat: 'dddd' }}
|
||||
{{ item.repeatFrequency | amDuration }},
|
||||
{{ item.dates[0] | amDateFormat: 'dddd' }}
|
||||
<span
|
||||
>({{ item.dates[0] | amDateFormat: 'll' }} -
|
||||
{{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<ion-card>
|
||||
<span *ngIf="item.url; else imageNoUrl">
|
||||
<a href="{{ item.url }}">
|
||||
<span *ngIf="item.sameAs; else imageNoUrl">
|
||||
<a href="{{ item.sameAs }}">
|
||||
<ion-thumbnail
|
||||
><ion-img
|
||||
src="{{ item.image }}"
|
||||
@@ -26,8 +26,8 @@
|
||||
item.datePublished | amDateFormat: 'LLL'
|
||||
}}</ion-card-subtitle>
|
||||
<ion-card-title>
|
||||
<span *ngIf="item.url; else titleNoUrl"
|
||||
><a href="{{ item.url }}"
|
||||
<span *ngIf="item.sameAs; else titleNoUrl"
|
||||
><a href="{{ item.sameAs }}"
|
||||
><span class="text">{{ item.name }}</span
|
||||
><span class="icon"
|
||||
><ion-icon name="open-outline"></ion-icon></span></a
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
<!--
|
||||
~ 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/>.
|
||||
-->
|
||||
|
||||
<ion-card
|
||||
[style.height.px]="height * scale"
|
||||
[style.marginTop.px]="(fromY - fromHour) * scale - 5"
|
||||
@@ -12,9 +27,13 @@
|
||||
</ion-card-title>
|
||||
<ion-card-subtitle>
|
||||
<ion-icon name="calendar"></ion-icon>
|
||||
<span class="repetitions">
|
||||
{{ scheduleEvent.dateSeries.frequency }}
|
||||
until
|
||||
<span
|
||||
class="repetitions"
|
||||
*ngIf="scheduleEvent.dateSeries.repeatFrequency"
|
||||
>
|
||||
{{ 'schedule.card.forEach' | translate }}
|
||||
{{ scheduleEvent.dateSeries.repeatFrequency | amDuration }}
|
||||
{{ 'schedule.card.until' | translate }}
|
||||
{{
|
||||
scheduleEvent.dateSeries.dates | last | amDateFormat: 'DD. MMM YYYY'
|
||||
}}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
import {Component, Input, OnDestroy, OnInit} from '@angular/core';
|
||||
import {SCDateSeries, SCUuid} from '@openstapps/core';
|
||||
import {flatMap, groupBy, omit, sortBy} from 'lodash-es';
|
||||
import {flatMap, groupBy, isNil, omit, sortBy} from 'lodash-es';
|
||||
import moment from 'moment';
|
||||
import {Subscription} from 'rxjs';
|
||||
import {materialFade} from '../../../animation/material-motion';
|
||||
@@ -115,7 +115,7 @@ export class ScheduleSingleEventsComponent implements OnInit, OnDestroy {
|
||||
|
||||
// TODO: replace with filter
|
||||
return ScheduleSingleEventsComponent.groupDateSeriesToDays(
|
||||
dateSeries.filter(it => it.frequency === 'single'),
|
||||
dateSeries.filter(it => isNil(it.repeatFrequency)),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable unicorn/no-null */
|
||||
/*
|
||||
* Copyright (C) 2018-2020 StApps
|
||||
* 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.
|
||||
@@ -13,11 +12,14 @@
|
||||
* 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 unicorn/no-null */
|
||||
import {Injectable, OnDestroy} from '@angular/core';
|
||||
import {
|
||||
Bounds,
|
||||
SCDateSeries,
|
||||
SCISO8601Date,
|
||||
SCISO8601Duration,
|
||||
SCSearchFilter,
|
||||
SCThingType,
|
||||
SCUuid,
|
||||
@@ -102,7 +104,7 @@ export class ScheduleProvider implements OnDestroy {
|
||||
*/
|
||||
async getDateSeries(
|
||||
uuids: SCUuid[],
|
||||
frequencies?: Array<'single' | 'weekly' | 'biweekly'>,
|
||||
frequencies?: Array<SCISO8601Duration>,
|
||||
from?: SCISO8601Date | 'now',
|
||||
to?: SCISO8601Date | 'now',
|
||||
): Promise<SCDateSeries[]> {
|
||||
@@ -138,7 +140,7 @@ export class ScheduleProvider implements OnDestroy {
|
||||
arguments: {
|
||||
filters: frequencies.map(frequency => ({
|
||||
arguments: {
|
||||
field: 'frequency',
|
||||
field: 'repeatFrequency',
|
||||
value: frequency,
|
||||
},
|
||||
type: 'value',
|
||||
|
||||
Reference in New Issue
Block a user