feat: add about module

This commit is contained in:
Jovan Krunić
2021-10-27 08:25:41 +00:00
committed by Rainer Killinger
parent 7d449b43d0
commit d420008926
32 changed files with 999 additions and 65 deletions

View File

@@ -0,0 +1,23 @@
/*
* 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} from '@angular/core';
@Component({
selector: 'about-changelog',
templateUrl: 'about-changelog.html',
styleUrls: ['about-changelog.scss'],
})
export class AboutChangelogComponent {}

View File

@@ -0,0 +1,28 @@
<!--
~ 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-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-menu-button></ion-menu-button>
<ion-back-button></ion-back-button>
</ion-buttons>
<ion-title>Changelog</ion-title>
<!-- TODO: translation -->
</ion-toolbar>
</ion-header>
<ion-content>
<markdown src="assets/about/CHANGELOG.md"></markdown>
</ion-content>

View File

@@ -0,0 +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-content {
--padding-start: 16px;
}

View File

@@ -0,0 +1,31 @@
/*
* 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, Input} from '@angular/core';
import {License} from './about-licenses.component';
@Component({
selector: 'about-license-modal',
templateUrl: 'about-license-modal.html',
styleUrls: ['about-license-modal.scss'],
})
export class AboutLicenseModalComponent {
@Input() license: License;
/**
* Action when close is pressed
*/
@Input() dismissAction: () => void;
}

View File

@@ -0,0 +1,30 @@
<!--
~ 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-header>
<ion-card-title>
<ion-label>{{ license.licenses }}</ion-label>
</ion-card-title>
<ion-button fill="clear" (click)="dismissAction()">
<ion-label>{{ 'modal.DISMISS' | translate }}</ion-label>
</ion-button>
</ion-card-header>
<ion-card-content>
<ion-content>
<ion-list>
<pre>{{ license.licenseText }}</pre>
</ion-list>
</ion-content>
</ion-card-content>

View File

@@ -0,0 +1,34 @@
/*!
* 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-header {
ion-button {
position: absolute;
right: 0;
top: 0;
}
}
ion-card-content {
height: 100%;
ion-content {
ion-list {
pre {
white-space: pre-wrap;
}
}
}
}

View File

@@ -0,0 +1,72 @@
/*
* 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, OnInit} from '@angular/core';
import {map} from 'lodash-es';
import {ModalController} from '@ionic/angular';
import {AboutLicenseModalComponent} from './about-license-modal.component';
import licensesFile from 'src/assets/about/licenses.json';
export interface License {
name: string;
licenses: string;
repository: string;
authors?: string;
publisher?: string;
email?: string;
url?: string;
path: string;
licenseText?: string;
}
@Component({
selector: 'about-changelog',
templateUrl: 'about-licenses.html',
styleUrls: ['about-licenses.scss'],
})
export class AboutLicensesComponent implements OnInit {
licenses: License[];
constructor(private modalController: ModalController) {}
ngOnInit() {
this.licenses = this.loadLicenses();
}
async viewLicense(license: License) {
const modal = await this.modalController.create({
component: AboutLicenseModalComponent,
componentProps: {
license: license,
dismissAction: () => {
modal.dismiss();
},
},
swipeToClose: true,
});
return await modal.present();
}
loadLicenses(): License[] {
return map(
// eslint-disable-next-line @typescript-eslint/ban-types
licensesFile as Record<string, object>,
(value, key) =>
({
name: key,
...value,
} as unknown as License),
);
}
}

View File

@@ -0,0 +1,54 @@
<!--
~ 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-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-menu-button></ion-menu-button>
<ion-back-button></ion-back-button>
</ion-buttons>
<ion-title>Licenses</ion-title>
<!-- TODO: translation -->
</ion-toolbar>
</ion-header>
<cdk-virtual-scroll-viewport
itemSize="130"
minBufferPx="1500"
maxBufferPx="2000"
>
<ion-card
*cdkVirtualFor="let license of licenses"
[href]="license.url || license.repository"
rel="external"
target="_blank"
>
<ion-card-header>
<ion-card-title>
{{ license.name }}
<ion-icon class="supertext-icon" name="open-outline"></ion-icon>
</ion-card-title>
<ion-card-subtitle *ngIf="license.authors || license.publisher">
{{ license.authors || license.publisher }}
</ion-card-subtitle>
</ion-card-header>
<ion-card-content>
<ion-chip (click)="$event.preventDefault(); viewLicense(license)">
<ion-icon name="document"></ion-icon>
<ion-label>{{ license.licenses }} License</ion-label>
</ion-chip>
</ion-card-content>
</ion-card>
</cdk-virtual-scroll-viewport>

View File

@@ -0,0 +1,35 @@
/*!
* 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/>.
*/
cdk-virtual-scroll-viewport {
height: 100%;
width: 100%;
}
::ng-deep {
.cdk-virtual-scroll-content-wrapper {
width: 100%;
}
}
.virtual-scroll-expander {
clear: both;
}
.supertext-icon {
vertical-align: text-top;
font-size: 60%;
padding-left: 4px;
}

