integrasi tips dan trik

This commit is contained in:
Ryan Ariana 2024-05-16 09:41:25 +07:00
parent 507d26d216
commit 7c84085d13
6 changed files with 67 additions and 126 deletions

View File

@ -12,7 +12,7 @@ const routes: Routes = [
},
{
path: '',
redirectTo: 'home',
redirectTo: 'cover',
pathMatch: 'full'
},
{

View File

@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { TipsService } from './tips.service';
describe('TipsService', () => {
let service: TipsService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(TipsService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@ -0,0 +1,22 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { environment } from '../../environments/environment';
@Injectable({
providedIn: 'root'
})
export class TipsService {
private apiUrl = `${environment.apiUrl}/trik`;
constructor(private http: HttpClient) { }
simpanPengukuran(data: any): Observable<any> {
return this.http.post(this.apiUrl, data);
}
getAllTrik(): Observable<any> {
const url = `${this.apiUrl}?take=30`;
return this.http.get(url);
}
}

View File

@ -53,113 +53,20 @@ export class TabelPage implements OnInit {
async ngOnInit() {
await this.storage.create();
this.getPengukuranData();
this.loadingIndicator = true;
this.dummy = [
{
"id": 4,
"berat_badan": 1,
"tinggi_badan": 2,
"imt": 3,
"lingkar_perut": 16,
"tekanan_darah_diastole": 4,
"tekanan_darah_sistole": 5,
"frekuensi_nafas": 6,
"nadi": 7,
"kadar_gula_darah": 8,
"waktu_pengambilan_gula_darah": "pagi",
"kolesterol_total": 11,
"kolesterol_ldl": 10,
"kolesterol_hdl": 9,
"trigliserida": 15,
"kadar_hb": 12,
"kadar_asam_urat": 13,
"golongan_darah": "14",
"kondisi_umum": "kondisi",
"keluhan_perasaan": "keluhan",
"created_at": "2024-05-15T12:37:35Z",
"updated_at": "2024-05-15T12:37:35Z",
"deleted_at": null,
"identitas_id": 8
},
{
"id": 5,
"berat_badan": 3123,
"tinggi_badan": 123,
"imt": 412,
"lingkar_perut": 45,
"tekanan_darah_diastole": 244,
"tekanan_darah_sistole": 34,
"frekuensi_nafas": 234,
"nadi": 34,
"kadar_gula_darah": 42,
"waktu_pengambilan_gula_darah": "pagi",
"kolesterol_total": 2345,
"kolesterol_ldl": 23,
"kolesterol_hdl": 3424,
"trigliserida": 534,
"kadar_hb": 44,
"kadar_asam_urat": 53,
"golongan_darah": "45",
"kondisi_umum": "kondisi",
"keluhan_perasaan": "keluhan",
"created_at": "2024-05-15T12:39:11Z",
"updated_at": "2024-05-15T12:39:11Z",
"deleted_at": null,
"identitas_id": 8
},
{
"id": 6,
"berat_badan": 123,
"tinggi_badan": 412,
"imt": 312,
"lingkar_perut": 20,
"tekanan_darah_diastole": 23,
"tekanan_darah_sistole": 54,
"frekuensi_nafas": 34,
"nadi": 234,
"kadar_gula_darah": 234,
"waktu_pengambilan_gula_darah": "makan",
"kolesterol_total": 543,
"kolesterol_ldl": 523,
"kolesterol_hdl": 5234,
"trigliserida": 24,
"kadar_hb": 45,
"kadar_asam_urat": 35,
"golongan_darah": "2345",
"kondisi_umum": "aman terkendali",
"keluhan_perasaan": "perasaan",
"created_at": "2024-05-15T12:41:39Z",
"updated_at": "2024-05-15T12:41:39Z",
"deleted_at": null,
"identitas_id": 8
}
]
this.temp = [
{ id: 1, name: 'Austin', gender: 'Male', company: 'Swimlane' },
{ id: 2, name: 'Dany', gender: 'Male', company: 'KFC' },
{ id: 3, name: 'Molly', gender: 'Female', company: 'Burger King' },
{ id: 4, name: 'Austin', gender: 'Male', company: 'Swimlane' },
{ id: 5, name: 'Dany', gender: 'Male', company: 'KFC' },
{ id: 6, name: 'Molly', gender: 'Female', company: 'Burger King' },
{ id: 7, name: 'Austin', gender: 'Male', company: 'Swimlane' },
{ id: 8, name: 'Dany', gender: 'Male', company: 'KFC' },
{ id: 9, name: 'Molly', gender: 'Female', company: 'Burger King' },
{ id: 10, name: 'Austin', gender: 'Male', company: 'Swimlane' },
{ id: 11, name: 'Dany', gender: 'Male', company: 'KFC' },
{ id: 12, name: 'Molly', gender: 'Female', company: 'Burger King' },
];
this.rows = [...this.dummy];
this.loadingIndicator = false;
}
async getPengukuranData() {
this.loadingIndicator = true;
const idIdentitas = await this.storage.get('id_identitas');
this.pengukuranService.getPengukuranByIdentitasId(idIdentitas).subscribe(
(data: any) => {
console.log('Data Pengukuran:', data);
(res: any) => {
console.log('Data Pengukuran:', res);
this.rows = [...res.data];
},
(error: any) => {
console.error('Error:', error);
}
);
}
this.loadingIndicator = false;
}
}

View File

@ -14,34 +14,14 @@
</ion-toolbar>
</ion-header>
<ion-card>
<ion-card *ngFor="let tip of resData">
<ion-card-header>
<ion-card-title>
TRIK AGAR SEHAT BUGAR SETIAP HARI
{{ tip.judul }}
</ion-card-title>
</ion-card-header>
</ion-card>
<ion-card>
<ion-card-content>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum
</p>
<div [innerHTML]="tip.isi"></div>
</ion-card-content>
</ion-card>
<ion-card>
<ion-card-header>
<ion-card-title>
TRIK SEHAT BAGI PENDERITA DIABETES MELLITUS (DM) / KENCING MANIS
</ion-card-title>
</ion-card-header>
</ion-card>
<ion-card>
<ion-card-content>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum
</p>
</ion-card-content>
</ion-card>
</ion-content>
</ion-content>

View File

@ -1,4 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { TipsService } from '../services/tips.service';
@Component({
selector: 'app-tips',
@ -6,10 +7,25 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./tips.page.scss'],
})
export class TipsPage implements OnInit {
resData: any;
constructor() { }
constructor(
private tipservice: TipsService
) {}
ngOnInit() {
this.getAllData();
}
async getAllData() {
this.tipservice.getAllTrik().subscribe(
(res: any) => {
this.resData = res.data;
console.log(res.data);
},
(error: any) => {
console.error('Error:', error);
}
);
}
}