Angular Pallet Bundle
This library is a directive that wraps the following:
-
Angular-Pallet: it's an angular directive to perform asynchronous file uploads. It's built on top of Ng-File-Upload and it was created to play with Paperclip Upload gem.
-
Angular-Progress: directive that allows you to show progress status as a bar or percentage badge.
-
Angular-Doc-Preview: directive that allows you to show a file preview from a given url.
This directive is not intended to be a replacement for Ng-File-Upload. Rather, it uses its potential and prevents you to deal with annoying details like:
The visual representation of the upload progress.
The visual representation of errors in the upload process.
The file preview. Not only images, files of any kind.
The visual representation of the multiple files to upload.
As "the icing on the cake", it handles the upload process asynchronously using the angular-pallet directive.
Installation
bower install ng-file-upload --savebower install https://github.com/platanus/angular-pallet-bundle --save
Include the JS files in your project and the library as an Angular Dependency
angular;
The library comes with a proposed stylesheet under
/dist/angular-pallet-bundle.css
. You can use it or create your own.
Usage
To make it simple, I'm going to show you a use case example...
Suppose you have a User
model. This model has two attributes: avatar
(user photo) and file
(a document or spreadsheet). So, from your application, you want to let the user:
- Upload the avatar. See a preview (a thumbnail maybe), be sure the upload was successful.
- Upload the file. See a preview (a link), be sure the upload was successful.
- Submit the form and link all the user data on the server.
In order to make this directive work, the POST /uploads
response must be a json with the following format:
Paperclip Upload solves the server side for you.
Directive Options:
Mandatory
- ng-model: to keep the identifier(s) of the uploaded file. If multiple attribute is "true", the model will have a value like this:
["EJ6pOl5Y", "ZN5BaK3j"]
otherwise"EJ6pOl5Y"
. - upload-url: must contain the url to perform the
POST
to save files.
Optional
- no-document-text: custom message to show when the url is empty. By default, will show nothing.
- render-image-as: this option is only for images. You can choose, to show images: as
link
orthumb
. If this attribute is not present will show thumbnail and link. - progress-type: with
"bar"
value, will show a progress bar. Withindicator
value will show a progress badge with this format{progress}%
(for example 35%). Default isindicator
. - multiple: if present, multiple upload functionality will be enabled.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Credits
Thank you contributors!
angular-pallet-bundle is maintained by platanus.
License
angular-pallet-bundle is © 2015 platanus, spa. It is free software and may be redistributed under the terms specified in the LICENSE file.