From 08e8fab6635cda5808ac4bd53522f4e9058cc44a Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Thu, 3 Aug 2017 21:42:52 +0200 Subject: [PATCH] #352 basic functionallity with qqs - not web query yet --- js/saimod_webcraft_updates.js | 77 +---------------------- saimod_webcraft_updates.php | 36 +++++++++-- sql/mysql/system_api.sql | 11 +--- sql/mysql/system_page.sql | 2 +- sql/qq/MOJOTROLLZ_SERVER_LIST_ALL.php | 8 --- sql/qq/SAIMOD_MOJOTROLLZ_DEL.php | 8 --- sql/qq/SAIMOD_MOJOTROLLZ_SAVE.php | 8 --- sql/qq/SAIMOD_MOJOTROLLZ_VISIBLE.php | 8 --- sql/qq/WEBCRAFT_UPDATES_COMMIT.php | 10 +++ sql/qq/WEBCRAFT_UPDATES_COMMIT_SELECT.php | 9 +++ sql/qq/WEBCRAFT_UPDATES_PROJECT.php | 10 +++ sql/qq/WEBCRAFT_UPDATES_UPDATE.php | 12 ++++ tpl/saimod_webcraft_updates.tpl | 37 +---------- tpl/saimod_webcraft_updates_commit.tpl | 6 ++ tpl/saimod_webcraft_updates_commits.tpl | 11 ++++ tpl/saimod_webcraft_updates_project.tpl | 5 ++ tpl/saimod_webcraft_updates_projects.tpl | 10 +++ tpl/saimod_webcraft_updates_update.tpl | 6 ++ 18 files changed, 117 insertions(+), 157 deletions(-) delete mode 100644 sql/qq/MOJOTROLLZ_SERVER_LIST_ALL.php delete mode 100644 sql/qq/SAIMOD_MOJOTROLLZ_DEL.php delete mode 100644 sql/qq/SAIMOD_MOJOTROLLZ_SAVE.php delete mode 100644 sql/qq/SAIMOD_MOJOTROLLZ_VISIBLE.php create mode 100644 sql/qq/WEBCRAFT_UPDATES_COMMIT.php create mode 100644 sql/qq/WEBCRAFT_UPDATES_COMMIT_SELECT.php create mode 100644 sql/qq/WEBCRAFT_UPDATES_PROJECT.php create mode 100644 sql/qq/WEBCRAFT_UPDATES_UPDATE.php create mode 100644 tpl/saimod_webcraft_updates_commit.tpl create mode 100644 tpl/saimod_webcraft_updates_commits.tpl create mode 100644 tpl/saimod_webcraft_updates_project.tpl create mode 100644 tpl/saimod_webcraft_updates_projects.tpl create mode 100644 tpl/saimod_webcraft_updates_update.tpl diff --git a/js/saimod_webcraft_updates.js b/js/saimod_webcraft_updates.js index b068e58..d963607 100644 --- a/js/saimod_webcraft_updates.js +++ b/js/saimod_webcraft_updates.js @@ -1,76 +1 @@ -function init_saimod_mojotrollz_vote() { - register_server_edit(); - register_server_visible(); - register_server_del(); - register_server_save(); -}; - -function register_server_edit(){ - $('.btn_server_edit').click(function(){ - $('#input_id').val($(this).attr('_id')); - $('#input_name').val($(this).attr('_name')); - $('#input_url').val($(this).attr('_url')); - $('#input_version').val($(this).attr('_version')); - $('#input_description').val($(this).attr('_description')); - $("#btn_server_save").focus(); - }); -} - -function register_server_visible(){ - $('.btn_server_visible').click(function(){ - $.ajax({ type :'GET', - url : './sai.php?sai_mod=.SAI.saimod_mojotrollz_vote&action=visible'+ - '&id='+$(this).attr('_id')+ - '&visible='+$('#select_visible_'+$(this).attr('_i')).val(), - success : function(data) { - if(data.status){ - system.reload(); - }else{ - alert('Problem: '+data);} - } - }); - }); -} - -function register_server_del(){ - $('.btn_server_del').click(function(){ - if (confirm("Delete Server Permanently?") === true) { - $.ajax({ type :'GET', - url : './sai.php?sai_mod=.SAI.saimod_mojotrollz_vote&action=del'+ - '&id='+$(this).attr('_id'), - success : function(data) { - if(data.status){ - system.reload(); - }else{ - alert('Problem: '+data);} - } - }); - } - }); -} - -function register_server_save(){ - $('#btn_server_save').click(function() { - var id = $('#input_id').val(); - var name = $('#input_name').val(); - var url = $('#input_url').val(); - var version = $('#input_version').val(); - var description = $('#input_description').val(); - $.ajax({url: './sai.php', - data: { sai_mod: '.SAI.saimod_mojotrollz_vote', - action: 'save', - id: id, - name: name, - url: url, - version: version, - description: description}, - type: 'GET', - success: function(data) { - if(data.status){ - system.reload(); - }else{ - alert('Problem: '+data);} - } - }); - }); -} \ No newline at end of file +function init_saimod_webcraft_updates() {}; \ No newline at end of file diff --git a/saimod_webcraft_updates.php b/saimod_webcraft_updates.php index bad3e38..c9345fc 100644 --- a/saimod_webcraft_updates.php +++ b/saimod_webcraft_updates.php @@ -1,15 +1,43 @@ '', 'projects' => '', 'commits' => ''); + + $res = \SQL\WEBCRAFT_UPDATES_UPDATE::QQ(array('test/mojotrollz/%')); + while($row = $res->next()){ + $row['time'] = \SYSTEM\time::time_ago_string(strtotime($row['time'])); + $vars['updates'] .= \SYSTEM\PAGE\replace::replaceFile((new \PSAI('saimod_webcraft_updates/tpl/saimod_webcraft_updates_update.tpl'))->SERVERPATH(),$row);} + + $project_row = null; + if($update){ + $vars2 = array('project' => '', 'update' => $update); + $res = \SQL\WEBCRAFT_UPDATES_PROJECT::QQ(array($update, 'test/mojotrollz/%')); + while($row = $res->next()){ + if($project && $row['path'] == $project){ + $project_row = $row;} + $row['time'] = \SYSTEM\time::time_ago_string(strtotime($row['time'])); + $vars2['project'] .= \SYSTEM\PAGE\replace::replaceFile((new \PSAI('saimod_webcraft_updates/tpl/saimod_webcraft_updates_project.tpl'))->SERVERPATH(),$row);} + $vars['projects'] = \SYSTEM\PAGE\replace::replaceFile((new \PSAI('saimod_webcraft_updates/tpl/saimod_webcraft_updates_projects.tpl'))->SERVERPATH(),$vars2); + } + + if($project){ + $vars3 = array('commit' => '', 'project' => $project); + $min = \SQL\WEBCRAFT_UPDATES_COMMIT_SELECT::Q1(array($project_row['git'],$project_row['commit_last']))['id']+1; + $max = \SQL\WEBCRAFT_UPDATES_COMMIT_SELECT::Q1(array($project_row['git'],$project_row['commit']))['id']; + $res = \SQL\WEBCRAFT_UPDATES_COMMIT::QQ(array($project_row['git'],$min,$max)); + while($row = $res->next()){ + $row['time'] = \SYSTEM\time::time_ago_string(strtotime($row['time'])); + $vars3['commit'] .= \SYSTEM\PAGE\replace::replaceFile((new \PSAI('saimod_webcraft_updates/tpl/saimod_webcraft_updates_commit.tpl'))->SERVERPATH(),$row);} + $vars['commits'] = \SYSTEM\PAGE\replace::replaceFile((new \PSAI('saimod_webcraft_updates/tpl/saimod_webcraft_updates_commits.tpl'))->SERVERPATH(),$vars3); + } + + $vars = array_merge($vars, \SYSTEM\PAGE\text::tag('time')); return \SYSTEM\PAGE\replace::replaceFile((new \PSAI('saimod_webcraft_updates/tpl/saimod_webcraft_updates.tpl'))->SERVERPATH(),$vars);} public static function html_li_menu(){return '';} public static function right_public(){return false;} public static function right_right(){return \SYSTEM\SECURITY\security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);} - /*public static function css(){ - return array((new \SYSTEM\PSAI('modules/saistart_sys_sai/css/saistart_sys_sai.css'));}*/ public static function js(){ return array(new \PSAI('saimod_webcraft_updates/js/saimod_webcraft_updates.js'));} } \ No newline at end of file diff --git a/sql/mysql/system_api.sql b/sql/mysql/system_api.sql index f1c60e4..7281a7c 100644 --- a/sql/mysql/system_api.sql +++ b/sql/mysql/system_api.sql @@ -1,9 +1,2 @@ -REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5011, 42, 2, 5000, 'visible', 'visible', 'INT'); -REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5010, 42, 2, 5000, 'visible', 'id', 'INT'); -REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5008, 42, 2, 5000, 'del', 'id', 'INT'); -REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5005, 42, 2, 5000, 'save', 'description', 'STRING'); -REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5004, 42, 2, 5000, 'save', 'version', 'INT'); -REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5003, 42, 2, 5000, 'save', 'url', 'STRING'); -REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5002, 42, 2, 5000, 'save', 'name', 'STRING'); -REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5001, 42, 2, 5000, 'save', 'id', 'INT'); -REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5000, 42, 0, 0, '_SAI_saimod_mojotrollz_vote', 'action', NULL); \ No newline at end of file +REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (6000, 42, 3, 0, '_SAI_saimod_webcraft_updates', 'update', 'STRING'); +REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (6001, 42, 3, 0, '_SAI_saimod_webcraft_updates', 'project', 'STRING'); \ No newline at end of file diff --git a/sql/mysql/system_page.sql b/sql/mysql/system_page.sql index 8e9e15c..322608d 100644 --- a/sql/mysql/system_page.sql +++ b/sql/mysql/system_page.sql @@ -1 +1 @@ -REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (600, 42, 'updates', 'updates', -1, 0, 0, '#content', './sai.php?sai_mod=.SAI.saimod_webcraft_updates', 'init_saimod_webcraft_updates', '\\SAI\\saimod_webcraft_updates'); \ No newline at end of file +REPLACE INTO `system_page` (`id`, `group`, `name`, `state`, `parent_id`, `login`, `type`, `div`, `url`, `func`, `php_class`) VALUES (600, 42, 'updates', 'updates', -1, 0, 0, '#content', './sai.php?sai_mod=.SAI.saimod_webcraft_updates&update=${update}&project=${project}', 'init_saimod_webcraft_updates', '\\SAI\\saimod_webcraft_updates'); \ No newline at end of file diff --git a/sql/qq/MOJOTROLLZ_SERVER_LIST_ALL.php b/sql/qq/MOJOTROLLZ_SERVER_LIST_ALL.php deleted file mode 100644 index f356a2e..0000000 --- a/sql/qq/MOJOTROLLZ_SERVER_LIST_ALL.php +++ /dev/null @@ -1,8 +0,0 @@ - ${updates} -
-

