Skip to content

Commit 97cbab9

Browse files
committed
Some fixes and improvements
1 parent c4807d1 commit 97cbab9

File tree

8 files changed

+147
-2
lines changed

8 files changed

+147
-2
lines changed

languages/en.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@
6666
'UsageExample' => 'Usage example',
6767
'CurrentUserToken' => 'Current user token',
6868
'TokenNote' => 'The token will be reset if you press Logout.',
69+
'Settings' => 'Settings',
70+
'Parameter' => 'Parameter',
71+
'Value' => 'Value',
6972
'UnknownError' => 'Unknown error',
7073
'InvalidUserPasswd' => 'Invalid user name or password!',
7174
'AddPermissions' => 'Add permissions',

languages/ru.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@
6666
'UsageExample' => 'Пример использования',
6767
'CurrentUserToken' => 'Токен текущего пользователя',
6868
'TokenNote' => 'Токен будет обнулен, если вы разлогинетесь нажав Выход.',
69+
'Settings' => 'Настройки',
70+
'Parameter' => 'Параметр',
71+
'Value' => 'Значение',
6972
'UnknownError' => 'Неизвестная ошибка',
7073
'InvalidUserPasswd' => 'Неправильное имя пользователя или пароль!',
7174
'AddPermissions' => 'Добавление прав доступа',

