Skip to content

Commit

Permalink
Admin and User UI Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ksainc committed Oct 11, 2023
1 parent edee965 commit ae55797
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 21 deletions.
20 changes: 19 additions & 1 deletion js/data-AdminSettings.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/data-AdminSettings.js.map

Large diffs are not rendered by default.

34 changes: 24 additions & 10 deletions js/data-UserSettings.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/data-UserSettings.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ public function deleteService($data): DataResponse {
/**
* handles fetch settings requests
*
* @NoAdminRequired
*
* @return DataResponse
*/
public function fetchSystemSettings(): DataResponse {
Expand Down
1 change: 1 addition & 0 deletions lib/Service/ConfigurationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class ConfigurationService {
private const _SYSTEM = [
'permissions_user_create' => '1',
'permissions_user_modify' => '1',
'permissions_user_delete' => '1',
];

/**
Expand Down
13 changes: 13 additions & 0 deletions src/AdminSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
{{ t('data_service', 'Allow users to modify services') }}
</NcCheckboxRadioSwitch>
</div>
<div>
<NcCheckboxRadioSwitch type="switch" :checked.sync="permissionsUserDelete" @update:checked="depositSettings">
{{ t('data_service', 'Allow users to delete services') }}
</NcCheckboxRadioSwitch>
</div>
</div>
<div class="data-settings-section-services">
<div class="data-settings-hint">
Expand Down Expand Up @@ -324,6 +329,14 @@ export default {
this.configuredSettings.permissions_user_modify = (value === true) ? '1' : '0'
},
},
permissionsUserDelete: {
get() {
return (this.configuredSettings.permissions_user_delete === '1')
},
set(value) {
this.configuredSettings.permissions_user_delete = (value === true) ? '1' : '0'
},
},
},

watch: {
Expand Down
39 changes: 31 additions & 8 deletions src/UserSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@
<template #icon>
<IconActions />
</template>
<NcActionButton @click="onEditClick(item.id)">
<NcActionButton v-if="configuredSettings.permissions_user_modify === '1'"
@click="onModifyClick(item.id)">
<template #icon>
<IconEdit />
<IconModify />
</template>
Edit
Modify
</NcActionButton>
<NcActionButton @click="onDeleteClick(item.id)">
<NcActionButton v-if="configuredSettings.permissions_user_delete === '1'"
@click="onDeleteClick(item.id)">
<template #icon>
<IconDelete />
</template>
Expand All @@ -83,7 +85,7 @@
<h3>{{ t('data_service', 'No data services have been created for this account') }}</h3>
</div>
<br>
<div class="data-settings-content-actions">
<div v-if="configuredSettings.permissions_user_create === '1'" class="data-settings-content-actions">
<NcButton class="app-settings-button" @click="onAddClick()">
<template #icon>
<IconAdd :size="24" />
Expand Down Expand Up @@ -219,7 +221,7 @@ import NcModal from '@nextcloud/vue/dist/Components/NcModal.js'
import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js'
import IconApp from 'vue-material-design-icons/DatabaseOutline.vue'
import IconAdd from 'vue-material-design-icons/DatabaseExportOutline.vue'
import IconEdit from 'vue-material-design-icons/DatabaseEditOutline.vue'
import IconModify from 'vue-material-design-icons/DatabaseEditOutline.vue'
import IconDelete from 'vue-material-design-icons/DatabaseRemoveOutline.vue'
import IconSave from 'vue-material-design-icons/Check.vue'
import IconCancel from 'vue-material-design-icons/Close.vue'
Expand All @@ -236,7 +238,7 @@ export default {
NcSelect,
IconApp,
IconAdd,
IconEdit,
IconModify,
IconDelete,
IconSave,
IconCancel,
Expand All @@ -251,6 +253,7 @@ export default {
availableTypes: [],
availableCollections: [],
availableFormats: [],
configuredSettings: [],
configuredServices: [],
selectedId: '',
selectedServiceId: '',
Expand All @@ -276,14 +279,15 @@ export default {

methods: {
loadData() {
this.fetchSettings()
this.listTypes()
this.listServices()
},
onAddClick() {
this.clearSelected()
this.dialogServiceSettings = true
},
onEditClick(id) {
onModifyClick(id) {
// clear values
this.clearSelected()
// find item
Expand Down Expand Up @@ -482,6 +486,23 @@ export default {
})
.then(() => {})
},
fetchSettings() {
const uri = generateUrl('/apps/data/fetch-system-settings')
axios.get(uri)
.then((response) => {
if (response.data) {
this.configuredSettings = response.data
}
})
.catch((error) => {
showError(
t('data_service', 'Failed to retrieve system settings')
+ ': ' + error.response.request.responseText
)
})
.then(() => {
})
},
formatDate(dt) {
if (dt) {
return (new Date(dt * 1000)).toLocaleString()
Expand Down Expand Up @@ -527,6 +548,8 @@ export default {
width: auto;
padding-left: 10px;
padding-right: 10px;
padding-top: 5px;
padding-bottom: 5px;
}
.data-settings-button {
display:inline-flex;
Expand Down

0 comments on commit ae55797

Please sign in to comment.