You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
1.9 KiB

import { Component, OnInit } from '@angular/core'
5 years ago
import { Router, NavigationEnd } from '@angular/router'
import { ApisService } from '../services/apis.service'
import { environment } from '../../environments/environment'
@Component({
selector: 'app-portfolio',
templateUrl: './portfolio.component.html',
styleUrls: ['./portfolio.component.scss']
})
export class PortfolioComponent implements OnInit {
public basePath = `${environment.BASE_PATH}`
public portfolioItems: any = []
public section: string = ''
5 years ago
constructor(
private apisService: ApisService,
private router: Router)
{ }
ngOnInit(): void {
this.section = this.router.url.split('/')[1]
this.apisService.getPortfolio(this.section).toPromise().then((response) => {
this.portfolioItems = response.items
5 years ago
let cnt = 0
let width = 0
let tot = 0
this.portfolioItems.forEach((e) => {
e.loading = true
5 years ago
switch (cnt) {
case 0:
width = Math.floor(Math.random()*3)+3
tot = width
cnt++
break;
case 1:
width = Math.floor(Math.random()*3)+3
cnt++
if(tot + width > 9) {
width = 12 - tot
tot = 0
cnt = 0
} else {
tot = tot + width
}
break;
case 2:
width = 12 - tot
tot = 0
cnt = 0
break;
}
e.width = width
})
},(error) => {
console.error('getPortfolio ERROR', error)
}).catch((e) => {
console.error('getPortfolio CATCH', e)
})
}
5 years ago
showDetails(id): void {
const section = this.section == 'exhibitions' ? 'exhibitions' : 'works'
this.router.navigate([`/detail/${section}/${id}`])
5 years ago
}
onLoad(id): void {
this.portfolioItems.filter(item => item.id == id)[0].loading = false
}
}