Skip to content

Commit

Permalink
Merge pull request #92 from iml-it/set-variable-types
Browse files Browse the repository at this point in the history
Set variable types
  • Loading branch information
axelhahn authored Jul 25, 2024
2 parents 9ac3545 + 4382e19 commit 4d61357
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 29 deletions.
6 changes: 3 additions & 3 deletions public_html/client/classes/appmonitor-checks.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ protected function _checkArrayKeys($aConfig, $sKeyList)

/**
* Perform a check
* @param array $aConfig configuration array for a check
* Array
* @param array $aConfig configuration array for a check, eg.
* <code>
* [
* [name] => Dummy
* [description] => Dummy Test
Expand All @@ -238,7 +238,7 @@ protected function _checkArrayKeys($aConfig, $sKeyList)
* // its keys depend on the function
* ]
* ]
*
* </code>
* @return array
*/
public function makeCheck(array $aConfig): array
Expand Down
28 changes: 19 additions & 9 deletions public_html/client/git_update_appmonitor.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
#!/bin/bash
# ======================================================================
#
# UPDATE APPMONITOR CLIENT
# A P P M O N I T O R :: CLIENT - UPDATE
#
# requires git, rsync
# This script will install or update the appmonitor client only.
#
# Below the document root of a website create a new directory,
# i.e. [webroot]/appmonitor/ and copy this script there.
# Change the directory "cd [webroot]/appmonitor/" and execute it.
#
# ----------------------------------------------------------------------
# 2022-04-11 <[email protected]> first lines
# 2022-04-12 <[email protected]> add help; exclude unneeded files
# 2022-05-03 <[email protected]> create general_include.php
# requires git, rsync
# ----------------------------------------------------------------------
# 2022-04-11 0.1 <[email protected]> first lines
# 2022-04-12 0.2 <[email protected]> add help; exclude unneeded files
# 2022-05-03 0.3 <[email protected]> create general_include.php
# 2024-07-25 0.4 <[email protected]> update quoting and comments
# ======================================================================

# ----------------------------------------------------------------------
# CONFIG
# ----------------------------------------------------------------------

readonly git_repo_url="https://github.com/iml-it/appmonitor.git"
readonly line="____________________________________________________________"
readonly version="0.3"
readonly line="______________________________________________________________________________"
readonly version="0.4"

git_target=/tmp/git_data__appmonitor
client_from="${git_target}/public_html/client"
client_to="."

cd $( dirname "$0" ) || exit 1
cd "$( dirname "$0" )" || exit 1

# ----------------------------------------------------------------------
# FUNCTIONS
Expand Down Expand Up @@ -99,6 +106,9 @@ case "$1" in
This is a helper script to get the files of the IML Appmonitor
client part only.
Below the document root of a website create a new directory,
i.e. [webroot]/appmonitor/ and copy this script there.
This script clones and updates the repository in the /tmp
directory and syncs the client files of it to a given directory.
Expand Down Expand Up @@ -165,7 +175,7 @@ _fileupdate general_include.sample.php
echo $line
echo ">>> #3 of 3 >>> Diff"
echo
diff -r "$client_from" "$client_to"
diff --color -r "$client_from" "$client_to"
echo


Expand Down
5 changes: 3 additions & 2 deletions public_html/client/plugins/checks/loadmeter.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
*
* 2019-06-06 <[email protected]>
* 2024-07-23 <[email protected]> php 8 only: use typed variables
* 2024-07-25 <[email protected]> float return with 2 digits behind comma
*
*/
class checkLoadmeter extends appmonitorcheck
Expand Down Expand Up @@ -132,12 +133,12 @@ public function run(array $aParams): array
//
return [
$iResult,
($fLoad === false ? 'load value is not available' : 'current load is: ' . $fLoad),
($fLoad === false ? 'load value is not available' : 'current load is: ' . round($fLoad, 2)),
($fLoad === false
? []
: [
'type' => 'counter',
'count' => $fLoad,
'count' => round($fLoad, 2),
'visual' => 'line',
]
)
Expand Down
11 changes: 6 additions & 5 deletions public_html/server/classes/appmonitor-server-gui.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,9 @@ protected function _generateWebappTiles(string $sAppId): string
: '';
break;
case 'receiver':
$this->oNotification->setApp($sAppId, $this->_data[$sAppId]);
$this->oNotification->setApp($sAppId);
$aEmailNotifiers = $this->oNotification->getAppNotificationdata('email');
$aSlackChannels = $this->oNotification->getAppNotificationdata('slack', 1);
$aSlackChannels = $this->oNotification->getAppNotificationdata('slack');

// $aPeople=[ '[email protected]', '[email protected]' ];
$sMoreNotify = (count($aEmailNotifiers) ? '<span title="' . implode("\n", $aEmailNotifiers) . '">' . count($aEmailNotifiers) . ' x ' . $this->_aIco['notify-email'] . '</span> ' : '')
Expand Down Expand Up @@ -1261,7 +1261,7 @@ protected function _renderCounter(string $sAppId, string $sCounterId, array $aOp
'xValue' => false,

'yGrid' => false,
'yLabel' => $aOptions['label'],
// 'yLabel' => $aOptions['label'],
'yLabel' => false,
'yValue' => false,

Expand Down Expand Up @@ -1846,6 +1846,7 @@ public function _access_denied(string $sMessage): string
'text' => $sMessage,
]);
}
return '';
}

