From a0c76e155d4b54573cc25af5a65a3c78a10fefb2 Mon Sep 17 00:00:00 2001 From: Danijel Andjelkovic Date: Mon, 28 Feb 2022 19:46:47 +0100 Subject: Dodao frontend ponovo posto ga je git prepoznao kao pod-repozitorijum i nije pushovao fajlove. --- .../frontend/src/app/app-routing.module.ts | 15 +++++++++ .../frontend/src/app/app.component.css | 0 .../frontend/src/app/app.component.html | 1 + .../frontend/src/app/app.component.spec.ts | 35 +++++++++++++++++++++ .../frontend/src/app/app.component.ts | 10 ++++++ .../frontend/src/app/app.module.ts | 26 ++++++++++++++++ .../frontend/src/app/example.service.spec.ts | 16 ++++++++++ .../frontend/src/app/example.service.ts | 9 ++++++ .../src/app/page-one/page-one.component.css | 0 .../src/app/page-one/page-one.component.html | 26 ++++++++++++++++ .../src/app/page-one/page-one.component.spec.ts | 25 +++++++++++++++ .../src/app/page-one/page-one.component.ts | 36 ++++++++++++++++++++++ .../src/app/page-two/page-two.component.css | 0 .../src/app/page-two/page-two.component.html | 7 +++++ .../src/app/page-two/page-two.component.spec.ts | 25 +++++++++++++++ .../src/app/page-two/page-two.component.ts | 25 +++++++++++++++ .../frontend/src/app/values.service.spec.ts | 16 ++++++++++ .../frontend/src/app/values.service.ts | 22 +++++++++++++ 18 files changed, 294 insertions(+) create mode 100644 sandbox/test-projekat-danijel/frontend/src/app/app-routing.module.ts create mode 100644 sandbox/test-projekat-danijel/frontend/src/app/app.component.css create mode 100644 sandbox/test-projekat-danijel/frontend/src/app/app.component.html create mode 100644 sandbox/test-projekat-danijel/frontend/src/app/app.component.spec.ts create mode 100644 sandbox/test-projekat-danijel/frontend/src/app/app.component.ts create mode 100644 sandbox/test-projekat-danijel/frontend/src/app/app.module.ts create mode 100644 sandbox/test-projekat-danijel/frontend/src/app/example.service.spec.ts create mode 100644 sandbox/test-projekat-danijel/frontend/src/app/example.service.ts create mode 100644 sandbox/test-projekat-danijel/frontend/src/app/page-one/page-one.component.css create mode 100644 sandbox/test-projekat-danijel/frontend/src/app/page-one/page-one.component.html create mode 100644 sandbox/test-projekat-danijel/frontend/src/app/page-one/page-one.component.spec.ts create mode 100644 sandbox/test-projekat-danijel/frontend/src/app/page-one/page-one.component.ts create mode 100644 sandbox/test-projekat-danijel/frontend/src/app/page-two/page-two.component.css create mode 100644 sandbox/test-projekat-danijel/frontend/src/app/page-two/page-two.component.html create mode 100644 sandbox/test-projekat-danijel/frontend/src/app/page-two/page-two.component.spec.ts create mode 100644 sandbox/test-projekat-danijel/frontend/src/app/page-two/page-two.component.ts create mode 100644 sandbox/test-projekat-danijel/frontend/src/app/values.service.spec.ts create mode 100644 sandbox/test-projekat-danijel/frontend/src/app/values.service.ts (limited to 'sandbox/test-projekat-danijel/frontend/src/app') diff --git a/sandbox/test-projekat-danijel/frontend/src/app/app-routing.module.ts b/sandbox/test-projekat-danijel/frontend/src/app/app-routing.module.ts new file mode 100644 index 00000000..0c8301af --- /dev/null +++ b/sandbox/test-projekat-danijel/frontend/src/app/app-routing.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; +import { PageOneComponent } from './page-one/page-one.component'; +import { PageTwoComponent } from './page-two/page-two.component'; + +const routes: Routes = [ + { path: '', component: PageOneComponent }, + { path: 'boje', component: PageTwoComponent } +]; + +@NgModule({ + imports: [RouterModule.forRoot(routes)], + exports: [RouterModule] +}) +export class AppRoutingModule { } diff --git a/sandbox/test-projekat-danijel/frontend/src/app/app.component.css b/sandbox/test-projekat-danijel/frontend/src/app/app.component.css new file mode 100644 index 00000000..e69de29b diff --git a/sandbox/test-projekat-danijel/frontend/src/app/app.component.html b/sandbox/test-projekat-danijel/frontend/src/app/app.component.html new file mode 100644 index 00000000..90c6b646 --- /dev/null +++ b/sandbox/test-projekat-danijel/frontend/src/app/app.component.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/sandbox/test-projekat-danijel/frontend/src/app/app.component.spec.ts b/sandbox/test-projekat-danijel/frontend/src/app/app.component.spec.ts new file mode 100644 index 00000000..74b5b3eb --- /dev/null +++ b/sandbox/test-projekat-danijel/frontend/src/app/app.component.spec.ts @@ -0,0 +1,35 @@ +import { TestBed } from '@angular/core/testing'; +import { RouterTestingModule } from '@angular/router/testing'; +import { AppComponent } from './app.component'; + +describe('AppComponent', () => { + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [ + RouterTestingModule + ], + declarations: [ + AppComponent + ], + }).compileComponents(); + }); + + it('should create the app', () => { + const fixture = TestBed.createComponent(AppComponent); + const app = fixture.componentInstance; + expect(app).toBeTruthy(); + }); + + it(`should have as title 'frontend'`, () => { + const fixture = TestBed.createComponent(AppComponent); + const app = fixture.componentInstance; + expect(app.title).toEqual('frontend'); + }); + + it('should render title', () => { + const fixture = TestBed.createComponent(AppComponent); + fixture.detectChanges(); + const compiled = fixture.nativeElement as HTMLElement; + expect(compiled.querySelector('.content span')?.textContent).toContain('frontend app is running!'); + }); +}); diff --git a/sandbox/test-projekat-danijel/frontend/src/app/app.component.ts b/sandbox/test-projekat-danijel/frontend/src/app/app.component.ts new file mode 100644 index 00000000..9d6b2f11 --- /dev/null +++ b/sandbox/test-projekat-danijel/frontend/src/app/app.component.ts @@ -0,0 +1,10 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-root', + templateUrl: './app.component.html', + styleUrls: ['./app.component.css'] +}) +export class AppComponent { + title = 'frontend'; +} diff --git a/sandbox/test-projekat-danijel/frontend/src/app/app.module.ts b/sandbox/test-projekat-danijel/frontend/src/app/app.module.ts new file mode 100644 index 00000000..7206649d --- /dev/null +++ b/sandbox/test-projekat-danijel/frontend/src/app/app.module.ts @@ -0,0 +1,26 @@ +import { NgModule } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { HttpClientModule } from '@angular/common/http'; +import { FormsModule } from '@angular/forms'; + +import { AppRoutingModule } from './app-routing.module'; +import { AppComponent } from './app.component'; +import { PageOneComponent } from './page-one/page-one.component'; +import { PageTwoComponent } from './page-two/page-two.component'; + +@NgModule({ + declarations: [ + AppComponent, + PageOneComponent, + PageTwoComponent + ], + imports: [ + BrowserModule, + AppRoutingModule, + FormsModule, + HttpClientModule + ], + providers: [], + bootstrap: [AppComponent] +}) +export class AppModule { } diff --git a/sandbox/test-projekat-danijel/frontend/src/app/example.service.spec.ts b/sandbox/test-projekat-danijel/frontend/src/app/example.service.spec.ts new file mode 100644 index 00000000..9bf14ef0 --- /dev/null +++ b/sandbox/test-projekat-danijel/frontend/src/app/example.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { ExampleService } from './example.service'; + +describe('ExampleService', () => { + let service: ExampleService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(ExampleService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/sandbox/test-projekat-danijel/frontend/src/app/example.service.ts b/sandbox/test-projekat-danijel/frontend/src/app/example.service.ts new file mode 100644 index 00000000..abb4726c --- /dev/null +++ b/sandbox/test-projekat-danijel/frontend/src/app/example.service.ts @@ -0,0 +1,9 @@ +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class ExampleService { + + constructor() { } +} diff --git a/sandbox/test-projekat-danijel/frontend/src/app/page-one/page-one.component.css b/sandbox/test-projekat-danijel/frontend/src/app/page-one/page-one.component.css new file mode 100644 index 00000000..e69de29b diff --git a/sandbox/test-projekat-danijel/frontend/src/app/page-one/page-one.component.html b/sandbox/test-projekat-danijel/frontend/src/app/page-one/page-one.component.html new file mode 100644 index 00000000..5c8527f9 --- /dev/null +++ b/sandbox/test-projekat-danijel/frontend/src/app/page-one/page-one.component.html @@ -0,0 +1,26 @@ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +

