add value host email and password from db global settings table
This commit is contained in:
@@ -17,7 +17,7 @@ class GlobalSettingsController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$query = GlobalSetting::query();
|
||||
$query = GlobalSetting::query()->orderBy('id','desc');
|
||||
return GlobalSettingResource::collection($query->paginate());
|
||||
}
|
||||
|
||||
|
||||
@@ -14,13 +14,13 @@ class ImportDatasourceController extends Controller
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$query = ImportDatasource::query();
|
||||
$query = ImportDatasource::query()->orderBy('id', 'desc');
|
||||
|
||||
if($request->has("search") && !empty($request->get("search"))){
|
||||
$search = $request->get("search");
|
||||
$query->where('status', 'like', "%".$search."%");
|
||||
}
|
||||
return ImportDatasourceResource::collection($query->paginate()->withQueryString());
|
||||
return ImportDatasourceResource::collection($query->paginate(10));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,7 +19,9 @@ class GlobalSettingResource extends JsonResource
|
||||
'key' => $this->key,
|
||||
'value' => $this->value,
|
||||
'type' => $this->type,
|
||||
'description' => $this->description
|
||||
'description' => $this->description,
|
||||
'created_at' => $this->created_at->toDateTimeString(),
|
||||
'updated_at' => $this->updated_at->toDateTimeString(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App;
|
||||
|
||||
use App\Enums\ImportDatasourceStatus;
|
||||
use App\Models\GlobalSetting;
|
||||
use App\Models\ImportDatasource;
|
||||
use App\Models\PbgTaskIndexIntegrations;
|
||||
use App\Models\PbgTaskPrasarana;
|
||||
@@ -17,18 +18,20 @@ class ServiceSIMBG
|
||||
use GlobalApiResponse;
|
||||
private $email;
|
||||
private $password;
|
||||
private $simbg_host;
|
||||
/**
|
||||
* Create a new class instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->email = $_ENV['SIMBG_EMAIL'];
|
||||
$this->password = $_ENV['SIMBG_PASSWORD'];
|
||||
$this->email = trim((string) GlobalSetting::where('key','SIMBG_EMAIL')->first()->value);
|
||||
$this->password = trim((string) GlobalSetting::where('key','SIMBG_PASSWORD')->first()->value);
|
||||
$this->simbg_host = trim((string)GlobalSetting::where('key','SIMBG_HOST')->first()->value);
|
||||
}
|
||||
|
||||
public function getToken(){
|
||||
$clientHelper = new ServiceClient($_ENV['SIMBG_HOST']);
|
||||
$url = "api/user/v1/auth/login/";
|
||||
$clientHelper = new ServiceClient($this->simbg_host);
|
||||
$url = "/api/user/v1/auth/login/";
|
||||
$body = [
|
||||
'email' => $this->email,
|
||||
'password' => $this->password,
|
||||
@@ -44,8 +47,8 @@ class ServiceSIMBG
|
||||
|
||||
public function syncIndexIntegration($uuid)
|
||||
{
|
||||
$clientHelper = new ServiceClient($_ENV['SIMBG_HOST']);
|
||||
$url = "api/pbg/v1/detail/" . $uuid . "/retribution/indeks-terintegrasi/";
|
||||
$clientHelper = new ServiceClient($this->simbg_host);
|
||||
$url = "/api/pbg/v1/detail/" . $uuid . "/retribution/indeks-terintegrasi/";
|
||||
$resToken = $this->getToken();
|
||||
|
||||
if (!isset($resToken) || empty($resToken->original['data']['token']['access'])) {
|
||||
@@ -93,7 +96,7 @@ class ServiceSIMBG
|
||||
|
||||
public function syncTaskList()
|
||||
{
|
||||
$clientHelper = new ServiceClient($_ENV['SIMBG_HOST']);
|
||||
$clientHelper = new ServiceClient($this->simbg_host);
|
||||
$resToken = $this->getToken();
|
||||
|
||||
// create log import datasource
|
||||
@@ -118,7 +121,7 @@ class ServiceSIMBG
|
||||
'type' => 'task',
|
||||
]);
|
||||
|
||||
$url = "api/pbg/v1/list/?" . $queryParams;
|
||||
$url = "/api/pbg/v1/list/?" . $queryParams;
|
||||
$headers = ['Authorization' => "Bearer " . $apiToken];
|
||||
|
||||
$initialResponse = $clientHelper->get($url, $headers);
|
||||
@@ -143,7 +146,7 @@ class ServiceSIMBG
|
||||
'type' => 'task',
|
||||
]);
|
||||
|
||||
$url = "api/pbg/v1/list/?" . $queryParams;
|
||||
$url = "/api/pbg/v1/list/?" . $queryParams;
|
||||
$response = $clientHelper->get($url, $headers);
|
||||
|
||||
if (empty($response->original['data']['data'])) {
|
||||
@@ -221,7 +224,7 @@ class ServiceSIMBG
|
||||
|
||||
public function syncTaskDetailSubmit($uuid)
|
||||
{
|
||||
$clientHelper = new ServiceClient($_ENV['SIMBG_HOST']);
|
||||
$clientHelper = new ServiceClient($this->simbg_host);
|
||||
$resToken = $this->getToken();
|
||||
|
||||
if (!isset($resToken) || empty($resToken->original['data']['token']['access'])) {
|
||||
@@ -231,7 +234,7 @@ class ServiceSIMBG
|
||||
}
|
||||
|
||||
$apiToken = $resToken->original['data']['token']['access'];
|
||||
$url = "api/pbg/v1/detail/" . $uuid . "/retribution/submit/";
|
||||
$url = "/api/pbg/v1/detail/" . $uuid . "/retribution/submit/";
|
||||
$headers = [
|
||||
'Authorization' => "Bearer " . $apiToken,
|
||||
];
|
||||
|
||||
45
database/seeders/GlobalSettingSeeder.php
Normal file
45
database/seeders/GlobalSettingSeeder.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\GlobalSetting;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class GlobalSettingSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$globalSettings = [
|
||||
[
|
||||
"key" => "SIMBG_HOST",
|
||||
"value" => "https://simbg.pu.go.id",
|
||||
"type" => "string",
|
||||
"description" => "Host SIMBG",
|
||||
"created_at" => Carbon::now()->format("Y-m-d H:i:s"),
|
||||
"updated_at" => Carbon::now()->format("Y-m-d H:i:s"),
|
||||
],
|
||||
[
|
||||
"key" => "SIMBG_PASSWORD",
|
||||
"value" => "Simbg123",
|
||||
"type" => "string",
|
||||
"description" => "Password SIMBG",
|
||||
"created_at" => Carbon::now()->format("Y-m-d H:i:s"),
|
||||
"updated_at" => Carbon::now()->format("Y-m-d H:i:s"),
|
||||
],
|
||||
[
|
||||
"key" => "SIMBG_EMAIL",
|
||||
"value" => "dputr@bandungkab.go.id",
|
||||
"type" => "string",
|
||||
"description" => "Email SIMBG",
|
||||
"created_at" => Carbon::now()->format("Y-m-d H:i:s"),
|
||||
"updated_at" => Carbon::now()->format("Y-m-d H:i:s"),
|
||||
],
|
||||
];
|
||||
GlobalSetting::insert($globalSettings);
|
||||
}
|
||||
}
|
||||
36
resources/js/settings/general/general-settings.js
Normal file
36
resources/js/settings/general/general-settings.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import { Grid } from "gridjs/dist/gridjs.umd.js";
|
||||
import gridjs from 'gridjs/dist/gridjs.umd.js'
|
||||
import 'gridjs/dist/gridjs.umd.js'
|
||||
import GlobalConfig from "../../global-config.js";
|
||||
|
||||
class SyncronizeTask {
|
||||
init(){
|
||||
this.initTableGeneralSettings();
|
||||
}
|
||||
initTableGeneralSettings(){
|
||||
new Grid({
|
||||
columns: [
|
||||
"ID", "Key", "Value", "Description", "Created",
|
||||
],
|
||||
pagination: {
|
||||
limit: 10,
|
||||
server: {
|
||||
url: (prev, page, limit) => `${prev}?page=${page}`
|
||||
}
|
||||
},
|
||||
sort: true,
|
||||
search: {
|
||||
server: {
|
||||
url: (prev, page, keyword) => `${prev}?page=${page}&search=${keyword}`
|
||||
}
|
||||
},
|
||||
server: {
|
||||
url: `${GlobalConfig.apiHost}/api/global-settings`,
|
||||
then: data => data.data.map((item) => [item.id, item.key, item.value, item.description, item.created_at])
|
||||
}
|
||||
}).render(document.getElementById("general-setting-table"));
|
||||
}
|
||||
}
|
||||
document.addEventListener('DOMContentLoaded', function (e) {
|
||||
new SyncronizeTask().init();
|
||||
});
|
||||
@@ -13,12 +13,12 @@
|
||||
<button type="button" class="btn btn-outline-success width-lg">Create</button>
|
||||
</div>
|
||||
<div>
|
||||
<div id="common-table"></div>
|
||||
<div id="general-setting-table"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endsection
|
||||
|
||||
@section('scripts')
|
||||
@vite(['resources/js/tables/common-table.js'])
|
||||
@vite(['resources/js/settings/general/general-settings.js'])
|
||||
@endsection
|
||||
Reference in New Issue
Block a user