summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFulup Ar Foll <fulup@iot.bzh>2015-12-20 21:59:32 +0100
committerFulup Ar Foll <fulup@iot.bzh>2015-12-20 21:59:32 +0100
commit3b1b2ddc4692776318a135a66c1da8c5dee13f64 (patch)
tree18d757de7d82006f0b0b31c03e058cc0c979309e
parent6700ae902ee16d9474098c5435e4cdf210962851 (diff)
Fixed valid/invalid status for app
-rw-r--r--afb-client/app/Frontend/images/appli/isnotvalid.pngbin58558 -> 11124 bytes
-rw-r--r--afb-client/app/Frontend/pages/Sample/Sample.html6
-rw-r--r--afb-client/app/Frontend/widgets/FormInput/UploadFiles.js42
-rw-r--r--afb-client/app/Frontend/widgets/FormInput/newjavascript.js55
4 files changed, 22 insertions, 81 deletions
diff --git a/afb-client/app/Frontend/images/appli/isnotvalid.png b/afb-client/app/Frontend/images/appli/isnotvalid.png
index ee40d2a..057c215 100644
--- a/afb-client/app/Frontend/images/appli/isnotvalid.png
+++ b/afb-client/app/Frontend/images/appli/isnotvalid.png
Binary files differ
diff --git a/afb-client/app/Frontend/pages/Sample/Sample.html b/afb-client/app/Frontend/pages/Sample/Sample.html
index 35523a9..7461d49 100644
--- a/afb-client/app/Frontend/pages/Sample/Sample.html
+++ b/afb-client/app/Frontend/pages/Sample/Sample.html
@@ -21,14 +21,14 @@ animationIn: slideInRight
accept = [image] acceptable accept for upload
-->
<upload-image name="avatar" category="avatar" thumbnail="tux-visitor.png" maxsize="100"
- posturl="/api/post/upload-image" callback="ctrl.FileUploaded" accept="image">
+ posturl="/api/post/upload-image" callback="ctrl.FileUploaded" accept="image" title="Change your Avatar">
</upload-image>
<!-- Warning: name=xxx should match with what server expect [used as xform input name -->
- <upload-audio name=music posturl="/api/post/upload-music" callback="ctrl.FileUploaded"></upload-audio>
+ <upload-audio name=music posturl="/api/post/upload-music" callback="ctrl.FileUploaded" title="Upload your Music"></upload-audio>
<!-- Warning: name=xxx should match with what server expect [used as xform input name -->
- <upload-appli name=appli posturl="/api/post/upload-appli" callback="ctrl.FileUploaded"></upload-appli>
+ <upload-appli name=appli posturl="/api/post/upload-appli" callback="ctrl.FileUploaded" title="Upload AGL App"></upload-appli>
</div>
diff --git a/afb-client/app/Frontend/widgets/FormInput/UploadFiles.js b/afb-client/app/Frontend/widgets/FormInput/UploadFiles.js
index 65269f3..88669a9 100644
--- a/afb-client/app/Frontend/widgets/FormInput/UploadFiles.js
+++ b/afb-client/app/Frontend/widgets/FormInput/UploadFiles.js
@@ -22,12 +22,11 @@
* https://stuk.github.io/jszip/documentation/howto/read_zip.html
* http://onehungrymind.com/zip-parsing-jszip-angular/
* http://stackoverflow.com/questions/15341912/how-to-go-from-blob-to-arraybuffer
+ *
+ * Bugs: zip file sent even when flag as invalid
*/
-
-function changeInput() {
- console.log ('input imgClicked');
-}
+
(function() {
'use strict';
@@ -40,10 +39,6 @@ var tmpl = '<input type="file" name="{{name}}-input" onchange="angular.element(
'</div>';
-function Basename(path) {
- return path.split('/').reverse()[0];
-}
-
// Service Create xform insert files in and Post it to url
function LoadFileSvc (scope, elem, posturl, files, thumbnailCB) {
var xmlReq = new XMLHttpRequest();
@@ -105,16 +100,18 @@ function LoadFileSvc (scope, elem, posturl, files, thumbnailCB) {
return;
}
- scope.Basename=Basename(file.name);
+ scope.Basename= file.name.split('/').reverse()[0];
scope.imgElem[0].file = file;
// If File is an image let display it now
if (thumbnailCB) {
var reader = new FileReader();
reader.readAsArrayBuffer(file);
- reader.onload = thumbnailCB;
- }
-
+ reader.onload = function (target) {
+ var status = thumbnailCB (target);
+ //if (status) xform.append(scope.name, file, file.name);
+ };
+ }
// if everything is OK let's add file to xform
xform.append(scope.name, file, file.name);
}
@@ -123,7 +120,7 @@ function LoadFileSvc (scope, elem, posturl, files, thumbnailCB) {
// everything looks OK let's Post it
xmlReq.open("POST", posturl , true);
xmlReq.send(xform);
-};
+}
angular.module('UploadFiles',['ConfigApp', 'ModalNotification', 'RangeSlider'])
@@ -148,11 +145,11 @@ angular.module('UploadFiles',['ConfigApp', 'ModalNotification', 'RangeSlider'])
scope.UpLoadFile=function (files) {
var readerCB = function (upload) {
// scope.thumbnail = upload.target.result;
- scope.imgElem[0].src = window.URL.createObjectURL(new Blob([upload.target.result], {type: "image"}));
- scope.$apply('thumbnail'); // we short-circuit Angular resync image
+ scope.imgElem[0].src = window.URL.createObjectURL(new Blob([upload.target.result], {type: "image"}));
+ return true; // true activates post
};
var posturl = attrs.posturl + "?token=" + ConfigApp.session.token;
- LoadFileSvc (scope, elem, posturl, files, readerCB);
+ new LoadFileSvc (scope, elem, posturl, files, readerCB);
};
// Initiallize default values from attributes values
@@ -204,7 +201,7 @@ angular.module('UploadFiles',['ConfigApp', 'ModalNotification', 'RangeSlider'])
// Upload is delegated to a shared function
scope.UpLoadFile=function (files) {
var posturl = attrs.posturl + "?token=" + ConfigApp.session.token;
- LoadFileSvc (scope, elem, posturl, files, false);
+ new LoadFileSvc (scope, elem, posturl, files, false);
};
// Initiallize default values from attributes values
@@ -265,15 +262,14 @@ angular.module('UploadFiles',['ConfigApp', 'ModalNotification', 'RangeSlider'])
if (!thumbnail) {
console.log ("This is not a valid Application Framework APP");
scope.thumbnail=ConfigApp.paths[scope.category] + 'isnotvalid.png';
- scope.$apply('thumbnail'); // we short-circuit Angular resync image
- return;
+ scope.$apply('thumbnail'); // we short-circuit Angular resync Image
+ return false; // do not post zip on binder
}
- scope.imgElem[0].src = window.URL.createObjectURL(new Blob([thumbnail.asArrayBuffer()], {type: "image"}));
- scope.$apply('thumbnail'); // we short-circuit Angular resync image
+ scope.imgElem[0].src = window.URL.createObjectURL(new Blob([thumbnail.asArrayBuffer()], {type: "image"}));
+ return true; // true activates post
};
-
var posturl = attrs.posturl + "?token=" + ConfigApp.session.token;
- LoadFileSvc (scope, elem, posturl, files, readerCB);
+ new LoadFileSvc (scope, elem, posturl, files, readerCB);
};
// Initiallize default values from attributes values
diff --git a/afb-client/app/Frontend/widgets/FormInput/newjavascript.js b/afb-client/app/Frontend/widgets/FormInput/newjavascript.js
deleted file mode 100644
index 10280c7..0000000
--- a/afb-client/app/Frontend/widgets/FormInput/newjavascript.js
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2015 fulup
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
- var reader = new FileReader();
- // Closure to capture the file information.
- reader.onload = (function(theFile) {
- return function(e) {
- var $title = $("<h4>", {
- text : theFile.name
- });
- $result.append($title);
- var $fileContent = $("<ul>");
- try {
-
- var dateBefore = new Date();
- // read the content of the file with JSZip
- var zip = new JSZip(e.target.result);
- var dateAfter = new Date();
-
- $title.append($("<span>", {
- text:" (parsed in " + (dateAfter - dateBefore) + "ms)"
- }));
-
- // that, or a good ol' for(var entryName in zip.files)
- $.each(zip.files, function (index, zipEntry) {
- $fileContent.append($("<li>", {
- text : zipEntry.name
- }));
- // the content is here : zipEntry.asText()
- });
- // end of the magic !
-
- } catch(e) {
- $fileContent = $("<div>", {
- "class" : "alert alert-danger",
- text : "Error reading " + theFile.name + " : " + e.message
- });
- }
- $result.append($fileContent);
- }
- })(f); \ No newline at end of file