Skip to content
This repository has been archived by the owner on Jun 22, 2022. It is now read-only.

Commit

Permalink
Merge pull request #300 from InfyOmLabs/develop
Browse files Browse the repository at this point in the history
Release v1.8.1-alpha
  • Loading branch information
mitulgolakiya authored Aug 31, 2019
2 parents a4c961e + a484cf5 commit 52c7f08
Show file tree
Hide file tree
Showing 71 changed files with 1,216 additions and 619 deletions.
19 changes: 18 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
language: php

php:
- '7.2'

sudo: false

cache:
directories:
- $HOME/.composer/cache/files
install: travis_retry composer install --no-interaction --prefer-dist
- $HOME/.npm
- node_modules

before_install:
- nvm install 'lts/*'
- npm i -g npm

install:
- travis_retry composer install --no-interaction --prefer-dist
- npm install --no-audit --no-progress --quiet
- npm run production

script: vendor/bin/phpunit --verbose

notifications:
slack:
rooms:
Expand Down
10 changes: 8 additions & 2 deletions app/Events/StartTimer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@
class StartTimer implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $timerData;

/**
* Create a new event instance.
*
* @return void
*/
public function __construct()
public function __construct($timerData = [])
{
//
$this->timerData = $timerData;
}

/**
Expand All @@ -31,4 +32,9 @@ public function broadcastOn()
{
return new PrivateChannel('stopwatch-event.'.getLoggedInUserId());
}

public function broadcastWith()
{
return $this->timerData;
}
}
4 changes: 2 additions & 2 deletions app/Http/Controllers/TimeEntryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ public function getTasks($projectId, Request $request)
/**
* @return \Illuminate\Http\JsonResponse
*/
public function getStartTimer()
public function getStartTimer(Request $request)
{
$this->timeEntryRepository->broadcastStartTimerEvent();
$this->timeEntryRepository->broadcastStartTimerEvent($request->all());

return $this->sendSuccess('Start timer broadcasted successfully.');
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/CreateProjectRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function authorize()
public function rules()
{
$rules = Project::$rules;
$rules['prefix'] = 'required|alpha_num|max:4|min:2|unique:projects,prefix';
$rules['prefix'] = 'required|alpha_num|max:6|min:2|unique:projects,prefix';

return $rules;
}
Expand Down
10 changes: 6 additions & 4 deletions app/Http/Requests/UpdateUserProfileRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ public function rules()
{
$id = Auth::user()->id;
$rules = [
'name' => 'required|unique:users,name,'.$id,
'email' => 'required|email|unique:users,email,'.$id.'|regex:/^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/',
'phone' => 'nullable|numeric|digits:10',
'photo' => 'mimes:jpeg,jpg,png',
'name' => 'required|unique:users,name,'.$id,
'email' => 'required|email|unique:users,email,'.$id.'|regex:/^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/',
'phone' => 'nullable|numeric|digits:10',
'photo' => 'mimes:jpeg,jpg,png',
'password' => 'nullable|min:6|required_with:password_confirmation|same:password_confirmation',
'password_confirmation' => 'nullable|min:6',
];

return $rules;
Expand Down
2 changes: 1 addition & 1 deletion app/Models/ActivityType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Models;

use Eloquent as Model;
use Illuminate\Database\Eloquent\Model;

/**
* App\Models\ActivityType.
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Models;

use Eloquent as Model;
use Illuminate\Database\Eloquent\Model;

/**
* App\Models\Client.
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Models;

use Eloquent as Model;
use Illuminate\Database\Eloquent\Model;

/**
* App\Models\Project.
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Models;

use Carbon\Carbon;
use Eloquent as Model;
use Illuminate\Database\Eloquent\Model;

/**
* App\Models\Report.
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Models;

use Eloquent as Model;
use Illuminate\Database\Eloquent\Model;

/**
* App\Models\Tag.
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace App\Models;

use Carbon\Carbon;
use Eloquent as Model;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
Expand Down
12 changes: 11 additions & 1 deletion app/Models/TimeEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace App\Models;

use Eloquent as Model;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
Expand Down Expand Up @@ -59,6 +59,7 @@ class TimeEntry extends Model
use SoftDeletes;

public $table = 'time_entries';
public $appends = ['entry_type_string'];

const STOPWATCH = 1;
const VIA_FORM = 2;
Expand Down Expand Up @@ -149,4 +150,13 @@ public function scopeOfCurrentUser(Builder $query)
{
return $query->ofUser(getLoggedInUserId());
}

public function getEntryTypeStringAttribute()
{
if ($this->entry_type == self::STOPWATCH) {
return 'Stopwatch';
}

return 'Via Form';
}
}
7 changes: 5 additions & 2 deletions app/Queries/TaskDataTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace App\Queries;

use App\Models\Task;
use App\Repositories\ProjectRepository;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Auth;

/**
* Class TaskDataTable.
Expand All @@ -18,7 +18,10 @@ class TaskDataTable
*/
public function get($input = [])
{
$loginUserProjects = Auth::user()->projects()->get()->pluck('name', 'id')->toArray();
/** @var ProjectRepository $projectRepo */
$projectRepo = app(ProjectRepository::class);
$loginUserProjects = $projectRepo->getLoginUserAssignProjectsArr();

$query = Task::whereIn('project_id', array_keys($loginUserProjects))
->leftJoin('projects as p', 'p.id', '=', 'tasks.project_id')
->with(['project', 'taskAssignee', 'createdUser'])
Expand Down
11 changes: 5 additions & 6 deletions app/Queries/TimeEntryDataTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ class TimeEntryDataTable
public function get($input)
{
/** @var TimeEntry $query */
$query = TimeEntry::with(['task.project', 'user', 'activityType'])
->select('time_entries.*', \DB::raw("IF(IFNULL(entry_type,1)=1,'Stopwatch','Via Form') as entry_type_string"));
$query = TimeEntry::with(['task.project', 'user', 'activityType'])->select('time_entries.*');

/** @var User $user */
$user = Auth::user();
Expand All @@ -33,11 +32,11 @@ function (Builder $q) use ($input) {
});
$query->when(isset($input['filter_project']) && !empty($input['filter_project']),
function (Builder $q) use ($input) {
$filterUserId = (isset($input['filter_user']) && !empty($input['filter_user'])) ? $input['filter_user'] : getLoggedInUser()->id;
$taskIds = Task::whereProjectId($input['filter_project'])
->where('status', '=', Task::STATUS_ACTIVE)
->where(function ($q) {
$q->whereHas('taskAssignee', function ($q) {
$q->where('user_id', getLoggedInUser()->id);
->where(function ($q) use ($filterUserId) {
$q->whereHas('taskAssignee', function ($q) use ($filterUserId) {
$q->where('user_id', $filterUserId);
});
})->get()->pluck('id')->toArray();
$q->whereIn('task_id', $taskIds);
Expand Down
6 changes: 6 additions & 0 deletions app/Repositories/ProjectRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ public function model()
*/
public function getLoginUserAssignProjectsArr()
{
$loggedInUser = getLoggedInUser();

if ($loggedInUser->can('manage_projects')) {
return $this->getProjectsList()->toArray();
}

return Auth::user()->projects()->orderBy('name')->get()->pluck('name', 'id')->toArray();
}

Expand Down
4 changes: 2 additions & 2 deletions app/Repositories/ReportRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ public function updateReportFilter($input, $report)

$clientId = $this->getClientId($report->id);
if ($input['client_id'] != 0) {
if ($input['client_id'] !== $clientId) {
if ($input['client_id'] != $clientId) {
$result[] = $this->createFilter($report->id, $input['client_id'], Client::class);
}
}

if (!empty($clientId) && $input['client_id'] !== $clientId) {
if (!empty($clientId) && $input['client_id'] != $clientId) {
ReportFilter::ofParamType(Client::class)->whereParamId($clientId)->delete();
}

Expand Down
16 changes: 9 additions & 7 deletions app/Repositories/TaskRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use DB;
use Exception;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Symfony\Component\HttpFoundation\File\Exception\UploadException;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;

Expand Down Expand Up @@ -66,7 +67,7 @@ public function find($id, $columns = ['*'])
/**
* @param array $input
*
* @return Task|\Illuminate\Database\Eloquent\Model
* @return Task
*/
public function store($input)
{
Expand Down Expand Up @@ -261,15 +262,16 @@ public function attachTags($task, $tags)
}

/**
* @param int $id
* @param int $id
* @param array $input
*
* @return Task
*/
public function getTaskDetails($id, $input = [])
{
if (isset($input['user_id']) && $input['user_id'] > 0) {
$task = Task::with([
'timeEntries' => function ($query) use ($input) {
'timeEntries' => function (HasMany $query) use ($input) {
$query->where('time_entries.user_id', '=', $input['user_id'])
->with('user');
},
Expand All @@ -284,6 +286,7 @@ public function getTaskDetails($id, $input = [])
$totalDuration = sprintf('%02d Hours and %02d Minutes', floor($minutes / 60), $minutes % 60);
}
$task->totalDuration = $totalDuration;
$task->totalDurationMin = $minutes;

return $task;
}
Expand Down Expand Up @@ -349,10 +352,10 @@ public function uploadFile($id, $file)
$destinationPath = public_path(Task::PATH);
$task = $this->findOrFail($id);

try {
$fileName = TaskAttachment::makeAttachment($file, TaskAttachment::PATH);
$attachment = new TaskAttachment(['task_id' => $task->id, 'file' => $fileName]);
$fileName = TaskAttachment::makeAttachment($file, TaskAttachment::PATH);
$attachment = new TaskAttachment(['task_id' => $task->id, 'file' => $fileName]);

try {
DB::beginTransaction();
$task->attachments()->save($attachment);
DB::commit();
Expand Down Expand Up @@ -424,7 +427,6 @@ public function getAttachments($id)
public function addComment($input)
{
$input['created_by'] = Auth::id();
$input['comment'] = $input['comment'];
$comment = Comment::create($input);

return Comment::with('createdUser')->findOrFail($comment->id);
Expand Down
4 changes: 2 additions & 2 deletions app/Repositories/TimeEntryRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ public function checkDuplicateEntry($input, $id = null)
}
}

public function broadcastStartTimerEvent()
public function broadcastStartTimerEvent($input)
{
broadcast(new StartTimer())->toOthers();
broadcast(new StartTimer($input))->toOthers();
}

public function broadcastStopTimerEvent()
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "infyomlabs/infy-tracker",
"type": "project",
"version": "1.8.0-alpha",
"version": "1.8.1-alpha",
"description": "Create Projects / Tasks, Track Time, Show Daily Reports",
"keywords": [
"time",
Expand Down
1 change: 1 addition & 0 deletions database/factories/TaskFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
'description' => $faker->text,
'project_id' => $project->id,
'due_date' => $faker->dateTime,
'status' => Task::STATUS_ALL,
'task_number' => $faker->unique()->randomDigitNotNull,
];
});
Expand Down
8 changes: 4 additions & 4 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>

<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>

<testsuite name="Integration">
<directory suffix="Test.php">./tests/Integration</directory>
</testsuite>
Expand All @@ -24,10 +28,6 @@
<testsuite name="Controllers">
<directory suffix="Test.php">./tests/Controllers</directory>
</testsuite>

<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
Expand Down
2 changes: 0 additions & 2 deletions resources/assets/js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,5 +165,3 @@ window.displaySuccessMessage = function (message) {
position: 'top-right',
});
};
//modal not closed on click outside
$('.modal').modal({show: false, backdrop: 'static'});
Loading

0 comments on commit 52c7f08

Please sign in to comment.