User photo disappears when I change the password - css

I have a form where the user's photo appears. Every time I change the user password, the photo disappears from the form. I already tried to take the image of the form but it did not solve. The password change is done through onSubmit.
HTML:
<form (ngSubmit)="onSubmit($event)">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Configuração do Usuário: <b> {{userId?.name}} </b></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="example-container" style="width: 100%; margin: auto; margin-top: 2%">
<img class="img-modal" style="border-radius: 50%; width: 60px; height: 60px;" src={{userId?.photo}}>
<div class="example-container password-width">
<mat-form-field>
<input matInput placeholder="Alterar a Senha" [type]="hide ? 'text' : 'password'" [(ngModel)]="senha" name="senha">
<mat-icon matSuffix (click)="hide = !hide">{{hide ? 'visibility' : 'visibility_off'}}</mat-icon>
</mat-form-field>
</div>
<app-panel-config-user></app-panel-config-user>
</div>
</div>
<div class="modal-footerButtonConfig">
<button type="button" class="btn btn-danger btn-sm buttonConfig" *ngIf="userId?.status == 1">Desativar
Usuário</button>
<button type="button" class="btn btn-success btn-sm buttonConfig" *ngIf="userId?.status == 0">Ativar
Usuário</button>
<button type="button" class="btn btn-sm buttonConfig buttonColor" style="background-color: #6239BD; color: white" *ngIf="userId?.is_admin == 0">Tornar Administrador</button>
<button type="button" class="btn btn-sm buttonConfig buttonColor" style="background-color: #6239BD; color: white" *ngIf="userId?.is_admin == 1">Remover Administrador</button>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">Fechar</button>
<button type="submit" class="btn btn-sm buttonColor" style="background-color: #6239BD; color: white">Salvar</button>
</div>
</form>
Code change password:
onSubmit(
userPass: UserPass,
messageSucess: string = 'Senha alterada com Sucesso!',
messageError: string = 'Falha ao alterar a senha.',
action: string = '') {
userPass.password = this.senha;
return this.userService.putPass(this.idUser, userPass).subscribe(response => {
if (!response) {
console.log(Error);
} else {
this.userId = response;
if (this.userId['success'] === true) {
this.senha = '';
this.snackBar.open(messageSucess, action, {
duration: 4000,
panelClass: ['success-class']
});
} else {
this.snackBar.open(messageError, action, {
duration: 4000,
panelClass: ['error-class']
});
}
}
});
}

Your problem is the line
this.userId = response;
You are setting the userId to the response ({success: true}) - but the response isn't a userId!
Remove this line, and it should work again.

Related

How to push ID into form in popup using ASP.NET Core MVC?

I created a delete method where first I ask the user If he/she wants to delete the record. If user clicks yes, I will delete the record using the form but in order to delete it , I must send the ID inside the modal. How can I do that ? If I use foreach for modal it says something like too many request and tries to delete all the records, not the only one I ask.
<br />
<a asp-controller="Banner" asp-action="Create" style="float:right" class="btn btn-success">Create</a></td>
</br>
<table class="table table-bordered">
<thead>
<tr>
<th>Redirect Url</th>
</tr>
</thead>
<tbody>
#foreach (var item in Model.Banners)
{
<tr>
<td>#item.RedirectUrl</td>
<td>
<a asp-controller="Banner" asp-action="Update" asp-route-id="#item.Id" class="btn btn-info">Update</a>
<button type="button" class="btn btn-primary" data-toggle="modal" id="#item.Id" data-target="#exampleModal">
Delete
</button>
<a asp-controller="Banner" asp-action="Delete" data-toggle="modal" data-target="#exampleModal" asp-route-id="#item.Id" class="btn btn-info">Deletee</a>
</td>
</tr>
}
</tbody>
</table>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Delete</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
#using (Html.BeginForm("Delete", "Banner", FormMethod.Post, new { #class = "form-horizontal", enctype = "multipart/form-data" }))
{
<p>Are you sure you want to delete this record? </p>
<div>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-primary">Yes</button>
</div>
}
</div>
</div>
</div>
</div>
public async Task<IActionResult> Delete(int id)
{
bool value = true;
if (value == true)
{
var result = await _mediator.Send(new DeleteBannertByIdCommand(id));
}
else
{
TempData["error"] = "Something went wrong";
}
return Redirect("index");
}
You can use JavaScript to set the value of a hidden input element inside your modal form when a delete button is clicked.
<!-- ... -->
<button data-id="#item.Id" type="button" class="btn btn-primary delete-button" data-toggle="modal" data-target="#exampleModal">
Delete
</button>
<!-- ... -->
<!-- ... -->
<div class="modal-body">
#using (Html.BeginForm("Delete", "Banner", FormMethod.Post, new { #class = "form-horizontal", enctype = "multipart/form-data" }))
{
<input type="hidden" id="delete-input" name="id" />
<p>Are you sure you want to delete this record? </p>
<div>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-primary">Yes</button>
</div>
}
</div>
<!-- ... -->
#section Scripts {
<script>
const onDeleteButtonClicked = function () {
var deleteInput = document.getElementById('delete-input');
deleteInput.value = this.dataset.id;
};
const deleteButtons = document.querySelectorAll('.delete-button');
deleteButtons.forEach(function (deleteButton) {
deleteButton.onclick = onDeleteButtonClicked;
});
</script>
}

