laravel-admin.org generate menu command line - laravel-7

im using laravel-admin.org as my laravel admin panel
when i want to access my system admins, i generate a new route by this command
php artisan admin:make UserController --model=App\\User
then it make a controller for me.
then after running this command , it tell me to add this line
$router->resource('users', UserController::class);
into routes.php in admin folder. (app\admin\routes.php)
this is my routes.php file that i can sync it to my server by ftp tools like filezilla
<?php
use Illuminate\Routing\Router;
Admin::routes();
Route::group([
'prefix' => config('admin.route.prefix'),
'namespace' => config('admin.route.namespace'),
'middleware' => config('admin.route.middleware'),
'as' => config('admin.route.prefix') . '.',
], function (Router $router) {
$router->get('/', 'HomeController#index')->name('home');
$router->resource('users', UserController::class);
});
then i m usually should create my desired menus manually from admin panel and add new menus item.
http://localhost:8000/admin/auth/menu
i should add those items in my server again. by UI. !!!
How can i apply this last step in the server automatically?
i want to export my menus and import them into server.
is it possible to create a new command line for my laravel ? and generate menus like migrate command and add only newer on the server?
we know when we run migrate command just run only the migration files that they are new in server. and those tables that did not exist there.
i want to insert them increment and if i add a new menu, then only they are new to import from my local and only the new items export to my server.

i'm using seed
Use iseed component for inverse seed from local db and convert it to seed file and next step is to run that seed file on your server https://github.com/orangehill/iseed
Second solution we can use excel seeder https://github.com/bfinlay/laravel-excel-seeder

Related

Contentful Content Migration API try/catch on field creation?

We are trying to setup a workflow for delivering content model changes to our other environments (stage & prod).
Right now, our approach is this:
Create a new contentful field as a migration script using Contentful CLI.
Run script in local dev to make sure the result is as desired using contentful space migration migrations/2023-01-12-add-field.ts
Add script to GIT in folder migrations/[date]-[description].js
When release to prod, run all scripts in the migrations folder, in order, as part of the build process.
When folder contains "too many" scripts, and we are certain all changes are applied to all envs, manually remove the scripts from GIT and start over in an empty folder.
Where it fails
But, between point 4 & 5 there will be cases where a script has already been run in an earlier release, and that throws an error:
I would like the scripts to continue more gracefully without throwing an error, but I cant find support for it in the space migration docs. I have tried wrapping the code in try/catch without any luck.
Contentful recommends using the Content Migration API in favour for Content Management API since it is faster. I guess we could use the Content Management API, but at the same time we want to use "best practise".
Are we missing something here?
I would like to do something like:
module.exports = function (migration) {
// Create a new category field in the blog post content type.
const blogPost = migration.editContentType('blogPost')
if (blogPost.fieldExists('testField')) {
console.log('Field already exists')
} else {
blogPost.createField('testField').name('Test field').type('Symbol')
}
}

In Electron, how to allow users to pick a file path

I have an Electron App in which when users click on a button I want to open file explorer (or Finder on Mac) for users to choose a path in their file system. Then I want to use this path to save a file.
The second part is quiet easy to achieve. I just need to use writeFile() from node File System API.
However I have gone through the full list of node File System API and I have found nothing allowing me to do the first part.
You should use dialogue module. Simple example for showing the file explorer will be:
const {dialog} = require('electron')
console.log(dialog.showOpenDialog({properties: ['openFile', 'openDirectory', 'multiSelections']}))
Check this link for more information.

How to instantiate a blank workspace in node red?

I have an < iframe > based Node-Red UI hosted inside MEAN application. I want to create a blank workspace each time I visit the Node-Red hosted Page without restarting NR server?
But I also need to preserve the previously deployed flows.
I've tried changing user directory to scratch :
var settings = {
httpAdminRoot:"/red/",
httpNodeRoot: "/api/",
userDir:"/home/sudo/.nodered/scratch",
functionGlobalContext: { } // enables global context
};
but it wouldn't work instead it started creating persistent flow file inside the scratch directory.
You can't do what you want with the default Node-RED. It will always store the flow in a file in the userDir
You will need to look at implementing your own storage module as described here: http://nodered.org/docs/api/storage/

