diff --git a/lemonldap-ng-portal/site/coffee/favapps.coffee b/lemonldap-ng-portal/site/coffee/favapps.coffee new file mode 100644 index 000000000..6aaf20ebd --- /dev/null +++ b/lemonldap-ng-portal/site/coffee/favapps.coffee @@ -0,0 +1,42 @@ +### +LemonLDAP::NG Favorite Applications script +### + +# FavApps function (launched by "star" icon) +FavApps = (star, appuri) -> + $.ajax + type: "POST" + url: "#{portal}favapps" + data: + app: appuri + dataType: 'json' + #error: star.attr('src', 'static/common/icons/star0.png') + success: (resp) -> + if resp.error + #console.log 'Error' + #star.attr('src', 'static/common/icons/star0.png') + switchStar star, '0' + else if resp.result + #console.log 'OK' + #star.attr('src', 'static/common/icons/star1.png') + switchStar star, '1' + else + #console.log 'NOK' + #star.attr('src', 'static/common/icons/star0.png') + switchStar star, '-1' + #error: switchStar star, '0' + +switchStar = (star, status) -> + if status == '1' + console.log 'OK' + star.attr('src', 'static/common/icons/star1.png') + else if status == '-1' + console.log 'NOK' + star.attr('src', 'static/common/icons/star0.png') + else + console.log 'Error' + star.attr('src', 'static/common/icons/star0.png') + +# Switch "star" events +$(document).ready -> + $('body').on 'click', '.star', () -> FavApps $(this), ( $(this).attr 'appuri' ) diff --git a/lemonldap-ng-portal/site/htdocs/static/common/icons/star0.png b/lemonldap-ng-portal/site/htdocs/static/common/icons/star0.png new file mode 100644 index 000000000..348f94e8d Binary files /dev/null and b/lemonldap-ng-portal/site/htdocs/static/common/icons/star0.png differ diff --git a/lemonldap-ng-portal/site/htdocs/static/common/icons/star1.png b/lemonldap-ng-portal/site/htdocs/static/common/icons/star1.png new file mode 100644 index 000000000..54a4f2860 Binary files /dev/null and b/lemonldap-ng-portal/site/htdocs/static/common/icons/star1.png differ diff --git a/lemonldap-ng-portal/site/htdocs/static/common/js/favapps.js b/lemonldap-ng-portal/site/htdocs/static/common/js/favapps.js new file mode 100644 index 000000000..d25f1ee9b --- /dev/null +++ b/lemonldap-ng-portal/site/htdocs/static/common/js/favapps.js @@ -0,0 +1,49 @@ +// Generated by CoffeeScript 1.12.7 + +/* +LemonLDAP::NG Favorite Applications script + */ + +(function() { + var FavApps, switchStar; + + FavApps = function(star, appuri) { + return $.ajax({ + type: "POST", + url: portal + "favapps", + data: { + app: appuri + }, + dataType: 'json', + success: function(resp) { + if (resp.error) { + return switchStar(star, '0'); + } else if (resp.result) { + return switchStar(star, '1'); + } else { + return switchStar(star, '-1'); + } + } + }); + }; + + switchStar = function(star, status) { + if (status === '1') { + console.log('OK'); + return star.attr('src', 'static/common/icons/star1.png'); + } else if (status === '-1') { + console.log('NOK'); + return star.attr('src', 'static/common/icons/star0.png'); + } else { + console.log('Error'); + return star.attr('src', 'static/common/icons/star0.png'); + } + }; + + $(document).ready(function() { + return $('body').on('click', '.star', function() { + return FavApps($(this), $(this).attr('appuri')); + }); + }); + +}).call(this); diff --git a/lemonldap-ng-portal/site/htdocs/static/common/js/favapps.min.js b/lemonldap-ng-portal/site/htdocs/static/common/js/favapps.min.js new file mode 100644 index 000000000..049984755 --- /dev/null +++ b/lemonldap-ng-portal/site/htdocs/static/common/js/favapps.min.js @@ -0,0 +1 @@ +(function(){var FavApps,switchStar;FavApps=function(star,appuri){return $.ajax({type:"POST",url:portal+"favapps",data:{app:appuri},dataType:"json",success:function(resp){if(resp.error){return switchStar(star,"0")}else if(resp.result){return switchStar(star,"1")}else{return switchStar(star,"-1")}}})};switchStar=function(star,status){if(status==="1"){console.log("OK");return star.attr("src","static/common/icons/star1.png")}else if(status==="-1"){console.log("NOK");return star.attr("src","static/common/icons/star0.png")}else{console.log("Error");return star.attr("src","static/common/icons/star0.png")}};$(document).ready(function(){return $("body").on("click",".star",function(){return FavApps($(this),$(this).attr("appuri"))})})}).call(this); diff --git a/lemonldap-ng-portal/site/templates/bootstrap/header.tpl b/lemonldap-ng-portal/site/templates/bootstrap/header.tpl index 29c848af7..06fc2454f 100644 --- a/lemonldap-ng-portal/site/templates/bootstrap/header.tpl +++ b/lemonldap-ng-portal/site/templates/bootstrap/header.tpl @@ -42,14 +42,17 @@ + diff --git a/lemonldap-ng-portal/site/templates/bootstrap/menu.tpl b/lemonldap-ng-portal/site/templates/bootstrap/menu.tpl index 7216ab082..9ac66310f 100644 --- a/lemonldap-ng-portal/site/templates/bootstrap/menu.tpl +++ b/lemonldap-ng-portal/site/templates/bootstrap/menu.tpl @@ -114,6 +114,11 @@