Skip to content

Commit

Permalink
Real LastBackup + fix syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
ValT78 committed Mar 29, 2024
1 parent 35b8bd4 commit 61dcc74
Show file tree
Hide file tree
Showing 18 changed files with 32 additions and 43 deletions.
12 changes: 6 additions & 6 deletions frontend/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import {OAuthModule, OAuthStorage} from 'angular-oauth2-oidc';
import { OAuthModule, OAuthStorage } from 'angular-oauth2-oidc';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { HomeComponent } from './home/home.component';
Expand All @@ -19,13 +19,13 @@ import { LegalComponent } from './legal/legal.component';
import { ManualComponent } from './manual/manual.component';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { HistoryComponent } from './history/history.component';
import {Ng2SearchPipeModule} from "ng2-search-filter";
import { environment } from './../environments/environment';
import {HttpClient, HttpClientModule} from '@angular/common/http';
import {TranslateModule, TranslateLoader} from '@ngx-translate/core';
import {TranslateHttpLoader} from '@ngx-translate/http-loader';
import { HttpClient, HttpClientModule } from '@angular/common/http';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { Ng2SearchPipeModule } from 'ng2-search-filter';

export function storageFactory() : OAuthStorage {
export function storageFactory(): OAuthStorage {
return localStorage;
}

Expand Down
9 changes: 4 additions & 5 deletions frontend/src/app/common/services/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import {authCodeFlowConfig} from '../../sso.config';
import {merge, Observable} from 'rxjs';
import {fromPromise} from 'rxjs/internal-compatibility';
import {HttpClient} from '@angular/common/http';
import {CookieService} from "ngx-cookie-service";
import {ActivatedRoute, Router} from '@angular/router';

@Injectable({
providedIn: 'root'
})
Expand Down Expand Up @@ -80,14 +79,14 @@ export class UserService {
this.user.sn = user.sn;
this.user.name = user.given_name;
this.user.admin = false;
this.oauthService.loadUserProfile().then(r => {
if (r.attributes['memberOf']) {
this.oauthService.loadUserProfile().then((r: any) => { // Specify the type of 'r' as 'any'
if (r.attributes && r.attributes['memberOf']) { // Check if 'attributes' property exists
if (r.attributes['memberOf'].indexOf(this.authService.adminDn) > -1) {
this.user.admin = true;
}
}
this.check_freezeState();
if(r.attributes['signedhosting'] === "false")
if(r.attributes && r.attributes['signedhosting'] === "false") // Check if 'attributes' property exists
this.user.chartevalidated = false;
else
this.user.chartevalidated = true;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/dns/dns.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export class DnsComponent implements OnInit, OnDestroy {
if(this.user.chartevalidated || this.user.admin) {
this.http.delete(this.authService.SERVER_URL + '/dns/' + id, {observe: 'response'})
.subscribe(
rep => {
() => {
window.location.reload();
},
error => {
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/app/footer/footer.component.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { Component, OnInit } from '@angular/core';
import {TranslateService} from "@ngx-translate/core";
import { Component} from '@angular/core';
import {CookieService} from "ngx-cookie-service";


@Component({
selector: 'app-footer',
templateUrl: './footer.component.html',
styleUrls: ['./footer.component.css']
})

export class FooterComponent {
date: Date = new Date();

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/history/history.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {CookieService} from "ngx-cookie-service";
styleUrls: ['./history.component.css']
})
export class HistoryComponent implements OnInit {
history: any;
history: unknown;
page = 1;
errorcode = 201;
pageSize = 200;
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/home/home.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ <h5><label for="customRange3" class="form-label">Stockage : <span class="badge
<div *ngIf="loading">
<div class="progress" >
<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar"
aria-valuemin="0" aria-valuemax="100" style="width: {{progress}}%"><strong class="text-light" >{{progress | number:'1.0-0'}}%</strong></div>
aria-valuemin="0" aria-valuemax="100" [style.width.%]="progress"><strong class="text-light" >{{progress | number:'1.0-0'}}%</strong></div>
</div>
<p class="text-primary text-center font-weight-light font-italic">{{creation_state}}</p>
</div>
Expand All @@ -288,7 +288,7 @@ <h5><label for="customRange3" class="form-label">Stockage : <span class="badge

<div *ngIf="user.admin" class="adminmenu">
<p>{{'home.admin.description_1' | translate}}<br>
{{'home.admin.description_2' | translate}}</p>bg
{{'home.admin.description_2' | translate}}</p>
<h2>{{'home.admin.stats.title' | translate}}</h2>
<br>
<div class="card-deck mb-3">
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/app/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export class HomeComponent implements OnInit {


//configuration form
configurationForm(vm:Vm):void{
configurationForm():void{
this.errorMessage = ""
this.errorcode = -1
this.progress = 0
Expand Down Expand Up @@ -315,7 +315,6 @@ export class HomeComponent implements OnInit {
this.http.get(this.authService.SERVER_URL + '/dns', {observe: 'response'}).subscribe(rep => {
dns = rep.body as Array<string>;
for (let i = 0; i < dns.length; i++) {
const dnsid = dns[i];
this.countdns++;
}
},
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/app/legal/legal.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Component, OnInit } from '@angular/core';
import {TranslateService} from "@ngx-translate/core";
import {CookieService} from "ngx-cookie-service";
import { Component } from '@angular/core';

@Component({
selector: 'app-legal',
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/manual/manual.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Component, OnInit } from '@angular/core';
import {TranslateService} from "@ngx-translate/core";
import {CookieService} from "ngx-cookie-service";


@Component({
Expand All @@ -10,8 +8,10 @@ import {CookieService} from "ngx-cookie-service";
})
export class ManualComponent implements OnInit {

// eslint-disable-next-line @typescript-eslint/no-empty-function
constructor() { }

// eslint-disable-next-line @typescript-eslint/no-empty-function
ngOnInit(): void {
}

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/navbar/navbar.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, Inject, Injectable} from '@angular/core';
import { Component, OnInit, Inject} from '@angular/core';
import { UserService } from '../common/services/user.service';
import { User } from '../models/user';
import {CookieService} from 'ngx-cookie-service';
Expand Down Expand Up @@ -77,7 +77,7 @@ export class NavbarComponent implements OnInit {
this.notificationMessage = null;
}
},
error => {
() => {
this.notificationTitle = null;
this.notificationMessage = null;
});
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/app/ssh/ssh.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Component, OnInit } from '@angular/core';
import {TranslateService} from "@ngx-translate/core";
import {CookieService} from "ngx-cookie-service";
import { Component} from '@angular/core';

@Component({
selector: 'app-ssh',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/vm/vm.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ <h4>{{'vm.information' | translate}}</h4>
<p *ngIf="user.admin"><b>{{'vm.owner' | translate}} :</b> {{ user.vms[0].user }}</p>

<p><b>{{'vm.createdOn' | translate}} :</b> {{user.vms[0].createdOn}}</p>
<p><b>{{'vm.lastBackup' | translate}} :</b> {{formatTimestamp(user.vms[0].lastBackup)}}</p>
<p><b>{{'vm.lastBackupDate' | translate}} :</b> {{formatTimestamp(user.vms[0].lastBackupDate)}}</p>
<p *ngIf="user.vms[0].status == 'running'"><b>{{'vm.upTime' | translate}} :</b> {{secondsToDhms( user.vms[0].uptime )}}</p>
</div>
<p><br><br><button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#updateModal" id="openUpdateButton" data-whatever="@getbootstrap" *ngIf="!this.vm_has_proxmox_error && errorcode != 404" >{{'vm.updateCreds.button' | translate}}</button></p>
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/app/vm/vm.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class VmComponent implements OnInit, OnDestroy {
status,
};

this.http.patch(this.authService.SERVER_URL + '/vm/' + this.vmid, data).subscribe(rep => {
this.http.patch(this.authService.SERVER_URL + '/vm/' + this.vmid, data).subscribe(() => {
this.loading = true;
}, error => {
this.loading = false;
Expand All @@ -141,7 +141,7 @@ export class VmComponent implements OnInit, OnDestroy {
}
console.log(this.errorDescription)
console.log(url)
this.http.delete(url).subscribe(rep => {
this.http.delete(url).subscribe(() => {

const deletionTimer = timer(0, 3000).pipe(
mergeMap(() => this.http.get(this.authService.SERVER_URL + '/vm/' +this.vmid, {observe: 'response'}))).subscribe(rep => {
Expand Down Expand Up @@ -186,7 +186,7 @@ export class VmComponent implements OnInit, OnDestroy {
"user": this.new_user_to_transfer
};
this.transfering_ownership = true;
this.http.patch(this.authService.SERVER_URL + '/vm/' + this.vmid, data).subscribe(rep => {
this.http.patch(this.authService.SERVER_URL + '/vm/' + this.vmid, data).subscribe(() => {
this.transfering_request_message = "success";
setTimeout(() => {this.transfering_ownership = false;
this.transfering_request_message = ""}, 1000);
Expand Down Expand Up @@ -309,7 +309,7 @@ export class VmComponent implements OnInit, OnDestroy {
};
this.popUpLoading = true;

this.http.post(this.authService.SERVER_URL + '/updateCredentials', data, {observe: 'response'}).subscribe(rep => {
this.http.post(this.authService.SERVER_URL + '/updateCredentials', data, {observe: 'response'}).subscribe(() => {
console.log("success")
this.popUpLoading = false;
if(this.need_to_be_restored){
Expand Down
5 changes: 0 additions & 5 deletions frontend/src/app/vms/vms.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,3 @@
}

}


.comment {

}
2 changes: 1 addition & 1 deletion frontend/src/app/vms/vms.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Component, OnDestroy, OnInit} from '@angular/core';
import {Vm} from '../models/vm';
import {HttpClient, HttpHeaders, HttpResponse} from '@angular/common/http';
import {HttpClient} from '@angular/common/http';
import {UserService} from '../common/services/user.service';
import {AuthService} from '../common/services/auth.service';
import {User} from '../models/user';
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
"vm.owner": "Owner",
"vm.createdOn": "Created on",
"vm.uptime": "Uptime",
"vm.lastBackup": "Last backup",
"vm.lastBackupDate": "Last backup",
"vm.systemInformation": "System Information",
"vm.cpu": "CPU",
"vm.ram": "RAM (GB)",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/assets/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
"vm.owner": "Propriétaire",
"vm.createdOn": "Créée le",
"vm.uptime": "Uptime",
"vm.lastBackup": "Dernière backup",
"vm.lastBackupDate": "Dernière backup",
"vm.systemInformation": "Informations sur le Système",
"vm.cpu": "CPU",
"vm.ram": "RAM (GB)",
Expand Down
1 change: 1 addition & 0 deletions frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "es2020",
Expand Down

0 comments on commit 61dcc74

Please sign in to comment.