View File

@@ -0,0 +1,29 @@
/*
* 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, Input} from '@angular/core';
import {SCAboutPageContent} from '@openstapps/core';
@Component({
selector: 'about-page-content',
templateUrl: 'about-page-content.html',
styleUrls: ['about-page-content.scss'],
})
export class AboutPageContentComponent {
@Input() content: SCAboutPageContent;
isSimpleTextContent(content: unknown | string): content is string {
return typeof content === 'string';
}
}

View File

@@ -0,0 +1,52 @@
<!--
~ 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/>.
-->
<div [ngSwitch]="content.type">
<markdown
[data]="'value' | translateSimple: content"
*ngSwitchCase="'markdown'"
></markdown>
<div *ngSwitchCase="'section'">
<ion-card *ngIf="content.card; else noCard">
<ion-card-header>
<ion-card-title>{{
'title' | translateSimple: content
}}</ion-card-title>
</ion-card-header>
<ion-card-content>
<about-page-content [content]="content.content"></about-page-content>
</ion-card-content>
</ion-card>
<ng-template #noCard>
<h2>{{ 'title' | translateSimple: content }}</h2>
<about-page-content [content]="content.content"></about-page-content>
</ng-template>
</div>
<ion-grid *ngSwitchCase="'table'">
<ion-row *ngFor="let row of content.rows">
<ion-col *ngFor="let col of row">
<about-page-content [content]="col"></about-page-content>
</ion-col>
</ion-row>
</ion-grid>
<ion-item *ngSwitchCase="'router link'" [routerLink]="content.link">
<ion-icon
*ngIf="content.icon"
[name]="content.icon"
slot="start"
></ion-icon>
<ion-label>{{ 'title' | translateSimple: content }}</ion-label>
</ion-item>
</div>

View File

@@ -0,0 +1,14 @@
/*!
* 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/>.
*/

View File

