import 'package:fikoyt_ui/core/fiko_request.dart'; import 'package:fikoyt_ui/core/fikoyt_request_manager/fikoyt_request_engine.dart'; import 'package:fikoyt_ui/core/fikoyt_request_manager/fikoyt_request_queue.dart'; import 'package:fikoyt_ui/fikoyt_ui.dart'; import 'package:flutter/widgets.dart'; import 'package:get/get.dart'; class KullaniciService extends GetxService { Rx toplamlar = Rx({ "kullanici": 0, "aktif_kullanici": 0, "deaktif_kullanici": 0, "sistem_kullanici": 0, "soket_sayisi": 0, }); RxList kullanicilar = RxList([]); /** */ /** */ late FikoYTRequestEngine> listeIstek; late FikoYTRequestEngine> toplamlarIstek; late FikoYTRequestEngine ekleIstek; late FikoYTRequestEngine silIstek; @override void onInit() { listeIstek = FikoYTRequestEngine>( command: "/uyar/admin/kullanicilar/liste", parameters: {"x": 1}, retryCount: 2, onEkOlsun: false, autoIsBusy: false, ) .onStart((self) { self.isBusy.value = true; // print("🚀 İşlem baslatıldı"); }) // .onProgress((e) => print("⏳ ${e.requestProgress?.percent}%")) .onResult((self, e) { kullanicilar.value = e.result; // print("✅ Veri Geldi: ${e.result}"); }) // .onError((e) => print("❌ Hatalar: ${e.list.map((x) => x.message).join(", ")}")) .onDone((self) async { await Future.delayed(Duration(seconds: 1)); self.isBusy.value = false; // print("🏁 İşlem tamam"); }); toplamlarIstek = FikoYTRequestEngine>( command: "/uyar/admin/kullanicilar/toplamlar", parameters: {"x": 1}, retryCount: 2, onEkOlsun: false, autoIsBusy: false, ) .onStart((self) { self.isBusy.value = true; // print("🚀 İşlem baslatıldı"); }) // .onProgress((e) => print("⏳ ${e.requestProgress?.percent}%")) .onResult((self, e) { toplamlar.value = e.result; // print("✅ Veri Geldi: ${e.result}"); }) // .onError((e) => print("❌ Hatalar: ${e.list.map((x) => x.message).join(", ")}")) .onDone((self) async { await Future.delayed(Duration(seconds: 1)); self.isBusy.value = false; // print("🏁 İşlem tamam"); }); ekleIstek = FikoYTRequestEngine>( command: "/uyar/admin/kullanicilar/ekle", // parameters: {"x": 1}, retryCount: 2, onEkOlsun: false, autoIsBusy: false, ) .onStart((self) { self.isBusy.value = true; // print("🚀 İşlem baslatıldı"); }) // .onProgress((e) => print("⏳ ${e.requestProgress?.percent}%")) .onResult((self, e) { // kullanicilar.value = e.result; // print("✅ Veri Geldi: ${e.result}"); toastification.show( context: FikoYTCoreService.navigatorKey.currentContext, type: ToastificationType.success, style: ToastificationStyle.fillColored, // title: Text("FikoYT Sistem"), description: Text("Üye Tanımlaması Başarılı Şekilde Gerçekleşmiştir."), alignment: Alignment.topRight, margin: EdgeInsets.only(top: 32, right: 20), autoCloseDuration: const Duration(seconds: 4), borderRadius: BorderRadius.circular(4.0), // boxShadow: lowModeShadow, showProgressBar: false, dragToClose: true, applyBlurEffect: true, ); }) // .onError((e) => print("❌ Hatalar: ${e.list.map((x) => x.message).join(", ")}")) .onDone((self) async { await Future.delayed(Duration(seconds: 1)); self.isBusy.value = false; }) .onError((self, e) async { await Future.delayed(Duration(seconds: 1)); self.isBusy.value = false; toastification.show( context: FikoYTCoreService.navigatorKey.currentContext, type: ToastificationType.error, style: ToastificationStyle.fillColored, // title: Text("FikoYT Sistem"), description: Text(e.list.map((x) => x.message).join("\t\n")), alignment: Alignment.topRight, margin: EdgeInsets.only(top: 32, right: 20), autoCloseDuration: const Duration(seconds: 4), borderRadius: BorderRadius.circular(4.0), // boxShadow: lowModeShadow, showProgressBar: false, dragToClose: true, applyBlurEffect: true, ); // print("❌ Hatalar: ${e.list.map((x) => x.message).join(", ")}"); }); silIstek = FikoYTRequestEngine>( command: "/uyar/admin/kullanicilar/sil", // parameters: {"x": 1}, retryCount: 2, onEkOlsun: false, autoIsBusy: false, ) .onStart((self) { self.isBusy.value = true; // print("🚀 İşlem baslatıldı"); }) // .onProgress((e) => print("⏳ ${e.requestProgress?.percent}%")) .onResult((self, e) { // kullanicilar.value = e.result; print("✅ Veri Geldi: ${e.result}"); toastification.show( context: FikoYTCoreService.navigatorKey.currentContext, type: ToastificationType.success, style: ToastificationStyle.fillColored, // title: Text("FikoYT Sistem"), description: Text("Üye Tanımlaması Başarılı Şekilde Gerçekleşmiştir."), alignment: Alignment.topRight, margin: EdgeInsets.only(top: 32, right: 20), autoCloseDuration: const Duration(seconds: 4), borderRadius: BorderRadius.circular(4.0), // boxShadow: lowModeShadow, showProgressBar: false, dragToClose: true, applyBlurEffect: true, ); }) // .onError((e) => print("❌ Hatalar: ${e.list.map((x) => x.message).join(", ")}")) .onDone((self) async { await Future.delayed(Duration(seconds: 1)); self.isBusy.value = false; }) .onError((self, e) async { await Future.delayed(Duration(seconds: 1)); self.isBusy.value = false; toastification.show( context: FikoYTCoreService.navigatorKey.currentContext, type: ToastificationType.error, style: ToastificationStyle.fillColored, // title: Text("FikoYT Sistem"), description: Text(e.list.map((x) => x.message).join("\t\n")), alignment: Alignment.topRight, margin: EdgeInsets.only(top: 32, right: 20), autoCloseDuration: const Duration(seconds: 4), borderRadius: BorderRadius.circular(4.0), // boxShadow: lowModeShadow, showProgressBar: false, dragToClose: true, applyBlurEffect: true, ); // print("❌ Hatalar: ${e.list.map((x) => x.message).join(", ")}"); }); super.onInit(); } toplamlariAl() async { toplamlarIstek.start(); } kullanicilariAl() async { listeIstek.startWithQueue(tag: "kullanicilarListe", priority: 10); // listeIstek.start(); // veya queue için: FikoYTRequestQueue().enqueue(() => ...start()); /** */ } }