Suche nach Usern Teil 1
This commit is contained in:
parent
a34e8f0e88
commit
3b2544e7ac
|
|
@ -8,6 +8,7 @@ return [
|
||||||
# AGENCY
|
# AGENCY
|
||||||
['name' => 'agency#show', 'url' => '/getagencydata', 'verb' => 'GET'],
|
['name' => 'agency#show', 'url' => '/getagencydata', 'verb' => 'GET'],
|
||||||
['name' => 'agency#updateagencydata', 'url' => '/updateagencydata', 'verb' => 'PUT'],
|
['name' => 'agency#updateagencydata', 'url' => '/updateagencydata', 'verb' => 'PUT'],
|
||||||
|
['name' => 'agency#getagencycontributors', 'url' => '/getagencycontributors', 'verb' => 'GET'],
|
||||||
# GROUPS
|
# GROUPS
|
||||||
['name' => 'group#getagencygroups', 'url' => '/getagencygroups', 'verb' => 'GET'],
|
['name' => 'group#getagencygroups', 'url' => '/getagencygroups', 'verb' => 'GET'],
|
||||||
['name' => 'group#addagencygroup', 'url' => '/addagencygroup', 'verb' => 'PUT'],
|
['name' => 'group#addagencygroup', 'url' => '/addagencygroup', 'verb' => 'PUT'],
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ class AgencyManager {
|
||||||
/**
|
/**
|
||||||
* getAgencyByUser
|
* getAgencyByUser
|
||||||
*
|
*
|
||||||
* Return the Agency-ID by filtering the id from default agency-group, ex: agency_1 -> 1 (int)
|
* Return the complete Agency-Data by filtering the id from default agency-group, ex: agency_1 -> 1 (int)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function getAgencyByUser(){
|
public function getAgencyByUser(){
|
||||||
|
|
@ -52,6 +52,20 @@ class AgencyManager {
|
||||||
return $this->agencyMapper->getAgencyByGId($agency_group_id);
|
return $this->agencyMapper->getAgencyByGId($agency_group_id);
|
||||||
#return $agency_group_id;
|
#return $agency_group_id;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Return only the AgencyGroupId
|
||||||
|
*/
|
||||||
|
public function getAgencyGIdByUser(){
|
||||||
|
$groups = $this->groupManager->getUserGroups($this->userSession->getUser());
|
||||||
|
$agency_group_id = "";
|
||||||
|
foreach($groups as $group){
|
||||||
|
if(str_contains($group->getGId(), 'agencymaingroupid_')){
|
||||||
|
$agency_group_id_array = explode("_", strval($group->getGId()));
|
||||||
|
$agency_group_id = $agency_group_id_array[0]."_".$agency_group_id_array[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $agency_group_id;
|
||||||
|
}
|
||||||
|
|
||||||
// Return an random Id-Ele for generating single IDs
|
// Return an random Id-Ele for generating single IDs
|
||||||
public function generateRandomId($length = 6) {
|
public function generateRandomId($length = 6) {
|
||||||
|
|
@ -63,4 +77,22 @@ class AgencyManager {
|
||||||
}
|
}
|
||||||
return $randomString;
|
return $randomString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all users of an Agency by filtering the Main Agency Group Id out
|
||||||
|
*
|
||||||
|
* Returns an Array of IUser-Objects. Filtering is by logged User
|
||||||
|
*/
|
||||||
|
public function getagencycontributors(){
|
||||||
|
$group = $this->groupManager->get($this->getAgencyGIdByUser());
|
||||||
|
$users = $group->getUsers();
|
||||||
|
|
||||||
|
$return_users = array();
|
||||||
|
// Creating a nice User-JSON-Array
|
||||||
|
foreach($users as $user){
|
||||||
|
#array_push($return_users, array("displayName" => $user->getDisplayName(), "uid" => $user->getUID(), "lastLogin" => $user->getLastLogin()));
|
||||||
|
array_push($return_users, $user->getDisplayName());
|
||||||
|
}
|
||||||
|
return $return_users;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -94,4 +94,11 @@ class AgencyController extends Controller {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @NoAdminRequired
|
||||||
|
*/
|
||||||
|
public function getagencycontributors(){
|
||||||
|
return $this->agencyManager->getagencycontributors();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -3,6 +3,8 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace OCA\Agency\Controller;
|
namespace OCA\Agency\Controller;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
use OCP\IGroupManager;
|
use OCP\IGroupManager;
|
||||||
use OCP\AppFramework\Http\DataResponse;
|
use OCP\AppFramework\Http\DataResponse;
|
||||||
|
|
@ -106,12 +108,11 @@ class GroupController extends Controller {
|
||||||
$searchGroupId = $this->agencymanager->getAgencyByUser()->getAgencygid();
|
$searchGroupId = $this->agencymanager->getAgencyByUser()->getAgencygid();
|
||||||
|
|
||||||
$result = false;
|
$result = false;
|
||||||
# If user is in the same Agency, then delete
|
# If user is in the same Agency, then delete is possible - check permissions!
|
||||||
# TODO: Hier noch einbauen, dass die Rechte geprüft werden!
|
# TODO: Hier noch einbauen, dass die Rechte geprüft werden!
|
||||||
if(str_contains($todel->getGID(), $searchGroupId)) {
|
if(str_contains($todel->getGID(), $searchGroupId)) {
|
||||||
# TODO: Hier das löschen der GroupPermission mit verwalten, wenn eine Gruppe gelöscht wird!
|
$this->grouppermissionservice->remove($todel->getGID());
|
||||||
// $todel->delete();
|
$todel->delete();
|
||||||
$result = true;
|
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,11 +34,10 @@ class GroupPermissionMapper extends QBMapper {
|
||||||
return $this->findEntity($qb);
|
return $this->findEntity($qb);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function remove(int $id) {
|
public function remove(string $gid) {
|
||||||
$db = $this->db->getQueryBuilder();
|
$qb = $this->db->getQueryBuilder();
|
||||||
$db->delete($this->getTableName())
|
$qb->delete($this->getTableName())
|
||||||
->where($db->expr()->eq('id', $query->createNamedParameter($id)));
|
->where($qb->expr()->eq('gid', $qb->createNamedParameter($gid)));
|
||||||
|
return $qb->execute();
|
||||||
return $this->findEntity($qb);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -51,9 +51,9 @@ class GroupPermissionService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function remove(int $id){
|
public function remove(string $gid){
|
||||||
try {
|
try {
|
||||||
return $this->mapper->remove($id);
|
return $this->mapper->remove($gid);
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
$this->handleException($e);
|
$this->handleException($e);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,19 +24,27 @@
|
||||||
The GroupId is {{ group.gid }} <br>
|
The GroupId is {{ group.gid }} <br>
|
||||||
<span v-if="group.isDefault">Ist default</span>
|
<span v-if="group.isDefault">Ist default</span>
|
||||||
<span v-else>Nicht default</span>
|
<span v-else>Nicht default</span>
|
||||||
|
<hr>
|
||||||
|
<!-- SHAREING -->
|
||||||
|
<Multiselect
|
||||||
|
placeholder="Suche"
|
||||||
|
:options="agencyContributor" />
|
||||||
</b-card-body>
|
</b-card-body>
|
||||||
</b-collapse>
|
</b-collapse>
|
||||||
</b-card>
|
</b-card>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
// import { generateUrl, generateOcsUrl } from '@nextcloud/router'
|
||||||
import { generateUrl } from '@nextcloud/router'
|
import { generateUrl } from '@nextcloud/router'
|
||||||
import axios from '@nextcloud/axios'
|
import axios from '@nextcloud/axios'
|
||||||
import Permission from './Permission'
|
import Permission from './Permission'
|
||||||
|
import { Multiselect } from '@nextcloud/vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Group',
|
name: 'Group',
|
||||||
components: {
|
components: {
|
||||||
Permission,
|
Permission,
|
||||||
|
Multiselect,
|
||||||
},
|
},
|
||||||
// Properties of Group-Elements
|
// Properties of Group-Elements
|
||||||
props: {
|
props: {
|
||||||
|
|
@ -53,9 +61,22 @@ export default {
|
||||||
return {
|
return {
|
||||||
// Main Group-ID for all Accordions
|
// Main Group-ID for all Accordions
|
||||||
groupDefId: 'acc_groupele_',
|
groupDefId: 'acc_groupele_',
|
||||||
|
contributors: [],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
agencyContributor() {
|
||||||
|
return this.contributors
|
||||||
|
},
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getAgencyContributor()
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
async getAgencyContributor() {
|
||||||
|
const response = await axios.get(generateUrl('/apps/agency/getagencycontributors'))
|
||||||
|
this.contributors = response.data
|
||||||
|
},
|
||||||
// Toggle the Group-Accordion-Element
|
// Toggle the Group-Accordion-Element
|
||||||
accordionToggle(ele) {
|
accordionToggle(ele) {
|
||||||
this.$root.$emit('bv::toggle::collapse', this.groupDefId + ele)
|
this.$root.$emit('bv::toggle::collapse', this.groupDefId + ele)
|
||||||
|
|
@ -67,6 +88,7 @@ export default {
|
||||||
this.$emit('updateGroupData')
|
this.$emit('updateGroupData')
|
||||||
},
|
},
|
||||||
delGroup(id) {
|
delGroup(id) {
|
||||||
|
// Confirm Window
|
||||||
this.$confirm({
|
this.$confirm({
|
||||||
message: 'Möchten Sie die Gruppe ' + this.group.name + ' löschen?',
|
message: 'Möchten Sie die Gruppe ' + this.group.name + ' löschen?',
|
||||||
button: {
|
button: {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import 'bootstrap/dist/css/bootstrap.css'
|
||||||
import 'bootstrap-vue/dist/bootstrap-vue.css'
|
import 'bootstrap-vue/dist/bootstrap-vue.css'
|
||||||
import 'bootstrap-vue/dist/bootstrap-vue-icons.min.css'
|
import 'bootstrap-vue/dist/bootstrap-vue-icons.min.css'
|
||||||
import VueConfirmDialog from 'vue-confirm-dialog'
|
import VueConfirmDialog from 'vue-confirm-dialog'
|
||||||
|
// import { translate, translatePlural } from '@nextcloud/l10n'
|
||||||
// import store from './store'
|
// import store from './store'
|
||||||
|
|
||||||
Vue.use(VueRouter)
|
Vue.use(VueRouter)
|
||||||
|
|
@ -16,6 +17,8 @@ Vue.use(VueFormulate, {
|
||||||
plugins: [de],
|
plugins: [de],
|
||||||
locale: 'de',
|
locale: 'de',
|
||||||
})
|
})
|
||||||
|
// Vue.prototype.t = translate
|
||||||
|
// Vue.prototype.n = translatePlural
|
||||||
Vue.use(VueConfirmDialog)
|
Vue.use(VueConfirmDialog)
|
||||||
Vue.use(BootstrapVue)
|
Vue.use(BootstrapVue)
|
||||||
Vue.use(BootstrapVueIcons)
|
Vue.use(BootstrapVueIcons)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue