Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

#80 Added ability to edit config files

  • Loading branch information...
commit 74e8254b6c905f0e7679bd19dcdabc0925154188 1 parent 41f6822
@asgrim asgrim authored
View
47 application/controllers/ConfigsController.php
@@ -41,4 +41,51 @@ public function indexAction()
$configs = new GD_Model_ConfigsMapper();
$this->view->configs = $configs->getConfigsByProject($project->getId());
}
+
+ public function editAction()
+ {
+ $this->view->headTitle('Configuration Management');
+ $this->view->headLink()->appendStylesheet("/css/template/form.css");
+ $this->view->headLink()->appendStylesheet("/css/pages/configs_edit.css");
+
+ $projects = new GD_Model_ProjectsMapper();
+ $project_slug = $this->_getParam("project");
+ if($project_slug != "")
+ {
+ $project = $projects->getProjectBySlug($project_slug);
+ }
+
+ $this->view->project = $project;
+
+ $configs = new GD_Model_ConfigsMapper();
+ $config = new GD_Model_Config();
+ $config_id = $this->_getParam("id");
+
+ $user = GD_Auth_Database::GetLoggedInUser();
+
+ if($config_id > 0)
+ {
+ $configs->find($config_id, $config);
+ }
+ else
+ {
+ $config->setProjectsId($project->getId());
+ $config->setDateAdded(date("Y-m-d H:i:s"));
+ $config->setAddedUsersId($user->getId());
+ }
+
+ if($this->getRequest()->isPost())
+ {
+ $config->setFilename($this->_getParam("filename", ""));
+ $config->setContent($this->_getParam("configContent", ""));
+ $config->setUpdatedUsersId($user->getId());
+ $configs->save($config);
+
+ $this->_redirect($this->getFrontController()->getBaseUrl() . "/project/" . $this->_getParam("project") . "/configs");
+ }
+ else
+ {
+ $this->view->config = $config;
+ }
+ }
}
View
60 application/views/scripts/configs/edit.phtml
@@ -0,0 +1,60 @@
+
+<div class="content">
+<div class="padding_20"></div>
+<h1><?php echo $this->project->getName(); ?> &raquo; <?php _e("Configuration Management"); ?></h1>
+<div class="padding_15"></div>
+
+<div class="wrapper w_ededed"><div class="content">
+ <div class="padding_15"></div>
+ <h2><?php _e("Configuration Editor"); ?></h2>
+ <div id="form">
+ <form id="configEditor" enctype="application/x-www-form-urlencoded" action="" method="post">
+ <input type="hidden" name="id" value="<?php echo $this->config->getId(); ?>" />
+ <fieldset>
+ <ol>
+ <li>
+ <label><span><?php _e("Path to file"); ?></span></label>
+ <span class="field">
+ <input type="text" id="filename" name="filename" value="<?php echo $this->config->getFilename(); ?>" />
+ <span class="extras">
+ <span class="description">This must be a path relative to the folder in which <?php echo $this->project->getName(); ?> will be deployed, e.g. <span class="monospace">config/db.ini</span></span>
+ </span>
+ </span>
+ <div class="clear"></div>
+ </li>
+ <li>
+ <label><span><?php _e("Content of file to be uploaded"); ?></span></label>
+ <textarea name="configContent" id="configContent"><?php echo $this->config->getContent(); ?></textarea>
+ <div class="clear"></div>
+ </li>
+ <li>
+ <label><span><?php _e("Upload to servers"); ?></span></label>
+ <span class="field" id="configServerCheckboxes">
+ <ul>
+ <li>
+ <input type="checkbox" name="server[]" id="server_all" value="all" checked="checked" />
+ <label for="server_all">All servers</label>
+ <div class="clear"></div>
+ </li>
+ <li>
+ <input type="checkbox" name="server[]" id="server_first" value="first" />
+ <label for="server_first">First server</label>
+ <div class="clear"></div>
+ </li>
+ </ul>
+ </span>
+ <div class="clear"></div>
+ </li>
+ <li class="submit">
+ <input type="image" name="btnSave" id="btnSave" src="/images/buttons/small/save-changes.png" />
+ <span id="linkBack"><a href="<?php echo $this->baseUrl(); ?>/project/<?php echo $this->project->getSlug(); ?>/configs"><?php _e("&hellip;or go back"); ?></a></span>
+ <div class="clear"></div>
+ </li>
+ </ol>
+ </fieldset>
+ </form>
+ </div>
+</div></div>
+
+<div class="padding_20"></div>
+
View
2  library/GD/Model/ConfigServer.php
@@ -21,7 +21,7 @@
* @author See AUTHORS file
* @link http://www.godeploy.com/
*/
-class GD_Model_Config
+class GD_Model_ConfigServer
{
protected $_servers_id;
protected $_configs_id;
View
2  library/GD/Model/ConfigsMapper.php
@@ -106,7 +106,7 @@ public function getConfigsByProject($project_id)
$select = $this->getDbTable()
->select()
->where("projects_id = ?", $project_id)
- ->order("filename DESC");
+ ->order("filename ASC");
return $this->fetchAll($select);
}
View
38 public/css/pages/configs_edit.css
@@ -0,0 +1,38 @@
+/* CSS Document */
+
+#filepath {
+ width: 400px;
+ }
+
+#configContent {
+ width: 100%;
+ height: 300px;
+ }
+
+#configEditor li.submit {
+ padding: 10px 0 0 205px;
+ float: left;
+ width: 600px;
+ }
+
+ #configEditor li.submit input {
+ float: left;
+ }
+
+#linkBack {
+ display: block;
+ float: left;
+ line-height: 44px;
+ margin-left: 15px;
+ }
+
+#form #configServerCheckboxes {
+ width: 300px;
+ }
+ #configServerCheckboxes ul {
+ padding: 0;
+ }
+ #configServerCheckboxes ul li {
+ padding: 0;
+ border-bottom: none;
+ }
Please sign in to comment.
Something went wrong with that request. Please try again.