/**
Expand Down Expand Up @@ -2026,7 +2027,7 @@ function _generateWeblist(bool $bSkipOk = false, array $aOptions = []): array
$aTags = $aEntries["meta"]["tags"] ?? false;
$sTaglist = $aTags ? $this->_getTaglist($aTags) : '';

$this->oNotification->setApp($sAppId, $this->_data[$sAppId]);
$this->oNotification->setApp($sAppId);

$aLastStatus = $this->oNotification->getAppLastResult();
$sSince = isset($aLastStatus['laststatus']['result']['ts'])
Expand Down Expand Up @@ -2208,7 +2209,7 @@ public function generateViewWeblist(): string
* it is used to build an url; the "-" will be used to parse the app id
*
* @param string $sAppid
* @return type
* @return string
*/
protected function _getDivIdForApp(string $sAppid): string
{
Expand Down
2 changes: 1 addition & 1 deletion public_html/server/classes/appmonitor-server.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class appmonitorserver

/**
* name of the config file to load
* @var type
* @var string
*/
protected string $_sConfigfile = "appmonitor-server-config.json";

Expand Down
31 changes: 23 additions & 8 deletions public_html/server/classes/render-adminlte.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class renderadminlte
public function __construct()
{
$this->_oHtml = new htmlelements();
return true;
//return true;
}

// ----------------------------------------------------------------------
Expand All @@ -108,6 +108,7 @@ public function __construct()
* @param string $sType type; key in $_aValidItems; one of color|type
* @param string $sValue value to check
* @param string $sReferrer optional: method that called this function
* @return bool
*/
protected function _checkValue($sType, $sValue, $sReferrer = false)
{
Expand All @@ -131,7 +132,7 @@ protected function _checkValue($sType, $sValue, $sReferrer = false)
/**
* return a alert box
* https://adminlte.io/themes/AdminLTE/pages/UI/general.html
* @param type $aOptions hash with keys for all options
* @param array $aOptions hash with keys for all options
* - type - one of [none]|danger|info|primary|success|warning
* - dismissible - if dismissible - one of true|false; default: false
* - title
Expand Down Expand Up @@ -169,7 +170,7 @@ public function getAlert($aOptions)

/**
* get html code for a badge
* @param type $aOptions hash with keys for all options
* @param array $aOptions hash with keys for all options
* - type - one of [none]|danger|info|primary|success|warning
* - bgcolor - background color (without prefix "bg")
* - class - css class
Expand Down Expand Up @@ -202,7 +203,7 @@ public function getBadge($aOptions)
/**
* return a callout box
* https://adminlte.io/themes/AdminLTE/pages/UI/general.html
* @param type $aOptions hash with keys for all options
* @param array $aOptions hash with keys for all options
* - type - one of [none]|danger|info|primary|success|warning
* - title
* - text
Expand Down Expand Up @@ -235,7 +236,7 @@ public function getCallout($aOptions)

/**
* return a content Box
* @param type $aOptions hash with keys for all options
* @param array $aOptions hash with keys for all options
* - type - one of [none]|danger|info|primary|success|warning
* - solid - one of true|false; default: false
* - collapsable - one of true|false; default: false
Expand Down Expand Up @@ -295,6 +296,20 @@ public function getBox($aOptions)
}



/**
* Generates a menu item with a label and link options.
*
* @param array $aOptions The options for the menu item.
* - 'class' (string): The CSS class for the menu item.
* - 'label' (string): The label for the menu item.
* @param array $aLinkOptions The options for the link.
* - 'href' (string): The URL for the link.
* - 'text' (string): The text for the link.
* - 'class' (string): The CSS class for the link.
* - 'icon' (string): The icon for the link.
* @return string The generated menu item.
*/
public function getMenuItem($aOptions, $aLinkOptions)
{
$sLabel = $this->_oHtml->getTag('a', $aLinkOptions);
Expand Down Expand Up @@ -332,7 +347,7 @@ public function getMenuItem($aOptions, $aLinkOptions)

/**
* return a small Box
* @param type $aOptions hash with keys for all options
* @param array $aOptions hash with keys for all options
* - type - icon color one of [none]|aqua|green|yellow|red
* - bgcolor - background color one of [none]|aqua|green|yellow|red
* - color - icon color one of [none]|aqua|black|gray|green|orange|maroon|navy|purple|red|teal|yellow
Expand Down Expand Up @@ -368,7 +383,7 @@ public function getSmallBox($aOptions)
}
/**
* return a widget
* @param type $aOptions hash with keys for all options
* @param array $aOptions hash with keys for all options
* - bgcolor - icon color one of aqua|green|yellow|red
* - color - icon color one of aqua|black|gray|green|orange|maroon|navy|purple|red|teal|yellow
* - onclick
Expand Down Expand Up @@ -452,7 +467,7 @@ public function getSectionRow($sContent = false, $sId=false)
* get html code for headline of page content
*
* @param string $sHeadline headline as html
* @return type
* @return string
*/
public function getSectionHead($sHeadline)
{
Expand Down
5 changes: 4 additions & 1 deletion scripts/generate_class_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,17 @@ function docgen(){

echo "----- $myfile"
echo " $outfile"
./parse-class.php --debug --out md "$APPDIR/$myfile" > "$outfile"
./parse-class.php --out md "$APPDIR/$myfile" > "$outfile"
echo
}

# ----------------------------------------------------------------------
# MAIN
# ----------------------------------------------------------------------


# ./parse-class.php --out md "$APPDIR/public_html/server/classes/appmonitor-server.class.php"; exit

# generate all docs
for myfile in $clientClassfiles
do
Expand Down

0 comments on commit 4d61357

Please sign in to comment.