@@ -0,0 +1,44 @@
/*
* 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, OnInit} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import {SCAboutPage, SCAppConfiguration} from '@openstapps/core';
import {ConfigProvider} from '../../config/config.provider';
@Component({
selector: 'about-page',
templateUrl: 'about-page.html',
styleUrls: ['about-page.scss'],
})
export class AboutPageComponent implements OnInit {
content: Promise<SCAboutPage>;
constructor(
private readonly route: ActivatedRoute,
private readonly configProvider: ConfigProvider,
) {}
async ngOnInit() {
const route = this.route.snapshot.url.map(it => it.path).join('/');
this.content = new Promise(resolve => {
this.configProvider
.getValue('aboutPages')
.then(value =>
resolve((value as SCAppConfiguration['aboutPages'])[route] ?? {}),
);
});
}
}

View File

@@ -0,0 +1,37 @@
<!--
~ 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-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-menu-button></ion-menu-button>
<ion-back-button></ion-back-button>
</ion-buttons>
<ion-title *ngIf="content | async as content; else titleLoading">{{
'title' | translateSimple: content
}}</ion-title>
<ng-template #titleLoading>
<ion-title
><ion-skeleton-text animated="true"></ion-skeleton-text
></ion-title>
</ng-template>
</ion-toolbar>
</ion-header>
<ion-content *ngIf="content | async as content">
<about-page-content
*ngFor="let element of content.content"
[content]="element"
></about-page-content>
</ion-content>

View File

@@ -0,0 +1,19 @@
/*!
* 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-content {
--padding-start: 8px;
--padding-top: 8px;
}

View File

@@ -0,0 +1,65 @@
/*
* 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 {RouterModule, Routes} from '@angular/router';
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {FormsModule} from '@angular/forms';
import {IonicModule} from '@ionic/angular';
import {TranslateModule} from '@ngx-translate/core';
import {ThingTranslateModule} from '../../translation/thing-translate.module';
import {ConfigProvider} from '../config/config.provider';
import {AboutPageComponent} from './about-page/about-page.component';
import {MarkdownModule} from 'ngx-markdown';
import {AboutPageContentComponent} from './about-page/about-page-content.component';
import {AboutLicensesComponent} from './about-licenses.component';
import {DataModule} from '../data/data.module';
import {ScrollingModule} from '@angular/cdk/scrolling';
import {AboutLicenseModalComponent} from './about-license-modal.component';
import {AboutChangelogComponent} from './about-changelog.component';
const settingsRoutes: Routes = [
{path: 'about', component: AboutPageComponent},
{path: 'about/changelog', component: AboutChangelogComponent},
{path: 'about/imprint', component: AboutPageComponent},
{path: 'about/privacy', component: AboutPageComponent},
{path: 'about/terms', component: AboutPageComponent},
{path: 'about/licenses', component: AboutLicensesComponent},
];
/**
* Settings Module
*/
@NgModule({
declarations: [
AboutPageComponent,
AboutPageContentComponent,
AboutLicensesComponent,
AboutLicenseModalComponent,
AboutChangelogComponent,
],
imports: [
CommonModule,
FormsModule,
IonicModule.forRoot(),
TranslateModule.forChild(),
ThingTranslateModule.forChild(),
RouterModule.forChild(settingsRoutes),
MarkdownModule,
DataModule,
ScrollingModule,
],
providers: [ConfigProvider],
})
export class AboutModule {}

View File

@@ -0,0 +1,22 @@
/*
* 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} from '@angular/core';
@Component({
selector: 'stapps-license',
templateUrl: 'license.html',
styleUrls: ['license.scss'],
})
export class LicenseComponent {}

View File

@@ -0,0 +1,19 @@
/*!
* 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/>.
*/
div {
border: 1px var(--ion-color-light-shade) round;
font-family: monospace;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 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.
@@ -14,10 +14,11 @@
*/
import {TestBed} from '@angular/core/testing';
import {
SCAboutPageContentType,
SCIndexResponse,
SCSettingInputType,
SCThingOriginType,
SCThingType,
SCSettingInputType,
} from '@openstapps/core';
import {StAppsWebHttpClient} from '../data/stapps-web-http-client.provider';
import {StorageProvider} from '../storage/storage.provider';
@@ -220,7 +221,27 @@ const scVersion = packageJson.dependencies['@openstapps/core'];
const sampleIndexResponse: SCIndexResponse = {
app: {
aboutPages: {},
aboutPages: {
about: {
title: 'About',
content: [
{
value: 'This is the about page',
type: SCAboutPageContentType.MARKDOWN,
translations: {
en: {
value: 'This is the about page',
},
},
},
],
translations: {
en: {
title: 'About',
},
},
},
},
campusPolygon: {
coordinates: [[[1, 2]], [[1, 2]]],
type: 'Polygon',

View File

@@ -1,9 +1,24 @@
<!--
~ 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-header>
<ion-card-title>{{
'schedule.addEventModal.addEvent' | translate
}}</ion-card-title>
<ion-button fill="clear" (click)="dismissAction()">
<ion-label>{{ 'schedule.addEventModal.close' | translate }}</ion-label>
<ion-label>{{ 'modal.DISMISS' | translate }}</ion-label>
</ion-button>
</ion-card-header>

View File

@@ -1,6 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/*
* Copyright (C) 2018, 2019 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,8 +12,10 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
/* eslint-disable @typescript-eslint/no-explicit-any */
import {TestBed} from '@angular/core/testing';
import {Storage} from '@ionic/storage';
import {Storage} from '@ionic/storage-angular';
import {StorageModule} from './storage.module';
import {StorageProvider} from './storage.provider';