Merge remote-tracking branch 'origin/master' into tagyourit

Conflicts:
	test/data/test.db
This commit is contained in:
jakedt 2014-04-01 19:09:41 -04:00
commit d768b60a3c
23 changed files with 674 additions and 134 deletions

View file

@ -185,24 +185,164 @@ quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'angu
return service;
}]);
$provide.factory('UtilService', ['$sanitize', function($sanitize) {
var utilService = {};
utilService.textToSafeHtml = function(text) {
var adjusted = text.replace(/&/g, "&")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;");
$provide.factory('DataFileService', [function() {
var dataFileService = {};
return $sanitize(adjusted);
dataFileService.getName_ = function(filePath) {
var parts = filePath.split('/');
return parts[parts.length - 1];
};
dataFileService.tryAsZip_ = function(buf, success, failure) {
var zip = null;
var zipFiles = null;
try {
var zip = new JSZip(buf);
zipFiles = zip.files;
} catch (e) {
failure();
return;
}
var files = [];
for (var filePath in zipFiles) {
if (zipFiles.hasOwnProperty(filePath)) {
files.push({
'name': dataFileService.getName_(filePath),
'path': filePath,
'canRead': true,
'toBlob': (function(fp) {
return function() {
return new Blob([zip.file(fp).asArrayBuffer()]);
};
}(filePath))
});
}
}
success(files);
};
dataFileService.tryAsTarGz_ = function(buf, success, failure) {
var collapsePath = function(originalPath) {
// Tar files can contain entries of the form './', so we need to collapse
// those paths down.
var parts = originalPath.split('/');
for (var i = parts.length - 1; i >= 0; i--) {
var part = parts[i];
if (part == '.') {
parts.splice(i, 1);
}
}
return parts.join('/');
};
var gunzip = new Zlib.Gunzip(buf);
var plain = gunzip.decompress();
var handler = new MultiFile();
handler.files = [];
handler.processTarChunks(dataFileService.arrayToString(plain), 0);
if (!handler.files.length) {
failure();
return;
}
var files = [];
for (var i = 0; i < handler.files.length; ++i) {
var currentFile = handler.files[i];
var path = collapsePath(currentFile.filename);
if (path == '') { continue; }
files.push({
'name': dataFileService.getName_(path),
'path': path,
'canRead': true,
'toBlob': (function(currentFile) {
return function() {
return new Blob([currentFile.data], {type: 'application/octet-binary'});
};
}(currentFile))
});
}
success(files);
};
dataFileService.blobToString = function(blob, callback) {
var reader = new FileReader();
reader.onload = function(event){
callback(reader.result);
};
reader.readAsText(blob);
};
dataFileService.arrayToString = function(buf) {
return String.fromCharCode.apply(null, new Uint16Array(buf));
};
dataFileService.readDataArrayAsPossibleArchive = function(buf, success, failure) {
dataFileService.tryAsZip_(buf, success, function() {
dataFileService.tryAsTarGz_(buf, success, failure);
});
};
dataFileService.downloadDataFileAsArrayBuffer = function($scope, url, progress, error, loaded) {
var request = new XMLHttpRequest();
request.open('GET', url, true);
request.responseType = 'arraybuffer';
request.onprogress = function(e) {
$scope.$apply(function() {
var percentLoaded;
if (e.lengthComputable) {
progress(e.loaded / e.total);
}
});
};
request.onerror = function() {
$scope.$apply(function() {
error();
});
};
request.onload = function() {
if (this.status == 200) {
$scope.$apply(function() {
var uint8array = new Uint8Array(request.response);
loaded(uint8array);
});
return;
}
};
request.send();
};
return dataFileService;
}]);
$provide.factory('UtilService', ['$sanitize', function($sanitize) {
var utilService = {};
utilService.textToSafeHtml = function(text) {
var adjusted = text.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;");
return $sanitize(adjusted);
};
return utilService;
}]);
$provide.factory('TriggerDescriptionBuilder', ['UtilService', '$sanitize', function(UtilService, $sanitize) {
$provide.factory('TriggerDescriptionBuilder', ['UtilService', '$sanitize', function(UtilService, $sanitize) {
var builderService = {};
builderService.getDescription = function(name, config) {