0
1
Fork 0

Errores subida multiple de fotos solucionados

This commit is contained in:
Juan Ferrer Toribio 2017-06-22 12:00:52 +02:00
parent d56a4cc025
commit 9e97958f60
13 changed files with 485 additions and 39 deletions

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
hedera-web (1.405.6) stable; urgency=low
hedera-web (1.405.8) stable; urgency=low
* Initial Release.

View File

@ -7,6 +7,10 @@
,"Clear all": "Netejar tot"
,"Upload files": "Pujar arxius"
,"Waiting for upload": "Esperant per pujar"
,"Uploading file": "Pujant fitxer"
,"Image uploaded": "Imatge pujada"
,"Upload finished successfully": "Imatges pujades correctament"
,"Some errors happened on upload": "Van ocórrer errors en pujar alguna de les imatges"
,"There are no files to upload": "No s'ha seleccionat arxius per pujar"

View File

@ -7,6 +7,10 @@
,"Clear all": "Clear all"
,"Upload files": "Upload files"
,"Waiting for upload": "Waiting for upload"
,"Uploading file": "Uploading file"
,"Image uploaded": "Image uploaded"
,"Upload finished successfully": "Upload finished successfully"
,"Some errors happened on upload": "Some errors happened on upload"
,"There are no files to upload": "There are no files to upload"

View File

@ -7,6 +7,10 @@
,"Clear all": "Limpiar todo"
,"Upload files": "Subir archivos"
,"Waiting for upload": "Esperando para subir"
,"Uploading file": "Subiendo fichero"
,"Image uploaded": "Imagen subida"
,"Upload finished successfully": "Imágenes subidas correctamente"
,"Some errors happened on upload": "Ocurrieron errores al subir alguna de las imágenes"
,"There are no files to upload": "No se han seleccionado archivos para subir"

View File

@ -7,6 +7,10 @@
,"Clear all": "Tout effacer"
,"Upload files": "Upload Files"
,"Waiting for upload": "En attente de télécharger"
,"Uploading file": "Uploader des fichiers"
,"Image uploaded": "Fichier uploadé"
,"Upload finished successfully": "Les images téléchargées correctement"
,"Some errors happened on upload": "Des erreurs sont survenues lors du téléchargement des images"
,"There are no files to upload": "Aucun fichier sélectionné pour télécharger"

View File

@ -7,6 +7,10 @@
,"Clear all": "Clear all"
,"Upload files": "Upload files"
,"Waiting for upload": "Waiting for upload"
,"Uploading file": "Uploading file"
,"Image uploaded": "Image uploaded"
,"Upload finished successfully": "Upload finished successfully"
,"Some errors happened on upload": "Some errors happened on upload"
,"There are no files to upload": "There are no files to upload"

View File

@ -7,6 +7,10 @@
,"Clear all": "Clear All"
,"Upload files": "Fazer upload de arquivos"
,"Waiting for upload": "Esperando para enviar"
,"Uploading file": "Enviando arquivo"
,"Image uploaded": "Arquivo enviado"
,"Upload finished successfully": "Upload concluído com sucesso"
,"Some errors happened on upload": "Ocurrieron erros ao subir alguma das imagens"
,"There are no files to upload": "Não há arquivos selecionados para upload"

View File

