Skip to content

Commit

Permalink
Import json instead of fetch, update new links
Browse files Browse the repository at this point in the history
  • Loading branch information
cagataycivici committed Jan 30, 2023
1 parent 036d2c4 commit 95f68c4
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 69 deletions.
3 changes: 1 addition & 2 deletions src/app/showcase/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { FormsModule } from '@angular/forms';
import { AutoCompleteModule } from '../components/autocomplete/autocomplete';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { AppConfigComponent } from './app.config.component';
import { JsonService } from './service/jsonservice';
import { AppConfigService } from './service/appconfigservice';
import { HttpClientModule } from '@angular/common/http';
import { AppTopBarComponent } from './app.topbar.component';
Expand All @@ -18,7 +17,7 @@ describe('AppComponent', () => {
TestBed.configureTestingModule({
imports: [RouterTestingModule, FormsModule, BrowserAnimationsModule, AutoCompleteModule, HttpClientModule],
declarations: [AppComponent, AppConfigComponent, AppTopBarComponent, AppMenuComponent, AppFooterComponent, AppInputStyleSwitchComponent],
providers: [JsonService, AppConfigService]
providers: [AppConfigService]
}).compileComponents();
}));

Expand Down
33 changes: 13 additions & 20 deletions src/app/showcase/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Subscription } from 'rxjs';
import { environment } from 'src/environments/environment';
import { AppConfig } from './domain/appconfig';
import { AppConfigService } from './service/appconfigservice';
import { JsonService } from './service/jsonservice';
import Announcement from './data/news.json';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit, OnDestroy {
constructor(private configService: AppConfigService, private JsonService: JsonService) {}
constructor(private configService: AppConfigService) {}

config: AppConfig;

public subscription: Subscription;

public announcement: any;
public announcement: any = Announcement;

public newsActive: boolean = false;
public newsActive: boolean;

storageKey = 'primeng';

Expand All @@ -32,21 +31,15 @@ export class AppComponent implements OnInit, OnDestroy {
this.config = config;
});

/*if (environment.production) {
this.JsonService.getAnnouncement().then((data) => {
this.announcement = data;
const itemString = localStorage.getItem(this.storageKey);
if (itemString) {
const item = JSON.parse(itemString);
if (item.hiddenNews && item.hiddenNews !== data.id) {
this.newsActive = true;
}
} else {
this.newsActive = true;
}
});
}*/
const itemString = localStorage.getItem(this.storageKey);
if (itemString) {
const item = JSON.parse(itemString);
if (item.hiddenNews && item.hiddenNews !== Announcement.id) {
this.newsActive = true;
}
} else {
this.newsActive = true;
}
}

onNewsClose() {
Expand Down
6 changes: 3 additions & 3 deletions src/app/showcase/app.menu.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ declare let gtag: Function;
<div class="menu-items">
<a [routerLink]="['/theming']" routerLinkActive="router-link-exact-active">Guide</a>
<a href="https://www.primefaces.org/designer/primeng">Theme Designer</a>
<a href="https://www.primefaces.org/designer-ng">Visual Editor</a>
<a href="https://designer.primeng.org">Visual Editor</a>
<a [routerLink]="['/colors']" routerLinkActive="router-link-exact-active">Colors</a>
<a href="https://www.primefaces.org/designer/api/primeng/14.0.0">SASS API</a>
</div>
Expand All @@ -81,8 +81,8 @@ declare let gtag: Function;
<div class="menu-category">PrimeBlocks</div>
<div class="menu-items">
<a href="https://www.primefaces.org/primeblocks-ng/#/free" target="_blank">Free Blocks</a>
<a href="https://www.primefaces.org/primeblocks-ng/#/" target="_blank">All Blocks</a>
<a href="https://blocks.primeng.org/#/free" target="_blank">Free Blocks</a>
<a href="https://blocks.primeng.org" target="_blank">All Blocks</a>
</div>
<div class="menu-category">PrimeFlex</div>
Expand Down
3 changes: 1 addition & 2 deletions src/app/showcase/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import { NodeService } from './service/nodeservice';
import { AppConfigService } from './service/appconfigservice';
import { CustomerService } from './service/customerservice';
import { IconService } from './service/iconservice';
import { JsonService } from './service/jsonservice';
import { PhotoService } from './service/photoservice';
import { ProductService } from './service/productservice';

Expand Down Expand Up @@ -80,7 +79,7 @@ import { LandingComponent } from './components/landing/landing.component';
InputMaskModule,
DropdownModule
],
providers: [{ provide: LocationStrategy, useClass: PathLocationStrategy }, CarService, CountryService, EventService, NodeService, IconService, CustomerService, PhotoService, JsonService, AppConfigService, ProductService],
providers: [{ provide: LocationStrategy, useClass: PathLocationStrategy }, CarService, CountryService, EventService, NodeService, IconService, CustomerService, PhotoService, AppConfigService, ProductService],
bootstrap: [AppComponent]
})
export class AppModule {}
11 changes: 5 additions & 6 deletions src/app/showcase/app.topbar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Component, EventEmitter, Output, ViewChild, ElementRef, Input, OnInit,
import { trigger, style, transition, animate, AnimationEvent } from '@angular/animations';
import { Router, NavigationEnd } from '@angular/router';
import { AppConfigService } from './service/appconfigservice';
import { JsonService } from './service/jsonservice';
import { AppConfig } from './domain/appconfig';
import { Subscription } from 'rxjs';
import Versions from './data/versions.json';

