-
Notifications
You must be signed in to change notification settings - Fork 3
/
admin.html
531 lines (524 loc) · 24.6 KB
/
admin.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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
<div class="ui segment basic container">
<div class="ui breadcrumb">
<a class="section">{{CONST.APP_NAME}}</a>
<i class="right angle icon divider"></i>
<div class="active section">Administrator</div>
</div>
<div class="ui top attached tabular menu">
<a data-tab="services" class="item active">
Services/Products
</a>
<a data-tab="notification" class="item">
Notification
</a>
</div>
<div data-tab="services" class="ui tab bottom attached segment active">
<div class="ui orange segment">
<h4 class="ui header orange" style="padding: 0.5rem;">
Platforms
</h4>
<div class="ui grid admin cards">
<!--<div class="column ui card">
<div class="ui dimmer">
<div class="content">
<div class="center">
<div class="ui inverted button centerr"><i class="icon angle double down"></i></div>
<div class="ui green inverted button"><i class="icon plus"></i></div>
</div>
</div>
</div>
<div class="blurring dimmable image">
<img src="public/images/twitter.png">
</div>
<div class="content">
<a class="header">Azure</a>
<div class="meta">
<span class="date">Create in Sep 2014</span>
</div>
</div>
<div class="extra content">
<a>
<i class="users icon"></i> 2 Members
</a>
</div>
</div>-->
<admin-card ng-repeat="p in TopicWithForum" ng-init="$last && renderDimmer()">
<!--<platform-card-content></platform-card-content>-->
<div class="ui card" ng-class="{'active':isSelectedPlatform(p.platform_Name)}">
<div class="ui hover dimmer">
<div class="content">
<div class="center">
<!--<div class="ui mini buttons">-->
<div class="ui mini inverted button center" ng-click="selectPlatform($index)"><i class="icon angle double down"></i></div>
<!--<div class="ui green inverted button"><i class="icon plus"></i></div>-->
<!--</div>-->
</div>
</div>
</div>
<div class="ui unfocus dimmer">
</div>
<div class="blurring dimmable image" style="background:#fff">
<img ng-src="public/images/{{p.platform_Name}}.png">
</div>
<div class="content">
<a class="header">{{p.platform_Name}}</a>
</div>
</div>
</admin-card>
</div>
</div>
<div class="ui violet segment" ng-show="selectedPlatformIndex!==undefined">
<h4 class="ui header violet" style="padding: 0.5rem;">
Services / Products
</h4>
<div class="ui equal width grid admin cards">
<admin-card ng-repeat="t in TopicWithForum[selectedPlatformIndex].topics" ng-init="$last && renderDimmer()">
<div class="ui card" ng-class="{'active':isSelectedTopic(t.topic)}">
<div class="content">
<a class="header text center" fittext="t.topic" height="23" style="line-height: 23px;">{{t.topic}}</a>
<div class="ui hover dimmer">
<div class="content">
<div class="center">
<div class="ui mini buttons">
<div class="ui mini inverted button center" ng-click="selectTopic($index)"><i class="icon edit"></i></div>
<div class="ui mini red inverted button" ng-click="removeTopic($index)"><i class="icon minus"></i></div>
</div>
</div>
</div>
</div>
<!--<div class="ui unfocus dimmer">
</div>-->
</div>
</div>
</admin-card>
<div class="two wide column">
<div class="ui card">
<div class="content">
<a class="header text center">New</a>
<div class="ui hover dimmer">
<div class="content">
<div class="center">
<div class="ui mini green inverted button" ng-click="newScope()"><i class="icon plus"></i></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="ui green segment" ng-show="selectedTopic!==undefined">
<h4 class="ui header green" style="padding: 0.5rem;">
Scopes
</h4>
<!--<div class="ui card" style="width:auto">
<div class="content">
<div class="header">Azure</div>
</div>
<div class="content">
<div class="ui sub header">Enabled Platforms</div>
</div>
<div class="content">
<div class="ui sub header">Twitter Keywords</div>
</div>
<div class="extra content">
<div class="ui two buttons">
<div class="ui green basic button">Approve</div>
<div class="ui red basic button">Decline</div>
</div>
</div>
</div>-->
<scope-card-content ng-transclude>
</scope-card-content>
</div>
<div class="extra content" ng-show="isDirty()">
<div class="ui two buttons">
<div class="ui green basic button" ng-click="approveUpdate()">Approve</div>
<div class="ui red basic button" ng-click="cancelUpdate()">Decline</div>
</div>
</div>
<div id="removeConfirmModal" class="ui small modal">
<div class="header">
Attention !
</div>
<div class="content">
<div class="description text red">
This operation will remove this topic!!!
</div>
</div>
<div class="actions">
<div class="ui cancel button">Cancel</div>
<div class="ui approve button">OK</div>
</div>
</div>
</div>
<div data-tab="notification" class="ui tab bottom attached segment">
<!--<div class="ui grid">
<div class="three wide column">
<div class="ui vertical fluid tabular menu">
<a data-tab="azure" class="active item" style="margin-top: 0em">
Azure
</a>
<a data-tab="uwp" class="item" style="margin-top: 0em">
UWP
</a>
<a data-tab="office" class="item" style="margin-top: 0em">
Office
</a>
</div>
</div>
<div class="thirteen wide column">
<div data-tab="azure" class="ui tab basic segment active">
<div class="field">
<div class="ui toggle checkbox">
<input type="checkbox" name="enable" tabindex="0" class="hidden">
<label>Enable Azure Alarm</label>
</div>
<div class="ui segment">
<div class="ui form">
<div class="field">
<label>Recipients</label>
<div class="fields">
<div class="twelve wide field">
<input type="text" name="shipping[address]" placeholder="Email Address">
</div>
<div class="four wide field">
<button class="ui icon red basic button center"><i class="icon red remove"></i></button>
<button class="ui icon green basic button center"><i class="icon green plus"></i></button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div data-tab="uwp" class="ui tab basic segment">
<div class="field">
<div class="ui toggle checkbox">
<input type="checkbox" name="enable" tabindex="0" class="hidden">
<label>Enable Azure Alarm</label>
</div>
<div class="ui segment">
<div class="ui form">
<div class="field">
<label>Recipients</label>
<div class="fields">
<div class="twelve wide field">
<input type="text" name="shipping[address]" placeholder="Email Address">
</div>
<div class="four wide field">
<button class="ui icon red basic button center"><i class="icon red remove"></i></button>
<button class="ui icon green basic button center"><i class="icon green plus"></i></button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div data-tab="office" class="ui tab basic segment">
<div class="field">
<div class="ui toggle checkbox">
<input type="checkbox" name="enable" tabindex="0" class="hidden">
<label>Enable Azure Alarm</label>
</div>
<div class="ui segment">
<div class="ui form">
<div class="field">
<label>Recipients</label>
<div class="fields">
<div class="twelve wide field">
<input type="text" name="shipping[address]" placeholder="Email Address">
</div>
<div class="four wide field">
<button class="ui icon red basic button center"><i class="icon red remove"></i></button>
<button class="ui icon green basic button center"><i class="icon green plus"></i></button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="extra content">
<div class="ui two buttons">
<div class="ui green basic button">Approve</div>
<div class="ui red basic button">Decline</div>
</div>
</div>-->
<div class="ui segment blue form">
<h5 class="ui header blue">
Search
<i class="link search icon pull-right" ng-click="listSubscriptions()"></i>
</h5>
<div class="fields">
<div class="two wide field">
<label>Platform</label>
<select class="ui fluid dropdown" ng-model="search.datasource">
<option value="all">All</option>
<option value="{{v}}" ng-repeat="(v,p) in CONST.ALL_ENABLED_PLARFORMS">{{p}}</option>
</select>
</div>
<div class="five wide field">
<label>Topic</label>
<select class="ui fluid dropdown" ng-model="search.topic">
<option value="all">All</option>
<option value="{{t.TechCategoryName}}" ng-repeat="t in enabledTopics | filter:{isGA:true}">{{t.TechCategoryName}}</option>
</select>
</div>
<div class="five wide field">
<label>Message Type</label>
<select class="ui fluid dropdown" ng-model="search.messagetype">
<option value="all">All</option>
<option value="{{k}}" ng-repeat="(k,v) in CONST.MESSAGE_TYPES">{{v}}</option>
</select>
</div>
</div>
</div>
<button class="ui icon green button" data-bind="events: { click: onCreateSubscriptionRule }">
<i class="plus icon"></i> Add Notification Rule
</button>
<table id="gridSubscriptionRules" st-table="stTable" st-safe-src="subscriptions" class="ui striped green table">
<thead>
<tr>
<th>Email
<span class="label">
<i class="popup small link info circle icon" data-content="info" data-variation="mini inverted"></i>
</span>
</th>
<th>Platform
<span class="label">
<i class="popup small link info circle icon" data-content="info" data-variation="mini inverted"></i>
</span>
</th>
<th>Topic
<span class="label">
<i class="popup small link info circle icon" data-content="info" data-variation="mini inverted"></i>
</span>
</th>
<th>Message Type
<span class="label">
<i class="popup small link info circle icon" data-content="info" data-variation="mini inverted"></i>
</span>
</th>
<th>
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="m in stTable">
<td>{{m.EMail}}</td>
<td>{{m.Platform}}</td>
<td>{{m.Topic}}</td>
<td>{{m.MsgType}}</td>
<td width="100">
<i class="icon remove rule" title="Remove Subscription Rule" data-entity="{ 'id': '{{m.GroupId}}', 'email': '{{m.EMail}}', 'platforms': '{{m.Platform}}', 'topics': '{{m.Topic}}', 'types': '{{m.MsgType}}' }"
onclick="onSubscriptionRuleRemove(this);"></i>
<i class="icon write rule" title="Update Subscription Rule" data-entity="{ 'id': '{{m.GroupId}}', 'email': '{{m.EMail}}', 'platforms': {{m.PlatformArrayJson}}, 'topics': {{m.TopicArrayJson}}, 'types': {{m.MsgTypeArrayJson}} }"
onclick="onSubscriptionRuleUpdate(this);"></i>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="5">
<div st-items-by-page="10" st-pagination="" st-template="/public/template/pagination.custom.html"></div>
</td>
</tr>
</tfoot>
</table>
</div>
</div>
<script type="text/javascript">
var dialogSubscriptionRuleEditor;
function getSubscriptionRuleEditor(viewModel, callback) {
if (callback) {
if (dialogSubscriptionRuleEditor) {
callback();
} else {
$.get("../public/template/dialogSubscirptionRuleEditor.htm")
.done(function (response) {
var element = $(response);
kendo.bind(element, viewModel);
var editor = element.kendoWindow({
animation: false,
modal: true,
scrollable: false,
resizable: false,
title: "Edit Subscription",
width: 464,
visible: false
}).data("kendoWindow");
element.parent()
.find("span.k-window-title")
.css({
fontSize: "18px",
fontWeight: "500"
});
dialogSubscriptionRuleEditor = editor;
callback();
})
.fail(function () { showNotificationError("Load Subscription Rule Editor Fail.") });
}
} else {
return dialogSubscriptionRuleEditor;
}
}
function onSubscriptionRuleUpdate(element) {
var data = JSON.parse($(element).data("entity").replace(/'/g, '"'));
var isSelectAllTopics = false;
if (data.topics.length === 0) { isSelectAllTopics = true; }
else if (data.topics[0] === "all") { isSelectAllTopics = true; }
viewModel.set("editSubscriptionRule.id", data.id);
viewModel.set("editSubscriptionRule.email", data.email);
viewModel.set("editSubscriptionRule.platform", data.platforms[0]);
viewModel.set("editSubscriptionRule.isSelectAllTopics", isSelectAllTopics);
viewModel.set("editSubscriptionRule.topics", data.topics);
viewModel.set("editSubscriptionRule.messagetype", data.types[0]);
getSubscriptionRuleEditor(viewModel, function () {
dialogSubscriptionRuleEditor.center().open();
});
}
function onSubscriptionRuleRemove(element) {
var data = JSON.parse($(element).data("entity").replace(/'/g, '"'));
confirm(kendo.template($("#templateConfirmRemoveRule").html())(data), function () {
scope.service.removeSubscriptionRule(data.id).then(function (response) {
if (response === true) {
showNotificationSuccess("Remove Subscription Rule Success!");
scope.listSubscriptions();
} else {
showNotificationError("Remove Subscription Rule Fail.");
}
});
});
}
var scope = angular.element("#gridSubscriptionRules").scope();
var flatforms = [{ value: "all", text: "All", }];
var topics = { all: [] };
var messagetypes = [{ value: "all", text: "All", }];
$.each(scope.CONST.ALL_ENABLED_PLARFORMS, function (key, value) {
flatforms.push({ value: key, text: value });
});
$.each(scope.CONST.MESSAGE_TYPES, function (key, value) {
messagetypes.push({ value: key, text: value });
});
var editSubscriptionRule = kendo.data.Model.define({
fields: {
id: { type: "string" },
email: { type: "string" },
platform: { type: "string" },
topics: { type: "object" },
messagetype: { type: "string" },
topicSource: { type: "object" }
},
isEmailEditable: function () {
return (this.get("email") || "").length === 0;
},
emailFieldBorderStyle: function () {
if (this.get("isEmailEditable()") === false) {
return "none";
}
return "";
},
topicsInForum: function () {
var topicSource = this.get("topicSource") || {};
var platform = this.get("platform") || "all";
return topicSource[platform] || [];
}
});
var viewModel = kendo.observable({
editSubscriptionRule: new editSubscriptionRule(),
onCreateSubscriptionRule: function (e) {
viewModel.set("editSubscriptionRule.id", null);
viewModel.set("editSubscriptionRule.email", "");
viewModel.set("editSubscriptionRule.platform", "all");
viewModel.set("editSubscriptionRule.isSelectAllTopics", true);
viewModel.set("editSubscriptionRule.topics", []);
viewModel.set("editSubscriptionRule.messagetype", "all");
getSubscriptionRuleEditor(viewModel, function () {
dialogSubscriptionRuleEditor.center().open();
});
},
onSubscriptionRuleEditorClose: function (e) {
getSubscriptionRuleEditor(viewModel, function () {
dialogSubscriptionRuleEditor.close();
});
},
onSubscriptionRuleUpdate: function (e) {
var topics = viewModel.editSubscriptionRule.topics;
if (viewModel.editSubscriptionRule.isSelectAllTopics === true) {
topics = ["all"];
} else {
var swap = [];
var topicsInForum = viewModel.editSubscriptionRule.topicsInForum();
$.each(topics, function (i, topic) {
if (topicsInForum.indexOf(topic) >= 0) {
swap.push(topic);
}
});
topics = swap;
}
if (viewModel.editSubscriptionRule.email.length === 0) {
showNotificationWarning("Email is necessary.");
return;
}
if (topics.length === 0) {
showNotificationWarning("Please select one Topic at least.");
return;
}
scope.service.createSubscribe({
id: viewModel.editSubscriptionRule.id,
email: viewModel.editSubscriptionRule.email,
platform: viewModel.editSubscriptionRule.platform,
topics: topics,
msgtype: viewModel.editSubscriptionRule.messagetype,
}).then(function (response) {
var action = viewModel.editSubscriptionRule.id
? "Update" : "Create";
if (response === true) {
showNotificationSuccess(action + " Subscription Rule Success!");
scope.listSubscriptions();
} else {
showNotificationError(action + " Subscription Rule Fail.");
}
getSubscriptionRuleEditor(viewModel, function () {
dialogSubscriptionRuleEditor.close();
});
});
},
messagetypes: messagetypes,
topics: topics,
flatforms: flatforms
});
viewModel.bind("change", function (e) {
if (e.field === "topics") {
this.set("editSubscriptionRule.topicSource", topics);
}
});
scope.service.getCate().then(function (categories) {
$.each(categories, function (i, category) {
if (category.isGA === true) {
var name = category.TechCategoryName;
$.each(category.Platforms, function (j, platform) {
if (platform.isEnabled === true) {
if (topics.all.indexOf(name) < 0) {
topics.all.push(name);
}
if (platform.PlatformName in topics) {
var array = topics[platform.PlatformName];
if (array.indexOf(name) < 0) {
array.push(name);
}
} else {
topics[platform.PlatformName] = [name];
}
}
});
}
});
viewModel.set("topics", topics);
});
kendo.bind($("div[data-tab=notification]"), viewModel);
</script>