how to fix delete record using partial view?

I want to delete the record from the table with modal but the partial view is not displayed in modal ...
How can I solve this problem !?
And that I can not use onClick !!!
this action for delete in controller:
public IActionResult DelPlatform(int? id)
{
if (id == null)
{
return NotFound();
}
PR_Platform platformModel = _Iunit.PlatformsRepository.GenGetById(id);
if (platformModel == null)
{
return NotFound();
}
return View(platformModel);
}
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult DelPlatform(int id)
{
_Iunit.PlatformsRepository.GenDeleteById(id);
return RedirectToAction(nameof(PlatformList));
}
this delete button in index view:
<a asp-controller="Platform" asp-action="DelPlatform" asp-route-id="#item.PlatformId" class="btn btn-danger btn-sm waves-effect waves-light" data-toggle="modal" data-target="#delete-modal"><i class="mdi mdi-delete" data-toggle="tooltip" data-placement="top" title="حذف"></i></a>
this script for delete:
<script>
(function ($) {
function Delete() {
var $this = this;
function initilizeModel() {
$("#delete-modal").on('show.bs.modal', function (e) {
}).on('hidden.bs.modal', function (e) {
$(this).removeData('bs.modal');
});
}
$this.init = function () {
initilizeModel();
}
}
$(function () {
var self = new Delete();
self.init();
})
}(jQuery))
</script>
this modal (in shared folder):
<div class="modal fade bs-example-modal-center" tabindex="-1" role="dialog" id="delete-modal" aria-labelledby="mySmallModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header text-danger">
<h5 class="modal-title mt-0 text-white"><strong>حذف از پایگاه داده</strong></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-footer mr-auto">
<button type="submit" class="btn btn-primary waves-effect waves-light">حذف شود</button>
</div>
</div>
</div>
this delete action view (for get record name):
#model PR_Platform
#{
Layout = null;
}
<form asp-controller="Platform" asp-action="DelPlatform" method="post">
<div class="modal-body" id="delete-modal">
<p><strong>آیا از حذف <em>"#Model.PlatformName"</em> مطمئن هستید؟</strong></p>
<p class="mb-0"><small>#Model.PlatformName از پایگاه داده حذف خواهد شد</small></p>
</div>
</form>
Please try this:
View:
#{
ViewData["Title"] = "Home Page";
}
<div class="modal fade bs-example-modal-center" tabindex="-1" role="dialog" id="delete-modal" aria-labelledby="mySmallModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header text-danger">
<h5 class="modal-title mt-0 text-white"><strong>حذف از پایگاه داده</strong></h5>
<form asp-controller="Platform" asp-action="DelPlatform" method="post">
<div class="modal-body" id="delete-modal">
#*<em>"#Model.PlatformName"</em> <small>#Model.PlatformName از پایگاه داده حذف خواهد شد</small>*#
<p><strong>آیا از حذف مطمئن هستید؟</strong></p>
<p class="mb-0"></p>
</div>
<button type="submit">Click if you are sure to Delete</button>
</form>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
#*<div class="modal-footer mr-auto">
<button type="submit" class="btn btn-primary waves-effect waves-light">حذف شود</button>
</div>*#
</div>
</div>
</div>
#*asp-controller="Home" asp-action="DelPlatform" asp-route-id="#item.PlatformId"*#
<a class="btn btn-danger btn-sm waves-effect waves-light" data-toggle="modal" data-target="#delete-modal">Click to Delete<i class="mdi mdi-delete" data-toggle="tooltip" data-placement="top" title="حذف"></i></a>
Here is a whole working demo you could follow:
Model:
public class PR_Platform
{
public int PlatformId { get; set; }
public string PlatformName { get; set; }
}
Main View(Index.cshtml):
Add data-id in the anchor tag for getting the clicked value.
#model IEnumerable<PR_Platform>
#foreach(var item in Model)
{
<a asp-controller="Platform" asp-action="DelPlatform" asp-route-id="#item.PlatformId" data-id="#item.PlatformId" class="btn btn-danger btn-sm waves-effect waves-light" data-toggle="modal" data-target="#delete-modal"><i class="mdi mdi-delete" data-toggle="tooltip" data-placement="top" title="حذف"></i></a>
<a asp-controller="Platform" asp-action="DelPlatform" asp-route-id="#item.PlatformId" data-id="#item.PlatformId" class="btn btn-danger btn-sm waves-effect waves-light" data-toggle="modal" data-target="#delete-modal"><i class="mdi mdi-delete" data-toggle="tooltip" data-placement="top" title="حذف"></i></a>
}
<div class="modal fade bs-example-modal-center" tabindex="-1" role="dialog" id="delete-modal" aria-labelledby="mySmallModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header text-danger">
<h5 class="modal-title mt-0 text-white"><strong>حذف از پایگاه داده</strong></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
//add this......
</div>
<div class="modal-footer mr-auto">
<button type="submit" class="btn btn-primary waves-effect waves-light">حذف شود</button>
</div>
</div>
</div>
</div>
JS in main view:
#section Scripts
{
<script>
(function ($) {
function Delete() {
var $this = this;
function initilizeModel() {
$("#delete-modal").on('show.bs.modal', function (e) {
var $button = $(e.relatedTarget); //Button that triggered the modal
var id = $button.data("id"); //get the id
alert(id);
$.ajax({
type: "GET",
url: "/Platform/DelPlatform/"+id,
contentType: "application/json",
success: function (data) {
$(".modal-body").html(data);//load the response html code to the modal
},
error: function (e) {
alert('Error');
}
})
}).on('hidden.bs.modal', function (e) {
$(this).removeData('bs.modal');
});
}
$this.init = function () {
initilizeModel();
}
}
$(function () {
var self = new Delete();
self.init();
})
}(jQuery))
</script>
}
Controller:
public IActionResult DelPlatform(int? id)
{
if (id == null)
{
return NotFound();
}
PR_Platform platformModel = _Iunit.PlatformsRepository.GenGetById(id);
if (platformModel == null)
{
return NotFound();
}
return View(platformModel);
}

