Better token support in UI

pull/51/head
Piero Toffanin 2018-11-20 14:33:27 -05:00
rodzic c23d8bde75
commit 1b64ce4b3b
2 zmienionych plików z 14 dodań i 20 usunięć

Wyświetl plik

@ -160,7 +160,7 @@ app.post('/task/new', authCheck, addRequestId, upload.array('images'), (req, res
};
if ((!req.files || req.files.length === 0) && !req.body.zipurl) die("Need at least 1 file or a zip file url.");
if (config.maxImages > 0 && req.files && req.files.length > config.maxImages) die(`${req.files.length} images uploaded, but this node can only process up to ${config.maxImages}.`);
else if (config.maxImages > 0 && req.files && req.files.length > config.maxImages) die(`${req.files.length} images uploaded, but this node can only process up to ${config.maxImages}.`);
else {
let destPath = path.join(Directories.data, req.id);

Wyświetl plik

@ -16,6 +16,14 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
$(function() {
function query(key) {
key = key.replace(/[*+?^$.\[\]{}()|\\\/]/g, "\\$&"); // escape RegEx meta chars
var match = location.search.match(new RegExp("[?&]"+key+"=([^&]+)(&|$)"));
return match && decodeURIComponent(match[1].replace(/\+/g, " "));
}
var token = query('token') || "";
function hoursMinutesSecs(t) {
var ch = 60 * 60 * 1000,
cm = 60 * 1000,
@ -134,7 +142,7 @@ $(function() {
}
Task.prototype.refreshInfo = function() {
var self = this;
var url = "/task/" + this.uuid + "/info";
var url = "/task/" + this.uuid + "/info?token=" + token;
$.get(url)
.done(function(json) {
// Track time
@ -160,7 +168,7 @@ $(function() {
var self = this;
function fetchOutput() {
var url = "/task/" + self.uuid + "/output";
var url = "/task/" + self.uuid + "/output?token=" + token;
$.get(url, { line: self.viewOutputLine })
.done(function(output) {
for (var i in output) {
@ -269,7 +277,7 @@ $(function() {
// Handle uploads
$("#images").fileinput({
uploadUrl: '/task/new',
uploadUrl: '/task/new?token=' + token,
showPreview: false,
allowedFileExtensions: ['jpg', 'jpeg', 'txt', 'zip'],
elErrorContainer: '#errorBlock',
@ -299,18 +307,11 @@ $(function() {
return;
}
// Start upload
$("#images").fileinput('upload');
$("#images").fileinput('upload');
});
$('#resetWebhook').on('click', function(){
$("#webhook").val('');
});
@ -334,6 +335,7 @@ $(function() {
$('#btnShowUpload').addClass('hidden');
$('#zipurl').val('');
});
var btnUploadLabel = $("#btnUpload").val();
$("#images")
@ -359,14 +361,6 @@ $(function() {
this.value(undefined);
};
function query(key) {
key = key.replace(/[*+?^$.\[\]{}()|\\\/]/g, "\\$&"); // escape RegEx meta chars
var match = location.search.match(new RegExp("[?&]"+key+"=([^&]+)(&|$)"));
return match && decodeURIComponent(match[1].replace(/\+/g, " "));
}
var token = query('token') || "";
function OptionsModel() {
var self = this;