Closed miladhashemi closed 3 years ago
In any case, I would recommend creating a service provider for this. Store the data required to set up the mountpoints in the user data,
So, You recommend to write SP for this functionality.
The reason for this is that the VFS is not available before after a user has logged in (this can be customized, but I would not recommend it).
Because the vfs is available after user logs in, and this type of remote mountpoint must be added after user athenticated, I had thought if we have this capability per user, can be good, but it really couples with authentication service provider implementation where must get users mountpoints list.
So, You recommend to write SP for this functionality.
Yes. All functionality that's not directly doable inside an adapter I recommend creating a SP for.
This is mostly for "separation of concerns" to keep the code clean, portable and testable :smile:
You can think of it like this: when writing an authentication adapter, it should only do authentication. Anything else (which is called an "effect") should be handled externally.
Why did you close this?
On Sun, Jan 3, 2021, 19:08 SMHashemi notifications@github.com wrote:
Closed #134 https://github.com/os-js/osjs-client/issues/134.
— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/os-js/osjs-client/issues/134#event-4162679401, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABHODAQROGJ5X4AECQLJFTSYCXBDANCNFSM4UIDOUQA .
Because you tell me on another issue if your issue solved close issue. I think the problem solved.
fs.mountpoints.push({name: name, adapter: 'monster', id:item, attributes:{}});
I didn't should close an issue when someone self-assigned it..right?
Hi Using client side service provider for mounting, mountpoints are not added correctly and they are not shown in File Manager application. (Mountpoints with the same name are already added in server side)
start() {
const fs = this.core.make('osjs/fs');
let userObj = this.core.make('osjs/auth').user();
userObj['projects'].map(item => {
this.core.config('vfs').mountpoints.push({name: item, label: item});
fs.mountpoints().push({name: item, label: item});
fs.mount(item);
})
//console.log(this.core.config('vfs').mountpoints); // => it shows added mountpoints
//console.log(fs.mountpoints()); // => it does not show the added mountpoints
}
I tested adding below line code in client index.js file, and the mounting is correctly done!
osjs.config('vfs').mountpoints.push({name: 'demo', label: 'demo'});
As I mentioned in https://github.com/os-js/osjs-server/issues/42#issuecomment-754080889 I don't feel this has been solved.
I strongly discourage mutating the configuration like this on runtime. This is was designed to be static in mind.
Having a proper API method for this is what's needed for this so you don't have to touch parts of the internals that are prone to changes.
Do you think is there any brute force way for for this requirement until a proper API method is developed. 😕
According to @mahsashadi, he made it work. So you can probably use that for the time being.
I tested adding below line code in client index.js file, and the mounting is correctly done!
According to @mahsashadi, he made it work. So you can probably use that for the time being.
First we tested the code in index file:
this.core.config('vfs').mountpoints.push({name: item, label: item});
but it not solve our problem, because we needed mounting done after user logins.(user gets mountpoint name when he logs in, and these names store in session)
For these we create two service provider:
server service provider execute with login signal
client service provider execute after user has successful login.
Server serviceProvider works successfully and mountpoints with name and adapter created:
fs.mountpoints().push({name: item, label: item});
but client service provider that @mahsashadi puts here https://github.com/os-js/osjs-client/issues/134#issuecomment-753931816 didn't work
PR incoming: https://github.com/os-js/osjs-client/pull/139
Published @osjs/client@3.1.1
that allows you to do:
core.make('osjs/fs').addMountpoint({
name: 'example',
label: 'Hello World'
})
You should use depends() { return ['osjs/fs']; }
in your service provider in order for this to work without any issues.
Thank YOU so much @andersevenrud
Great... thanks a lot.
As I mentioned in https://github.com/os-js/osjs-server/issues/42#issuecomment-754158531, I've now changed it so that you can use the .mount()
with an object that now behaves the same as .addMountpoint()
.
So this should be solved now. Please re-open if you have any issues :)
https://github.com/os-js/osjs-server/issues/42
addMountpoint
methodmount
support object, which is a shorthand foraddMountpoint