Add a link/endpoint for downloading the generated model

pull/1/head
Daniel Asher Resnick 3 years ago
parent 763c01c002
commit 2b089cb516
  1. 10
      src/app.rb
  2. 16
      src/public/js/burning.js
  3. 5
      src/views/partials/main.erb

@ -97,6 +97,16 @@ post '/download_charfile' do
"/get_file?file=#{key}&download_name=#{data['name']} Character Sheet.char"
end
post '/model' do
request.body.rewind
raw = request.body.readpartial(16 * 1024)
data = JSON.parse(raw)
key = "char-#{Time.now.strftime('%Y%m%d%H%M%S%L')}-#{rand(1...10000)}"
CACHE.store key, data
"/get_file?file=#{key}&download_name=#{data['name']} Character Sheet.model"
end
get '/get_file' do
data = nil
if params['download_name'].match(/\.pdf$/)

@ -1431,6 +1431,22 @@ function BurningCtrl($scope, $http, $modal, $timeout, settings, appropriateWeapo
});
}
$scope.downloadCharacterModel = function(){
var json = angular.toJson($scope.convertCurrentCharacterToStructForCharSheet(), true);
$http.post("/model", json).
success(function(data,status,headers,config){
console.log("huzzah, making model succeeded. File URL: " + data);
var frame = document.getElementById("downloadframe");
if ( frame ){
frame.src = data;
}
}).
error(function(data,status,headers,config){
console.log("boo, making model failed: " + data);
$scope.addAlert('tools', "Generating character model failed: " + data);
});
}
$scope.saveCurrentCharacterToServer = function(){
var nameWarn = "The character must have a name before it can be saved.";
if( $scope.name.length == 0 ){

@ -54,6 +54,11 @@
Upload Character...
</a>
</div>
<div class='col-md-3' ng-show="serverSettings.storageType != 'server'">
<a href='' ng-click='downloadCharacterModel()'>
Download Character Model
</a>
</div>
</div>
</div>
</div>

Loading…
Cancel
Save