Skip to content

Commit

Permalink
Added Shows and Files selection
Browse files Browse the repository at this point in the history
Some code should still be cleaned up, but this is an effor to wrap up
things for an Alpha release.
  • Loading branch information
fsiddi committed Dec 8, 2013
1 parent e478b19 commit 9fe2349
Show file tree
Hide file tree
Showing 13 changed files with 465 additions and 126 deletions.
56 changes: 45 additions & 11 deletions dashboard/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,29 @@ def worker(worker_id):
return make_response('worker ' + worker_id + ' doesnt exist')


@app.route('/shows/')
def shows_index():
shows = http_request(BRENDER_SERVER, '/shows')
shows= json.loads(shows)
return render_template('shows.html', shows=shows, title='shows')


@app.route('/shows/update', methods=['POST'])
def shows_update():

params = dict(
show_id=request.form['show_id'],
path_server=request.form['path_server'],
path_linux=request.form['path_linux'],
path_osx=request.form['path_osx'])

print http_request(BRENDER_SERVER, '/shows/update', params)

shows = http_request(BRENDER_SERVER, '/shows/')
shows= json.loads(shows)
return render_template('shows.html', shows=shows, title='shows')


@app.route('/shots/')
def shots_index():
shots = http_request(BRENDER_SERVER, '/shots')
Expand All @@ -170,6 +193,17 @@ def shots_index():

return render_template('shots.html', entries=entries, title='shots')

@app.route('/shots/browse/', defaults={'path': ''})
@app.route('/shots/browse/<path:path>',)
def shots_browse(path):
path = os.path.join('/shots/browse/', path)
print path
path_data = json.loads(http_request(BRENDER_SERVER, path))
return render_template('browse_modal.html',
# items=path_data['items'],
items_list=path_data['items_list'],
parent_folder=path + '/..')


@app.route('/shots/delete', methods=['POST'])
def shots_delete():
Expand Down Expand Up @@ -218,9 +252,13 @@ def shots_add():
return redirect(url_for('shots_index'))
else:
render_settings = json.loads(http_request(BRENDER_SERVER, '/render-settings/'))
shows = json.loads(http_request(BRENDER_SERVER, '/shows/'))
settings = json.loads(http_request(BRENDER_SERVER, '/settings/'))
return render_template('add_shot_modal.html',
title='add_shot',
render_settings=render_settings)
render_settings=render_settings,
settings=settings,
shows=shows)


@app.route('/jobs/')
Expand Down Expand Up @@ -261,16 +299,12 @@ def settings():
params = request.form
http_request(BRENDER_SERVER, '/settings/update', params)

settings = json.loads(http_request(BRENDER_SERVER, '/settings/'))
return render_template('settings.html',
title='settings',
settings=settings)

else:
settings = json.loads(http_request(BRENDER_SERVER, '/settings/'))
return render_template('settings.html',
title='settings',
settings=settings)
shows = json.loads(http_request(BRENDER_SERVER, '/shows/'))
settings = json.loads(http_request(BRENDER_SERVER, '/settings/'))
return render_template('settings.html',
title='settings',
settings=settings,
shows=shows)


@app.route('/render-settings/', methods=['GET'])
Expand Down
5 changes: 5 additions & 0 deletions dashboard/static/css/brender.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ h2 {

}


.blendfile.active {
background: #CCC;
}

