diff --git a/backend/app.js b/backend/app.js index cecf6b4..cde8294 100644 --- a/backend/app.js +++ b/backend/app.js @@ -176,4 +176,22 @@ app.post('/api/addownername', (req, res, next) => { }); }); +app.get('/api/getitems', (req, res, next) => { + console.log('Get: /api/getitems'); + const items = itemmodel.find({address: req.body.address}).then((documents) => { + if(documents.length > 0){ + //console.log(documents); + res.status(200).json({ + message: 'items found!', + items: documents + }); + } else { + res.status(204).json({ + message: 'items not found!', + items: [] + }); + } + }); +}); + module.exports = app; diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 7d3be8b..2426277 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -11,24 +11,21 @@ import { MatDialogModule } from '@angular/material/dialog'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; -//import { PostCreateComponent } from './posts/post-create/post-create.component'; import { HeaderComponent } from './header/header.component'; -//import { PostListComponent } from './posts/post-list/post-list.component'; -//import { PostService } from './posts/posts.service'; import { ViewerComponent } from './viewer/viewer.component'; import { LoginComponent } from './login/login.component'; +import { ItemListComponent } from './items/item-list/item-list.component'; //import { NameDialogComponent } from './namedialog/namedialog.component'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; @NgModule({ declarations: [ AppComponent, - //PostCreateComponent, HeaderComponent, ViewerComponent, - LoginComponent, + ItemListComponent, + LoginComponent //NameDialogComponent, - //PostListComponent ], imports: [ BrowserModule, diff --git a/src/app/items/item-list/item-list.component.html b/src/app/items/item-list/item-list.component.html new file mode 100644 index 0000000..2bcb03d --- /dev/null +++ b/src/app/items/item-list/item-list.component.html @@ -0,0 +1,10 @@ +
{{item.description}}
+No items yet!
diff --git a/src/app/items/item-list/item-list.component.ts b/src/app/items/item-list/item-list.component.ts new file mode 100644 index 0000000..5620e7a --- /dev/null +++ b/src/app/items/item-list/item-list.component.ts @@ -0,0 +1,38 @@ +import { Component, OnInit } from '@angular/core'; +import { Observable } from 'rxjs'; +import { Item } from '../item.model'; +import { Owner } from '../../owner.model'; +import { UserService } from '../../user.service'; +import { ItemService } from '../items.service'; + + +@Component({ + selector: 'app-item-list', + templateUrl: './item-list.component.html' +}) + +export class ItemListComponent{ + public items: Item[] = []; + private owner: Owner = {_id: '', name: '', address: ''}; + public ownerUpdate: Observable