Mount react-admin under /admin - admin-on-rest

I simply want all of my admin pages to be under /admin.
<Admin
title="Admin"
dashboard={Dashboard}
dataProvider={restClient}
history={history}
>
<Resource
name="users"
list={UserList}
/>
</Admin>
My main page is at /admin but when I click Users in the sidebar, it changes the path to /users and not /admin/users.
I'm using react-admin 2.0.0.

The key is actually in the history prop passed to the Admin component:
import createHistory from 'history/createBrowserHistory';
const history = createHistory({ basename: '/admin' });
<Admin history={history} />

react-router v4 expects a basename prop to arrange what you desire. More info here.
It's not clear that react-admin exposes a way for you to provide this, at least I'm not aware of one.

We had to use nginx and host two completely different apps to do this. It does not seem easy at all to integrate react-admin with another application already using react-router. The documentation provides some help, but the documentation also is often difficult to follow so I was very trepidatious of copying and pasting it's code to try and do this.
Ovverall I've been more frustrated with react-admin the longer I use it; I think there are some great things about the project but the documentation is not well-organized, there's no easy-to-read API reference, and there are a lot of leaky abstractions in that you really have to understand the material-ui, react-final-forms, and of course react-router packages to do anything even remotely 'outside the box' with react-admin.
Sorry to vent, but, my two cents is, split the app or use a different tool.

Not sure it is going to work for all versions.
In my case, the solution with history has not worked.
I've done the following approach:
<Admin basename="/admin">

Related

Is there a way to clear chat history in Webchat which uses DirectlineJS and not React

As per the below github issues link for Chatbot and BotFramework.
https://github.com/microsoft/BotFramework-WebChat/issues/1846
We can clear chat history by assigning a new instance to store variable, which triggers a DIRECT_LINE/DISCONNECT action. Now this works in React Webchat. But, I have tried in Web-chat Java script version and the issue seems to still persist, i.e., when the store variable is replaced the previous chats are not removed.
Any confirmation from the community will be relieving as there are many open issues in Botframework github that its confusing. I'm sharing a few that I found out.
https://github.com/microsoft/BotFramework-WebChat/issues/1293
https://github.com/Microsoft/BotFramework-DirectLineJS/issues/124
If No, can this be achieved in some other way? any suggestions will be helpful.
I was able to resolve it. So, just replacing the variable will not work. You need to render the store variable to update/replace it in webchat.js code.
await window.WebChat.renderWebChat(
{
store: widgetStore
},
document.getElementById('webchat')
);
The BotFramework-WebChat repo provides a sample that demonstrates precisely how to do this. The sample is 04.api/h.clear-after-idle. The readme also includes some caveats to be aware of.

VueJS SPA dynamic baseURL for axios

I've searched and searched and can't seem to find a pattern for this. I'd consider myself an intermediate Vue dev, however, the backend is my strong suit. I'm working on an app that will be white-labeled by resellers. While it's possible to have multiple builds, avoiding that would be ideal. The setup is a stand-alone vue-cli SPA connecting to a Laravel api backend and using the Sanctum auth package. So I need calls to the same domain. The issue: resellers will be on their own domain. The ask: Is there a pattern/solution for dynamically loading configs (mainly baseURL) for different domains (other items would by theme/stylesheet). Currently I have a few typical entries:
i.e. axios.defaults.baseURL = process.env.VUE_APP_API_BASE_URL
Basically, based on the domain the site is being served on, I'd like a dynamic/runtime config. I feel like this has been solved, but I can't seem to use the right search terms for some direction, so anything is helpful. I've tried a few things:
1) Parsing in js, but can't seem to get it to run early enough in the process to take effect? It seems to work, but I can't get it to "click"
2) Hit a public API endpoint with the current domain and get the config. Again, can implement, but can't seem to get it to inject into the Vue side correctly?
Any resources, pattern references or general guidance would be much appreciative to avoid maintaining multiple builds merely for a few variables. That said, I don't think there's much overhead in any of this, but also open to telling my I'm wrong and need multiple builds.
End Result
url visited is https://mydomaincom
then baseURL = https://api.mydomiancom
url visited https://resellerdomaincom
then baseURL=https://api.resellerdomaincom
I don't think there is a common pattern to solve your problem - I haven't found anything on the net.
The best software design solution could be the following:
have a single back-end
distribute only the client to your customers/resellers
Obviously the back end could see the domain of the application from which the request comes and manage the logic accordingly.
Good luck with your project.
Honestly how the question is put it's not really clear to me. Although my usual pattern is to:
Create an axios instance like so:
export const axiosInstance = axios.create({
// ...configs
baseURL: process.env.VUE_APP_URL_YOU_WOULD_LIKE_TO_HIT
})
and then whenever I make a request to some api, I would use this instance.
EDIT: According to your edit, you can either release the client to each customer, and have a .env file for each and every of them, or you can have a gateway system, where the client axios end point is always the same, hitting always the same server, and then from there the server decides what to ping, based on your own logic

