Commit 0845b7c4 authored by Sascha Pfeiffer's avatar Sascha Pfeiffer

some more progress

parent fb990d60
......@@ -44,7 +44,7 @@
<uib-progressbar max="state.open_requests" value="state.closed_request" style="margin-top:15px" ng-if="state.processing">
<span style="color:white; white-space:nowrap;">{{ state.percentage_complete }} %</span>
</uib-progressbar>
<span translate="{{ state.next_step }}"></span>
<span translate="{{ state.next_step }}" ng-if="state.processing"></span>
<div class="form-group alert alert-danger" ng-repeat="e in errors">
<strong>{{'ERROR' | translate}}:</strong>
......
......@@ -57,6 +57,7 @@
var onError = function(data) {
if (data.hasOwnProperty('non_field_errors')) {
$scope.errors = data.non_field_errors;
$scope.state.next_step = '';
$scope.state.processing = false;
} else {
console.log(data);
......
......@@ -6,12 +6,13 @@
* @name psonocli.apiFileserver
* @requires $http
* @requires $q
* @requires psonocli.converter
*
* @description
* Service to talk to the psono REST api
*/
var apiFileserver = function($http, $q) {
var apiFileserver = function($http, $q, converter) {
var call = function(fileserver_url, connection_type, endpoint, data, headers, transformRequest, responseType) {
......@@ -105,7 +106,14 @@
var headers = {
};
return call(fileserver_url, connection_type, endpoint, data, headers, undefined, 'arraybuffer');
return call(fileserver_url, connection_type, endpoint, data, headers, undefined, 'arraybuffer').then(function(data) {
return data
},function(data) {
if (data.status === 400) {
data.data = JSON.parse(converter.bytes_to_string(data.data));
}
return $q.reject(data)
});
};
/**
......@@ -138,6 +146,6 @@
};
var app = angular.module('psonocli');
app.factory("apiFileserver", ['$http', '$q', apiFileserver]);
app.factory("apiFileserver", ['$http', '$q', 'converter', apiFileserver]);
}(angular));
(function(angular, uuid) {
(function(angular, uuid, TextDecoder) {
'use strict';
/**
......@@ -495,6 +495,26 @@
return Mnemonic.fromHex(val).toWords();
};
/**
* @ngdoc
* @name psonocli.converter#bytest_to_string
* @methodOf psonocli.converter
*
* @description
* Converts bytes (arraybuffer or uint8array) to string with the specified encoding (default utf-8)
*
* @param bytes
* @param encoding
*
* @returns {*}
*/
var bytes_to_string = function(bytes, encoding) {
if (typeof(encoding) === 'undefined') {
encoding = 'utf-8'
}
return new TextDecoder(encoding).decode(bytes);
};
return {
// Conversion functions
......@@ -513,12 +533,13 @@
uuid_to_hex: uuid_to_hex,
hex_to_uuid: hex_to_uuid,
words_to_hex: words_to_hex,
hex_to_words: hex_to_words
hex_to_words: hex_to_words,
bytes_to_string : bytes_to_string
};
};
var app = angular.module('psonocli');
app.factory("converter", [converter]);
}(angular, uuid));
}(angular, uuid, TextDecoder));
......@@ -350,8 +350,7 @@
registrations['download_started'](chunk_count * 2);
function onError(data) {
console.log(data);
// pass
return $q.reject(data);
}
function on_chunk_download(data) {
......
{
"CHUNK_NOT_AVAILABLE": "Chunk not available. Please try again later.",
"DOWNLOAD_COMPLETED": "Download abgeschlossen",
"DOWNLOADING_FILE_CHUNK": "Lade Chunk herunter...",
"DECRYPTING_FILE_CHUNK": "Entschlüssele Chunk...",
......
{
"CHUNK_NOT_AVAILABLE": "Chunk nicht verfügbar. Bitte versuche es später erneut.",
"DOWNLOAD_COMPLETED": "Download completed",
"DOWNLOADING_FILE_CHUNK": "Downloading chunk...",
"DECRYPTING_FILE_CHUNK": "Decrypting chunk...",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment