Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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!
</description>
<version>0.0.74</version>
<version>0.0.75</version>
<licence>agpl</licence>
<author mail="[email protected]" >MTier Ltd.</author>
<namespace>TimeTracker</namespace>
Expand Down
14 changes: 11 additions & 3 deletions js/src/timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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]);
Expand Down
18 changes: 14 additions & 4 deletions lib/Controller/AjaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)]);
}

Expand Down Expand Up @@ -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)]);
}

/**
*
Expand Down
13 changes: 8 additions & 5 deletions lib/Db/ClientMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}

/**
Expand All @@ -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]);
}


}
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 . "%"]);
}
}
7 changes: 2 additions & 5 deletions lib/Db/ProjectMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ."%"]);

}

/**
Expand Down Expand Up @@ -75,8 +76,4 @@ public function delete($project_id) {
}

}




}
4 changes: 2 additions & 2 deletions lib/Migration/Version000020Date20220528101009.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

/**
* @copyright Copyright (c) 2022 Your name <your@email.com>
* @copyright Copyright (c) 2022 Harm Akkerman <harmakkerman94@gmail.com>
*
* @author Your name <your@email.com>
* @author Harm Akkerman <harmakkerman94@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
Expand Down
4 changes: 2 additions & 2 deletions templates/content/index.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div id="timetracker-content">
<div id="top-work-bar">
<div id="work-input-container">
<form>
<form id="work-input-form">
<input tabindex="1" type="text" spellcheck="false" autocomplete="off" class="" value="" placeholder="What have you done?" id="work-input">
</form>
</div>
Expand Down Expand Up @@ -66,4 +66,4 @@
<div class="clearfix"> </div>
<div id="work-intervals">
</div>
</div>
</div>