group training: add admin menu improvements, add build environment files
This commit is contained in:
parent
c2ea538103
commit
0b5ea5df09
@ -71,10 +71,11 @@ class SiteController extends Controller
|
|||||||
$model = new LoginForm();
|
$model = new LoginForm();
|
||||||
$model->roles = [
|
$model->roles = [
|
||||||
'admin',
|
'admin',
|
||||||
'employee'
|
'employee',
|
||||||
|
'trainer',
|
||||||
];
|
];
|
||||||
if ($model->load(Yii::$app->request->post()) && $model->login()) {
|
if ($model->load(Yii::$app->request->post()) && $model->login()) {
|
||||||
|
|
||||||
$geoip = Helper::getGeoIp();
|
$geoip = Helper::getGeoIp();
|
||||||
|
|
||||||
|
|
||||||
@ -83,14 +84,14 @@ class SiteController extends Controller
|
|||||||
$ipAddress = ( isset($geoip) && isset($geoip->ip) ) ? $geoip->ip : "ismeretlen";
|
$ipAddress = ( isset($geoip) && isset($geoip->ip) ) ? $geoip->ip : "ismeretlen";
|
||||||
$geoCity = ( isset($geoip) && isset($geoip->city) ) ? $geoip->city : "ismeretlen";
|
$geoCity = ( isset($geoip) && isset($geoip->city) ) ? $geoip->city : "ismeretlen";
|
||||||
$message = "Bejelentkezés: " .$user->username. " Ip cím:". $ipAddress . " Város: " . $geoCity;
|
$message = "Bejelentkezés: " .$user->username. " Ip cím:". $ipAddress . " Város: " . $geoCity;
|
||||||
|
|
||||||
Log::log([
|
Log::log([
|
||||||
'type' =>Log::$TYPE_LOGIN,
|
'type' =>Log::$TYPE_LOGIN,
|
||||||
'message' => $message
|
'message' => $message
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->sendLoginMail();
|
$this->sendLoginMail();
|
||||||
|
|
||||||
return $this->goBack();
|
return $this->goBack();
|
||||||
} else {
|
} else {
|
||||||
return $this->render('login', [
|
return $this->render('login', [
|
||||||
@ -102,32 +103,32 @@ class SiteController extends Controller
|
|||||||
protected function sendLoginMail(){
|
protected function sendLoginMail(){
|
||||||
if ( \Yii::$app->params['login_admin_email'] == true){
|
if ( \Yii::$app->params['login_admin_email'] == true){
|
||||||
$geoip = Helper::getGeoIp();
|
$geoip = Helper::getGeoIp();
|
||||||
|
|
||||||
$user = User::findOne(\Yii::$app->user->id);
|
$user = User::findOne(\Yii::$app->user->id);
|
||||||
$message = \Yii::$app->mailer->compose('login_admin', [
|
$message = \Yii::$app->mailer->compose('login_admin', [
|
||||||
'model' => $user,
|
'model' => $user,
|
||||||
'geoip' => $geoip,
|
'geoip' => $geoip,
|
||||||
'company' => Helper::getCompany()
|
'company' => Helper::getCompany()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$message->setFrom( \Yii::$app->params['infoEmail'] )
|
$message->setFrom( \Yii::$app->params['infoEmail'] )
|
||||||
->setTo( \Yii::$app->params['notify_mail'] )
|
->setTo( \Yii::$app->params['notify_mail'] )
|
||||||
->setSubject('Admin bejelentkezés - ' . $user->username )
|
->setSubject('Admin bejelentkezés - ' . $user->username )
|
||||||
->send();
|
->send();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function actionLogout()
|
public function actionLogout()
|
||||||
{
|
{
|
||||||
Yii::$app->user->logout();
|
Yii::$app->user->logout();
|
||||||
|
|
||||||
return $this->goHome();
|
return $this->goHome();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function actionUploadImage(){
|
public function actionUploadImage(){
|
||||||
\yii::$app->request->enableCsrfValidation = false;
|
\yii::$app->request->enableCsrfValidation = false;
|
||||||
$model = new UploadForm();
|
$model = new UploadForm();
|
||||||
|
|
||||||
return $this->render('upload', ['model' =>$model]);
|
return $this->render('upload', ['model' =>$model]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,17 +4,18 @@ namespace common\components;
|
|||||||
use \Yii;
|
use \Yii;
|
||||||
|
|
||||||
class RoleDefinition{
|
class RoleDefinition{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static function roleLabels(){
|
public static function roleLabels(){
|
||||||
return [
|
return [
|
||||||
'reception' => Yii::t('common/role' ,'Reception'),
|
'reception' => Yii::t('common/role' ,'Reception'),
|
||||||
'admin' => Yii::t('common/role' ,'Administrator'),
|
'admin' => Yii::t('common/role' ,'Administrator'),
|
||||||
'employee' => Yii::t('common/role' ,'Employee'),
|
'employee' => Yii::t('common/role' ,'Employee'),
|
||||||
|
'Trainer' => Yii::t('common/role' ,'Edző'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getRoleLabel($role){
|
public static function getRoleLabel($role){
|
||||||
$result = null;
|
$result = null;
|
||||||
$roleLabels = self::roleLabels();
|
$roleLabels = self::roleLabels();
|
||||||
@ -23,8 +24,8 @@ class RoleDefinition{
|
|||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function roleDefinitions(){
|
public static function roleDefinitions(){
|
||||||
return [
|
return [
|
||||||
'employee' => [
|
'employee' => [
|
||||||
@ -38,8 +39,8 @@ class RoleDefinition{
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function getRoleDefinition($role){
|
public static function getRoleDefinition($role){
|
||||||
$defs = self::roleDefinitions();
|
$defs = self::roleDefinitions();
|
||||||
$result = null;
|
$result = null;
|
||||||
@ -49,14 +50,14 @@ class RoleDefinition{
|
|||||||
$result = $defs[$role];
|
$result = $defs[$role];
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getRolesCanAllow($role){
|
public static function getRolesCanAllow($role){
|
||||||
$result = [];
|
$result = [];
|
||||||
$def = self::getRoleDefinition($role);
|
$def = self::getRoleDefinition($role);
|
||||||
if ( isset($def)){
|
if ( isset($def)){
|
||||||
$result = $def['canAllow'];
|
$result = $def['canAllow'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,11 +76,11 @@ class RoleDefinition{
|
|||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isAdmin(){
|
public static function isAdmin(){
|
||||||
return self::can('admin');
|
return self::can('admin');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isReception(){
|
public static function isReception(){
|
||||||
return self::can('reception');
|
return self::can('reception');
|
||||||
}
|
}
|
||||||
@ -87,7 +88,16 @@ class RoleDefinition{
|
|||||||
public static function isEmployee(){
|
public static function isEmployee(){
|
||||||
return self::can('employee');
|
return self::can('employee');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function isTrainer(){
|
||||||
|
return self::can('trainer');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function isLoggedUser(){
|
||||||
|
return self::isTrainer() || self::isAdmin() || self::isEmployee()
|
||||||
|
|| self::isReception();
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* [
|
* [
|
||||||
* 'role1' => 'template1',
|
* 'role1' => 'template1',
|
||||||
@ -104,5 +114,5 @@ class RoleDefinition{
|
|||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
46
console/migrations/m210924_220452_add_permission_trainer.php
Normal file
46
console/migrations/m210924_220452_add_permission_trainer.php
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class m210924_220452_add_permission_trainer
|
||||||
|
*/
|
||||||
|
class m210924_220452_add_permission_trainer extends Migration
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
$am = Yii::$app->authManager;
|
||||||
|
$role = $am->createRole("trainer");
|
||||||
|
$am->add($role);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
echo "m210924_220452_add_permission_trainer cannot be reverted.\n";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Use up()/down() to run migration code without a transaction.
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
echo "m210924_220452_add_permission_trainer cannot be reverted.\n";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
@ -64,6 +64,58 @@
|
|||||||
"maximumWarning": "6kb"
|
"maximumWarning": "6kb"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"cutler-movar": {
|
||||||
|
"fileReplacements": [
|
||||||
|
{
|
||||||
|
"replace": "src/environments/environment.ts",
|
||||||
|
"with": "src/environments/environment.cutler-movar.ts"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"optimization": true,
|
||||||
|
"outputHashing": "all",
|
||||||
|
"sourceMap": false,
|
||||||
|
"namedChunks": false,
|
||||||
|
"extractLicenses": true,
|
||||||
|
"vendorChunk": false,
|
||||||
|
"buildOptimizer": true,
|
||||||
|
"budgets": [
|
||||||
|
{
|
||||||
|
"type": "initial",
|
||||||
|
"maximumWarning": "2mb",
|
||||||
|
"maximumError": "5mb"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "anyComponentStyle",
|
||||||
|
"maximumWarning": "6kb"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"cutler-gyor": {
|
||||||
|
"fileReplacements": [
|
||||||
|
{
|
||||||
|
"replace": "src/environments/environment.ts",
|
||||||
|
"with": "src/environments/environment.cutler-gyor.ts"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"optimization": true,
|
||||||
|
"outputHashing": "all",
|
||||||
|
"sourceMap": false,
|
||||||
|
"namedChunks": false,
|
||||||
|
"extractLicenses": true,
|
||||||
|
"vendorChunk": false,
|
||||||
|
"buildOptimizer": true,
|
||||||
|
"budgets": [
|
||||||
|
{
|
||||||
|
"type": "initial",
|
||||||
|
"maximumWarning": "2mb",
|
||||||
|
"maximumError": "5mb"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "anyComponentStyle",
|
||||||
|
"maximumWarning": "6kb"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"defaultConfiguration": ""
|
"defaultConfiguration": ""
|
||||||
|
|||||||
@ -5,6 +5,9 @@
|
|||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"start": "ng serve",
|
"start": "ng serve",
|
||||||
"build": "ng build",
|
"build": "ng build",
|
||||||
|
"build:prod": "ng build --configuration production",
|
||||||
|
"build:prod-cutler-gyor": "ng build --configuration cutler-gyor",
|
||||||
|
"build:prod-cutler-movar": "ng build --configuration cutler-movar",
|
||||||
"test": "ng test",
|
"test": "ng test",
|
||||||
"lint": "ng lint",
|
"lint": "ng lint",
|
||||||
"e2e": "ng e2e"
|
"e2e": "ng e2e"
|
||||||
|
|||||||
@ -1,51 +1,54 @@
|
|||||||
|
import {environment} from "../../environments/environment";
|
||||||
|
|
||||||
export class Endpoints {
|
export class Endpoints {
|
||||||
private static contextPath = "http://localhost:86/fitness_web";
|
|
||||||
private static baseUrl: string = Endpoints.contextPath + "/customerapi/web/index.php?r=";
|
// private static apiUrl: string = "http://localhost:86/fitness_web/customerapi/web/index.php?r=";
|
||||||
|
private static apiUrl: string = environment.apiUrl;
|
||||||
|
|
||||||
public static POST_USERS_AUTHENTICATE(){
|
public static POST_USERS_AUTHENTICATE(){
|
||||||
return `${this.baseUrl}user/login`;
|
return `${this.apiUrl}user/login`;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static POST_USER_PASSWORD_CHANGE(){
|
public static POST_USER_PASSWORD_CHANGE(){
|
||||||
return `${this.baseUrl}user/password-change`;
|
return `${this.apiUrl}user/password-change`;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GET_EVENTS( ){
|
public static GET_EVENTS( ){
|
||||||
return `${this.baseUrl}/events`;
|
return `${this.apiUrl}/events`;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GET_EVENT( id: number){
|
public static GET_EVENT( id: number){
|
||||||
return `${this.baseUrl}/event/event&id_event=${id}`;
|
return `${this.apiUrl}/event/event&id_event=${id}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static POST_EVENT_REGISTRATIONS_REGISTER(id: number){
|
public static POST_EVENT_REGISTRATIONS_REGISTER(id: number){
|
||||||
return `${this.baseUrl}/event-registration/register&id_event=${id}`;
|
return `${this.apiUrl}/event-registration/register&id_event=${id}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GET_EVENT_REGISTRATIONS_FIND(){
|
public static GET_EVENT_REGISTRATIONS_FIND(){
|
||||||
return `${this.baseUrl}/event-registration/index`;
|
return `${this.apiUrl}/event-registration/index`;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GET_REGISTRATION( id: number){
|
public static GET_REGISTRATION( id: number){
|
||||||
return `${this.baseUrl}/event-registration/registration&id_registration=${id}`;
|
return `${this.apiUrl}/event-registration/registration&id_registration=${id}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static POST_EVENT_CANCEL( id: number){
|
public static POST_EVENT_CANCEL( id: number){
|
||||||
return `${this.baseUrl}/event/cancel&id_event=${id}`;
|
return `${this.apiUrl}/event/cancel&id_event=${id}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static POST_EVENT_REGISTRATION_CANCEL( id: number){
|
public static POST_EVENT_REGISTRATION_CANCEL( id: number){
|
||||||
return `${this.baseUrl}/event-registration/cancel&idRegistration=${id}`;
|
return `${this.apiUrl}/event-registration/cancel&idRegistration=${id}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GET_EVENT_TYPES(){
|
public static GET_EVENT_TYPES(){
|
||||||
return `${this.baseUrl}/event-type`;
|
return `${this.apiUrl}/event-type`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static GET_EVENTS_AVAILABLE(){
|
public static GET_EVENTS_AVAILABLE(){
|
||||||
return `${this.baseUrl}/event/available`;
|
return `${this.apiUrl}/event/available`;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
4
customer/app/src/environments/environment.cutler-gyor.ts
Normal file
4
customer/app/src/environments/environment.cutler-gyor.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export const environment = {
|
||||||
|
production: true,
|
||||||
|
apiUrl: "http://cutler-gyor:80/fitness_web/customerapi/web/index.php?r="
|
||||||
|
};
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
export const environment = {
|
||||||
|
production: true,
|
||||||
|
apiUrl: "http://cutler-movar:80/fitness_web/customerapi/web/index.php?r="
|
||||||
|
};
|
||||||
@ -1,3 +1,4 @@
|
|||||||
export const environment = {
|
export const environment = {
|
||||||
production: true
|
production: true,
|
||||||
|
apiUrl: "http://myapi:80/fitness_web/customerapi/web/index.php?r="
|
||||||
};
|
};
|
||||||
|
|||||||
@ -3,7 +3,8 @@
|
|||||||
// The list of file replacements can be found in `angular.json`.
|
// The list of file replacements can be found in `angular.json`.
|
||||||
|
|
||||||
export const environment = {
|
export const environment = {
|
||||||
production: false
|
production: false,
|
||||||
|
apiUrl: 'http://localhost:86/fitness_web/customerapi/web/index.php?r='
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user