Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added the refresh UI
  • Loading branch information
gustavobascope committed Feb 3, 2025
commit 6b55da25f7d8fec567d9f89e456a84bad2ae1a7a
68 changes: 68 additions & 0 deletions ProcessMaker/Http/Controllers/Api/DevLinkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Notification;
use Illuminate\Validation\Rule;
use ProcessMaker\Events\CustomizeUiUpdated;
use ProcessMaker\Exception\ValidationException;
use ProcessMaker\Http\Controllers\Controller;
use ProcessMaker\Http\Resources\ApiCollection;
use ProcessMaker\Jobs\CompileSass;
use ProcessMaker\Jobs\DevLinkInstall;
use ProcessMaker\Models\Bundle;
use ProcessMaker\Models\BundleAsset;
Expand Down Expand Up @@ -396,4 +399,69 @@ public function getBundleAllSettings($settingKey)
['hidden', 0],
])->get();
}

public function refreshUi()
{
$cssOverride = Setting::where('key', 'css-override')->first();

$config = $cssOverride->config;
$variables = json_decode($config['variables']);
$sansSerif = json_decode($config['sansSerifFont'], true);

$this->writeColors($variables);
$this->writeFonts($sansSerif);
$this->compileSass(auth()->user()->id);
CustomizeUiUpdated::dispatch([], [], false);
}

private function writeColors($data)
{
// Now generate the _colors.scss file
$contents = "// Changed theme colors\n";
foreach ($data as $value) {
$contents .= $value->id . ': ' . $value->value . ";\n";
}
File::put(app()->resourcePath('sass') . '/_colors.scss', $contents);
}

/**
* Write variables font in file
*
* @param $sansSerif
* @param $serif
*/
private function writeFonts($sansSerif)
{
$sansSerif = $sansSerif ? $sansSerif : $this->sansSerifFontDefault();
// Generate the _fonts.scss file
$contents = "// Changed theme fonts\n";
$contents .= '$font-family-sans-serif: ' . $sansSerif['id'] . " !default;\n";
File::put(app()->resourcePath('sass') . '/_fonts.scss', $contents);
}

/**
* run jobs compile
*/
private function compileSass($userId)
{
// Compile the Sass files
$this->dispatch(new CompileSass([
'tag' => 'sidebar',
'origin' => 'resources/sass/sidebar/sidebar.scss',
'target' => 'public/css/sidebar.css',
'user' => $userId,
]));
$this->dispatch(new CompileSass([
'tag' => 'app',
'origin' => 'resources/sass/app.scss',
'target' => 'public/css/app.css',
'user' => $userId,
]));
$this->dispatch(new CompileSass([
'tag' => 'queues',
'origin' => 'resources/sass/admin/queues.scss',
'target' => 'public/css/admin/queues.css',
'user' => $userId,
]));
}
}
13 changes: 1 addition & 12 deletions ProcessMaker/Models/BundleSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,10 @@ public function export()
return $publicFiles->map(function ($publicFile) {
return $this->exportHelper($publicFile, MediaExporter::class);
});
case 'auth_clients':
if (empty($this->config)) {
$authClients = \Laravel\Passport\Client::where('revoked', false)->get();
} else {
$authClients = \Laravel\Passport\Client::where('revoked', false)->whereIn('id', $ids)->get();
}

return $authClients->map(function ($authClient) {
$authClient->setting_type = $this->setting;

return $authClient;
});
case 'Log-In & Auth':
case 'User Settings':
case 'Email':
case 'ui_settings':
case 'Integrations':
$bundleSettings = Setting::whereIn('key', $ids)->get();

Expand Down
16 changes: 14 additions & 2 deletions resources/js/admin/devlink/components/BundleSettingsModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
:cancel-title="'Cancel'"
>
<p>
These settings will be saved as they are now in the platform. Future changes to the platform's settings won't affect them, as this is a snapshot of the current configuration. To replace this saved configuration with the current one, click "Refresh bundle with current settings".
{{ $t("These settings will be saved as they are now in the platform. Future changes to the platform's settings won't affect them, as this is a snapshot of the current configuration. To replace this saved configuration with the current one.") }}
</p>
<div class="card settings-listing-card">
<b-table
Expand All @@ -34,7 +34,13 @@
</template>
</b-table>
</div>
<p class="mt-3">Setting's date: 12 may 2024 12:12</p>
<button
v-if="modalTitle === 'ui_settings'"
class="btn btn-primary"
@click="refreshUi"
>
{{ $t("Refresh UI") }}
</button>
</b-modal>
</template>
<script setup>
Expand Down Expand Up @@ -112,6 +118,12 @@ const loadSettings = async () => {
allSelected.value = settings.value.every(setting => setting.enabled);
};

const refreshUi = async () => {
await window.ProcessMaker.apiClient.post(`devlink/local-bundles/setting/refresh-ui`);
window.ProcessMaker.alert('UI refreshed', 'success');
emit('settings-saved');
};

const toggleSetting = (key) => {
if (selectedIds.value.includes(key)) {
selectedIds.value = selectedIds.value.filter(id => id !== key);
Expand Down
1 change: 1 addition & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@
Route::get('devlink/local-bundles/{bundle}', [DevLinkController::class, 'showBundle'])->name('devlink.local-bundle');
Route::get('devlink/local-bundles/{bundle}/setting/{settingKey}', [DevLinkController::class, 'getBundleSetting'])->name('devlink.local-bundle-setting');
Route::get('devlink/local-bundles/all-settings/{settingKey}', [DevLinkController::class, 'getBundleAllSettings'])->name('devlink.local-bundle-all-settings');
Route::post('devlink/local-bundles/setting/refresh-ui', [DevLinkController::class, 'refreshUi'])->name('devlink.local-bundle-setting-refresh-ui');
Route::post('devlink/local-bundles', [DevLinkController::class, 'createBundle'])->name('devlink.create-bundle');
Route::put('devlink/local-bundles/{bundle}', [DevLinkController::class, 'updateBundle'])->name('devlink.update-bundle');
Route::post('devlink/local-bundles/{bundle}/increase-version', [DevLinkController::class, 'increaseBundleVersion'])->name('devlink.increase-bundle-version');
Expand Down