totaljs / openplatform

OpenPlatform v5 is a beautiful and simple portal for running, integrating and managing multiple 3rd party web applications.
https://www.totaljs.com/openplatform/
MIT License
95 stars 44 forks source link

Extendable bundle? #66

Open Invincible83 opened 8 months ago

Invincible83 commented 8 months ago

Hello,

Is there any way to extend setup plugin in bundle? I would like to add a new page with extra settings. However I want to keep the OpenPlatform intact.

I'm thinking something like this:

bundles/openplatform.bundle
plugins/setup/--index.js
plugins/setup/public/mypage.html
petersirka commented 8 months ago

Hi @Invincible83, we have added a small support for extending setup interface.

Quick summary:

Invincible83 commented 8 months ago

Hello,

Nice. This is extactly what I mean. Is there something else I should do? I'm trying it and this is where I get, as far. (I used the profiles plugin from openplatform-application for testing)

This is the openplatform directory structure

bundles/openplatform.bundle
plugins/profiles/index.js
plugins/profiles/public/index.html
plugins/profiles/...

index.js

exports.icon = 'ti ti-totaljs';
exports.name = '@(Profiles)';
exports.position = 2;
exports.permissions = [{ id: 'profiles', name: 'Profiles' }];
exports.visible = user => user.sa || user.permissions.includes('profiles');
exports.type = 'setup'; // extends the `setup` plugin
exports.routes = [
    { url: '/profiles/{id}/', html: 'detail' }
];

exports.install = function() {
    ROUTE('+API    /api/    -profiles    *Profiles   --> list');
};

It kind of works. I have profiles link in setup menu. Yet, when I click on it, I get this errors in the console

mytesting.com/_profiles/pages/setup.html?language=en 404 (Not Found)
jC: invalid response for IMPORT("/_profiles/pages/setup.html")  [{…}]

Sorry to bother you, Thank you

petersirka commented 8 months ago

I tested it. I don't know about it, but you must move the file /public/index.html to /public/pages/index.html and it will work. Be careful with API endpoints, they must be in the form /setup/.

Invincible83 commented 8 months ago

Can you please upload your testing version?

As far I see, there https://github.com/totaljs/openplatform/blob/master/plugins/setup/index.js#L55-L63 is no obj.routes even in setup/index.html it's counting on it. https://github.com/totaljs/openplatform/blob/master/plugins/setup/index.html#L80C1-L86

And there is static setup.html. I believe this should be index.html. https://github.com/totaljs/openplatform/blob/master/plugins/setup/index.html#L79

Invincible83 commented 8 months ago

Sure, so I had some time to spare and did some tests. I found that my suspicions were correct. It's the /setup.html in the component. The second I changed it to /index.html , it started working.

https://github.com/totaljs/openplatform/blob/master/plugins/setup/index.html#L79C95-L79C112