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 => 'register', ['POST'] );
|
||||||
$self->addAuthRoute( favapps => 'read', ['GET'] );
|
$self->addAuthRoute( favapps => 'read', ['GET'] );
|
||||||
|
$self->addAuthRoute( favapps => 'reset', ['DELETE'] );
|
||||||
|
|
||||||
# Parse activation rule
|
# Parse activation rule
|
||||||
$self->logger->debug(
|
$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 {
|
sub _isFavApp {
|
||||||
my ( $self, $_favApps, $uri ) = @_;
|
my ( $self, $_favApps, $uri ) = @_;
|
||||||
my $test = 0;
|
my $test = 0;
|
||||||
|
|
|
@ -4,35 +4,47 @@ LemonLDAP::NG Favorite Applications script
|
||||||
|
|
||||||
# FavApps function (launched by "star" icon)
|
# FavApps function (launched by "star" icon)
|
||||||
FavApps = (star) ->
|
FavApps = (star) ->
|
||||||
$.ajax
|
$.ajax
|
||||||
type: "POST"
|
type: "POST"
|
||||||
url: "#{portal}favapps"
|
url: "#{portal}favapps"
|
||||||
data:
|
data:
|
||||||
id: star.attr 'aid'
|
id: star.attr 'aid'
|
||||||
uri: star.attr 'uri'
|
uri: star.attr 'uri'
|
||||||
name: star.attr 'name'
|
name: star.attr 'name'
|
||||||
logo: star.attr 'logo'
|
logo: star.attr 'logo'
|
||||||
desc: star.attr 'desc'
|
desc: star.attr 'desc'
|
||||||
dataType: 'json'
|
dataType: 'json'
|
||||||
success: (resp) ->
|
success: (resp) ->
|
||||||
if resp.error
|
if resp.error
|
||||||
console.log 'Max number reached'
|
console.log 'Max number reached'
|
||||||
|
switchStar star, 0
|
||||||
|
else if resp.error == 0
|
||||||
|
console.log 'Not authorized'
|
||||||
switchStar star, 0
|
switchStar star, 0
|
||||||
else if resp.error == 0
|
else if resp.result
|
||||||
console.log 'Not authorized'
|
console.log 'App. registered'
|
||||||
|
switchStar star, 1
|
||||||
|
else
|
||||||
|
console.log 'App. unregistered'
|
||||||
switchStar star, 0
|
switchStar star, 0
|
||||||
else if resp.result
|
error: switchStar star, '0'
|
||||||
console.log 'App. registered'
|
|
||||||
switchStar star, 1
|
ResetFavApps = ->
|
||||||
else
|
$.ajax
|
||||||
console.log 'App. unregistered'
|
type: "DELETE"
|
||||||
switchStar star, 0
|
url: "#{portal}favapps"
|
||||||
error: switchStar star, '0'
|
success: (resp) ->
|
||||||
|
if resp.result
|
||||||
|
console.log 'Favorite Apps. reset'
|
||||||
|
window.location.reload()
|
||||||
|
else
|
||||||
|
console.log 'Error'
|
||||||
|
|
||||||
switchStar = (star, status) ->
|
switchStar = (star, status) ->
|
||||||
star.attr('src', "#{window.staticPrefix}common/icons/star#{status}.png")
|
star.attr('src', "#{window.staticPrefix}common/icons/star#{status}.png")
|
||||||
#window.location.reload()
|
#window.location.reload()
|
||||||
|
|
||||||
# Switch "star" events
|
# Switch "star" ans Reset events
|
||||||
$(document).ready ->
|
$(document).ready ->
|
||||||
$('body').on 'click', '.star', () -> FavApps $(this)
|
$('body').on 'click', '.star', () -> FavApps $(this)
|
||||||
|
$('#reset').on 'click', () -> ResetFavApps()
|
||||||
|
|
|
@ -5,7 +5,7 @@ LemonLDAP::NG Favorite Applications script
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var FavApps, switchStar;
|
var FavApps, ResetFavApps, switchStar;
|
||||||
|
|
||||||
FavApps = function(star) {
|
FavApps = function(star) {
|
||||||
return $.ajax({
|
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) {
|
switchStar = function(star, status) {
|
||||||
return star.attr('src', window.staticPrefix + "common/icons/star" + status + ".png");
|
return star.attr('src', window.staticPrefix + "common/icons/star" + status + ".png");
|
||||||
};
|
};
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
return $('body').on('click', '.star', function() {
|
$('body').on('click', '.star', function() {
|
||||||
return FavApps($(this));
|
return FavApps($(this));
|
||||||
});
|
});
|
||||||
|
return $('#reset').on('click', function() {
|
||||||
|
return ResetFavApps();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}).call(this);
|
}).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>
|
</TMPL_LOOP>
|
||||||
</div>
|
</div>
|
||||||
</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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user