diff --git a/appinfo/info.xml b/appinfo/info.xml index e36e28f..df0326a 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -35,7 +35,7 @@ Mit dem integrierten Dashboard lässt sich anhand eines Kuchen-/Donut-Diagramms Diese App wird aktuell noch weiterentwickelt, also: Augen offen halten für neue Features! Und falls Dir irgendwelche Verbesserungsvorschläge, Probleme oder neue Features einfallen, schau mal auf unserem [GitHub Projekt](https://github.com/mtierltd/timetracker) vorbei, vielleicht wird Dein Thema bereits diskutiert! Und falls nicht, starte gerne eine neue Diskussion, wir freuen uns auf Dein Feedback! - 0.0.74 + 0.0.75 agpl MTier Ltd. TimeTracker diff --git a/js/src/timer.js b/js/src/timer.js index d4c3ffe..4391477 100644 --- a/js/src/timer.js +++ b/js/src/timer.js @@ -25,6 +25,10 @@ function() { $( function() { + $('#work-input-form').on('submit', function(e) { + e.preventDefault(); + createWorkItem(); + }); var days='30'; var start = moment().startOf('day').subtract(29, 'days'); var end = moment().endOf('day'); @@ -382,9 +386,7 @@ function() { }) $('.wi-play').click(function(e) { e.preventDefault(); - $('#work-input').val($(this).data('work-name')); - startTimer($(this).data('projectid'), $(this).data('tagids')); - return false; + createWorkItem(); }) $('.wi-trash').click(function(e) { $("#dialog-confirm").dialog({ @@ -577,6 +579,12 @@ function() { }); } + function createWorkItem() { + $('#work-input').val($(this).data('work-name')); + startTimer($(this).data('projectid'), $(this).data('tagids')); + return false; + } + function startTimer(projectId = null, tags = ""){ if(localStorage.getItem('isTimerStarted') === 'true'){ stopTimer(startTimer, [projectId, tags]); diff --git a/lib/Controller/AjaxController.php b/lib/Controller/AjaxController.php index f89bac5..96e12d2 100644 --- a/lib/Controller/AjaxController.php +++ b/lib/Controller/AjaxController.php @@ -152,10 +152,14 @@ public function index() { } + /** + * @NoAdminRequired + */ public function addCost($id) { $wi = $this->workIntervalMapper->find($id); $cost = $this->request->cost; + $cost = str_replace(',', '.', $cost); if (!is_numeric($cost)) { return new JSONResponse(['error' => 'Non numeric value'], Http::STATUS_BAD_REQUEST); @@ -481,6 +485,8 @@ public function addWorkInterval() { $this->workIntervalMapper->insert($wi); + $running = $this->workIntervalMapper->findAllRunning($this->userId); + return new JSONResponse(["WorkIntervals" => json_decode(json_encode($running), true)]); } @@ -561,12 +567,16 @@ public function deleteClient($id) { * @NoCSRFRequired */ public function getClients(){ - $clients = $this->clientMapper->findAll($this->userId); - return new JSONResponse(["Clients" => json_decode(json_encode($clients), true)]); - } - + $clientName = $this->request->term ?? null; + if ($clientName) { + $clients = $this->clientMapper->searchByName($this->userId, $clientName); + } else { + $clients = $this->clientMapper->findAll($this->userId); + } + return new JSONResponse(["Clients" => json_decode(json_encode($clients), true)]); + } /** * diff --git a/lib/Db/ClientMapper.php b/lib/Db/ClientMapper.php index 77e6f11..550c5cf 100644 --- a/lib/Db/ClientMapper.php +++ b/lib/Db/ClientMapper.php @@ -16,14 +16,14 @@ public function __construct(IDBConnection $db) { public function findByName($name) { $sql = 'SELECT * FROM `*PREFIX*timetracker_client` ' . 'WHERE upper(`name`) = ?'; - + try { $e = $this->findEntity($sql, [strtoupper($name)]); return $e; } catch (\OCP\AppFramework\Db\DoesNotExistException $e){ return null; } - + } /** @@ -36,11 +36,14 @@ public function find($id) { return $this->findEntity($sql, [$id]); } - public function findAll($user){ $sql = 'SELECT tc.* FROM `*PREFIX*timetracker_client` tc left join `*PREFIX*timetracker_user_to_client` uc on uc.client_id = tc.id where uc.user_uid = ? order by tc.name asc'; return $this->findEntities($sql, [$user]); } - -} \ No newline at end of file + public function searchByName($user, $name){ + $name = strtoupper($name); + $sql = 'SELECT tc.* FROM `*PREFIX*timetracker_client` tc left join `*PREFIX*timetracker_user_to_client` uc on uc.client_id = tc.id where uc.user_uid = ? and upper(tc.name) LIKE ? order by tc.name asc'; + return $this->findEntities($sql, [$user, "%" . $name . "%"]); + } +} diff --git a/lib/Db/ProjectMapper.php b/lib/Db/ProjectMapper.php index 7176979..f6db52e 100644 --- a/lib/Db/ProjectMapper.php +++ b/lib/Db/ProjectMapper.php @@ -30,7 +30,8 @@ public function searchByName($user, string $name) { $name = strtoupper($name); $sql = 'SELECT tp.* FROM `*PREFIX*timetracker_project` tp LEFT JOIN `*PREFIX*timetracker_user_to_project` up ON up.project_id = tp.id WHERE up.`user_uid` = ? AND upper(tp.`name`) LIKE ? ORDER BY tp.`name`'; - return $this->findEntities($sql, [$user, $name ."%"]); + return $this->findEntities($sql, [$user,"%" . $name ."%"]); + } /** @@ -75,8 +76,4 @@ public function delete($project_id) { } } - - - - } diff --git a/lib/Migration/Version000020Date20220528101009.php b/lib/Migration/Version000020Date20220528101009.php index 1f4bcc5..6e2c6bf 100644 --- a/lib/Migration/Version000020Date20220528101009.php +++ b/lib/Migration/Version000020Date20220528101009.php @@ -3,9 +3,9 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2022 Your name + * @copyright Copyright (c) 2022 Harm Akkerman * - * @author Your name + * @author Harm Akkerman * * @license GNU AGPL version 3 or any later version * diff --git a/templates/content/index.php b/templates/content/index.php index bf1655e..d3ba8e6 100644 --- a/templates/content/index.php +++ b/templates/content/index.php @@ -1,7 +1,7 @@ - + @@ -66,4 +66,4 @@ - \ No newline at end of file +