.video-container {
position: relative;
padding-bottom: 56.25%;
Expand Down
156 changes: 84 additions & 72 deletions dashboard/templates/add_shot_modal.html
Original file line number Diff line number Diff line change
@@ -1,78 +1,90 @@
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="addShotModalLabel">Add Shot</h4>
<form id="addShot" role="form" action="{{ url_for('shots_add') }}" method=post>
<!-- <div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="project">Show</label>
<select name="active_show" class="form-control">
{% for show in shows %}
<option value="{{show}}"{% if show == settings['active_show'] %}selected{% endif %}>{{shows[show]['name']}}</option>
{% endfor %}
<option value="">Single blendfile</option>
</select>
</div>
</div>
<div class="modal-body">

<form id="addShot" role="form" action="{{ url_for('shots_add') }}" method=post>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="project">Project</label>
<select name="project" class="form-control">
{% for file in render_settings['settings_files'] %}
<option value="{{file}}">{{file}}</option>
{% endfor %}
<option value="">File Settings</option>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="filepath">Filepath</label>
<input type="text" class="form-control" id="filepath" name="filepath" placeholder="/tmp/untitled.blend" required="">
</div>
</div>
</div> -->
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="project">Shot</label>
<div class="input-group">
<input id="filepath" name="filepath" type="text" class="form-control">
<div class="input-group-btn">
<a id="browse_filepath" type="button" class="btn btn-default">Browse</a>
</div><!-- /btn-group -->
</div><!-- /input-group -->
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="shot_name">Shot name</label>
<input type="text" class="form-control" id="shot_name" name="shot_name" placeholder="a2s31" required="">
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="shot_name">Shot name</label>
<input type="text" class="form-control" id="shot_name" name="shot_name" placeholder="a2s31" required="">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="render_settings">Render settings</label>
<select name="render_settings" class="form-control">
{% for file in render_settings['settings_files'] %}
<option value="{{file}}">{{file}}</option>
{% endfor %}
<option value="">File Settings</option>
</select>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="render_settings">Render settings</label>
<select name="render_settings" class="form-control">
{% for file in render_settings['settings_files'] %}
<option value="{{file}}">{{file}}</option>
{% endfor %}
<option value="">File Settings</option>
</select>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label for="frame_start">Frame start</label>
<input type="text" class="form-control" id="frame_start" name="frame_start" value="1" required="">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="frame_end">Frame end</label>
<input type="text" class="form-control" id="frame_end" name="frame_end" value="20" required="">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="chunk_size">Chunk size</label>
<input type="text" class="form-control" id="chunk_size" name="chunk_size" value="5" required="">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label for="frame_start">Frame start</label>
<input type="text" class="form-control" id="frame_start" name="frame_start" value="1" required="">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="frame_end">Frame end</label>
<input type="text" class="form-control" id="frame_end" name="frame_end" value="20" required="">
</div>

</form>


</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" onclick="$('.modal-body > form').submit();" >Submit shot</button>
<div class="col-md-4">
<div class="form-group">
<label for="chunk_size">Chunk size</label>
<input type="text" class="form-control" id="chunk_size" name="chunk_size" value="5" required="">
</div>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
</form>

<script>
$(document).ready(function() {

$('#brenderModalLabel').text('Add shot');

$('#filepath').val($('#modal_variable').val());

$('#browse_filepath').click(function(e) {
e.preventDefault();
$.get('/shots/browse/', function(data) {
$('.modal-body').html(data);
});

$('.modal-footer').children('.btn-primary').text('Select');
$('.modal-footer').children('.btn-primary').addClass('select-file');
});

});

</script>


44 changes: 44 additions & 0 deletions dashboard/templates/browse_modal.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<ul class="files">
<li><a class="folder" href="{{parent_folder}}">..</a></li>
{% for item in items_list %}
<li><a class="{{item[2]}}" href="{{item[1]}}">{{item[0]}}</a></li>
{% endfor %}
</ul>


<script>
$(document).ready(function() {

$('#brenderModalLabel').text('Select a blendfile');

// Support for AJAX loaded modal window.
// Focuses on first input textbox after it loads the window.
$('.folder').click(function(e) {
e.preventDefault();
var url = '/shots/browse/' + $(this).attr('href');
$.get(url, function(data) {
$('.modal-body').html(data);
});
});

$('.blendfile').click(function(e) {
e.preventDefault();
var url = '/shots/browse/' + $(this).attr('href');
$(this).parent().siblings().children('a').removeClass('active');
$(this).addClass('active');
$('#modal_variable').val($(this).attr('href'));

});

$('.select-file').click(function(e) {
e.preventDefault();
var url = '/shots/add';
$.get(url, function(data) {
$('.modal-body').html(data);
});
$('.modal-footer').children('.btn-primary').text('Add Shot');
});

});

</script>
37 changes: 34 additions & 3 deletions dashboard/templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,25 @@

<body>
{% block modal %}

<div class="modal fade" id="brenderModal" tabindex="-1" role="dialog" aria-labelledby="brenderModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="brenderModalLabel">Modal title</h4>
</div>
<div class="modal-body">

</div>
<div class="modal-footer">
<input type="hidden" id="modal_variable" name="modal_variable" value="">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" onclick="$('.modal-body > form').submit();" >Submit shot</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->

{% endblock %}

Expand Down Expand Up @@ -72,7 +91,7 @@
<li><a href="{{ url_for('status') }}">Status</a></li>
<li class="divider"></li>
<li><a href="{{ url_for('settings') }}">Settings</a></li>
<li><a href="#">Projects</a></li>
<li><a href="{{ url_for('shows_index') }}">Shows</a></li>
<li><a href="{{ url_for('log') }}">Logs</a></li>
<li><a href="{{ url_for('sandbox') }}">Sandbox</a></li>
</ul>
Expand Down Expand Up @@ -112,15 +131,27 @@
$('[data-toggle="modal"]').click(function(e) {
e.preventDefault();
var url = $(this).attr('modal');
/*
if (url.indexOf('#') == 0) {
$(url).modal('open');
} else {
$.get(url, function(data) {
$('<div class="modal fade">' + data + '</div>').modal();
}).success(function() { $('input:text:visible:first').focus(); });
}
}).success(function() {
$('input:text:visible:first').focus();
});
}*/

$.get(url, function(data) {
$('.modal-body').html(data);
});

$('.modal-footer').children('.btn-primary').text('Add Shot');
$('#brenderModal').modal('show');
});

});

</script>

</body>
Expand Down
Loading

0 comments on commit 9fe2349

Please sign in to comment.