This commit is contained in:
2023-08-08 08:28:09 +05:30
commit 30f30966a3
131 changed files with 5212 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:queue_mgr/backend/DebugHelper.dart';
// DateFormat dateFormat;
final String API_ENDPOINT= "https://vps.playpoolstudios.com/qms/api/";
class DataManager{
static _DataManager? m_instance = null;
static _DataManager instance(){
m_instance ??= _DataManager();
return m_instance!;
}
}
class _DataManager{
_DataManager();
List<dynamic> services = [];
Future<void> GetData() async{
try{
var response = (await http.post(
Uri.parse('${API_ENDPOINT}get_services.php'),
body: <String, String>{}));
Debug.LogResponse(response.body.toString());
services = jsonDecode(response.body.toString());
Debug.LogResponse(services);
}catch(e){
Debug.LogError(e);
}
}
Future<void> AddService(String name, DateTime sTime, DateTime eTime,TimeOfDay duration) async {
try{
var response = (await http.post(
Uri.parse('${API_ENDPOINT}add_service.php'),
body: <String, String>{
'name':name,
'stime':sTime.toString(),
'etime':eTime.toString(),
'duration':"${duration.hour}:${duration.minute}"
}));
Debug.LogResponse(response.body.toString());
services = jsonDecode(response.body.toString());
Debug.LogResponse(services);
}catch(e){
Debug.LogError(e);
}
}
}

View File

@@ -0,0 +1,32 @@
import 'dart:developer';
class Debug{
static bool enableLogging = true;
static bool enableResponseLogging = true;
static bool enableErrorLoggin = true;
static bool enableTestLogging = true;
static void LogResponse(Object? response, {Object src= ''}){
if(!enableLogging){return;}
if(!enableResponseLogging) {return;}
print('\x1B[32m$src response\n$response\x1B[0m');
}
static void LogError(Object? msg){
if(!enableLogging){return;}
if(!enableErrorLoggin) {return;}
print('\x1B[31m$msg\x1B[0m');
}
static void Log(Object? msg){
if(!enableLogging) {return;}
print('\x1B[36m$msg\x1B[0m');
}
static void LogTest(Object? msg){
if(!enableLogging){return;}
if(!enableTestLogging) {return;}
print('\x1B[35m$msg\x1B[0m');
}
}