Coder Social home page Coder Social logo

n1crack / vuefinder Goto Github PK

View Code? Open in Web Editor NEW
231.0 5.0 68.0 3.89 MB

Empower your Vue.js applications with this versatile and customizable file manager component, simplifying file organization and navigation.

Home Page: https://vuefinder.ozdemir.be

License: MIT License

Vue 46.42% JavaScript 36.90% CSS 2.66% TypeScript 0.57% HTML 0.26% SCSS 13.20%
vue file-manager explorer webmanagementtools vue3 tailwindcss vite component media-library

vuefinder's Introduction

Vuefinder File Manager

GitHub npm

About

Vuefinder is a file manager component for Vue.js version 3

Demo

Live Demo [ Source ]

Installation

npm i vuefinder

JS entry point (it can be index.js or main.js)

import { createApp } from 'vue'
import App from './App.vue'

import 'vuefinder/dist/style.css'
import VueFinder from 'vuefinder/dist/vuefinder'

const app = createApp(App)

//By default, Vuefinder will use English as the main language. 
// However, if you want to support multiple languages and customize the localization, 
// you can import the language files manually during component registration.
app.use(VueFinder)

app.mount('#app')
 

Localization

You can manually import the localization files from the package and register them with Vuefinder. The localization files are located in the dist/locales folder.

import en from 'vuefinder/dist/locales/en.js'
import tr from 'vuefinder/dist/locales/tr.js'
import ru from 'vuefinder/dist/locales/ru.js'

app.use(VueFinder, {
  i18n: { en, tr, ru }
});

Async Localization

Alternatively, you can import the localization files asynchronously during component registration. This can be useful for lazy loading or if you prefer to load the files dynamically.

app.use(VueFinder, {
  i18n: {
    en: async () => await import("vuefinder/dist/locales/en.js"),
    de: async () => await import("vuefinder/dist/locales/de.js"),
    // Add more locales as needed
  }
});

Vue Template

<div>
    <vue-finder id='my_vuefinder' :request="request"></vue-finder>
</div>
...

<script setup>
  const request = "http://vuefinder-php.test"
  
  // Or ...
  const request = {
    // ----- CHANGE ME! -----
    // [REQUIRED] Url for development server endpoint
    baseUrl: "http://vuefinder-php.test",
    // ----- CHANGE ME! -----

    // Additional headers & params & body
    headers: { "X-ADDITIONAL-HEADER": 'yes' },
    params: { additionalParam1: 'yes' },
    body: { additionalBody1: ['yes'] },

    // And/or transform request callback
    transformRequest: req => {
      if (req.method === 'get') {
        req.params.vf = "1"
      }
      return req;
    },

    // XSRF Token header name
    xsrfHeaderName: "X-CSRF-TOKEN",
  }
</script>

Styling

Vuefinder uses the BEM (Block Element Modifier) convention for its CSS classes, with default styles applied using TailwindCSS. This structured approach helps maintain a clear and consistent naming convention for CSS classes, making it easier to understand and manage styles across the project.

To customize or update the styles, simply find the appropriate BEM class in the component’s style section and override the styles as needed.

Props

Prop Value Default Description
id string null required
request string/object object required - backend url or request object, see above
locale string en optional - default language code
theme string system optional - default theme, options: "system","light","dark"
max-file-size string 10mb optional - client side max file upload
max-height string 600px optional - max height of the component
features array null optional - array of the enabled features
path string null optional - initial directory, example: 'media://public'
persist boolean false optional - keep current directory on page refresh
full-screen boolean false optional - start in full screen mode
select-button object object optional - adds select button in status bar, see example

Events

Event Description
@select="callback" The callback function is invoked when the user selects a file or folder, and the selected elements are passed as arguments

Selection

There are 2 ways to select files and folders.

First one, you can use the select button in the status bar. To enable the select button, you can use the select-button prop. when you set the select-button active to true, the select button will be visible in the status bar.

<vue-finder
  id='my_vuefinder'
  :request="request"
  :select-button="handleSelectButton"
/>

<script setup>
  // other codes

  const handleSelectButton = {
    // show select button
    active: true,
    // allow multiple selection
    multiple: false,
    // handle click event
    click: (items, event) => {
      if (!items.length) {
        alert('No item selected');
        return;
      }
      alert('Selected: ' + items[0].path);
      console.log(items, event);
    }
  }
