Setting up a new admin module

Note: The following tutorial requires some fairly good understanding over the Appzio’s infrastructure.

With the Appzio Platform you have the ability to create semi-automated, yet fully functional CRUD interface for your application. Please refer to the following test case in order to get a better understanding on how the system works.

The following example would demonstrate how to build a decent admin interface for a multipurpose Golf application. The current application is using several different tables:

  • golf hole ( ae_ext_golf_hole )
  • golf hole user ( ae_ext_golf_hole_user )
  • mobile events ( ae_ext_mobileevents )
  • mobile events participants ( ae_ext_mobileevents_participants )
  • mobile places ( ae_ext_mobileplaces )
  • location log ( ae_location_log )

Here is how this looks like in practice:

 

What’s needed in order achieve this functionality:

1. Create the CRUD generator model

  1. Navigate to the appzioUI/console/config directory found in your core project.
  2. Open the main.php file
  3. Insert your configuration requirements under the controllerMap array
  4. Example code for the Golf admin showed above
    'golf-batch' => [
          'class' => 'schmunk42\giiant\commands\BatchController',
          'interactive' => false,
          'overwrite' => true,
          'enableI18N' => true,
          'crudTidyOutput' => true,
          'crudAccessFilter' => false, // no login required for inner pages
          'tablePrefix' => '',
          'modelMessageCategory' => 'backend',
          'crudMessageCategory' => 'backend',
    
          // Do not edit
          'crudBaseControllerClass' => 'backend\\controllers\\CrudBaseController',
          'modelBaseClass' => 'backend\\models\\CrudBase',
          // Do not edit
    
          // Do configuration here
          'modelNamespace' => 'backend\\modules\\golf\\models',
          'modelQueryNamespace' => 'backend\\modules\\golf\\models\\query',
          'crudControllerNamespace' => 'backend\\modules\\golf\\controllers',
          'crudSearchModelNamespace' => 'backend\\modules\\golf\\search',
          'crudViewPath' => '@backend/modules/golf/views',
          'crudPathPrefix' => '/golf/',
    ]
    
  5.  For your project you would need to replace the strings, marked with {} . Please note that {your_application_name} should be lowercase, without spaces.
    '{your_batch_name}' => [
          'class' => 'schmunk42\giiant\commands\BatchController',
          'interactive' => false,
          'overwrite' => true,
          'enableI18N' => true,
          'crudTidyOutput' => true,
          'crudAccessFilter' => false, // no login required for inner pages
          'tablePrefix' => '',
          'modelMessageCategory' => 'backend',
          'crudMessageCategory' => 'backend',
    
          // Do not edit
          'crudBaseControllerClass' => 'backend\\controllers\\CrudBaseController',
          'modelBaseClass' => 'backend\\models\\CrudBase',
          // Do not edit
    
          // Do configuration here
          'modelNamespace' => 'backend\\modules\\{your_application_name}\\models',
          'modelQueryNamespace' => 'backend\\modules\\{your_application_name}\\models\\query',
          'crudControllerNamespace' => 'backend\\modules\\{your_application_name}\\controllers',
          'crudSearchModelNamespace' => 'backend\\modules\\{your_application_name}\\search',
          'crudViewPath' => '@backend/modules/{your_application_name}/views',
          'crudPathPrefix' => '/{your_application_name}/',
    ]
    

2. Generate your custom admin module

  1. Navigate to your appzioUI directory
  2. Open your console ( or git bash console )
  3. Run the following command
    ./yii {your_batch_name} --tables={table1},{table2},{table3}
  4. The above example was used for the Golf application admin:
    ./yii golf-batch --tables=ae_ext_golf_hole,ae_ext_golf_hole_user,ae_ext_mobileevents,ae_ext_mobileevents_participants,ae_ext_mobileplaces,ae_location_log
  5. Weight for the program to finish up the module creation.

3. Register your module

Once the system generates your new custom module, we need to register it with YII so it could become readable. In order to that:

  1. Navigate to the appzioUI/backend/config directory found in your core project.
  2. Open the main.php file
  3. Add your module as part of the modules array
  4. Example
    'users' => [
    	'class' => 'backend\modules\users\Users',
    ],
    
  5. Once you do this, you could simply access your controllers using the following URL structure: appzioUI/backend/web/{module_name}/

4. Configure your admin

The system allows you to control the Left navigation bar and the User’s filters of your admin using .json config files. The file itself should be named as your application’s Config identifier, available in the App Dashboard ( example: 273380e054fa80a2733cd9bbc6ec3c3e ). All files need to be placed in the following directory: appzioUI/backend/components/configs. If  a configuration file is not defined, the system would be using the default default-config.json configuration.

Below you could find a basic configuration file:

{
  "menus": {
    "usergroups-user": {
      "label": "Users",
      "icon": "user-o",
      "url": [
        "/users/usergroups-user"
      ]
    }
  },
  "filter_vars": {
    "name": {
      "label": "Name",
      "type": "input",
      "match": "loose_match",
      "location": "variables"
    },
    "email": {
      "label": "Email",
      "type": "input",
      "match": "loose_match",
      "location": "variables"
    },
    "gender": {
      "label": "Gender",
      "type": "select",
      "match": "exact_match",
      "values": [
        "",
        "man",
        "woman",
        "male",
        "female"
      ],
      "location": "variables"
    },
    "reg_phase": {
      "label": "Registration Status",
      "type": "select",
      "match": "reg_options",
      "values": [
        "",
        "complete",
        "not complete"
      ],
      "location": "variables"
    },
    "flag": {
      "label": "Reported",
      "type": "select",
      "match": "matching_options",
      "values": [
        "",
        "yes",
        "no"
      ],
      "location": "mobilematching"
    }
  }
}