Merge branch 'spidev' into 'master'

Spidev

See merge request fronk/thetool!1698
This commit is contained in:
Daniel Spitzer
2025-09-02 07:28:27 +00:00
6 changed files with 131 additions and 62 deletions

View File

@@ -2,6 +2,12 @@
<link href="<?=self::getResourcePath()?>assets/css/select2-cstm.css?<?=date('U')?>" rel="stylesheet" type="text/css" />
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css?<?= date('U') ?>" rel="stylesheet" type="text/css"/>
<!-- start page title -->
<style type="text/css">
.tool-border-spacer
{
border-right: 2px solid #868686;
}
</style>
<div class="row">
<div class="col-12">
<div class="page-title-box">
@@ -78,7 +84,18 @@
value="<?= $devicetypes->power ?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="price">Temperatur Warnung | Kritisch</label>
<div class="col-lg-2 tool-border-spacer">
<input type="number" min="0" step="1" class="form-control" name="temp_warning" id="temp_warning" placeholder="80"
value="<?= $devicetypes->temp_warning ?>" >
</div>
<div class="col-lg-2">
<input type="number" min="0" step="1" class="form-control" name="temp_critical" id="temp_critical" placeholder="90"
value="<?= $devicetypes->temp_critical ?>" >
</div>
</div>
</div>

View File

@@ -44,6 +44,8 @@ class DeviceController extends mfBaseController
"manufacturer" => $deviceType->devicemanufactor->name,
"price" => $deviceType->price,
"power" => $deviceType->power,
"temp_warning" => $deviceType->temp_warning,
"temp_critical" => $deviceType->temp_critical,
"creator" => $deviceType->creator->name,
"created" => $deviceType->create,
];

View File

