Commit bb81b005 by Emil Holsti

eventList update

1 parent 1393c4a8
<!--The content below is only a placeholder and can be replaced.--> <!--The content below is only a placeholder and can be replaced.-->
<div style="text-align:center"> <div>
<h1> <moya-organization-list style="float:top, left;"></moya-organization-list>
<h1 style="text-align:center; margin-left:25%; display:inline-block">
Welcome to {{ title }}! Welcome to {{ title }}!
</h1> </h1>
<img width="300" alt="Angular Logo" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg=="> <a style="float:right; font-size:20px; margin-top: 20px" href="#">Moya Login</a>
</div> </div>
<moya-event-list></moya-event-list> <div style="width:50%; float:left">
\ No newline at end of file <h2 style="margin-left: 10px">Tulevat tapahtumat</h2>
<moya-event-list [organisation]="currentOrganisation" style="margin-top:5em;"></moya-event-list>
</div>
<div style="width:50%; float:right">
<h2>Ei omaa organisaatiota?</h2>
<button (click)="newOrg()">Luo uusi organisaatio</button>
</div>
\ No newline at end of file
...@@ -8,7 +8,7 @@ import { AppService } from './shared/app.service'; ...@@ -8,7 +8,7 @@ import { AppService } from './shared/app.service';
}) })
export class AppComponent { export class AppComponent {
title = 'Moay'; title = 'Moay';
public currentOrganisation = 'insomnia';
constructor(private appService: AppService) { constructor(private appService: AppService) {
console.log(this.appService.get()); console.log(this.appService.get());
} }
......
<mat-card *ngFor="let event of events" style="width:40%;margin:1em;"> <mat-card *ngFor="let event of events" style="margin:1em;max-width:75%">
<mat-card-title>{{event.title}}</mat-card-title> <mat-card-title>{{event.title}}</mat-card-title>
<mat-card-subtitle>{{event.date}}</mat-card-subtitle> <mat-card-subtitle>{{event.date}}</mat-card-subtitle>
<mat-card-actions> <!--<mat-card-actions>
<button mat-raised-button color="primary" (click)="onClick()" style="float:right;margin-top:-5em;margin-right:1em;">Edit</button> <button mat-raised-button color="primary" (click)="onClick()" style="float:right;margin-top: ;margin-right:1em;">Edit</button>
</mat-card-actions> </mat-card-actions>-->
</mat-card> </mat-card>
\ No newline at end of file
import { Component, OnInit } from '@angular/core'; import { Component, OnInit, Input } from '@angular/core';
import { EventsService } from './event-service.service';
@Component({ @Component({
selector: 'moya-event-list', selector: 'moya-event-list',
...@@ -6,15 +7,12 @@ import { Component, OnInit } from '@angular/core'; ...@@ -6,15 +7,12 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./event-list.component.scss'] styleUrls: ['./event-list.component.scss']
}) })
export class EventListComponent implements OnInit { export class EventListComponent implements OnInit {
@Input() organisation: string;
public events: any;
public events = [ constructor(private appService: EventsService) {
{title: 'Assembly Winter 18', date: '1.2.2018 - 3.2.2018'}, this.events = (this.appService.get(this.organisation));
{title: 'Assembly Summer 18', date: '1.2.2018 - 3.2.2018'}, }
{title: 'Assembly Winter 19', date: '1.2.2018 - 3.2.2018'},
{title: 'Assembly Summer 19', date: '1.2.2018 - 3.2.2018'}
];
constructor() { }
onClick() { onClick() {
console.log('Nappitoimii'); console.log('Nappitoimii');
......
import { TestBed, inject } from '@angular/core/testing';
import { EventsService } from './event-service.service';
describe('EventsService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [EventsService]
});
});
it('should be created', inject([EventsService], (service: EventsService) => {
expect(service).toBeTruthy();
}));
});
import { Injectable } from '@angular/core';
@Injectable()
export class EventsService {
get(org: String) {
if (org.localeCompare('asm') === 0) {
return [
{title: 'Assembly Winter 18', date: '1.2.2018 - 3.2.2018'},
{title: 'Assembly Summer 18', date: '1.2.2018 - 3.2.2018'},
{title: 'Assembly Winter 19', date: '1.2.2018 - 3.2.2018'},
{title: 'Assembly Summer 19', date: '1.2.2018 - 3.2.2018'}
];
}
return [
{title: 'No future events to show at the moment', date: ' '}
];
}
}
...@@ -7,6 +7,7 @@ import {MatSelectModule} from '@angular/material/select'; ...@@ -7,6 +7,7 @@ import {MatSelectModule} from '@angular/material/select';
import {OrganizationListService} from './organization-list/organization-list.service'; import {OrganizationListService} from './organization-list/organization-list.service';
import {MatCardModule} from '@angular/material/card'; import {MatCardModule} from '@angular/material/card';
import {MatButtonModule} from '@angular/material'; import {MatButtonModule} from '@angular/material';
import { EventsService } from './event-list/event-service.service';
@NgModule({ @NgModule({
imports: [ imports: [
...@@ -15,7 +16,7 @@ import {MatButtonModule} from '@angular/material'; ...@@ -15,7 +16,7 @@ import {MatButtonModule} from '@angular/material';
MatCardModule, MatCardModule,
MatButtonModule MatButtonModule
], ],
providers: [OrganizationListService], providers: [OrganizationListService, EventsService],
declarations: [NewOrganizationComponent, OrganizationListComponent, EventListComponent], declarations: [NewOrganizationComponent, OrganizationListComponent, EventListComponent],
exports: [NewOrganizationComponent, OrganizationListComponent, EventListComponent], exports: [NewOrganizationComponent, OrganizationListComponent, EventListComponent],
}) })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!