Giter Club home page Giter Club logo

cfs-file-manager's Introduction

CFS File Manager

File Manager GUI to accompany cfs suite of meteor packages. Allows users to organize files into a hierarchy, select existing files or upload new ones.

Installation

meteor add dbernhard:cfs-file-manager

Setup

This package creates a new collection called FileManagerGroups, and it also needs to know which collections to get files from. To initialize, create a file in your common code that does three things:

First, it needs to tell the package which collections to get files from. Pass an array of Mongo collection instances.

FileManager.includedCollections = [ Images, Documents, ... ];

Second, we need to tell the package where to render the file manager. Use any css selector.

FileManager.wrapperElem = "body";

Finally, we need to declare allow/deny rules that control who can update the FileManagerGroups collection.

if ( Meteor.isServer ) {
   FileManagerGroups.allow({
      insert: function () {
        return true;
      },
      update: function () {
        return true;
      },
      remove: function () {
        return true;
    }
  });
}

You can add deny rules too, if you like. Obviously, the allow/deny rules should match your use case.

Also, if you insert a file with this package, it will add a fileGroupId prop to the file. Make sure you publish this property and that you allow / deny rules allow it to be set!

Use

Launch the file manager as follows:

FileManager.launch(collection, opts, doneCallBack);

collection is the Mongo collection an image will be inserted into.

opts is an object that will be appended to file as metadata (eg, {userId: blah, postId, blahblah ...}).

doneCallBack is a function that takes two arguements: error and fileObject. It will be called once your user has finished with the file manager. The fileObject it returns is an instance of FS.File.

All together then, we have something like this:

FileManager.launch(Images, {userId: '123abc', postId: 'abc123', function (err, fileObject)} {
  if ( err ) {
    alert("Oh snap: your select or upload didn't work");
  } else {
    console.log("You either selected or inserted a file with id ", fileObj._id);
  }
});

NB The file manager will render in the elem you defined above (FileManager.wrapperElem). It's up to you to ensure that this elem exists and that it is visible.

To Do

  • Tests
  • Improve UX (eg, drag and drop moves, etc)

cfs-file-manager's People

Contributors

huevoncito avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.