first commit

This commit is contained in:
kicap
2025-07-13 06:59:30 +08:00
commit 86d84de7e3
165 changed files with 7941 additions and 0 deletions

28
lib/model/data_model.dart Normal file
View File

@ -0,0 +1,28 @@
import '../app/app.locator.dart';
import '../services/other_function.dart';
class DataModel {
final _myFunction = locator<OtherFunction>();
int? no;
String? waterHeight;
int? status;
String? createdAt;
DataModel({this.no, this.waterHeight, this.status, this.createdAt});
DataModel.fromJson(Map<String, dynamic> json) {
no = json['no'];
waterHeight = json['water_height'];
status = json['status'];
createdAt = _myFunction.formatDateString2(json['created_at']);
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['no'] = no;
data['water_height'] = waterHeight;
data['status'] = status;
data['created_at'] = createdAt;
return data;
}
}

View File

@ -0,0 +1,57 @@
import 'package:intl/intl.dart';
class OntDataModel {
final int idData;
final int id;
final DateTime waktu; // Use DateTime instead of String
final String status;
final String download;
final String upload;
OntDataModel({
required this.idData,
required this.id,
required this.waktu,
required this.status,
required this.download,
required this.upload,
});
// Factory constructor to create an instance from JSON
factory OntDataModel.fromJson(Map<String, dynamic> json) {
DateTime originalTime =
DateTime.parse(json['waktu'].toString()).toUtc(); // Ensure UTC
DateTime utcPlus8 =
originalTime.add(const Duration(hours: 8)); // Convert to UTC+8
return OntDataModel(
idData: json['id_data'] is int
? json['id_data']
: int.tryParse(json['id_data'].toString()) ?? 0,
id: json['id'] is int
? json['id']
: int.tryParse(json['id'].toString()) ?? 0,
waktu: utcPlus8, // Store UTC+8 time
status: json['status']?.toString() ?? 'Unknown',
download: json['download']?.toString() ?? '-',
upload: json['upload']?.toString() ?? '-',
);
}
// Method to return formatted UTC+8 date
String getFormattedDate() {
return DateFormat('yyyy-MM-dd HH:mm:ss').format(waktu);
}
// Convert back to UTC before saving to JSON
Map<String, dynamic> toJson() => {
'id_data': idData,
'id': id,
'waktu': waktu
.subtract(const Duration(hours: 8))
.toIso8601String(), // Convert back to original UTC
'status': status,
'download': download,
'upload': upload,
};
}

63
lib/model/ont_model.dart Normal file
View File

@ -0,0 +1,63 @@
import 'package:intl/intl.dart';
class OntModel {
int? id;
String? nama;
String? noInternet;
String? noHp;
String? alamat;
String? langganan;
String? download;
String? upload;
String? status;
DateTime? updated;
OntModel({
this.id,
this.nama,
this.noInternet,
this.noHp,
this.alamat,
this.langganan,
this.download,
this.upload,
this.status,
this.updated,
});
factory OntModel.fromJson(Map<String, dynamic> json) {
DateTime originalTime =
DateTime.parse(json['updated'].toString()).toUtc(); // Ensure UTC
DateTime utcPlus8 =
originalTime.add(const Duration(hours: 8)); // Convert to UTC+8
return OntModel(
id: json['id'] as int?,
nama: json['nama'] as String?,
noInternet: json['no_internet'] as String?,
noHp: json['no_hp'] as String?,
alamat: json['alamat'] as String?,
langganan: json['langganan'] as String?,
download: json['download'] as String?,
upload: json['upload'] as String?,
status: json['status'] as String?,
updated: utcPlus8,
);
}
String getFormattedDate() {
return DateFormat('yyyy-MM-dd HH:mm:ss').format(updated!);
}
Map<String, dynamic> toJson() => {
'id': id,
'nama': nama,
'no_internet': noInternet,
'no_hp': noHp,
'alamat': alamat,
'langganan': langganan,
'download': download,
'upload': upload,
'status': status,
'updated': updated?.toIso8601String(),
};
}