forked from awslabs/amazon-redshift-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConfigurationForm.html
190 lines (161 loc) · 7.59 KB
/
ConfigurationForm.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="robots" content="noindex, nofollow">
<meta name="googlebot" content="noindex, nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" src="/js/lib/dummy.js"></script>
<link rel="stylesheet" type="text/css" href="/css/result-light.css">
<script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-serialize-object/2.5.0/jquery.serialize-object.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/parsley.js/2.8.0/parsley.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://rawgit.com/guillaumepotier/Parsley.js/2.8.0/bower_components/bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="https://rawgit.com/guillaumepotier/Parsley.js/2.8.0/doc/assets/docs.css">
<link rel="stylesheet" type="text/css" href="https://rawgit.com/guillaumepotier/Parsley.js/2.8.0/src/parsley.css">
<style type="text/css">
#output {
white-space: pre-wrap;
font-family: monospace; font-size: 16px; font-style: normal;
}
input[type="text"] {
width: 40%;
}
input[type="number"] {
width: 40%;
}
input {
margin: 5px;
}
label {
margin: 5px;
}
</style>
<title></title>
<script type='text/javascript'>//<![CDATA[
window.onload=function(){
// Validate
$('#config-form').parsley().on('field:validated', function() {
// Validate and show validators
var ok = $('.parsley-error').length === 0;
$('.bs-callout-info').toggleClass('hidden', !ok);
$('.bs-callout-warning').toggleClass('hidden', ok);
if (ok) { // Serialize into JSON and add to output DIV
var formObj = $('form#config-form').serializeObject();
var config = formObj['configuration'];
// remove unconfigured options
if (config['table_whitelist'] == "") {
delete config['table_whitelist'];
}
if (config['blacklisted_tables'] == "") {
delete config['blacklisted_tables'];
}
if (config['target_schema'] == "") {
delete config['target_schema'];
}
if (config['table_name'] == "") {
delete config['table_name'];
}
if (config['kms_auth_context'] == "") {
delete config['kms_auth_context'];
}
if (config['s3_unload_location'] == "") {
delete config['s3_unload_location'];
}
config['comprows'] = -1;
config['ignore_errors'] = true;
config['query_group'] = "";
config['query_slot_count'] = 1;
config['force'] = false;
config['output_file'] = "/tmp/redshift-automation.log";
config['debug'] = false;
config['do_execute'] = true;
config['analyze_col_width'] = 1;
config['threads'] = 1;
config['ssl'] = true;
config['do_analyze'] = true;
config['do_vacuum'] = true;
config['agg_interval'] = "1 hour";
// add defaults
formObj.utilities = ["ColumnEncodingUtility", "AnalyzeVacuumUtility", "Monitoring", "SystemTablePersistence"];
// re-add the configuration
formObj['configuration'] = config;
var formStringPretty = JSON.stringify(formObj, undefined, 4);
$('div#output').text(formStringPretty);
}
})
.on('form:submit', function() {
return false; // Don't submit form for this demo
});
}//]]>
</script>
</head>
<body>
<!-- all of these will work! -->
<div class="bs-callout bs-callout-warning hidden">
<h4>Oh snap!</h4>
<p>This form seems to be invalid :(</p>
</div>
<form id="config-form" data-parsley-validate="">
<label for="clusterName">Cluster Name * :</label>
<input type="text" class="form-control" name="configuration[cluster_name]" required="true" data-parsley-required="true" data-parsley-trigger="change" value="my-cluster">
<label for="dnsName">Cluster Endpoint * :</label>
<input type="text" class="form-control" name="configuration[db_host]" required="true" data-parsley-trigger="change" value="my-cluster.XXXXXX.redshift.amazonaws.com">
<label for="hostPort">Cluster Port * :</label>
<input type="number" class="form-control" name="configuration[db_port]" data-parsley-type="integer" data-parsley-trigger="change" required="true" min="1024" max="65535" value="5439">
<label for="userName">Username * :</label>
<input type="text" class="form-control" name="configuration[db_user]" required="true" data-parsley-trigger="change" value="master">
<label for="encryptedPassword">Base64 Encoded/Encrypted Password * :</label>
<input type="text" class="form-control" name="configuration[encrypted_pwd]" required="true" data-parsley-trigger="change" value="my encrypted password">
<label for="authContext">KMS Authorisation Context JSON:</label>
<input type="text" class="form-control" name="configuration[kms_auth_context]" data-parsley-required="false" data-parsley-trigger="change">
<label for="dbName">Database Name * :</label>
<input type="text" class="form-control" name="configuration[db]" required="true" data-parsley-trigger="change" value="master">
<label for="sourceSchema">Source Schema * :</label>
<input type="text" class="form-control" name="configuration[schema_name]" required="true" data-parsley-trigger="change" value="public">
<label for="systableUnloadLoc">System Tables S3 Unload Location :</label>
<input type="text" class="form-control" name="configuration[s3_unload_location]" data-parsley-required="false" data-parsley-trigger="change" value="">
<label for="systableUnloadRoleArn">System Tables Unload Role ARN :</label>
<input type="text" class="form-control" name="configuration[s3_unload_role_arn]" data-parsley-trigger="change" value="arn:aws:iam::<your account number>:role/<role name>">
<hr/>
<label>Table Analyze Options</label>
<br>
<br>
<label for="tableWhitelist">Restrict to Table Name:</label>
<input type="text" class="form-control" name="configuration[table_name]" data-parsley-required="false" data-parsley-trigger="change">
<label for="blacklistedTables">Blacklisted Tables :</label>
<input type="text" class="form-control" name="configuration[blacklisted_tables]" data-parsley-required="false" data-parsley-trigger="change">
<hr/>
<label>Automated Column Encoding Options</label>
<br>
<br>
<label for="targetSchema">Target Schema :</label>
<input type="text" class="form-control" name="configuration[target_schema]" data-parsley-required="false" data-parsley-trigger="change">
<label for="dropOldData">Drop old (unencoded) data tables? * :</label>
<select name="configuration[drop_old_data]" required="true" data-parsley-trigger="change" value="false">
<option value="false">False</option>
<option value="true">True</option>
</select>
<hr>
<br>
<label for="cleanupAfter">System Table Retention Period (Days - 0 means keep forever) :</label>
<input type="number" class="form-control" name="configuration[systable_cleanup_after_days]" data-parsley-required="false" data-parsley-trigger="change" min="0" value="0">
<hr>
<br>
<input type="submit" class="btn btn-default" value="Validate Configuration">
</form>
<br/> Redshift Automation Configuration - place this file in S3!
<br/>
<div id="output">
</div>
<script>
// tell the embed parent frame the height of the content
if (window.parent && window.parent.parent){
window.parent.parent.postMessage(["resultsFrame", {
height: document.body.getBoundingClientRect().height,
slug: "xnjLcw2L"
}], "*")
}
</script>
</body>
</html>