Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.editor
Commits
6a60208e
Commit
6a60208e
authored
Jan 12, 2018
by
Jaden DIEFENBAUGH
Browse files
PUT instead of POST for save all, sort when saving objs to webapp
parent
69e055f4
Changes
5
Hide whitespace changes
Inline
Side-by-side
server.py
View file @
6a60208e
...
...
@@ -188,10 +188,10 @@ def write_json(be, obj, mode):
file_path
=
os
.
path
.
join
(
resource_path
,
name
+
'.json'
)
if
mode
==
WriteMode
.
UPDATE
:
if
os
.
path
.
isfile
(
file_path
):
with
open
(
file_path
,
'w'
)
as
f
:
f
.
write
(
stringified
)
if
mode
==
WriteMode
.
CREATE
:
os
.
makedirs
(
folder_path
,
exist_ok
=
True
)
with
open
(
file_path
,
'w'
)
as
f
:
f
.
write
(
stringified
)
el
if
mode
==
WriteMode
.
CREATE
:
if
not
os
.
path
.
isfile
(
file_path
):
os
.
makedirs
(
folder_path
,
exist_ok
=
True
)
with
open
(
file_path
,
'w'
)
as
f
:
...
...
@@ -240,7 +240,7 @@ class Settings(Resource):
"""Returns the settings"""
return
get_user_conf
()
def
p
os
t
(
self
):
def
p
u
t
(
self
):
"""Overwrites the settings"""
new_conf
=
request
.
get_json
()
with
open
(
'./user_conf.json'
,
'w'
)
as
f
:
...
...
@@ -280,8 +280,11 @@ def gen_beat_endpoint(entity):
def
put
(
self
):
"""Updates an already-existing object"""
obj
=
request
.
get_json
()
write_json
(
self
.
be
,
obj
,
WriteMode
.
UPDATE
)
obj_list
=
request
.
get_json
()
if
not
isinstance
(
obj_list
,
list
):
obj_list
=
[
obj_list
]
for
obj
in
obj_list
:
write_json
(
self
.
be
,
obj
,
WriteMode
.
UPDATE
)
return
self
.
refresh
()
def
delete
(
self
):
...
...
src/components/EntityDetail.jsx
View file @
6a60208e
...
...
@@ -159,7 +159,7 @@ export class EntityDetail extends React.Component<Props, State> {
<
TabPane
tabId
=
'1'
>
<
Row
>
<
Col
>
<
h4
style
=
{
{
textAlign
:
'
center
'
}
}
>
Under construction
:)
</
h4
>
<
h4
style
=
{
{
textAlign
:
'
center
'
}
}
>
Under construction
😄
</
h4
>
</
Col
>
</
Row
>
</
TabPane
>
...
...
src/components/MainNav.jsx
View file @
6a60208e
...
...
@@ -46,8 +46,8 @@ const saveAll = (allLists: Props) => {
[...
BEAT_ENTITIES
,
'
settings
'
]
//.filter(e => Array.isArray(allLists[e]))
.
map
(
e
=>
{
const
p
os
t
=
genModuleApiFuncs
(
e
).
p
os
t
;
return
p
os
t
(
allLists
[
e
]);
const
p
u
t
=
genModuleApiFuncs
(
e
).
p
u
t
;
return
p
u
t
(
allLists
[
e
]);
})
);
};
...
...
src/components/Settings.jsx
View file @
6a60208e
...
...
@@ -29,7 +29,7 @@ export class Settings extends React.PureComponent<Props> {
}
save
=
async
()
=>
{
await
genModuleApiFuncs
(
'
settings
'
).
p
os
t
(
this
.
props
.
settings
);
await
genModuleApiFuncs
(
'
settings
'
).
p
u
t
(
this
.
props
.
settings
);
await
this
.
props
.
fetchAllObjects
();
}
...
...
src/store/reducers.js
View file @
6a60208e
...
...
@@ -29,7 +29,7 @@ const initialState: State = {
}
};
const
saveFunc
=
(
state
:
BeatObject
[],
objs
:
BeatObject
[]):
BeatObject
[]
=>
[...
objs
];
const
saveFunc
=
(
state
:
BeatObject
[],
objs
:
BeatObject
[]):
BeatObject
[]
=>
[...
objs
]
.
sort
((
a
,
b
)
=>
a
.
name
>
b
.
name
?
1
:
-
1
)
;
const
addFunc
=
(
state
:
BeatObject
[],
obj
:
BeatObject
):
BeatObject
[]
=>
[
obj
,
...
state
];
const
deleteFunc
=
(
state
:
BeatObject
[],
obj
:
BeatObject
):
BeatObject
[]
=>
state
.
filter
(
o
=>
o
.
name
!==
obj
.
name
);
const
updateFunc
=
(
state
:
BeatObject
[],
{
oldName
,
obj
}):
BeatObject
[]
=>
state
.
map
(
o
=>
o
.
name
===
oldName
?
obj
:
o
);
...
...
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