consulta.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <script type="text/javascript" src="https://unpkg.com/@ant-design/graphs@latest/dist/graphs.min.js"></script>
  2. <style>
  3. .site-card {
  4. min-height: 100vh;
  5. width: 100%;
  6. padding: 20px;
  7. background: #ececec;
  8. }
  9. .content {
  10. width: 100%;
  11. }
  12. .grid {
  13. width: 25%;
  14. text-align: center;
  15. }
  16. .full-width {
  17. width: 100%;
  18. }
  19. </style>
  20. <script type="text/babel">
  21. const url = "https://descarga.fourier.audio";
  22. const { LoadingOutlined } = window.icons;
  23. const { Card, Form, Input, Row, Col, Button, DatePicker, Spin, Table } = window.antd;
  24. const { RangePicker } = DatePicker;
  25. const App = () => {
  26. const [cargando, setCargando] = React.useState(false);
  27. const [descargas, setDescargas] = React.useState([]);
  28. const [inicio, setInicio] = React.useState(null);
  29. const [form] = Form.useForm();
  30. const onFinish = async (data) => {
  31. setCargando(true);
  32. const idPc = data.idPc;
  33. const estacion = data.estacion || "";
  34. const fi = data.fechas[0].format("YYYY-MM-DD HH:mm:ss");
  35. const ff = data.fechas[1].format("YYYY-MM-DD HH:mm:ss");
  36. const resp = await fetch(`${url}/descarga/por-pc?pc=${idPc}&fi=${fi}&ff=${ff}&estacion=${estacion}`);
  37. const res = await resp.json();
  38. setDescargas(res.resultado);
  39. setCargando(false);
  40. }
  41. let onCalendarChange = (mf, f, r) => {
  42. if(r.range === "start") {
  43. setInicio(mf[0]);
  44. }
  45. }
  46. let disabledDate = (current) => {
  47. if(inicio === null) {
  48. return false;
  49. } else {
  50. let disabled = current < inicio.add(7, 'days')
  51. console.log(!disabled, current, inicio.add(7, 'days'))
  52. return !disabled;
  53. }
  54. }
  55. const columnas = [
  56. {
  57. title: 'Estación',
  58. dataIndex: 'clave',
  59. key: '1',
  60. },
  61. {
  62. title: 'Fecha',
  63. dataIndex: 'fecha',
  64. key: '2',
  65. },
  66. {
  67. title: 'Descargas',
  68. key: '3',
  69. render(r) {
  70. return (<div>{r.descargados}/{r.pendientes + r.descargados}</div>)
  71. }
  72. }
  73. ];
  74. return (
  75. <div className="site-card">
  76. <Card className="content">
  77. <Form
  78. form={form}
  79. layout="vertical"
  80. onFinish={onFinish}
  81. >
  82. <Row gutter={8}>
  83. <Col span={6}>
  84. <Form.Item
  85. label="ID PC"
  86. name="idPc"
  87. rules={[{ required: true, message: 'Ingresa el ID del PC' }]}
  88. >
  89. <Input placeholder="ID del anydesk" size="large" />
  90. </Form.Item>
  91. </Col>
  92. <Col span={6}>
  93. <Form.Item
  94. label="Estación"
  95. name="estacion"
  96. rules={[{ required: false }]}
  97. >
  98. <Input placeholder="Clave de la Estación (opcional)" size="large" />
  99. </Form.Item>
  100. </Col>
  101. <Col span={6}>
  102. <Form.Item
  103. label="Fechas"
  104. name="fechas"
  105. rules={[{ required: true, message: 'Ingresa el Rango de Fechas' }]}
  106. >
  107. <RangePicker
  108. showTime={{
  109. hideDisabledOptions: true,
  110. defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')],
  111. }}
  112. format="DD-MM-YYYY HH:mm:ss"
  113. size="large"
  114. />
  115. </Form.Item>
  116. </Col>
  117. <Col span={6}>
  118. <Form.Item label="&nbsp;" >
  119. <Button type="primary" htmlType="submit" size="large">Consultar</Button>
  120. </Form.Item>
  121. </Col>
  122. </Row>
  123. </Form>
  124. { cargando && <Row>
  125. <Col>
  126. <LoadingOutlined style={{ fontSize: 24 }} spin />
  127. </Col>
  128. </Row>}
  129. <Row>
  130. <Col span={16}>
  131. <Table className="full-width" dataSource={descargas} columns={columnas} />
  132. </Col>
  133. </Row>
  134. </Card>
  135. </div>
  136. );
  137. }
  138. ReactDOM.render(<App />, document.getElementById('root'));
  139. </script>