aboutsummaryrefslogtreecommitdiff
path: root/sandbox/TestAppOgnjen/FrontEnd/src
diff options
context:
space:
mode:
authorOgnjen Cirkovic <ciraboxkg@gmail.com>2022-02-28 23:31:04 +0100
committerOgnjen Cirkovic <ciraboxkg@gmail.com>2022-02-28 23:31:04 +0100
commit2e683211fb1b2a451843444790cd2f6df5b0b6c6 (patch)
treee24ec56e584c973cd0e33be6148d3f789603806f /sandbox/TestAppOgnjen/FrontEnd/src
parent0829c5f64926c46e90cc0f443cd2b301c888d1f2 (diff)
Dodat test projekat.Povezan front i back.
Diffstat (limited to 'sandbox/TestAppOgnjen/FrontEnd/src')
-rw-r--r--sandbox/TestAppOgnjen/FrontEnd/src/app/app-routing.module.ts14
-rw-r--r--sandbox/TestAppOgnjen/FrontEnd/src/app/app.component.css0
-rw-r--r--sandbox/TestAppOgnjen/FrontEnd/src/app/app.component.html3
-rw-r--r--sandbox/TestAppOgnjen/FrontEnd/src/app/app.component.spec.ts35
-rw-r--r--sandbox/TestAppOgnjen/FrontEnd/src/app/app.component.ts10
-rw-r--r--sandbox/TestAppOgnjen/FrontEnd/src/app/app.module.ts28
-rw-r--r--sandbox/TestAppOgnjen/FrontEnd/src/app/lista/lista.component.css15
-rw-r--r--sandbox/TestAppOgnjen/FrontEnd/src/app/lista/lista.component.html23
-rw-r--r--sandbox/TestAppOgnjen/FrontEnd/src/app/lista/lista.component.spec.ts25
-rw-r--r--sandbox/TestAppOgnjen/FrontEnd/src/app/lista/lista.component.ts60
-rw-r--r--sandbox/TestAppOgnjen/FrontEnd/src/app/shared.service.spec.ts16
-rw-r--r--sandbox/TestAppOgnjen/FrontEnd/src/app/shared.service.ts25
-rw-r--r--sandbox/TestAppOgnjen/FrontEnd/src/assets/.gitkeep0
-rw-r--r--sandbox/TestAppOgnjen/FrontEnd/src/environments/environment.prod.ts3
-rw-r--r--sandbox/TestAppOgnjen/FrontEnd/src/environments/environment.ts16
-rw-r--r--sandbox/TestAppOgnjen/FrontEnd/src/favicon.icobin0 -> 948 bytes
-rw-r--r--sandbox/TestAppOgnjen/FrontEnd/src/index.html13
-rw-r--r--sandbox/TestAppOgnjen/FrontEnd/src/main.ts12
-rw-r--r--sandbox/TestAppOgnjen/FrontEnd/src/polyfills.ts53
-rw-r--r--sandbox/TestAppOgnjen/FrontEnd/src/styles.css1
-rw-r--r--sandbox/TestAppOgnjen/FrontEnd/src/test.ts26
21 files changed, 378 insertions, 0 deletions
diff --git a/sandbox/TestAppOgnjen/FrontEnd/src/app/app-routing.module.ts b/sandbox/TestAppOgnjen/FrontEnd/src/app/app-routing.module.ts
new file mode 100644
index 00000000..6aeec2fd
--- /dev/null
+++ b/sandbox/TestAppOgnjen/FrontEnd/src/app/app-routing.module.ts
@@ -0,0 +1,14 @@
+import { NgModule } from '@angular/core';
+import { RouterModule, Routes } from '@angular/router';
+
+import { ListaComponent } from './lista/lista.component';
+
+const routes: Routes = [
+ {path:'lista',component:ListaComponent}
+];
+
+@NgModule({
+ imports: [RouterModule.forRoot(routes)],
+ exports: [RouterModule]
+})
+export class AppRoutingModule { }
diff --git a/sandbox/TestAppOgnjen/FrontEnd/src/app/app.component.css b/sandbox/TestAppOgnjen/FrontEnd/src/app/app.component.css
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/sandbox/TestAppOgnjen/FrontEnd/src/app/app.component.css
diff --git a/sandbox/TestAppOgnjen/FrontEnd/src/app/app.component.html b/sandbox/TestAppOgnjen/FrontEnd/src/app/app.component.html
new file mode 100644
index 00000000..62466c4e
--- /dev/null
+++ b/sandbox/TestAppOgnjen/FrontEnd/src/app/app.component.html
@@ -0,0 +1,3 @@
+<!-- <button routerLink="lista">Lista</button> -->
+<app-lista></app-lista>
+<router-outlet></router-outlet>
diff --git a/sandbox/TestAppOgnjen/FrontEnd/src/app/app.component.spec.ts b/sandbox/TestAppOgnjen/FrontEnd/src/app/app.component.spec.ts
new file mode 100644
index 00000000..c7edcb57
--- /dev/null
+++ b/sandbox/TestAppOgnjen/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 'ToDoFront'`, () => {
+ const fixture = TestBed.createComponent(AppComponent);
+ const app = fixture.componentInstance;
+ expect(app.title).toEqual('ToDoFront');
+ });
+
+ it('should render title', () => {
+ const fixture = TestBed.createComponent(AppComponent);
+ fixture.detectChanges();
+ const compiled = fixture.nativeElement as HTMLElement;
+ expect(compiled.querySelector('.content span')?.textContent).toContain('ToDoFront app is running!');
+ });
+});
diff --git a/sandbox/TestAppOgnjen/FrontEnd/src/app/app.component.ts b/sandbox/TestAppOgnjen/FrontEnd/src/app/app.component.ts
new file mode 100644
index 00000000..42cc33bb
--- /dev/null
+++ b/sandbox/TestAppOgnjen/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 = 'ToDoFront';
+}
diff --git a/sandbox/TestAppOgnjen/FrontEnd/src/app/app.module.ts b/sandbox/TestAppOgnjen/FrontEnd/src/app/app.module.ts
new file mode 100644
index 00000000..80bf0308
--- /dev/null
+++ b/sandbox/TestAppOgnjen/FrontEnd/src/app/app.module.ts
@@ -0,0 +1,28 @@
+import { NgModule } from '@angular/core';
+import { BrowserModule } from '@angular/platform-browser';
+
+import { AppRoutingModule } from './app-routing.module';
+import { AppComponent } from './app.component';
+import { ListaComponent } from './lista/lista.component';
+import { SharedService } from './shared.service';
+
+
+import {HttpClientModule} from '@angular/common/http';
+import {FormsModule, ReactiveFormsModule} from '@angular/forms';
+
+@NgModule({
+ declarations: [
+ AppComponent,
+ ListaComponent
+ ],
+ imports: [
+ BrowserModule,
+ AppRoutingModule,
+ HttpClientModule,
+ FormsModule,
+ ReactiveFormsModule
+ ],
+ providers: [SharedService],
+ bootstrap: [AppComponent]
+})
+export class AppModule { }
diff --git a/sandbox/TestAppOgnjen/FrontEnd/src/app/lista/lista.component.css b/sandbox/TestAppOgnjen/FrontEnd/src/app/lista/lista.component.css
new file mode 100644
index 00000000..aa0f09c9
--- /dev/null
+++ b/sandbox/TestAppOgnjen/FrontEnd/src/app/lista/lista.component.css
@@ -0,0 +1,15 @@
+table{
+ background-color: lightblue;
+ text-align: center;
+}
+td,tr,th{
+ border:2px solid black;
+ padding: 3px;
+
+}
+tr:nth-child(even) {
+ background-color: Lightgreen;
+}
+tr:nth-child(odd) {
+ background-color: lightblue;
+} \ No newline at end of file
diff --git a/sandbox/TestAppOgnjen/FrontEnd/src/app/lista/lista.component.html b/sandbox/TestAppOgnjen/FrontEnd/src/app/lista/lista.component.html
new file mode 100644
index 00000000..2f182c15
--- /dev/null
+++ b/sandbox/TestAppOgnjen/FrontEnd/src/app/lista/lista.component.html
@@ -0,0 +1,23 @@
+<h1>ToDo Lista</h1>
+<table style="border: 1px black solid;padding: 3px;">
+<tr>
+ <th>Id</th><th>Task</th><th>Done</th><th>Options</th>
+</tr>
+<tr *ngFor="let item of ToDoList">
+<th>{{item.id}}</th>
+<td>{{item.task}}</td>
+<td>{{item.done}}</td>
+<td>
+ <button type="button" (click)="editToDo(item)">Do/Undo</button> &nbsp;
+ <button type="button" style="background-color:rgba(212, 10, 10, 0.459);" (click)="deleteToDo(item)">Delete</button>
+</td>
+</tr>
+
+</table>
+
+<br><br>
+<form>
+Task &nbsp;<input type='text'[(ngModel)]="TaskName" name="TaskName"><br><br>
+Done &nbsp;<input type='checkbox' [(ngModel)]="isDone" name="isDone"><br><br>
+<button type="button" (click)="addToDo()">Dodaj</button>
+</form> \ No newline at end of file
diff --git a/sandbox/TestAppOgnjen/FrontEnd/src/app/lista/lista.component.spec.ts b/sandbox/TestAppOgnjen/FrontEnd/src/app/lista/lista.component.spec.ts
new file mode 100644
index 00000000..a85678b7
--- /dev/null
+++ b/sandbox/TestAppOgnjen/FrontEnd/src/app/lista/lista.component.spec.ts
@@ -0,0 +1,25 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { ListaComponent } from './lista.component';
+
+describe('ListaComponent', () => {
+ let component: ListaComponent;
+ let fixture: ComponentFixture<ListaComponent>;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [ ListaComponent ]
+ })
+ .compileComponents();
+ });
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(ListaComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/sandbox/TestAppOgnjen/FrontEnd/src/app/lista/lista.component.ts b/sandbox/TestAppOgnjen/FrontEnd/src/app/lista/lista.component.ts
new file mode 100644
index 00000000..b98b9aed
--- /dev/null
+++ b/sandbox/TestAppOgnjen/FrontEnd/src/app/lista/lista.component.ts
@@ -0,0 +1,60 @@
+import { Component, OnInit } from '@angular/core';
+import { SharedService } from '../shared.service';
+import { NgModule } from '@angular/core';
+@Component({
+ selector: 'app-lista',
+ templateUrl: './lista.component.html',
+ styleUrls: ['./lista.component.css']
+})
+export class ListaComponent implements OnInit {
+
+ constructor(private service:SharedService) { }
+
+ ToDoList:any=[];
+ TaskName:string="ime taska";
+ isDone:boolean=false;
+
+
+ ngOnInit(): void {
+ this.refreshToDoList();
+ }
+
+
+
+ editToDo(item:any){
+ var done=1;
+ if(item.done==1)
+ done=0;
+ var val={id:item.id,
+ task:item.task,
+ done:done};
+ this.service.updateToDo(val,item.id).subscribe(data=>{
+ this.refreshToDoList();
+ });
+
+ }
+ deleteToDo(item:any){
+ if(confirm("Da li stvarno zelite da obrisete "+item.task))
+ this.service.deleteToDo(item.id).subscribe(data=>{
+ this.refreshToDoList();
+ });
+
+ }
+ addToDo(){
+ var done=0;
+ if(this.isDone)
+ done=1;
+ var val={task:this.TaskName,
+ done:done};
+ this.service.addToDo(val).subscribe(data=>{
+ this.refreshToDoList();
+ })
+
+ }
+
+ refreshToDoList(){
+ this.service.getToDoList().subscribe(data=>{
+ this.ToDoList=data;
+ });
+ }
+}
diff --git a/sandbox/TestAppOgnjen/FrontEnd/src/app/shared.service.spec.ts b/sandbox/TestAppOgnjen/FrontEnd/src/app/shared.service.spec.ts
new file mode 100644
index 00000000..3da5345f
--- /dev/null
+++ b/sandbox/TestAppOgnjen/FrontEnd/src/app/shared.service.spec.ts
@@ -0,0 +1,16 @@
+import { TestBed } from '@angular/core/testing';
+
+import { SharedService } from './shared.service';
+
+describe('SharedService', () => {
+ let service: SharedService;
+
+ beforeEach(() => {
+ TestBed.configureTestingModule({});
+ service = TestBed.inject(SharedService);
+ });
+
+ it('should be created', () => {
+ expect(service).toBeTruthy();
+ });
+});
diff --git a/sandbox/TestAppOgnjen/FrontEnd/src/app/shared.service.ts b/sandbox/TestAppOgnjen/FrontEnd/src/app/shared.service.ts
new file mode 100644
index 00000000..501beda0
--- /dev/null
+++ b/sandbox/TestAppOgnjen/FrontEnd/src/app/shared.service.ts
@@ -0,0 +1,25 @@
+import { Injectable } from '@angular/core';
+import { HttpClient, HttpClientModule } from '@angular/common/http';
+import { Observable } from 'rxjs';
+
+@Injectable({
+ providedIn: 'root'
+})
+export class SharedService {
+readonly APIUrl="http://localhost:5000/api";
+ constructor(private http:HttpClient) { }
+
+
+ getToDoList():Observable<any[]>{
+ return this.http.get<any>(this.APIUrl+'/ToDo');
+ }
+ addToDo(val:any){
+ return this.http.post(this.APIUrl+'/ToDo',val);
+ }
+ updateToDo(val:any,id:any){
+ return this.http.put(this.APIUrl+'/ToDo/'+id,val);
+ }
+ deleteToDo(val:any){
+ return this.http.delete(this.APIUrl+'/ToDo/'+val);
+ }
+}
diff --git a/sandbox/TestAppOgnjen/FrontEnd/src/assets/.gitkeep b/sandbox/TestAppOgnjen/FrontEnd/src/assets/.gitkeep
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/sandbox/TestAppOgnjen/FrontEnd/src/assets/.gitkeep
diff --git a/sandbox/TestAppOgnjen/FrontEnd/src/environments/environment.prod.ts b/sandbox/TestAppOgnjen/FrontEnd/src/environments/environment.prod.ts
new file mode 100644
index 00000000..3612073b
--- /dev/null
+++ b/sandbox/TestAppOgnjen/FrontEnd/src/environments/environment.prod.ts
@@ -0,0 +1,3 @@
+export const environment = {
+ production: true
+};
diff --git a/sandbox/TestAppOgnjen/FrontEnd/src/environments/environment.ts b/sandbox/TestAppOgnjen/FrontEnd/src/environments/environment.ts
new file mode 100644
index 00000000..f56ff470
--- /dev/null
+++ b/sandbox/TestAppOgnjen/FrontEnd/src/environments/environment.ts
@@ -0,0 +1,16 @@
+// This file can be replaced during build by using the `fileReplacements` array.
+// `ng build` replaces `environment.ts` with `environment.prod.ts`.
+// The list of file replacements can be found in `angular.json`.
+
+export const environment = {
+ production: false
+};
+
+/*
+ * For easier debugging in development mode, you can import the following file
+ * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
+ *
+ * This import should be commented out in production mode because it will have a negative impact
+ * on performance if an error is thrown.
+ */
+// import 'zone.js/plugins/zone-error'; // Included with Angular CLI.
diff --git a/sandbox/TestAppOgnjen/FrontEnd/src/favicon.ico b/sandbox/TestAppOgnjen/FrontEnd/src/favicon.ico
new file mode 100644
index 00000000..997406ad
--- /dev/null
+++ b/sandbox/TestAppOgnjen/FrontEnd/src/favicon.ico
Binary files differ
diff --git a/sandbox/TestAppOgnjen/FrontEnd/src/index.html b/sandbox/TestAppOgnjen/FrontEnd/src/index.html
new file mode 100644
index 00000000..c9c862c0
--- /dev/null
+++ b/sandbox/TestAppOgnjen/FrontEnd/src/index.html
@@ -0,0 +1,13 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>ToDoFront</title>
+ <base href="/">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <link rel="icon" type="image/x-icon" href="favicon.ico">
+</head>
+<body>
+ <app-root></app-root>
+</body>
+</html>
diff --git a/sandbox/TestAppOgnjen/FrontEnd/src/main.ts b/sandbox/TestAppOgnjen/FrontEnd/src/main.ts
new file mode 100644
index 00000000..c7b673cf
--- /dev/null
+++ b/sandbox/TestAppOgnjen/FrontEnd/src/main.ts
@@ -0,0 +1,12 @@
+import { enableProdMode } from '@angular/core';
+import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
+
+import { AppModule } from './app/app.module';
+import { environment } from './environments/environment';
+
+if (environment.production) {
+ enableProdMode();
+}
+
+platformBrowserDynamic().bootstrapModule(AppModule)
+ .catch(err => console.error(err));
diff --git a/sandbox/TestAppOgnjen/FrontEnd/src/polyfills.ts b/sandbox/TestAppOgnjen/FrontEnd/src/polyfills.ts
new file mode 100644
index 00000000..429bb9ef
--- /dev/null
+++ b/sandbox/TestAppOgnjen/FrontEnd/src/polyfills.ts
@@ -0,0 +1,53 @@
+/**
+ * This file includes polyfills needed by Angular and is loaded before the app.
+ * You can add your own extra polyfills to this file.
+ *
+ * This file is divided into 2 sections:
+ * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
+ * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
+ * file.
+ *
+ * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
+ * automatically update themselves. This includes recent versions of Safari, Chrome (including
+ * Opera), Edge on the desktop, and iOS and Chrome on mobile.
+ *
+ * Learn more in https://angular.io/guide/browser-support
+ */
+
+/***************************************************************************************************
+ * BROWSER POLYFILLS
+ */
+
+/**
+ * By default, zone.js will patch all possible macroTask and DomEvents
+ * user can disable parts of macroTask/DomEvents patch by setting following flags
+ * because those flags need to be set before `zone.js` being loaded, and webpack
+ * will put import in the top of bundle, so user need to create a separate file
+ * in this directory (for example: zone-flags.ts), and put the following flags
+ * into that file, and then add the following code before importing zone.js.
+ * import './zone-flags';
+ *
+ * The flags allowed in zone-flags.ts are listed here.
+ *
+ * The following flags will work for all browsers.
+ *
+ * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
+ * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
+ * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
+ *
+ * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
+ * with the following flag, it will bypass `zone.js` patch for IE/Edge
+ *
+ * (window as any).__Zone_enable_cross_context_check = true;
+ *
+ */
+
+/***************************************************************************************************
+ * Zone JS is required by default for Angular itself.
+ */
+import 'zone.js'; // Included with Angular CLI.
+
+
+/***************************************************************************************************
+ * APPLICATION IMPORTS
+ */
diff --git a/sandbox/TestAppOgnjen/FrontEnd/src/styles.css b/sandbox/TestAppOgnjen/FrontEnd/src/styles.css
new file mode 100644
index 00000000..90d4ee00
--- /dev/null
+++ b/sandbox/TestAppOgnjen/FrontEnd/src/styles.css
@@ -0,0 +1 @@
+/* You can add global styles to this file, and also import other style files */
diff --git a/sandbox/TestAppOgnjen/FrontEnd/src/test.ts b/sandbox/TestAppOgnjen/FrontEnd/src/test.ts
new file mode 100644
index 00000000..00025daf
--- /dev/null
+++ b/sandbox/TestAppOgnjen/FrontEnd/src/test.ts
@@ -0,0 +1,26 @@
+// This file is required by karma.conf.js and loads recursively all the .spec and framework files
+
+import 'zone.js/testing';
+import { getTestBed } from '@angular/core/testing';
+import {
+ BrowserDynamicTestingModule,
+ platformBrowserDynamicTesting
+} from '@angular/platform-browser-dynamic/testing';
+
+declare const require: {
+ context(path: string, deep?: boolean, filter?: RegExp): {
+ <T>(id: string): T;
+ keys(): string[];
+ };
+};
+
+// First, initialize the Angular testing environment.
+getTestBed().initTestEnvironment(
+ BrowserDynamicTestingModule,
+ platformBrowserDynamicTesting(),
+);
+
+// Then we find all the tests.
+const context = require.context('./', true, /\.spec\.ts$/);
+// And load the modules.
+context.keys().map(context);