Append reset button (#1689)
This commit is contained in:
parent
66ec4da991
commit
14ae7ea1a2
|
@ -17,6 +17,7 @@ sub init {
|
|||
|
||||
$self->addAuthRoute( favapps => 'register', ['POST'] );
|
||||
$self->addAuthRoute( favapps => 'read', ['GET'] );
|
||||
$self->addAuthRoute( favapps => 'reset', ['DELETE'] );
|
||||
|
||||
# Parse activation rule
|
||||
$self->logger->debug(
|
||||
|
@ -159,6 +160,22 @@ sub read {
|
|||
];
|
||||
}
|
||||
|
||||
sub reset {
|
||||
my ( $self, $req ) = @_;
|
||||
my $user = $req->userData->{ $self->conf->{whatToTrace} };
|
||||
$self->p->updatePersistentSession( $req, { _favApps => '' } );
|
||||
$self->userLogger->notice("$user favorite Apps. RESET");
|
||||
|
||||
return [
|
||||
200,
|
||||
[
|
||||
'Content-Type' => 'application/json',
|
||||
'Content-Length' => 12,
|
||||
],
|
||||
['{"result":1}']
|
||||
];
|
||||
}
|
||||
|
||||
sub _isFavApp {
|
||||
my ( $self, $_favApps, $uri ) = @_;
|
||||
my $test = 0;
|
||||
|
|
|
@ -4,35 +4,47 @@ LemonLDAP::NG Favorite Applications script
|
|||
|
||||
# FavApps function (launched by "star" icon)
|
||||
FavApps = (star) ->
|
||||
$.ajax
|
||||
type: "POST"
|
||||
url: "#{portal}favapps"
|
||||
data:
|
||||
id: star.attr 'aid'
|
||||
uri: star.attr 'uri'
|
||||
name: star.attr 'name'
|
||||
logo: star.attr 'logo'
|
||||
desc: star.attr 'desc'
|
||||
dataType: 'json'
|
||||
success: (resp) ->
|
||||
if resp.error
|
||||
console.log 'Max number reached'
|
||||
$.ajax
|
||||
type: "POST"
|
||||
url: "#{portal}favapps"
|
||||
data:
|
||||
id: star.attr 'aid'
|
||||
uri: star.attr 'uri'
|
||||
name: star.attr 'name'
|
||||
logo: star.attr 'logo'
|
||||
desc: star.attr 'desc'
|
||||
dataType: 'json'
|
||||
success: (resp) ->
|
||||
if resp.error
|
||||
console.log 'Max number reached'
|
||||
switchStar star, 0
|
||||
else if resp.error == 0
|
||||
console.log 'Not authorized'
|
||||
switchStar star, 0
|
||||
else if resp.error == 0
|
||||
console.log 'Not authorized'
|
||||
else if resp.result
|
||||
console.log 'App. registered'
|
||||
switchStar star, 1
|
||||
else
|
||||
console.log 'App. unregistered'
|
||||
switchStar star, 0
|
||||
else if resp.result
|
||||
console.log 'App. registered'
|
||||
switchStar star, 1
|
||||
else
|
||||
console.log 'App. unregistered'
|
||||
switchStar star, 0
|
||||
error: switchStar star, '0'
|
||||
error: switchStar star, '0'
|
||||
|
||||
ResetFavApps = ->
|
||||
$.ajax
|
||||
type: "DELETE"
|
||||
url: "#{portal}favapps"
|
||||
success: (resp) ->
|
||||
if resp.result
|
||||
console.log 'Favorite Apps. reset'
|
||||
window.location.reload()
|
||||
else
|
||||
console.log 'Error'
|
||||
|
||||
switchStar = (star, status) ->
|
||||
star.attr('src', "#{window.staticPrefix}common/icons/star#{status}.png")
|
||||
#window.location.reload()
|
||||
|
||||
# Switch "star" events
|
||||
# Switch "star" ans Reset events
|
||||
$(document).ready ->
|
||||
$('body').on 'click', '.star', () -> FavApps $(this)
|
||||
$('#reset').on 'click', () -> ResetFavApps()
|
||||
|
|
|
@ -5,7 +5,7 @@ LemonLDAP::NG Favorite Applications script
|
|||
*/
|
||||
|
||||
(function() {
|
||||
var FavApps, switchStar;
|
||||
var FavApps, ResetFavApps, switchStar;
|
||||
|
||||
FavApps = function(star) {
|
||||
return $.ajax({
|
||||
|
@ -38,14 +38,32 @@ LemonLDAP::NG Favorite Applications script
|
|||
});
|
||||
};
|
||||
|
||||
ResetFavApps = function() {
|
||||
return $.ajax({
|
||||
type: "DELETE",
|
||||
url: portal + "favapps",
|
||||
success: function(resp) {
|
||||
if (resp.result) {
|
||||
console.log('Favorite Apps. reset');
|
||||
return window.location.reload();
|
||||
} else {
|
||||
return console.log('Error');
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
switchStar = function(star, status) {
|
||||
return star.attr('src', window.staticPrefix + "common/icons/star" + status + ".png");
|
||||
};
|
||||
|
||||
$(document).ready(function() {
|
||||
return $('body').on('click', '.star', function() {
|
||||
$('body').on('click', '.star', function() {
|
||||
return FavApps($(this));
|
||||
});
|
||||
return $('#reset').on('click', function() {
|
||||
return ResetFavApps();
|
||||
});
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
|
|
|
@ -1 +1 @@
|
|||
(function(){var FavApps,switchStar;FavApps=function(star){return $.ajax({type:"POST",url:portal+"favapps",data:{id:star.attr("aid"),uri:star.attr("uri"),name:star.attr("name"),logo:star.attr("logo"),desc:star.attr("desc")},dataType:"json",success:function(resp){if(resp.error){console.log("Max number reached");return switchStar(star,0)}else if(resp.error===0){console.log("Not authorized");return switchStar(star,0)}else if(resp.result){console.log("App. registered");return switchStar(star,1)}else{console.log("App. unregistered");return switchStar(star,0)}},error:switchStar(star,"0")})};switchStar=function(star,status){return star.attr("src",window.staticPrefix+"common/icons/star"+status+".png")};$(document).ready(function(){return $("body").on("click",".star",function(){return FavApps($(this))})})}).call(this);
|
||||
(function(){var FavApps,ResetFavApps,switchStar;FavApps=function(star){return $.ajax({type:"POST",url:portal+"favapps",data:{id:star.attr("aid"),uri:star.attr("uri"),name:star.attr("name"),logo:star.attr("logo"),desc:star.attr("desc")},dataType:"json",success:function(resp){if(resp.error){console.log("Max number reached");return switchStar(star,0)}else if(resp.error===0){console.log("Not authorized");return switchStar(star,0)}else if(resp.result){console.log("App. registered");return switchStar(star,1)}else{console.log("App. unregistered");return switchStar(star,0)}},error:switchStar(star,"0")})};ResetFavApps=function(){return $.ajax({type:"DELETE",url:portal+"favapps",success:function(resp){if(resp.result){console.log("Favorite Apps. reset");return window.location.reload()}else{return console.log("Error")}}})};switchStar=function(star,status){return star.attr("src",window.staticPrefix+"common/icons/star"+status+".png")};$(document).ready(function(){$("body").on("click",".star",function(){return FavApps($(this))});return $("#reset").on("click",function(){return ResetFavApps()})})}).call(this);
|
||||
|
|
|
@ -138,6 +138,13 @@
|
|||
</TMPL_LOOP>
|
||||
</div>
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<span id="reset" class="btn btn-danger" role="button">
|
||||
<span class="fa fa-trash-o"></span>
|
||||
<span trspan="resetFavApps">Reset my favorite Apps.</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue