From 19211e0254a30255593357e46124de32c2cc969d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20G=C3=B3reczny?= Date: Wed, 2 Dec 2020 10:39:08 +0100 Subject: [PATCH] Added routing and removed unnecessary pages --- .../ClientApp/src/app.routing.ts | 12 +++++++ .../ClientApp/src/app/app.module.ts | 17 +++------- .../nav-menu/nav-menu.component.css | 0 .../nav-menu/nav-menu.component.html | 0 .../nav-menu/nav-menu.component.ts | 0 .../src/app/counter/counter.component.html | 7 ---- .../src/app/counter/counter.component.spec.ts | 34 ------------------- .../src/app/counter/counter.component.ts | 13 ------- .../app/fetch-data/fetch-data.component.html | 24 ------------- .../app/fetch-data/fetch-data.component.ts | 23 ------------- .../app/{ => pages}/home/home.component.html | 0 .../app/{ => pages}/home/home.component.ts | 0 12 files changed, 17 insertions(+), 113 deletions(-) create mode 100644 SessionCompanion/SessionCompanion/ClientApp/src/app.routing.ts rename SessionCompanion/SessionCompanion/ClientApp/src/app/{ => components}/nav-menu/nav-menu.component.css (100%) rename SessionCompanion/SessionCompanion/ClientApp/src/app/{ => components}/nav-menu/nav-menu.component.html (100%) rename SessionCompanion/SessionCompanion/ClientApp/src/app/{ => components}/nav-menu/nav-menu.component.ts (100%) delete mode 100644 SessionCompanion/SessionCompanion/ClientApp/src/app/counter/counter.component.html delete mode 100644 SessionCompanion/SessionCompanion/ClientApp/src/app/counter/counter.component.spec.ts delete mode 100644 SessionCompanion/SessionCompanion/ClientApp/src/app/counter/counter.component.ts delete mode 100644 SessionCompanion/SessionCompanion/ClientApp/src/app/fetch-data/fetch-data.component.html delete mode 100644 SessionCompanion/SessionCompanion/ClientApp/src/app/fetch-data/fetch-data.component.ts rename SessionCompanion/SessionCompanion/ClientApp/src/app/{ => pages}/home/home.component.html (100%) rename SessionCompanion/SessionCompanion/ClientApp/src/app/{ => pages}/home/home.component.ts (100%) diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app.routing.ts b/SessionCompanion/SessionCompanion/ClientApp/src/app.routing.ts new file mode 100644 index 0000000..0d8d551 --- /dev/null +++ b/SessionCompanion/SessionCompanion/ClientApp/src/app.routing.ts @@ -0,0 +1,12 @@ +import {RouterModule, Routes} from '@angular/router'; +import {HomeComponent} from './app/pages/home/home.component'; + +const routes: Routes = [ + { + path: '', + component: HomeComponent, + pathMatch: 'full' + }, +]; + +export const appRoutingModule = RouterModule.forRoot(routes); diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/app.module.ts b/SessionCompanion/SessionCompanion/ClientApp/src/app/app.module.ts index cecdded..804d468 100644 --- a/SessionCompanion/SessionCompanion/ClientApp/src/app/app.module.ts +++ b/SessionCompanion/SessionCompanion/ClientApp/src/app/app.module.ts @@ -5,28 +5,21 @@ import { HttpClientModule } from '@angular/common/http'; import { RouterModule } from '@angular/router'; import { AppComponent } from './app.component'; -import { NavMenuComponent } from './nav-menu/nav-menu.component'; -import { HomeComponent } from './home/home.component'; -import { CounterComponent } from './counter/counter.component'; -import { FetchDataComponent } from './fetch-data/fetch-data.component'; +import { NavMenuComponent } from './components/nav-menu/nav-menu.component'; +import { HomeComponent } from './pages/home/home.component'; +import {appRoutingModule} from '../app.routing'; @NgModule({ declarations: [ AppComponent, NavMenuComponent, - HomeComponent, - CounterComponent, - FetchDataComponent + HomeComponent ], imports: [ BrowserModule.withServerTransition({ appId: 'ng-cli-universal' }), HttpClientModule, FormsModule, - RouterModule.forRoot([ - { path: '', component: HomeComponent, pathMatch: 'full' }, - { path: 'counter', component: CounterComponent }, - { path: 'fetch-data', component: FetchDataComponent }, - ]) + appRoutingModule ], providers: [], bootstrap: [AppComponent] diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/nav-menu/nav-menu.component.css b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/nav-menu/nav-menu.component.css similarity index 100% rename from SessionCompanion/SessionCompanion/ClientApp/src/app/nav-menu/nav-menu.component.css rename to SessionCompanion/SessionCompanion/ClientApp/src/app/components/nav-menu/nav-menu.component.css diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/nav-menu/nav-menu.component.html b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/nav-menu/nav-menu.component.html similarity index 100% rename from SessionCompanion/SessionCompanion/ClientApp/src/app/nav-menu/nav-menu.component.html rename to SessionCompanion/SessionCompanion/ClientApp/src/app/components/nav-menu/nav-menu.component.html diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/nav-menu/nav-menu.component.ts b/SessionCompanion/SessionCompanion/ClientApp/src/app/components/nav-menu/nav-menu.component.ts similarity index 100% rename from SessionCompanion/SessionCompanion/ClientApp/src/app/nav-menu/nav-menu.component.ts rename to SessionCompanion/SessionCompanion/ClientApp/src/app/components/nav-menu/nav-menu.component.ts diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/counter/counter.component.html b/SessionCompanion/SessionCompanion/ClientApp/src/app/counter/counter.component.html deleted file mode 100644 index 89b9c80..0000000 --- a/SessionCompanion/SessionCompanion/ClientApp/src/app/counter/counter.component.html +++ /dev/null @@ -1,7 +0,0 @@ -

Counter

- -

This is a simple example of an Angular component.

- -

Current count: {{ currentCount }}

- - diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/counter/counter.component.spec.ts b/SessionCompanion/SessionCompanion/ClientApp/src/app/counter/counter.component.spec.ts deleted file mode 100644 index 37b350c..0000000 --- a/SessionCompanion/SessionCompanion/ClientApp/src/app/counter/counter.component.spec.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { CounterComponent } from './counter.component'; - -describe('CounterComponent', () => { - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ CounterComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(CounterComponent); - fixture.detectChanges(); - }); - - it('should display a title', async(() => { - const titleText = fixture.nativeElement.querySelector('h1').textContent; - expect(titleText).toEqual('Counter'); - })); - - it('should start with count 0, then increments by 1 when clicked', async(() => { - const countElement = fixture.nativeElement.querySelector('strong'); - expect(countElement.textContent).toEqual('0'); - - const incrementButton = fixture.nativeElement.querySelector('button'); - incrementButton.click(); - fixture.detectChanges(); - expect(countElement.textContent).toEqual('1'); - })); -}); diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/counter/counter.component.ts b/SessionCompanion/SessionCompanion/ClientApp/src/app/counter/counter.component.ts deleted file mode 100644 index 1f336aa..0000000 --- a/SessionCompanion/SessionCompanion/ClientApp/src/app/counter/counter.component.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { Component } from '@angular/core'; - -@Component({ - selector: 'app-counter-component', - templateUrl: './counter.component.html' -}) -export class CounterComponent { - public currentCount = 0; - - public incrementCounter() { - this.currentCount++; - } -} diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/fetch-data/fetch-data.component.html b/SessionCompanion/SessionCompanion/ClientApp/src/app/fetch-data/fetch-data.component.html deleted file mode 100644 index 19b3835..0000000 --- a/SessionCompanion/SessionCompanion/ClientApp/src/app/fetch-data/fetch-data.component.html +++ /dev/null @@ -1,24 +0,0 @@ -

