mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-03-14 18:52:33 +00:00
feat: add detail view for news
This commit is contained in:
@@ -10,6 +10,7 @@ android {
|
|||||||
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
|
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation project(':capacitor-app')
|
implementation project(':capacitor-app')
|
||||||
|
implementation project(':capacitor-browser')
|
||||||
implementation project(':capacitor-haptics')
|
implementation project(':capacitor-haptics')
|
||||||
implementation project(':capacitor-keyboard')
|
implementation project(':capacitor-keyboard')
|
||||||
implementation project(':capacitor-splash-screen')
|
implementation project(':capacitor-splash-screen')
|
||||||
|
|||||||
@@ -3,6 +3,10 @@
|
|||||||
"pkg": "@capacitor/app",
|
"pkg": "@capacitor/app",
|
||||||
"classpath": "com.capacitorjs.plugins.app.AppPlugin"
|
"classpath": "com.capacitorjs.plugins.app.AppPlugin"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"pkg": "@capacitor/browser",
|
||||||
|
"classpath": "com.capacitorjs.plugins.browser.BrowserPlugin"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"pkg": "@capacitor/haptics",
|
"pkg": "@capacitor/haptics",
|
||||||
"classpath": "com.capacitorjs.plugins.haptics.HapticsPlugin"
|
"classpath": "com.capacitorjs.plugins.haptics.HapticsPlugin"
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/
|
|||||||
include ':capacitor-app'
|
include ':capacitor-app'
|
||||||
project(':capacitor-app').projectDir = new File('../node_modules/@capacitor/app/android')
|
project(':capacitor-app').projectDir = new File('../node_modules/@capacitor/app/android')
|
||||||
|
|
||||||
|
include ':capacitor-browser'
|
||||||
|
project(':capacitor-browser').projectDir = new File('../node_modules/@capacitor/browser/android')
|
||||||
|
|
||||||
include ':capacitor-haptics'
|
include ':capacitor-haptics'
|
||||||
project(':capacitor-haptics').projectDir = new File('../node_modules/@capacitor/haptics/android')
|
project(':capacitor-haptics').projectDir = new File('../node_modules/@capacitor/haptics/android')
|
||||||
|
|
||||||
|
|||||||
5
package-lock.json
generated
5
package-lock.json
generated
@@ -2078,6 +2078,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@capacitor/app/-/app-1.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/@capacitor/app/-/app-1.0.6.tgz",
|
||||||
"integrity": "sha512-NjHIs6f4WJQuhabnCkcE6YLyIIn+t4Al5etB/SJGZJwUYRe1yJYtZ4T/KobDIzwwZn9I9de7QbEA5947lGttBQ=="
|
"integrity": "sha512-NjHIs6f4WJQuhabnCkcE6YLyIIn+t4Al5etB/SJGZJwUYRe1yJYtZ4T/KobDIzwwZn9I9de7QbEA5947lGttBQ=="
|
||||||
},
|
},
|
||||||
|
"@capacitor/browser": {
|
||||||
|
"version": "1.0.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@capacitor/browser/-/browser-1.0.6.tgz",
|
||||||
|
"integrity": "sha512-ZDx+HNPRQZKHpWxbYEyDz34Ge4fwhiiGg2UEnA+ol+pmdvHyYxw/c8HafCEVRJutHrXcVdSNoBNAeEPkQeabrQ=="
|
||||||
|
},
|
||||||
"@capacitor/cli": {
|
"@capacitor/cli": {
|
||||||
"version": "3.3.2",
|
"version": "3.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/@capacitor/cli/-/cli-3.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/@capacitor/cli/-/cli-3.3.2.tgz",
|
||||||
|
|||||||
@@ -55,6 +55,7 @@
|
|||||||
"@asymmetrik/ngx-leaflet": "8.1.0",
|
"@asymmetrik/ngx-leaflet": "8.1.0",
|
||||||
"@asymmetrik/ngx-leaflet-markercluster": "5.0.1",
|
"@asymmetrik/ngx-leaflet-markercluster": "5.0.1",
|
||||||
"@capacitor/app": "1.0.6",
|
"@capacitor/app": "1.0.6",
|
||||||
|
"@capacitor/browser": "1.0.6",
|
||||||
"@capacitor/core": "3.3.1",
|
"@capacitor/core": "3.3.1",
|
||||||
"@capacitor/haptics": "1.1.3",
|
"@capacitor/haptics": "1.1.3",
|
||||||
"@capacitor/keyboard": "1.1.3",
|
"@capacitor/keyboard": "1.1.3",
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import {APP_INITIALIZER, NgModule, Provider} from '@angular/core';
|
|||||||
import {BrowserModule} from '@angular/platform-browser';
|
import {BrowserModule} from '@angular/platform-browser';
|
||||||
import {RouteReuseStrategy} from '@angular/router';
|
import {RouteReuseStrategy} from '@angular/router';
|
||||||
import {Diagnostic} from '@ionic-native/diagnostic/ngx';
|
import {Diagnostic} from '@ionic-native/diagnostic/ngx';
|
||||||
import {IonicModule, IonicRouteStrategy} from '@ionic/angular';
|
import {IonicModule, IonicRouteStrategy, Platform} from '@ionic/angular';
|
||||||
import {
|
import {
|
||||||
TranslateLoader,
|
TranslateLoader,
|
||||||
TranslateModule,
|
TranslateModule,
|
||||||
@@ -57,6 +57,8 @@ import {AboutModule} from './modules/about/about.module';
|
|||||||
import {FavoritesModule} from './modules/favorites/favorites.module';
|
import {FavoritesModule} from './modules/favorites/favorites.module';
|
||||||
import {FeedbackModule} from './modules/feedback/feedback.module';
|
import {FeedbackModule} from './modules/feedback/feedback.module';
|
||||||
import {DebugDataCollectorService} from './modules/data/debug-data-collector.service';
|
import {DebugDataCollectorService} from './modules/data/debug-data-collector.service';
|
||||||
|
import {Browser} from './util/browser.factory';
|
||||||
|
import {browserFactory} from './util/browser.factory';
|
||||||
|
|
||||||
registerLocaleData(localeDe);
|
registerLocaleData(localeDe);
|
||||||
|
|
||||||
@@ -119,6 +121,11 @@ const providers: Provider[] = [
|
|||||||
provide: LocationStrategy,
|
provide: LocationStrategy,
|
||||||
useClass: PathLocationStrategy,
|
useClass: PathLocationStrategy,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
provide: Browser,
|
||||||
|
useFactory: browserFactory,
|
||||||
|
deps: [Platform],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
provide: APP_INITIALIZER,
|
provide: APP_INITIALIZER,
|
||||||
multi: true,
|
multi: true,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
import {Component, Input} from '@angular/core';
|
import {Component, Input} from '@angular/core';
|
||||||
import {SCMessage} from '@openstapps/core';
|
import {SCMessage} from '@openstapps/core';
|
||||||
|
import {Browser} from '../../../../util/browser.factory';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* TODO
|
||||||
@@ -21,10 +22,22 @@ import {SCMessage} from '@openstapps/core';
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'stapps-message-detail-content',
|
selector: 'stapps-message-detail-content',
|
||||||
templateUrl: 'message-detail-content.html',
|
templateUrl: 'message-detail-content.html',
|
||||||
|
styleUrls: ['message-detail-content.scss'],
|
||||||
})
|
})
|
||||||
export class MessageDetailContentComponent {
|
export class MessageDetailContentComponent {
|
||||||
|
constructor(private browser: Browser) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* TODO
|
||||||
*/
|
*/
|
||||||
@Input() item: SCMessage;
|
@Input() item: SCMessage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open the external link when clicked
|
||||||
|
*
|
||||||
|
* @param url Web address to open
|
||||||
|
*/
|
||||||
|
onLinkClick(url: string) {
|
||||||
|
this.browser.open(url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<div *ngIf="!item.categories.includes('news'); else news">
|
||||||
<stapps-simple-card
|
<stapps-simple-card
|
||||||
[title]="'messageBody' | propertyNameTranslate: item | titlecase"
|
[title]="'messageBody' | propertyNameTranslate: item | titlecase"
|
||||||
[content]="'messageBody' | thingTranslate: item"
|
[content]="'messageBody' | thingTranslate: item"
|
||||||
@@ -21,3 +22,30 @@
|
|||||||
[title]="'publishers' | propertyNameTranslate: item | titlecase"
|
[title]="'publishers' | propertyNameTranslate: item | titlecase"
|
||||||
[content]="item.publishers"
|
[content]="item.publishers"
|
||||||
></stapps-simple-card>
|
></stapps-simple-card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ng-template #news>
|
||||||
|
<ion-thumbnail>
|
||||||
|
<ion-img
|
||||||
|
*ngIf="item.image"
|
||||||
|
src="{{ item.image }}"
|
||||||
|
(ionError)="$event.target.nextSibling.style.display = 'none'"
|
||||||
|
alt="{{ item.name }}"
|
||||||
|
></ion-img>
|
||||||
|
</ion-thumbnail>
|
||||||
|
<stapps-simple-card
|
||||||
|
*ngIf="item.datePublished"
|
||||||
|
content="{{ item.datePublished | amCalendar | sentencecase }}"
|
||||||
|
></stapps-simple-card>
|
||||||
|
<stapps-simple-card content="{{ item.messageBody }}"></stapps-simple-card>
|
||||||
|
<ion-card *ngIf="item.sameAs">
|
||||||
|
<ion-card-header>
|
||||||
|
{{ 'sameAs' | propertyNameTranslate: item | titlecase }}
|
||||||
|
</ion-card-header>
|
||||||
|
<ion-card-content>
|
||||||
|
<a (click)="onLinkClick(item.sameAs)"
|
||||||
|
>{{ item.name }}<ion-icon name="open-outline"></ion-icon>
|
||||||
|
</a>
|
||||||
|
</ion-card-content>
|
||||||
|
</ion-card>
|
||||||
|
</ng-template>
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
:host {
|
||||||
|
ion-thumbnail {
|
||||||
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
|
img {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
cursor: pointer;
|
||||||
|
ion-icon {
|
||||||
|
vertical-align: text-top;
|
||||||
|
font-size: 80%;
|
||||||
|
padding-left: 2px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Show smaller image on a desktop
|
||||||
|
@media (min-width: 992px) {
|
||||||
|
ion-thumbnail {
|
||||||
|
width: 60%;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
import {Component, Input} from '@angular/core';
|
import {Component, Input} from '@angular/core';
|
||||||
import {SCMessage} from '@openstapps/core';
|
import {SCMessage} from '@openstapps/core';
|
||||||
|
import {Browser} from '../../../util/browser.factory';
|
||||||
/**
|
/**
|
||||||
* News page component
|
* News page component
|
||||||
*/
|
*/
|
||||||
@@ -23,8 +24,14 @@ import {SCMessage} from '@openstapps/core';
|
|||||||
styleUrls: ['news-item.scss'],
|
styleUrls: ['news-item.scss'],
|
||||||
})
|
})
|
||||||
export class NewsItemComponent {
|
export class NewsItemComponent {
|
||||||
|
constructor(private browser: Browser) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* News (message) to show
|
* News (message) to show
|
||||||
*/
|
*/
|
||||||
@Input() item: SCMessage;
|
@Input() item: SCMessage;
|
||||||
|
|
||||||
|
onLinkClick(url: string) {
|
||||||
|
this.browser.open(url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<ion-card>
|
<ion-card>
|
||||||
<span *ngIf="item.sameAs; else imageNoUrl">
|
<span>
|
||||||
<a href="{{ item.sameAs }}">
|
<a [routerLink]="['/data-detail', item.uid]">
|
||||||
<ion-thumbnail
|
<ion-thumbnail
|
||||||
><ion-img
|
><ion-img
|
||||||
src="{{ item.image }}"
|
src="{{ item.image }}"
|
||||||
@@ -11,31 +11,20 @@
|
|||||||
</ion-thumbnail>
|
</ion-thumbnail>
|
||||||
</a>
|
</a>
|
||||||
</span>
|
</span>
|
||||||
<ng-template #imageNoUrl>
|
|
||||||
<ion-thumbnail>
|
|
||||||
<ion-img
|
|
||||||
src="{{ item.image }}"
|
|
||||||
(ionError)="$event.target.nextSibling.style.display = 'block'"
|
|
||||||
alt=""
|
|
||||||
></ion-img>
|
|
||||||
<ion-icon name="newspaper-outline"></ion-icon>
|
|
||||||
</ion-thumbnail>
|
|
||||||
</ng-template>
|
|
||||||
<ion-card-header>
|
<ion-card-header>
|
||||||
<ion-card-subtitle *ngIf="item.datePublished">{{
|
<ion-card-subtitle *ngIf="item.datePublished">{{
|
||||||
item.datePublished | amCalendar | sentencecase
|
item.datePublished | amCalendar | sentencecase
|
||||||
}}</ion-card-subtitle>
|
}}</ion-card-subtitle>
|
||||||
<ion-card-title>
|
<ion-card-title>
|
||||||
<span *ngIf="item.sameAs; else titleNoUrl"
|
<span>
|
||||||
><a href="{{ item.sameAs }}"
|
<a [routerLink]="['/data-detail', item.uid]"
|
||||||
><span class="text">{{ item.name }}</span
|
><span class="text">{{ item.name }}</span></a
|
||||||
><span class="icon"
|
></span
|
||||||
><ion-icon name="open-outline"></ion-icon></span></a
|
>
|
||||||
></span>
|
|
||||||
<ng-template #titleNoUrl>{{ item.name }}</ng-template>
|
|
||||||
</ion-card-title>
|
</ion-card-title>
|
||||||
</ion-card-header>
|
</ion-card-header>
|
||||||
<ion-card-content>
|
<ion-card-content>
|
||||||
{{ item.messageBody }}
|
<!-- TODO: Temporary solution until the designs are ready, where is probable use of title only -->
|
||||||
|
{{ item.messageBody | slice: 0:120 }}...
|
||||||
</ion-card-content>
|
</ion-card-content>
|
||||||
</ion-card>
|
</ion-card>
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
ion-card-header a {
|
ion-card-header a {
|
||||||
color: var(--ion-color-dark-tint);
|
color: var(--ion-color-dark-tint);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
span.icon ion-icon {
|
|
||||||
vertical-align: text-top;
|
|
||||||
font-size: 60%;
|
|
||||||
padding-left: 4px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ion-card ion-thumbnail {
|
ion-card ion-thumbnail {
|
||||||
|
|||||||
36
src/app/util/browser.factory.ts
Normal file
36
src/app/util/browser.factory.ts
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* 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 {Platform} from '@ionic/angular';
|
||||||
|
import {Browser as BrowserPlugin} from '@capacitor/browser';
|
||||||
|
|
||||||
|
export abstract class Browser {
|
||||||
|
abstract open(url: string): Promise<void> | void;
|
||||||
|
}
|
||||||
|
|
||||||
|
class CapacitorBrowser {
|
||||||
|
open(url: string) {
|
||||||
|
return BrowserPlugin.open({url});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class WebBrowser {
|
||||||
|
open(url: string) {
|
||||||
|
window.open(url, '_blank');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const browserFactory = (platform: Platform) => {
|
||||||
|
return platform.is('capacitor') ? new CapacitorBrowser() : new WebBrowser();
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user