Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 2b790e00

Přidáno uživatelem Ondřej Váně před více než 4 roky(ů)

Re #7726: Implementace architektury FE

- implementace metody pro získání všech dokumentů z BE
- implementováno basic view pro stránku Browse

Zobrazit rozdíly:

be/fulltextsearch/src/main/java/cz/zcu/kiv/aswi/fulltextsearch/IndexController.java
1 1
package cz.zcu.kiv.aswi.fulltextsearch;
2 2

  
3
import cz.zcu.kiv.aswi.fulltextsearch.model.DocumentResponse;
3 4
import cz.zcu.kiv.aswi.fulltextsearch.model.Query;
4 5
import cz.zcu.kiv.aswi.fulltextsearch.model.QueryResponse;
5 6
import cz.zcu.kiv.aswi.fulltextsearch.model.ResponseMessage;
......
11 12

  
12 13
import javax.xml.bind.JAXBException;
13 14
import java.io.IOException;
15
import java.util.ArrayList;
14 16
import java.util.List;
15 17

  
16 18
@CrossOrigin(origins = "*", allowedHeaders = "*")
......
51 53
        }
52 54
    }
53 55

  
56
    @GetMapping("/documents")
57
    public List<DocumentResponse> uploadFile() {
58

  
59
        // TODO : získat všechny uložené dokumenty v systému
60

  
61
        return new ArrayList<>() {
62
            {
63
                add(new DocumentResponse("soap-ch_knihovna_ascher-zeitung-1866-06-16-n24_0855", 1));
64
                add(new DocumentResponse("soap-ch_knihovna_ascher-zeitung-1866-09-15-n37_1365", 2));
65
                add(new DocumentResponse("soap-ch_knihovna_ascher-zeitung-1866-08-25-n34_1255", 3));
66
                add(new DocumentResponse("soap-ch_knihovna_ascher-zeitung-1866-07-07-n27_0980", 4));
67
            }
68
        };
69

  
70
    }
71

  
72

  
73

  
54 74
    @GetMapping("/add")
55 75
    public String add() {
56 76
        String response;
be/fulltextsearch/src/main/java/cz/zcu/kiv/aswi/fulltextsearch/model/DocumentResponse.java
1
package cz.zcu.kiv.aswi.fulltextsearch.model;
2

  
3
public class DocumentResponse {
4

  
5
    private String documentName;
6
    private int id;
7

  
8
    public DocumentResponse(String documentName, int id) {
9
        this.documentName = documentName;
10
        this.id = id;
11
    }
12

  
13
    public String getDocumentName() {
14
        return documentName;
15
    }
16

  
17
    public void setDocumentName(String documentName, int id) {
18
        this.documentName = documentName;
19
    }
20

  
21
    public int getId() {
22
        return id;
23
    }
24

  
25
    public void setId(int id) {
26
        this.id = id;
27
    }
28
}
fe/fulltextsearch/src/app/components/pages/browse/browse.component.css
1
h1 {
2
  font-size: xx-large;
3
}
4

  
5
.text-box {
6
  margin: auto;
7
  width: 80%;
8
  padding: 10px;
9
}
fe/fulltextsearch/src/app/components/pages/browse/browse.component.html
1
<p>browse works!</p>
1
<div class="text-box">
2
  <div class="card">
3
    <h1 class="card-header">All documents</h1>
4
    <div class="card-body">
5
      <ul class="list-group">
6
        <li class="list-group-item" *ngFor="let documentResponse of documents">
7
          <b>Id: </b>{{documentResponse.id}}
8
          <b>Document name: </b>{{documentResponse.documentName}}
9
        </li>
10
      </ul>
11
    </div>
12
  </div>
13
</div>
fe/fulltextsearch/src/app/components/pages/browse/browse.component.ts
1 1
import { Component, OnInit } from '@angular/core';
2
import {DocumentResponse} from '../../../model/DocumentResponse';
3
import {QueryService} from '../../../services/query.service';
2 4

  
3 5
@Component({
4 6
  selector: 'app-browse',
......
6 8
  styleUrls: ['./browse.component.css']
7 9
})
8 10
export class BrowseComponent implements OnInit {
11
  documents: DocumentResponse[] = null;
9 12

  
10
  constructor() { }
13
  constructor( private queryService: QueryService ) { }
11 14

  
12 15
  ngOnInit(): void {
16
    this.queryService.getDocuments().subscribe( documents => {
17
      this.documents = documents;
18
    });
13 19
  }
14 20

  
15 21
}
fe/fulltextsearch/src/app/services/query.service.ts
3 3
import {Observable} from 'rxjs';
4 4
import {QueryResponse} from '../model/QueryResponse';
5 5
import {Query} from '../model/Query';
6
import {DocumentResponse} from '../model/DocumentResponse';
6 7

  
7 8
const httpOptions = {
8 9
  headers: new HttpHeaders( {
......
17 18

  
18 19
  backendUrl = 'http://localhost:8080/';
19 20
  uploadFileUrl = 'upload';
21
  documentsUrl = 'documents';
20 22

  
21 23
  constructor(private httpClient: HttpClient) {}
22 24

  
......
35 37
      observe: 'events'
36 38
    });
37 39
  }
40

  
41
  getDocuments(): Observable<DocumentResponse[]> {
42
    return this.httpClient.get<DocumentResponse[]>(this.backendUrl + this.documentsUrl, httpOptions);
43
  }
44

  
45

  
38 46
}

Také k dispozici: Unified diff