kaui 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/kaui/kaui.js +118 -11
- data/app/assets/stylesheets/kaui/common.less +91 -6
- data/app/assets/stylesheets/kaui/payment.less +1 -0
- data/app/controllers/kaui/account_children_controller.rb +1 -4
- data/app/controllers/kaui/accounts_controller.rb +4 -7
- data/app/controllers/kaui/admin_allowed_users_controller.rb +24 -7
- data/app/controllers/kaui/admin_tenants_controller.rb +59 -20
- data/app/controllers/kaui/audit_logs_controller.rb +3 -2
- data/app/controllers/kaui/charges_controller.rb +1 -1
- data/app/controllers/kaui/credits_controller.rb +1 -1
- data/app/controllers/kaui/home_controller.rb +273 -10
- data/app/controllers/kaui/invoice_items_controller.rb +1 -1
- data/app/controllers/kaui/invoices_controller.rb +3 -3
- data/app/controllers/kaui/payments_controller.rb +5 -3
- data/app/controllers/kaui/refunds_controller.rb +2 -2
- data/app/controllers/kaui/subscriptions_controller.rb +2 -1
- data/app/helpers/kaui/object_helper.rb +4 -0
- data/app/helpers/kaui/plugin_helper.rb +36 -20
- data/app/helpers/kaui/uuid_helper.rb +9 -0
- data/app/models/kaui/admin.rb +3 -1
- data/app/models/kaui/admin_tenant.rb +58 -10
- data/app/models/kaui/allowed_user.rb +1 -0
- data/app/models/kaui/catalog.rb +2 -2
- data/app/models/kaui/credit.rb +0 -2
- data/app/models/kaui/overdue.rb +5 -5
- data/app/views/kaui/account_children/index.html.erb +3 -3
- data/app/views/kaui/accounts/_account_info.html.erb +45 -91
- data/app/views/kaui/accounts/_billing_info.html.erb +12 -8
- data/app/views/kaui/accounts/_parent.html.erb +1 -1
- data/app/views/kaui/accounts/_payment_methods.html.erb +1 -1
- data/app/views/kaui/accounts/_personal_info.html.erb +74 -0
- data/app/views/kaui/accounts/index.html.erb +4 -4
- data/app/views/kaui/accounts/show.html.erb +9 -3
- data/app/views/kaui/admin_allowed_users/_form.html.erb +38 -10
- data/app/views/kaui/admin_tenants/_form_plugin_config.erb +82 -17
- data/app/views/kaui/admin_tenants/_show_catalog_simple.erb +11 -3
- data/app/views/kaui/admin_tenants/_show_overdue.erb +4 -4
- data/app/views/kaui/admin_tenants/_tenant_details.html.erb +7 -1
- data/app/views/kaui/admin_tenants/new_overdue_config.html.erb +1 -1
- data/app/views/kaui/audit_logs/_show_history_modal.html.erb +1 -1
- data/app/views/kaui/audit_logs/index.html.erb +4 -0
- data/app/views/kaui/home/_advanced_search_modal.html.erb +80 -0
- data/app/views/kaui/home/index.html.erb +18 -5
- data/app/views/kaui/invoices/show.html.erb +7 -1
- data/app/views/kaui/layouts/kaui_flash.html.erb +14 -3
- data/app/views/kaui/layouts/kaui_navbar.html.erb +11 -9
- data/app/views/kaui/payments/_form.html.erb +8 -10
- data/app/views/kaui/payments/_payment_table.html.erb +40 -37
- data/app/views/kaui/payments/index.html.erb +1 -0
- data/app/views/kaui/payments/show.html.erb +5 -7
- data/app/views/kaui/queues/index.html.erb +22 -4
- data/app/views/kaui/subscriptions/_subscriptions_table.html.erb +1 -1
- data/app/views/kaui/tag_definitions/index.html.erb +1 -1
- data/config/routes.rb +2 -0
- data/lib/kaui/version.rb +1 -1
- data/test/functional/kaui/accounts_controller_test.rb +35 -0
- data/test/functional/kaui/admin_allowed_users_controller_test.rb +55 -2
- data/test/functional/kaui/admin_tenants_controller_test.rb +67 -6
- data/test/functional/kaui/home_controller_test.rb +389 -15
- data/test/functional/kaui/subscriptions_controller_test.rb +1 -1
- data/test/killbill_test_helper.rb +2 -2
- data/test/unit/helpers/kaui/uuid_helper_test.rb +16 -0
- data/test/unit/kaui/admin_tenant_test.rb +49 -0
- metadata +6 -4
- data/test/unit/kaui/uuid_helper_test.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0651238ca5895ad6646d03a02d6aea566789aecf'
|
4
|
+
data.tar.gz: 5f69d3a6033391e3fe1ee08e6a195a44475c33db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb800c76bba3c7073b21418059ec15614e3e6ba65c33e61101630d4a8ffaebf289dfe92296fcfbe72dbd87a66cef1fa2442302eaa405402024afbc9b27abd5c9
|
7
|
+
data.tar.gz: 89cbb200e3eabc97fe3c4475603a1906d83ab0c19baad61926b696a77cf58e7b3e83061fa39edb372bf9205e78caf312232fa72f376d695b636130634e6c3e48
|
@@ -198,43 +198,72 @@ jQuery(document).ready(function ($) {
|
|
198
198
|
if (jqxhr.status == 0) {
|
199
199
|
return;
|
200
200
|
}
|
201
|
-
|
202
|
-
var message = 'Request Status: ' + jqxhr.status + ' Status Text: ' + jqxhr.statusText + ' ' + jqxhr
|
201
|
+
|
202
|
+
var message = 'Request Status: ' + jqxhr.status + ', Status Text: ' + jqxhr.statusText + ': ' + getMessageFromResponse(jqxhr);
|
203
203
|
|
204
204
|
if (jqxhr.status == 200) {
|
205
205
|
message = thrownError.message == undefined ? thrownError : thrownError.message;
|
206
206
|
}
|
207
|
-
|
207
|
+
ajaxErrorAlert(message);
|
208
208
|
});
|
209
209
|
|
210
|
+
function getMessageFromResponse(jqxhr) {
|
211
|
+
if (isBlank(jqxhr.responseJSON)) {
|
212
|
+
return jqxhr.responseText;
|
213
|
+
}
|
214
|
+
|
215
|
+
if (!isBlank(jqxhr.responseJSON.error)) {
|
216
|
+
return jqxhr.responseJSON.error;
|
217
|
+
}
|
218
|
+
|
219
|
+
return jqxhr.responseText;
|
220
|
+
}
|
221
|
+
|
210
222
|
// this will prevent DataTable to show an alert message box when an error occurs
|
211
223
|
$.fn.dataTable.ext.errMode = 'none';
|
212
224
|
// this will try to register a DataTable error event to all tables, and if an error occurs will display the error on screen
|
213
225
|
$( document ).find(".table").on('error.dt', function ( e, settings, techNote, message ) {
|
214
|
-
|
215
|
-
})
|
226
|
+
ajaxErrorAlert('An error has been reported by DataTables: ' + message);
|
227
|
+
});
|
216
228
|
|
229
|
+
setObjectIdPopover();
|
217
230
|
});
|
218
231
|
|
219
|
-
|
220
|
-
function
|
232
|
+
|
233
|
+
// global function used to show an error message that occurs on a Ajax call, if timeout is passed the box will disappear when the time is up.
|
234
|
+
function ajaxErrorAlert(message, timeout) {
|
235
|
+
ajaxAlert("ajaxErrorAlert", message, timeout);
|
236
|
+
}
|
237
|
+
|
238
|
+
// global function used to show an information message.
|
239
|
+
function ajaxInfoAlert(message, timeout) {
|
240
|
+
ajaxAlert("ajaxInfoAlert", message, timeout);
|
241
|
+
}
|
242
|
+
|
243
|
+
// if timeout is passed the box will disappear when the time is up.
|
244
|
+
function ajaxAlert(alert_element_id, message, timeout) {
|
221
245
|
// do not show ajax alert if there is already an server alert
|
222
246
|
var serverAlertStatus = $(".server-alert").css("display");
|
223
247
|
if (serverAlertStatus != undefined && serverAlertStatus != "none") {
|
224
248
|
return;
|
225
249
|
}
|
226
250
|
|
227
|
-
var messageBox = $("#
|
228
|
-
messageBox.find("#
|
251
|
+
var messageBox = $("#" + alert_element_id);
|
252
|
+
messageBox.find("#" + alert_element_id + "Message").text(message);
|
229
253
|
messageBox.show();
|
230
254
|
messageBox.find("button").click(function(){
|
231
255
|
ajaxCloseAlert(messageBox);
|
232
256
|
});
|
257
|
+
|
258
|
+
//if timeout is passed the box will disappear when the time is up
|
259
|
+
if (!isBlank(timeout)) {
|
260
|
+
setTimeout(function(){ ajaxCloseAlert()}, timeout);
|
261
|
+
}
|
233
262
|
}
|
234
263
|
|
235
264
|
function ajaxCloseAlert(messageBox) {
|
236
|
-
var messageBox = messageBox || $("
|
237
|
-
messageBox.find("
|
265
|
+
var messageBox = messageBox || $(".ajaxAlert");
|
266
|
+
messageBox.find(".ajaxAlertMessage").text('');
|
238
267
|
messageBox.hide();
|
239
268
|
}
|
240
269
|
|
@@ -261,3 +290,81 @@ function isBlank(value) {
|
|
261
290
|
return false;
|
262
291
|
}
|
263
292
|
}
|
293
|
+
|
294
|
+
// this function set popover for all tags that have class object-id-popover
|
295
|
+
// attributes:
|
296
|
+
// data-id = content of the popover,object id; required
|
297
|
+
// title = title of the popover; not required
|
298
|
+
// id = (must be {{id}}-popover) used to close popover when the copy image is clicked; if present; if not present a timeout of 5s will apply; not required
|
299
|
+
function setObjectIdPopover(){
|
300
|
+
$(".object-id-popover").each(function(idx, e){
|
301
|
+
$(this).popover('destroy');
|
302
|
+
$(this).off("shown.bs.popover");
|
303
|
+
$(this).data("index", idx);
|
304
|
+
|
305
|
+
$(this).popover({
|
306
|
+
html: true,
|
307
|
+
content: function() {
|
308
|
+
var template = '<div class="{{id}}-content" >' +
|
309
|
+
'{{id}} <i id="{{id}}-copy" class="fa fa-clipboard copy-icon" aria-hidden="true"></i> ' +
|
310
|
+
'<input id="{{id}}-placeholder" class="form-control hidden"> ' +
|
311
|
+
'</div>';
|
312
|
+
|
313
|
+
var popover_html = Mustache.render( template , { id: $(this).data("id") });
|
314
|
+
return popover_html;
|
315
|
+
},
|
316
|
+
container: 'body',
|
317
|
+
trigger: 'hover',
|
318
|
+
delay: { "show": 100, "hide": 4000 }
|
319
|
+
});
|
320
|
+
|
321
|
+
$(this).on("show.bs.popover", function(e) {
|
322
|
+
var currentPopoverIndex = $(this).data('index');
|
323
|
+
$(".object-id-popover").each(function(idx, e){
|
324
|
+
var index = $(this).data('index');
|
325
|
+
|
326
|
+
if (currentPopoverIndex != index) {
|
327
|
+
$(this).popover('hide');
|
328
|
+
}
|
329
|
+
});
|
330
|
+
});
|
331
|
+
|
332
|
+
$(this).on("shown.bs.popover", function(e) {
|
333
|
+
var objectId = $(this).data('id');
|
334
|
+
var copyIdImg = $("#" + objectId + "-copy");
|
335
|
+
|
336
|
+
copyIdImg.data("popover",$(this).attr("id"));
|
337
|
+
copyIdImg.click(function(e){
|
338
|
+
var id = ($(this).attr("id")).replace('-copy','');
|
339
|
+
var placeholder = $("#" + objectId + "-placeholder");
|
340
|
+
var popover = $("#" + copyIdImg.data("popover"));
|
341
|
+
placeholder.val(id);
|
342
|
+
placeholder.removeClass("hidden");
|
343
|
+
placeholder.select();
|
344
|
+
|
345
|
+
document.execCommand("Copy");
|
346
|
+
placeholder.addClass("hidden");
|
347
|
+
ajaxInfoAlert("Id [" + id + "] was copied into the clipboard!", 4000);
|
348
|
+
|
349
|
+
if (!isBlank(popover)) {
|
350
|
+
popover.popover('hide');
|
351
|
+
}
|
352
|
+
|
353
|
+
});
|
354
|
+
|
355
|
+
});
|
356
|
+
|
357
|
+
});
|
358
|
+
|
359
|
+
// close all object id popover on modal show
|
360
|
+
$(".modal").on('show.bs.modal',function(e){
|
361
|
+
$(".object-id-popover").each(function(idx, e) {
|
362
|
+
$(this).popover('destroy');
|
363
|
+
});
|
364
|
+
});
|
365
|
+
|
366
|
+
// check if object id must be restored
|
367
|
+
$(".modal").on('hide.bs.modal',function(e){
|
368
|
+
setObjectIdPopover();
|
369
|
+
});
|
370
|
+
}
|
@@ -382,7 +382,7 @@ table.subtitle {
|
|
382
382
|
}
|
383
383
|
|
384
384
|
.fix-position {
|
385
|
-
padding-left:
|
385
|
+
padding-left: 20px;
|
386
386
|
|
387
387
|
@media (@phone) {
|
388
388
|
padding-left: 15px;
|
@@ -553,6 +553,61 @@ form[id^="new_tag_definition"] {
|
|
553
553
|
}
|
554
554
|
|
555
555
|
/* The switch - the box around the slider */
|
556
|
+
.switch-half-container {
|
557
|
+
padding-top: 9px !important;
|
558
|
+
}
|
559
|
+
|
560
|
+
.switch-half {
|
561
|
+
position: relative;
|
562
|
+
display: inline-block;
|
563
|
+
margin-bottom: 0;
|
564
|
+
width: 20px;
|
565
|
+
height: 12px;
|
566
|
+
|
567
|
+
|
568
|
+
/* Hide default HTML checkbox */
|
569
|
+
input {display:none;}
|
570
|
+
|
571
|
+
/* The slider */
|
572
|
+
.slider {
|
573
|
+
position: absolute;
|
574
|
+
cursor: pointer;
|
575
|
+
top: 0;
|
576
|
+
left: 0;
|
577
|
+
right: 0;
|
578
|
+
bottom: 0;
|
579
|
+
background-color: #ccc;
|
580
|
+
-webkit-transition: .4s;
|
581
|
+
transition: .4s;
|
582
|
+
}
|
583
|
+
|
584
|
+
.slider:before {
|
585
|
+
position: absolute;
|
586
|
+
content: "";
|
587
|
+
height: 10px;
|
588
|
+
width: 10px;
|
589
|
+
left: 1px;
|
590
|
+
bottom: 1px;
|
591
|
+
background-color: white;
|
592
|
+
-webkit-transition: .4s;
|
593
|
+
transition: .4s;
|
594
|
+
}
|
595
|
+
|
596
|
+
input:checked + .slider {
|
597
|
+
background-color: #00919d;
|
598
|
+
}
|
599
|
+
|
600
|
+
input:focus + .slider {
|
601
|
+
box-shadow: 0 0 1px #2196F3;
|
602
|
+
}
|
603
|
+
|
604
|
+
input:checked + .slider:before {
|
605
|
+
-webkit-transform: translateX(8px);
|
606
|
+
-ms-transform: translateX(8px);
|
607
|
+
transform: translateX(8px);
|
608
|
+
}
|
609
|
+
}
|
610
|
+
|
556
611
|
.switch {
|
557
612
|
position: relative;
|
558
613
|
display: inline-block;
|
@@ -595,12 +650,12 @@ form[id^="new_tag_definition"] {
|
|
595
650
|
input:focus + .slider {
|
596
651
|
box-shadow: 0 0 1px #2196F3;
|
597
652
|
}
|
598
|
-
}
|
599
653
|
|
600
|
-
input:checked + .slider:before {
|
601
|
-
|
602
|
-
|
603
|
-
|
654
|
+
input:checked + .slider:before {
|
655
|
+
-webkit-transform: translateX(16px);
|
656
|
+
-ms-transform: translateX(16px);
|
657
|
+
transform: translateX(16px);
|
658
|
+
}
|
604
659
|
}
|
605
660
|
|
606
661
|
/* Rounded sliders */
|
@@ -632,4 +687,34 @@ input:checked + .slider:before {
|
|
632
687
|
|
633
688
|
.toggle-label {
|
634
689
|
text-align: left !important;
|
690
|
+
}
|
691
|
+
|
692
|
+
.spinner {
|
693
|
+
padding-top: 3.5px;
|
694
|
+
width: 40px;
|
695
|
+
color: #00919d;
|
696
|
+
display: none;
|
697
|
+
}
|
698
|
+
|
699
|
+
.footer-notice {
|
700
|
+
.modal-footer {
|
701
|
+
text-align: left;
|
702
|
+
padding-bottom: 0;
|
703
|
+
|
704
|
+
.alert {
|
705
|
+
margin-bottom: 0;
|
706
|
+
|
707
|
+
.label-default {
|
708
|
+
color: white;
|
709
|
+
}
|
710
|
+
}
|
711
|
+
}
|
712
|
+
}
|
713
|
+
|
714
|
+
.copy-icon {
|
715
|
+
cursor: pointer;
|
716
|
+
}
|
717
|
+
|
718
|
+
.switch-tenant-active {
|
719
|
+
color: #00919d;
|
635
720
|
}
|
@@ -34,12 +34,9 @@ class Kaui::AccountChildrenController < Kaui::EngineController
|
|
34
34
|
|
35
35
|
formatter = lambda do |account_child|
|
36
36
|
[
|
37
|
-
view_context.link_to(account_child.
|
38
|
-
view_context.truncate_uuid(account_child.account_id),
|
37
|
+
view_context.link_to(account_child.account_id, account_path(account_child.account_id)),
|
39
38
|
account_child.external_key,
|
40
39
|
view_context.humanized_money_with_symbol(account_child.balance_to_money),
|
41
|
-
account_child.city,
|
42
|
-
account_child.country
|
43
40
|
]
|
44
41
|
end
|
45
42
|
|
@@ -45,12 +45,9 @@ class Kaui::AccountsController < Kaui::EngineController
|
|
45
45
|
|
46
46
|
[
|
47
47
|
child_label,
|
48
|
-
view_context.link_to(account.
|
49
|
-
view_context.truncate_uuid(account.account_id),
|
48
|
+
view_context.link_to(account.account_id, view_context.url_for(:action => :show, :account_id => account.account_id)),
|
50
49
|
account.external_key,
|
51
|
-
view_context.humanized_money_with_symbol(account.balance_to_money)
|
52
|
-
account.city,
|
53
|
-
account.country
|
50
|
+
view_context.humanized_money_with_symbol(account.balance_to_money)
|
54
51
|
]
|
55
52
|
end
|
56
53
|
|
@@ -171,7 +168,7 @@ class Kaui::AccountsController < Kaui::EngineController
|
|
171
168
|
def trigger_invoice
|
172
169
|
account_id = params.require(:account_id)
|
173
170
|
target_date = params[:target_date].presence
|
174
|
-
dry_run = params[:dry_run] == '1'
|
171
|
+
dry_run = params[:dry_run].nil? ? false : params[:dry_run] == '1'
|
175
172
|
|
176
173
|
invoice = nil
|
177
174
|
begin
|
@@ -233,7 +230,7 @@ class Kaui::AccountsController < Kaui::EngineController
|
|
233
230
|
def pay_all_invoices
|
234
231
|
payment = Kaui::InvoicePayment.new(:account_id => params.require(:account_id))
|
235
232
|
|
236
|
-
payment.bulk_create(params[:is_external_payment] == 'true', current_user.kb_username, params[:reason], params[:comment], options_for_klient)
|
233
|
+
payment.bulk_create(params[:is_external_payment] == 'true', nil, nil, current_user.kb_username, params[:reason], params[:comment], options_for_klient)
|
237
234
|
|
238
235
|
redirect_to account_path(payment.account_id), :notice => 'Successfully triggered a payment for all unpaid invoices'
|
239
236
|
end
|
@@ -8,14 +8,17 @@ class Kaui::AdminAllowedUsersController < Kaui::EngineController
|
|
8
8
|
|
9
9
|
def new
|
10
10
|
@allowed_user = Kaui::AllowedUser.new
|
11
|
+
@is_killbill_managed = true
|
12
|
+
|
11
13
|
@roles = []
|
12
14
|
end
|
13
15
|
|
14
16
|
def create
|
17
|
+
@is_killbill_managed = nil
|
15
18
|
@allowed_user = Kaui::AllowedUser.new(allowed_user_params)
|
16
19
|
|
17
20
|
existing_user = Kaui::AllowedUser.find_by_kb_username(@allowed_user.kb_username)
|
18
|
-
|
21
|
+
unless existing_user.blank?
|
19
22
|
flash[:error] = "User with name #{@allowed_user.kb_username} already exists!"
|
20
23
|
@roles = roles_for_user(existing_user)
|
21
24
|
render :new and return
|
@@ -24,10 +27,12 @@ class Kaui::AdminAllowedUsersController < Kaui::EngineController
|
|
24
27
|
# Create locally only
|
25
28
|
@allowed_user.save!
|
26
29
|
else
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
30
|
+
@allowed_user.create_in_kb!(params.require(:password) ,
|
31
|
+
params[:roles].blank? ? [] : params[:roles].split(','),
|
32
|
+
current_user.kb_username,
|
33
|
+
params[:reason],
|
34
|
+
params[:comment],
|
35
|
+
options_for_klient)
|
31
36
|
end
|
32
37
|
|
33
38
|
redirect_to kaui_engine.admin_allowed_user_path(@allowed_user.id), :notice => 'User was successfully configured'
|
@@ -46,6 +51,7 @@ class Kaui::AdminAllowedUsersController < Kaui::EngineController
|
|
46
51
|
|
47
52
|
def edit
|
48
53
|
@allowed_user = Kaui::AllowedUser.find(params.require(:id))
|
54
|
+
@is_killbill_managed = killbill_managed?(@allowed_user, options_for_klient)
|
49
55
|
|
50
56
|
@roles = roles_for_user(@allowed_user)
|
51
57
|
end
|
@@ -56,7 +62,7 @@ class Kaui::AdminAllowedUsersController < Kaui::EngineController
|
|
56
62
|
@allowed_user.description = params[:allowed_user][:description].presence
|
57
63
|
|
58
64
|
@allowed_user.update_in_kb!(params[:password].presence,
|
59
|
-
params[:roles].
|
65
|
+
params[:roles].blank? ? nil : params[:roles].split(','),
|
60
66
|
current_user.kb_username,
|
61
67
|
params[:reason],
|
62
68
|
params[:comment],
|
@@ -103,6 +109,17 @@ class Kaui::AdminAllowedUsersController < Kaui::EngineController
|
|
103
109
|
|
104
110
|
private
|
105
111
|
|
112
|
+
# this will check if the user is managed by killbill (not managed externally or internally by a shiro config file).
|
113
|
+
def killbill_managed?(allowed_user, options = {})
|
114
|
+
begin
|
115
|
+
Kaui::UserRole.find_roles_by_username(allowed_user.kb_username, options)
|
116
|
+
rescue KillBillClient::API::ClientError => _
|
117
|
+
return false
|
118
|
+
end
|
119
|
+
|
120
|
+
return true
|
121
|
+
end
|
122
|
+
|
106
123
|
def allowed_user_params
|
107
124
|
allowed_user = params.require(:allowed_user)
|
108
125
|
allowed_user.require(:kb_username)
|
@@ -110,6 +127,6 @@ class Kaui::AdminAllowedUsersController < Kaui::EngineController
|
|
110
127
|
end
|
111
128
|
|
112
129
|
def roles_for_user(allowed_user)
|
113
|
-
Kaui::UserRole.find_roles_by_username(allowed_user.kb_username, options_for_klient).map(&:presence).compact
|
130
|
+
Kaui::UserRole.find_roles_by_username(allowed_user.kb_username, options_for_klient).map(&:presence).compact rescue []
|
114
131
|
end
|
115
132
|
end
|
@@ -233,7 +233,7 @@ class Kaui::AdminTenantsController < Kaui::EngineController
|
|
233
233
|
view_form_model['states'] = view_form_model['states'].values unless view_form_model['states'].blank?
|
234
234
|
|
235
235
|
overdue = Kaui::Overdue::from_overdue_form_model(view_form_model)
|
236
|
-
overdue.
|
236
|
+
Kaui::Overdue::upload_tenant_overdue_config_json(overdue.to_json,options[:username], nil, comment, options)
|
237
237
|
redirect_to admin_tenant_path(current_tenant.id), :notice => 'Overdue config was successfully added '
|
238
238
|
end
|
239
239
|
|
@@ -314,11 +314,16 @@ class Kaui::AdminTenantsController < Kaui::EngineController
|
|
314
314
|
plugin_type = params[:plugin_type]
|
315
315
|
plugin_key = params[:plugin_key]
|
316
316
|
|
317
|
-
|
317
|
+
if plugin_properties.blank?
|
318
|
+
flash[:error] = 'Plugin properties cannot be blank'
|
319
|
+
else
|
320
|
+
plugin_config = Kaui::AdminTenant.format_plugin_config(plugin_key, plugin_type, plugin_properties)
|
318
321
|
|
319
|
-
|
322
|
+
Kaui::AdminTenant.upload_tenant_plugin_config(plugin_name, plugin_config, options[:username], nil, comment, options)
|
323
|
+
flash[:notice] = 'Config for plugin was successfully uploaded'
|
324
|
+
end
|
320
325
|
|
321
|
-
redirect_to admin_tenant_path(current_tenant.id)
|
326
|
+
redirect_to admin_tenant_path(current_tenant.id)
|
322
327
|
end
|
323
328
|
|
324
329
|
def remove_allowed_user
|
@@ -367,23 +372,15 @@ class Kaui::AdminTenantsController < Kaui::EngineController
|
|
367
372
|
end
|
368
373
|
|
369
374
|
def display_catalog_xml
|
370
|
-
|
371
|
-
effective_date = params.require(:effective_date)
|
372
|
-
|
373
|
-
options = tenant_options_for_client
|
374
|
-
options[:api_key] = current_tenant.api_key
|
375
|
-
options[:api_secret] = current_tenant.api_secret
|
376
|
-
|
377
|
-
response = Kaui::Catalog.get_catalog_xml(effective_date, options) rescue response = {}
|
378
|
-
|
379
|
-
catalog_xml = {}
|
380
|
-
unless response.nil? && response.size > 0
|
381
|
-
catalog_xml = response[0][:xml]
|
382
|
-
end
|
383
|
-
|
375
|
+
catalog_xml = fetch_catalog_xml(params[:id], params.require(:effective_date))
|
384
376
|
render xml: catalog_xml
|
385
377
|
end
|
386
378
|
|
379
|
+
def download_catalog_xml
|
380
|
+
effective_date = params.require(:effective_date)
|
381
|
+
catalog_xml = fetch_catalog_xml(params[:id], effective_date)
|
382
|
+
send_data catalog_xml, filename: "catalog_#{effective_date}.xml", type: :xml
|
383
|
+
end
|
387
384
|
|
388
385
|
def display_overdue_xml
|
389
386
|
render xml: params.require(:xml)
|
@@ -440,6 +437,17 @@ class Kaui::AdminTenantsController < Kaui::EngineController
|
|
440
437
|
end
|
441
438
|
end
|
442
439
|
|
440
|
+
def switch_tenant
|
441
|
+
tenant = Kaui::Tenant.find_by_kb_tenant_id(params.require(:kb_tenant_id))
|
442
|
+
|
443
|
+
# Select the tenant, see TenantsController
|
444
|
+
session[:kb_tenant_id] = tenant.kb_tenant_id
|
445
|
+
session[:kb_tenant_name] = tenant.name
|
446
|
+
session[:tenant_id] = tenant.id
|
447
|
+
|
448
|
+
redirect_to admin_tenant_path(tenant.id), :notice => "Tenant was switched to #{tenant.name}"
|
449
|
+
end
|
450
|
+
|
443
451
|
private
|
444
452
|
|
445
453
|
|
@@ -483,10 +491,10 @@ class Kaui::AdminTenantsController < Kaui::EngineController
|
|
483
491
|
|
484
492
|
plugin_repository.each do |plugin|
|
485
493
|
return plugin, [] if plugin[:plugin_name] == entered_plugin_name || plugin[:plugin_key] == entered_plugin_name
|
486
|
-
|
487
|
-
splitted_plugin_name = split_camel_dash_underscore_space(plugin[:plugin_name])
|
488
494
|
weight = { :plugin_name => plugin[:plugin_name], :plugin_key => plugin[:plugin_key],
|
489
495
|
:plugin_type => plugin[:plugin_type], :installed => plugin[:installed], :worth_weight => 0.0 }
|
496
|
+
|
497
|
+
splitted_plugin_name = split_camel_dash_underscore_space(plugin[:plugin_name])
|
490
498
|
splitted_entered_plugin_name.each do |entered|
|
491
499
|
if splitted_plugin_name.include?(entered)
|
492
500
|
weight[:worth_weight] = weight[:worth_weight] + 1.0
|
@@ -498,7 +506,23 @@ class Kaui::AdminTenantsController < Kaui::EngineController
|
|
498
506
|
break
|
499
507
|
end
|
500
508
|
end
|
509
|
+
|
510
|
+
# perform a plugin key search, if weight is zero
|
511
|
+
next unless weight[:worth_weight] == 0
|
512
|
+
splitted_plugin_key = split_camel_dash_underscore_space(plugin[:plugin_key])
|
513
|
+
|
514
|
+
if splitted_plugin_key.include?(entered)
|
515
|
+
weight[:worth_weight] = weight[:worth_weight] + 1.0
|
516
|
+
end
|
517
|
+
|
518
|
+
splitted_plugin_key.each do |splitted|
|
519
|
+
if entered.chars.all? { |ch| splitted.include?(ch) }
|
520
|
+
weight[:worth_weight] = weight[:worth_weight] + worth_of_non_words
|
521
|
+
break
|
522
|
+
end
|
523
|
+
end
|
501
524
|
end
|
525
|
+
|
502
526
|
weights << weight if weight[:worth_weight] > 0
|
503
527
|
|
504
528
|
end
|
@@ -506,4 +530,19 @@ class Kaui::AdminTenantsController < Kaui::EngineController
|
|
506
530
|
weights.sort! { |a,b| b[:worth_weight] <=> a[:worth_weight] } if weights.size > 1
|
507
531
|
return nil, weights
|
508
532
|
end
|
533
|
+
|
534
|
+
def fetch_catalog_xml(tenant_id, effective_date)
|
535
|
+
current_tenant = safely_find_tenant_by_id(tenant_id)
|
536
|
+
|
537
|
+
options = tenant_options_for_client
|
538
|
+
options[:api_key] = current_tenant.api_key
|
539
|
+
options[:api_secret] = current_tenant.api_secret
|
540
|
+
|
541
|
+
response = Kaui::Catalog.get_catalog_xml(effective_date, options) rescue response = {}
|
542
|
+
|
543
|
+
catalog_xml = {}
|
544
|
+
catalog_xml = response[0][:xml] unless response.blank?
|
545
|
+
|
546
|
+
catalog_xml
|
547
|
+
end
|
509
548
|
end
|