Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
2
2018_web_app
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
inutralia
2018_web_app
Commits
944d4390
Commit
944d4390
authored
Dec 04, 2018
by
David Villalba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
En proceso de guardar perfil ! WS put profile
parent
25f7a11d
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
121 additions
and
33 deletions
+121
-33
index.php
fuel/app/classes/controller/perfil/index.php
+10
-2
inutraliaWS.php
fuel/app/classes/trait/inutraliaWS.php
+41
-12
constants.php
fuel/app/config/development/constants.php
+3
-6
routes.php
fuel/app/config/routes.php
+12
-1
datos_generales.twig
fuel/app/views/perfil/datos_generales.twig
+9
-9
index.twig
fuel/app/views/perfil/index.twig
+2
-1
switches.twig
fuel/app/views/perfil/switches.twig
+2
-2
index.js
public/assets/js/perfil/index.js
+42
-0
No files found.
fuel/app/classes/controller/perfil/index.php
View file @
944d4390
...
...
@@ -23,7 +23,7 @@ class Controller_Perfil_Index extends \Controller_App{
public
function
before
(){
//Se cargan funciones de javascript especificas de esta funcionalidad
Casset
::
js
(
'
dashboard
/index.js'
);
Casset
::
js
(
'
perfil
/index.js'
);
//Se marca la navegación en forma de migas de pan. Cada miga de pan la forman dos variables:
// ds : String a mostrar
...
...
@@ -46,9 +46,16 @@ class Controller_Perfil_Index extends \Controller_App{
//Paso de las opciones de menu que deben aparecer seleccionadas
$view
->
option_menu
=
$this
->
_option_menu
;
$view
->
profile
=
$this
->
ws_profile
();
$view
->
profile
=
$this
->
ws_profile
_get
();
return
Response
::
forge
(
$view
);
}
public
function
post_update
(){
$this
->
ws_profile_put
(
\Input
::
post
(
'id'
),
\Input
::
post
(
'inputs'
));
}
}
\ No newline at end of file
fuel/app/classes/trait/inutraliaWS.php
View file @
944d4390
...
...
@@ -15,10 +15,11 @@ trait Trait_InutraliaWS {
public
function
get_header
(){
return
array
(
'Content-Type: application/json'
,
'Accept: application/json'
,
'Authorization: Basic '
.
\Session
::
get
(
'token_auth'
)
'Authorization: Basic '
.
\Session
::
get
(
'token_auth'
)
,
);
}
...
...
@@ -36,22 +37,27 @@ trait Trait_InutraliaWS {
* @return mixed
*/
public
function
request_generic
(
$
parameter_url
,
$header
=
false
,
$timeout
=
30
,
$httpget
=
true
,
$return_transfer
=
1
){
public
function
request_generic
(
$
url
,
$method
=
"get"
,
$return_transfer
=
1
,
$extra_options
=
array
(),
$add_params_header
=
array
()
){
$constant
=
\Config
::
load
(
'constants'
);
// La url la obtiene de config dependiendo del entorno.
$process
=
curl_init
(
$constant
[
$parameter_url
]);
$ch
=
curl_init
(
$constant
[
'domain'
]
.
$url
.
$constant
[
'apikey'
]);
curl_setopt
(
$ch
,
CURLOPT_HTTPHEADER
,
array_merge
(
$this
->
get_header
(),
$add_params_header
));
curl_setopt
(
$ch
,
$method
==
"get"
?
CURLOPT_HTTPGET
:
CURLOPT_POST
,
1
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
$return_transfer
);
foreach
(
$extra_options
as
$key
=>
$value
){
curl_setopt
(
$ch
,
$key
,
$value
);
}
curl_setopt
(
$process
,
CURLOPT_HTTPHEADER
,
$this
->
get_header
());
curl_setopt
(
$process
,
CURLOPT_HEADER
,
$header
);
curl_setopt
(
$process
,
CURLOPT_TIMEOUT
,
$timeout
);
curl_setopt
(
$process
,
CURLOPT_HTTPGET
,
$httpget
);
curl_setopt
(
$process
,
CURLOPT_RETURNTRANSFER
,
$return_transfer
);
$return
=
curl_exec
(
$
process
);
$return
=
curl_exec
(
$
ch
);
curl_close
(
$
process
);
curl_close
(
$
ch
);
return
$return
;
}
...
...
@@ -73,13 +79,35 @@ trait Trait_InutraliaWS {
}
/**
* Request get profile
* Reques profile get
*
* @param null $data
* @return mixed
*/
public
function
ws_profile
(){
public
function
ws_profile
_get
(){
return
json_decode
(
$this
->
request_generic
(
'profile'
));
}
/**
* Reques profile put
*
* @param $data
* @return mixed
*/
public
function
ws_profile_put
(
$id
,
$data
){
$data_json
=
http_build_query
(
$data
);
$extra_options
=
array
(
CURLOPT_CUSTOMREQUEST
=>
'put'
,
CURLOPT_POSTFIELDS
=>
$data_json
);
return
json_decode
(
$this
->
request_generic
(
'profile'
.
DS
.
$id
,
"post"
,
1
,
$extra_options
,
array
(
'Content-Length: '
.
strlen
(
$data_json
))));
}
}
\ No newline at end of file
fuel/app/config/development/constants.php
View file @
944d4390
...
...
@@ -29,15 +29,11 @@
const
DOMAIN
=
"http://inutralia20back"
;
const
V1
=
'/api/v1/'
;
const
APIKEY
=
"?api-key=7745289b-f09c-4e0b-89d1-bb59c599c85e"
;
// PARAMETERS
const
USER
=
'user'
;
const
PROFILE
=
'profile'
;
return
array
(
'
user'
=>
DOMAIN
.
V1
.
USER
.
APIKEY
,
'
profile'
=>
DOMAIN
.
V1
.
PROFILE
.
APIKEY
,
'
domain'
=>
DOMAIN
.
V1
,
'
apikey'
=>
"?api-key=7745289b-f09c-4e0b-89d1-bb59c599c85e"
);
\ No newline at end of file
fuel/app/config/routes.php
View file @
944d4390
...
...
@@ -25,17 +25,28 @@ return array(
/*HOME*/
'dashboard'
=>
'dashboard/index'
,
'perfil'
=>
'perfil/index'
,
// PERFIL
'perfil'
=>
'perfil/index'
,
'perfil/update'
=>
'perfil/index/update'
,
// MENU PERSONALIZADO
'menupersonalizado'
=>
'menupersonalizado/index'
,
// MENU SALUDABLES
'menussaludables'
=>
'menussaludables/lista/index'
,
'menussaludables-menu'
=>
'menussaludables/menu/index'
,
// RECETA
'receta-detalle'
=>
'receta/index'
,
// RECETARIO
'recetario'
=>
'recetario/index'
,
// BOLETIN SALUDABLE
'boletin-saludable'
=>
'boletinsaludable/index'
,
// ARTICULO
'articulo-detalle'
=>
'articulo/index'
,
...
...
fuel/app/views/perfil/datos_generales.twig
View file @
944d4390
<span
class=
"input input--nao"
>
<input
class=
"input__field input__field--nao
"
type=
"text"
id=
"edad"
name=
"edad
"
required=
""
value=
"
{{
profile.age
}}
"
/>
<label
class=
"input__label input__label--nao"
for=
"
input-1
"
>
<input
class=
"input__field input__field--nao
data-profile"
type=
"text"
id=
"age"
name=
"age
"
required=
""
value=
"
{{
profile.age
}}
"
/>
<label
class=
"input__label input__label--nao"
for=
"
age
"
>
<span
class=
"input__label-content input__label-content--nao"
>
Edad
</span>
</label>
<svg
class=
"graphic graphic--nao"
width=
"300%"
height=
"100%"
viewBox=
"0 0 1200 60"
preserveAspectRatio=
"none"
>
...
...
@@ -9,8 +9,8 @@
</span>
<span
class=
"input input--nao"
>
<input
class=
"input__field input__field--nao
"
type=
"text"
id=
"altura"
name=
"altura
"
required=
""
value=
"
{{
profile.height
}}
"
/>
<label
class=
"input__label input__label--nao"
for=
"
input-1
"
>
<input
class=
"input__field input__field--nao
data-profile"
type=
"text"
id=
"height"
name=
"height
"
required=
""
value=
"
{{
profile.height
}}
"
/>
<label
class=
"input__label input__label--nao"
for=
"
height
"
>
<span
class=
"input__label-content input__label-content--nao"
>
Altura
</span>
</label>
<svg
class=
"graphic graphic--nao"
width=
"300%"
height=
"100%"
viewBox=
"0 0 1200 60"
preserveAspectRatio=
"none"
>
...
...
@@ -19,8 +19,8 @@
</span>
<span
class=
"input input--nao"
>
<input
class=
"input__field input__field--nao
"
type=
"text"
id=
"peso"
name=
"peso
"
required=
""
value=
"
{{
profile.weight
}}
"
/>
<label
class=
"input__label input__label--nao"
for=
"
input-1
"
>
<input
class=
"input__field input__field--nao
data-profile"
type=
"text"
id=
"weight"
name=
"weight
"
required=
""
value=
"
{{
profile.weight
}}
"
/>
<label
class=
"input__label input__label--nao"
for=
"
weight
"
>
<span
class=
"input__label-content input__label-content--nao"
>
Peso
</span>
</label>
<svg
class=
"graphic graphic--nao"
width=
"300%"
height=
"100%"
viewBox=
"0 0 1200 60"
preserveAspectRatio=
"none"
>
...
...
@@ -28,7 +28,7 @@
</svg>
</span>
<select
class=
"cs-select cs-skin-underline mt20"
>
<select
class=
"cs-select cs-skin-underline mt20
data-profile"
id=
"gender
"
>
<option
value=
""
{%
if
(
profile.gender
==
''
)
%}
selected
{%
endif
%}
disabled
>
Género...
</option>
<option
value=
"1"
{%
if
(
profile.gender
==
'H'
)
%}
selected
{%
endif
%}
>
Hombre
</option>
...
...
@@ -36,7 +36,7 @@
</select>
<select
class=
"cs-select cs-skin-underline mt20
"
>
<select
class=
"cs-select cs-skin-underline mt20
data-profile"
id=
"physical"
>
<option
value=
""
{%
if
(
profile.physical
==
''
)
%}
selected
{%
endif
%}
disabled
>
Actividad fisica...
</option>
<option
value=
"1"
{%
if
(
profile.physical
==
'1'
)
%}
selected
{%
endif
%}
>
Sedentario
</option>
...
...
@@ -46,7 +46,7 @@
<option
value=
"5"
{%
if
(
profile.physical
==
'5'
)
%}
selected
{%
endif
%}
>
Muy Intenso
</option>
</select>
<select
class=
"cs-select cs-skin-underline mt20"
>
<select
class=
"cs-select cs-skin-underline mt20
data-profile"
id=
"preference
"
>
<option
value=
""
{%
if
profile.preference
==
""
%}
selected
{%
endif
%}
disabled
>
Preferencia de dieta...
</option>
<option
value=
"1"
{%
if
profile.preference
==
"1"
%}
selected
{%
endif
%}
>
Normal
</option>
<option
value=
"2"
{%
if
profile.preference
==
"2"
%}
selected
{%
endif
%}
>
Vegetariana
</option>
...
...
fuel/app/views/perfil/index.twig
View file @
944d4390
...
...
@@ -9,6 +9,7 @@
</div>
<div
class=
"container"
>
<input
type=
"hidden"
id=
"profile_id"
value=
"
{{
profile.id
}}
"
>
<div
class=
"row"
>
<div
class=
"col-md-4"
>
<div
class=
"solid-box bg-color-perfil pb50"
>
...
...
@@ -29,7 +30,7 @@
</div>
<div
class=
"row"
>
<div
class=
"col-md-4 col-md-offset-8"
>
<button
class=
"btn btn-custom btn-perfil mt20
"
><i
class=
"fa fa-save"
></i>
Guardar Perfil
</button>
<button
class=
"btn btn-custom btn-perfil mt20"
id=
"save-profile
"
><i
class=
"fa fa-save"
></i>
Guardar Perfil
</button>
</div>
</div>
...
...
fuel/app/views/perfil/switches.twig
View file @
944d4390
...
...
@@ -33,7 +33,7 @@
<div
class=
"col-md-4 col-lg-4 visible-md visible-lg"
>
<div
class=
"form-group text-center"
>
<label
class=
"switch"
for=
"
{{
key
}}
"
>
<input
type=
"checkbox"
id=
"
{{
key
}}
"
{%
if
attribute
(
profile
,
key
)
%}
checked
{%
endif
%}
/>
<input
type=
"checkbox"
class=
"data-profile"
id=
"
{{
key
}}
"
{%
if
attribute
(
profile
,
key
)
%}
checked
{%
endif
%}
/>
<div
class=
"slider round"
></div>
</label>
<p>
{{
value
}}
</p>
...
...
@@ -55,7 +55,7 @@
<div
class=
"col-xs-6 col-sm-6 visible-xs visible-sm"
>
<div
class=
"form-group text-center"
>
<label
class=
"switch"
for=
"
{{
key
}}
"
>
<input
type=
"checkbox"
id=
"
{{
key
}}
"
{%
if
attribute
(
profile
,
key
)
%}
checked
{%
endif
%}
/>
<input
type=
"checkbox"
class=
"data-profile"
id=
"
{{
key
}}
"
{%
if
attribute
(
profile
,
key
)
%}
checked
{%
endif
%}
/>
<div
class=
"slider round"
></div>
</label>
<p>
{{
value
}}
</p>
...
...
public/assets/js/perfil/index.js
0 → 100644
View file @
944d4390
$
(
document
).
ready
(
function
()
{
$
(
'#save-profile'
).
on
(
'click'
,
function
()
{
var
inputs
=
{};
$
(
'.data-profile'
).
map
(
function
()
{
if
(
typeof
$
(
this
).
attr
(
'id'
)
!==
"undefined"
){
inputs
[
$
(
this
).
attr
(
'id'
)]
=
$
(
this
).
attr
(
'type'
)
===
"checkbox"
?
$
(
this
).
is
(
':checked'
)
:
$
(
this
).
val
();
}
});
$
.
ajax
({
url
:
"perfil/update"
,
type
:
"POST"
,
method
:
"post"
,
data
:
{
id
:
$
(
'#profile_id'
).
val
(),
inputs
:
inputs
},
success
:
function
(
data
)
{
console
.
log
(
data
);
},
error
:
function
(
data
)
{
console
.
log
(
data
);
}
})
})
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment