Skip to content

Commit fac8a8d

Browse files
committed
minor adds
1 parent 91c22f0 commit fac8a8d

File tree

3 files changed

+77
-27
lines changed

3 files changed

+77
-27
lines changed

back/upload/output.txt

-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
[ 5 1 6 3 4 2 7 8 ]Costo: 770
2-
----------
3-
==========

back/upload/temp.dzn

+25-10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
1-
ACTORES = {Actor1, Actor2, Actor3, Actor4, Actor5, Actor6, Actor7} ;
2-
3-
Escenas = [| 0,1,0,0,0,0,1,0,10
4-
| 0,1,1,1,0,1,1,1,20
5-
| 1,1,1,1,0,1,0,0,5
6-
| 0,1,1,1,0,0,1,1,5
7-
| 1,0,0,0,1,1,0,0,15
8-
| 1,0,0,0,1,0,1,1,10
9-
| 1,1,0,1,0,1,1,0,10|];
1+
ACTORES = {Actor1, Actor2, Actor3, Actor4} ;
2+
3+
Escenas = [| 0,1,0,0,0,0,1,10
4+
| 0,1,1,1,0,1,1,20
5+
| 1,1,1,1,0,1,0,5
6+
| 1,0,0,0,1,1,0,15|];
107

11-
Duracion = [2,1,1,1,3,4,2,3];
8+
Duracion = [2,1,1,1,3,4,2];
9+
10+
11+
Disponibilidad =[|Actor1, 8
12+
|Actor2, 9
13+
|Actor3, 0
14+
|Actor4, 10|];
15+
16+
Evitar =[|Actor1, Actor2
17+
|Actor2, Actor3|];
18+
19+
%Ejecución con Gecode
20+
21+
% Orden de las Escenas: [5, 1, 6, 3, 4, 2, 7]
22+
% Costo: 390
23+
% Tiempo Compartido: 10
24+
% ----------
25+
% ==========
26+
% Finished in 164msec

front-minizinc/src/App.js

+52-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import './App.css';
3-
import { Modal, Button, CardDeck, Card, Form } from 'react-bootstrap';
3+
import { Modal, Button, CardDeck, Card, Form, Alert } from 'react-bootstrap';
44
import axios from 'axios';
55

66
const backColor = {
@@ -15,46 +15,80 @@ class App extends React.Component {
1515
model: -1,
1616
data: 'No hay informacion',
1717
dznfile: null,
18+
escenas: [],
1819
}
1920
this.dznfile = this.dznfile.bind(this);
2021
this.execute = this.execute.bind(this);
22+
this.formatdata = this.formatdata.bind(this);
23+
}
24+
formatdata = (text) => {
25+
this.setState({data: ""});
26+
var result = "";
27+
var all = text.split("\n");
28+
if (all[0].includes("ACTORES =")) {
29+
const actores = all[0].split(",").length;
30+
result += "Actores: " + actores + ", ";
31+
/*var index = all.indexOf(all.find(res => res.includes("Escenas =")));
32+
for (var i=index; i<index+actores; i++ ){
33+
result += all[i] + "\n";
34+
} */
35+
var disponibilidad = all.find(res => res.includes("Disponibilidad ="));
36+
var evitar = all.find(res => res.includes("Evitar ="));
37+
if (( typeof disponibilidad !== "undefined" ) && ( typeof evitar !== "undefined" )){
38+
result += "Deberias usar el Modelo 2\n";
39+
}else{
40+
result += "Deberias usar el Modelo 1\n";
41+
}
42+
}else{
43+
result= "No hay información";
44+
}
45+
console.log(result);
46+
return result;
2147
}
2248
dznfile = (event) => {
2349
event.preventDefault();
2450
let file = event.target.files[0];
2551
this.setState({ 'dznfile': file })
52+
const reader = new FileReader();
53+
reader.onload = async (e) => {
54+
const text = reader.result;
55+
const inf = this.formatdata(text);
56+
console.log(inf);
57+
this.setState({ data: inf });
58+
};
59+
reader.readAsText(event.target.files[0]);
2660

2761
}
2862
execute = () => {
29-
if (this.state.model === -1) {
30-
alert("No se ha escogido un modelo")
63+
if (this.state.model === -1 || this.state.dznfile === null) {
64+
alert("No se ha escogido un modelo o un archivo")
3165
} else {
3266
const data = new FormData();
3367
data.append('dznfile', this.state.dznfile);
3468
axios({
3569
url: 'http://localhost:5000/dzn',
3670
method: 'POST',
3771
data: data,
38-
params: { model : this.state.model },
72+
params: { model: this.state.model },
3973
config: { headers: { 'Content-Type': 'multipart/form-data' } }
4074
}).then((response) => {
41-
if(response.data === ""){
75+
if (response.data === "") {
4276
alert("Se ha producido un error. Es posible que la causa sea la selección de un modelo incorrecto");
43-
}else{
44-
this.setState({ r: response.data })
45-
}}
77+
} else {
78+
const result = response.data;
79+
this.setState({ r: result.substring(0,result.length - 22) });
80+
}
81+
}
4682
).catch((error) => alert("Se ha producido un error. Es posible que la causa sea la selección de un modelo incorrecto"))
4783
}
4884

4985
}
5086
clean = (event) => {
5187
event.preventDefault();
52-
this.setState({ r: '', dznfile: null });
88+
this.setState({ r: '', dznfile: null, model: -1, data: "No hay información" });
5389
}
5490
setModel = (data) => {
55-
console.log(data)
5691
this.setState({ model: data });
57-
console.log(this.state.model)
5892
}
5993
render() {
6094
return (
@@ -71,9 +105,8 @@ class App extends React.Component {
71105
<Modal.Body>
72106
<CardDeck>
73107
<Card>
74-
<h5>Carga tu archivo de dzn</h5>
108+
<h5>Carga tu archivo dzn</h5>
75109
<input name="dzn" type="file" onChange={this.dznfile} />
76-
{/*<p>{this.state.data}</p>*/}
77110
<Form.Check
78111
type="radio"
79112
label="Modelo 1"
@@ -88,9 +121,14 @@ class App extends React.Component {
88121
id="Modelo2"
89122
onClick={() => this.setModel(1)}
90123
/>
124+
<br></br>
91125
<Button onClick={this.execute} variant="primary">
92126
Enviar
93-
</Button>
127+
</Button>
128+
129+
<Alert variant={"info"}>
130+
{this.state.data}
131+
</Alert>
94132
</Card>
95133
<Card>
96134
{this.state.r}

0 commit comments

Comments
 (0)