In this episode, John and Pedro answer questions about CRON jobs, Directus Insights, and bulk editing.
Speaker 0: Hey, everyone. Welcome to a holiday special of from the field q and a with p and j. This will be the last one for the year. We're all taking a holiday break so we can focus on some actual work, but this has been fun. But, again, welcome to this holiday episode of from the field with p and j.
I am John.
Speaker 1: And I'm Pedro. Thanks so much for joining us this year and submitting all your questions. We we definitely appreciate all of that and all the comments to continue to improve this video series. So let's dive in for the last episode of the year into some questions. Alright.
So first question of the episode, a lot of the users and customers we've talked to recently have asked about roles and permissions, and we've gone over this a little bit. But, John, could you could you walk us through maybe a video on creating one from scratch?
Speaker 0: Yeah. I I think it'd just be beneficial to start one of these from scratch. So we'll pull up a screen share here and and show you guys how to create something from scratch, say, for a content editor. So alright, everyone. Let's create a new user.
We'll go into settings and you we're do new role and permission just off from scratch. So we're gonna call them a content editor. Not admin access. We'll save this. And here's where you can enable roles.
As you can see, everything is default deny. So what we first wanna do, we just want them to see articles and be able to create articles. So up here, you've got your full CRUD. We'll go into articles and we will give them all access to create, all access to see, and edit. But we don't want them to delete.
So we'll not let them delete. We might as well also let them have translations access. Alright. So now we've given them access to that. Alright.
So what I'm gonna do is I'm gonna log out and log back in as that user. Actually, first, let's assign it. So now when we log in as this new user role, we'll log in and we'll only be able to see articles. And you can see here articles. I could see article translations if I wanted.
We'll go in and see I did not create this article as this user, so I cannot go in and I cannot edit things. Don't have permission. But we could go back into articles and we could create new. Alright. So hopefully, that was a great look into creating a a role and a permission from scratch.
Hopefully, it was a deep enough dive for some of you. The next question is, is it possible to put a cron job in place to collect data from external API or external sources and then update something in the database on another cron another cron job, you know. Every day, for example, can we update something with new new information?
Speaker 1: Yeah. Absolutely. And let me show you here in this video. Alright. So we're going to do this using flows.
I've already created one for the Stripe API. We're gonna be putting a CronJob in place to collect data from that Stripe API and update something in the database. And it's already set up, so we'll go ahead and go to trigger setup. And we'll have a few options here when we first create event hook, webhook, and schedule cron so we're gonna go ahead and do that and let's run this daily at 8 in the morning go ahead and save those changes and now this is an active API integration pulling in data to the database. So we've been asked a lot of questions over the last, you know, few weeks, few months about our insights panel, and we've got some new options coming for the insights module, in in the coming weeks months, so it might be beneficial to do a quick overview, John, of the panel in general and and maybe create a new chart and show people what's possible today and maybe hint at what's coming in the future.
Speaker 0: Yeah. Well, I I think we have some new visual layouts, like some some pie charts and multiline charts coming here in the near future. So I think, again, kind of how we did it with the first example, it might be best and most of you seem to like when we screen share anyway. So let's pull up another example of creating an insights dashboard from some information that is in the database. So alright.
So here again, we are in my demo example. And anything that you're keeping track of in the database, you can actually put into our insights panel. So we do have a table here for metrics. We'll go and let's, let's add GitHub stars. So we'll go into here.
We'll go into our insights panel. Let's do social media. That's what I consider GitHub, although it's not. But, we'll edit panels and we'll create a new panel. This is where there's a bunch of options here, but I just wanna see how my star growth has been.
So, we'll click time series. Again, that collection was in metrics. We'll go with black since that's the GitHub color that I see. Then when we're looking at group aggregation, we'll do maximum. That's the maximum stars for a precision, which I will choose day.
I wanna see per day, you know, how my growth is happening. The date field, we'll do a time stamp. Let's I don't know how far back my data goes, but let's just do 1 month. The value field will choose value because we wanna know the value. You can change the decimals here.
We'll just keep it as we'll keep it at 0. We'll do automatic there.
Speaker 1: I like the smooth. I like the gradient.
Speaker 0: And then here in the filter is what we're gonna is this service, and we will do, GitHub. And then we will do one more because, what do we wanna find? We wanna find the key. And the key will equal stars. Because that is what if we go back in a second, you can see that stars is the metric in that table.
So we'll do that. Let's add a panel so we know what it is. And icon, I don't really care, but let's pick 1. And color. Let's, let's just go with that color again.
So we'll hit save and you can see it popped up and we'll find it and we'll make it bigger and there's our chart. And again, all of this, I'm still in edit mode, so we'll bring it down here. And all of this is being fed from our metrics table. Again, you see GitHub, stars, there's the value itself, timestamp is there. There's additional things as well, but we have chose not to show them.
But that's how you create an insights panel. Alright. So hopefully, that was deep enough. I know I do a lot of high level overview. So, hopefully, you got a good view of how to create an insights panel and are excited about some of the upcoming visualizations that we're putting into the platform.
Let's do a little bit something simpler, Pedro. How about are you able to bulk edit items?
Speaker 1: Yeah. Of course. Let me show you how that works here. Okay. So bulk editing records within Directus is probably easier than you might even assume.
So, of course, we have the search and we can add filters and dive through each product individually, but you know what? Today, let's just select all. And because I'm feeling spicy, I'm gonna batch edit all 26 products in my table and turn this into a 99¢ store. And there you have it. All of the records have been updated.
99¢ as the price. And that's bulk editing.
Speaker 0: I think that's all the questions that we had. Again, we wanna thank you for everything. Anything else from your end, Pedro?
Speaker 1: No. Just, you know, appreciate everything and all the attention that we've gotten on these videos so far. We're definitely looking to grow this channel and grow this series. But, again, thanks for watching. If you like these videos, please like and subscribe, comment on them, and don't forget to hop into one of our communities, whether it's Discord or GitHub, and post your questions there as well and follow along.
Happy holidays to everyone, and we'll see you next year.