Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ACS
Public
VILLASframework
VILLASweb
Commits
bfab0be2
Commit
bfab0be2
authored
Nov 05, 2019
by
Laura Fuentes Grau
Browse files
wip
#210
added query parameter 'param'
parent
b801a509
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/common/api/rest-api.js
View file @
bfab0be2
...
...
@@ -73,6 +73,7 @@ class RestAPI {
}
post
(
url
,
body
,
token
)
{
console
.
log
(
url
);
return
new
Promise
(
function
(
resolve
,
reject
)
{
var
req
=
request
.
post
(
url
).
send
(
body
).
timeout
({
response
:
5000
});
// Simple response start timeout (3s)
...
...
src/common/data-managers/rest-data-manager.js
View file @
bfab0be2
...
...
@@ -52,7 +52,7 @@ class RestDataManager {
return
object
;
}
load
(
id
,
token
=
null
)
{
load
(
id
,
token
=
null
,
param
=
null
)
{
if
(
id
!=
null
)
{
// load single object
RestAPI
.
get
(
this
.
makeURL
(
this
.
url
+
'
/
'
+
id
),
token
).
then
(
response
=>
{
...
...
@@ -96,54 +96,102 @@ class RestDataManager {
}
}
add
(
object
,
token
=
null
)
{
add
(
object
,
token
=
null
,
param
=
null
)
{
var
obj
=
{};
obj
[
this
.
type
]
=
this
.
filterKeys
(
object
);
RestAPI
.
post
(
this
.
makeURL
(
this
.
url
),
obj
,
token
).
then
(
response
=>
{
AppDispatcher
.
dispatch
({
type
:
this
.
type
+
'
s/added
'
,
data
:
response
[
this
.
type
]
if
(
param
===
null
)
{
RestAPI
.
post
(
this
.
makeURL
(
this
.
url
),
obj
,
token
).
then
(
response
=>
{
AppDispatcher
.
dispatch
({
type
:
this
.
type
+
'
s/added
'
,
data
:
response
[
this
.
type
]
});
}).
catch
(
error
=>
{
AppDispatcher
.
dispatch
({
type
:
this
.
type
+
'
s/add-error
'
,
error
:
error
});
});
}).
catch
(
error
=>
{
AppDispatcher
.
dispatch
({
type
:
this
.
type
+
'
s/add-error
'
,
error
:
error
}
else
{
console
.
log
(
"
else was called in add
"
);
RestAPI
.
post
(
this
.
makeURL
(
this
.
url
)
+
"
?
"
+
param
,
obj
,
token
).
then
(
response
=>
{
AppDispatcher
.
dispatch
({
type
:
this
.
type
+
'
s/added
'
,
data
:
response
[
this
.
type
]
});
}).
catch
(
error
=>
{
AppDispatcher
.
dispatch
({
type
:
this
.
type
+
'
s/add-error
'
,
error
:
error
});
});
}
);
}
}
remove
(
object
,
token
=
null
)
{
RestAPI
.
delete
(
this
.
makeURL
(
this
.
url
+
'
/
'
+
object
.
id
),
token
).
then
(
response
=>
{
AppDispatcher
.
dispatch
({
type
:
this
.
type
+
'
s/removed
'
,
data
:
response
[
this
.
type
],
original
:
object
remove
(
object
,
token
=
null
,
param
=
null
)
{
if
(
param
===
null
)
{
RestAPI
.
delete
(
this
.
makeURL
(
this
.
url
+
'
/
'
+
object
.
id
),
token
).
then
(
response
=>
{
AppDispatcher
.
dispatch
({
type
:
this
.
type
+
'
s/removed
'
,
data
:
response
[
this
.
type
],
original
:
object
});
}).
catch
(
error
=>
{
AppDispatcher
.
dispatch
({
type
:
this
.
type
+
'
s/remove-error
'
,
error
:
error
});
});
}).
catch
(
error
=>
{
AppDispatcher
.
dispatch
({
type
:
this
.
type
+
'
s/remove-error
'
,
error
:
error
}
else
{
RestAPI
.
delete
(
this
.
makeURL
(
this
.
url
+
'
/
'
+
object
.
id
+
'
?
'
+
param
),
token
).
then
(
response
=>
{
AppDispatcher
.
dispatch
({
type
:
this
.
type
+
'
s/removed
'
,
data
:
response
[
this
.
type
],
original
:
object
});
}).
catch
(
error
=>
{
AppDispatcher
.
dispatch
({
type
:
this
.
type
+
'
s/remove-error
'
,
error
:
error
});
});
}
);
}
}
update
(
object
,
token
=
null
)
{
update
(
object
,
token
=
null
,
param
=
null
)
{
var
obj
=
{};
obj
[
this
.
type
]
=
this
.
filterKeys
(
object
);
RestAPI
.
put
(
this
.
makeURL
(
this
.
url
+
'
/
'
+
object
.
id
),
obj
,
token
).
then
(
response
=>
{
AppDispatcher
.
dispatch
({
type
:
this
.
type
+
'
s/edited
'
,
data
:
response
[
this
.
type
]
if
(
param
===
null
)
{
RestAPI
.
put
(
this
.
makeURL
(
this
.
url
+
'
/
'
+
object
.
id
),
obj
,
token
).
then
(
response
=>
{
AppDispatcher
.
dispatch
({
type
:
this
.
type
+
'
s/edited
'
,
data
:
response
[
this
.
type
]
});
}).
catch
(
error
=>
{
AppDispatcher
.
dispatch
({
type
:
this
.
type
+
'
s/edit-error
'
,
error
:
error
});
});
}).
catch
(
error
=>
{
AppDispatcher
.
dispatch
({
type
:
this
.
type
+
'
s/edit-error
'
,
error
:
error
}
else
{
RestAPI
.
put
(
this
.
makeURL
(
this
.
url
+
'
/
'
+
object
.
id
+
'
?
'
+
param
),
obj
,
token
).
then
(
response
=>
{
AppDispatcher
.
dispatch
({
type
:
this
.
type
+
'
s/edited
'
,
data
:
response
[
this
.
type
]
});
}).
catch
(
error
=>
{
AppDispatcher
.
dispatch
({
type
:
this
.
type
+
'
s/edit-error
'
,
error
:
error
});
});
});
}
}
}
};
export
default
RestDataManager
;
src/user/edit-user.js
View file @
bfab0be2
...
...
@@ -121,8 +121,8 @@ class EditUserDialog extends React.Component {
<
FormControl
type
=
"
text
"
placeholder
=
"
Enter e-mail
"
value
=
{
this
.
state
.
mail
}
onChange
=
{(
e
)
=>
this
.
handleChange
(
e
)}
/
>
<
/FormGroup
>
<
FormGroup
as
=
{
Col
}
controlId
=
"
oldPassword
"
>
<
FormLabel
>
Old
Password
<
/FormLabel
>
<
FormControl
type
=
"
password
"
placeholder
=
"
Enter
current
password
"
value
=
{
this
.
state
.
oldPassword
}
onChange
=
{(
e
)
=>
this
.
handleChange
(
e
)}
/
>
<
FormLabel
>
Admin
Password
<
/FormLabel
>
<
FormControl
type
=
"
password
"
placeholder
=
"
Enter
admin
password
"
value
=
{
this
.
state
.
oldPassword
}
onChange
=
{(
e
)
=>
this
.
handleChange
(
e
)}
/
>
<
/FormGroup
>
<
FormGroup
as
=
{
Col
}
controlId
=
"
password
"
>
<
FormLabel
>
Password
<
/FormLabel
>
...
...
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