Creating bootstrap glow buttons with correct color

I want to give my bootstrap buttons a glow effect. I know I can use box-shadow for this, but since it requires a color specified, I was hoping there was some way I could inherit it from the button itself, so that each different button (success, primary, warning, etc) glowed with its respective color. For example, here's what it would look like for btn-primary, but I'd like to make the color dynamically inherited:
.glow-button {
box-shadow: 0 0 30px #007bff;
}
.btn-lg {
margin: 1em;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet"/>
<button type="button" class="btn btn-block btn-lg glow-button btn-primary">Primary</button>
A pseudo element where you apply filter can do this relying on inheriting the background color:
.glow-button {
position:relative;
}
.glow-button::before {
content:"";
position:absolute;
z-index:-1;
top:0;
left:0;
right:0;
bottom:0;
background:inherit;
filter:blur(15px);
transition:0.5s;
}
.glow-button:focus::before {
filter:blur(1px);
}
.btn-lg {
margin: 1em;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-6">
<div class="form-group">
<button type="button" class="btn btn-block btn-lg glow-button btn-primary">Primary</button>
<button type="button" class="btn btn-block btn-lg glow-button btn-secondary">Secondary</button>
<button type="button" class="btn btn-block btn-lg glow-button btn-success">Success</button>
<button type="button" class="btn btn-block btn-lg glow-button btn-danger">Danger</button>
<button type="button" class="btn btn-block btn-lg glow-button btn-warning">Warning</button>
<button type="button" class="btn btn-block btn-lg glow-button btn-info">Info</button>
<button type="button" class="btn btn-block btn-lg glow-button btn-light">Light</button>
<button type="button" class="btn btn-block btn-lg glow-button btn-dark">Dark</button>
</div>
</div>
</div>
</div>
Here's what I ultimately came up with. If someone has a way to do it without manually specifying the color for each button type I'd love to hear it!
.glow-button {
--box-shadow-color: black;
box-shadow: 0 0 30px var(--box-shadow-color);
}
.btn-primary.glow-button {
--box-shadow-color: #007bff;
}
.btn-secondary.glow-button {
--box-shadow-color: #6c757d;
}
.btn-success.glow-button {
--box-shadow-color: #28a745;
}
.btn-danger.glow-button {
--box-shadow-color: #dc3545;
}
.btn-warning.glow-button {
--box-shadow-color: #ffc107;
}
.btn-info.glow-button {
--box-shadow-color: #17a2b8;
}
.btn-light.glow-button {
--box-shadow-color: #f8f9fa;
}
.btn-dark.glow-button {
--box-shadow-color: #343a40;
}
.btn-lg {
margin: 1em;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-6">
<div class="form-group">
<button type="button" class="btn btn-block btn-lg glow-button btn-primary">Primary</button>
<button type="button" class="btn btn-block btn-lg glow-button btn-secondary">Secondary</button>
<button type="button" class="btn btn-block btn-lg glow-button btn-success">Success</button>
<button type="button" class="btn btn-block btn-lg glow-button btn-danger">Danger</button>
<button type="button" class="btn btn-block btn-lg glow-button btn-warning">Warning</button>
<button type="button" class="btn btn-block btn-lg glow-button btn-info">Info</button>
<button type="button" class="btn btn-block btn-lg glow-button btn-light">Light</button>
<button type="button" class="btn btn-block btn-lg glow-button btn-dark">Dark</button>
</div>
</div>
</div>
</div>

Ng bootstrap modal is not poping up just after closing one modal popup in angular

Here is the problem,
I want to just open popups successModal if(res != null || res != undefined) otherwise want to popups failureModal. But it pops up in background just after closing reserveModal.
Here is my code:
Here is my code:-
this.locolService.sendActivityRequest(requestObject).subscribe((res)=>{
console.log('response after sending request ', res.description);
if(res != null || res != undefined){
this.reserveModel.close();
this.modalService.open(successModal);
}
}, error =>{
this.errors = error.error.description;
this.errors = this.errors.replace("User","You");
console.log('error ', this.errors);
this.reserveModel.close();
this.modalService.open(failureModal);
});
}
Here is my component.html:-
<ng-template #requestSentModelSuccess let-c="close" let-d="dismiss">
<div class="modal-header">
<h4 class="modal-title" id="modal-basic-title">Hi there!</h4>
<button type="button" class="close" aria-label="Close" (click)="d('Cross click')">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>Congrats! Your place has been reserved. A will of receipt will be sent on your email also<br /><br />Check My
Account
for your reservations</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-dark" (click)="c('Save click')">Close</button>
</div>
</ng-template>
<!--MODAL-3-->
<ng-template #requestSentModelFaliure let-c="close" let-d="dismiss">
<div class="modal-header">
<h5 class="modal-title text-uppercase" id="">Error</h5>
<button type="button" class="close" (click)="d('Cross click')" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>{{this.errors}}<br /><br />Check My
Account
for your reservations</p>
<a type="button" (click)="onNewSearch(false)" class="btn btn-primary mybtngreen btn-lg text-uppercase">My
Account</a>
<a type="button" (click)="onMyAccount(false)" class="btn btn-outline-secondary btn-lg text-uppercase">New
search</a>
<div class="mt-2"></div>
<div class="clearfix"></div>
</div>
</ng-template>
I have referenced: requestSentModelFaliure as failureModal and requestSentModelSuccess as successModal using NgbModalRef.

So bootstrap is separating my buttons?

My issue with this code is that when I added the links around the buttons it separated the buttons up. And instead of them all being joined they no longer are joined.
<div class="btn-group btn-group-justified" role="group" aria-label="...">
<div class="btn-group" role="group">
<button type="button" class="btn btn-default <? if ($type == 'all'){ ?>active<? } ?>">All</button>
</div>
<div class="btn-group" role="group">
<button type="button" class="btn btn-default <? if ($type == 'male'){ ?>active<? } ?>">Male</button>
</div>
<div class="btn-group" role="group">
<button type="button" class="btn btn-default <? if ($type == 'female'){ ?>active<? } ?>">Female</button>
</div>
<div class="btn-group" role="group">
<button type="button" class="btn btn-default <? if ($type == 'couples'){ ?>active<? } ?>">Couples</button>
</div>
<div class="btn-group" role="group">
<button type="button" class="btn btn-default <? if ($type == 'trans'){ ?>active<? } ?>">Trans</button>
</div>
</div>
Appreciate any help
Instead of putting the button in a a href code you can do this:
Click here
The link will look like a button instead.
Remove the button element and move the classes over to the a element
...
<div class="btn-group" role="group">
<a class="btn btn-default <? if ($type == 'all'){ ?>active<? } ?>" href="/learn/popular-tags/all">All</a>
</div>
...
Bootply - http://www.bootply.com/IcLAD63W9u

Resources