summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil <phil.buschmann@tum.de>2018-05-15 22:03:04 +0200
committerPhil <phil.buschmann@tum.de>2018-05-15 22:03:04 +0200
commit57efd4f24d238ca649ef25e9922b7f64fa4cc417 (patch)
tree4869437ba286487bd2a26d24135a1fead2d21416
parent734d4b3be1cf2931752d5c192f93353bbf2373af (diff)
-wip Service feature
-rw-r--r--src/app/api.service.spec.ts15
-rw-r--r--src/app/api.service.ts20
-rw-r--r--src/app/app-routing.module.spec.ts13
-rw-r--r--src/app/app-routing.module.ts16
-rw-r--r--src/app/app.component.html32
-rw-r--r--src/app/app.component.ts2
-rw-r--r--src/app/app.module.ts12
-rw-r--r--src/app/rest-api.ts5
-rw-r--r--src/app/rest-apis/rest-apis.component.html3
-rw-r--r--src/app/rest-apis/rest-apis.component.scss0
-rw-r--r--src/app/rest-apis/rest-apis.component.spec.ts25
-rw-r--r--src/app/rest-apis/rest-apis.component.ts24
12 files changed, 150 insertions, 17 deletions
diff --git a/src/app/api.service.spec.ts b/src/app/api.service.spec.ts
new file mode 100644
index 0000000..65b6c71
--- /dev/null
+++ b/src/app/api.service.spec.ts
@@ -0,0 +1,15 @@
+import { TestBed, inject } from '@angular/core/testing';
+
+import { ApiService } from './api.service';
+
+describe('ApiService', () => {
+ beforeEach(() => {
+ TestBed.configureTestingModule({
+ providers: [ApiService]
+ });
+ });
+
+ it('should be created', inject([ApiService], (service: ApiService) => {
+ expect(service).toBeTruthy();
+ }));
+});
diff --git a/src/app/api.service.ts b/src/app/api.service.ts
new file mode 100644
index 0000000..aaf0162
--- /dev/null
+++ b/src/app/api.service.ts
@@ -0,0 +1,20 @@
+import { Injectable } from '@angular/core';
+import { Observable, of } from 'rxjs';
+import { RestAPI } from './rest-api';
+
+@Injectable({
+ providedIn: 'root'
+})
+export class ApiService {
+ apis: RestAPI[] = [
+ {name: 'Rest API 1', desc: 'What it does', link: '#'},
+ {name: 'Rest API 1', desc: 'What it does', link: '#'},
+ {name: 'Rest API 1', desc: 'What it does', link: '#'}
+ ];
+
+ constructor() { }
+
+ getAPIs(): Observable<RestAPI[]> {
+ return of(this.apis);
+ }
+}
diff --git a/src/app/app-routing.module.spec.ts b/src/app/app-routing.module.spec.ts
new file mode 100644
index 0000000..d68ef06
--- /dev/null
+++ b/src/app/app-routing.module.spec.ts
@@ -0,0 +1,13 @@
+import { AppRoutingModule } from './app-routing.module';
+
+describe('AppRoutingModule', () => {
+ let appRoutingModule: AppRoutingModule;
+
+ beforeEach(() => {
+ appRoutingModule = new AppRoutingModule();
+ });
+
+ it('should create an instance', () => {
+ expect(appRoutingModule).toBeTruthy();
+ });
+});
diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts
new file mode 100644
index 0000000..2c25096
--- /dev/null
+++ b/src/app/app-routing.module.ts
@@ -0,0 +1,16 @@
+import { NgModule } from '@angular/core';
+import { RouterModule, Routes } from '@angular/router';
+
+import { RestApisComponent } from './rest-apis/rest-apis.component';
+
+
+const routes: Routes = [
+ { path: 'apis', component: RestApisComponent }
+];
+
+@NgModule({
+ imports: [ RouterModule.forRoot(routes) ],
+ exports: [ RouterModule ]
+})
+export class AppRoutingModule {
+}
diff --git a/src/app/app.component.html b/src/app/app.component.html
index fa2706a..566c30f 100644
--- a/src/app/app.component.html
+++ b/src/app/app.component.html
@@ -1,20 +1,24 @@
<!--The content below is only a placeholder and can be replaced.-->
<div style="text-align:center">
<h1>
- Welcome to {{ title }}!
+ {{ title }}
</h1>
- <img width="300" alt="Angular Logo" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg==">
+ <app-rest-apis></app-rest-apis>
+ <router-outlet></router-outlet>
</div>
-<h2>Here are some links to help you start: </h2>
-<ul>
- <li>
- <h2><a target="_blank" rel="noopener" href="https://angular.io/tutorial">Tour of Heroes</a></h2>
- </li>
- <li>
- <h2><a target="_blank" rel="noopener" href="https://github.com/angular/angular-cli/wiki">CLI Documentation</a></h2>
- </li>
- <li>
- <h2><a target="_blank" rel="noopener" href="https://blog.angular.io/">Angular blog</a></h2>
- </li>
+<div class="o-container u-bgcolor-grey-light">
+ <div class="o-grid o-grid--gutter-x4">
+ <div class="o-grid__col u-1/2@sm u-bgcolor-white">
+ Test
+ </div>
+ <div class="o-grid__col u-1/2@sm u-bgcolor-white">
+ Test
+ </div>
+ </div>
+<h2 class="">Here are some links to help you start: </h2>
+<ul class="o-list">
+ <li class="o-list__item"><a target="_blank" rel="noopener" href="https://angular.io/tutorial">Tour of Heroes</a></li>
+ <li class="o-list__item"><a target="_blank" rel="noopener" href="https://github.com/angular/angular-cli/wiki">CLI Documentation</a></li>
+ <li class="o-list__item"><a target="_blank" rel="noopener" href="https://blog.angular.io/">Angular blog</a></li>
</ul>
-
+</div>
diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index bff8c82..4bba0e2 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -6,5 +6,5 @@ import { Component } from '@angular/core';
styleUrls: ['./../scss/main.scss']
})
export class AppComponent {
- title = 'app';
+ title = 'GNUnet Web User Interface';
}
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index f657163..cb9bb62 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -1,14 +1,22 @@
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
+import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
+import { HeroesComponent } from './heroes/heroes.component';
+import { RestApisComponent } from './rest-apis/rest-apis.component';
+import { AppRoutingModule } from './/app-routing.module';
@NgModule({
declarations: [
- AppComponent
+ AppComponent,
+ HeroesComponent,
+ RestApisComponent
],
imports: [
- BrowserModule
+ BrowserModule,
+ FormsModule,
+ AppRoutingModule
],
providers: [],
bootstrap: [AppComponent]
diff --git a/src/app/rest-api.ts b/src/app/rest-api.ts
new file mode 100644
index 0000000..b4fa409
--- /dev/null
+++ b/src/app/rest-api.ts
@@ -0,0 +1,5 @@
+export class RestAPI {
+ name: string;
+ desc: string;
+ link: string;
+}
diff --git a/src/app/rest-apis/rest-apis.component.html b/src/app/rest-apis/rest-apis.component.html
new file mode 100644
index 0000000..5e0e14a
--- /dev/null
+++ b/src/app/rest-apis/rest-apis.component.html
@@ -0,0 +1,3 @@
+<div *ngFor="let api of apis">
+ {{api.name}}{{api.desc}}<a href="{{api.link}}">Link</a>
+</div>
diff --git a/src/app/rest-apis/rest-apis.component.scss b/src/app/rest-apis/rest-apis.component.scss
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/app/rest-apis/rest-apis.component.scss
diff --git a/src/app/rest-apis/rest-apis.component.spec.ts b/src/app/rest-apis/rest-apis.component.spec.ts
new file mode 100644
index 0000000..7ed2d82
--- /dev/null
+++ b/src/app/rest-apis/rest-apis.component.spec.ts
@@ -0,0 +1,25 @@
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { RestApisComponent } from './rest-apis.component';
+
+describe('RestApisComponent', () => {
+ let component: RestApisComponent;
+ let fixture: ComponentFixture<RestApisComponent>;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ RestApisComponent ]
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(RestApisComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/rest-apis/rest-apis.component.ts b/src/app/rest-apis/rest-apis.component.ts
new file mode 100644
index 0000000..c8fc017
--- /dev/null
+++ b/src/app/rest-apis/rest-apis.component.ts
@@ -0,0 +1,24 @@
+import { Component, OnInit } from '@angular/core';
+import { RestAPI } from '../rest-api';
+import { ApiService } from '../api.service';
+
+@Component({
+ selector: 'app-rest-apis',
+ templateUrl: './rest-apis.component.html',
+ styleUrls: ['./rest-apis.component.scss']
+})
+export class RestApisComponent implements OnInit {
+
+ apis: RestAPI[];
+
+ constructor(private apiService: ApiService) { }
+
+ getAPIs(): void {
+ this.apiService.getAPIs().subscribe(apis => this.apis = apis);
+ }
+
+ ngOnInit() {
+ this.getAPIs();
+ }
+
+}