@ -1,3 +1,11 @@
(function() {
var Status = {
NONE : 0
,WAITING : 1
,UPLOADING : 2
,UPLOADED : 3
};
Hedera.Photos = new Class
({
@ -5,6 +13,8 @@ Hedera.Photos = new Class
,filesData: []
,uploadCount: 0
,errors: false
,uploadQueue: []
,isUploading: false
,activate: function ()
{
@ -46,17 +56,16 @@ Hedera.Photos = new Class
name.value = getFileName (file.name);
div.appendChild (name);
var status = doc.createElement ('span');
status.className = 'status';
div.appendChild (status);
var statusNode = doc.createElement ('span');
statusNode.className = 'status';
div.appendChild (statusNode);
var fileData = {
div: div,
file: file,
name: name,
status: status,
sent: false,
loading : false
statusNode: statusNode,
status: Status.NONE
};
this.filesData.push (fileData);
button.value = fileData;
@ -67,68 +76,88 @@ Hedera.Photos = new Class
,onUploadClick: function ()
{
var filesData = this.filesData;
var formData = new FormData();
var count = 0;
for (var i = 0; i < filesData.length; i++)
{
var fileData = filesData[i];
if (!(fileData.sent || fileData.loading))
{
formData.append ('image', fileData.file);
formData.append ('name', fileData.name.value);
formData.append ('schema', this.$('schema').value);
formData.append ('srv', 'json:image/upload');
this.conn.sendFormData (formData,
this.onFileUpload.bind (this, fileData));
fileData.loading = true;
this.uploadCount++;
if (fileData.status === Status.NONE)
{
this.setImageStatus (
fileData, Status.WAITING, 'cloud-upload', _('Waiting for upload'));
fileData.name.disabled = true;
this.uploadQueue.push (fileData);
count++;
}
}
if (count === 0)
Htk.Toast.showWarning (_('There are no files to upload'));
else
this.uploadNextFile ();
}
,uploadNextFile: function ()
{
if (this.isUploading)
return;
this.isUploading = true;
var fileData = this.uploadQueue.shift ();
this.setImageStatus (
fileData, Status.UPLOADING, 'upload', _('Uploading file'));
var formData = new FormData();
formData.append ('image', fileData.file);
formData.append ('name', fileData.name.value);
formData.append ('schema', this.$('schema').value);
formData.append ('srv', 'json:image/upload');
this.conn.sendFormData (formData,
this.onFileUpload.bind (this, fileData));
}
,onFileUpload: function (fileData, data, error)
{
fileData.loading = false;
this.isUploading = false;
if (data)
{
var iconName = 'ok';
var title = _('ImageAdded');
fileData.sent = true;
fileData.name.disabled = true;
this.setImageStatus (
fileData, Status.UPLOADED, 'ok', _('Image uploaded'));
}
else
{
var iconName = 'error';
var title = error.message;
this.setImageStatus (
fileData, Status.NONE, 'error', error.message);
fileData.name.disabled = false;
this.errors = true;
}
var status = fileData.status;
Vn.Node.removeChilds (status);
var icon = new Htk.Icon ({icon: iconName});
status.appendChild (icon.node);
status.title = title;
this.uploadCount--;
if (this.uploadCount === 0)
if (this.uploadQueue.length === 0)
{
if (!this.errors)
Htk.Toast.showMessage (_('Upload finished successfully'));
else
if (this.errors)
Htk.Toast.showError (_('Some errors happened on upload'));
else
Htk.Toast.showMessage (_('Upload finished successfully'));
this.errors = false;
}
else
this.uploadNextFile ();
}
,setImageStatus: function (fileData, status, icon, title)
{
fileData.status = status;
var statusNode = fileData.statusNode;
Vn.Node.removeChilds (statusNode);
var iconNode = new Htk.Icon ({icon: icon});
statusNode.appendChild (iconNode.node);
statusNode.title = title ? title : '';
}
,onFileRemove: function (button)
@ -202,3 +231,5 @@ function getFileName (path)
return path.substr (barIndex, dotIndex);
}
})();

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="16"
viewBox="0 0 16 16"
width="16"
version="1.1"
id="svg6"
sodipodi:docname="cloud-upload.svg"
style="fill:#000000"
inkscape:version="0.92.1 r15371">
<metadata
id="metadata12">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs10" />
<sodipodi:namedview
pagecolor="#000000"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1016"
id="namedview8"
showgrid="false"
inkscape:zoom="9.8333333"
inkscape:cx="-18.305085"
inkscape:cy="11.59322"
inkscape:window-x="1920"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="svg6" />
<path
d="M 0,-8 H 24 V 16 H 0 Z"
id="path2"
inkscape:connector-curvature="0"
style="fill:none" />
<path
d="M 11.98125,6.9383334 C 11.612917,5.0695833 9.971667,3.6666667 8,3.6666667 6.4345833,3.6666667 5.075,4.555 4.3979167,5.855 2.7675,6.0283334 1.5,7.4095833 1.5,9.0833334 1.5,10.87625 2.9570833,12.333333 4.75,12.333333 h 7.041667 c 1.495,0 2.708333,-1.213333 2.708333,-2.7083329 0,-1.43 -1.110417,-2.5891668 -2.51875,-2.6866667 z M 9.083333,8.5416667 V 10.708333 H 6.9166667 V 8.5416667 h -1.625 L 8,5.8333333 10.708333,8.5416667 Z"
id="path4"
inkscape:connector-curvature="0"
style="stroke-width:0.54166669;fill:#ffffff;fill-opacity:1" />
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="16"
viewBox="0 0 16 16"
width="16"
version="1.1"
id="svg6"
sodipodi:docname="upload.svg"
style="fill:#000000"
inkscape:version="0.92.1 r15371">
<metadata
id="metadata12">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs10" />
<sodipodi:namedview
pagecolor="#000000"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1016"
id="namedview8"
showgrid="false"
inkscape:zoom="9.8333333"
inkscape:cx="-18.101695"
inkscape:cy="11.18644"
inkscape:window-x="1920"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="svg6" />
<path
d="M 0,-8 H 24 V 16 H 0 Z"
id="path2"
inkscape:connector-curvature="0"
style="fill:none" />
<path
d="M 5.7058832,11.441177 H 10.294123 V 6.8529413 H 13.35294 L 8.000008,1.5 2.64706,6.8529413 H 5.7058832 Z M 2.64706,12.970587 H 13.35294 V 14.5 H 2.64706 Z"
id="path4"
inkscape:connector-curvature="0"
style="stroke-width:0.76470536;fill:#ffffff;fill-opacity:1" />
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -0,0 +1,143 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
sodipodi:docname="clean.svg"
inkscape:export-filename="/home/sam/dev/RESOURCES/gnome-icon-theme-symbolic/src/gnome-stencils.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
height="16"
id="svg7384"
version="1.1"
inkscape:version="0.48.5 r10040"
width="16">
<metadata
id="metadata90">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title>Gnome Symbolic Icon Theme</dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
inkscape:bbox-nodes="false"
inkscape:bbox-paths="true"
bordercolor="#666666"
borderopacity="1"
inkscape:current-layer="layer12"
inkscape:cx="-150.83074"
inkscape:cy="80.67304"
gridtolerance="10"
inkscape:guide-bbox="true"
guidetolerance="10"
id="namedview88"
inkscape:object-nodes="false"
inkscape:object-paths="false"
objecttolerance="10"
pagecolor="#3a3b39"
inkscape:pageopacity="1"
inkscape:pageshadow="2"
showborder="false"
showgrid="false"
showguides="true"
inkscape:snap-bbox="true"
inkscape:snap-bbox-midpoints="false"
inkscape:snap-global="true"
inkscape:snap-grids="true"
inkscape:snap-nodes="true"
inkscape:snap-others="false"
inkscape:snap-to-guides="true"
inkscape:window-height="1014"
inkscape:window-maximized="1"
inkscape:window-width="1920"
inkscape:window-x="1920"
inkscape:window-y="27"
inkscape:zoom="2.0429688">
<inkscape:grid
dotted="false"
empspacing="2"
enabled="true"
id="grid4866"
originx="60px"
originy="550px"
snapvisiblegridlinesonly="true"
spacingx="1px"
spacingy="1px"
type="xygrid"
visible="true" />
</sodipodi:namedview>
<title
id="title9167">Gnome Symbolic Icon Theme</title>
<defs
id="defs7386" />
<g
inkscape:groupmode="layer"
id="layer9"
inkscape:label="status"
style="display:inline"
transform="translate(-181.0002,-767)" />
<g
inkscape:groupmode="layer"
id="layer10"
inkscape:label="devices"
style="display:inline"
transform="translate(-181.0002,-767)" />
<g
inkscape:groupmode="layer"
id="layer11"
inkscape:label="apps"
transform="translate(-181.0002,-767)" />
<g
inkscape:groupmode="layer"
id="layer13"
inkscape:label="places"
style="display:inline"
transform="translate(-181.0002,-767)" />
<g
inkscape:groupmode="layer"
id="layer14"
inkscape:label="mimetypes"
transform="translate(-181.0002,-767)" />
<g
inkscape:groupmode="layer"
id="layer15"
inkscape:label="emblems"
style="display:inline"
transform="translate(-181.0002,-767)" />
<g
inkscape:groupmode="layer"
id="g71291"
inkscape:label="emotes"
style="display:inline"
transform="translate(-181.0002,-767)" />
<g
inkscape:groupmode="layer"
id="g4953"
inkscape:label="categories"
style="display:inline"
transform="translate(-181.0002,-767)" />
<g
inkscape:groupmode="layer"
id="layer12"
inkscape:label="actions"
style="display:inline"
transform="translate(-181.0002,-767)">
<path
inkscape:connector-curvature="0"
d="m 191.0002,769 6,6 -6,6 -9.0353,0 c -0.53033,-0.0221 -0.9647,-0.49177 -0.9647,-1 l 0,-10 c 0,-0.53079 0.34561,-1 1.0089,-1 l 8.9911,0 z m -1,3 -1,0 c -0.0104,-1.2e-4 -0.0208,-4.6e-4 -0.0313,0 -0.25495,0.0112 -0.50987,0.12858 -0.6875,0.3125 l -1.2812,1.28125 -1.3125,-1.28125 C 185.42208,772.082 185.24103,772.007 185.0002,772 l -1,0 0,1 c 0,0.28647 0.0343,0.55065 0.25,0.75 l 1.28125,1.28125 -1.25,1.25 c -0.18819,0.18817 -0.28124,0.45345 -0.28125,0.71875 l 0,1 1,0 c 0.2653,-10e-6 0.53059,-0.0931 0.71875,-0.28125 l 1.28125,-1.28125 1.28125,1.28125 C 188.46961,777.90694 188.73491,778 189.0002,778 l 1,0 0,-1 c 0,-0.26529 -0.0931,-0.53058 -0.28125,-0.71875 l -1.28125,-1.25 1.28125,-1.28125 c 0.21074,-0.19463 0.30316,-0.46925 0.28125,-0.75 l 0,-1 z"
id="path43079"
sodipodi:nodetypes="ccccccccccsccccccccccccccccccccccc"
style="color:#000000;fill:#666666;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="16"
viewBox="0 0 16 16"
width="16"
version="1.1"
id="svg6"
sodipodi:docname="cloud-upload.svg"
style="fill:#000000"
inkscape:version="0.92.1 r15371">
<metadata
id="metadata12">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs10" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1016"
id="namedview8"
showgrid="false"
inkscape:zoom="9.8333333"
inkscape:cx="12.20339"
inkscape:cy="12"
inkscape:window-x="1920"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="svg6" />
<path
d="M 0,-8 H 24 V 16 H 0 Z"
id="path2"
inkscape:connector-curvature="0"
style="fill:none" />
<path
d="M 11.98125,6.9383334 C 11.612917,5.0695833 9.971667,3.6666667 8,3.6666667 6.4345833,3.6666667 5.075,4.555 4.3979167,5.855 2.7675,6.0283334 1.5,7.4095833 1.5,9.0833334 1.5,10.87625 2.9570833,12.333333 4.75,12.333333 h 7.041667 c 1.495,0 2.708333,-1.213333 2.708333,-2.7083329 0,-1.43 -1.110417,-2.5891668 -2.51875,-2.6866667 z M 9.083333,8.5416667 V 10.708333 H 6.9166667 V 8.5416667 h -1.625 L 8,5.8333333 10.708333,8.5416667 Z"
id="path4"
inkscape:connector-curvature="0"
style="stroke-width:0.54166669;fill:#666666;fill-opacity:1" />
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="16"
viewBox="0 0 16 16"
width="16"
version="1.1"
id="svg6"
sodipodi:docname="upload.svg"
style="fill:#000000"
inkscape:version="0.92.1 r15371">
<metadata
id="metadata12">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs10" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1016"
id="namedview8"
showgrid="false"
inkscape:zoom="9.8333333"
inkscape:cx="12.40678"
inkscape:cy="11.59322"
inkscape:window-x="1920"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="svg6" />
<path
d="M 0,-8 H 24 V 16 H 0 Z"
id="path2"
inkscape:connector-curvature="0"
style="fill:none" />
<path
d="M 5.7058832,11.441177 H 10.294123 V 6.8529413 H 13.35294 L 8.000008,1.5 2.64706,6.8529413 H 5.7058832 Z M 2.64706,12.970587 H 13.35294 V 14.5 H 2.64706 Z"
id="path4"
inkscape:connector-curvature="0"
style="stroke-width:0.76470536;fill:#666666;fill-opacity:1" />
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB