diff --git a/.htaccess.sample b/.htaccess.sample
new file mode 100644
index 0000000..33cdd17
--- /dev/null
+++ b/.htaccess.sample
@@ -0,0 +1,17 @@
+
+ RewriteEngine On
+
+ RewriteCond %{REQUEST_URI} ^system.*
+ RewriteRule ^(.*)$ /index.php?/$1 [L]
+
+ RewriteCond %{REQUEST_URI} ^application.*
+ RewriteRule ^(.*)$ /index.php?/$1 [L]
+
+ RewriteCond %{REQUEST_FILENAME} !-f
+ RewriteCond %{REQUEST_FILENAME} !-d
+ RewriteRule ^(.*)$ index.php?/$1 [L]
+
+
+
+ ErrorDocument 404 /index.php
+
diff --git a/application/config/config.sample.php b/application/config/config.sample.php
new file mode 100644
index 0000000..35e6a32
--- /dev/null
+++ b/application/config/config.sample.php
@@ -0,0 +1,362 @@
+load->model('job');
+
+ // load language file
+ $this->lang->load(strtolower($this->router->class));
+ }
+
+ /**
+ * Get jobs belonging to projects owned by the user.
+ */
public function getOwn() {
$query = $this->db->order_by('progress', 'desc')
->get_where('jobs', array('started_by' => $this->session->userdata('user_id')));
- $count = $query->num_rows();
$jobs = $query->result_array();
for($i=0; $iset_content_type('application/json')
->set_output(json_encode(
array(
- 'count' => $count,
+ 'count' => count($jobs),
'jobs' => $jobs
)
));
}
-
- public function listResultsNotSeen() {
- $query = $this->db->order_by('started_at', 'asc')
- ->get_where('jobs', array('started_by' => $this->session->userdata('user_id'), 'seen' => '0'));
- $count = $query->num_rows();
- $jobs = $query->result_array();
-
- for($i=0; $idb->select('name')->get_where('projects', array('id' => $jobs[$i]['project_id']))->row()->name;
- }
+
+ /**
+ * Get a list of results that the owner has not yet seen.
+ * @todo not yet verified
+ */
+ public function get_unseen_results() {
+ $results = $this->job->getUnseenResults();
$this->output
->set_content_type('application/json')
->set_output(json_encode(
array(
- 'count' => $count,
- 'jobs' => $jobs
+ 'count' => count($results),
+ 'results' => $results
)
));
}
diff --git a/application/controllers/projects.php b/application/controllers/projects.php
index 2735759..b01b4a9 100644
--- a/application/controllers/projects.php
+++ b/application/controllers/projects.php
@@ -64,7 +64,7 @@ class Projects extends CI_Controller {
// ->set_output(json_encode(array('count' => $count, 'projects' => $projects)));
}
- public function detail($projects, $area, $id) {
+ public function detail($project_id) {
$project = $this->project->get($id);
$this->output
->set_content_type('application/json')
diff --git a/application/controllers/statusrpc.php b/application/controllers/statusrpc.php
index 3696f0b..89fec9b 100644
--- a/application/controllers/statusrpc.php
+++ b/application/controllers/statusrpc.php
@@ -44,6 +44,6 @@ class Statusrpc extends CI_Controller {
die("Unauthorized access.");
}
- $this->server->update_workload($secret, $workload);
+ $this->server->updateWorkload($secret, $workload);
}
}
\ No newline at end of file
diff --git a/application/language/english/jobs_lang.php b/application/language/english/jobs_lang.php
new file mode 100644
index 0000000..d747055
--- /dev/null
+++ b/application/language/english/jobs_lang.php
@@ -0,0 +1,8 @@
+db->escape($progress).$finished_at. " WHERE `id`=".
$this->db->escape($job_id));
}
+
+ /**
+ * Get a list of results that the owner has not yet seen.
+ */
+ public function getUnseenResults() {
+ $query = $this->db->order_by('started_at', 'asc')
+ ->get_where('jobs', array('started_by' => $this->session->userdata('user_id'), 'seen' => '0'));
+ $jobs = $query->result_array();
+
+ for($i=0; $idb->select('name')->get_where('projects', array('id' => $jobs[$i]['project_id']))->row()->name;
+ }
+
+ return $jobs;
+ }
}
diff --git a/application/models/project.php b/application/models/project.php
index d51e3d0..8cac9f4 100644
--- a/application/models/project.php
+++ b/application/models/project.php
@@ -102,7 +102,7 @@ class Project extends CI_Model {
*
* @param array $project_id The project to get the configuration from.
*/
- public function get_configurations($project_id) {
+ public function getConfigurations($project_id) {
$query = $this->db->get_where('configurations', array('project_id' => $project_id));
$configurations = $query->result_array();
diff --git a/application/models/server.php b/application/models/server.php
index b4d8570..811829c 100644
--- a/application/models/server.php
+++ b/application/models/server.php
@@ -10,7 +10,7 @@ class Server extends CI_Model {
*
* @return array List of all available servers.
*/
- public function get_all() {
+ public function getAll() {
return $this->db->get('servers')->result_array();
}
@@ -19,7 +19,7 @@ class Server extends CI_Model {
*
* @return array List of servers that could handle another job.
*/
- public function get_idle() {
+ public function getIdle() {
return $this->db->get_where('servers', 'workload <= 2')->result_array();
}
@@ -32,9 +32,19 @@ class Server extends CI_Model {
* @param type $secret The server's secret for basic authentication.
* @param type $workload The server's workload.
*/
- public function update_workload($secret, $workload) {
+ public function updateWorkload($secret, $workload) {
$this->db->query("UPDATE `servers` SET `workload`=".$this->db->escape($workload)
. ", `last_update`=NOW()"
. " WHERE `secret`=".$this->db->escape($secret));
}
+
+ /**
+ * Get the best suiting server for a new job.
+ *
+ * @todo not yet verified.
+ */
+ public function getBestServer() {
+ return $this->db->limit(1)->order_by('last_update', 'desc')->
+ get_where('servers', 'workload <= 2')->row_array();
+ }
}
diff --git a/application/views/index.php b/application/views/index.php
index a4cd6d6..24878ce 100644
--- a/application/views/index.php
+++ b/application/views/index.php
@@ -98,7 +98,7 @@ function logout() {
function loadProjectInfo(n) {
if(n.isLeaf()){
Ext.Ajax.request({
- url: BASE_URL + 'projects/detail' + n.id,
+ url: BASE_URL + 'projects/detail/' + n.prjId,
method: 'get',
success: function ( result, request ) {
@@ -107,21 +107,10 @@ function loadProjectInfo(n) {
tabPanel.add({
title: 'New Tab ',
html: 'Lade Projekt...',
- closable:true,
- handler: function(){
- alert("foo");
- var data = theResponse.result;
- var tpl = new Ext.Template(
- 'ID: {id}
',
- 'Name: {name}
'
- );
-
- tpl.overwrite(this.html, data);
- }
+ closable:true
}).show();
},
failure: function ( result, request ) {
- //Ext.MessageBox.alert("Fehler!", "Das gewünschte Projekt kann nicht geladen werden.");
switch(result.status) {
case 404:
Ext.MessageBox.alert("Fehler", "Das gewünschte Projekt konnte nicht gefunden werden.");