modules/AnsibleAWX.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ public function get_job($id)
775775
{
776776
$job_info['workflow_nodes'][] = array(
777777
'job_id' => $workflow_node['summary_fields']['job']['id'],
778-
'name' => $workflow_node['summary_fields']['job']['name'],
778+
'name' => $workflow_node['summary_fields']['unified_job_template']['name'],
779779
'status' => $workflow_node['summary_fields']['job']['status']
780780
);
781781
}
@@ -788,9 +788,24 @@ public function get_job($id)
788788
public function get_activity($guid)
789789
{
790790
$activity_info = array(
791-
'guid' => $guid
791+
'guid' => $guid,
792+
'params' => array()
792793
);
793794

795+
$job_data = $this->awx_api_request('GET', '/api/v2/jobs/' . $guid . '/');
796+
797+
$extra_vars = json_decode($job_data['extra_vars'], TRUE);
798+
if($extra_vars !== FALSE)
799+
{
800+
foreach($extra_vars as $var => $value)
801+
{
802+
$activity_info['params'][] = array(
803+
'name' => $var,
804+
'value' => is_array($value) ? implode(', ', $value) : $value
805+
);
806+
}
807+
}
808+
794809
$result = $this->awx_api_request('GET', '/api/v2/jobs/' . $guid . '/stdout/?format=ansi', NULL, TRUE);
795810

796811
if($result !== FALSE && !empty($result))

routes/setting_get.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
function setting_get(&$core, $params, $post_data)
4+
{
5+
$user_id = intval(@$params[1]);
6+
$setting_key = @$params[2];
7+
8+
assert_permission_ajax(0, RB_ACCESS_EXECUTE);
9+
10+
if($user_id)
11+
{
12+
$setting_value = $core->Config->get_user($setting_key, '');
13+
}
14+
else
15+
{
16+
$setting_value = $core->Config->get_global($setting_key, '');
17+
}
18+
19+
$result_json = array(
20+
'code' => 0,
21+
'message' => '',
22+
'title' => LL('Edit'),
23+
'action' => 'setting_save',
24+
'fields' => array(
25+
array(
26+
'type' => 'hidden',
27+
'name' => 'uid',
28+
'value' => $user_id
29+
),
30+
array(
31+
'type' => 'readonly',
32+
'name' => 'key',
33+
'title' => LL('Parameter').'*',
34+
'value' => $setting_key
35+
),
36+
array(
37+
'type' => preg_match('/_json$/i', $setting_key) ? 'text' : 'string',
38+
'name' => 'value',
39+
'title' => LL('Value').'*',
40+
'value' => $setting_value
41+
)
42+
)
43+
);
44+
45+
echo json_encode($result_json);
46+
}

routes/setting_save.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
/**
3+
* @file setting_save.php
4+
* @brief При сохранении параметра оканчивающегося на _json производится
5+
* попытка распарсить значение, чтобы исключить опечатки в формате.
6+
*/
7+
8+
function setting_save(&$core, $params, $post_data)
9+
{
10+
$result_json = array(
11+
'code' => 0,
12+
'message' => '',
13+
'errors' => array()
14+
);
15+
16+
assert_permission_ajax(0, RB_ACCESS_EXECUTE);
17+
18+
$user_id = intval(@$post_data['uid']);
19+
$setting_key = @$post_data['key'];
20+
$setting_value = @$post_data['value'];
21+
22+
if(!empty($setting_value) && preg_match('/_json$/i', $setting_key))
23+
{
24+
if(json_decode($setting_value, TRUE) === NULL)
25+
{
26+
$result_json['code'] = 1;
27+
$result_json['message'] = 'Failed parse JSON value. ERROR: '.json_last_error_msg();
28+
29+
echo json_encode($result_json, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
30+
31+
return;
32+
}
33+
}
34+
35+
if($user_id)
36+
{
37+
$core->Config->set_user($setting_key, $setting_value);
38+
}
39+
else
40+
{
41+
$core->Config->set_global($setting_key, $setting_value);
42+
}
43+
44+
log_db('Updated settings', '{uid='.$user_id.',key="'.$setting_key.',value="'.$setting_value.'"}', 0);
45+
$result_json['message'] = LL('SuccessfulUpdated');
46+
47+
echo json_encode($result_json, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
48+
}

routes/tools.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22

33
function tools(&$core, $params, $post_data)
44
{
5+
$core->db->select_assoc_ex($config, rpv('SELECT m.`uid`, m.`name`, m.`value`, m.`description` FROM @config AS m WHERE m.`uid` = 0 OR m.`uid` = # ORDER BY m.`uid`, m.`name`', $core->UserAuth->get_id()));
6+
57
include(TEMPLATES_DIR.'tpl.tools.php');
68
}

templates/tpl.tools.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,30 @@
4747
<a href="<?php ln('password_change_form'); ?>" onclick="return f_show_form(this.href);"><?php L('ChangePassword') ?></a><br />
4848
<?php } ?>
4949

50+
<!--
51+
<h3><?php L('Settings') ?></h3>
52+
53+
<table id="table" class="main-table">
54+
<thead>
55+
<tr>
56+
<th width="1%">UID</th>
57+
<th width="20%"><?php L('Name') ?></th>
58+
<th width="40%"><?php L('Value') ?></th>
59+
<th width="39%"><?php L('Description') ?></th>
60+
</tr>
61+
</thead>
62+
<tbody id="table-data">
63+
<?php foreach($config as &$row) { ?>
64+
<tr>
65+
<td><?php eh($row['uid']); ?></td>
66+
<td><span class="command" onclick="f_show_form('<?php ln('setting_get/'.$row['uid'].'/'.$row['name']) ?>');"><?php eh($row['name']); ?></span></td>
67+
<td><pre><?php eh($row['value']); ?></pre></td>
68+
<td><pre><?php eh($row['description']); ?></pre></td>
69+
</tr>
70+
<?php } ?>
71+
</tbody>
72+
</table>
73+
-->
74+
5075
<?php include(TEMPLATES_DIR.'tpl.universal-form.php'); ?>
5176
<?php include(TEMPLATES_DIR.'tpl.footer.php'); ?>

websco.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,9 @@ function exception_handler_ajax($exception)
292292
$core->Router->add_route('complete_group', 'complete_group', TRUE);
293293
$core->Router->add_route('complete_group_sam', 'complete_group_sam', TRUE);
294294

295+
$core->Router->add_route('setting_get', 'setting_get', TRUE);
296+
$core->Router->add_route('setting_save', 'setting_save', TRUE);
297+
295298
$core->Router->add_route('tools', 'tools');
296299

297300
$core->Router->add_route('folder_hide', 'folder_hide', TRUE);

0 commit comments

Comments
 (0)