diff --git a/appinfo/info.xml b/appinfo/info.xml index 8b40e68..21783ee 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -5,7 +5,7 @@ Agency App for managing Agency of DA - 0.0.2 + 0.0.1 Agency tools diff --git a/appinfo/routes.php b/appinfo/routes.php index abb37bc..576c62d 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -1,11 +1,11 @@ [ - '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'], ] ]; diff --git a/lib/Agency/AgencyManager.php b/lib/Agency/AgencyManager.php index a1d5c67..4e867a5 100644 --- a/lib/Agency/AgencyManager.php +++ b/lib/Agency/AgencyManager.php @@ -1,24 +1,56 @@ 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); + } + } \ No newline at end of file diff --git a/lib/Controller/AgencyController.php b/lib/Controller/AgencyController.php index cd5f4c9..7ac9c0b 100644 --- a/lib/Controller/AgencyController.php +++ b/lib/Controller/AgencyController.php @@ -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); diff --git a/lib/Controller/TestController.php b/lib/Controller/TestController.php index f4a29c0..60a930e 100644 --- a/lib/Controller/TestController.php +++ b/lib/Controller/TestController.php @@ -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; } } \ No newline at end of file diff --git a/lib/Migration/Version000001Date20210521125400.php b/lib/Migration/Version000001Date20210521125400.php index f826848..45dab41 100644 --- a/lib/Migration/Version000001Date20210521125400.php +++ b/lib/Migration/Version000001Date20210521125400.php @@ -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 ]); diff --git a/lib/Service/AgencyService.php b/lib/Service/AgencyService.php index f8d2f12..937f2fa 100644 --- a/lib/Service/AgencyService.php +++ b/lib/Service/AgencyService.php @@ -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) { diff --git a/package-lock.json b/package-lock.json index 26f0d4b..e7cd25e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index a51c7b8..a0642e8 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/assets/styling.css b/src/assets/styling.css new file mode 100644 index 0000000..adea1ad --- /dev/null +++ b/src/assets/styling.css @@ -0,0 +1,3 @@ +.btn-secondary { + background-color: rgb(84, 69, 69) !important; +} \ No newline at end of file diff --git a/src/components/Navigation.vue b/src/components/Navigation.vue index b370557..f155ea3 100644 --- a/src/components/Navigation.vue +++ b/src/components/Navigation.vue @@ -2,11 +2,20 @@