+
+ +
+ \ No newline at end of file diff --git a/sandbox/test-projekat-danijel/frontend/src/app/page-one/page-one.component.spec.ts b/sandbox/test-projekat-danijel/frontend/src/app/page-one/page-one.component.spec.ts new file mode 100644 index 00000000..9270aeda --- /dev/null +++ b/sandbox/test-projekat-danijel/frontend/src/app/page-one/page-one.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { PageOneComponent } from './page-one.component'; + +describe('PageOneComponent', () => { + let component: PageOneComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ PageOneComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(PageOneComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/sandbox/test-projekat-danijel/frontend/src/app/page-one/page-one.component.ts b/sandbox/test-projekat-danijel/frontend/src/app/page-one/page-one.component.ts new file mode 100644 index 00000000..93964644 --- /dev/null +++ b/sandbox/test-projekat-danijel/frontend/src/app/page-one/page-one.component.ts @@ -0,0 +1,36 @@ +import { Component, OnInit } from '@angular/core'; +import { ValuesService } from '../values.service'; +import { NgModel } from '@angular/forms'; +import { Router } from '@angular/router'; + +@Component({ + selector: 'app-page-one', + templateUrl: './page-one.component.html', + styleUrls: ['./page-one.component.css'] +}) +export class PageOneComponent implements OnInit { + + red: number = 255; + green: number = 255; + blue: number = 255; + + color = '#ffffff'; + + constructor(private values: ValuesService, private router: Router) { } + + ngOnInit(): void { + } + + submit() { + console.log(this.red + ':' + this.green + ':' + this.blue); + this.values.addColor(this.red, this.green, this.blue).subscribe((color) => { + console.log(color); + this.color = color; + }) + } + + goToColors() { + this.router.navigate(['boje']) + } + +} diff --git a/sandbox/test-projekat-danijel/frontend/src/app/page-two/page-two.component.css b/sandbox/test-projekat-danijel/frontend/src/app/page-two/page-two.component.css new file mode 100644 index 00000000..e69de29b diff --git a/sandbox/test-projekat-danijel/frontend/src/app/page-two/page-two.component.html b/sandbox/test-projekat-danijel/frontend/src/app/page-two/page-two.component.html new file mode 100644 index 00000000..24719f71 --- /dev/null +++ b/sandbox/test-projekat-danijel/frontend/src/app/page-two/page-two.component.html @@ -0,0 +1,7 @@ +

+ +
+
+ +
+
\ No newline at end of file diff --git a/sandbox/test-projekat-danijel/frontend/src/app/page-two/page-two.component.spec.ts b/sandbox/test-projekat-danijel/frontend/src/app/page-two/page-two.component.spec.ts new file mode 100644 index 00000000..e5086adb --- /dev/null +++ b/sandbox/test-projekat-danijel/frontend/src/app/page-two/page-two.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { PageTwoComponent } from './page-two.component'; + +describe('PageTwoComponent', () => { + let component: PageTwoComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ PageTwoComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(PageTwoComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/sandbox/test-projekat-danijel/frontend/src/app/page-two/page-two.component.ts b/sandbox/test-projekat-danijel/frontend/src/app/page-two/page-two.component.ts new file mode 100644 index 00000000..f30bf9e2 --- /dev/null +++ b/sandbox/test-projekat-danijel/frontend/src/app/page-two/page-two.component.ts @@ -0,0 +1,25 @@ +import { Component, OnInit } from '@angular/core'; +import { Router } from '@angular/router'; +import { ValuesService } from '../values.service'; + +@Component({ + selector: 'app-page-two', + templateUrl: './page-two.component.html', + styleUrls: ['./page-two.component.css'] +}) +export class PageTwoComponent implements OnInit { + + colors?: string[]; + + constructor(private values: ValuesService, private router: Router) { } + + ngOnInit(): void { + this.values.getColors().subscribe((colors) => { + this.colors = colors; + }) + } + + goToAddColor() { + this.router.navigate(['']); + } +} diff --git a/sandbox/test-projekat-danijel/frontend/src/app/values.service.spec.ts b/sandbox/test-projekat-danijel/frontend/src/app/values.service.spec.ts new file mode 100644 index 00000000..51457f40 --- /dev/null +++ b/sandbox/test-projekat-danijel/frontend/src/app/values.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { ValuesService } from './values.service'; + +describe('ValuesServiceService', () => { + let service: ValuesService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(ValuesService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/sandbox/test-projekat-danijel/frontend/src/app/values.service.ts b/sandbox/test-projekat-danijel/frontend/src/app/values.service.ts new file mode 100644 index 00000000..a76555ee --- /dev/null +++ b/sandbox/test-projekat-danijel/frontend/src/app/values.service.ts @@ -0,0 +1,22 @@ +import { HttpClient, HttpHeaders } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs'; + +@Injectable({ + providedIn: 'root' +}) +export class ValuesService { + + constructor(private http: HttpClient) { } + + getColors() { + return this.http.get(`http://localhost:5000/api/values/`); + } + + addColor(red: number, green: number, blue: number) { + let header: HttpHeaders = new HttpHeaders({ + 'Content-type': 'application/json', + }); + return this.http.post(`http://localhost:5000/api/values/`, { red, green, blue }, { headers: header, responseType: 'text' }); + } +} -- cgit v1.2.3