-
Notifications
You must be signed in to change notification settings - Fork 22
Annotation Guideline #1390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dbrembilla
wants to merge
98
commits into
master
Choose a base branch
from
235-annotation-strategy-introduction
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Annotation Guideline #1390
Changes from 86 commits
Commits
Show all changes
98 commits
Select commit
Hold shift + click to select a range
4ddad3e
Introduce annotationStrategyTab
dbrembilla 69d1554
Introduces AnnotationStrategyController classes
dbrembilla 35c4693
Introduce annotation_strategies and annotation_strategy_labels tables
dbrembilla 3eee344
Introduce AnnotationStrategy and AnnotationStrategyLabel classes
dbrembilla 7085f7d
Introduce annotationStrategy annotationStrategyLabel resources
dbrembilla ba65e06
Introduce annotationStrategy to main.js
dbrembilla e8067e1
Adds api routes
dbrembilla 6919f86
Adds the annotationStrategyLabelImage component
dbrembilla 1efbf56
Finalize the annotationStrategycomponents
dbrembilla c1a5748
Adds methods to upload and delete reference images
dbrembilla 5db3bbb
Fix migration
dbrembilla 9031cdc
Adds configurations for annotation strategies
dbrembilla 92f9e92
Fix annotationStrategyLabel model
dbrembilla 2c47384
Fix AnnotationStrategyController
dbrembilla baeacd2
Fix AnnotationStrategy Apis
dbrembilla 0025693
Adds api routes for uploading images
dbrembilla 651ac25
Remove method
dbrembilla f0fdbd6
Fix css for annotation strategies to make them better centred
dbrembilla 9cb1775
Fix blade template for annotation strategies
dbrembilla cf80848
Fix annotation strategy tab
dbrembilla 994c6ca
Rename columns in AnnotationStrategy models, adds docstrings
dbrembilla 671bad7
Rename columns, add tests for PHP controllers
dbrembilla cf5ad6e
Fix style, rename attributes to follow columns
dbrembilla d27524f
Fix minimum description size
dbrembilla 065a30a
Fix name of attributes
dbrembilla fd35a40
Fix reload bug
dbrembilla 08c0d65
Format vue files
dbrembilla c89e608
Fix more formatting
dbrembilla 953cd02
Apply PHP fixing
dbrembilla 17781dc
Add logic when cancel editing in order to avoid cancelling progress
dbrembilla 4fd4bfc
Fix php linting
dbrembilla 564ed9e
Fix access to strategy tab
dbrembilla 5e6f489
Remove unused import
dbrembilla 0489259
Potential fix for pull request finding
dbrembilla 1308ebc
Fix consistency of permission name
dbrembilla 3037631
Fix parameter gathering from request
dbrembilla 164c738
Fix namespace
dbrembilla 690cdf3
Fix docstring
dbrembilla 487226b
Fix typo
dbrembilla 31f62fe
Fix API method in docstring
dbrembilla 4058e99
Fix typo in route
dbrembilla fe8574a
Move annotationStrategy components to a separate directory, simplify
dbrembilla 6447b85
Remove reference image column, rethink image upload system
dbrembilla 3d2074e
Fix styling
dbrembilla 1535612
Fix role as suggested by review
dbrembilla 3ec391e
Introduce disabled labels in labelTrees
dbrembilla 18b1c4a
Add custom request to store annotation strategies
dbrembilla 4a3c197
Remove reference image from docstring and tests
dbrembilla aa593dc
Align tests to the new upload rules
dbrembilla 2c68e10
Fix docstring
dbrembilla 1dddc45
Changes error management, fixes bug in displaying images and reload
dbrembilla 5a10011
Merge branch 'master' of https://github.com/biigle/core into 235-anno…
dbrembilla 7b0292f
Fix docstring
dbrembilla 4b13f3c
Change the AnnotationStrategyLabel model's id, fix route of images
dbrembilla 6fb8bda
Fix access to AnnotationStrategy tabs
dbrembilla 4e920e3
Remove now useless methods from api resource
dbrembilla ad1c532
Remove disabled labels management
dbrembilla 7b0a2a9
Fix strategy and label descriptions
dbrembilla bd5681f
Adds annotation strategy section to the manual
dbrembilla 8b6cb87
Revamp UI; use Messages to communicate errors
dbrembilla a3a1a95
Adds annotationStrategy to the other project views
dbrembilla 8c69311
Fix docstring
dbrembilla f88caa0
Apply PHP fix
dbrembilla 3285afb
Fix update of the annotation strategy
dbrembilla 96c501d
Improves placeholder of typeahead
dbrembilla 9ee4864
Fix case for images that are too small
dbrembilla b63bd0a
Implements different annotation strategy UX
dbrembilla e3bff8f
Changes the naming to annotation guideline, introduces new UI
dbrembilla 248896d
Add icon to labels within guideline
dbrembilla 5e2044a
Add delete method to annotationGuideline
dbrembilla bb6fae0
Fix label in guideline highlighting
dbrembilla d355805
Change icon for guideline
dbrembilla 930166c
Fix logic errors and syntax
dbrembilla c66a351
Introduces models for guidelines
dbrembilla 36ef330
Fix tests for AnnotationGuidelineLabel
dbrembilla da6c8e3
Apply composer fix
dbrembilla 0adf6e4
Merge pull request #1431 from biigle/annotation-strategy-option-2
dbrembilla c213601
Adds missing annotation guideline blade template without overflow
dbrembilla 2b284a2
Fix overflow annotation guideline
dbrembilla dce7876
Fix saving of annotationGuidelineLabels when saving guideline
dbrembilla 0809e03
Adapt manual to guideline
dbrembilla 74fab7b
Fix image refreshing, require description before adding a label
dbrembilla 06146d6
Fix bug in refreshCount prop
dbrembilla d00fa72
Fix syntax and remove unused methods
dbrembilla 1829a80
Remove more useless functions
dbrembilla 10c48ec
Remove useless prop and structure
dbrembilla 0e0a4fd
Implement new guideline icon and label trees filter mechanism
mzur c082c9e
Fix AnnotationGuideline tests
dbrembilla 35f2101
Fix annotation guideline storage disk; apply suggestion from review
dbrembilla e441bb1
Transform referenceImage to boolean to allow storage of information o…
dbrembilla ca32108
Apply review suggestion, fix computed property
dbrembilla 5ee50aa
Remove description requirement for guideline, fix saving, ref image
dbrembilla d1bb311
Fix filter by guideline if guideline is empty
mzur 096aaa1
Merge branch '235-annotation-strategy-introduction' into 235-annotati…
mzur 546a6df
Fix reactivity of annotation guideline labels in label trees
mzur b9ddb13
Fix label favourites with annotation guideline filtering
mzur 2246140
Fix deletion of favourite label storage with filtering
mzur cd706c6
Merge pull request #1452 from biigle/235-annotation-strategy-introduc…
mzur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| <?php | ||
|
|
||
| namespace Biigle; | ||
|
|
||
| use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
| use Illuminate\Database\Eloquent\Model; | ||
|
|
||
| /** | ||
| * This Model describes the annotation guideline of a Project | ||
| * | ||
| * @property int $id | ||
| */ | ||
| class AnnotationGuideline extends Model | ||
| { | ||
| use HasFactory; | ||
|
|
||
| /** | ||
| * The attributes that should be casted to native types. | ||
| * | ||
| * @var array<string, string> | ||
| */ | ||
| protected $casts = [ | ||
| 'id' => 'int', | ||
| 'project' => 'int', | ||
| 'description' => 'string', | ||
| ]; | ||
|
|
||
| protected $fillable = [ | ||
| 'project', | ||
| 'description', | ||
| ]; | ||
|
|
||
| /** | ||
| * Don't maintain timestamps for this model. | ||
| * | ||
| * @var bool | ||
| */ | ||
| public $timestamps = false; | ||
|
|
||
| /** | ||
| * The project this guideline belongs to. | ||
| * | ||
| * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<Project, $this> | ||
| */ | ||
| public function project() | ||
| { | ||
| return $this->belongsTo(Project::class, 'project'); | ||
| } | ||
|
|
||
| /** | ||
| * The labels within this guideline. | ||
| * | ||
| * @return \Illuminate\Database\Eloquent\Relations\HasMany<AnnotationGuidelineLabel, $this> | ||
| */ | ||
| public function guidelineLabels() | ||
| { | ||
| return $this->hasMany(AnnotationGuidelineLabel::class, 'annotation_guideline'); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| <?php | ||
|
|
||
| namespace Biigle; | ||
|
|
||
| use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
| use Illuminate\Database\Eloquent\Model; | ||
|
|
||
| /** | ||
| * Model for labels within an annotation guideline. | ||
| * | ||
| * @property int $id | ||
| */ | ||
| class AnnotationGuidelineLabel extends Model | ||
| { | ||
| use HasFactory; | ||
|
|
||
| /** | ||
| * The attributes that should be casted to native types. | ||
| * | ||
| * @var array<string, string> | ||
| */ | ||
| protected $casts = [ | ||
| 'annotation_guideline' => 'int', | ||
| 'label' => 'int', | ||
| 'shape' => 'int', | ||
| 'description' => 'string', | ||
| ]; | ||
|
|
||
| /** | ||
| * The attributes that are mass assignable. | ||
| * | ||
| * @var list<string> | ||
| */ | ||
| protected $fillable = [ | ||
| 'annotation_guideline', | ||
| 'label', | ||
| 'shape', | ||
| 'description', | ||
| ]; | ||
| /** | ||
| * Don't maintain timestamps for this model. | ||
| * | ||
| * @var bool | ||
| */ | ||
| public $timestamps = false; | ||
|
|
||
| /** | ||
| * The labels that have a guideline for their annotation | ||
| * | ||
| * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<Label, $this> | ||
| */ | ||
| public function label() | ||
| { | ||
| return $this->belongsTo(Label::class, 'label'); | ||
| } | ||
| } |
110 changes: 110 additions & 0 deletions
110
app/Http/Controllers/Api/Projects/AnnotationGuidelineController.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| <?php | ||
|
|
||
| namespace Biigle\Http\Controllers\Api\Projects; | ||
|
|
||
| use Biigle\AnnotationGuideline; | ||
| use Biigle\Http\Controllers\Api\Controller; | ||
| use Biigle\Project; | ||
| use Illuminate\Http\Request; | ||
| use Storage; | ||
|
|
||
| class AnnotationGuidelineController extends Controller | ||
| { | ||
| /** | ||
| * Get the annotation guideline for the given project and the associated labels | ||
| * | ||
| * @api {get} projects/:pid/annotation-guideline Get the annotation guideline for the given project | ||
| * @apiGroup Projects | ||
| * @apiName AnnotationGuideline | ||
| * @apiParam {Number} id The Project ID | ||
| * @apiPermission projectAdmin | ||
| * @apiDescription Returns the annotation guideline and the associated labels | ||
| * | ||
| * @apiSuccessExample {json} Success response: | ||
| * {"annotation_guideline":[{ | ||
| * "id":1, | ||
| * "project":2, | ||
| * "description":"guideline description" | ||
| * }], | ||
| * "annotation_guideline_labels" : [{ | ||
| * "annotation_guideline": 1, | ||
| * "label":4, | ||
| * "shape":7, | ||
| * "description":"description of a label", | ||
| * "label": | ||
| * { | ||
| * "id":4, | ||
| * "name":"something else", | ||
| * }, | ||
| * }]} | ||
| * | ||
| */ | ||
| public function index($id) | ||
| { | ||
| $project = Project::findOrFail($id); | ||
| $this->authorize('update', $project); | ||
| $guideline = AnnotationGuideline::where(['project'=> $id]) | ||
| ->firstOrFail(); | ||
| $guidelineLabels = $guideline | ||
| ->guidelineLabels() | ||
| ->select() | ||
| ->with('label') | ||
| ->get(); | ||
| return ['annotation_guideline' => $guideline, 'annotation_guideline_labels' => $guidelineLabels]; | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * Update the annotation guideline for the given project | ||
| * | ||
| * @api {post} projects/:pid/annotation-guideline Update the annotation guideline for the given project | ||
| * @apiGroup Projects | ||
| * @apiName AnnotationGuideline | ||
| * @apiParam {Number} id The Project ID | ||
| * @apiParam {String} description A description on how to annotate the guideline | ||
| * @apiPermission projectAdmin | ||
| * @apiDescription Edit the annotation guideline associated with the given ID | ||
| * | ||
| * @param int $id Project ID | ||
| */ | ||
| public function update(Request $request, int $id) | ||
| { | ||
| $request->validate([ | ||
| 'description' => 'required|string|min:1', | ||
| ]); | ||
|
|
||
| $project = Project::findOrFail($id); | ||
| $this->authorize('update', $project); | ||
|
|
||
| AnnotationGuideline::updateOrCreate( | ||
| ['project' => $project->id], | ||
| ['description' => $request->description] | ||
| ); | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| * Delete the annotation guideline for the given project | ||
| * | ||
| * @api {delete} projects/:pid/annotation-guideline Delete the annotation guideline for the given project | ||
| * @apiGroup Projects | ||
| * @apiName AnnotationGuideline | ||
| * @apiParam {Number} id The Project ID | ||
| * @apiPermission projectAdmin | ||
| * @apiDescription Delete the annotation guideline associated with the given ID | ||
| */ | ||
| public function delete(Request $request) | ||
| { | ||
| $project = Project::findOrFail($request->id); | ||
| $this->authorize('update', $project); | ||
| $annotationGuideline = AnnotationGuideline::where(['project'=> $project->id])->firstOrFail(); | ||
| $annotationGuideline->delete(); | ||
|
|
||
| //Cleanup the directory | ||
| $disk = Storage::disk(config('annotation_guideline.storage_disk')); | ||
| $url = "$project->id/"; | ||
| if ($disk->exists($url)) { | ||
| $disk->deleteDirectory($url); | ||
| } | ||
| } | ||
| } |
112 changes: 112 additions & 0 deletions
112
app/Http/Controllers/Api/Projects/AnnotationGuidelineLabelController.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| <?php | ||
|
|
||
| namespace Biigle\Http\Controllers\Api\Projects; | ||
|
|
||
| use Biigle\AnnotationGuideline; | ||
| use Biigle\AnnotationGuidelineLabel; | ||
| use Biigle\Http\Controllers\Api\Controller; | ||
| use Biigle\Http\Requests\StoreAnnotationGuidelineLabel; | ||
| use Biigle\Label; | ||
| use Biigle\Project; | ||
| use Illuminate\Http\Request; | ||
| use Storage; | ||
|
|
||
| class AnnotationGuidelineLabelController extends Controller | ||
| { | ||
| /** | ||
| * Update the label within an annotation guideline. | ||
| * @api {post} projects/:id/annotation-guideline-label Update the guideline for labels within an annotation guideline | ||
| * @apiGroup Projects | ||
| * @apiName UpdateAnnotationGuidelineLabels | ||
| * @apiPermission projectAdmin | ||
| * | ||
| * @apiParam {Integer} id THe ID of the project for the annotation guideline for the labels | ||
| * @apiParam {Integer} label The ID for the label for the annotation guideline | ||
| * @apiParam {Integer} shape The IDs for the shapes for the annotation guideline | ||
| * @apiParam {String} description The IDs for the shapes for the annotation guideline | ||
| * @apiParam {File} reference_image The reference image for the desired label | ||
| * | ||
| */ | ||
| public function update(StoreAnnotationGuidelineLabel $request) | ||
| { | ||
|
|
||
| $projectId = $request->project->id; | ||
| $annotationGuideline = AnnotationGuideline::where(['project' => $projectId])->firstOrFail(); | ||
| $validated = $request->validated(); | ||
|
|
||
| $label = $validated['label']; | ||
| $shape = $validated['shape']; | ||
| $description = $validated['description']; | ||
| $referenceImage = $validated['reference_image']; | ||
|
|
||
| $disk = Storage::disk(config('annotation_guideline.storage_disk')); | ||
|
|
||
| if ($referenceImage != null) { | ||
| $disk->putFileAs("$projectId", $referenceImage, "$label.jpg"); | ||
| } | ||
| AnnotationGuidelineLabel::updateOrCreate( | ||
| [ | ||
| 'annotation_guideline' => $annotationGuideline->id, | ||
| 'label' => $label, | ||
| ], | ||
| [ | ||
| 'shape' => $shape, | ||
| 'description' => $description, | ||
| ] | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Delete a label from a guideline. | ||
| * | ||
| * @api {delete} projects/:id/annotation-guideline-labels/delete-image Delete a reference image | ||
| * @apiGroup Projects | ||
| * @apiName DeleteReferenceImage | ||
| * @apiPermission projectAdmin | ||
| * | ||
| * @apiParam {Integer} id The ID of the project for the annotation guideline for the labels | ||
| * | ||
| */ | ||
| public function delete(Request $request) | ||
| { | ||
| $project = Project::findOrFail($request->id); | ||
| $label = Label::findOrFail($request->label); | ||
| $annotationGuideline = AnnotationGuideline::where(['project' => $project->id])->firstOrFail(); | ||
| $annotationGuidelineLabel = $annotationGuideline->guidelineLabels()->where(['label' => $label->id])->firstOrFail(); | ||
|
|
||
| $this->authorize('update', $project); | ||
|
|
||
| $annotationGuidelineLabel->delete(); | ||
|
|
||
| $disk = Storage::disk(config('annotation_guideline.storage_disk')); | ||
| $url = "$project->id/$label->id.jpg"; | ||
| if ($disk->exists($url)) { | ||
| $disk->delete($url); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Delete a reference image. | ||
| * | ||
| * @api {delete} projects/:id/annotation-guideline-labels/delete-image Delete a reference image | ||
| * @apiGroup Projects | ||
| * @apiName DeleteReferenceImage | ||
| * @apiPermission projectAdmin | ||
| * | ||
| * @apiParam {Integer} id The ID of the project for the annotation guideline for the labels | ||
| * | ||
| */ | ||
| public function deleteReferenceImage(Request $request) | ||
| { | ||
| $project = Project::findOrFail($request->id); | ||
| $label = Label::findOrFail($request->label); | ||
|
|
||
| $this->authorize('update', $project); | ||
|
|
||
| $disk = Storage::disk(config('annotation_guideline.storage_disk')); | ||
| $url = "$project->id/$label->id.jpg"; | ||
| if ($disk->exists($url)) { | ||
| $disk->delete($url); | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.