Skip to content

Commit 1b50821

Browse files
authored
Merge pull request #192 from ConductionNL/development
Development to main
2 parents bccff4c + a2a719c commit 1b50821

File tree

12 files changed

+352
-184
lines changed

12 files changed

+352
-184
lines changed

lib/Service/FileService.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class FileService
4242
const ROOT_FOLDER = 'Open Registers';
4343
const APP_GROUP = 'openregister';
4444
const APP_USER = 'OpenRegister';
45-
const FILE_TAG_TYPE = 'file';
45+
const FILE_TAG_TYPE = 'files';
4646
/**
4747
* Constructor for FileService
4848
*
@@ -354,24 +354,24 @@ private function getCurrentDomain(): string
354354
private function getUser(): IUser
355355
{
356356
$openCatalogiUser = $this->userManager->get(self::APP_USER);
357-
357+
358358
if (!$openCatalogiUser) {
359359
// Create OpenCatalogi user if it doesn't exist
360360
$password = bin2hex(random_bytes(16)); // Generate random password
361361
$openCatalogiUser = $this->userManager->createUser(self::APP_USER, $password);
362-
362+
363363
if (!$openCatalogiUser) {
364364
throw new \Exception('Failed to create OpenCatalogi user account.');
365365
}
366-
366+
367367
// Add user to OpenCatalogi group
368368
$group = $this->groupManager->get(self::APP_GROUP);
369369
if (!$group) {
370370
$group = $this->groupManager->createGroup(self::APP_GROUP);
371371
}
372372
$group->addUser($openCatalogiUser);
373373
}
374-
374+
375375
return $openCatalogiUser;
376376
}
377377

@@ -420,7 +420,7 @@ public function formatFiles(array $files): array
420420
'size' => $file->getSize(),
421421
'hash' => $file->getEtag(),
422422
'published' => (new DateTime())->setTimestamp($file->getCreationTime())->format('c'),
423-
'modified' => (new DateTime())->setTimestamp($file->getUploadTime())->format('c'),
423+
'modified' => (new DateTime())->setTimestamp($file->getUploadTime())->format('c'),
424424
'labels' => $this->getFileTags(fileId: $file->getId())
425425
];
426426

@@ -517,7 +517,7 @@ public function findShare(string $path, ?int $shareType = 3): ?IShare
517517
private function createShare(array $shareData): IShare
518518
{
519519
$userId = $this->getUser()->getUID();
520-
520+
521521
// Create a new share
522522
$share = $this->shareManager->newShare();
523523
$share->setTarget(target: '/'.$shareData['path']);
@@ -565,7 +565,7 @@ public function createShareLink(string $path, ?int $shareType = 3, ?int $permiss
565565
}
566566

567567
$userId = $this->getUser()->getUID();
568-
568+
569569
try {
570570
$userFolder = $this->rootFolder->getUserFolder(userId: $userId);
571571
} catch (NotPermittedException) {
@@ -819,14 +819,14 @@ public function addFile(ObjectEntity $objectEntity, string $fileName, string $co
819819
$this->userSession->setUser($this->getUser());
820820

821821
$file = $folder->newFile($fileName);
822-
822+
823823
// Write content to the file
824824
$file->putContent($content);
825825

826826
$this->userSession->setUser($currentUser);
827-
827+
828828
return $file;
829-
829+
830830
} catch (NotPermittedException $e) {
831831
$this->logger->error("Permission denied creating file $fileName: " . $e->getMessage());
832832
throw new NotPermittedException("Cannot create file $fileName: " . $e->getMessage());

src/navigation/MainMenu.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ import { navigationStore } from '../store/store.js'
2525
<CubeOutline :size="20" />
2626
</template>
2727
</NcAppNavigationItem>
28+
<NcAppNavigationItem :active="navigationStore.selected === 'search'" name="Search" @click="navigationStore.setSelected('search')">
29+
<template #icon>
30+
<LayersSearchOutline :size="20" />
31+
</template>
32+
</NcAppNavigationItem>
2833
</NcAppNavigationList>
2934

3035
<NcAppNavigationSettings>
@@ -51,6 +56,7 @@ import DatabaseOutline from 'vue-material-design-icons/DatabaseOutline.vue'
5156
import FileTreeOutline from 'vue-material-design-icons/FileTreeOutline.vue'
5257
import DatabaseArrowRightOutline from 'vue-material-design-icons/DatabaseArrowRightOutline.vue'
5358
import CubeOutline from 'vue-material-design-icons/CubeOutline.vue'
59+
import LayersSearchOutline from 'vue-material-design-icons/LayersSearchOutline.vue'
5460
5561
export default {
5662
name: 'MainMenu',

src/sidebars/SideBars.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1+
<script setup>
2+
import { navigationStore } from '../store/store.js'
3+
</script>
4+
15
<template>
2-
<div />
6+
<SearchSideBar v-if="navigationStore.selected === 'search'" />
37
</template>
48

59
<script>
10+
import SearchSideBar from './search/SearchSideBar.vue'
611
712
export default {
813
name: 'SideBars',
914
components: {
15+
SearchSideBar,
1016
},
1117
}
1218
</script>

src/sidebars/search/SearchSideBar.vue

Lines changed: 72 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup>
2-
import { searchStore } from '../../store/store.js'
2+
import { searchStore, registerStore, schemaStore } from '../../store/store.js'
33
</script>
44

55
<template>
@@ -11,96 +11,104 @@ import { searchStore } from '../../store/store.js'
1111
<template #icon>
1212
<Magnify :size="20" />
1313
</template>
14-
Zoek snel in het voor uw beschikbare federatieve netwerk<br>
15-
<NcTextField class="searchField"
16-
:value.sync="searchStore.search"
17-
label="Zoeken" />
18-
<NcNoteCard v-if="searchStore.searchError" type="error">
19-
<p>{{ searchStore.searchError }}</p>
20-
</NcNoteCard>
14+
<NcSelect v-bind="registerOptions"
15+
v-model="selectedRegister"
16+
input-label="Registratie"
17+
:loading="registerLoading" />
18+
<NcSelect v-bind="schemaOptions"
19+
v-model="selectedSchema"
20+
input-label="Schema"
21+
:loading="schemaLoading"
22+
:disabled="!selectedRegister?.id" />
2123
</NcAppSidebarTab>
22-
<NcAppSidebarTab id="settings-tab" name="Catalogi" :order="2">
24+
25+
<NcAppSidebarTab id="upload-tab" name="Upload" :order="2">
2326
<template #icon>
24-
<DatabaseOutline :size="20" />
27+
<Upload :size="20" />
2528
</template>
26-
<NcCheckboxRadioSwitch v-for="(catalogiItem, i) in catalogiStore.catalogiList"
27-
:key="`${catalogiItem}${i}`"
28-
type="switch"
29-
:checked.sync="searchStore.catalogi[catalogiItem.id]">
30-
{{ catalogiItem.title || 'Geen titel' }}
31-
</NcCheckboxRadioSwitch>
29+
<NcButton type="primary">
30+
Upload
31+
</NcButton>
3232
</NcAppSidebarTab>
33-
<NcAppSidebarTab id="share-tab" name="Publicatie typen" :order="3">
33+
34+
<NcAppSidebarTab id="download-tab" name="Download" :order="3">
3435
<template #icon>
35-
<FileTreeOutline :size="20" />
36+
<Download :size="20" />
3637
</template>
37-
<NcCheckboxRadioSwitch v-for="(metaData, i) in metadataStore.metaDataList"
38-
:key="`${metaData}${i}`"
39-
type="switch"
40-
:checked.sync="searchStore.metadata[metaData.id]">
41-
{{ metaData.title || 'Geen titel' }}
42-
</NcCheckboxRadioSwitch>
38+
<NcButton type="primary">
39+
Download
40+
</NcButton>
4341
</NcAppSidebarTab>
4442
</NcAppSidebar>
4543
</template>
4644
<script>
4745
48-
import { NcAppSidebar, NcAppSidebarTab, NcTextField, NcNoteCard, NcCheckboxRadioSwitch } from '@nextcloud/vue'
46+
import { NcAppSidebar, NcAppSidebarTab, NcSelect, NcButton } from '@nextcloud/vue'
4947
import Magnify from 'vue-material-design-icons/Magnify.vue'
50-
import DatabaseOutline from 'vue-material-design-icons/DatabaseOutline.vue'
51-
import FileTreeOutline from 'vue-material-design-icons/FileTreeOutline.vue'
52-
import { debounce } from 'lodash'
48+
import Upload from 'vue-material-design-icons/Upload.vue'
49+
import Download from 'vue-material-design-icons/Download.vue'
5350
5451
export default {
5552
name: 'SearchSideBar',
5653
components: {
5754
NcAppSidebar,
5855
NcAppSidebarTab,
59-
NcTextField,
60-
NcCheckboxRadioSwitch,
61-
// Icons
62-
Magnify,
63-
DatabaseOutline,
64-
FileTreeOutline,
65-
},
66-
props: {
67-
search: {
68-
type: String,
69-
required: true,
70-
},
71-
metadata: {
72-
type: Object,
73-
required: true,
74-
},
75-
catalogi: {
76-
type: Object,
77-
required: true,
78-
},
56+
NcSelect,
57+
NcButton,
7958
},
8059
data() {
8160
return {
82-
starred: false,
61+
registerLoading: false,
62+
selectedRegister: null,
63+
schemaLoading: false,
64+
selectedSchema: null,
8365
}
8466
},
67+
computed: {
68+
// when registerList is filled, make a options object for NcSelect
69+
registerOptions() {
70+
return {
71+
options: registerStore.registerList.map(register => ({
72+
label: register.title,
73+
id: register.id,
74+
})),
75+
}
76+
},
77+
// when schemaList is filled, make a options object for NcSelect based on the selected register
78+
schemaOptions() {
79+
const fullSelectedRegister = registerStore.registerList.find(register => register.id === (this.selectedRegister?.id || Symbol('no selected register')))
80+
if (!fullSelectedRegister) return []
81+
82+
return {
83+
options: schemaStore.schemaList
84+
.filter(schema => fullSelectedRegister.schemas.includes(schema.id))
85+
.map(schema => ({
86+
label: schema.title,
87+
id: schema.id,
88+
})),
89+
}
90+
},
91+
},
8592
watch: {
86-
search: 'debouncedSearch',
87-
metadata: {
88-
handler() {
89-
this.debouncedSearch()
90-
},
91-
deep: true,
93+
// when the selected register changes clear the selected schema
94+
selectedRegister(newValue) {
95+
this.selectedSchema = null
9296
},
93-
catalogi: {
94-
handler() {
95-
this.debouncedSearch()
96-
},
97-
deep: true,
97+
// when selectedSchema changes, search for objects with the selected register and schema as filters
98+
selectedSchema(newValue) {
99+
if (newValue?.id) {
100+
searchStore.searchObjects({
101+
register: this.selectedRegister?.id,
102+
schema: this.selectedSchema?.id,
103+
})
104+
}
98105
},
99106
},
100-
methods: {
101-
debouncedSearch: debounce(function() {
102-
searchStore.getSearchResults()
103-
}, 500),
107+
mounted() {
108+
this.registerLoading = true
109+
this.schemaLoading = true
110+
registerStore.refreshRegisterList().finally(() => (this.registerLoading = false))
111+
schemaStore.refreshSchemaList().finally(() => (this.schemaLoading = false))
104112
},
105113
}
106114
</script>

src/store/modules/search.js

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)