Weather forecast

- -

This component demonstrates fetching data from the server.

- -

Loading...

- - - - - - - - - - - - - - - - - - -
DateTemp. (C)Temp. (F)Summary
{{ forecast.date }}{{ forecast.temperatureC }}{{ forecast.temperatureF }}{{ forecast.summary }}
diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/fetch-data/fetch-data.component.ts b/SessionCompanion/SessionCompanion/ClientApp/src/app/fetch-data/fetch-data.component.ts deleted file mode 100644 index 9b81e1b..0000000 --- a/SessionCompanion/SessionCompanion/ClientApp/src/app/fetch-data/fetch-data.component.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Component, Inject } from '@angular/core'; -import { HttpClient } from '@angular/common/http'; - -@Component({ - selector: 'app-fetch-data', - templateUrl: './fetch-data.component.html' -}) -export class FetchDataComponent { - public forecasts: WeatherForecast[]; - - constructor(http: HttpClient, @Inject('BASE_URL') baseUrl: string) { - http.get(baseUrl + 'weatherforecast').subscribe(result => { - this.forecasts = result; - }, error => console.error(error)); - } -} - -interface WeatherForecast { - date: string; - temperatureC: number; - temperatureF: number; - summary: string; -} diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/home/home.component.html b/SessionCompanion/SessionCompanion/ClientApp/src/app/pages/home/home.component.html similarity index 100% rename from SessionCompanion/SessionCompanion/ClientApp/src/app/home/home.component.html rename to SessionCompanion/SessionCompanion/ClientApp/src/app/pages/home/home.component.html diff --git a/SessionCompanion/SessionCompanion/ClientApp/src/app/home/home.component.ts b/SessionCompanion/SessionCompanion/ClientApp/src/app/pages/home/home.component.ts similarity index 100% rename from SessionCompanion/SessionCompanion/ClientApp/src/app/home/home.component.ts rename to SessionCompanion/SessionCompanion/ClientApp/src/app/pages/home/home.component.ts