Weiterer ausbau

This commit is contained in:
holger.trampe 2021-06-09 20:26:49 +02:00
parent dfd79d1048
commit c0da34309b
15 changed files with 140 additions and 76 deletions

View File

@ -5,7 +5,7 @@
<name>Agency</name>
<summary>App for managing Agency of DA</summary>
<description><![CDATA[test]]></description>
<version>0.0.2</version>
<version>0.0.1</version>
<licence></licence>
<namespace>Agency</namespace>
<category>tools</category>

View File

@ -1,11 +1,11 @@
<?php
return [
'resources' => [
'agency' => ['url' => '/agencys'],
],
//'resources' => [
// 'agency' => ['url' => '/agencys'],
//],
'routes' => [
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
['name' => 'agency#getagencyidbyuser', 'url' => '/getagencyidbyuser', 'verb' => 'GET'],
['name' => 'agency#show', 'url' => '/getagencydata', 'verb' => 'GET'],
['name' => 'test#filetest', 'url' => '/filetest', 'verb' => 'GET'],
]
];

View File

@ -1,24 +1,56 @@
<?php
namespace OCA\Agency\Agency;
use OCP\IRequest;
use OCP\IUserSession;
use OCP\IDBConnection;
use OCA\Agency\Db\AgencyMapper;
use OCA\Agency\Service\AgencyService;
use OCP\IGroupManager;
class AgencyManager {
protected $agencyMapper;
protected $groupManager;
protected $db;
public function __construct(IDBConnection $db) {
$this->appName = $appName;
$this->agencyMapper = new AgencyMapper($db);
public function __construct($AppName, IDBConnection $db, IRequest $request, AgencyMapper $agencyMapper, IGroupManager $groupManager) {
$this->agencyMapper = $agencyMapper;
$this->groupManager = $groupManager;
}
public function createAgencyOnReg(string $agencygid, string $agencydirid, string $standarddirid){
/**
* Creates a new Agency and save it to the database.
*
* @param:
* agencygid - GrouopID of the Agency
* agencydirid - ID for the Grouopfolder for AgencyData
* standarddirid - ID for the Groupfolder for all Uploaded Standardfiles
*/
public function createAgencyOnReg(string $agencygid, int $agencydirid, int $standarddirid){
$agencyService = new AgencyService($this->agencyMapper);
return $agencyService->create(null, null, null, null, null, null, null, $agencygid, $agencydirid, $standarddirid);
}
/**
* getAgencyIdByUser
*
* @param:
* - $request
* - $userSession
*
* Return the Agency-ID by filtering the id from default agency-group, ex: agency_1 -> 1 (int)
*
*/
public function getAgencyIdByUser(IUserSession $userSession){
$groups = $this->groupManager->getUserGroups($userSession->getUser());
$agency_group_id = "";
foreach($groups as $group){
if(str_contains($group->getGId(), 'agency')){
$agency_group_id = explode("_", strval($group->getGId()))[1];
}
}
return intval($agency_group_id);
}
}

View File

@ -10,6 +10,8 @@ use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Controller;
use OCA\Agency\Service\AgencyService;
use OCA\Agency\Agency\AgencyManager;
use OCP\IDBConnection;
class AgencyController extends Controller {
@ -18,14 +20,16 @@ class AgencyController extends Controller {
private $Id;
protected $userSession;
protected $request;
protected $agencyManager;
use Errors;
public function __construct(string $AppName, IRequest $request, IUserSession $userSession, AgencyService $service){
public function __construct(string $AppName, IRequest $request, IUserSession $userSession, AgencyService $service, IDBConnection $connection, AgencyManager $agencymanager){
parent::__construct($AppName, $request);
$this->service = $service;
$this->userSession = $userSession;
$this->request = $request;
$this->agencyManager = $agencymanager;
}
/**
@ -41,7 +45,8 @@ class AgencyController extends Controller {
*
* @param int $id
*/
public function show(int $id) {
public function show() {
$id = $this->agencyManager->getAgencyIdByUser($this->userSession);
return $this->handleNotFound(function () use ($id) {
return $this->service->find($id);
});
@ -73,7 +78,7 @@ class AgencyController extends Controller {
* @param int $id
* @param string $title
*/
public function update(int $id, string $name, string $inhaber, string $street, string $plz, string $city, string $agencymail, string $phone) {
public function update(int $id, string $name = null, string $inhaber = null, string $street = null, string $plz = null, string $city = null, string $agencymail = null, string $phone = null) {
return $this->handleNotFound(function () use ($id, $name, $inhaber, $street, $plz, $city, $agencymail, $phone) {
# TODO: ABfrage machen!
return $this->service->update($id, $name, $inhaber, $street, $plz, $city, $agencymail, $phone);

View File

@ -10,18 +10,27 @@ use OCP\Util;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\DataResponse;
use OCA\Agency\Agency\AgencyManager;
use OCP\IDBConnection;
use OCP\IGroupManager;
use OCP\IUserManager;
class TestController extends Controller {
protected $appName;
protected $agencyManager;
public function __construct($appName, IRequest $request, IDBConnection $db) {
private $groupManager;
private $userManager;
public function __construct($appName, IRequest $request, IDBConnection $db, IGroupManager $gm, IUserManager $userManager) {
parent::__construct($appName, $request);
$this->appName = $appName;
$this->agencyManager = new AgencyManager($db);
$this->groupManager = $gm;
$this->userManager = $userManager;
}
/**
@ -29,8 +38,17 @@ class TestController extends Controller {
* @NoCSRFRequired
*/
public function filetest() {
# TODO: Diese Erstellung hier portieren, damit bei neuem User auch eine neue Agentur mit den Infos zur GruppenID und den Ordner-IDs für Standards und Dateien erstellt wird
return $this->agencyManager->createAgencyOnReg("0","0","0");
$user = $this->userManager->get('holger');
$groups = $this->groupManager->getUserGroups($user);
$agency_group_id = "";
foreach($groups as $group){
if(str_contains($group->getGId(), 'agency')){
$agency_group_id = explode("_", strval($group->getGId()))[1];
}
}
return $agency_group_id;
}
}

View File

@ -67,15 +67,15 @@
'length' => 200
]);
$table->addColumn('agencydirid', 'string', [
$table->addColumn('agencydirid', 'integer', [
'notnull' => true,
'default' => '',
'default' => 0,
'length' => 200
]);
$table->addColumn('standarddirid', 'string', [
$table->addColumn('standarddirid', 'integer', [
'notnull' => true,
'default' => '',
'default' => 0,
'length' => 200
]);

View File

@ -52,7 +52,7 @@ class AgencyService {
return $this->mapper->insert($agency);
}
//Update an Agency
public function update(int $id, string $name, string $inhaber, string $street, string $plz, string $city, string $agencymail, string $phone) {
public function update(int $id, string $name = null, string $inhaber = null, string $street = null, string $plz = null, string $city = null, string $agencymail = null, string $phone = null) {
try {
$agency = $this->mapper->find($id);
} catch(Exception $e) {

27
package-lock.json generated
View File

@ -2264,6 +2264,11 @@
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.0.1.tgz",
"integrity": "sha512-Fl79+wsLOZKoiU345KeEaWD0ik8WKRI5zm0YSPj2oF1Qr+BO7z0fco6GbUtqjoG1h4VI89PeKJnMsMMVQdKKTw=="
},
"bootstrap-icons-vue": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/bootstrap-icons-vue/-/bootstrap-icons-vue-0.7.0.tgz",
"integrity": "sha512-bxdJB3GKJ1MaJxbMbK8xkM+EADELF1XYx9KLNFZD/k0Rt7Zp+h8h+zKe31npqHPr1UllRThiGxESs3e/EORiRg=="
},
"bootstrap-vue": {
"version": "2.21.2",
"resolved": "https://registry.npmjs.org/bootstrap-vue/-/bootstrap-vue-2.21.2.tgz",
@ -2621,7 +2626,6 @@
"version": "3.5.1",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.1.tgz",
"integrity": "sha512-9+s+Od+W0VJJzawDma/gvBNQqkTiqYTWLuZoyAsivsI4AaWTCzHG06/TMjsf1cYe9Cb97UCEhjz7HvnPk2p/tw==",
"optional": true,
"requires": {
"anymatch": "3.1.2",
"braces": "3.0.2",
@ -2637,7 +2641,6 @@
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz",
"integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==",
"optional": true,
"requires": {
"normalize-path": "3.0.0",
"picomatch": "2.2.3"
@ -2646,14 +2649,12 @@
"binary-extensions": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz",
"integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==",
"optional": true
"integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA=="
},
"braces": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
"optional": true,
"requires": {
"fill-range": "7.0.1"
}
@ -2662,7 +2663,6 @@
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
"optional": true,
"requires": {
"to-regex-range": "5.0.1"
}
@ -2671,7 +2671,6 @@
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
"optional": true,
"requires": {
"is-glob": "4.0.1"
}
@ -2680,7 +2679,6 @@
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz",
"integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==",
"optional": true,
"requires": {
"binary-extensions": "2.2.0"
}
@ -2688,14 +2686,12 @@
"is-number": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
"optional": true
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng=="
},
"readdirp": {
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.5.0.tgz",
"integrity": "sha512-cMhu7c/8rdhkHXWsY+osBhfSy0JikwpHK/5+imo+LpeasTF8ouErHrlYkwT0++njiyuDvc7OFY5T3ukvZ8qmFQ==",
"optional": true,
"requires": {
"picomatch": "2.2.3"
}
@ -2704,7 +2700,6 @@
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
"optional": true,
"requires": {
"is-number": "7.0.0"
}
@ -8107,6 +8102,14 @@
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"dev": true
},
"sass": {
"version": "1.34.1",
"resolved": "https://registry.npmjs.org/sass/-/sass-1.34.1.tgz",
"integrity": "sha512-scLA7EIZM+MmYlej6sdVr0HRbZX5caX5ofDT9asWnUJj21oqgsC+1LuNfm0eg+vM0fCTZHhwImTiCU0sx9h9CQ==",
"requires": {
"chokidar": "3.5.1"
}
},
"sass-graph": {
"version": "2.2.5",
"resolved": "https://registry.npmjs.org/sass-graph/-/sass-graph-2.2.5.tgz",

View File

@ -22,7 +22,9 @@
"@nextcloud/vue": "^3.7.0",
"axios": "^0.21.1",
"bootstrap": "^5.0.1",
"bootstrap-icons-vue": "^0.7.0",
"bootstrap-vue": "^2.21.2",
"sass": "^1.34.1",
"vue": "^2.6.12",
"vue-router": "^3.5.1",
"vuex": "^3.6.2"

3
src/assets/styling.css Normal file
View File

@ -0,0 +1,3 @@
.btn-secondary {
background-color: rgb(84, 69, 69) !important;
}

View File

@ -2,11 +2,20 @@
<AppNavigation>
<template #list>
<AppNavigationItem to="/"
title="Agenturdaten"
icon="icon-category-customization" />
title="Agentur"
icon="" />
<AppNavigationItem to=""
title="Abrechnung"
icon="" />
<AppNavigationItem to=""
title="Mitarbeiter"
icon="icon-user" />
<AppNavigationItem to="/groupmanagement"
title="Gruppenverwaltung"
icon="icon-category-customization" />
title="Gruppen"
icon="icon-group" />
<AppNavigationItem to=""
title="Module"
icon="" />
<AppNavigationItem to="/testing"
title="Tests"
icon="icon-category-customization" />

View File

@ -4,10 +4,11 @@ import VueRouter from 'vue-router'
import Routes from './router/routes'
import VueFormulate from '@braid/vue-formulate'
import { de } from '@braid/vue-formulate-i18n'
import { BootstrapVue, IconsPlugin } from 'bootstrap-vue'
import { BootstrapVue, BootstrapVueIcons } from 'bootstrap-vue'
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'
import store from './store'
import 'bootstrap-vue/dist/bootstrap-vue-icons.min.css'
// import store from './store'
Vue.use(VueRouter)
Vue.use(VueFormulate, {
@ -15,7 +16,7 @@ Vue.use(VueFormulate, {
locale: 'de',
})
Vue.use(BootstrapVue)
Vue.use(IconsPlugin)
Vue.use(BootstrapVueIcons)
Vue.prototype.$hostname = 'http://localhost:8080'
const router = new VueRouter({
@ -25,6 +26,6 @@ const router = new VueRouter({
export default new Vue({
el: '#content',
router,
store,
// store,
render: h => h(App),
})

View File

@ -25,12 +25,12 @@ export default new Vuex.Store({
},
},
actions: {
loadAgencyData({ commit }) {
async loadAgencyData({ commit }) {
// axios.get(generateUrl('/apps/agency/getagencyidbyuser')).then(response => {
// console.log('Here we load...')
// this.agencyId = response.data.agency
// }) + this.$store.state.agencyId
const agencydata = axios.get(generateUrl('/apps/agency/agencys/4')).then(function() {
const agencydata = await axios.get(generateUrl('/apps/agency/agencys/4')).then(function() {
commit('setAgency', agencydata.data)
return true
})

View File

@ -5,8 +5,8 @@
<FormulateForm
v-model="agency"
@submit="submitHandler">
<b-row cols="1"
cols-sm="1"
<b-row cols="2"
cols-sm="2"
cols-md="2"
cols-lg="4">
<b-col>
@ -20,8 +20,8 @@
type="text" />
</b-col>
</b-row>
<b-row cols="1"
cols-sm="1"
<b-row cols="2"
cols-sm="2"
cols-md="2"
cols-lg="4">
<b-col>
@ -35,8 +35,8 @@
type="text" />
</b-col>
</b-row>
<b-row cols="1"
cols-sm="1"
<b-row cols="2"
cols-sm="2"
cols-md="2"
cols-lg="4">
<b-col>
@ -46,12 +46,12 @@
</b-col>
<b-col>
<FormulateInput name="agencymail"
label="Agentur-Email-Adresse"
label="Agentur-Email-Adressedd"
type="text" />
</b-col>
</b-row>
<b-row cols="1"
cols-sm="1"
<b-row cols="2"
cols-sm="2"
cols-md="2"
cols-lg="4">
<b-col>
@ -62,9 +62,11 @@
</b-row>
<b-row class="mt-2">
<b-col>
<FormulateInput
type="submit"
label="Aktualisieren" />
<b-button
variant="secondary"
type="submit">
Aktualisieren
</b-button>
</b-col>
</b-row>
</FormulateForm>
@ -77,6 +79,7 @@
<script>
import Content from '@nextcloud/vue/dist/Components/Content'
import { generateUrl } from '@nextcloud/router'
import '@braid/vue-formulate/themes/snow/snow.scss'
const axios = require('axios').default
export default ({
@ -86,29 +89,21 @@ export default ({
},
data() {
return {
agency: this.$store.agency,
agency: null,
isLoading: false,
}
},
created() {
this.loadInitialData()
this.loadingAgencyData()
},
methods: {
async loadInitialData() {
// await this.$store.dispatch('loadAgencyData') {
// console.log('Done!')
// console.log(this.$store.state)
// }
console.log('Loading something')
},
async loadingAgencyData() {
// const agencydata = await axios.get(generateUrl('/apps/agency/agencys/' + this.$store.state.agencyId))
// this.agency = agencydata.data
// this.isLoading = true
console.log('Now loading AgencyData')
const agencydata = await axios.get(generateUrl('/apps/agency/getagencydata'))
this.agency = agencydata.data
this.isLoading = true
},
async submitHandler(data) {
const response = await axios.put(generateUrl('/apps/agency/agencys/' + this.$store.state.agencyid), data)
const response = await axios.put(generateUrl('/apps/agency/agencys/1'), data)
console.log(response)
},
},

View File

@ -1,7 +1,8 @@
<template>
<Content app-name="GroupManagement">
<b-container class="bv-example-row">
<h3>Gruppenverwaltung in Echt jetzt!</h3>
<h3>Gruppenverwaltung</h3>
<hr>
</b-container>
</Content>
</template>
@ -22,13 +23,8 @@ export default ({
}
},
created() {
this.loadUserData()
},
methods: {
async loadUserData() {
// const userdata = await axios.get(generateUrl('/apps/agency/getagencyidbyuser'))
// console.log(userdata)
},
},
})
</script>