Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
David Solanas authored and David Solanas committed May 30, 2019
2 parents 6f9f784 + a75e878 commit 23acf92
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 51 deletions.
11 changes: 8 additions & 3 deletions app/src/components/AdministradorCrear.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -573,9 +573,14 @@ class AdministradorCrear extends Component {
if (uni !== -1) {
const subj = this.nombreAsig.current.value;
const shortname = this.nombreCortoAsig.current.value;
crearAsigYLigar(this.SubjectApi, subj, shortname, uni);
form.reset();
this.handleShow();
crearAsigYLigar(
this.SubjectApi,
subj,
shortname,
uni,
form,
this.handleShow
);
}
}
/**
Expand Down
24 changes: 5 additions & 19 deletions app/src/components/Perfil.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ class CamposMostrar extends Component {
render() {
return (
<div>
{this.renderCampo("Usuario:", this.props.username)}
{this.renderCampo("Universidad:", this.props.uni)}
{this.renderCampo("Grado:", this.props.degree)}
<div>
<h6
style={{
Expand All @@ -77,8 +80,6 @@ class CamposMostrar extends Component {
</div>
</div>
<br />
{this.renderCampo("Universidad:", this.props.uni)}
{this.renderCampo("Grado:", this.props.degree)}
</div>
);
}
Expand Down Expand Up @@ -258,27 +259,12 @@ class Perfil extends Component {
a
</div>
)}

<div
style={{
padding: "40px 20px 0px 0px"
}}
>
<h6
style={{
float: "left",
padding: "0 20px 0 0"
}}
>
<strong>Nombre de usuario:</strong>
</h6>
<p>{this.state.user.username}</p>
</div>
</div>
</div>
</div>
<div style={{ marginTop: "80px" }}>
<div style={{ marginTop: "150px" }}>
<CamposMostrar
username={this.state.user.username}
description={this.state.user.description}
uni={this.state.uni.name}
degree={this.state.degree.name}
Expand Down
38 changes: 14 additions & 24 deletions app/src/components/Profesor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,19 @@ class CamposMostrar extends Component {
) : (
<div>
<div>
{this.renderCampo("Usuario:", this.props.username)}
<br />
<h6
style={{
float: "left"
}}
>
<strong>Descripción:</strong>
</h6>
<div
style={{
margin: "40px 40% 0 120px"
}}
>
<h6 style={{ textAlign: "justify" }}>{this.props.description}</h6>
</div>

<h6 style={{ textAlign: "justify", margin: "0 40% 0 120px" }}>
{this.props.description}
</h6>
<br />
</div>
{this.renderCampo("Universidad:", this.props.uni)}
Expand Down Expand Up @@ -387,26 +386,17 @@ class Profesor extends Component {
this.state.esProfe
? null
: this.renderButton(this.state.esProfe)}

<div
style={{
padding: "40px 20px 0px 0px"
}}
>
<h6
style={{
float: "left",
padding: "0 20px 0 0"
}}
>
<strong>Nombre de usuario:</strong>
</h6>
<p>{user_nom}</p>
</div>
</div>
</div>
<br />
<CamposMostrar description={descr} uni={uni} degree={degree} />
<div style={{ marginTop: "150px" }}>
<CamposMostrar
description={descr}
uni={uni}
degree={degree}
username={user_nom}
/>
</div>
<AsignaturasProf sub={this.state.sub} />
</div>
)}
Expand Down
4 changes: 2 additions & 2 deletions app/src/components/SubirVideo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const FormularioDatos = (
<Form.Group controlId="formGridMiniatura">
<Form.Label className={img_valida === 0 ? "text-danger" : ""}>
{img_valida === 0
? "Introduzca un formato de imagen válido"
? "Introduzca un formato de imagen válido y seleccione Confirmar"
: "Miniatura del video"}
</Form.Label>
<Form.Control type="file" accept="image/*" ref={miniatura} required />
Expand All @@ -128,7 +128,7 @@ const FormularioDatos = (
<Form.Group controlId="formGridVideo">
<Form.Label className={video_valido === 0 ? "text-danger" : ""}>
{video_valido === 0
? "Introduzca un formato de imagen válido"
? "Introduzca un formato de vídeo válido y seleccione Confirmar"
: "Vídeo"}
</Form.Label>
<Form.Control type="file" accept="video/*" ref={video} required />
Expand Down
14 changes: 11 additions & 3 deletions app/src/config/AdminAPI.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,14 @@ function ligarUniCarr(uniID, carreraID, DegreeApi) {
* @param {String} shortname Nombre abreviado de la asignatura
* @param {Number} uni ID de la universidad
*/
export function crearAsigYLigar(SubjectApi, subject, shortname, uni) {
export function crearAsigYLigar(
SubjectApi,
subject,
shortname,
uni,
form,
handleShow
) {
// Configure Bearer (JWT) access token for authorization: bearerAuth
let bearerAuth = defaultClient.authentications["bearerAuth"];
bearerAuth.accessToken = getUserToken();
Expand All @@ -273,7 +280,6 @@ export function crearAsigYLigar(SubjectApi, subject, shortname, uni) {
if (error) {
console.error(error);
} else {
console.log(data);
data._embedded.subjects.forEach(element => {
if (element.university !== undefined && element.university.id === uni) {
encontrado = true;
Expand All @@ -283,6 +289,7 @@ export function crearAsigYLigar(SubjectApi, subject, shortname, uni) {
}
if (encontrado) {
alert("La asignatura ya existía para esa universidad");
form.reset();
} else {
let subject2 = new Subject2(subject, shortname.substr(0, 5)); // Subject2 | Asignatura a añadir
SubjectApi.addSubject(subject2, (error, data, response) => {
Expand All @@ -300,7 +307,6 @@ export function crearAsigYLigar(SubjectApi, subject, shortname, uni) {
if (error) {
console.error(error);
} else {
console.log(data);
let id = 0;
data._embedded.subjects.forEach(element => {
if (element.university === undefined) {
Expand All @@ -314,6 +320,8 @@ export function crearAsigYLigar(SubjectApi, subject, shortname, uni) {
ligarUniAsig(uni, data.id, SubjectApi);
}
});
form.reset();
handleShow();
}
});
}
Expand Down

0 comments on commit 23acf92

Please sign in to comment.