summaryrefslogtreecommitdiffstats
path: root/afb-client/app/Frontend/pages/Sample
diff options
context:
space:
mode:
Diffstat (limited to 'afb-client/app/Frontend/pages/Sample')
-rw-r--r--afb-client/app/Frontend/pages/Sample/Sample.html25
-rw-r--r--afb-client/app/Frontend/pages/Sample/SampleModule.js40
2 files changed, 23 insertions, 42 deletions
diff --git a/afb-client/app/Frontend/pages/Sample/Sample.html b/afb-client/app/Frontend/pages/Sample/Sample.html
index e7e9164..35523a9 100644
--- a/afb-client/app/Frontend/pages/Sample/Sample.html
+++ b/afb-client/app/Frontend/pages/Sample/Sample.html
@@ -1,5 +1,4 @@
-<!-- comment -->
-
+<!-- Foundation Annotations generate tmp/route.js -->
---
name: mysample
url: /sample
@@ -8,16 +7,28 @@ animationIn: slideInRight
---
<h1><img class="logo" src="images/logo/triskel_iot_bzhx250.png" alt="IoT.bzh Logo" style="height:150px;">
- Not Working
+ Post File Upload
</h1>
<div class="sample-box box-content">
- <upload-file name="avatar" category="avatars" icon="tux-visitor.png"></upload-file>
+ <!-- Usage: upload-xxxxx
+ name = [xxxxxx] is use a field label for xform input field. Should match with server side
+ category = [avatar] should match to a valid directory of thumbnail within AppConfig.path
+ thumbnail= [tux-bzh.png] a valid image within AppConfig.paths.[category]
+ istoobig = [istoobig.png] used image from AppConfig.paths.[category] when file is oversized
+ maxsize = [xxx] maximum size in KB [default max depend on upload-type]
+ 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">
+ </upload-image>
- <submit-button class="sample-button" icon="fi-zoom-in" label="Vol+" clicked="ctrl.MuteOn" ></submit-button>
- <submit-button class="sample-button" icon="fi-zoom-out" label="Vol-" clicked="ctrl.MuteOff" ></submit-button>
- <submit-button class="home-button" icon="fi-upload" label="Refresh" clicked="ctrl.UploadFile" ></submit-button>
+ <!-- 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>
+
+ <!-- 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>
</div>
diff --git a/afb-client/app/Frontend/pages/Sample/SampleModule.js b/afb-client/app/Frontend/pages/Sample/SampleModule.js
index 2a2e777..8ae82ea 100644
--- a/afb-client/app/Frontend/pages/Sample/SampleModule.js
+++ b/afb-client/app/Frontend/pages/Sample/SampleModule.js
@@ -2,46 +2,16 @@
'use strict';
// list all rependencies within the page + controler if needed
-angular.module('SampleModule', ['SubmitButton','UploadFile'])
+angular.module('SampleModule', ['SubmitButton','UploadFiles'])
.controller('SampleController', function ($http) {
- var self = this; // I hate JavaScript
- this.status='muted-off';
+ var scope = this; // I hate JavaScript
- console.log ("sample controller");
-
- this.MuteOn = function() {
- console.log ("Muted");
- // send AJAX request to server
- var handler = $http.post('/api/dbus/ping', {type:'mute', action: "on"});
-
- handler.success(function(response, errcode, headers, config) {
- self.status = 'muted-on';
- });
-
- handler.error(function(status, errcode, headers) {
- console.log ("Oops /api/dbus/pring err=" + errcode);
- self.status = 'muted-error';
- });
- };
+ console.log ("sample Init");
- this.MuteOff = function() {
- console.log ("UnMuted");
- // send AJAX request to server
- var handler = $http.post('/api/dbus/ping', {type:'mute', action: "off"});
-
- handler.success(function(response, errcode, headers, config) {
- self.status = 'muted-off';
- });
-
- handler.error(function(status, errcode, headers) {
- console.log ("Oops /api/dbus/ping err=" + errcode);
- self.status = 'muted-error';
- });
-
+ scope.FileUploaded = function (response) {
+ console.log ("FileUploaded response=%s", JSON.stringify(response));
};
-
-
});
console.log ("SampleControler Loaded");