@Component({
selector: 'app-topbar',
Expand All @@ -28,7 +28,7 @@ import { Subscription } from 'rxjs';
<a href="https://www.primefaces.org/designer/primeng"><i class="pi pi-fw pi-palette"></i><span>Designer</span></a>
</li>
<li>
<a href="https://www.primefaces.org/designer-ng"><i class="pi pi-fw pi-desktop"></i><span>Visual Editor</span></a>
<a href="https://designer.primeng.org"><i class="pi pi-fw pi-desktop"></i><span>Visual Editor</span></a>
</li>
<li>
<a [routerLink]="['/uikit']"><i class="pi pi-fw pi-pencil"></i><span>UI Kit</span></a>
Expand Down Expand Up @@ -365,7 +365,7 @@ import { Subscription } from 'rxjs';
</ul>
</li>
<li class="topbar-submenu">
<a tabindex="0" href="https://www.primefaces.org/primeblocks-ng/" target="_blank">Blocks</a>
<a tabindex="0" href="https://blocks.primeng.org" target="_blank">Blocks</a>
</li>
<li class="topbar-submenu">
<a tabindex="0" (click)="toggleMenu($event, 3)">{{ versions ? versions[0].version : 'Latest' }}</a>
Expand Down Expand Up @@ -452,16 +452,15 @@ export class AppTopBarComponent implements OnInit, OnDestroy {
'tailwind-light': 'tailwind-light.png'
};

versions: any[];
versions: any[] = Versions;

scrollListener: any;

constructor(private router: Router, private JsonService: JsonService, private configService: AppConfigService) {}
constructor(private router: Router, private configService: AppConfigService) {}

ngOnInit() {
this.config = this.configService.config;
this.subscription = this.configService.configUpdate$.subscribe((config) => (this.config = config));
this.JsonService.getVersions().then((data) => (this.versions = data));

this.router.events.subscribe((event) => {
if (event instanceof NavigationEnd) {
Expand Down
14 changes: 7 additions & 7 deletions src/app/showcase/components/landing/landing.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
</a>
</li>
<li class="mr-0 lg:mr-2">
<a href="https://www.primefaces.org/primeblocks-ng" target="_blank">
<a href="https://blocks.primeng.org" target="_blank">
<img src="assets/showcase/images/landing/blocks-icon.svg" alt="Primeng blocks">
<span>Blocks</span>
</a>
</li>
<li class="mr-0 lg:mr-2">
<a href="https://www.primefaces.org/designer-ng" target="_blank">
<a href="https://designer.primeng.org" target="_blank">
<img src="assets/showcase/images/landing/designer-icon.svg" alt="Primeng designer">
<span>Designer</span>
</a>
Expand Down Expand Up @@ -67,7 +67,7 @@
</div>
</div>
</a>
<a href="https://primefaces.org/designer-ng" target="_blank">
<a href="https://designer.primeng.org" target="_blank">
<div class="hero-box w-10rem h-10rem md:w-12rem md:h-12rem animation ml-4 md:ml-0 md:mt-4 flex align-items-center justify-content-center" >
<div class="flex flex-column align-items-center">
<img src="assets/showcase/images/landing/designer-icon.svg" alt="primeng templates" />
Expand Down Expand Up @@ -115,7 +115,7 @@
</a>
</div>
<div class="p-2 flex flex-row md:flex-column">
<a href="https://primefaces.org/primeblocks-ng" target="_blank">
<a href="https://blocks.primeng.org" target="_blank">
<div class="hero-box w-10rem h-10rem md:w-12rem md:h-12rem animation flex align-items-center justify-content-center">
<div class="flex flex-column align-items-center">
<img src="assets/showcase/images/landing/blocks-icon.svg" alt="primeng templates" />
Expand Down Expand Up @@ -331,7 +331,7 @@
<button type="button" class="font-medium linkbox mr-3 mt-4" [ngClass]="{'active': theme.startsWith('lara')}" (click)="changeTableTheme(config.dark ? 'lara-dark-blue' : 'lara-light-blue')">PrimeOne</button>
<button type="button" class="font-medium linkbox mr-3 mt-4" [ngClass]="{'active': theme.startsWith('md')}" (click)="changeTableTheme(config.dark ? 'md-dark-indigo' : 'md-light-indigo')">Material</button>
<button type="button" class="font-medium linkbox mr-3 mt-4" [ngClass]="{'active': theme.startsWith('bootstrap')}" (click)="changeTableTheme(config.dark ? 'bootstrap4-dark-blue' : 'bootstrap4-light-blue')">Bootstrap</button>
<a type="button" class="font-medium p-link linkbox mt-4" href="https://www.primefaces.org/designer-ng" target="_blank">more...</a>
<a type="button" class="font-medium p-link linkbox mt-4" href="https://designer.primeng.org" target="_blank">more...</a>
</div>
<div class="themes-main flex mt-7 justify-content-center pad-section" [style]="{'background-size': 'cover'}" [ngStyle]="{'background-image': config.dark ? 'url(assets/showcase/images/landing/wave-dark-alt.svg)' : 'url(assets/showcase/images/landing/wave-light-alt.svg)'}">
<div class="box overflow-hidden z-1 p-5 table-container">
Expand Down Expand Up @@ -452,7 +452,7 @@ <h5 class="m-0">Customers</h5>
<div class="section-header">PrimeBlocks</div>
<p class="section-detail">400+ ready to copy-paste UI blocks to build spectacular applications in no time.</p>
<div class="flex justify-content-center mt-4">
<a href="https://www.primefaces.org/primeblocks-ng" target="_blank" class="font-semibold p-3 border-round flex align-items-center linkbox active" style="z-index:99;">
<a href="https://blocks.primeng.org" target="_blank" class="font-semibold p-3 border-round flex align-items-center linkbox active" style="z-index:99;">
<span>Learn More</span>
<i class="pi pi-arrow-right ml-2"></i>
</a>
Expand Down Expand Up @@ -872,7 +872,7 @@ <h5 class="m-0">Customers</h5>
</div>
</div>

<a href="https://www.primefaces.org/designer-ng" target="_blank" class="font-semibold p-3 border-round flex align-items-center linkbox active">
<a href="https://designer.primeng.org" target="_blank" class="font-semibold p-3 border-round flex align-items-center linkbox active">
<span>View Full Version</span>
<i class="pi pi-arrow-right ml-auto"></i>
</a>
Expand Down
10 changes: 10 additions & 0 deletions src/app/showcase/data/news.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"id": 30,
"content": "🚀 PrimeBlocks v3.2.0 is out with more than 30 new UI blocks ",
"linkText": "Learn More",
"linkHref": "https://blocks.primeng.org",
"backgroundStyle": "background-color:#3B82F6",
"textStyle": "color:#ffffff;font-weight:500",
"linkStyle": "color:#ffffff;font-weight:700",
"linkHoverStyle": "text-decoration: underline"
}
38 changes: 38 additions & 0 deletions src/app/showcase/data/versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[
{
"version": "v15.2.0",
"url": "https://primeng.org"
},
{
"version": "v14.2.2",
"url": "https://www.primefaces.org/primeng-v14"
},
{
"version": "v13.4.1",
"url": "https://www.primefaces.org/primeng-v13"
},
{
"version": "v12.2.5-lts",
"url": "https://www.primefaces.org/primeng-v12-lts"
},
{
"version": "v11.4.10-lts",
"url": "https://www.primefaces.org/primeng-v11-lts"
},
{
"version": "v10.1.5-lts",
"url": "https://www.primefaces.org/primeng-v10-lts"
},
{
"version": "v9.2.8-lts",
"url": "https://www.primefaces.org/primeng-v9-lts"
},
{
"version": "v8.2.9-lts",
"url": "https://www.primefaces.org/primeng-v8-lts"
},
{
"version": "v7.2.6-lts",
"url": "https://www.primefaces.org/primeng-v7-lts"
}
]
26 changes: 0 additions & 26 deletions src/app/showcase/service/jsonservice.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/versions.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"versions": [
{
"version": "v15.2.0",
"url": "https://www.primefaces.org/primeng"
"version": "v15.2.",
"url": "https://primeng.org"
},
{
"version": "v14.2.2",
Expand Down
4 changes: 3 additions & 1 deletion tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": []
"types": [],
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true
},
"files": [
"src/main.ts",
Expand Down

0 comments on commit 95f68c4

Please sign in to comment.