Skip to content
Snippets Groups Projects
Commit 7eacb815 authored by Florent Poittevin's avatar Florent Poittevin
Browse files

Manage display of welcome page

parent 8b92d6c1
No related branches found
No related tags found
1 merge request!41632 633 Add home page with rss news and twitter
Showing
with 262 additions and 34 deletions
......@@ -38,7 +38,7 @@
"/api/rss": {
"target": "https://www.unige.ch/feed",
"secure": true,
"logLevel": "debug",
"logLevel": "info",
"pathRewrite": {
"^/api": ""
},
......
......@@ -9,15 +9,6 @@ import {DlcmRoutes} from "@app/shared/models/dlcm-route.model";
import {TRANSLATE} from "solidify-frontend";
const routes: DlcmRoutes = [
{
path: AppRoutesEnum.welcomePage,
// @ts-ignore Dynamic import
loadChildren: () => import("./features/welcome/welcome.module").then(m => m.WelcomeModule),
data: {
permission: ApplicationRolePermissionEnum.noPermission,
},
canActivate: [ApplicationRoleGuardService],
},
{
path: AppRoutesEnum.homePage,
// @ts-ignore Dynamic import
......@@ -68,7 +59,7 @@ const routes: DlcmRoutes = [
pathMatch: "full",
},
{
path: AppRoutesEnum.home,
path: AppRoutesEnum.homePage,
redirectTo: AppRoutesEnum.homePage,
pathMatch: "full",
},
......
<a [href]="item.link" target="_blank">
<div class="item-rss">
<h2>{{item.title}}</h2>
<span>{{item.pubDate | date}}</span>
<img *ngIf="getImage(item) as imageUrl" [src]="imageUrl">
</div>
</a>
@import "../sass/abstracts/variables";
@import "../sass/abstracts/mixins";
.item-rss {
color: $text-color;
padding: 10px;
&:hover {
background-color: rgba(160, 200, 220, .12);
}
h2 {
margin-bottom: 0;
}
img {
margin-top: 10px;
width: 100%;
border-radius: 4px;
}
}
import {async, ComponentFixture, TestBed} from "@angular/core/testing";
import {WelcomeTwitterWrapperPresentational} from "./welcome-twitter-wrapper.presentational";
import {HomeRssDetailPresentational} from "./home-rss-detail.presentational";
describe("WelcomeTweetWrapperPresentational", () => {
let component: WelcomeTwitterWrapperPresentational;
let fixture: ComponentFixture<WelcomeTwitterWrapperPresentational>;
describe("HomeRssDetailPresentational", () => {
let component: HomeRssDetailPresentational;
let fixture: ComponentFixture<HomeRssDetailPresentational>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [WelcomeTwitterWrapperPresentational],
declarations: [HomeRssDetailPresentational],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(WelcomeTwitterWrapperPresentational);
fixture = TestBed.createComponent(HomeRssDetailPresentational);
component = fixture.componentInstance;
component.item = {
title: "test",
description: "desc",
pubDate: new Date(),
link: "url",
};
fixture.detectChanges();
});
it("should create", () => {
expect(component).toBeTruthy();
expect(() => fixture.detectChanges()).not.toThrow();
});
});
import {ChangeDetectionStrategy, Component, Input} from "@angular/core";
import {RssItem} from "@app/features/home/models/rss.model";
import {SharedAbstractPresentational} from "@app/shared/components/presentationals/shared-abstract/shared-abstract.presentational";
import {isNullOrUndefined} from "solidify-frontend";
@Component({
selector: "dlcm-home-rss-detail-presentational",
templateUrl: "./home-rss-detail.presentational.html",
styleUrls: ["./home-rss-detail.presentational.scss"],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class HomeRssDetailPresentational extends SharedAbstractPresentational {
@Input()
item: RssItem;
getImage(item: RssItem): string | undefined {
if (isNullOrUndefined(item) || isNullOrUndefined(item.enclosure) || isNullOrUndefined(item.enclosure["@attributes"] || isNullOrUndefined(item.enclosure["@attributes"].url))) {
return undefined;
}
return item.enclosure["@attributes"].url;
}
}
<div class="rss-wrapper">
<h1>{{rss.channel.title}}</h1>
<div class="rss-items-wrapper">
<ng-container *ngFor="let item of rssItems">
<dlcm-home-rss-detail-presentational [item]="item">
</dlcm-home-rss-detail-presentational>
</ng-container>
</div>
</div>
@import "../sass/abstracts/mixins";
.rss-wrapper {
display: flex;
flex-direction: column;
align-items: center;
}
.rss-items-wrapper {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
> * {
width: 30%;
@include respond-to-smaller-than-breakpoint('lg') {
width: 50%;
}
@include respond-to-smaller-than-breakpoint('sm') {
width: 100%;
}
}
}
import {NO_ERRORS_SCHEMA} from "@angular/core";
import {async, ComponentFixture, TestBed} from "@angular/core/testing";
import {HomeRssWrapperPresentational} from "./home-rss-wrapper.presentational";
describe("HomeRssWrapperPresentational", () => {
let component: HomeRssWrapperPresentational;
let fixture: ComponentFixture<HomeRssWrapperPresentational>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [HomeRssWrapperPresentational],
schemas: [NO_ERRORS_SCHEMA],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(HomeRssWrapperPresentational);
component = fixture.componentInstance;
component.rss = {
channel: {
item: [],
title: "title",
},
};
fixture.detectChanges();
});
it("should create", () => {
expect(() => fixture.detectChanges()).not.toThrow();
});
});
import {ChangeDetectionStrategy, Component, Input} from "@angular/core";
import {Rss, RssItem} from "@app/features/home/models/rss.model";
import {SharedAbstractPresentational} from "@app/shared/components/presentationals/shared-abstract/shared-abstract.presentational";
import {environment} from "../../../../../../environments/environment";
@Component({
selector: "dlcm-home-rss-wrapper-presentational",
templateUrl: "./home-rss-wrapper.presentational.html",
styleUrls: ["./home-rss-wrapper.presentational.scss"],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class HomeRssWrapperPresentational extends SharedAbstractPresentational {
private readonly _maxNumberOfNewsToDisplay: number = environment.rssMaxNumberOfNewsToDisplay;
@Input()
rss: Rss;
get rssItems(): RssItem[] {
if (this.rss.channel.item.length > this._maxNumberOfNewsToDisplay) {
return this.rss.channel.item.slice(0, this._maxNumberOfNewsToDisplay);
}
return this.rss.channel.item;
}
}
......@@ -11,11 +11,11 @@ describe("HomeSearchScopePresentational", () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [ MaterialModule ],
declarations: [ HomeSearchScopePresentational, MockTranslatePipe ],
schemas: [ NO_ERRORS_SCHEMA ]
imports: [MaterialModule],
declarations: [HomeSearchScopePresentational, MockTranslatePipe],
schemas: [NO_ERRORS_SCHEMA],
})
.compileComponents();
.compileComponents();
}));
beforeEach(() => {
......@@ -25,6 +25,6 @@ describe("HomeSearchScopePresentational", () => {
});
it("should create", () => {
expect(component).toBeTruthy();
expect(() => fixture.detectChanges()).not.toThrow();
});
});
import {async, ComponentFixture, TestBed} from "@angular/core/testing";
import {TwitterService} from "@app/features/home/services/twitter.service";
import {MockTwitterService} from "../../../../../../test-helpers/mock-twitter.service";
import {HomeTwitterWidgetPresentational} from "./home-twitter-widget.presentational";
describe("HomeTwitterWidgetPresentational", () => {
let component: HomeTwitterWidgetPresentational;
let fixture: ComponentFixture<HomeTwitterWidgetPresentational>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [HomeTwitterWidgetPresentational],
providers: [
{
provide: TwitterService,
useClass: MockTwitterService,
},
],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(HomeTwitterWidgetPresentational);
component = fixture.componentInstance;
fixture.detectChanges();
});
xit("should create", () => {
expect(() => fixture.detectChanges()).not.toThrow();
});
});
import {AfterViewInit, ChangeDetectionStrategy, Component, ElementRef, Inject, Input, Renderer2} from "@angular/core";
import {WINDOW} from "@app/app.module";
import {TwitterChromeEnum} from "@app/features/welcome/enums/twitter-chrome.enum";
import {TwitterSourceTypeEnum} from "@app/features/welcome/enums/twitter-source-type.enum";
import {TwitterMetadata} from "@app/features/welcome/models/twitter-metadata.model";
import {DataSource, Options} from "@app/features/welcome/models/twitter-widget.model";
import {TwitterService} from "@app/features/welcome/services/twitter.service";
import {TwitterChromeEnum} from "@app/features/home/enums/twitter-chrome.enum";
import {TwitterSourceTypeEnum} from "@app/features/home/enums/twitter-source-type.enum";
import {TwitterMetadata} from "@app/features/home/models/twitter-metadata.model";
import {DataSource, Options} from "@app/features/home/models/twitter-widget.model";
import {TwitterService} from "@app/features/home/services/twitter.service";
import {SharedAbstractPresentational} from "@app/shared/components/presentationals/shared-abstract/shared-abstract.presentational";
import {catchError, tap} from "rxjs/operators";
import {CoreAbstractComponent, LoggingService} from "solidify-frontend";
import {LoggingService} from "solidify-frontend";
@Component({
selector: "dlcm-welcome-twitter-widget-presentational",
templateUrl: "./welcome-twitter-widget.presentational.html",
styleUrls: ["./welcome-twitter-widget.presentational.scss"],
selector: "dlcm-home-twitter-widget-presentational",
templateUrl: "./home-twitter-widget.presentational.html",
styleUrls: ["./home-twitter-widget.presentational.scss"],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class WelcomeTwitterWidgetPresentational extends CoreAbstractComponent implements AfterViewInit {
export class HomeTwitterWidgetPresentational extends SharedAbstractPresentational implements AfterViewInit {
@Input()
sourceType: TwitterSourceTypeEnum | undefined;
......
<dlcm-home-twitter-widget-presentational [sourceType]="sourceType"
[screenName]="screenName"
[tweetLimit]="tweetLimit"
[chrome]="chrome">
</dlcm-home-twitter-widget-presentational>
import {NO_ERRORS_SCHEMA} from "@angular/core";
import {async, ComponentFixture, TestBed} from "@angular/core/testing";
import {WelcomeTwitterWidgetPresentational} from "./welcome-twitter-widget.presentational";
import {HomeTwitterWrapperPresentational} from "./home-tweeter-wrapper.presentational";
describe("WelcomeTweetDetailPresentational", () => {
let component: WelcomeTwitterWidgetPresentational;
let fixture: ComponentFixture<WelcomeTwitterWidgetPresentational>;
describe("HomeTwitterWrapperPresentational", () => {
let component: HomeTwitterWrapperPresentational;
let fixture: ComponentFixture<HomeTwitterWrapperPresentational>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [WelcomeTwitterWidgetPresentational],
declarations: [HomeTwitterWrapperPresentational],
schemas: [NO_ERRORS_SCHEMA],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(WelcomeTwitterWidgetPresentational);
fixture = TestBed.createComponent(HomeTwitterWrapperPresentational);
component = fixture.componentInstance;
fixture.detectChanges();
});
it("should create", () => {
expect(component).toBeTruthy();
expect(() => fixture.detectChanges()).not.toThrow();
});
});
import {ChangeDetectionStrategy, Component} from "@angular/core";
import {TwitterChromeEnum} from "@app/features/welcome/enums/twitter-chrome.enum";
import {TwitterSourceTypeEnum} from "@app/features/welcome/enums/twitter-source-type.enum";
import {TwitterChromeEnum} from "@app/features/home/enums/twitter-chrome.enum";
import {TwitterSourceTypeEnum} from "@app/features/home/enums/twitter-source-type.enum";
import {SharedAbstractPresentational} from "@app/shared/components/presentationals/shared-abstract/shared-abstract.presentational";
import {environment} from "../../../../../../environments/environment";
@Component({
selector: "dlcm-welcome-twitter-wrapper-presentational",
templateUrl: "./welcome-tweeter-wrapper.presentational.html",
styleUrls: ["./welcome-tweeter-wrapper.presentational.scss"],
selector: "dlcm-home-twitter-wrapper-presentational",
templateUrl: "./home-tweeter-wrapper.presentational.html",
styleUrls: ["./home-tweeter-wrapper.presentational.scss"],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class WelcomeTwitterWrapperPresentational extends SharedAbstractPresentational {
export class HomeTwitterWrapperPresentational extends SharedAbstractPresentational {
readonly sourceType: string = TwitterSourceTypeEnum.profile;
readonly screenName: string = environment.twitterAccount;
readonly tweetLimit: number = environment.twitterTweetToDisplay;
......
import {ChangeDetectionStrategy, Component, OnInit} from "@angular/core";
import {ActivatedRoute} from "@angular/router";
import {SearchScopeEnum} from "@app/features/home/enums/search-scope.enum";
import {AccessSearchDetail} from "@app/features/home/stores/home.action";
import {HomeAction} from "@app/features/home/stores/home.action";
import {HomeState} from "@app/features/home/stores/home.state";
import {OrganizationalUnits} from "@app/generated-api";
import {SharedAbstractPresentational} from "@app/shared/components/presentationals/shared-abstract/shared-abstract.presentational";
......@@ -55,6 +55,6 @@ export class HomeDetailRoutable extends SharedAbstractPresentational implements
}
private getById(id: string): void {
this.store.dispatch(new AccessSearchDetail(id));
this.store.dispatch(new HomeAction.SearchDetail(id));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment