Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Action series #209

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
37 changes: 37 additions & 0 deletions sql/action-series.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
CREATE TABLE `Action_Series` (
`AS_ID` INT PRIMARY KEY AUTO_INCREMENT,
`AS_Date_Created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`AS_User_ID` INT NOT NULL,
`AS_Name` VARCHAR(255) NOT NULL
);

CREATE TABLE `Action_Series_Commands` (
`ASC_ID` INT PRIMARY KEY AUTO_INCREMENT,
`ASC_Date_Created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`ASC_User_ID` INT NOT NULL,
`ASC_AS_ID` INT NOT NULL,
`ASC_Name` VARCHAR(255) NOT NULL,
`ASC_Command` TEXT NOT NULL,
`ASC_ASC_Parent` INT, -- Trees
`ASC_ASC_Parent_Return_Action` INT
);

CREATE TABLE `Action_Series_Runs` (
`ASR_ID` INT PRIMARY KEY AUTO_INCREMENT,
`ASR_Date_Created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`ASR_User_ID` INT NOT NULL,
`ASR_AS_ID` INT NOT NULL,
`ASR_Date_Finished` DATETIME NULL
);

CREATE TABLE `Action_Series_Command_Results` (
`ASCR_ID` INT PRIMARY KEY AUTO_INCREMENT,
`ASCR_ASR_ID` INT NOT NULL,
`ASCR_ASC_ID` INT NOT NULL,
`ASCR_Date_Executed` DATETIME NOT NULL,
`ASCR_Host_ID` INT NOT NULL,
`ASCR_Instance` VARCHAR(255) NOT NULL,
`ASCR_Out_Log_Path` VARCHAR(255) NOT NULL, -- can be local or remote
`ASCR_Err_Log_Path` VARCHAR(255) NOT NULL, -- can be local or remote
`ASCR_Return` INT NOT NULL
);
4 changes: 4 additions & 0 deletions src/assets/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ body {
cursor: pointer;
}

.cursor-pointer {
cursor: pointer;;
}


.disabled {
cursor: not-allowed;
Expand Down
9 changes: 9 additions & 0 deletions src/classes/App/RouteApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class RouteApi
private $project;
private $userId;

private $routed = false;

public function __construct(Container $container, RecordAction $recordAction)
{
$this->container = $container;
Expand All @@ -26,8 +28,15 @@ public function getUserId() :int
return $this->userId;
}

public function isRealRequest() :bool
{
return $this->routed;
}

public function route($pathParts, $headers)
{
$this->routed = true;

$userId = $headers["userid"];

$this->project = isset($headers["project"]) && !empty($headers["project"]) ? $headers["project"] : null;
Expand Down
18 changes: 18 additions & 0 deletions src/classes/Controllers/ActionSeries/GetOverviewController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace dhope0000\LXDClient\Controllers\ActionSeries;

use dhope0000\LXDClient\Tools\ActionSeries\GetOverview;

class GetOverviewController
{
public function __construct(GetOverview $getOverview)
{
$this->getOverview = $getOverview;
}

public function get()
{
return $this->getOverview->get();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace dhope0000\LXDClient\Controllers\ActionSeries;

use dhope0000\LXDClient\Tools\ActionSeries\GetSeriesOverview;

class GetSeriesOverviewController
{
public function __construct(GetSeriesOverview $getSeriesOverview)
{
$this->getSeriesOverview = $getSeriesOverview;
}

public function get(int $actionSeries)
{
return $this->getSeriesOverview->get($actionSeries);
}
}
18 changes: 18 additions & 0 deletions src/classes/Controllers/ActionSeries/Run/GetRunController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace dhope0000\LXDClient\Controllers\ActionSeries\Run;

use dhope0000\LXDClient\Tools\ActionSeries\Run\GetRun;

class GetRunController
{
public function __construct(GetRun $getRun)
{
$this->getRun = $getRun;
}

public function get(int $runId)
{
return $this->getRun->get($runId);
}
}
20 changes: 20 additions & 0 deletions src/classes/Controllers/ActionSeries/StartRunController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace dhope0000\LXDClient\Controllers\ActionSeries;

use dhope0000\LXDClient\Tools\ActionSeries\Run\StartRun;

class StartRunController
{
public function __construct(StartRun $startRun)
{
$this->startRun = $startRun;
}

public function start(int $userId, int $actionSeries, array $instancesByHost)
{
$this->startRun->start($userId, $actionSeries, $instancesByHost);

return ["state"=>"success", "message"=>"Completed Run"];
}
}
16 changes: 16 additions & 0 deletions src/classes/Controllers/Hosts/GetInstancesController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
namespace dhope0000\LXDClient\Controllers\Hosts;

use dhope0000\LXDClient\Tools\Hosts\GetInstances;

class GetInstancesController
{
public function __construct(GetInstances $getInstances)
{
$this->getInstances = $getInstances;
}
public function get()
{
return $this->getInstances->get();
}
}
29 changes: 29 additions & 0 deletions src/classes/Model/ActionSeries/Commands/FetchCommandDetails.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace dhope0000\LXDClient\Model\ActionSeries\Commands;

use dhope0000\LXDClient\Model\Database\Database;

class FetchCommandDetails
{
public function __construct(Database $database)
{
$this->database = $database->dbObject;
}

public function fetchDetails(int $commandId)
{
$sql = "SELECT
`ASC_Command` as `command`
FROM
`Action_Series_Commands`
WHERE
`ASC_ID` = :commandId
";
$do = $this->database->prepare($sql);
$do->execute([
":commandId"=>$commandId
]);
return $do->fetch(\PDO::FETCH_ASSOC);
}
}
33 changes: 33 additions & 0 deletions src/classes/Model/ActionSeries/Commands/FetchCommands.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace dhope0000\LXDClient\Model\ActionSeries\Commands;

use dhope0000\LXDClient\Model\Database\Database;

class FetchCommands
{
public function __construct(Database $database)
{
$this->database = $database->dbObject;
}

public function fetchForSeries(int $seriesId)
{
$sql = "SELECT
`ASC_ID` as `id`,
`ASC_Name` as `name`,
`ASC_Command` as `command`,
`ASC_ASC_Parent` as `parentId`,
`ASC_ASC_Parent_Return_Action` as `parentReturnAction`
FROM
`Action_Series_Commands`
WHERE
`ASC_AS_ID` = :seriesId
";
$do = $this->database->prepare($sql);
$do->execute([
":seriesId"=>$seriesId
]);
return $do->fetchAll(\PDO::FETCH_ASSOC);
}
}
44 changes: 44 additions & 0 deletions src/classes/Model/ActionSeries/Commands/InsertSeriesCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace dhope0000\LXDClient\Model\ActionSeries\Commands;

use dhope0000\LXDClient\Model\Database\Database;

class InsertSeriesCommand
{
public function __construct(Database $database)
{
$this->database = $database->dbObject;
}

public function insert(
int $userId,
int $seriesId,
string $command
) {
$sql = "INSERT INTO `Action_Series_Commands`
(
`ASC_User_ID`,
`ASC_AS_ID`,
`ASC_Command`,
`ASC_Term_On_Non_Zero`
) VALUES (
:userId,
:seriesId,
:command
);
";
$do = $this->database->prepare($sql);
$do->execute([
":userId"=>$userId,
":seriesId"=>$seriesId,
":command"=>$command
]);
return $do->rowCount() ? true : false;
}

public function getId() :int
{
return $this->database->lastInsertId();
}
}
44 changes: 44 additions & 0 deletions src/classes/Model/ActionSeries/FetchSeries.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace dhope0000\LXDClient\Model\ActionSeries;

use dhope0000\LXDClient\Model\Database\Database;

class FetchSeries
{
public function __construct(Database $database)
{
$this->database = $database->dbObject;
}

public function fetchAll()
{
$sql = "SELECT
`AS_ID` as `id`,
`AS_Name` as `name`
FROM
`Action_Series`
ORDER BY
`AS_ID` DESC
";
$do = $this->database->query($sql);
return $do->fetchAll(\PDO::FETCH_ASSOC);
}

public function fetchDetails(int $actionSeries)
{
$sql = "SELECT
`AS_ID` as `id`,
`AS_Name` as `name`
FROM
`Action_Series`
WHERE
`AS_ID` = :actionSeries
";
$do = $this->database->prepare($sql);
$do->execute([
":actionSeries"=>$actionSeries
]);
return $do->fetch(\PDO::FETCH_ASSOC);
}
}
36 changes: 36 additions & 0 deletions src/classes/Model/ActionSeries/InsertSeries.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace dhope0000\LXDClient\Model\ActionSeries;

use dhope0000\LXDClient\Model\Database\Database;

class InsertSeries
{
public function __construct(Database $database)
{
$this->database = $database->dbObject;
}

public function insert(int $userId, string $name)
{
$sql = "INSERT INTO `Action_Series`
(
`AS_User_ID`,
`AS_Name`
) VALUES (
:userId,
:name
);
";
$do = $this->database->prepare($sql);
$do->execute([
":userId"=>$userId,
":name"=>$name
]);
return $do->rowCount() ? true : false;
}
public function getId() :int
{
return $this->database->lastInsertId();
}
}
Loading