From 95a41e671c5faca60d0e4e5aee1cbd605e3057f5 Mon Sep 17 00:00:00 2001 From: romankko2 Date: Thu, 2 Feb 2023 11:23:30 +0100 Subject: [PATCH 01/15] . --- app/src/plugins/tm@modal/blocker/z-blocker-modal.vue | 3 --- app/src/plugins/tm@modal/task/z-task-modal.vue | 3 --- 2 files changed, 6 deletions(-) diff --git a/app/src/plugins/tm@modal/blocker/z-blocker-modal.vue b/app/src/plugins/tm@modal/blocker/z-blocker-modal.vue index 7805a7b..68b9f88 100644 --- a/app/src/plugins/tm@modal/blocker/z-blocker-modal.vue +++ b/app/src/plugins/tm@modal/blocker/z-blocker-modal.vue @@ -167,9 +167,6 @@ export default { await this.$axios.post_auth('v1/blockers', this.blocker) this.closeModal() - - // Kravarik: Toto tu ma byt? - this.$router.push({ name: 'Dashboard - Tasks' }) } catch (error) { this.$toast(error) } diff --git a/app/src/plugins/tm@modal/task/z-task-modal.vue b/app/src/plugins/tm@modal/task/z-task-modal.vue index 91cdae4..6f6eaf0 100644 --- a/app/src/plugins/tm@modal/task/z-task-modal.vue +++ b/app/src/plugins/tm@modal/task/z-task-modal.vue @@ -424,9 +424,6 @@ export default { } this.closeModal() - - // Kravarik: Toto tu ma byt? - this.$router.push({ name: 'Dashboard - Tasks' }) } catch (error) { this.$toast.error(error) } From 9725b92ff17a8a038a805f749c48b45a3aba1c47 Mon Sep 17 00:00:00 2001 From: romankko2 Date: Thu, 2 Feb 2023 11:42:28 +0100 Subject: [PATCH 02/15] . --- .../plugins/tm@modal/master-task/z-master-task-modal.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue b/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue index 056c8b6..af6d06c 100644 --- a/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue +++ b/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue @@ -233,7 +233,7 @@ -

{{ (masterTask.worked_time)?.toFixed(2) }} h

+

{{ (masterTask.time_worked)?.toFixed(2) }} h

@@ -251,7 +251,7 @@ -

{{ (masterTask.duration - masterTask.worked_time)?.toFixed(2) }} h

+

{{ (masterTask.duration - masterTask.time_worked)?.toFixed(2) }} h

@@ -385,6 +385,7 @@ export default { } catch (error) { this.$toast.error(error) } + console.log(this.masterTask) }, async save() { @@ -399,7 +400,6 @@ export default { await this.$axios.post_auth('v1/mastertasks', this.masterTask) this.closeModal() - // this.$router.push({ name: 'Dashboard - Tasks' }) } catch (error) { this.$toast(error) } From 5eea588984453a3ec5d705eb334920411783d1d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Kalu=C5=BEa?= Date: Thu, 2 Feb 2023 13:44:17 +0100 Subject: [PATCH 03/15] [timeline, sidemenu] fixnute velkosti podla grafiky --- app/src/plugins/app/_layout/app/_components/a-sidemenu.vue | 5 +++-- app/src/plugins/app/_layout/app/app.layout.vue | 4 ++-- app/src/plugins/lib@auth/login/_components/a-login-form.vue | 2 +- app/src/plugins/tm@dashboard/_components/z-timeline.vue | 2 +- app/src/plugins/tm@dashboard/tasks/tasks.vue | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/src/plugins/app/_layout/app/_components/a-sidemenu.vue b/app/src/plugins/app/_layout/app/_components/a-sidemenu.vue index 56ac007..646cd73 100644 --- a/app/src/plugins/app/_layout/app/_components/a-sidemenu.vue +++ b/app/src/plugins/app/_layout/app/_components/a-sidemenu.vue @@ -109,6 +109,7 @@ ion-item @media (min-width: 992px) ion-menu - width: 300px - --width: 300px + width: 257px + min-width: 257px + --width: 257px diff --git a/app/src/plugins/app/_layout/app/app.layout.vue b/app/src/plugins/app/_layout/app/app.layout.vue index dbc81d5..ed15c39 100644 --- a/app/src/plugins/app/_layout/app/app.layout.vue +++ b/app/src/plugins/app/_layout/app/app.layout.vue @@ -44,6 +44,6 @@ export default { @media (min-width: 992px) .split-pane-right-side - width: calc(100vw - 300px) !important - max-width: calc(100vw - 300px) !important + width: calc(100vw - 257px) !important + max-width: calc(100vw - 257px) !important diff --git a/app/src/plugins/lib@auth/login/_components/a-login-form.vue b/app/src/plugins/lib@auth/login/_components/a-login-form.vue index 45e1942..a7adf08 100644 --- a/app/src/plugins/lib@auth/login/_components/a-login-form.vue +++ b/app/src/plugins/lib@auth/login/_components/a-login-form.vue @@ -42,7 +42,7 @@ export default { try { await this.$store.dispatch('auth/login', this.form) - this.$router.push({ name: 'Overview - Ongoing tasks'}) + this.$router.push({ name: 'Dashboard - Tasks'}) } catch (error) { this.$toast.error(error) } diff --git a/app/src/plugins/tm@dashboard/_components/z-timeline.vue b/app/src/plugins/tm@dashboard/_components/z-timeline.vue index 227b150..563c8b1 100644 --- a/app/src/plugins/tm@dashboard/_components/z-timeline.vue +++ b/app/src/plugins/tm@dashboard/_components/z-timeline.vue @@ -17,7 +17,7 @@ :scroll-to-hour="calConfig.scrollHour" :split-days="splits" :sticky-split-labels="true" - :min-split-width="300" + :min-split-width="270" @ready="onReady()" @view-change="weekChanged" @event-drop="eventMoved" diff --git a/app/src/plugins/tm@dashboard/tasks/tasks.vue b/app/src/plugins/tm@dashboard/tasks/tasks.vue index 0e27252..6dfc60e 100644 --- a/app/src/plugins/tm@dashboard/tasks/tasks.vue +++ b/app/src/plugins/tm@dashboard/tasks/tasks.vue @@ -82,7 +82,7 @@ export default { event.split = diffInDays * (-1) + 1 }) - console.log(this.timelineData.tasks) + // console.log(this.timelineData.tasks) this.unscheduledTime = 0 From 2c4299616d1e2d748baa333ef3506f130e1671c0 Mon Sep 17 00:00:00 2001 From: romankko2 Date: Thu, 2 Feb 2023 19:14:50 +0100 Subject: [PATCH 04/15] [z-delete-masterTask-modal, spenTime formatted, addSubTask, style team in subTask detail] --- app/src/plugins/app/_config/App.vue | 32 +++++++---- .../app/_layout/app/_components/a-header.vue | 17 +----- .../app/_theme/_components/modals.sass | 15 +++--- .../z-delete-master-task-modal.vue | 54 +++++++++++++++++++ .../master-task/z-master-task-modal.vue | 53 +++++++++--------- .../tm@modal/task/z-delete-task-modal.vue | 5 +- .../plugins/tm@modal/task/z-task-modal.vue | 11 ++-- app/src/plugins/tm@overview/teams/teams.vue | 2 +- 8 files changed, 118 insertions(+), 71 deletions(-) create mode 100644 app/src/plugins/tm@modal/master-task/z-delete-master-task-modal.vue diff --git a/app/src/plugins/app/_config/App.vue b/app/src/plugins/app/_config/App.vue index 19efa9f..c322478 100644 --- a/app/src/plugins/app/_config/App.vue +++ b/app/src/plugins/app/_config/App.vue @@ -5,16 +5,17 @@ - - + + - - - - - + + + + + + - + \ No newline at end of file diff --git a/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue b/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue index af6d06c..fb9bf27 100644 --- a/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue +++ b/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue @@ -133,8 +133,8 @@ @@ -177,9 +177,9 @@ - + - +
- -

{{ masterTask.team }}

-
+ +

Tu bude vypisany nazov Timu

+

{{ employee.name.charAt(0) + employee.surname.charAt(0) }}

@@ -273,14 +273,14 @@
- - - {{ masterTask.name }} + + {{ task.master_task }}

- {{ employee.name.charAt(0) + employee.surname.charAt(0) }} + IN

-

+ +

Meno zamestnanca

@@ -293,7 +293,7 @@
- Pridať Subtask + Pridať Subtask
@@ -358,6 +358,12 @@ export default { } }, + mounted() { + this.$events.on('on-master-task-deleted', (masterTask) => { + if (masterTask?.id == this.masterTask?.id) this.closeModal() + }) + }, + methods: { itemSelected(x) { console.log(x) @@ -385,7 +391,6 @@ export default { } catch (error) { this.$toast.error(error) } - console.log(this.masterTask) }, async save() { @@ -410,15 +415,8 @@ export default { this.$emit('close', this.masterTask) }, - async _delete() { - // Kravarik: Tu sa ma volat delete-master-task-modal, ak taka funkcionalita vlastne je - - // try { - // await this.$axios.delete(`v1/master-tasks/${this.masterTask.id}`) - // this.closeModal() - // } catch (error) { - // this.$toast.error(error) - // } + openDeleteMasterTaskModal(masterTask) { + this.$events.emit('show-delete-master-task-modal', { masterTask }) }, employeeSelected(selectedOption) { @@ -429,7 +427,11 @@ export default { filesUploaded(files) { this.masterTask.files = files - } + }, + + addTask() { + this.$events.emit('show-task-modal', {}) + }, }, computed: { @@ -502,9 +504,6 @@ export default { .scrolling overflow: hidden !important -.scroll-employees - overflow-x: scroll - .border-bottom border-bottom: 1px solid rgba(0,0,0,.1) diff --git a/app/src/plugins/tm@modal/task/z-delete-task-modal.vue b/app/src/plugins/tm@modal/task/z-delete-task-modal.vue index 56c1962..5ca82b4 100644 --- a/app/src/plugins/tm@modal/task/z-delete-task-modal.vue +++ b/app/src/plugins/tm@modal/task/z-delete-task-modal.vue @@ -8,6 +8,7 @@ @click.stop="closeModal()" icon="mdi-close" size="large" + class="mb-15" >
@@ -20,7 +21,7 @@ diff --git a/app/src/plugins/tm@modal/task/z-task-modal.vue b/app/src/plugins/tm@modal/task/z-task-modal.vue index 04cea04..3ecad71 100644 --- a/app/src/plugins/tm@modal/task/z-task-modal.vue +++ b/app/src/plugins/tm@modal/task/z-task-modal.vue @@ -420,6 +420,7 @@ export default { try { if (this.task.id) { await this.$axios.put_auth(`v1/mastertasks/${this.task.id}`, this.task) + this.$events.emit('on-task-edited', this.task) } else { await this.$axios.post_auth('v1/mastertasks', this.task) } From 04a738ddc71c880f5d184c45193fade6f2151751 Mon Sep 17 00:00:00 2001 From: romankko2 Date: Mon, 6 Feb 2023 19:05:28 +0100 Subject: [PATCH 06/15] [sub-task-detail-modal] multiple dates --- app/public/mock/v1/tasks/(id).GET.json | 13 +++- app/src/plugins/app/_theme/global.sass | 15 ++++ .../master-task/z-master-task-modal.vue | 26 +++++-- .../plugins/tm@modal/task/z-task-modal.vue | 73 +++++++++++++++++-- 4 files changed, 114 insertions(+), 13 deletions(-) diff --git a/app/public/mock/v1/tasks/(id).GET.json b/app/public/mock/v1/tasks/(id).GET.json index 320d663..5dd1e78 100644 --- a/app/public/mock/v1/tasks/(id).GET.json +++ b/app/public/mock/v1/tasks/(id).GET.json @@ -7,7 +7,18 @@ "duration": 5400000, "spent_time": 3000000, "is_finished": false, - "dates": [], + "timeblocks": [ + { + "id": 43, + "start": "2023-01-31 04:02:17", + "end": "2023-01-31 08:23:05" + }, + { + "id": 52, + "start": "2023-09-26 01:01:17", + "end": "2024-02-11 08:23:05" + } + ], "master_task": { "id": 1, "name": "Master task 1", diff --git a/app/src/plugins/app/_theme/global.sass b/app/src/plugins/app/_theme/global.sass index 193b9e2..b269b45 100644 --- a/app/src/plugins/app/_theme/global.sass +++ b/app/src/plugins/app/_theme/global.sass @@ -34,6 +34,21 @@ height: 24px width: 24px +.remove-date + border: 1px solid rgba(0, 0, 0, 0.2) + border-radius: 50% + padding: 13px + height: 24px + width: 24px + +.add-date + color: white + border-radius: 50% + background: #6200EE + padding: 13px + height: 24px + width: 24px + th font-size: 16px !important diff --git a/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue b/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue index fb9bf27..c62c19e 100644 --- a/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue +++ b/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue @@ -277,15 +277,14 @@ {{ task.master_task }}

- IN + {{ getFullNameByEmployeeId(task.employee_id).initials }}

- -

Meno zamestnanca

+

{{ getFullNameByEmployeeId(task.employee_id).fullName }}

- checkmark-icon - pencil-icon + checkmark-icon + pencil-icon trash-icon
@@ -369,6 +368,23 @@ export default { console.log(x) }, + getFullNameByEmployeeId(employee_id) { + let fullName = '' + let initials = '' + this.employees.forEach(employee => { + if (employee.id === employee_id) { + fullName = `${employee.name} ${employee.surname}` + initials = employee.name.charAt(0) + employee.surname.charAt(0) + } + }) + return { + fullName, + initials + } + + }, + + async showModal(masterTask, editMode = false) { this.visible = true this.masterTask = null diff --git a/app/src/plugins/tm@modal/task/z-task-modal.vue b/app/src/plugins/tm@modal/task/z-task-modal.vue index 3ecad71..afe9e91 100644 --- a/app/src/plugins/tm@modal/task/z-task-modal.vue +++ b/app/src/plugins/tm@modal/task/z-task-modal.vue @@ -165,9 +165,9 @@
- + - +
-

+

+ +

+

+
+ + + +
+

Pridať dátum

+ + +
+ + + + Potvrdiť +
+
@@ -355,7 +396,9 @@ export default { preventInputFocus: false, masterTasks: [], masterTaskIdSelect: null, - employeeIdSelect: null + employeeIdSelect: null, + showDatePicker: false, + selectedNewDate: [] } }, @@ -377,6 +420,7 @@ export default { duration: { required }, employee: { required }, }, + selectedNewDate: { required } } }, @@ -431,6 +475,21 @@ export default { } }, + async addNewDate() { + if (this.selectedNewDate) { + this.task.timeblocks.push({ + start: this.selectedNewDate[0], + end: this.selectedNewDate[1] + }) + this.showDatePicker = false + this.selectedNewDate = [] + } + }, + + removeDate(index) { + this.task.timeblocks.splice(index, 1) + }, + openDeleteTaskModal(task) { this.$events.emit('show-delete-task-modal', { task }) }, From 9293e8efff5ca360837f2df6634b5094f5099c31 Mon Sep 17 00:00:00 2001 From: Michal Feher Date: Tue, 7 Feb 2023 09:01:08 +0100 Subject: [PATCH 07/15] no message --- be/app/Http/Resources/MasterTaskResource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/be/app/Http/Resources/MasterTaskResource.php b/be/app/Http/Resources/MasterTaskResource.php index 53ea379..a7ef8bd 100644 --- a/be/app/Http/Resources/MasterTaskResource.php +++ b/be/app/Http/Resources/MasterTaskResource.php @@ -24,7 +24,7 @@ class MasterTaskResource extends JsonResource 'starts_at' => $this->created_at, 'deadline' => $this->deadline, 'project_code' => $this->project->code, - 'team_id' => ($this->team) ? $this->team->id : null, + 'team' => ($this->team) ?: null, 'employees' => UserResource::collection($this->usersOutsideTeam), 'subtasks' => SubTaskResource::collection($this->subtasks), 'files' => AttachmentResource::collection($this->attachments), From d5b4f1a3452221e2c1cab27ff7f8a57513272582 Mon Sep 17 00:00:00 2001 From: romankko2 Date: Tue, 7 Feb 2023 10:22:04 +0100 Subject: [PATCH 08/15] [z-subtask-detail] index fix --- app/src/plugins/tm@modal/task/z-task-modal.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/plugins/tm@modal/task/z-task-modal.vue b/app/src/plugins/tm@modal/task/z-task-modal.vue index afe9e91..85e05a7 100644 --- a/app/src/plugins/tm@modal/task/z-task-modal.vue +++ b/app/src/plugins/tm@modal/task/z-task-modal.vue @@ -179,7 +179,7 @@ -
+
Date: Tue, 7 Feb 2023 10:23:02 +0100 Subject: [PATCH 09/15] [z-subtask-detail] index fix From 9370dd43b91fe8663a8255e4778a3e87ea937d22 Mon Sep 17 00:00:00 2001 From: romankko2 Date: Tue, 7 Feb 2023 11:02:47 +0100 Subject: [PATCH 10/15] [z-masterTask-detail] team name --- .../tm@modal/master-task/z-master-task-modal.vue | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue b/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue index c62c19e..4c659b3 100644 --- a/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue +++ b/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue @@ -191,7 +191,7 @@ -

Tu bude vypisany nazov Timu

+

{{ masterTask.team.name }}

{{ employee.name.charAt(0) + employee.surname.charAt(0) }} @@ -274,17 +274,17 @@ - {{ task.master_task }} + {{ task.project_code }}

{{ getFullNameByEmployeeId(task.employee_id).initials }}

-

{{ getFullNameByEmployeeId(task.employee_id).fullName }}

+

{{ getFullNameByEmployeeId(task.employee_id).fullName }}

- checkmark-icon - pencil-icon + checkmark-icon + pencil-icon trash-icon
From d03dac838f9fea72a8574ccfbc7d8fc7094c417f Mon Sep 17 00:00:00 2001 From: romankko2 Date: Tue, 7 Feb 2023 11:54:35 +0100 Subject: [PATCH 11/15] [w-loadable] fix warning --- app/src/plugins/w/loadable/_components/w-loadable.vue | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/plugins/w/loadable/_components/w-loadable.vue b/app/src/plugins/w/loadable/_components/w-loadable.vue index 22e0ba9..2f80a60 100644 --- a/app/src/plugins/w/loadable/_components/w-loadable.vue +++ b/app/src/plugins/w/loadable/_components/w-loadable.vue @@ -26,13 +26,12 @@ export default { } }, - async created() { + async mounted() { await this._startLoading() }, methods: { async _startLoading() { - // Kravarik: toto hadze tie warny v konzole. Fixnut this.loader = await this.$loading.show() }, @@ -56,4 +55,4 @@ export default { + \ No newline at end of file From ed3300ad2979e988527683b2bbeb83b7578c21a1 Mon Sep 17 00:00:00 2001 From: Michal Feher Date: Tue, 7 Feb 2023 12:29:05 +0100 Subject: [PATCH 12/15] attachments upload --- .../Http/Controllers/MasterTaskController.php | 21 +- be/app/Http/Controllers/SubTaskController.php | 7 + be/app/Http/Resources/AttachmentResource.php | 3 +- be/app/Http/Resources/SubTaskResource.php | 3 +- be/app/Models/Attachment.php | 32 + be/app/Models/MasterTask.php | 5 + be/app/Models/SubTask.php | 5 + be/composer.json | 4 +- be/composer.lock | 621 +++++++++++++++++- 9 files changed, 689 insertions(+), 12 deletions(-) diff --git a/be/app/Http/Controllers/MasterTaskController.php b/be/app/Http/Controllers/MasterTaskController.php index fa898d1..a454a82 100644 --- a/be/app/Http/Controllers/MasterTaskController.php +++ b/be/app/Http/Controllers/MasterTaskController.php @@ -2,20 +2,23 @@ namespace App\Http\Controllers; +use App\Models\Attachment; use App\Models\MasterTask; use App\Models\Team; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Validator; class MasterTaskController extends Controller { public function store(Request $request) { - $image = base64_encode(file_get_contents($request->all()['data']['files'][0])); - echo $image; - - dd('done'); +//// $image = base64_encode(file_get_contents($request->all()['data']['files'][0])); +// $image = base64_encode(file_get_contents($request->all()['files'])); +// +// echo $image; +// dd(file_get_contents($request->all()['files'])); $validator = Validator::make($request->all(), [ 'data.name' => 'required', @@ -23,6 +26,7 @@ class MasterTaskController extends Controller 'data.duration' => 'required', 'data.deadline' => 'required', 'data.project_id' => 'required', + 'data.employees' => 'required', ]); if($validator->fails()){ @@ -34,19 +38,22 @@ class MasterTaskController extends Controller $data['data']['title'] = $request->all()['data']['name']; $data['data']['estimated_time'] = $request->all()['data']['duration']; - foreach ( $data['data']['employees'] as $key => $employee ) { $data['data']['employees'][$key]['user_id'] = $employee['id']; $data['data']['employees'][$key]['estimated_time'] = $employee['duration']; } - - $request->merge($data); $mastertask = MasterTask::create($request->all()['data']); $mastertask->subtasks()->createMany($request->all()['data']['employees']); + // upload attachmentu + if ($request->file('data')) { + $attachments = Attachment::uploadAttachmentsToS3($request->file('data')['files'], $mastertask); + $mastertask->attachments()->createMany($attachments); + } + return response()->json([ 'message' => 'Master Task created successfully', 'mastertask' => $mastertask diff --git a/be/app/Http/Controllers/SubTaskController.php b/be/app/Http/Controllers/SubTaskController.php index df5e701..3d1097e 100644 --- a/be/app/Http/Controllers/SubTaskController.php +++ b/be/app/Http/Controllers/SubTaskController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use App\Models\Attachment; use App\Models\MasterTask; use App\Models\SubTask; use App\Models\Team; @@ -40,6 +41,12 @@ class SubTaskController extends Controller $mastertask = MasterTask::find($mastertask_id); $subtask = $mastertask->subtasks()->create($request->all()['data']); + // upload attachmentu + if ($request->file('data')) { + $attachments = Attachment::uploadAttachmentsToS3($request->file('data')['files'], $mastertask); + $subtask->attachments()->createMany($attachments); + } + return response()->json([ 'message' => 'Sub Task created successfully', 'subtask' => $subtask diff --git a/be/app/Http/Resources/AttachmentResource.php b/be/app/Http/Resources/AttachmentResource.php index 00ae34b..5c7ec44 100644 --- a/be/app/Http/Resources/AttachmentResource.php +++ b/be/app/Http/Resources/AttachmentResource.php @@ -18,11 +18,10 @@ class AttachmentResource extends JsonResource 'id' => $this->id, 'content_type' => $this->content_type, 'disk_name' => $this->disk_name, - 'extension' => $this->estimated_time, + 'extension' => $this->extension, 'name' => $this->original_name, 'file_size' => $this->file_size, 'path' => $this->path, - ]; } } diff --git a/be/app/Http/Resources/SubTaskResource.php b/be/app/Http/Resources/SubTaskResource.php index 62f5b8b..6f78154 100644 --- a/be/app/Http/Resources/SubTaskResource.php +++ b/be/app/Http/Resources/SubTaskResource.php @@ -20,7 +20,7 @@ class SubTaskResource extends JsonResource 'project_code' => $this->mastertask->project->code, 'master_task_id' => $this->mastertask->id, 'master_task' => $this->mastertask->title, - 'team_id' => $this->mastertask->team->id, + 'team_id' => ($this->mastertask->team) ? $this->mastertask->team->id : null, 'team' => $this->mastertask->team, 'employee_id' => $this->user->id, 'duration' => $this->estimated_time, @@ -28,6 +28,7 @@ class SubTaskResource extends JsonResource 'is_finished' => $this->is_finished, 'timeblocks' => TimeblockResource::collection($this->timeblocks), 'timesheets' => TimesheetResource::collection($this->timesheets), + 'files' => AttachmentResource::collection($this->attachments), ]; } diff --git a/be/app/Models/Attachment.php b/be/app/Models/Attachment.php index 31debad..e1c0a4a 100644 --- a/be/app/Models/Attachment.php +++ b/be/app/Models/Attachment.php @@ -4,15 +4,47 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Facades\Storage; class Attachment extends Model { use HasFactory; public $timestamps = true; + public $guarded = ['id']; public function mastertask() { return $this->belongsTo(MasterTask::class, 'master_task_id'); } + + public function subtask() + { + return $this->belongsTo(SubTask::class, 'sub_task_id'); + } + + public static function uploadAttachmentsToS3($request, $mastertask) + { + $attachmentDataArray = []; + + foreach ( $request as $file ) { + $extension = $file->getClientOriginalExtension(); + $disk_name = uniqid() . '.' . $extension; + + $path = 'jandl_taskmanager/attachments/' . $mastertask->id . '/' . $disk_name; + + Storage::disk('s3')->put($path, $file->getContent(), 'public'); + + $attachmentDataArray[] = [ + 'original_name' => $file->getClientOriginalName(), + 'disk_name' => $disk_name, + 'path' => Storage::disk('s3')->url($path), + 'extension' => $extension, + 'content_type' => $file->getMimeType(), + 'file_size' => $file->getSize(), + ]; + } + + return $attachmentDataArray; + } } diff --git a/be/app/Models/MasterTask.php b/be/app/Models/MasterTask.php index 1b496cd..5cbcb6d 100644 --- a/be/app/Models/MasterTask.php +++ b/be/app/Models/MasterTask.php @@ -37,6 +37,11 @@ class MasterTask extends Model { $users = $this->subtasks->pluck('user')->unique(); + // ak nie je uvedeny ziaden team, tak sa vratia vsetci useri + if (!$this->team){ + return $users; + } + return $users->filter(function ($user) { return !in_array($this->team->id, $user->teams->pluck('id')->unique()->toArray()); }); diff --git a/be/app/Models/SubTask.php b/be/app/Models/SubTask.php index a5d02be..fc0b9db 100644 --- a/be/app/Models/SubTask.php +++ b/be/app/Models/SubTask.php @@ -31,6 +31,11 @@ class SubTask extends Model { return $this->hasMany(Timesheet::class); } + + public function attachments() + { + return $this->hasMany(Attachment::class); + } } diff --git a/be/composer.json b/be/composer.json index 299b7e8..0645318 100644 --- a/be/composer.json +++ b/be/composer.json @@ -6,10 +6,12 @@ "license": "MIT", "require": { "php": "^8.0.2", + "doctrine/dbal": "^3.5", "guzzlehttp/guzzle": "^7.2", "laravel/framework": "^9.19", "laravel/sanctum": "^3.0", - "laravel/tinker": "^2.7" + "laravel/tinker": "^2.7", + "league/flysystem-aws-s3-v3": "^3.12" }, "require-dev": { "fakerphp/faker": "^1.9.1", diff --git a/be/composer.lock b/be/composer.lock index 476abfe..21f0fd1 100644 --- a/be/composer.lock +++ b/be/composer.lock @@ -4,8 +4,152 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ccbd816a07b206f971042295b899d1ba", + "content-hash": "a4780cc777f18d3de8e76af29ee7bfeb", "packages": [ + { + "name": "aws/aws-crt-php", + "version": "v1.0.4", + "source": { + "type": "git", + "url": "https://github.com/awslabs/aws-crt-php.git", + "reference": "f5c64ee7c5fce196e2519b3d9b7138649efe032d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/awslabs/aws-crt-php/zipball/f5c64ee7c5fce196e2519b3d9b7138649efe032d", + "reference": "f5c64ee7c5fce196e2519b3d9b7138649efe032d", + "shasum": "" + }, + "require": { + "php": ">=5.5" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35|^5.6.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "AWS SDK Common Runtime Team", + "email": "aws-sdk-common-runtime@amazon.com" + } + ], + "description": "AWS Common Runtime for PHP", + "homepage": "http://aws.amazon.com/sdkforphp", + "keywords": [ + "amazon", + "aws", + "crt", + "sdk" + ], + "support": { + "issues": "https://github.com/awslabs/aws-crt-php/issues", + "source": "https://github.com/awslabs/aws-crt-php/tree/v1.0.4" + }, + "time": "2023-01-31T23:08:25+00:00" + }, + { + "name": "aws/aws-sdk-php", + "version": "3.258.4", + "source": { + "type": "git", + "url": "https://github.com/aws/aws-sdk-php.git", + "reference": "c20d674f502ed96ed0de63e9da087eb5f0e95590" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/c20d674f502ed96ed0de63e9da087eb5f0e95590", + "reference": "c20d674f502ed96ed0de63e9da087eb5f0e95590", + "shasum": "" + }, + "require": { + "aws/aws-crt-php": "^1.0.4", + "ext-json": "*", + "ext-pcre": "*", + "ext-simplexml": "*", + "guzzlehttp/guzzle": "^6.5.8 || ^7.4.5", + "guzzlehttp/promises": "^1.4.0", + "guzzlehttp/psr7": "^1.8.5 || ^2.3", + "mtdowling/jmespath.php": "^2.6", + "php": ">=5.5" + }, + "require-dev": { + "andrewsville/php-token-reflection": "^1.4", + "aws/aws-php-sns-message-validator": "~1.0", + "behat/behat": "~3.0", + "composer/composer": "^1.10.22", + "dms/phpunit-arraysubset-asserts": "^0.4.0", + "doctrine/cache": "~1.4", + "ext-dom": "*", + "ext-openssl": "*", + "ext-pcntl": "*", + "ext-sockets": "*", + "nette/neon": "^2.3", + "paragonie/random_compat": ">= 2", + "phpunit/phpunit": "^4.8.35 || ^5.6.3 || ^9.5", + "psr/cache": "^1.0", + "psr/simple-cache": "^1.0", + "sebastian/comparator": "^1.2.3 || ^4.0", + "yoast/phpunit-polyfills": "^1.0" + }, + "suggest": { + "aws/aws-php-sns-message-validator": "To validate incoming SNS notifications", + "doctrine/cache": "To use the DoctrineCacheAdapter", + "ext-curl": "To send requests using cURL", + "ext-openssl": "Allows working with CloudFront private distributions and verifying received SNS messages", + "ext-sockets": "To use client-side monitoring" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "files": [ + "src/functions.php" + ], + "psr-4": { + "Aws\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Amazon Web Services", + "homepage": "http://aws.amazon.com" + } + ], + "description": "AWS SDK for PHP - Use Amazon Web Services in your PHP project", + "homepage": "http://aws.amazon.com/sdkforphp", + "keywords": [ + "amazon", + "aws", + "cloud", + "dynamodb", + "ec2", + "glacier", + "s3", + "sdk" + ], + "support": { + "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80", + "issues": "https://github.com/aws/aws-sdk-php/issues", + "source": "https://github.com/aws/aws-sdk-php/tree/3.258.4" + }, + "time": "2023-02-06T19:28:40+00:00" + }, { "name": "brick/math", "version": "0.10.2", @@ -137,6 +281,210 @@ }, "time": "2022-10-27T11:44:00+00:00" }, + { + "name": "doctrine/cache", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/cache.git", + "reference": "1ca8f21980e770095a31456042471a57bc4c68fb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/cache/zipball/1ca8f21980e770095a31456042471a57bc4c68fb", + "reference": "1ca8f21980e770095a31456042471a57bc4c68fb", + "shasum": "" + }, + "require": { + "php": "~7.1 || ^8.0" + }, + "conflict": { + "doctrine/common": ">2.2,<2.4" + }, + "require-dev": { + "cache/integration-tests": "dev-master", + "doctrine/coding-standard": "^9", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "psr/cache": "^1.0 || ^2.0 || ^3.0", + "symfony/cache": "^4.4 || ^5.4 || ^6", + "symfony/var-exporter": "^4.4 || ^5.4 || ^6" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongodb and others.", + "homepage": "https://www.doctrine-project.org/projects/cache.html", + "keywords": [ + "abstraction", + "apcu", + "cache", + "caching", + "couchdb", + "memcached", + "php", + "redis", + "xcache" + ], + "support": { + "issues": "https://github.com/doctrine/cache/issues", + "source": "https://github.com/doctrine/cache/tree/2.2.0" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fcache", + "type": "tidelift" + } + ], + "time": "2022-05-20T20:07:39+00:00" + }, + { + "name": "doctrine/dbal", + "version": "3.5.3", + "source": { + "type": "git", + "url": "https://github.com/doctrine/dbal.git", + "reference": "88fa7e5189fd5ec6682477044264dc0ed4e3aa1e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/88fa7e5189fd5ec6682477044264dc0ed4e3aa1e", + "reference": "88fa7e5189fd5ec6682477044264dc0ed4e3aa1e", + "shasum": "" + }, + "require": { + "composer-runtime-api": "^2", + "doctrine/cache": "^1.11|^2.0", + "doctrine/deprecations": "^0.5.3|^1", + "doctrine/event-manager": "^1|^2", + "php": "^7.4 || ^8.0", + "psr/cache": "^1|^2|^3", + "psr/log": "^1|^2|^3" + }, + "require-dev": { + "doctrine/coding-standard": "11.0.0", + "jetbrains/phpstorm-stubs": "2022.3", + "phpstan/phpstan": "1.9.4", + "phpstan/phpstan-strict-rules": "^1.4", + "phpunit/phpunit": "9.5.27", + "psalm/plugin-phpunit": "0.18.4", + "squizlabs/php_codesniffer": "3.7.1", + "symfony/cache": "^5.4|^6.0", + "symfony/console": "^4.4|^5.4|^6.0", + "vimeo/psalm": "4.30.0" + }, + "suggest": { + "symfony/console": "For helpful console commands such as SQL execution and import of files." + }, + "bin": [ + "bin/doctrine-dbal" + ], + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\DBAL\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + } + ], + "description": "Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.", + "homepage": "https://www.doctrine-project.org/projects/dbal.html", + "keywords": [ + "abstraction", + "database", + "db2", + "dbal", + "mariadb", + "mssql", + "mysql", + "oci8", + "oracle", + "pdo", + "pgsql", + "postgresql", + "queryobject", + "sasql", + "sql", + "sqlite", + "sqlserver", + "sqlsrv" + ], + "support": { + "issues": "https://github.com/doctrine/dbal/issues", + "source": "https://github.com/doctrine/dbal/tree/3.5.3" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fdbal", + "type": "tidelift" + } + ], + "time": "2023-01-12T10:21:44+00:00" + }, { "name": "doctrine/deprecations", "version": "v1.0.0", @@ -180,6 +528,97 @@ }, "time": "2022-05-02T15:47:09+00:00" }, + { + "name": "doctrine/event-manager", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/event-manager.git", + "reference": "750671534e0241a7c50ea5b43f67e23eb5c96f32" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/event-manager/zipball/750671534e0241a7c50ea5b43f67e23eb5c96f32", + "reference": "750671534e0241a7c50ea5b43f67e23eb5c96f32", + "shasum": "" + }, + "require": { + "php": "^8.1" + }, + "conflict": { + "doctrine/common": "<2.9" + }, + "require-dev": { + "doctrine/coding-standard": "^10", + "phpstan/phpstan": "^1.8.8", + "phpunit/phpunit": "^9.5", + "vimeo/psalm": "^4.28" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Common\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + }, + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com" + } + ], + "description": "The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.", + "homepage": "https://www.doctrine-project.org/projects/event-manager.html", + "keywords": [ + "event", + "event dispatcher", + "event manager", + "event system", + "events" + ], + "support": { + "issues": "https://github.com/doctrine/event-manager/issues", + "source": "https://github.com/doctrine/event-manager/tree/2.0.0" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fevent-manager", + "type": "tidelift" + } + ], + "time": "2022-10-12T20:59:15+00:00" + }, { "name": "doctrine/inflector", "version": "2.0.6", @@ -1600,6 +2039,76 @@ ], "time": "2023-01-06T16:34:48+00:00" }, + { + "name": "league/flysystem-aws-s3-v3", + "version": "3.12.2", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/flysystem-aws-s3-v3.git", + "reference": "645e14e4a80bd2da8b01e57388e7296a695a80c2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/flysystem-aws-s3-v3/zipball/645e14e4a80bd2da8b01e57388e7296a695a80c2", + "reference": "645e14e4a80bd2da8b01e57388e7296a695a80c2", + "shasum": "" + }, + "require": { + "aws/aws-sdk-php": "^3.220.0", + "league/flysystem": "^3.10.0", + "league/mime-type-detection": "^1.0.0", + "php": "^8.0.2" + }, + "conflict": { + "guzzlehttp/guzzle": "<7.0", + "guzzlehttp/ringphp": "<1.1.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "League\\Flysystem\\AwsS3V3\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Frank de Jonge", + "email": "info@frankdejonge.nl" + } + ], + "description": "AWS S3 filesystem adapter for Flysystem.", + "keywords": [ + "Flysystem", + "aws", + "file", + "files", + "filesystem", + "s3", + "storage" + ], + "support": { + "issues": "https://github.com/thephpleague/flysystem-aws-s3-v3/issues", + "source": "https://github.com/thephpleague/flysystem-aws-s3-v3/tree/3.12.2" + }, + "funding": [ + { + "url": "https://ecologi.com/frankdejonge", + "type": "custom" + }, + { + "url": "https://github.com/frankdejonge", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/league/flysystem", + "type": "tidelift" + } + ], + "time": "2023-01-17T14:15:08+00:00" + }, { "name": "league/mime-type-detection", "version": "1.11.0", @@ -1758,6 +2267,67 @@ ], "time": "2022-07-24T11:55:47+00:00" }, + { + "name": "mtdowling/jmespath.php", + "version": "2.6.1", + "source": { + "type": "git", + "url": "https://github.com/jmespath/jmespath.php.git", + "reference": "9b87907a81b87bc76d19a7fb2d61e61486ee9edb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/jmespath/jmespath.php/zipball/9b87907a81b87bc76d19a7fb2d61e61486ee9edb", + "reference": "9b87907a81b87bc76d19a7fb2d61e61486ee9edb", + "shasum": "" + }, + "require": { + "php": "^5.4 || ^7.0 || ^8.0", + "symfony/polyfill-mbstring": "^1.17" + }, + "require-dev": { + "composer/xdebug-handler": "^1.4 || ^2.0", + "phpunit/phpunit": "^4.8.36 || ^7.5.15" + }, + "bin": [ + "bin/jp.php" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.6-dev" + } + }, + "autoload": { + "files": [ + "src/JmesPath.php" + ], + "psr-4": { + "JmesPath\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Declaratively specify how to extract elements from a JSON document", + "keywords": [ + "json", + "jsonpath" + ], + "support": { + "issues": "https://github.com/jmespath/jmespath.php/issues", + "source": "https://github.com/jmespath/jmespath.php/tree/2.6.1" + }, + "time": "2021-06-14T00:11:39+00:00" + }, { "name": "nesbot/carbon", "version": "2.65.0", @@ -2224,6 +2794,55 @@ ], "time": "2022-07-30T15:51:26+00:00" }, + { + "name": "psr/cache", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/cache.git", + "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/cache/zipball/aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", + "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for caching libraries", + "keywords": [ + "cache", + "psr", + "psr-6" + ], + "support": { + "source": "https://github.com/php-fig/cache/tree/3.0.0" + }, + "time": "2021-02-03T23:26:27+00:00" + }, { "name": "psr/container", "version": "2.0.2", From ce454ffd0e5a1b7225a29d587572ba8c795d93f8 Mon Sep 17 00:00:00 2001 From: Michal Feher Date: Tue, 7 Feb 2023 12:42:22 +0100 Subject: [PATCH 13/15] no message --- ...7_083923_add_subtask_id_to_attachments.php | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 be/database/migrations/2023_02_07_083923_add_subtask_id_to_attachments.php diff --git a/be/database/migrations/2023_02_07_083923_add_subtask_id_to_attachments.php b/be/database/migrations/2023_02_07_083923_add_subtask_id_to_attachments.php new file mode 100644 index 0000000..c3e7b2f --- /dev/null +++ b/be/database/migrations/2023_02_07_083923_add_subtask_id_to_attachments.php @@ -0,0 +1,33 @@ +foreignIdFor( \App\Models\SubTask::class)->nullable()->after('master_task_id'); + $table->bigInteger( 'master_task_id')->nullable()->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('master_tasks', function (Blueprint $table) { + // + }); + } +}; From 17ed7616eebff9fef9f4106ed5d11b79758bf3bf Mon Sep 17 00:00:00 2001 From: Michal Feher Date: Wed, 8 Feb 2023 13:01:43 +0100 Subject: [PATCH 14/15] tasks endpoint update --- .../Http/Controllers/MasterTaskController.php | 60 ++++++++++-- be/app/Http/Controllers/SubTaskController.php | 91 ++++++++++++++++++- be/app/Models/SubTask.php | 31 +++++++ be/app/Models/Timeblock.php | 1 + be/app/Models/Timesheet.php | 1 + be/routes/api.php | 10 +- 6 files changed, 183 insertions(+), 11 deletions(-) diff --git a/be/app/Http/Controllers/MasterTaskController.php b/be/app/Http/Controllers/MasterTaskController.php index a454a82..7b0d16e 100644 --- a/be/app/Http/Controllers/MasterTaskController.php +++ b/be/app/Http/Controllers/MasterTaskController.php @@ -13,13 +13,6 @@ class MasterTaskController extends Controller { public function store(Request $request) { - -//// $image = base64_encode(file_get_contents($request->all()['data']['files'][0])); -// $image = base64_encode(file_get_contents($request->all()['files'])); -// -// echo $image; -// dd(file_get_contents($request->all()['files'])); - $validator = Validator::make($request->all(), [ 'data.name' => 'required', 'data.description' => 'required', @@ -60,6 +53,57 @@ class MasterTaskController extends Controller ], 201); } + public function update($id, Request $request) + { + $validator = Validator::make($request->all(), [ + 'data.name' => 'required', + 'data.description' => 'required', + 'data.duration' => 'required', + 'data.deadline' => 'required', + 'data.project_id' => 'required', + ]); + + if ($validator->fails()){ + return response()->json($validator->errors(), 400); + } + + // upratanie requestu, pretoze frontend pouziva inu nomenklaturu fieldov ako appka + $data['data'] = $request->all()['data']; + $data['data']['title'] = $request->all()['data']['name']; + $data['data']['estimated_time'] = $request->all()['data']['duration']; + + $request->merge($data); + + $mastertask = MasterTask::find($id); + + // ak je Master task v stave ukončený, nedovolime update + if ($mastertask->is_finished == 1) { + return response()->json([ + 'message' => 'Cannot update mastertask with is_finished 1.', + ], 400); + } + $mastertask->update($request->all()['data']); + + // upload attachmentu + + // TODO prerobit na upsert + if ($request->file('data')) { + $attachments = Attachment::uploadAttachmentsToS3($request->file('data')['files'], $mastertask); + $mastertask->attachments()->createMany($attachments); + } + + return response()->json([ + 'message' => 'Master Task updated successfully', + 'mastertask' => $mastertask + ]); + + + // TODO V prípade, že sa menil zodpovedný team - Pre prebiehajúce sub tasky - Ukončia sa sub tasky pôvodného teamu a tie sa následne zarátajú do ERP Karat + + // TODO V prípade, že sa menil zodpovedný team - Pre nové sub tasky (s nenatrackovaným časom) budú tieto tasky zmazané + + } + public function delete($id) { $mastertask = MasterTask::find($id); @@ -68,7 +112,7 @@ class MasterTaskController extends Controller foreach ($mastertask->subtasks as $subtask) { if ($subtask->timesheets()->exists()) { return response()->json([ - 'message' => 'Cannot delete subtask with submitted timesheets.', + 'message' => 'Cannot delete mastertask containing subtasks submitted timesheets.', ], 400); } } diff --git a/be/app/Http/Controllers/SubTaskController.php b/be/app/Http/Controllers/SubTaskController.php index 3d1097e..93a0a93 100644 --- a/be/app/Http/Controllers/SubTaskController.php +++ b/be/app/Http/Controllers/SubTaskController.php @@ -6,11 +6,56 @@ use App\Models\Attachment; use App\Models\MasterTask; use App\Models\SubTask; use App\Models\Team; +use App\Models\Timesheet; use Illuminate\Http\Request; use Illuminate\Support\Facades\Validator; class SubTaskController extends Controller { + public function index(Request $request) + { + // get query parameter from request + $parameters = $request->query(); + + $parameters['user_id'] = ( $parameters['employee_id'] ?? null ); + + $validator = Validator::make($request->all(), [ + 'start' => 'required', + 'end' => 'required', + ]); + + $validator->after(function ($validator) use ($parameters) { + + if ( !isset($parameters['employee_id']) && !isset($parameters['team_id'])) { + $validator->errors()->add( + 'error', 'You must provide either employee_id or team_id.' + ); + } + }); + + if ($validator->fails()){ + return response()->json($validator->errors(), 400); + } + + if (isset($parameters['team_id'])) { + $subtasks = SubTask::whereHas('mastertask', function ($query) use ($parameters) { + $query->where('team_id', $parameters['team_id']); + })->whereHas('timeblocks', function ($query) use ($parameters) { + $query->where('start', '>=', $parameters['start']); + $query->where('end', '<=', $parameters['end']); + })->get(); + } else if (isset($parameters['user_id'])) { + $subtasks = SubTask::where('user_id', $parameters['user_id'])->whereHas('timeblocks', function ($query) use ($parameters) { + $query->where('start', '>=', $parameters['start']); + $query->where('end', '<=', $parameters['end']); + })->get(); + } + + return response()->json([ + 'subtasks' => $subtasks + ], 200); + } + public function store($mastertask_id, Request $request) { $validator = Validator::make($request->all(), [ @@ -27,7 +72,7 @@ class SubTaskController extends Controller } }); - if($validator->fails()){ + if ($validator->fails()){ return response()->json($validator->errors(), 400); } @@ -41,6 +86,11 @@ class SubTaskController extends Controller $mastertask = MasterTask::find($mastertask_id); $subtask = $mastertask->subtasks()->create($request->all()['data']); + // syncnutie timeblocks + if (!empty($data['data']['timeblocks'])) { + $subtask->syncTimeblocks($data['data']['timeblocks']); + } + // upload attachmentu if ($request->file('data')) { $attachments = Attachment::uploadAttachmentsToS3($request->file('data')['files'], $mastertask); @@ -53,6 +103,45 @@ class SubTaskController extends Controller ], 201); } + // TODO zabezpecit, ze ked sa meni user, tak nech sa dvojmu nevlozia jeho vykazy + public function update($id, Request $request) + { + $subtask = SubTask::find($id); + + $validator = Validator::make($request->all(), [ + 'data.employee_id' => 'required', + 'data.duration' => 'required', + ]); + + if ($validator->fails()){ + return response()->json($validator->errors(), 400); + } + + // upratanie requestu, pretoze frontend pouziva inu nomenklaturu fieldov ako appka + $data['data'] = $request->all()['data']; + $data['data']['user_id'] = $request->all()['data']['employee_id']; + $data['data']['estimated_time'] = $request->all()['data']['duration']; + + $request->merge($data); + + $subtask->update($request->all()['data']); + + // syncnutie vykazu + if (!empty($data['data']['timesheets'])) { + $subtask->syncTimesheets($data['data']['timesheets']); + } + + // syncnutie timeblocks + if (!empty($data['data']['timeblocks'])) { + $subtask->syncTimeblocks($data['data']['timeblocks']); + } + + return response()->json([ + 'message' => 'Subtask updated successfully', + 'subtask' => $subtask + ]); + } + public function delete($id) { $subtask = SubTask::find($id); diff --git a/be/app/Models/SubTask.php b/be/app/Models/SubTask.php index fc0b9db..feb8d26 100644 --- a/be/app/Models/SubTask.php +++ b/be/app/Models/SubTask.php @@ -36,6 +36,37 @@ class SubTask extends Model { return $this->hasMany(Attachment::class); } + + // syncnutie vykazu. ak array obsahuje NULL id, tak ho vytvori, ak obsahuje ID, tak ho upravi. ak sa v array nenachadza, tak ho zmaze z DB + public function syncTimesheets(Array $timesheets) + { + // pripravenie array na upsert + $timesheets = array_map(function($item) { + $item['user_id'] = $item['employee_id']; + unset($item['employee_id']); + $item['sub_task_id'] = $this->id; + return $item; + }, $timesheets); + + $this->timesheets()->upsert($timesheets, ['id']); + + // zmazanie vykazov, ktore boli poslane z frontendu + $this->timesheets()->whereNotIn('id', collect($timesheets)->pluck('id'))->delete(); + } + + public function syncTimeblocks(Array $timeblocks) + { + // pripravenie array na upsert + $timeblocks = array_map(function($item) { + $item['sub_task_id'] = $this->id; + return $item; + }, $timeblocks); + + $this->timeblocks()->upsert($timeblocks, ['id']); + + // zmazanie vykazov, ktore boli poslane z frontendu + $this->timeblocks()->whereNotIn('id', collect($timeblocks)->pluck('id'))->delete(); + } } diff --git a/be/app/Models/Timeblock.php b/be/app/Models/Timeblock.php index 7390e40..8b5ca74 100644 --- a/be/app/Models/Timeblock.php +++ b/be/app/Models/Timeblock.php @@ -10,6 +10,7 @@ class Timeblock extends Model use HasFactory; public $timestamps = true; + public $guarded = ['id']; public function subtask() { diff --git a/be/app/Models/Timesheet.php b/be/app/Models/Timesheet.php index 71ae475..3838437 100644 --- a/be/app/Models/Timesheet.php +++ b/be/app/Models/Timesheet.php @@ -10,6 +10,7 @@ class Timesheet extends Model use HasFactory; public $timestamps = true; + public $guarded = ['id']; public function subtask() { diff --git a/be/routes/api.php b/be/routes/api.php index 0b47b4c..87850cd 100644 --- a/be/routes/api.php +++ b/be/routes/api.php @@ -66,6 +66,7 @@ Route::get('/v1/mastertasks/{id}', function ($id) { Route::post('/v1/mastertasks', MasterTaskController::class . '@store'); +Route::put('/v1/mastertasks/{id}', MasterTaskController::class . '@update'); Route::delete('/v1/mastertasks/{id}', MasterTaskController::class . '@delete'); Route::get('/v1/mastertasks/{id}/subtasks', function ($id) { @@ -75,12 +76,17 @@ Route::get('/v1/mastertasks/{id}/subtasks', function ($id) { }); Route::post('/v1/mastertasks/{id}/subtasks', SubTaskController::class . '@store'); - - +Route::put('/v1/subtasks/{id}', SubTaskController::class . '@update'); Route::get('/v1/subtasks/{id}', function ($id) { return new SubTaskResource( SubTask::find($id)); }); +Route::get('/v1/subtasks/{id}', function ($id) { + return new SubTaskResource( SubTask::find($id)); +}); + +Route::get('/v1/subtasks',SubTaskController::class . '@index'); + Route::delete('/v1/subtasks/{id}', SubTaskController::class . '@delete'); From 72d709cd13c3d044a49e0d23079320b9b2028440 Mon Sep 17 00:00:00 2001 From: romankko2 Date: Wed, 8 Feb 2023 18:41:07 +0100 Subject: [PATCH 15/15] [subtask, masterTask] delete requests --- app/src/plugins/app/_config/main.ts | 8 ++-- .../master-task/z-master-task-modal.vue | 45 ++++++++++++------- .../tm@modal/task/z-delete-task-modal.vue | 4 +- .../plugins/tm@modal/task/z-task-modal.vue | 16 +++---- 4 files changed, 44 insertions(+), 29 deletions(-) diff --git a/app/src/plugins/app/_config/main.ts b/app/src/plugins/app/_config/main.ts index 07945f5..dc4d824 100644 --- a/app/src/plugins/app/_config/main.ts +++ b/app/src/plugins/app/_config/main.ts @@ -54,17 +54,17 @@ const options: Options = { // 'GET v1/master-tasks/(id)': true, // 'GET v1/master-tasks': true, 'POST v1/master-tasks/(id)': true, - 'DELETE v1/master-tasks/(id)': true, - 'POST v1/master-tasks': true, + // 'DELETE v1/master-tasks/(id)': true, + // 'POST v1/master-tasks': true, - 'GET v1/overview/projects': true, + // 'GET v1/overview/projects': true, 'GET v1/overview/tasks': true, 'GET v1/overview/teams': true, 'GET v1/overview/ongoing-tasks': true, 'GET v1/overview/unscheduled-tasks': true, 'GET v1/tasks/(id)': true, - 'POST v1/tasks/(id)': true, + // 'POST v1/tasks/(id)': true, 'DELETE v1/tasks/(id)': true, // 'GET v1/teams/(id)': true, diff --git a/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue b/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue index 4c659b3..be661e1 100644 --- a/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue +++ b/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue @@ -12,19 +12,22 @@
- + > checkmark-icon pencil-icon - trash-icon + trash-icon
@@ -336,6 +339,7 @@ export default { errorUtils, v$: useVuelidate(), teams: null, + projects: null, employees: null, employeeSelect: null, teamSelect: '', @@ -348,9 +352,11 @@ export default { validations() { return { masterTask: { - project_code: { required }, + project_id: { required }, name: { required }, team: { required }, + // duration: { required }, + // description: { required }, deadline: { required }, employees: { atLeastOne } }, @@ -364,10 +370,6 @@ export default { }, methods: { - itemSelected(x) { - console.log(x) - }, - getFullNameByEmployeeId(employee_id) { let fullName = '' let initials = '' @@ -394,6 +396,7 @@ export default { try { this.teams = await this.$axios.get_auth_data('v1/teams') const employees = await this.$axios.get_auth_data('v1/employees') + this.projects = await this.$axios.get_auth_data('v1/projects') this.employees = tmUtils.enrichEmployeesByFullName(employees) if (masterTask?.id) { @@ -414,15 +417,23 @@ export default { return try { + this.masterTask.duration = 5 + this.masterTask.description = 'popis' + this.masterTask.employees = this.masterTask.employees.map(employee => { + employee.duration = 5 + return employee + }) + this.masterTask.deadline = moment(this.masterTask.deadline).format("YYYY-MM-DD HH:MM:SS") + if (this.masterTask.id) await this.$axios.put_auth(`v1/mastertasks/${this.masterTask.id}`, this.masterTask) else - await this.$axios.post_auth('v1/mastertasks', this.masterTask) + await this.$axios.post_auth_data('v1/mastertasks', this.masterTask) this.closeModal() } catch (error) { - this.$toast(error) + this.$toast.error(error) } }, @@ -435,6 +446,10 @@ export default { this.$events.emit('show-delete-master-task-modal', { masterTask }) }, + openDeleteTaskModal(task) { + this.$events.emit('show-delete-task-modal', { task }) + }, + employeeSelected(selectedOption) { const employee = this.employees.find((empl) => empl.id == selectedOption.key) this.masterTask.employees.push(employee) diff --git a/app/src/plugins/tm@modal/task/z-delete-task-modal.vue b/app/src/plugins/tm@modal/task/z-delete-task-modal.vue index 5ca82b4..dff68a2 100644 --- a/app/src/plugins/tm@modal/task/z-delete-task-modal.vue +++ b/app/src/plugins/tm@modal/task/z-delete-task-modal.vue @@ -2,7 +2,7 @@
-

Ste si istý, že chcete zmazať {{ task.title }}?

+

Ste si istý, že chcete zmazať task z masterTasku {{ task.project_code }}?

masterTask.id == value) + const selectedMasterTask = this.masterTasks.find(masterTask => masterTask.id === value) + if (selectedMasterTask) { + this.task.project_code = selectedMasterTask.project_code + } }, employeeIdSelect(value) {