-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#4205 - Ability to refresh document to load pending suggestions
- Add a action bar button to refresh the document in case there are recommenders - Wiggle the button a bit if there are pending suggestions
- Loading branch information
Showing
9 changed files
with
273 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
65 changes: 65 additions & 0 deletions
65
.../de/tudarmstadt/ukp/inception/recommendation/actionbar/RecommenderActionBarExtension.java
This file contains 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,65 @@ | ||
/* | ||
* Licensed to the Technische Universität Darmstadt under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The Technische Universität Darmstadt | ||
* licenses this file to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package de.tudarmstadt.ukp.inception.recommendation.actionbar; | ||
|
||
import org.apache.wicket.markup.html.panel.Panel; | ||
import org.springframework.core.annotation.Order; | ||
|
||
import de.tudarmstadt.ukp.clarin.webanno.api.annotation.actionbar.ActionBarExtension; | ||
import de.tudarmstadt.ukp.clarin.webanno.api.annotation.page.AnnotationPageBase; | ||
import de.tudarmstadt.ukp.clarin.webanno.ui.annotation.AnnotationPage; | ||
import de.tudarmstadt.ukp.inception.recommendation.api.RecommendationService; | ||
import de.tudarmstadt.ukp.inception.recommendation.config.RecommenderServiceAutoConfiguration; | ||
import de.tudarmstadt.ukp.inception.rendering.editorstate.AnnotatorState; | ||
|
||
/** | ||
* <p> | ||
* This class is exposed as a Spring Component via | ||
* {@link RecommenderServiceAutoConfiguration#recommenderActionBarExtension}. | ||
* </p> | ||
*/ | ||
@Order(2000) | ||
public class RecommenderActionBarExtension | ||
implements ActionBarExtension | ||
{ | ||
private final RecommendationService recommendationService; | ||
|
||
public RecommenderActionBarExtension(RecommendationService aRecommendationService) | ||
{ | ||
recommendationService = aRecommendationService; | ||
} | ||
|
||
@Override | ||
public boolean accepts(AnnotationPageBase aPage) | ||
{ | ||
if (!(aPage instanceof AnnotationPage)) { | ||
return false; | ||
} | ||
|
||
return aPage.getModel() // | ||
.map(AnnotatorState::getProject) // | ||
.map(recommendationService::existsEnabledRecommender) // | ||
.orElse(false).getObject(); | ||
} | ||
|
||
@Override | ||
public Panel createActionBarItem(String aId, AnnotationPageBase aPage) | ||
{ | ||
return new RecommenderActionBarPanel(aId, aPage); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...java/de/tudarmstadt/ukp/inception/recommendation/actionbar/RecommenderActionBarPanel.html
This file contains 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,54 @@ | ||
<!DOCTYPE html> | ||
<!-- | ||
Licensed to the Technische Universität Darmstadt under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The Technische Universität Darmstadt | ||
licenses this file to you under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<html xmlns:wicket="http://wicket.apache.org"> | ||
<wicket:head> | ||
<style> | ||
.state-predictions-available .btn-refresh-document>* { | ||
animation: btn-refresh-document-attention 6s linear infinite; | ||
} | ||
|
||
@keyframes btn-refresh-document-attention { | ||
0%, 15%, 100% { | ||
transform: rotate(0deg); | ||
} | ||
|
||
5% { | ||
transform: rotate(-20deg); | ||
animation-timing-function: ease-in; | ||
} | ||
|
||
10% { | ||
transform: rotate(20deg); | ||
animation-timing-function: ease-in; | ||
} | ||
} | ||
</style> | ||
</wicket:head> | ||
<wicket:panel> | ||
<div class="action-bar-group"> | ||
<div class="btn-group"> | ||
<button wicket:id="refreshDocument" class="btn btn-action-bar btn-refresh-document" type="button" | ||
wicket:message="title:refreshDocument"> | ||
<i class="fas fa-sync"></i> | ||
</button> | ||
</div> | ||
</div> | ||
</wicket:panel> | ||
|
||
</html> |
57 changes: 57 additions & 0 deletions
57
...java/de/tudarmstadt/ukp/inception/recommendation/actionbar/RecommenderActionBarPanel.java
This file contains 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,57 @@ | ||
/* | ||
* Licensed to the Technische Universität Darmstadt under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The Technische Universität Darmstadt | ||
* licenses this file to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package de.tudarmstadt.ukp.inception.recommendation.actionbar; | ||
|
||
import java.lang.invoke.MethodHandles; | ||
|
||
import org.apache.wicket.ajax.AjaxRequestTarget; | ||
import org.apache.wicket.markup.html.panel.Panel; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import de.tudarmstadt.ukp.clarin.webanno.api.annotation.page.AnnotationPageBase; | ||
import de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaAjaxLink; | ||
|
||
public class RecommenderActionBarPanel | ||
extends Panel | ||
{ | ||
private static final long serialVersionUID = -2999081548651637508L; | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); | ||
|
||
public static final String STATE_PREDICTIONS_AVAILABLE = "state-predictions-available"; | ||
|
||
private final LambdaAjaxLink refreshDocumentButton; | ||
|
||
private final AnnotationPageBase page; | ||
|
||
public RecommenderActionBarPanel(String aId, AnnotationPageBase aPage) | ||
{ | ||
super(aId); | ||
|
||
page = aPage; | ||
|
||
refreshDocumentButton = new LambdaAjaxLink("refreshDocument", this::actionRefreshDocument); | ||
add(refreshDocumentButton); | ||
} | ||
|
||
private void actionRefreshDocument(AjaxRequestTarget aTarget) | ||
{ | ||
page.actionRefreshDocument(aTarget); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...e/tudarmstadt/ukp/inception/recommendation/actionbar/RecommenderActionBarPanel.properties
This file contains 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,17 @@ | ||
# Licensed to the Technische Universität Darmstadt under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The Technische Universität Darmstadt | ||
# licenses this file to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
refreshDocument=Refresh document |
This file contains 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
This file contains 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
This file contains 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
This file contains 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