How can I host my own Parse Server on Heroku using MongoDB? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
(To be clear, Im asking this question so as to provide the answer I found in an effort to help others that have been similarly affected by the Parse closure)
Parse.com recently anounced that they are closing shop January 2017 but thankfully they have made their Parse Server software open source so we can all host our own Parse server instances.
I have looked into the various options available for hosting Parse Server and have decided to host mine on Heroku
I loved Parse because it was so easy to use and I have no real experience with setting up a backend. I have tried to follow several guides online but found them all a bit hard to understand with vague steps or steps that take you down a rabbit hole on another site installing a bunch of tools and it all gets a bit confusing.
How can I host Parse Server on heroku, set it up to accept cross domain requests from my application, create a MongoDB database, and migrate all of my data from Parse to the new database?
Self hosting Parse Server on Heroku
Setup Heroku, MongoDB, and Parse
Visit https://signup.heroku.com/ and sign up for an acount
Verify your email, and log into Heroku
Go to Deploying a Parse Server to Heroku
Click "Deploy to Heroku"
Give your parse server a name
Skip the app's APP_ID and MASTER_KEY for now, we'll set that in later step.
Click "Deploy for free"
If the below box appears, enter your credit card info to verify your account. Dont worry, you wont be charged unless you upgrade your account later. This is simply a security measure Heroku has in place to prevent abuse.
Heroku will create your app. In the background it will also create a .git repo for you and clone the contents of the official parse-server-example git repo, create a MongoDB database, and configure your Heroku app to use that DB.
When the app is created, you'll be taken to it's Heroku dashboard or you can get there by logging in, clicking "Personal Apps" then clicking on the name of your parse server
On your app's dashboard, click "Settings" then click "Reveal config vars"
Fill in your app's APP_ID and MASTER_KEY. If you have an app on Parse.com now, you can use the same keys it uses. You can gey the at https://www.parse.com/apps/<APP_NAME>/edit#keys where <APP_NAME> is the name of your app. If you're creating a new app you can generate random keys here. You can add new keys for any sdks you plan to use, I'm adding one for the javascript sdk here.
Make note of the value for MONGOLAB_URI, you'll need this later if you want to migrate your existing Parse data to your new DB
Scroll down and make a note of the Git Url and the Heroku domain for your app, you'll need these later
Install the Heroku Toolbelt which is a command line interface tool for managing your Heroku apps.
Open a terminal prompt and enter $ heroku login, enter your Heroku email and password
Enter $ heroku git:clone -a <MY_APP_NAME> (where <MY_APP_NAME> is the name of your heroku app) to make a local copy of your server code repo, you can also use the git url from we saw earlier. When you clone the repo you will see the message "warning: You appear to have cloned an empty repository.". The app folder will be created but it will only contain the standard git files and no parse server. To fix this. Go to the official parse-server-example git repo, download the zip file of the repo. Extract the folder, drag all of the files and folders from the parse-server-example-master folder into your app folder.
Back in the terminal, enter $ cd <MY_APP_NAME>to move into the repo
Enable CORS (so you can use the API from other domains)
On your hard drive, find and open the local copy of the repo that we just created
In the folder, open package.json and add "cors": "*" to the dependencies like this:
.
"dependencies": {
"express": "~4.2.x",
"kerberos": "~0.0.x",
"parse": "~1.6.12",
"parse-server": "~2.0", // <= don't forget this comma
"cors": "*" // add this line
}
NOTE
Make sure to remove the above comments in your actual code as it wont be valid JSON
Open index.js and make these changes:
.
var express = require('express'); // find this line in the file
var cors = require('cors') // add this line below it
//....
//var databaseUri = process.env.DATABASE_URI || process.env.MONGOLAB_URI // old name, you may need to change this for new deployments
var databaseUri = process.env.DATABASE_URI || process.env.MONGODB_URI // changed to MONGODB_URI in Heroku!
//....
var app = express(); // find this line in the file
app.use(cors()); // add this line below it
//Add declarations for any keys you plan to use as shown below
var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || 'myAppId',
masterKey: process.env.MASTER_KEY || '',
serverURL: process.env.SERVER_URL || 'http://localhost:1337',
javascriptKey: process.env.JAVASCRIPT_KEY || '', //** add this line no need to set values, they will be overwritten by heroku config vars
restAPIKey: process.env.REST_API_KEY || '', //** add this line
dotNetKey: process.env.DOT_NET_KEY || '', //** add this line
clientKey: process.env.CLIENT_KEY || '', //** add this line
});
Go back to the terminal window, make sure you are still in the folder of the repo we cloned and enter the below to push the changes to Heroku:
.
$ git add .
$ git commit -am "make it better"
$ git push heroku master
Test your new Parse Server
Go to this jsFiddle page
Change <MY_APP_ID>,<MY_JS_KEY>,<MY_HEROKU_APP_NAME> in the fiddle to the appropriate values for your app then click "Run"
.
Parse.initialize('<MY_APP_ID>', '<MY_JS_KEY>');
Parse.serverURL = 'https://<MY_HEROKU_APP_NAME>.herokuapp.com/Parse'
You should get the below alert letting you know that your new Parse server is working correctly
NOTE:
If, you use the jsfiddle tool with multiple parse server instances, you might get the error "invalid session token". If this happens, open the dev console, and delete all of the "parse" keys from local storage, after that, it should work:
Migrate your existing data from Parse
You should do this at least once with a test app before migrating a production app. Also, it seems that legacy files from your old app may not yet transfer, see this GitHub Issue
Before we migrate, if your new MongoDB has data in it the migration will fail. If you just tested the server and created and object, go to https://dashboard.heroku.com/apps/<MY_HEROKU_APP_NAME>/resources, click "MongoLab" next to it's icon, then, on the next page, click "Delete all collections"
Go to https://dashboard.parse.com/apps/<APP_NAME>/settings/general where <APP_NAME> is the name of your parse app
Scroll down on the page and click "Migrate"
In the modal, in the grey area (that doesn't look much like an input...) enter the MONGOLAB_URI that we made note of earlier
Click "Begin the migration"
When the migration is done, click "Finalize" then, in the popup click "Okay" when the migration is final, all your data will be in your new MongoDB database.
For now, your Parse dashboard will continue to show your data that now lives in the new DB. To test everything, go back to the test jsFiddle we used before and run it again. Now, go to your Parse dashboard and you should see the newly added class and row. Note that when I used the new Parse dashboard, I could see the number of rows but the row area was all blank. I reverted to the old Parse dashboard and could see everything fine.

How to access the "foo" controller in the jhipster-sample-app?

I'm starting to learn AngularJS and as Java/Maven/Spring developer, the jhipster yeoman generator looks great.
I've cloned the jhipster-sample-app, imported it into my IDE and started it via Maven command mvn spring-boot:run. (I know that when I want to generate my own app, i can use yo jhipster)
I am able to browse the app at http://localhost:8080/ and also login as 'user' and 'admin'
How do I navigate to the Foo entity in the sample app?
I've tried http://localhost:8080/#/foo which redirects back to the homepage.
On the server side, I see the sample app has a Foo entity, repository, and resource. On the AngularJS side, I also there is a Foo controller, router, service, and view.
What am i missing?
The sample is just an example of the "default" application, the "foo" entity is not complete.
If you use the generator, here are the steps to make the "foo" entity working:
http://jhipster.github.io/creating_an_entity.html
There are basically the same steps to do on the sample application: you need to set up the database tables (in Liquibase, they are just commented), and import the JS files in your main app.
But you are right, we should generate a complete entity in the sample application (or no entity at all!), but not provide this half complete result.

Resources