perbaikan login dan tampilan cost management

This commit is contained in:
Fuzi_fauzia 2024-06-23 18:10:04 +07:00
parent efaf30d55e
commit 23154e6862
4 changed files with 59 additions and 26 deletions

View File

@ -177,7 +177,6 @@
/>
</div>
</div>
<div class="col-3">
<div class="form-group">
<ng-select
@ -191,7 +190,6 @@
</ng-select>
</div>
</div>
<div class="col-3">
<div class="d-flex">
<button

View File

@ -1,29 +1,49 @@
<div class="modal-body" style="background-color: #000000 !important">
<div class="modal-body" style="background-color: #252525 !important">
<h4 style="color: #ffffff">Input the actual cost of your expenses</h4>
<p style="color: #ffffff">Building : {{ buildingName }}</p>
<p style="color: #ffffff">Periode : {{ formattedDate }}</p>
<form [formGroup]="myForm">
<div class="form-group">
<input
type="text"
class="form-control"
id="real_cost"
formControlName="real_cost"
placeholder="0.00"
mask="separator"
thousandSeparator="."
/>
<div class="input-group">
<div
class="input-group-prepend"
style="background-color: #252525 !important"
>
<span
class="input-group-text"
id="basic-addon1"
style="
background-color: #252525 !important;
color: #ffffff;
height: calc(1.5em + 0.75rem + 2px) !important;
"
>Rp</span
>
</div>
<input
type="text"
class="form-control"
id="real_cost"
aria-describedby="basic-addon1"
formControlName="real_cost"
placeholder="..............."
mask="separator"
thousandSeparator="."
/>
</div>
</div>
</form>
</div>
<div class="modal-footer" style="background-color: #000000 !important">
<div class="modal-footer justify-content-between" style="background-color: #252525 !important; border-style: none !important;">
<button
type="button"
class="btn btn-secondary"
style="
color: #c3f164;
background-color: #000000 !important;
width: 25%;
background-color: #252525 !important;
border-color: #c3f164 !important;
border-radius: 10px;
"
(click)="activeModal.dismiss('Cross click')"
>
@ -33,12 +53,15 @@
type="button"
class="btn btn-primary"
style="
color: #000000 !important;
color: #252525 !important;
width: 25%;
background-color: #c3f164 !important;
border-color: #c3f164 !important;
border-radius: 10px;
"
(click)="addRow()"
>
Save Changes
Add
</button>
</div>

View File

@ -13,7 +13,7 @@
class="brand-logo"
src="assets/images/logo/smart.png"
alt="branding logo"
height="100" width="400"
height="100%" width="75%"
/>
<!-- <h3 class="brand-text" style="color: #000000; margin: 0; font-weight: 600;">
Smart Building
@ -81,7 +81,7 @@
<div
class="col-md-6 col-12 text-center text-sm-left pr-0"
>
<fieldset>
<!-- <fieldset>
<div
class="icheckbox_square-blue"
id="icheckbox"
@ -116,14 +116,14 @@
<label class="lb-remember" for="remember-me"
>Remember Me</label
>
</fieldset>
</fieldset> -->
</div>
<div
class="col-md-6 col-12 float-sm-left text-center text-sm-right"
>
<a href="recover-password.html" class="card-link"
<!-- <a href="recover-password.html" class="card-link"
>Forgot Password?</a
>
> -->
</div>
</div>
<button

View File

@ -5,6 +5,7 @@ import { AuthService } from "../_services/auth.service";
import { AlertService } from "../_services/alert.service";
import { HttpClient } from "@angular/common/http";
import { BuildingService } from "../content/hemat-app/service/monitoring-api.service";
import { ToastrService } from "ngx-toastr";
@Component({
templateUrl: "login.component.html",
@ -23,7 +24,8 @@ export class LoginComponent implements OnInit {
public authService: AuthService,
private renderer: Renderer2,
private router: Router,
private monitoringApiService: BuildingService
private monitoringApiService: BuildingService,
private toastr: ToastrService
) {
this.route.queryParams.subscribe((params) => {
this.returnUrl = params["returnUrl"];
@ -41,6 +43,9 @@ export class LoginComponent implements OnInit {
password: ["password", Validators.required],
rememberMe: false,
});
if (localStorage.getItem("currentUser")) {
this.router.navigate(["/monitoring"]);
}
// Remember Me
// console.log(localStorage.getItem("remember"));
@ -116,23 +121,29 @@ export class LoginComponent implements OnInit {
this.monitoringApiService.postLogin(loginData)
.subscribe(
(response: any) => {
console.log('Login successful:', response);
localStorage.setItem('access_token', response.access_token);
// Store the user profile information
const userProfile = {
displayName: this.loginForm.value.email,
buildingId: 4
};
this.toastr.success("Success", "Selamat Datang " + userProfile.displayName , {
timeOut: 5000,
closeButton: true,
});
localStorage.setItem('currentUser', JSON.stringify(userProfile));
this.router.navigate(['/monitoring']);
},
error => {
this.toastr.error("Error", "Akun yang anda masukan salah!", {
timeOut: 5000,
closeButton: true,
});
console.error('Login failed:', error);
}
);
}
addCheckbox(event) {
const toggle = document.getElementById("icheckbox");
if (event.currentTarget.className === "icheckbox_square-blue") {
@ -143,6 +154,7 @@ export class LoginComponent implements OnInit {
this.renderer.removeClass(toggle, "checked");
}
}
setUserInStorage(res) {
if (res.user) {
localStorage.setItem("currentUser", JSON.stringify(res.user));