254 lines
8.8 KiB
Dart
254 lines
8.8 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:educa_controle_acesso/models/log_model.dart';
|
|
import 'package:educa_controle_acesso/utils/fixos.dart';
|
|
import 'package:educa_controle_acesso/widgets/item_log.dart';
|
|
import 'package:flutter/material.dart';
|
|
import '../controllers/main_controllers.dart';
|
|
import '../utils/colors.dart';
|
|
import '../widgets/buttom_custom.dart';
|
|
import '../widgets/input_text.dart';
|
|
import '../widgets/snackBars.dart';
|
|
import '../widgets/text_custom.dart';
|
|
import 'package:http/http.dart' as http;
|
|
|
|
class LogScreen extends StatefulWidget {
|
|
List dados;
|
|
|
|
LogScreen({
|
|
required this.dados
|
|
});
|
|
|
|
@override
|
|
State<LogScreen> createState() => _LogScreenState();
|
|
}
|
|
|
|
class _LogScreenState extends State<LogScreen> {
|
|
|
|
var inputPesquisa = TextEditingController();
|
|
bool buscandoDados = false;
|
|
List <LogModel> logs = [];
|
|
String? selectApp;
|
|
|
|
getLogsDB()async{
|
|
logs.clear();
|
|
if(selectApp!=null){
|
|
String nome = inputPesquisa.text.replaceAll(' ', '%20').toUpperCase();
|
|
final url = '${widget.dados[2]}/buscarlogs?USUARIO=$nome&CIDADE=${widget.dados[0]}&SISTEMA=${selectApp}';
|
|
print(url);
|
|
final response = await http.get(Uri.parse(url));
|
|
var map = json.decode(response.body);
|
|
// print(map);
|
|
List list = map;
|
|
if(list.length!=0){
|
|
for(int i=0;list.length>i;i++){
|
|
// if(list[i]['NO_USERNAME']!='ADMIN'){
|
|
logs.add(
|
|
LogModel(
|
|
NRO_LOG: list[i]['NRO_LOG'],
|
|
DATA:list[i]['DATA'],
|
|
TELA: list[i]['TELA'],
|
|
CD_USUARIO: list[i]['CD_USUARIO'],
|
|
NO_USUARIO: list[i]['NO_USUARIO'],
|
|
SISTEMA: list[i]['SISTEMA'],
|
|
CIDADE: list[i]['CIDADE'],
|
|
)
|
|
);
|
|
// }
|
|
}
|
|
}else{
|
|
showSnackBar(context, 'NENHUM DADO ENCONTRADO!', Colors.red);
|
|
}
|
|
}else{
|
|
showSnackBar(context, 'SELECIONE QUAL APP DESEJA PESQUISAR!', Colors.red);
|
|
}
|
|
setState(() {
|
|
buscandoDados = false;
|
|
});
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
MainControllers().salvarLog('DADOS LOG',widget.dados);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
|
|
double width = MediaQuery.of(context).size.width;
|
|
double height = MediaQuery.of(context).size.height;
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Row(
|
|
children: [
|
|
Container(
|
|
child: Image.asset("assets/images/logoEduca.png",width:width * 0.08,height: height * 0.12)
|
|
),
|
|
TextCustom(text: ' - LOGS',color: Colors.white,),
|
|
Spacer(),
|
|
SizedBox(width: width * 0.02),
|
|
Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
TextCustom(text: widget.dados[0]==null?'':widget.dados[0],color: Colors.white,),
|
|
TextCustom(text:widget.dados[1]==null?'':widget.dados[1].toString().toUpperCase(),color: Colors.white,),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
backgroundColor: PaletteColors.grey,
|
|
),
|
|
body: ListView(
|
|
children: [
|
|
Container(
|
|
margin: EdgeInsets.symmetric(horizontal: width*0.08),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
Container(
|
|
height: 35,
|
|
width: 70,
|
|
alignment: Alignment.center,
|
|
child: TextCustom(text: 'BUSCAR',color: Colors.black,size: 12.0),
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.only(topLeft: Radius.circular(3.0),bottomLeft: Radius.circular(3.0),),
|
|
color: PaletteColors.greySearch,
|
|
border: Border.all(color: PaletteColors.grey)
|
|
),
|
|
),
|
|
InputText(
|
|
borderRadius: 0,
|
|
hint: 'Pesquisar por login do usuário'.toUpperCase(),
|
|
controller: inputPesquisa,
|
|
width: width*0.71,
|
|
inputFormatters: [],
|
|
fontSize: 14,
|
|
colorBackground: Colors.white,
|
|
),
|
|
ButtonCustom(
|
|
borderRadiusbottomLeft: 0,
|
|
borderRadiustopLeft: 0,
|
|
borderRadiusbottomRight: 0,
|
|
borderRadiustopRight: 0,
|
|
widthCustom: 0.05,
|
|
text: "PESQUISAR",
|
|
fontSize: 10.0,
|
|
colorText: PaletteColors.white,
|
|
colorButton: PaletteColors.green,
|
|
colorBorder: PaletteColors.green,
|
|
onPressed: (){
|
|
if(inputPesquisa.text.isNotEmpty){
|
|
setState(() {
|
|
buscandoDados = true;
|
|
});
|
|
getLogsDB();
|
|
}else{
|
|
showSnackBar(context, 'Digite alguma informação para pesquisar', Colors.red);
|
|
}
|
|
},
|
|
),
|
|
ButtonCustom(
|
|
borderRadiusbottomLeft: 0,
|
|
borderRadiustopLeft: 0,
|
|
widthCustom: 0.05,
|
|
text: "LIMPAR",
|
|
fontSize: 10.0,
|
|
colorText: PaletteColors.white,
|
|
colorButton: PaletteColors.grey,
|
|
colorBorder: PaletteColors.grey,
|
|
onPressed: ()=>setState((){
|
|
inputPesquisa.clear();
|
|
// resultadoPesquisa.clear();
|
|
// alunos.clear();
|
|
}),
|
|
)
|
|
],
|
|
)
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.symmetric(horizontal: width>900?width*0.08:width*0.05,vertical: 5),
|
|
padding: EdgeInsets.symmetric(horizontal: 5,vertical: 1),
|
|
child: Row(
|
|
children: [
|
|
Container(
|
|
width: width*0.05,
|
|
child: TextCustom(text: 'NRO LOG')
|
|
),
|
|
Container(
|
|
width: width*0.08,
|
|
child: TextCustom(text: 'DATA')
|
|
),
|
|
Container(
|
|
width: width*0.1,
|
|
child: TextCustom(text: 'CÓDIGO USUARIO'),
|
|
),
|
|
Container(
|
|
width: width*0.15,
|
|
child:
|
|
TextCustom(text: 'NOME USUÁRIO'),
|
|
),
|
|
Container(
|
|
width: width*0.1,
|
|
child:
|
|
TextCustom(text: 'APP/WEB'),
|
|
),
|
|
Container(
|
|
width: width*0.1,
|
|
child:
|
|
TextCustom(text: 'CIDADE'),
|
|
),
|
|
Container(
|
|
width: width*0.07,
|
|
child:
|
|
TextCustom(text: 'TELA/AÇÃO'),
|
|
),
|
|
Spacer(),
|
|
Container(
|
|
padding: EdgeInsets.symmetric(horizontal: 5),
|
|
color: PaletteColors.lightGrey,
|
|
child: DropdownButtonHideUnderline(
|
|
child: DropdownButton(
|
|
hint: TextCustom(text: 'QUAL APP DESEJA EXIBIR?'),
|
|
value: selectApp,
|
|
items: Fixos().itensApp.map((value) => DropdownMenuItem(
|
|
value: value,
|
|
child: TextCustom(
|
|
text: value,
|
|
color: Colors.black54,
|
|
),
|
|
)
|
|
).toList(),
|
|
onChanged: (value){
|
|
setState(() {
|
|
selectApp = value.toString();
|
|
logs.clear();
|
|
});
|
|
},
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
border: Border.all(color: logs.length==0?Colors.white:PaletteColors.grey)
|
|
),
|
|
margin: EdgeInsets.symmetric(horizontal: width>900?width*0.08:width*0.05),
|
|
height: height*0.7,
|
|
child: ListView.builder(
|
|
itemCount: logs.length,
|
|
itemBuilder: (context,index){
|
|
return ItemLog(logs: logs[index]);
|
|
},
|
|
),
|
|
)
|
|
],
|
|
)
|
|
);
|
|
}
|
|
}
|