consulta.php 4.2 KB

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