Wagtail alongside Django Rest Framework drf-yasg?

I am implementing a Wagtail powered blog within a larger (primarily DRF) driven app. I'm attempting to use drf-yasg for my documentation.
Since installing wagtail, the docs are now throwing
'Request' object has no attribute 'wagtailapi_router'
It looks to be related to the introspection that drf-yasg does, and all I can find about excluding views from drf-yasg is done at the code level. Being an installed module obviously I want to avoid that.
Has anyone got these 2 (3) components playing nicely together?
It's been a very long time since you asked this question, but as I found this while looking for an answer myself, I thought I might share what worked for me.
Note that I'm not using drf-yasg, but rather DRF's own schema generator. They do however have a lot in common.
The problem in my case was that the schema generator URL was defined like this:
path(
"schema/",
get_schema_view(title="My API Schema"),
name="openapi-schema",
),
What I needed to add was a patterns= argument that referenced my API specifically, leaving out the other non-API urls (like Wagtail):
path(
"v3/schema/",
get_schema_view(title="My API Schema", patterns=router.urls),
name="openapi-schema",
),
I hope that helps... someone :-D

Linkedin+Codeigniter : linkedin status update using codeigniter

could any one guide me on how can I update status on linkedin using codeigniter?
Any help appreciated thanks!
I implemented this library into CI to make sure a user could log in with his LinkedIn profile. Maybe you can also update the status of a user.
http://code.google.com/p/simple-linkedinphp/
Implementing it in CI is pretty easy if you know your way around in CI.
I really like it when people write libraries for others to use and the code is commented/well thought out/well structured and is easy to follow.
I tried the other examples, but settled on this one.
http://blog.justni.com/posting-to-linkedin-from-php-and-codeigniter/
Edit:
Having banged my head for a long time on the POS code of Sudhir and the code above. Yes I can change my opinion, because when I started to work on it, it just doesn't work!.
Although I am new to CI, I managed to do the same as P.T and implemented the lib into CI.
The simple-linkedinphp class works like a charm.
I can now authorise an app, authenticate, get profile details and even post to linkedin.
I even posted a comment on Sundir's blog that it doesn't work and he deleted the comment! Stay away, well away if you don't want any headaches!

Url routing in elgg

I am trying to create a social network application using elgg.Since i am pretty new to elgg i like know whether i can define url routing like in cakePHP
I need the url like this
mydomain.com/username instead of mydomin.com/pg/profile/username
Is there any way that i can avoid /pg/ and /mod/ from the urls??
I am using elgg version 1.7.8.
I am not interested in url rewriting with .htaccess.
Thanks in advance
elgg itself is using .htaccess file to redirect /pg, /action etc. So, I think there is no other way than using .htaccess.
Elgg's page handling is pretty bad but you can register handlers as follows.
for /mypage:
elgg_register_page_handler('mypage', function($pages){
//content here
//the $pages parameter is an array. so /mypage/a/b with return
// array('a','b');
});
Matt Beckett has written a profile URL plugin (https://community.elgg.org/plugins/1091233) that, though for 1.8 and above, is only 35 lines of code and does exactly what you ask. You should be able to adapt this quite easily for 1.7.8.
He has also written a fuller page handler hijack plugin that may help if you have other use cases apart from user profiles - see https://community.elgg.org/plugins/854839
It is also only for 1.8 and above, however, and may take more effort to backport than the first.

Resources