storj-archived / browser

A Vue component for managing files on Storj, via gateway-mt.
GNU General Public License v3.0
5 stars 4 forks source link

storj/browser

prettier

A Vue component for managing files on Storj, via gateway-mt.

screenshot

Development

Use Iris.

Integration

Install

Right now, storj/browser is not published to npm, so you have to install it from the git repo. This can be done by referencing a specific commit and adding it to your package.json.

"dependencies": {
    ...
    "browser": "git+https://github.com/storj/browser#e2f7fd2b7a8502c41ca13b5fa0987df659e58efa",
},
npm install

Add Vuex module

In order to use the file browser, we need to add the files module to our app store.

import { files } from "browser";
export default new Vuex.Store({
  state: {
      ...
  },
  mutations: {
      ...
  },
  actions: {
      ...
  },
  modules: {
    files
  }
})

Create page to instantiate FileBrowser

<style scoped>
    @import "../node_modules/browser/dist/browser.css";
</style>
<template>
    <div class="home">
        <div class="file-browser">
            <file-browser></file-browser>
        </div>
    </div>
</template>
<script>
    import { FileBrowser } from "browser";

    export default {
        name: "FileBrowserPage",
        data: () => ({
            displayCredentials: true,
            endpoint: "gateway.tardigradeshare.io",
            accessKey: "",
            secretKey: "",
            bucket: "",
            browserRoot: "/"
        }),
        created() {
            this.$store.commit("files/init", {
                endpoint: this.endpoint,
                accessKey: this.accessKey,
                secretKey: this.secretKey,
                bucket: this.bucket,
                browserRoot: this.browserRoot
            });
        }
    };
</script>

Add MyFileBrowserPage.vue to your router

import MyFileBrowserPage from "../views/MyFileBrowserPage.vue";

const routes = [
    {
        path: "/",
        name: "Home",
        component: MyFileBrowserPage,
        children: [
            {
                path: "*",
                component: MyFileBrowserPage
            }
        ]
    }
];