-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit db1336b
Showing
81 changed files
with
11,056 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 4 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.{yml,yaml}] | ||
indent_size = 2 | ||
|
||
[docker-compose.yml] | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
APP_NAME=Laravel | ||
APP_ENV=local | ||
APP_KEY= | ||
APP_DEBUG=true | ||
APP_URL=http://localhost | ||
|
||
LOG_CHANNEL=stack | ||
LOG_DEPRECATIONS_CHANNEL=null | ||
LOG_LEVEL=debug | ||
|
||
DB_CONNECTION=mysql | ||
DB_HOST=127.0.0.1 | ||
DB_PORT=3306 | ||
DB_DATABASE=laravel | ||
DB_USERNAME=root | ||
DB_PASSWORD= | ||
|
||
BROADCAST_DRIVER=log | ||
CACHE_DRIVER=file | ||
FILESYSTEM_DISK=local | ||
QUEUE_CONNECTION=sync | ||
SESSION_DRIVER=file | ||
SESSION_LIFETIME=120 | ||
|
||
MEMCACHED_HOST=127.0.0.1 | ||
|
||
REDIS_HOST=127.0.0.1 | ||
REDIS_PASSWORD=null | ||
REDIS_PORT=6379 | ||
|
||
MAIL_MAILER=smtp | ||
MAIL_HOST=mailpit | ||
MAIL_PORT=1025 | ||
MAIL_USERNAME=null | ||
MAIL_PASSWORD=null | ||
MAIL_ENCRYPTION=null | ||
MAIL_FROM_ADDRESS="[email protected]" | ||
MAIL_FROM_NAME="${APP_NAME}" | ||
|
||
AWS_ACCESS_KEY_ID= | ||
AWS_SECRET_ACCESS_KEY= | ||
AWS_DEFAULT_REGION=us-east-1 | ||
AWS_BUCKET= | ||
AWS_USE_PATH_STYLE_ENDPOINT=false | ||
|
||
PUSHER_APP_ID= | ||
PUSHER_APP_KEY= | ||
PUSHER_APP_SECRET= | ||
PUSHER_HOST= | ||
PUSHER_PORT=443 | ||
PUSHER_SCHEME=https | ||
PUSHER_APP_CLUSTER=mt1 | ||
|
||
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}" | ||
VITE_PUSHER_HOST="${PUSHER_HOST}" | ||
VITE_PUSHER_PORT="${PUSHER_PORT}" | ||
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}" | ||
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" | ||
|
||
ENKIN_USERNAME= | ||
ENKIN_PASSWORD= | ||
ENKIN_LOG_TIME= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
* text=auto eol=lf | ||
|
||
*.blade.php diff=html | ||
*.css diff=css | ||
*.html diff=html | ||
*.md diff=markdown | ||
*.php diff=php | ||
|
||
/.github export-ignore | ||
CHANGELOG.md export-ignore | ||
.styleci.yml export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/.phpunit.cache | ||
/node_modules | ||
/public/build | ||
/public/hot | ||
/public/storage | ||
/storage/*.key | ||
/vendor | ||
.env | ||
.env.backup | ||
.env.production | ||
.phpunit.result.cache | ||
Homestead.json | ||
Homestead.yaml | ||
auth.json | ||
npm-debug.log | ||
yarn-error.log | ||
/.fleet | ||
/.idea | ||
/.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
## Installation | ||
|
||
`cp .env.example .env` | ||
|
||
Fill your account in `.env` file. | ||
|
||
``` | ||
ENKIN_USERNAME={your_email} | ||
ENKIN_PASSWORD={your_password} | ||
``` | ||
|
||
Run composer | ||
|
||
`composer install` | ||
|
||
Start schedule to log start work | ||
|
||
`php artisan schedule:work` | ||
|
||
By default time will be log at 08:25. You can change this by changing `.env` file. | ||
|
||
For example: | ||
|
||
`ENKIN_LOG_TIME=08:20` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Facebook\WebDriver\Chrome\ChromeDevToolsDriver; | ||
use Facebook\WebDriver\Chrome\ChromeDriver; | ||
use Facebook\WebDriver\Chrome\ChromeOptions; | ||
use Facebook\WebDriver\Remote\DesiredCapabilities; | ||
use Facebook\WebDriver\WebDriverBy; | ||
use Facebook\WebDriver\WebDriverExpectedCondition; | ||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Facades\Log; | ||
|
||
class EnkinLog extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'enkin'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Enkin log'; | ||
|
||
protected ChromeDriver $driver; | ||
|
||
const BASE_URL = "https://etgroup.enkinlab.net"; | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return int | ||
*/ | ||
public function handle() | ||
{ | ||
$this->init(); | ||
|
||
$login = $this->login(env("ENKIN_USERNAME"), env("ENKIN_PASSWORD")); | ||
|
||
if (!$login){ | ||
$this->error("login fail. check your account"); | ||
return Command::FAILURE; | ||
} | ||
|
||
$openModal = $this->openModal(); | ||
|
||
if (!$openModal){ | ||
$this->error("open model fail"); | ||
return Command::FAILURE; | ||
} | ||
|
||
$startWork = $this->startWork(); | ||
|
||
if (!$startWork){ | ||
$this->error("start working fail"); | ||
return Command::FAILURE; | ||
} | ||
|
||
$this->info("all good. start working successfully"); | ||
return Command::SUCCESS; | ||
} | ||
|
||
public function init(): void | ||
{ | ||
$desiredCapabilities = DesiredCapabilities::chrome(); | ||
|
||
$chromeOptions = new ChromeOptions(); | ||
$chromeOptions->addArguments([ | ||
'--disable-gpu', | ||
'--headless', | ||
'--no-sandbox' | ||
]); | ||
$chromeOptions->setExperimentalOption('w3c', false); | ||
|
||
$desiredCapabilities->setCapability(ChromeOptions::CAPABILITY, $chromeOptions); | ||
$desiredCapabilities->setCapability( 'loggingPrefs', [ | ||
'browser' => 'ALL', | ||
'performance' => 'ALL', | ||
]); | ||
|
||
putenv('WEBDRIVER_CHROME_DRIVER='.base_path('chromedriver')); | ||
$this->driver = ChromeDriver::start($desiredCapabilities); | ||
$devTools = new ChromeDevToolsDriver($this->driver); | ||
$devTools->execute('Performance.enable'); | ||
} | ||
|
||
public function login($username, $password): bool | ||
{ | ||
$this->driver->get(self::BASE_URL."/login"); | ||
|
||
try { | ||
$this->driver->wait()->until( | ||
WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::name('loginId')) | ||
); | ||
|
||
$this->driver->wait()->until( | ||
WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::name('password')) | ||
); | ||
|
||
$this->driver->findElement(WebDriverBy::name('loginId')) | ||
->sendKeys($username); | ||
|
||
$this->driver->findElement(WebDriverBy::name('password')) | ||
->sendKeys($password) | ||
->submit(); | ||
|
||
sleep(5); | ||
} catch (\Exception $e) { | ||
Log::info($e->getMessage()); | ||
|
||
return false; | ||
} | ||
|
||
if ($this->driver->getCurrentURL() === self::BASE_URL . "/app#top/myhome"){ | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
public function openModal(): bool | ||
{ | ||
sleep(1); | ||
try { | ||
$this->driver->wait()->until( | ||
WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::cssSelector('#ext-work-start-end-view-1 button.x-button-el')) | ||
); | ||
|
||
$button = $this->driver->findElement(WebDriverBy::cssSelector('#ext-work-start-end-view-1 button.x-button-el')); | ||
|
||
if ($button->isEnabled()){ | ||
$button->click(); | ||
}else{ | ||
$this->error("button open modal is disable"); | ||
} | ||
|
||
} catch (\Exception $e) { | ||
$this->error($e->getMessage()); | ||
|
||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public function startWork(): bool | ||
{ | ||
sleep(1); | ||
try { | ||
$this->driver->wait()->until( | ||
WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::cssSelector('#ext-work-input-dialog-1 button.x-button-el')) | ||
); | ||
|
||
$button = $this->driver->findElement(WebDriverBy::cssSelector('#ext-work-input-dialog-1 button.x-button-el')); | ||
|
||
if ($button->isEnabled()){ | ||
$button->click(); | ||
}else{ | ||
$this->error("button start work is disable"); | ||
} | ||
|
||
} catch (\Exception $e) { | ||
$this->error($e->getMessage()); | ||
|
||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace App\Console; | ||
|
||
use Illuminate\Console\Scheduling\Schedule; | ||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel; | ||
|
||
class Kernel extends ConsoleKernel | ||
{ | ||
/** | ||
* Define the application's command schedule. | ||
*/ | ||
protected function schedule(Schedule $schedule): void | ||
{ | ||
$schedule->command('enkin')->dailyAt(env("ENKIN_LOG_TIME", "08:25")); | ||
} | ||
|
||
/** | ||
* Register the commands for the application. | ||
*/ | ||
protected function commands(): void | ||
{ | ||
$this->load(__DIR__.'/Commands'); | ||
|
||
require base_path('routes/console.php'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace App\Exceptions; | ||
|
||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; | ||
use Throwable; | ||
|
||
class Handler extends ExceptionHandler | ||
{ | ||
/** | ||
* The list of the inputs that are never flashed to the session on validation exceptions. | ||
* | ||
* @var array<int, string> | ||
*/ | ||
protected $dontFlash = [ | ||
'current_password', | ||
'password', | ||
'password_confirmation', | ||
]; | ||
|
||
/** | ||
* Register the exception handling callbacks for the application. | ||
*/ | ||
public function register(): void | ||
{ | ||
$this->reportable(function (Throwable $e) { | ||
// | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests; | ||
use Illuminate\Foundation\Validation\ValidatesRequests; | ||
use Illuminate\Routing\Controller as BaseController; | ||
|
||
class Controller extends BaseController | ||
{ | ||
use AuthorizesRequests, ValidatesRequests; | ||
} |
Oops, something went wrong.