-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathdefault.cshtml
More file actions
200 lines (187 loc) · 8.17 KB
/
default.cshtml
File metadata and controls
200 lines (187 loc) · 8.17 KB
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
191
192
193
194
195
196
197
198
199
200
@layout ""
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Email Contacts</title>
<script type="text/javascript" src="Scripts/jquery-3.2.1.js"></script>
<script type="text/javascript" src="Scripts/bootstrap.js"></script>
<script type="text/javascript" src="/js/ss-utils.js"></script>
<link href="Content/default.css" rel="stylesheet" />
<link href="Content/bootstrap.css" rel="stylesheet" />
<link href="Content/bootstrap-theme.css" rel="stylesheet" />
<style type="text/css">
body {
margin: 20px;
color: #444;
}
[data-click] {
cursor: pointer;
padding: 0 10px;
font-size: 18px;
}
span[data-click] {
color: #999;
}
span[data-click]:hover {
color: #333;
}
#email-contact .rotate {
visibility: hidden;
font-size: 18px;
margin: 0 0 0 10px;
}
#email-contact .loading .rotate {
visibility: visible;
}
</style>
</head>
<body>
<a href="https://github.com/ServiceStackApps/LiveDemos"><h1 class="glyphicon glyphicon-send" style="float:left; margin:0 10px 0 0; color: #444"></h1></a>
<h1>Email Contacts</h1>
<a href="https://github.com/ServiceStackApps/EmailContacts" style="position:absolute; top: 10px; right: 10px">docs</a>
<div class="clearfix"></div>
<h3 class="glyphicon glyphicon-plus" style="float:left; padding: 0 10px 0 0; line-height: 80%"></h3>
<h3>Add Contact</h3>
<div class="clearfix"></div>
<form id="form-addcontact" action="@(new CreateContact().ToPostUrl())" method="POST">
<div class="row">
<div class="col-sm-3 form-group">
<label for="Name">Name</label>
<input class="form-control input-sm" type="text" id="Name" name="Name" value="" placeholder="">
<span class="help-block"></span>
</div>
<div class="col-sm-3 form-group">
<label for="Email">Email</label>
<input class="form-control input-sm" type="text" id="Email" name="Email" value="" placeholder="">
<span class="help-block"></span>
</div>
<div class="col-sm-3 form-group">
<label for="Age">Age</label>
<input class="form-control input-sm" type="text" id="Age" name="Age" value="" placeholder="">
<span class="help-block"></span>
</div>
<div class="col-sm-1 form-group">
<label> </label><br/>
<button class="btn btn-sm btn-default" type="submit">Create Contact</button>
</div>
</div>
<div class="clearfix"></div>
</form>
<div class="col-sm-3">
<h3>Contacts</h3>
<ul id="contacts" class="nav"></ul>
</div>
<div id="email-contact" class="col-sm-7" style="display: none; border-bottom: 1px solid #ccc; padding: 0 0 10px 0; margin: 0 0 10px 0;">
<div class='glyphicon glyphicon-envelope' style='float: left; font-size: 65px; line-height: 65px; margin: 15px 20px 0 0'></div>
<h3>
Email <span data-html="Name"></span>
</h3>
<h4>To: <span data-html="Email"></span></h4>
<div class="clearfix"></div>
<form id="form-emailcontact" method="POST"
action="@(new EmailContact().ToPostUrl())"
data-action-alt="@(new EmailContact().ToOneWayUrl())">
<div class="alert alert-success" style="display:none"></div>
<input type="hidden" name="ContactId" data-val="Id" />
<div class="form-group">
<label for="Subject">Subject</label>
<input class="form-control input-sm" type="text" id="Subject" name="Subject" value="" placeholder="">
<span class="help-block"></span>
</div>
<div class="form-group">
<label for="Body">Body</label>
<textarea class="form-control" type="text" id="Body" name="Body"></textarea>
<span class="help-block"></span>
</div>
<div class="form-group">
<div style="float:right">
<input type="checkbox" id="chkAction" data-click="toggleAction" />
<label for="chkAction">Email via MQ</label>
</div>
<label> </label><br/>
<button class="btn btn-lg btn-default" type="submit">Email Contact</button>
<div class='glyphicon glyphicon-repeat rotate'></div>
</div>
<div class="clearfix"></div>
</form>
</div>
<div class="col-sm-3"></div>
<div id="email-history" class="col-sm-7" style="display:none;">
<h3>Email History</h3>
<table class="table table-striped" style="width: 100%;">
<thead>
<th>Id</th>
<th>To</th>
<th>Subject</th>
</thead>
<tbody></tbody>
</table>
</div>
</body>
<script>
$("input").change($.ss.clearAdjacentError);
$.getJSON("/contacts", addContacts);
refreshEmailHistory();
function addContacts(contacts) {
var html = contacts.map(function (c) {
return "<li data-id='" + c.Id + "' data-click='showContact'>" +
"<span class='glyphicon glyphicon-user' style='margin: 0 5px 0 0'></span>" +
c.Name + " " + " (" + c.Age + ")" +
'<span class="glyphicon glyphicon-remove-circle" data-click="deleteContact"></span>' +
"</li>";
});
$("#contacts").append(html.join(''));
}
function refreshEmailHistory() {
$.getJSON("/emails", function (emails) {
if (emails.length > 0) {
$("#email-history").show().find("TABLE tbody").html(
emails.map(function(email) {
return "<tr>" +
"<td>" + email.Id + "</td>" +
"<td>" + email.To + "</td>" +
"<td>" + email.Subject + "</td>" +
"</tr>";
}));
}});
}
$("#form-addcontact").bindForm({
success: function (contact) {
addContacts([contact]);
$("#form-addcontact input").val('')
.first().focus();
}
});
$("#form-emailcontact").bindForm({
success: function (request) {
$("#form-emailcontact .form-control").val('')
.parents("form").find('.alert-success')
.html('Email was sent to ' + (request.Email || "MQ"))
.show();
refreshEmailHistory();
}
});
$(document).bindHandlers({
showContact: function() {
var id = $(this).data("id");
$.getJSON("/contacts/" + id, function (contact) {
$("#email-contact")
.applyValues(contact)
.show();
$("#form-emailcontact .alert-success").hide();
});
},
deleteContact: function () {
var $li = $(this).closest("li");
$.post("/contacts/" + $li.data("id") + "/delete", function () {
$li.remove();
});
},
toggleAction: function() {
var $form = $(this).closest("form"), action = $form.attr("action");
$form.attr("action", $form.data("action-alt"))
.data("action-alt", action);
}
});
</script>
</html>