Skip to content

Commit

Permalink
[Front] Feature Messages
Browse files Browse the repository at this point in the history
	modified:   front/src/app/core/http/message.service.ts
	modified:   front/src/app/modules/management/parameters/message/message.component.html
	modified:   front/src/app/modules/management/parameters/message/message.component.ts
	deleted:    front/src/app/modules/management/parameters/parameters.component.css
	deleted:    front/src/app/modules/management/parameters/parameters.component.spec.ts
	modified:   front/src/app/modules/management/parameters/parameters.component.ts
  • Loading branch information
MinhNamNguyen committed Sep 1, 2020
1 parent e5ad910 commit f5d2488
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 36 deletions.
4 changes: 2 additions & 2 deletions front/src/app/core/http/message.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export class MessageService {

constructor(private http: HttpClient) { }

getMessages(): Observable<PaginatedMessage> {
getMessages(): Observable<PaginatedMessage[]> {
const url = `${environment.apiUrl}/api/messages`;
return this.http.get<PaginatedMessage>(url, HTTP_OPTIONS);
return this.http.get<PaginatedMessage[]>(url, HTTP_OPTIONS);
}

getCurrentMessage(): Observable<Message> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@
<th class="collapsing"><i class="thumbtack icon"></i> Message Actuel</th>
<th class="collapsing"><i class="mail alternate icon"></i> Anciens Messages</th>
</tr>
<tr>
<tr *ngFor="let message of messages">
<td *ngIf="currentmessage.length > 0 ; else elseBlock">
{{currentmessage.title}}
</td>
<td>
<div *ngIf="message.is_active === true"></div>
{{message.content}}
<ng-template #elseBlock>
No current message
</ng-template>
</td>
<td>
<div *ngIf="message.is_active === false"></div>
{{message.content}}
<b>Title :</b>{{message.title}}<br>
<b>Content :</b>{{message.content}}<br>
</td>
</tr>
</thead>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { Component, OnInit } from '@angular/core';
import { Component, Input, OnInit } from '@angular/core';
import { Message } from '../../../../core/classes/models/message';
import { MessageService } from '../../../../core/http/message.service';
import { Moment } from 'moment';
import * as moment from 'moment';
import { Router } from '@angular/router';

@Component({
selector: 'app-message',
Expand All @@ -7,9 +12,36 @@ import { Component, OnInit } from '@angular/core';
})
export class MessageComponent implements OnInit {

constructor() { }
messages: Message[];
loading: boolean = false;
currentmessage: Message;

constructor(
private messageService: MessageService,
) { }

ngOnInit() {
this.getCurrentMessage();
this.getAllMessages();
}

getCurrentMessage() {
this.loading = true;

this.messageService.getCurrentMessage().subscribe(currentmessage =>{
this.currentmessage=currentmessage;

this.loading =false;
});
}

getAllMessages(){
this.loading = true;
this.messageService.getMessages().subscribe(messages =>{
this.messages = messages;

this.loading=false;
})
}

}
Empty file.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-parameters',
templateUrl: './parameters.component.html',
styleUrls: ['./parameters.component.css']
templateUrl: './parameters.component.html'
})
export class ParametersComponent implements OnInit {

Expand Down

0 comments on commit f5d2488

Please sign in to comment.