summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorYoung Gyu Park <younggyu@google.com>2017-12-21 14:04:46 +0900
committerKeun Soo Yim <yim@google.com>2017-12-22 01:22:02 +0000
commit32abd6d9efcddb302f8ccde1412a305068bae3a3 (patch)
treedf35a2c4ccc115d0ea5a8f6e2b8d4386449d138b /src/main
parent50639a71c5bd6b66c932a0b28013de7c240684ab (diff)
downloaddashboard-32abd6d9efcddb302f8ccde1412a305068bae3a3.tar.gz
Implementation of javascript logic for favorite mark's registering and
removing. The logic is developed by fully utilizing the existing code in order not to break the consistency Test: Tested with web browser (https://android-vts-staging.googleplex.com/?showAll=true) Bug: 70914765 Change-Id: I91dbb3556c38f824616ef3baf58e9fe0e60b9dc2
Diffstat (limited to 'src/main')
-rw-r--r--src/main/webapp/WEB-INF/jsp/dashboard_main.jsp82
1 files changed, 71 insertions, 11 deletions
diff --git a/src/main/webapp/WEB-INF/jsp/dashboard_main.jsp b/src/main/webapp/WEB-INF/jsp/dashboard_main.jsp
index 0552f8f..45e9cd6 100644
--- a/src/main/webapp/WEB-INF/jsp/dashboard_main.jsp
+++ b/src/main/webapp/WEB-INF/jsp/dashboard_main.jsp
@@ -133,6 +133,44 @@
});
}
+ var addFavoriteButton = function() {
+ var self = $(this);
+ var test = self.attr('test');
+
+ $.post('/api/favorites', { testName: test}).then(function(data) {
+ if (data.key) {
+ subscriptionMap[test] = data.key;
+
+ self.children().text("star");
+ self.switchClass("add-fav-button", "min-fav-button", 0);
+
+ self.off('click', addFavoriteButton);
+ self.on('click', removeFavoriteButton);
+ }
+ })
+ .fail(function() {
+ alert( "Error occurred on registering your favorite test case!" );
+ });
+ }
+
+ var removeFavoriteButton = function() {
+ var self = $(this);
+ var test = self.attr('test');
+
+ $.ajax({
+ url: '/api/favorites/' + subscriptionMap[test],
+ type: 'DELETE'
+ }).then(function() {
+ delete subscriptionMap[test];
+
+ self.children().text("star_border");
+ self.switchClass("min-fav-button", "add-fav-button", 0);
+
+ self.off('click', removeFavoriteButton);
+ self.on('click', addFavoriteButton);
+ });
+ }
+
$.widget('custom.sizedAutocomplete', $.ui.autocomplete, {
_resizeMenu: function() {
this.menu.element.outerWidth($('#input-box').width());
@@ -157,6 +195,10 @@
$('.notification-button').click(toggleNotifications);
$('#add-button').click(addFavorite);
+ $('.add-fav-button').click(addFavoriteButton);
+
+ $('.min-fav-button').click(removeFavoriteButton);
+
$('#favoritesLink').click(function() {
window.open('/', '_self');
});
@@ -187,7 +229,7 @@
</ul>
</div>
</div>
- <c:set var='width' value='${showAll ? 12 : 11}' />
+ <c:set var='width' value='${showAll ? 11 : 11}' />
<c:if test='${not showAll}'>
<div class='row'>
<div class='input-field col s8'>
@@ -214,16 +256,34 @@
</span>
</div>
</a>
- <c:if test='${not showAll}'>
- <div class='col s1 center btn-container'>
- <a class='col s6 btn-flat notification-button ${test.muteNotifications ? "inactive" : "active"}' test='${test.name}' title='${test.muteNotifications ? "Enable" : "Disable"} notifications'>
- <i class='material-icons'>notifications_${test.muteNotifications ? "off" : "active"}</i>
- </a>
- <a class='col s6 btn-flat remove-button' test='${test.name}' title='Remove favorite'>
- <i class='material-icons'>clear</i>
- </a>
- </div>
- </c:if>
+ <c:choose>
+ <c:when test="${showAll}">
+ <div class="col s1 center btn-container">
+ <c:choose>
+ <c:when test="${test.isFavorite}">
+ <a class="col s6 btn-flat min-fav-button" test="${test.name}" title="Remove favorite">
+ <i class="material-icons">star</i>
+ </a>
+ </c:when>
+ <c:otherwise>
+ <a class="col s6 btn-flat add-fav-button" test="${test.name}" title="Add favorite">
+ <i class="material-icons">star_border</i>
+ </a>
+ </c:otherwise>
+ </c:choose>
+ </div>
+ </c:when>
+ <c:otherwise>
+ <div class='col s1 center btn-container'>
+ <a class='col s6 btn-flat notification-button ${test.muteNotifications ? "inactive" : "active"}' test='${test.name}' title='${test.muteNotifications ? "Enable" : "Disable"} notifications'>
+ <i class='material-icons'>notifications_${test.muteNotifications ? "off" : "active"}</i>
+ </a>
+ <a class='col s6 btn-flat remove-button' test='${test.name}' title='Remove favorite'>
+ <i class='material-icons'>clear</i>
+ </a>
+ </div>
+ </c:otherwise>
+ </c:choose>
</div>
</c:forEach>
</div>