Commits of Update ${update}

- - - - - - - - ${update_commits} -
timeauthorlogcommit
-
-

Projects of Update ${update}

- - - - - - - - - - ${projects} -
timepathgit
-
-

Commits of Project ${project}

- - - - - - - - ${commits} -
timeauthorlogcommit
+ ${projects} + ${commits} diff --git a/tpl/saimod_webcraft_updates_commit.tpl b/tpl/saimod_webcraft_updates_commit.tpl new file mode 100644 index 0000000..c0c6319 --- /dev/null +++ b/tpl/saimod_webcraft_updates_commit.tpl @@ -0,0 +1,6 @@ + + ${time} + ${author} + ${log} + ${commit} + \ No newline at end of file diff --git a/tpl/saimod_webcraft_updates_commits.tpl b/tpl/saimod_webcraft_updates_commits.tpl new file mode 100644 index 0000000..918d5d4 --- /dev/null +++ b/tpl/saimod_webcraft_updates_commits.tpl @@ -0,0 +1,11 @@ +
+

Commits of Project ${project}

+ + + + + + + + ${commit} +
timeauthorlogcommit
\ No newline at end of file diff --git a/tpl/saimod_webcraft_updates_project.tpl b/tpl/saimod_webcraft_updates_project.tpl new file mode 100644 index 0000000..8650778 --- /dev/null +++ b/tpl/saimod_webcraft_updates_project.tpl @@ -0,0 +1,5 @@ + + ${time} + ${path} + ${git} + \ No newline at end of file diff --git a/tpl/saimod_webcraft_updates_projects.tpl b/tpl/saimod_webcraft_updates_projects.tpl new file mode 100644 index 0000000..2be8307 --- /dev/null +++ b/tpl/saimod_webcraft_updates_projects.tpl @@ -0,0 +1,10 @@ +
+

Projects of Update ${update}

+ + + + + + + ${project} +
timepathgit
\ No newline at end of file diff --git a/tpl/saimod_webcraft_updates_update.tpl b/tpl/saimod_webcraft_updates_update.tpl new file mode 100644 index 0000000..a28b789 --- /dev/null +++ b/tpl/saimod_webcraft_updates_update.tpl @@ -0,0 +1,6 @@ + + ${time} + ${commit} + ${commit_last} + ${complete} + \ No newline at end of file