Merge pull request #408 from allerta-vvf/master

Fix logger and destroy
This commit is contained in:
Matteo Gheza 2021-12-30 12:00:59 +01:00 committed by GitHub
commit 99f1dc6bf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 12 deletions

View File

@ -217,7 +217,7 @@ function apiRouter (FastRoute\RouteCollector $r) {
exit;
}
$user_id = is_numeric($_POST["id"]) ? $_POST["id"] : $users->auth->getUserId();
logger("Disponibilità cambiata in ".($_POST["available"] ? '"disponibile"' : '"non disponibile"'), $user_id);
logger("Disponibilità cambiata in ".($_POST["available"] ? '"disponibile"' : '"non disponibile"'), $user_id, $users->auth->getUserId());
apiResponse([
"response" => $db->update(
DB_PREFIX.'_profiles',

View File

@ -32,7 +32,7 @@
"@angular/cli": "~13.0.3",
"@angular/compiler-cli": "~13.0.0",
"@types/jasmine": "~3.10.0",
"@types/node": "^12.11.1",
"@types/node": "16.11.17",
"jasmine-core": "~3.10.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",
@ -2687,9 +2687,9 @@
"dev": true
},
"node_modules/@types/node": {
"version": "12.20.39",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.39.tgz",
"integrity": "sha512-U7PMwkDmc3bnL0e4U8oA0POpi1vfsYDc+DEUS2+rPxm9NlLcW1dBa5JcRhO633PoPUcCSWMNXrMsqhmAVEo+IQ==",
"version": "16.11.17",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.17.tgz",
"integrity": "sha512-C1vTZME8cFo8uxY2ui41xcynEotVkczIVI5AjLmy5pkpBv/FtG+jhtOlfcPysI8VRVwoOMv6NJm44LGnoMSWkw==",
"dev": true
},
"node_modules/@types/parse-json": {
@ -14469,9 +14469,9 @@
"dev": true
},
"@types/node": {
"version": "12.20.39",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.39.tgz",
"integrity": "sha512-U7PMwkDmc3bnL0e4U8oA0POpi1vfsYDc+DEUS2+rPxm9NlLcW1dBa5JcRhO633PoPUcCSWMNXrMsqhmAVEo+IQ==",
"version": "16.11.17",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.17.tgz",
"integrity": "sha512-C1vTZME8cFo8uxY2ui41xcynEotVkczIVI5AjLmy5pkpBv/FtG+jhtOlfcPysI8VRVwoOMv6NJm44LGnoMSWkw==",
"dev": true
},
"@types/parse-json": {

View File

@ -34,7 +34,7 @@
"@angular/cli": "~13.0.3",
"@angular/compiler-cli": "~13.0.0",
"@types/jasmine": "~3.10.0",
"@types/node": "^12.11.1",
"@types/node": "16.11.17",
"jasmine-core": "~3.10.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",

View File

@ -1,4 +1,4 @@
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { Component, OnInit, OnDestroy, Input, Output, EventEmitter } from '@angular/core';
import { TableType } from 'src/app/_models/TableType';
import { ApiClientService } from 'src/app/_services/api-client.service';
import { AuthService } from '../../_services/auth.service';
@ -8,7 +8,7 @@ import { AuthService } from '../../_services/auth.service';
templateUrl: './table.component.html',
styleUrls: ['./table.component.scss']
})
export class TableComponent implements OnInit {
export class TableComponent implements OnInit, OnDestroy {
@Input() sourceType?: string;
@Input() refreshInterval?: number;
@ -17,7 +17,7 @@ export class TableComponent implements OnInit {
public data: any = [];
public loadDataInterval: NodeJS.Timer | number = 0;
public loadDataInterval: NodeJS.Timer | undefined = undefined;
constructor(public apiClient: ApiClientService, public auth: AuthService) {}
@ -44,6 +44,12 @@ export class TableComponent implements OnInit {
}, this.refreshInterval || 10000);
}
ngOnDestroy(): void {
if(typeof this.loadDataInterval !== 'undefined') {
clearInterval(this.loadDataInterval);
}
}
onChangeAvailability(user: number, newState: 0|1) {
if(this.auth.profile.full_viewer) {
this.changeAvailability.emit({user, newState});