</script>

Alternatively, you can use the select event to get the selected items.

<vue-finder
  id='my_vuefinder'
  :request="request"
  @select="handleSelect"
/>

<script setup>
  // other codes
  
  // we can define a ref object to store the selected items
  const selectedFiles = ref([]);
  
  // handle select event, and store the selected items
  const handleSelect = (selection) => {
    selectedFiles.value = selection
  }
  // then with a button click, you can get the selected items easily
  // you can add this method to the click event of a button. 
  const handleButtonClick = () => {
    console.log(selectedFiles.value);
  }
</script>

Features

  • Multi adapter/storage (see https://github.com/thephpleague/flysystem)
  • File and folder operations
    • Create a new file
    • Create a new folder
    • Rename
    • Delete
    • Archive (zip)
    • Unarchive (unzip)
    • Text editing
    • Image Crop Tool
    • Upload / Download files
    • Search (deep based on current folder)
  • Nice UI
    • Context Menu
    • Breadcrumb links
    • Toolbar
    • File explorer
    • Status bar
    • Image thumbnails
    • Toast notifications
  • Appearance
    • Multi language
    • Full Screen
    • View Modes: list, grid
    • Dark Mode
  • Accessibility
    • Drag & drop support
    • Move items (to a folder or up one folder) with drag and drop
    • Mouse selection

Backend

You can use any backend language. Just be sure, the response should be compatible. If you develop a backend library for another language, please let me know to add it here.

Collaboration

If you want to contribute to the project, please feel free to fork the repository and submit your changes as a pull request. Ensure that the changes you submit are applicable for general use rather than specific to your project.

Dependencies

License

Copyright (c) 2018 Yusuf ÖZDEMİR, released under the MIT license

vuefinder's People

Contributors

abichinger avatar andreas-lundgren-qlucore avatar byawitz avatar daedalus11069 avatar dreamlandowo avatar hughsaffar avatar mldmoritz avatar n1crack avatar tazaq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

vuefinder's Issues

Preflight styles applying to elements outside of component

This is related to #31, wherein the following code(reduced for brevity), was added to the tailwind config:

preflightStyles.walkRules((rule) => {
    rule.selector = ".vuefinder " + rule.selector;
});

While this works for the most part, it's still causing a leak because the preflight uses commas in several rules. I wasn't sure if creating a repo/PR for this was overkill because of how minor the change is, so here's the simple bug report/fix.

I was able to fix this on my side with a simple change to the above:

preflightStyles.walkRules(rule => {
  rule.selector = rule.selectors
    .map(selector => ".vuefinder " + selector)
    .join(",");
});

Showing error on npm install

Showing error on npm install

` error in ./node_modules/vuefinder/src/components/Explorer.vue?vue&type=style&index=0&id=2c3bb2b3&lang=scss&scoped=true&

Syntax Error: SassError: expected selector.

81 │ /deep/ .vuefinder-items-enter-active{
/Sites/vehicle/node_modules/vuefinder/src/components/Explorer.vue 81:1 root stylesheet
`

Node version: v12.18.1
NPM version: 6.14.11

File download ignoring "url" property (if present) on file entries?

In ContextMenu.vue:

download: {
    title: () =>  t('Download'),
    action: () => {
      const url = apiUrl.value + '?' + buildURLQuery({q:'download', adapter: props.current.adapter, path: selectedItems.value[0].path});
      emitter.emit('vf-download', url);
    },
  },

But some file entries might have a "url" property and it seems to me that this property should be used as the url to pass to vf-download. An adapter on the server side like S3 might be returning pre-signed S3 urls for files, right? Your vuefinder-php backend is:

$config = [
    'publicLinks' => [
        'local://public' => 'http://example.test',
    ],
];

and for files in the public folder, the url property is set to http://example.test/... but the vuefinder component is not downloading from this location, its calling APIURL?q=download instead.

Is this an oversite, or am I doing something wrong? In my use case, my backend is a lot like S3 and will return "url" properties for files, and I need the client to download from those urls.

Vuefinder locale doesnt work and download files twice

I'm using Vuefinder with Nuxt 3 and set it up as a plugin. It's an awesome library, but I have two problems

When I try to change the default language of the library to another one, it never gets changed and always displays in English. This is the configuration of my Vuefinder plugin:

import 'vuefinder/dist/style.css';
import VueFinder from 'vuefinder/dist/vuefinder';

export default defineNuxtPlugin(({ vueApp }) => {

    vueApp.use(VueFinder, {
        i18n: {  es: async () => await import("vuefinder/dist/locales/es.js") }
      });
});

And this is how I call Vuefinder in a view:

<template>
    <div>
        <VueFinder :request="request" locale="es"></VueFinder>
    </div>
</template>
<script setup>
const request = `apiUrl`
</script>

The second problem is that when I download a file, it usually downloads twice. I have also been investigating the example displayed, and this problem also occurs.

In the following image you can see how a download is performed twice in the displayed example

image

Thanks in advance!

Localisation Select button

Hello Yusuf!
Thank you so much for your package, it's really a big deal, I found this solution recently and decided to apply it in my projects.
I am very glad that your package has localization, but I could not find a button for :select-button, is it hard-coded text or do I need to add a line in the localization file?

image

Error removeListener with v-show

An error is generated when the component is no longer displayed with a v-if, for example.

image

I think it's because the ref="root " no longer exists in the unmounted function in useHotkeyActions.js composable.

Missing auth token in download requests

With this configuration

script...

const accessToken = useCookie('accessToken').value
const request = {
  baseUrl: "/api/auth/vuefinder/"+ currentId,
  headers: { Authorization: `Bearer ${accessToken}`, Accept :'application/json'}
}
const vuefinderFeatures = [
  'download',
  'search'
];

template...
<vue-finder id="vf" theme="light" :features="vuefinderFeatures" :request="request" :select-button="handleSelectButton"></vue-finder>

the download action is performed without the Bearer token

tailwindcss

I am trying to use veufinder in a Quazar -based app. This app does not use tailwinds. Some of the important styling is missing when I am using this component and I am not sure how to get it working. I've tried some suggestions I found on the web, but so far nothing is working.

It seems to me that a lot is missing from dist/style.css. Like all the base tailwind css. Is there a way to build vuefinder dist such that style.css contains everything, and that any "user" of vuefinder does not need to depend on tailwind at all?

Error: Cannot parse server response.

Hi,
I'm getting a "Cannot parse server response." error while trying to upload a large .zip file, see screenshot.
I set the max-file-size='10000MB' and inside php.ini upload_max_filesize = 10000M.
Screenshot from 2024-02-29 10-19-14

Thanks.

Choose dark mode based on browser settings

For my project I used Tailwind and so we're using the dark: classes too. Is there a way to let the browser decide which version it should use, without having to code a check? I did this, but unlucky:

const prefersDark = ref(false);

onMounted(() => {
    prefersDark.value = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
});

const isDarkMode = computed(() => prefersDark.value);
<VueFinder id="finder" :url="`/filemanager/order/${order.id}`" :dark="isDarkMode" locale="de"></VueFinder>

Bug: file uploading doesn't work with any type of files

  • Vuefinder 2.4.3 (also tried 2.2.7)
  • Nuxt 3.11.2
  • Vue 3.4.27
  • Yarn 4.2.2
  • Node 20.13.1

When trying to upload any type of files get an error from Uppy package dependency used in Vuefinder:
image
I've tried to upload various types of images (webp, png, jpg), audio files (mp3), but result remains the same.
image
Vuefinder usage in my project:
image
image

deep Error

Hi there,
thank you for your great file browser.
At the moment I get the following message

` error in ./node_modules/vuefinder/src/components/FilePreviewer.vue?vue&type=style&index=0&id=5a99ec95&lang=scss&scoped=true&

SassError: expected selector.

95 │ /deep/ .vuefinder-text-preview{
│ ^

`
Maybe you have a fix for that ?

Thanks in advance.

attributes not work at all

Hey mate, I hope you were ok.

None of attributes (ex. dark, locale) are working! Please check these attr's and If you have a free time please fix there.
Thank you

Unhandled error during execution of unmounted hook in nuxt3

when i trying to unshow the VueFinder component, I'm faced with this error

image

Code sample:

<template>
  <PageHeader title="Website uploads"></PageHeader>

  <PageBody>
    <a href="#" @click.prevent="show = false">Hide</a>
    <VueFinder :request="`${runtimeConfig.public.appUrl}/api/crm/uploads`" v-if="show"/>
  </PageBody>
</template>

<script setup>
definePageMeta({
  middleware: 'auth',
  nav: 'uploads',
});

const runtimeConfig = useRuntimeConfig();

const show = ref(true);
</script>

This behavior is watching only in dev-mode in Nuxt3. Generated version of App works fine

REST API?

Looks like an awesome component! I have a NodeJS backend that implements a virtual file system. I wouldn't be able to use your php server ... not without spending a lot of time creating a custom adapter and having that talk to my existing backend. But if you happen to have documentation on the REST interface between your vue code and your php server, I could use that to create the required endpoints in my backend.

I can reverse engineer some of that using your live demo, but its read-only so I can't try "write stuff".

Add support for sending headers with previewing items

Currently, the VueFinder file manager's preview feature lacks support for sending custom headers, such as Authorization headers containing JWT tokens, when fetching images or loading videos, previewing pdfs etc..

This limitation arises because the preview feature utilizes straightforward URLs in the tag to display images, which does not allow for the inclusion of headers in the requests.

We can disable the preview feature, if the Authentication header is set. And show only the public links if they are set. This is the easiest solution I think.

If we want to show previews of auth protected items, there are some discussions to look at first:

https://alphahydrae.com/2021/02/how-to-display-an-image-protected-by-header-based-authentication/

https://stackoverflow.com/questions/46642960/authorization-header-in-img-src-link

Btw, out of context, while talking about previews, when displaying folder with a large amount of images like more than 50 or 100, i'm thinking to disable the preview in grid view. It will increase performance.

nuxt3 support

I am developing an application for Nuxt 3. Vuefinder works with both frontend and backend api. But when I import it as vuefinder as plugin, I get an error.

plugins/vue-finder.ts

import "vuefinder/dist/style.css";
import VueFinder from "vuefinder/dist/vuefinder";

export default defineNuxtPlugin(async (nuxtApp) => {
  nuxtApp.vueApp.component("vue-finder", VueFinder);
});

Error:
require() of ES Module C:\Users\x-pt1\Desktop\programlar\vuefinder-nuxt3\node_modules@uppy\core\lib\index.js from C:\Users\x-pt1\Desktop\programlar\vuefinder-nuxt3\node_modules\vuefinder\dist\vuefinder.cjs not supported. Instead change the require of index.js in C:\Users\x-pt1\Desktop\programlar\vuefinder-nuxt3\node_modules\vuefinder\dist\vuefinder.cjs to a dynamic import() which is available in all CommonJS modules.

Large Dataset performance

The performance is poor (and memory-hungry) when the listing is large, in my case 12k entities.
Can lazy loading be used or something like virtual-scroller.

version mismatch

I encountered a challenge related to CSS overriding within version 1.2.5 of our project. In an attempt to find relevant documentation or discussions addressing this issue, I conducted a thorough search but found no pertinent resources. Subsequently, I opted to proceed with upgrading the project version.

Upon initiating the installation process, I observed that the update incremented by only a minor version, leaving the project at version 1.2.6. However, upon further investigation, I discovered that the latest available version stands at 2.2.2.

SFTP Surpport

Hello, Can someone help me on how I can use this on sFTP or FTP with Javascript or Python

WordPress integration

Is possible to integrate this component with WordPress and limit what users can see based on WP permissions?

adapter about remote api

example:

            getIndex(url, path = null) {
                if (!url) {
                    this.msgBox('There is no url defined.', 'error');
                    return;
                }
                this.loading = true;
                axios(url, {
                    params: {
                        q: 'index',
                        path: path
                    }
                }).then(response => {
                    this.data = response.data;
                    this.loading = false;
                }).catch(error => {
                    this.msgBox(error.message, 'error')
                });
            }

change to like this:

            getIndex(path = null) {
                this.loading = true;
                this.apiAdapter.fetchIndex(path).then(data => {
                    this.data = data;
                    this.loading = false;
                }).catch(error => {
                    this.msgBox(error.message, 'error')
                });
            }

the other develper can build their adapter use different api

Data as prop

Is it possible to handle requests manually / pass data as a prop?

Im currently using amplify to handle the authentication on requests. Would be great to be able to return a custom request response via callback or pass the files data as a prop with emits to handle changes

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.