umbau auf migration
This commit is contained in:
parent
7b20459210
commit
00b6a377e6
|
|
@ -14,7 +14,7 @@
|
|||
</dependencies>
|
||||
<navigations>
|
||||
<navigation>
|
||||
<name>Agenturverwaltung</name>
|
||||
<name>Agenturmigration</name>
|
||||
<route>agency.page.index</route>
|
||||
<icon>app.svg</icon>
|
||||
</navigation>
|
||||
|
|
|
|||
|
|
@ -15,6 +15,6 @@ return [
|
|||
['name' => 'group#addagencygroup', 'url' => '/addagencygroup', 'verb' => 'PUT'],
|
||||
['name' => 'group#delagencygroup', 'url' => '/delagencygroup/{id}', 'verb' => 'GET'],
|
||||
# DEVELOPMENT
|
||||
['name' => 'test#filetest', 'url' => '/filetest', 'verb' => 'GET'],
|
||||
['name' => 'migrate#startMigration', 'url' => '/startmigration', 'verb' => 'PUT'],
|
||||
]
|
||||
];
|
||||
|
|
|
|||
|
|
@ -93,12 +93,14 @@ class AgencyManager {
|
|||
$return_users = array();
|
||||
// Creating a nice User-JSON-Array
|
||||
foreach($users as $user){
|
||||
array_push($return_users, array("user" => $user->getUID(), "displayName" => $user->getDisplayName()));
|
||||
// TODO: Hier muss noch sichergestellt werden, dass der aktuelle Nutzer, wenn er in der Admingruppe ist, sich selbst nicht entfernen kann
|
||||
array_push($return_users, array("user" => $user->getUID(), "displayName" => $user->getDisplayName()));
|
||||
}
|
||||
return $return_users;
|
||||
}
|
||||
|
||||
# TODO: Hier prüfen, ob alle User in der gleichen Agentur sind und er eingeloggte User auch wirklich das Recht dazu hat
|
||||
// TODO: Hier noch sicherstellen, dass der aktuell eingeloggte User sich nicht selbst aus der Admingruppe werfen darf!
|
||||
public function updateagencygroupcontributors(string $gid, array $users){
|
||||
// Getting the Group
|
||||
$groupToChange = $this->groupManager->get($gid);
|
||||
|
|
@ -127,7 +129,6 @@ class AgencyManager {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
return $users;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\Agency\Controller;
|
||||
|
||||
use OCP\IRequest;
|
||||
use OCP\IUserSession;
|
||||
use OCP\IGroupManager;
|
||||
use OCP\IUserManager;
|
||||
use OCP\IGroup;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\AppFramework\Http\JSONResponse;
|
||||
use OCP\AppFramework\Controller;
|
||||
|
||||
use OCP\IDBConnection;
|
||||
|
||||
class MigrateController extends Controller {
|
||||
|
||||
protected $userSession;
|
||||
protected $request;
|
||||
protected $connection;
|
||||
protected $groupManager;
|
||||
protected $userManager;
|
||||
|
||||
use Errors;
|
||||
|
||||
public function __construct(string $AppName, IRequest $request, IUserSession $userSession,IDBConnection $connection, IGroupManager $groupManager, IUserManager $userManager){
|
||||
parent::__construct($AppName, $request);
|
||||
$this->userSession = $userSession;
|
||||
$this->request = $request;
|
||||
$this->connection = $connection;
|
||||
$this->groupManager = $groupManager;
|
||||
$this->userManager = $userManager;
|
||||
}
|
||||
|
||||
// Return an random Id-Ele for generating single IDs
|
||||
public function generateRandomPassword($length = 50) {
|
||||
$characters = '_=()?!-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
$charactersLength = strlen($characters);
|
||||
$randomString = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
||||
}
|
||||
return $randomString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function startMigration(string $agencyid, string $mainurl) {
|
||||
$json = file_get_contents($mainurl.$agencyid);
|
||||
|
||||
// Hier werden die Nutzer erstellt, anhand eines JSON-Arrays von der API (migrateAgency)
|
||||
$ag_data = json_decode($json, true);
|
||||
$feedbackstring = "Erstelle Nutzer: ";
|
||||
foreach($ag_data as $ele){
|
||||
|
||||
$feedbackstring .= $ele['displayname'].", ";
|
||||
|
||||
if($this->userManager->userExists($ele['userid']) == false){
|
||||
$tempuser = $this->userManager->createUser($ele['userid'], $this->generateRandomPassword());
|
||||
$tempuser->setEmailAddress($ele['userid']);
|
||||
}
|
||||
|
||||
}
|
||||
return $feedbackstring;
|
||||
}
|
||||
}
|
||||
|
|
@ -40,6 +40,7 @@ class GroupPermissionService {
|
|||
public function create(string $gid, string $permission = "") {
|
||||
$grouppermission = new GroupPermission();
|
||||
$grouppermission->setGid($gid);
|
||||
$grouppermission->setPermissions($permission);
|
||||
return $this->mapper->insert($grouppermission);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,26 +2,27 @@
|
|||
<b-card no-body>
|
||||
<b-card-header header-tag="header"
|
||||
role="tab">
|
||||
<b-button block
|
||||
<b-btn block
|
||||
variant="secondary"
|
||||
@click="accordionToggle(index)">
|
||||
{{ group.name }}
|
||||
</b-button>
|
||||
</b-btn>
|
||||
<span v-if="group.isDefault"><small>Standardgruppe</small></span>
|
||||
<b-button v-if="!group.isDefault"
|
||||
style="float: right; "
|
||||
<b-btn v-if="!group.isDefault"
|
||||
style="float: right; margin-left: 2px;"
|
||||
size="sm"
|
||||
variant=""
|
||||
@click="delGroup(group.gid)">
|
||||
variant="">
|
||||
<b-icon icon="pencil-fill" aria-hidden="true" />
|
||||
</b-button>
|
||||
<b-button v-if="!group.isDefault"
|
||||
</b-btn>
|
||||
<b-btn v-if="!group.isDefault"
|
||||
v-b-tooltip.hover
|
||||
title="Gruppe löschen"
|
||||
style="float: right;"
|
||||
size="sm"
|
||||
variant="danger"
|
||||
@click="delGroup(group.gid)">
|
||||
<b-icon icon="trash-fill" aria-hidden="true" />
|
||||
</b-button>
|
||||
</b-btn>
|
||||
</b-card-header>
|
||||
<b-collapse :id="groupDefId + index "
|
||||
accordion="groupaccordion"
|
||||
|
|
@ -29,7 +30,6 @@
|
|||
<b-card-body>
|
||||
<Permission :groupid="group.gid" />
|
||||
<hr>
|
||||
Gruppenmitglieder
|
||||
<Multiselect v-if="!group.isMainGroup"
|
||||
v-model="value"
|
||||
:options="formattedContributors"
|
||||
|
|
@ -56,7 +56,7 @@ import { generateUrl } from '@nextcloud/router'
|
|||
import axios from '@nextcloud/axios'
|
||||
import Permission from './Permission'
|
||||
import { Multiselect, ListItemIcon } from '@nextcloud/vue'
|
||||
// TODO: Wenn eine neue Gruppe erstellt wird, ist das MultiSelect-Field NICHT leer :( Da nochmal schauen!
|
||||
// BUG: Wenn eine neue Gruppe erstellt wird, ist das MultiSelect-Field NICHT leer :( Da nochmal schauen!
|
||||
export default {
|
||||
name: 'Group',
|
||||
components: {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<AppNavigation>
|
||||
<template #list>
|
||||
<AppNavigationItem to="/"
|
||||
<!--<AppNavigationItem to="/"
|
||||
title="Agentur"
|
||||
icon="" />
|
||||
<AppNavigationItem to=""
|
||||
|
|
@ -12,13 +12,13 @@
|
|||
icon="icon-user" />
|
||||
<AppNavigationItem to="/groupmanagement"
|
||||
title="Gruppen"
|
||||
icon="icon-group" />
|
||||
icon="icon-group" />-->
|
||||
<!-- TODO: Module später zum programmieren usw. -->
|
||||
<!--<AppNavigationItem to=""
|
||||
title="Module"
|
||||
icon="" />-->
|
||||
<AppNavigationItem to="/testing"
|
||||
title="Tests"
|
||||
<AppNavigationItem to="/"
|
||||
title="Migration"
|
||||
icon="icon-category-customization" />
|
||||
</template>
|
||||
</AppNavigation>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
</p>
|
||||
</template>
|
||||
<script>
|
||||
import { generateUrl } from '@nextcloud/router'
|
||||
import axios from '@nextcloud/axios'
|
||||
|
||||
export default {
|
||||
name: 'Permission',
|
||||
|
|
@ -18,9 +20,17 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
permissions: null,
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.loadGroupPermissions()
|
||||
},
|
||||
methods: {
|
||||
async loadGroupPermissions() {
|
||||
const response = await axios.get(generateUrl('/apps/agency/getpermissions/' + this.groupid))
|
||||
console.log(response)
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -31,6 +31,5 @@ const router = new VueRouter({
|
|||
export default new Vue({
|
||||
el: '#content',
|
||||
router,
|
||||
// store,
|
||||
render: h => h(App),
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import AgencyData from '../views/AgencyData'
|
||||
import Testing from '../views/Testing'
|
||||
import Migrate from '../views/Migrate'
|
||||
import GroupManagement from '../views/GroupManagement'
|
||||
|
||||
export default [
|
||||
{
|
||||
path: '/',
|
||||
path: '/agencydata',
|
||||
name: 'agencydata',
|
||||
component: AgencyData,
|
||||
},
|
||||
|
|
@ -14,8 +14,8 @@ export default [
|
|||
component: GroupManagement,
|
||||
},
|
||||
{
|
||||
path: '/testing',
|
||||
name: 'testing',
|
||||
component: Testing,
|
||||
path: '/',
|
||||
name: 'migrate',
|
||||
component: Migrate,
|
||||
},
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import Vue from 'vue'
|
||||
/*import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
import { generateUrl } from '@nextcloud/router'
|
||||
const axios = require('axios').default
|
||||
|
|
@ -37,4 +37,4 @@ export default new Vuex.Store({
|
|||
return false
|
||||
},
|
||||
},
|
||||
})
|
||||
})*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,64 @@
|
|||
<template>
|
||||
<Content app-name="Migrate">
|
||||
<b-container class="bv-example-row">
|
||||
<h3>Agenturmigration</h3>
|
||||
<FormulateForm
|
||||
@submit="submitHandler">
|
||||
<b-row>
|
||||
<b-col>
|
||||
<FormulateInput name="mainurl"
|
||||
label="Migrationsurl"
|
||||
value="http://host.docker.internal:8000/api/migrateagencyusers/"
|
||||
type="text" />
|
||||
</b-col>
|
||||
</b-row>
|
||||
<b-row>
|
||||
<b-col>
|
||||
<FormulateInput name="agencyid"
|
||||
label="Agentur-ID"
|
||||
validation="required|number"
|
||||
type="text" />
|
||||
</b-col>
|
||||
</b-row>
|
||||
<b-row class="mt-2">
|
||||
<b-col>
|
||||
<b-button
|
||||
variant="secondary"
|
||||
type="submit">
|
||||
Migration starten
|
||||
</b-button>
|
||||
</b-col>
|
||||
</b-row>
|
||||
</FormulateForm>
|
||||
<p>{{ feedbackstring }}</p>
|
||||
</b-container>
|
||||
</Content>
|
||||
</template>
|
||||
<script>
|
||||
import Content from '@nextcloud/vue/dist/Components/Content'
|
||||
import { generateUrl } from '@nextcloud/router'
|
||||
import axios from '@nextcloud/axios'
|
||||
// import '@braid/vue-formulate/themes/snow/snow.scss'
|
||||
// import { generateUrl } from '@nextcloud/router'
|
||||
// const axios = require('axios').default
|
||||
|
||||
export default ({
|
||||
name: 'Migrate',
|
||||
components: {
|
||||
Content,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
feedbackstring: '',
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async submitHandler(data) {
|
||||
this.feedbackstring = 'Migriere Agentur..'
|
||||
const response = await axios.put(generateUrl('/apps/agency/startmigration'), data)
|
||||
console.log(response)
|
||||
this.feedbackstring = response.data
|
||||
},
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
<template>
|
||||
<Content app-name="Testing">
|
||||
<b-container class="bv-example-row">
|
||||
<h3>Allgemeine Tests für den ganzen stuff</h3>
|
||||
</b-container>
|
||||
<button @click="action">
|
||||
Action
|
||||
</button>
|
||||
</Content>
|
||||
</template>
|
||||
<script>
|
||||
import Content from '@nextcloud/vue/dist/Components/Content'
|
||||
import { generateUrl } from '@nextcloud/router'
|
||||
import axios from '@nextcloud/axios'
|
||||
// import '@braid/vue-formulate/themes/snow/snow.scss'
|
||||
// import { generateUrl } from '@nextcloud/router'
|
||||
// const axios = require('axios').default
|
||||
|
||||
export default ({
|
||||
name: 'Testing',
|
||||
components: {
|
||||
Content,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
action() {
|
||||
axios.get(generateUrl('/apps/agency/filetest')).then(function(resp) {
|
||||
console.log(resp)
|
||||
})
|
||||
|
||||
},
|
||||
},
|
||||
})
|
||||
</script>
|
||||
Loading…
Reference in New Issue