Skip to content

Commit

Permalink
Rewritten displays_info module (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxudo authored Dec 5, 2018
1 parent 3fe3a49 commit 6294fd2
Show file tree
Hide file tree
Showing 13 changed files with 771 additions and 217 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 munkireport

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
59 changes: 44 additions & 15 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,59 @@ Displays Information module

Collects some relevant information from the output of `system_profiler -xml SPDisplaysDataType`

Configuration
------

Displays infomation module has two settings that can be managed by adding them to the server environment variables or the `.env` file.

```
keep_previous_displays=TRUE
show_virtual_displays=TRUE
```

Table Schema
--------

This is the table of values for 'displays':

* type (bool) Wether the display is internal (built-in) or external
* display_serial (string) Serial number of the display
* serial_number (string) Serial number of the computer it's connected to
* vendor (string) Public name translated by the model from hex value
* model (string) Model reported
* manufactured (string) Aproximate date when it was manufactured
* manufactured (string) Approximate date when it was manufactured
* native (string) Native resolution
* timestamp (int) UNIX timestamp
* ui_resolution (string) Resolution of the user interface
* current_resolution (string) Current resolution
* color_depth (string) Color depth in use by the framebuffer
* display_type (string) Type of display; LCD/CRT/Projector
* main_display (boolean) Is main display
* mirror (boolean) Is Mirrored
* mirror_status (string) Mirroring status
* online (boolean) Display online
* interlaced (boolean) Interlacing in use
* rotation_supported (boolean) Supports rotation
* television (boolean) Is a television
* display_asleep (boolean) Is display asleep
* ambient_brightness (boolean) Ambient brightness set
* automatic_graphics_switching (boolean) Automatic graphics switching in use
* retina (boolean) Is Retina display
* edr_enabled (boolean) EDR enabled
* edr_limit (float) EDR limit
* edr_supported (boolean) Supports EDR
* connection_type (string) Type of display connection in use
* dp_dpcd_version (string) Version of DisplayPort
* dp_current_bandwidth (string) Current bandwidth of DisplayPort
* dp_current_lanes (int) Current number of lanes in use by DisplayPort
* dp_current_spread (string) Current DisplayPort spread
* dp_hdcp_capability (boolean) Supports HDCP
* dp_max_bandwidth (string) Maximum DisplayPort bandwidth
* dp_max_lanes (int) Maximum DisplayPort lanes
* dp_max_spread (string) Maximum DisplayPort spread
* virtual_device (boolean) Is virtual display device
* dynamic_range (string) Dynamic range currently in use
* dp_adapter_firmware_version (string) Firmware version of DisplayPort adapter

Remarks
---
Expand Down Expand Up @@ -52,17 +95,3 @@ Nonetheless you can configure it to keep old data by adding this to your config.
* Laptop1 reports in the morning about the built-in display and an external display --> mr-php stores and displays both
* The display is broken/stolen/etc.
* The display remains associated with Laptop1 until you remove Laptop1 from MR

Configuration
-------------
Displays module history option

By default this module overrides the information of a client computer
on each client's report submission.
If you would like to keep displays information until the display is seen again
on a different computer use:
`DISPLAYS_INFO_KEEP_PREVIOUS=TRUE`
When not configured, or if set to FALSE, the default behaviour applies.
```
DISPLAYS_INFO_KEEP_PREVIOUS=FALSE
```
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"name": "munkireport/displays_info",
"description": "Module for munkireport.",
"license": "MIT"
"description": "Displays_info module for munkireport.",
"license": "MIT",
"require": {
"php":"^7.0"
}
}
24 changes: 21 additions & 3 deletions config.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
<?php

return [
'keep_previous_displays' => env('DISPLAYS_INFO_KEEP_PREVIOUS', true),
];
/*
|============================================================
| Displays module history and virtual displays option
|============================================================
|
| By default this module overrides the information of a client computer
| on each client's report submission.
|
| If you would like to keep displays information until the display is seen again
| on a different computer use:
| $conf['keep_previous_displays'] = TRUE;
|
| When not configured, or if set to FALSE, the default behaviour applies.
|
| By default the displays_info module saves virtual displays. To disable them
| set show_virtual_displays to FALSE.
|
*/
$conf['keep_previous_displays'] = env('DISPLAYS_INFO_KEEP_PREVIOUS', true),
$conf['show_virtual_displays'] = env('SHOW_VIRTUAL_DISPLAYS', true),
];
28 changes: 15 additions & 13 deletions displays_info_controller.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct()
**/
public function index()
{
echo "You've loaded the displays module!";
echo "You've loaded the displays_info module!";
}

/**
Expand All @@ -33,23 +33,25 @@ public function index()
**/
public function get_data($serial = '')
{
$out = array();
$obj = new View();

if (! $this->authorized()) {
$out['error'] = 'Not authorized';
} else {
$prm = new Displays_info_model;
foreach ($prm->retrieve_records($serial) as $display) {
$out[] = $display->rs;
}
$obj->view('json', array('msg' => 'Not authorized'));
return;
}

$obj = new View();
$obj->view('json', array('msg' => $out));
$queryobj = new Displays_info_model();

$sql = "SELECT vendor, type, display_type, display_serial, manufactured, native, ui_resolution, current_resolution, color_depth, connection_type, online, main_display, display_asleep, retina, mirror, mirror_status, interlaced, rotation_supported, television, ambient_brightness, automatic_graphics_switching, virtual_device, edr_supported, edr_enabled, edr_limit, dp_dpcd_version, dp_current_bandwidth, dp_current_lanes, dp_current_spread, dp_hdcp_capability, dp_max_bandwidth, dp_max_lanes, dp_max_spread, dynamic_range, dp_adapter_firmware_version, timestamp, model
FROM displays
WHERE serial_number = '$serial'";

$displays_tab = $queryobj->query($sql);
$obj->view('json', array('msg' => current(array('msg' => $displays_tab))));
}

/**
* Get count of displays
*
* Get count of displays
*
* @param int $type type 1 is external, type 0 is internal
**/
Expand All @@ -65,4 +67,4 @@ public function get_count($type = 1)
$dim = new Displays_info_model();
$obj->view('json', array('msg' => $dim->get_count($type)));
}
} // END class default_module
} // END class displays_info
Loading

0 comments on commit 6294fd2

Please sign in to comment.