@@ -76,6 +76,17 @@ class DevicetypeController extends mfBaseController
} else {
$power = $r->power;
}
if (!$r->temp_warning) {
$temp_warning = "80";
} else {
$temp_warning = $r->temp_warning;
}
if (!$r->temp_critical) {
$temp_critical = "90";
} else {
$temp_critical = $r->temp_critical;
}
if ($r->olt) {
@@ -88,6 +99,8 @@ class DevicetypeController extends mfBaseController
$data['price'] = $price;
$data['power'] = $power;
$data['olt'] = $olt;
$data['temp_warning'] = $temp_warning;
$data['temp_critical'] = $temp_critical;
if (!$data['name']) {
$this->layout()->setFlash("Name darf nicht leer sein", "error");

View File

@@ -7,6 +7,8 @@ class DevicetypeModel
public $price = null;
public $olt = null;
public $devicemanufactor_id = null;
public $temp_warning = 80;
public $temp_critical = 90;
public $create_by = null;

View File

@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class DevicetypeAddTemperature extends AbstractMigration
{
public function up(): void
{
if($this->getEnvironment() == "thetool") {
$table = $this->table("Devicetype");
$table->addColumn("temp_warning", "integer", ['null' => false,'default' => '80', "after" => "power"]);
$table->addColumn("temp_critical", "integer", ['null' => false,'default' => '90', "after" => "temp_warning"]);
$table->update();
}
if($this->getEnvironment() == "addressdb") {
}
}
public function down(): void
{
if($this->getEnvironment() == "thetool") {
$this->table("Devicetype")->removeColumn("temp_warning")->save();
$this->table("Devicetype")->removeColumn("temp_critical")->save();
}
if($this->getEnvironment() == "addressdb") {
}
}
}

View File

@@ -11,38 +11,38 @@ const deviceTypeFilterOptions = window?.TT_CONFIG?.DEVICE_TYPES.map(type => ({
Vue.component('device-view-switch', {
//language=Vue
template: `
<div class="device-view-switch" style="margin-bottom: 10px">
<div v-if="!isOverflowing"
class="button-group"
style="display:grid; grid-template-columns: repeat(3, 1fr); gap: 10px; justify-content: center; align-items: center; text-align: center; width: 100%;">
<button @click="$emit('input', 'DeviceTable')" :class="{ 'active': value === 'DeviceTable' }" class="btn btn-primary">Devices</button>
<button @click="$emit('input', 'DeviceManufacturer')"
:class="{ 'active': value === 'DeviceManufacturer' }"
class="btn btn-primary">Hersteller
</button>
<button @click="$emit('input', 'DeviceType')"
:class="{ 'active': value === 'DeviceType' }"
class="btn btn-primary">Geräte Typen
</button>
</div>
<div v-else>
<div class="dropdown">
<button @click="showDropdown = !showDropdown"
class="btn btn-primary dropdown-toggle">Ansicht
</button>
<div v-show="showDropdown" class="dropdown-menu show">
<a href="#" @click="$emit('input', 'DeviceTable'); showDropdown = false" class="dropdown-item">Devices</a>
<a href="#"
@click="$emit('input', 'DeviceManufacturer'); showDropdown = false"
class="dropdown-item">Hersteller</a>
<a href="#"
@click="$emit('input', 'DeviceType'); showDropdown = false"
class="dropdown-item">Geräte Typen</a>
</div>
</div>
</div>
</div>
`,
<div class="device-view-switch" style="margin-bottom: 10px">
<div v-if="!isOverflowing"
class="button-group"
style="display:grid; grid-template-columns: repeat(3, 1fr); gap: 10px; justify-content: center; align-items: center; text-align: center; width: 100%;">
<button @click="$emit('input', 'DeviceTable')" :class="{ 'active': value === 'DeviceTable' }" class="btn btn-primary">Devices</button>
<button @click="$emit('input', 'DeviceManufacturer')"
:class="{ 'active': value === 'DeviceManufacturer' }"
class="btn btn-primary">Hersteller
</button>
<button @click="$emit('input', 'DeviceType')"
:class="{ 'active': value === 'DeviceType' }"
class="btn btn-primary">Geräte Typen
</button>
</div>
<div v-else>
<div class="dropdown">
<button @click="showDropdown = !showDropdown"
class="btn btn-primary dropdown-toggle">Ansicht
</button>
<div v-show="showDropdown" class="dropdown-menu show">
<a href="#" @click="$emit('input', 'DeviceTable'); showDropdown = false" class="dropdown-item">Devices</a>
<a href="#"
@click="$emit('input', 'DeviceManufacturer'); showDropdown = false"
class="dropdown-item">Hersteller</a>
<a href="#"
@click="$emit('input', 'DeviceType'); showDropdown = false"
class="dropdown-item">Geräte Typen</a>
</div>
</div>
</div>
</div>
`,
props: ['value'],
data() {
return {
@@ -172,24 +172,24 @@ Vue.component('DeviceTable', {
Vue.component('DeviceManufacturer', {
//language=Vue
template: `
<tt-table :data="window['TT_CONFIG']['DEVICE_MANUFACTURERS']" :config="DeviceManufacturerConfig" excel-export>
<tt-table :data="window['TT_CONFIG']['DEVICE_MANUFACTURERS']" :config="DeviceManufacturerConfig" excel-export>
<template v-slot:top-buttons>
<button type="button" class="btn btn-primary" @click="window.location = window['TT_CONFIG']['BASE_URL'] + '/Devicemanufactor/add'">
<i class="fas fa-plus"></i>Hersteller hinzufügen
</button>
</template>
<template v-slot:top-buttons>
<button type="button" class="btn btn-primary" @click="window.location = window['TT_CONFIG']['BASE_URL'] + '/Devicemanufactor/add'">
<i class="fas fa-plus"></i>Hersteller hinzufügen
</button>
</template>
<template v-slot:actions="{ row }">
<a :href="window['TT_CONFIG']['BASE_URL'] +'/Devicemanufactor/edit/?id=' + row.id"><i class="far fa-edit" title="Bearbeiten"></i></a>
<a :href="window['TT_CONFIG']['BASE_URL'] +'/Devicemanufactor/delete/?id=' + row.id"
onclick="if(!confirm('Hersteller wirklich löschen?')) return false;"
class="text-danger"
title="Löschen"><i class="fas fa-trash "></i></a>
</template>
<template v-slot:actions="{ row }">
<a :href="window['TT_CONFIG']['BASE_URL'] +'/Devicemanufactor/edit/?id=' + row.id"><i class="far fa-edit" title="Bearbeiten"></i></a>
<a :href="window['TT_CONFIG']['BASE_URL'] +'/Devicemanufactor/delete/?id=' + row.id"
onclick="if(!confirm('Hersteller wirklich löschen?')) return false;"
class="text-danger"
title="Löschen"><i class="fas fa-trash "></i></a>
</template>
</tt-table>
`,
</tt-table>
`,
data() {
return {
window: window,
@@ -211,24 +211,24 @@ Vue.component('DeviceManufacturer', {
Vue.component('DeviceType', {
//language=Vue
template: `
<tt-table :data="window['TT_CONFIG']['DEVICE_TYPES']" :config="DeviceTypeConfig" excel-export>
<tt-table :data="window['TT_CONFIG']['DEVICE_TYPES']" :config="DeviceTypeConfig" excel-export>
<template v-slot:top-buttons>
<button type="button" class="btn btn-primary" @click="window.location = window['TT_CONFIG']['BASE_URL'] + '/Devicetype/add'">
<i class="fas fa-plus"></i>Device Type hinzufügen
</button>
</template>
<template v-slot:top-buttons>
<button type="button" class="btn btn-primary" @click="window.location = window['TT_CONFIG']['BASE_URL'] + '/Devicetype/add'">
<i class="fas fa-plus"></i>Device Type hinzufügen
</button>
</template>
<template v-slot:actions="{ row }">
<a :href="window['TT_CONFIG']['BASE_URL'] +'/Devicetype/edit/?id=' + row.id"><i class="far fa-edit" title="Bearbeiten"></i></a>
<a :href="window['TT_CONFIG']['BASE_URL'] +'/Devicetype/delete/?id=' + row.id"
onclick="if(!confirm('Gerätetyp wirklich löschen?')) return false;"
class="text-danger"
title="Löschen"><i class="fas fa-trash "></i></a>
</template>
<template v-slot:actions="{ row }">
<a :href="window['TT_CONFIG']['BASE_URL'] +'/Devicetype/edit/?id=' + row.id"><i class="far fa-edit" title="Bearbeiten"></i></a>
<a :href="window['TT_CONFIG']['BASE_URL'] +'/Devicetype/delete/?id=' + row.id"
onclick="if(!confirm('Gerätetyp wirklich löschen?')) return false;"
class="text-danger"
title="Löschen"><i class="fas fa-trash "></i></a>
</template>
</tt-table>
`,
</tt-table>
`,
data() {
return {
window: window,
@@ -241,6 +241,8 @@ Vue.component('DeviceType', {
{text: 'Hersteller', key: 'manufacturer', filter: 'search', class: 'text-center'},
{text: 'Preis', key: 'price', filter: 'numberRange', class: 'text-center', suffix: ' €'},
{text: 'max. Leistung', key: 'power', filter: 'numberRange', class: 'text-center', suffix: ' W'},
{text: 'Temp. Warnung', key: 'temp_warning', filter: 'numberRange', class: 'text-center', suffix: ' °C'},
{text: 'Temp. Kritisch', key: 'temp_critical', filter: 'numberRange', class: 'text-center', suffix: ' °C'},
{text: 'Erstellungsdatum', key: 'created', filter: 'date', class: 'text-center'},
{text: 'Erstellt von', key: 'creator', filter: 'search', class: 'text-center'},
{text: 'Aktionen', key: 'actions', class: 'text-center', sortable: false, filter: false, priority: 9},