Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scheduling-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SMASCH
scheduling-system
Commits
b6545312
Commit
b6545312
authored
7 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
configuration panel allows modifying elements
parent
ac1a2f00
No related branches found
No related tags found
1 merge request
!36
Resolve "configuration panel"
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
smash/web/api_urls.py
+2
-1
2 additions, 1 deletion
smash/web/api_urls.py
smash/web/api_views/configuration.py
+23
-0
23 additions, 0 deletions
smash/web/api_views/configuration.py
smash/web/templates/configuration/index.html
+57
-14
57 additions, 14 deletions
smash/web/templates/configuration/index.html
with
82 additions
and
15 deletions
smash/web/api_urls.py
+
2
−
1
View file @
b6545312
...
@@ -24,8 +24,9 @@ urlpatterns = [
...
@@ -24,8 +24,9 @@ urlpatterns = [
# appointment types
# appointment types
url
(
r
'
^appointment_types$
'
,
appointment_type
.
appointment_types
,
name
=
'
web.api.appointment_types
'
),
url
(
r
'
^appointment_types$
'
,
appointment_type
.
appointment_types
,
name
=
'
web.api.appointment_types
'
),
#
appointment
s
#
configuration item
s
url
(
r
'
^configuration_items$
'
,
configuration
.
configuration_items
,
name
=
'
web.api.configuration_items
'
),
url
(
r
'
^configuration_items$
'
,
configuration
.
configuration_items
,
name
=
'
web.api.configuration_items
'
),
url
(
r
'
^configuration_items/update$
'
,
configuration
.
update_configuration_item
,
name
=
'
web.api.update_configuration_item
'
),
# subjects data
# subjects data
url
(
r
'
^cities$
'
,
subject
.
cities
,
name
=
'
web.api.cities
'
),
url
(
r
'
^cities$
'
,
subject
.
cities
,
name
=
'
web.api.cities
'
),
...
...
This diff is collapsed.
Click to expand it.
smash/web/api_views/configuration.py
+
23
−
0
View file @
b6545312
...
@@ -31,3 +31,26 @@ def configuration_items(request):
...
@@ -31,3 +31,26 @@ def configuration_items(request):
"
recordsFiltered
"
:
count_filtered
,
"
recordsFiltered
"
:
count_filtered
,
"
data
"
:
data
"
data
"
:
data
})
})
@login_required
def
update_configuration_item
(
request
):
id
=
int
(
request
.
GET
.
get
(
"
id
"
,
None
))
value
=
request
.
GET
.
get
(
"
value
"
,
None
)
if
(
id
is
None
)
or
(
value
is
None
):
return
JsonResponse
({
"
status
"
:
"
error
"
,
"
message
"
:
"
id and value are obligatory
"
})
item
=
ConfigurationItem
.
objects
.
get
(
id
=
id
)
if
item
is
None
:
return
JsonResponse
({
"
status
"
:
"
error
"
,
"
message
"
:
"
item with given id doesn
'
t exist
"
})
item
.
value
=
value
item
.
save
()
return
JsonResponse
({
"
status
"
:
"
ok
"
,
})
This diff is collapsed.
Click to expand it.
smash/web/templates/configuration/index.html
+
57
−
14
View file @
b6545312
...
@@ -22,21 +22,22 @@
...
@@ -22,21 +22,22 @@
{% block maincontent %}
{% block maincontent %}
<div>
<div>
<div>
<div
id=
"message"
>
<table
id=
"table"
class=
"table table-bordered table-striped"
>
<thead>
<tr>
<th>
Name
</th>
<th>
Value
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<hr/>
</div>
</div>
<table
id=
"table"
class=
"table table-bordered table-striped"
>
<thead>
<tr>
<th>
Name
</th>
<th>
Value
</th>
<th></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<hr/>
</div>
</div>
{% endblock maincontent %}
{% endblock maincontent %}
...
@@ -49,6 +50,33 @@
...
@@ -49,6 +50,33 @@
<script
src=
"{% static 'AdminLTE/plugins/moment.js/moment.min.js' %}"
></script>
<script
src=
"{% static 'AdminLTE/plugins/moment.js/moment.min.js' %}"
></script>
<script>
<script>
function
update
(
id
)
{
var
value
=
$
(
"
#value-
"
+
id
).
val
();
var
data
=
{
"
id
"
:
id
,
"
value
"
:
value
,
"
_
"
:
Math
.
random
()
};
$
.
ajax
({
type
:
"
GET
"
,
url
:
"
{% url 'web.api.update_configuration_item' %}
"
,
data
:
data
,
success
:
function
(
response
)
{
var
message
;
var
classString
;
if
(
response
.
status
==
"
ok
"
)
{
message
=
"
Element modified successfully
"
;
classString
=
"
alert alert-success
"
}
else
{
message
=
"
Problem with modifying element:
"
+
response
.
message
;
classString
=
"
alert alert-danger
"
}
$
(
"
#message
"
).
html
(
message
);
$
(
"
#message
"
).
attr
(
'
class
'
,
classString
);
},
});
}
$
(
function
()
{
$
(
function
()
{
$
(
function
()
{
$
(
function
()
{
var
table
=
$
(
'
#table
'
).
DataTable
({
var
table
=
$
(
'
#table
'
).
DataTable
({
...
@@ -60,6 +88,21 @@
...
@@ -60,6 +88,21 @@
{
"
data
"
:
"
name
"
},
{
"
data
"
:
"
name
"
},
{
"
data
"
:
"
value
"
},
{
"
data
"
:
"
value
"
},
],
],
columnDefs
:
[
{
render
:
function
(
data
,
type
,
row
)
{
return
'
<button class="btn btn-block btn-default" onclick="update(
'
+
row
.
id
+
'
)">Save</button>
'
},
targets
:
2
},
{
render
:
function
(
data
,
type
,
row
)
{
return
'
<input id="value-
'
+
row
.
id
+
'
" type="text" value="
'
+
row
.
value
+
'
" class="form-control"/>
'
},
targets
:
1
}
]
});
});
$
(
'
#table_filter
'
).
css
(
"
display
"
,
"
none
"
);
$
(
'
#table_filter
'
).
css
(
"
display
"
,
"
none
"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment