Skip to content

Commit

Permalink
Release 0.9.2 (#399)
Browse files Browse the repository at this point in the history
* fix for ol-ext > v4.0.0

* fix login for disabled users

* fix for removed extensions setting

* add support for themes

Signed-off-by: Vinzenz Rosenkranz <vinzenz.rosenkranz@uni-tuebingen.de>
  • Loading branch information
v1r0x authored Sep 28, 2022
1 parent 6805ec1 commit 7227dbc
Show file tree
Hide file tree
Showing 29 changed files with 437 additions and 100 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# Changelog
All notable changes to this project will be documented in this file.

## 0.9.2
### Added
- Support for color schemas (Dark Mode with unrounded corners included)
### Fixed
- Login of deactivated users
- Remove references to removed `extensions` preference

## 0.9.1
### Fixed
- Incompatible version of `ol-ext` to match updated `ol`

## 0.9 - Isfahan
### Added
- Global State for shared information (Vuex)
Expand Down
1 change: 1 addition & 0 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function getGlobalData() {
'preferences' => $preferenceValues,
'concepts' => $concepts,
'entityTypes' => $entityTypeMap,
'colorsets' => sp_get_themes(),
]);
}

Expand Down
10 changes: 10 additions & 0 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,18 @@ public function login(Request $request) {
$creds = ['password'];
if($request->has('nickname')) {
$creds[] = 'nickname';
if(!User::where('nickname', $request->get('nickname'))->withoutTrashed()->exists()) {
return response()->json([
'error' => __('Invalid Credentials')
], 400);
}
} else {
$creds[] = 'email';
if(!User::where('email', $request->get('email'))->withoutTrashed()->exists()) {
return response()->json([
'error' => __('Invalid Credentials')
], 400);
}
}
$credentials = request($creds);

Expand Down
10 changes: 5 additions & 5 deletions app/Preference.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public static function decodePreference($label, $value) {
switch($label) {
case 'prefs.gui-language':
return $value->language_key;
case 'prefs.color':
return $value->color_key;
case 'prefs.enable-password-reset-link':
return $value->use;
case 'prefs.columns':
Expand All @@ -66,8 +68,6 @@ public static function decodePreference($label, $value) {
return $value->show;
case 'prefs.tag-root':
return $value->uri;
case 'prefs.load-extensions':
return $value;
case 'prefs.link-to-thesaurex':
return $value->url;
case 'prefs.project-name':
Expand All @@ -92,6 +92,9 @@ public static function encodePreference($label, $decodedValue) {
case 'prefs.gui-language':
$value = json_encode(['language_key' => $decodedValue]);
break;
case 'prefs.color':
$value = json_encode(['color_key' => $decodedValue]);
break;
case 'prefs.enable-password-reset-link':
$value = json_encode(['use' => $decodedValue]);
break;
Expand All @@ -104,9 +107,6 @@ public static function encodePreference($label, $decodedValue) {
case 'prefs.tag-root':
$value = json_encode(['uri' => $decodedValue]);
break;
case 'prefs.load-extensions':
$value = $decodedValue;
break;
case 'prefs.link-to-thesaurex':
$value = json_encode(['url' => $decodedValue]);
break;
Expand Down
24 changes: 24 additions & 0 deletions app/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,30 @@ function sp_get_permission_groups($onlyGroups = false) {
}
}

if(!function_exists('sp_get_themes')) {
function sp_get_themes() {
$themeDir = base_path("resources/sass/");
$fileList = glob("${themeDir}app*.scss");
$themes = [];
foreach($fileList as $file) {
$theme = [];
// cut off base path and .scss extension
$fileName = substr($file, strlen($themeDir), -5);
// default stylesheet needs special treatment
if($fileName == 'app') {
$theme['id'] = 'default';
$theme['key'] = '';
} else {
$extName = substr($fileName, 3);
$theme['id'] = substr($extName, 1);
$theme['key'] = $extName;
}
$themes[] = $theme;
}
return $themes;
}
}

if(!function_exists('sp_loggable_models')) {
function sp_loggable_models() {
$loggableModels = [];
Expand Down
39 changes: 39 additions & 0 deletions database/migrations/2022_09_23_074139_add_color_preference.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

use App\Preference;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// Add Color Preference
$label = 'prefs.color';
$value = json_encode(['color_key' => '']);
$override = false;

$preference = new Preference();
$preference->label = $label;
$preference->default_value = $value;
$preference->allow_override = $override;
$preference->save();
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
// Remove Color Preference
Preference::where('label', 'prefs.color')->delete();
}
};
4 changes: 2 additions & 2 deletions resources/js/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
<i class="fas fa-fw" :class="plugin.icon"></i>
{{ t(plugin.label) }}
</router-link>
<template v-if="hasPreference('prefs.load-extensions', 'data-analysis') || hasPreference('prefs.link-to-thesaurex')">
<template v-if="hasPreference('prefs.link-to-thesaurex')">
<div class="dropdown-divider"></div>
<h6 class="dropdown-header">
{{ t('global.tools.external') }} <sup class="fas fa-fw fa-sm fa-fw fa-external-link-alt"></sup>
Expand All @@ -116,7 +116,7 @@
{{ t('global.tools.thesaurex') }}
</a>
</template>
<template v-if="hasPreference('prefs.load-extensions', 'data-analysis')">
<template>
<a class="dropdown-item" href="../db" target="_blank">
<i class="fas fa-fw fa-chart-bar"></i>
{{ t('global.tools.dbwebgen') }}
Expand Down
1 change: 1 addition & 0 deletions resources/js/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export async function fetchPreData(locale) {
store.dispatch('setEntityTypes', response.data.entityTypes);
store.commit('setPreferences', response.data.preferences);
store.commit('setSystemPreferences', response.data.system_preferences);
store.dispatch('setColorSets', response.data.colorsets);

if(auth.ready()) {
auth.load().then(_ => {
Expand Down
5 changes: 5 additions & 0 deletions resources/js/bootstrap/color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import store from '@/bootstrap/store.js';

export function getSupportedColorSets() {
return store.getters.colorSets;
}
8 changes: 8 additions & 0 deletions resources/js/bootstrap/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const store = createStore({
users: [],
version: {},
plugins: [],
colorsets: [],
registeredPluginSlots: {
tab: [],
tools: [],
Expand Down Expand Up @@ -426,6 +427,9 @@ export const store = createStore({
registerPluginInSlot(state, data) {
state.registeredPluginSlots[data.slot].push(data);
},
setColorSets(state, data) {
state.colorSets = data;
},
},
actions: {
setAppState({commit}, data) {
Expand Down Expand Up @@ -631,6 +635,9 @@ export const store = createStore({
registerPluginInSlot({commit}, data) {
commit('registerPluginInSlot', data);
},
setColorSets({commit}, data) {
commit('setColorSets', data);
},
},
getters: {
appInitialized: state => state.appInitialized,
Expand Down Expand Up @@ -678,6 +685,7 @@ export const store = createStore({
const p = state.registeredPluginSlots;
return slot ? p[slot] : p;
},
colorSets: state => state.colorSets,
vfm: state => state.vfm,
}
},
Expand Down
23 changes: 22 additions & 1 deletion resources/js/components/Preferences.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,24 @@
</div>
</td>
</tr>
<tr>
<td>
<strong>
{{ t('main.preference.key.color.title') }}
</strong>
</td>
<td>
<color-preference
:data="state.preferences['prefs.color'].value"
@changed="e => trackChanges('prefs.color', e)">
</color-preference>
</td>
<td>
<div class="form-check form-switch d-flex justify-content-center">
<input class="form-check-input" type="checkbox" v-model="state.preferences['prefs.gui-language'].allow_override" />
</div>
</td>
</tr>
<tr>
<td>
<strong>{{ t('main.preference.key.password_reset_link') }}</strong>
Expand Down Expand Up @@ -147,7 +165,7 @@
</div>
</td>
</tr>
<tr v-if="state.preferences['prefs.load-extensions'].value.map">
<tr>
<td>
<strong>{{ t('main.preference.key.map.projection') }}</strong>
</td>
Expand Down Expand Up @@ -188,6 +206,7 @@
} from '@/helpers/helpers.js';
import GuiLanguage from '@/components/preferences/GuiLanguage.vue';
import Color from '@/components/preferences/Color.vue';
import ResetEmail from '@/components/preferences/ResetEmail.vue';
import Columns from '@/components/preferences/Columns.vue';
import ShowTooltips from '@/components/preferences/ShowTooltips.vue';
Expand All @@ -200,6 +219,7 @@
export default {
components: {
'gui-language-preference': GuiLanguage,
'color-preference': Color,
'reset-email-preference': ResetEmail,
'columns-preference': Columns,
'tooltips-preference': ShowTooltips,
Expand All @@ -215,6 +235,7 @@
// FUNCTIONS
const trackChanges = (label, data) => {
console.log(label, data);
state.dirtyData[label] = {
value: data.value,
};
Expand Down
16 changes: 2 additions & 14 deletions resources/js/components/UserPreferences.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</button>
</h3>
<div class="table-responsive scroll-x-hidden">
<table class="table table-light table-striped table-hover mb-0" v-if="state.prefsLoaded" v-dcan="'preferences_view'">
<table class="table table-light table-striped table-hover mb-0" v-if="state.prefsLoaded" v-dcan="'preferences_read'">
<thead class="sticky-top">
<tr class="text-nowrap">
<th>{{ t('global.preference') }}</th>
Expand Down Expand Up @@ -82,18 +82,6 @@
</tags-preference>
</td>
</tr>
<tr>
<td>
<strong>{{ t('main.preference.key.extensions') }}</strong>
</td>
<td>
<extensions-preference
:data="state.preferences['prefs.load-extensions']"
:readonly="!state.overrides['prefs.load-extensions']"
@changed="e => trackChanges('prefs.load-extensions', e)">
</extensions-preference>
</td>
</tr>
<tr>
<td>
<strong>{{ t('main.preference.key.link_thesaurex') }}</strong>
Expand Down Expand Up @@ -130,7 +118,7 @@
</project-maintainer-preference>
</td>
</tr>
<tr v-if="state.preferences['prefs.load-extensions'].map">
<tr>
<td>
<strong>{{ t('main.preference.key.map.projection') }}</strong>
</td>
Expand Down
Loading

0 comments on commit 7227dbc

Please sign in to comment.