biovision-base 0.20.180731.0 → 0.21.180812.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/biovision/base/biovision.js +53 -30
  3. data/app/assets/stylesheets/biovision/base/biovision.scss +28 -9
  4. data/app/assets/stylesheets/biovision/base/default.scss +4 -16
  5. data/app/controllers/admin/foreign_users_controller.rb +25 -0
  6. data/app/controllers/api/embed_controller.rb +6 -0
  7. data/app/controllers/authentication_controller.rb +1 -3
  8. data/app/controllers/foreign_users_controller.rb +24 -0
  9. data/app/controllers/media_files_controller.rb +24 -1
  10. data/app/helpers/biovision_users_helper.rb +6 -0
  11. data/app/models/foreign_user.rb +7 -2
  12. data/app/views/admin/foreign_users/_nav_item.html.erb +6 -0
  13. data/app/views/admin/foreign_users/entity/_in_list.html.erb +13 -0
  14. data/app/views/admin/foreign_users/index.html.erb +16 -0
  15. data/app/views/admin/foreign_users/show.html.erb +62 -0
  16. data/app/views/admin/index/dashboard/_biovision_user.html.erb +1 -0
  17. data/app/views/admin/users/entity/_in_list.html.erb +8 -0
  18. data/app/views/admin/users/show.html.erb +11 -0
  19. data/app/views/media_files/medium.jbuilder +13 -0
  20. data/app/views/shared/forms/_state_container.html.erb +6 -0
  21. data/config/locales/common-en.yml +3 -0
  22. data/config/locales/common-ru.yml +3 -0
  23. data/config/locales/common-sv.yml +3 -0
  24. data/config/locales/users-en.yml +15 -0
  25. data/config/locales/users-ru.yml +15 -0
  26. data/config/locales/users-sv.yml +15 -0
  27. data/config/routes.rb +9 -0
  28. data/lib/biovision/base/base_methods.rb +12 -1
  29. data/lib/biovision/base/version.rb +1 -1
  30. metadata +11 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 878d3c84e3d6e08ba4fa008b488ed44edd05a0da401a1845782c7f31a3fab464
4
- data.tar.gz: f4e73e086c4fe87bf11f2c68e7ceb26daaeb0507e0699990cb0729a38758338a
3
+ metadata.gz: fe07ebb0c3da033a5ad0e0b65729448ad05c47511deb17da001ef960a5e95cc1
4
+ data.tar.gz: d0b3269f72e6a6f64dc1f1f5e4aeebac1f26bc040b58754af01c5a5898448434
5
5
  SHA512:
6
- metadata.gz: 2a1c30cb8db14f7831172840f86d9a05a4352e7d833e0c2b1e9e5d7c68515afe90aa499f9a9675478a46e572261a01e76f19ff4f9da6cf023d7155135f458781
7
- data.tar.gz: 71512a52954db3ceb82eaa5fc64fa9b773b2388c8117940194e972106c973b67b9a2fb59714c1e5ff20eb6bf8da3df38255af27b5b1d7f64b8415eea08003d7a
6
+ metadata.gz: 1f3b099642e625e586cb11741a35d9eec303aa655e71713a46efc9c0e8b354fd03f9a1ebdfa93819fa5c14512386930de33f0f680a0269da6804c7eb021ee28d
7
+ data.tar.gz: 58ee25c71e41d9ea86fe6a899cbb6b4bdc212f44e6ce217288ed87b8aff3d07b414a86474c1dfca6fdc49c35a775de53c1de1c95926de326f3c3283184e50414
@@ -220,7 +220,7 @@ const Biovision = {
220
220
  const container = form.querySelector('[data-field="' + key + '"]');
221
221
 
222
222
  if (container) {
223
- const errors = response.meta.errors;
223
+ const errors = response.meta['errors'];
224
224
 
225
225
  if (errors.hasOwnProperty(key)) {
226
226
  container.innerHTML = errors[key].join('; ');
@@ -234,7 +234,7 @@ const Biovision = {
234
234
  }
235
235
  });
236
236
 
237
- const data = new window.FormData();
237
+ const data = new FormData();
238
238
  Array.from((new FormData(form)).entries()).forEach(function (entry) {
239
239
  const value = entry[1];
240
240
 
@@ -330,6 +330,49 @@ const Biovision = {
330
330
  if (this.rows > maxRows) {
331
331
  this.rows = maxRows;
332
332
  }
333
+ },
334
+ remoteFormHandler: function (form) {
335
+ const button = form.querySelector('button[type=submit]');
336
+ const loadingMessage = form.querySelector('.loading_message');
337
+ const stateContainer = form.querySelector('.state_container');
338
+ const progressPercent = form.querySelector('.state_container .percentage');
339
+ const progressBar = form.querySelector('.state_container progress');
340
+
341
+ form.addEventListener('ajax:before', function () {
342
+ button.disabled = true;
343
+
344
+ if (loadingMessage) {
345
+ loadingMessage.classList.remove('hidden');
346
+ }
347
+ });
348
+
349
+ form.addEventListener('ajax:complete', function () {
350
+ button.disabled = false;
351
+
352
+ if (loadingMessage) {
353
+ loadingMessage.classList.add('hidden');
354
+ }
355
+ if (progressBar) {
356
+ progressBar.value = '0';
357
+ }
358
+ });
359
+
360
+ if (stateContainer) {
361
+ form.addEventListener('ajax:beforeSend', function (event) {
362
+ const request = event.detail[0];
363
+
364
+ request.upload.addEventListener('progress', function (e) {
365
+ const value = e.loaded / e.total;
366
+
367
+ if (progressPercent) {
368
+ progressPercent.innerHTML = (value * 100) + '%';
369
+ }
370
+ if (progressBar) {
371
+ progressBar.value = value;
372
+ }
373
+ });
374
+ });
375
+ }
333
376
  }
334
377
  };
335
378
 
@@ -373,7 +416,7 @@ document.addEventListener('DOMContentLoaded', function () {
373
416
 
374
417
  const container = element.closest('li');
375
418
  const button = element.closest('a');
376
- const lockable = container.parentNode.querySelectorAll('.lockable');
419
+ const lockable = container.parentElement.querySelectorAll('.lockable');
377
420
  const url = container.getAttribute('data-url');
378
421
 
379
422
  if (url.length > 1) {
@@ -417,7 +460,7 @@ document.addEventListener('DOMContentLoaded', function () {
417
460
  const url = element.parentNode.getAttribute('data-url');
418
461
  const parameter = element.getAttribute('data-flag');
419
462
 
420
- const on_success = function () {
463
+ const onSuccess = function () {
421
464
  const response = JSON.parse(this.responseText);
422
465
 
423
466
  if (response.hasOwnProperty('data')) {
@@ -436,12 +479,12 @@ document.addEventListener('DOMContentLoaded', function () {
436
479
  }
437
480
  };
438
481
 
439
- const on_failure = function () {
482
+ const onFailure = function () {
440
483
  element.className = 'unknown';
441
484
  Biovision.handleAjaxFailure().call(this);
442
485
  };
443
486
 
444
- const request = Biovision.newAjaxRequest('POST', url, on_success, on_failure);
487
+ const request = Biovision.newAjaxRequest('POST', url, onSuccess, onFailure);
445
488
  const data = new FormData();
446
489
  data.append('parameter', parameter);
447
490
 
@@ -497,7 +540,7 @@ document.addEventListener('DOMContentLoaded', function () {
497
540
  const request = Biovision.newAjaxRequest('POST', url, onSuccess);
498
541
 
499
542
  const data = new FormData();
500
- data.append('delta', delta);
543
+ data.append('delta', String(delta));
501
544
 
502
545
  request.send(data);
503
546
  }
@@ -555,27 +598,7 @@ document.addEventListener('DOMContentLoaded', function () {
555
598
  });
556
599
  });
557
600
 
558
- document.querySelectorAll('form[data-remote]').forEach(function (form) {
559
- const button = form.querySelector('button[type=submit]');
560
- const loading_message = form.querySelector('.loading_message');
561
-
562
- form.addEventListener('ajax:before', function () {
563
- button.disabled = true;
564
-
565
- if (loading_message) {
566
- loading_message.classList.remove('hidden');
567
- }
568
- });
569
-
570
- form.addEventListener('ajax:complete', function () {
571
- button.disabled = false;
572
-
573
- if (loading_message) {
574
- loading_message.classList.add('hidden');
575
- }
576
- });
577
- });
578
-
601
+ document.querySelectorAll('form[data-remote]').forEach(Biovision.remoteFormHandler);
579
602
  document.querySelectorAll('form[data-check-url]').forEach(Biovision.instant_check);
580
603
 
581
604
  document.querySelectorAll('.remove-image-button').forEach(function (button) {
@@ -611,11 +634,11 @@ function handle_ajax_failure(response) {
611
634
  document.addEventListener('ajax:beforeSend', function (e) {
612
635
  const formData = e.detail[1].data;
613
636
 
614
- if (!(formData instanceof window.FormData) || !formData.keys) {
637
+ if (!(formData instanceof FormData) || !formData.keys) {
615
638
  return;
616
639
  }
617
640
 
618
- const newFormData = new window.FormData();
641
+ const newFormData = new FormData();
619
642
 
620
643
  Array.from(formData.entries()).forEach(function (entry) {
621
644
  const value = entry[1];
@@ -1,3 +1,23 @@
1
+ :root {
2
+ --font-size-xxxl: #{$font-size-xxxl};
3
+ --font-size-xxl: #{$font-size-xxl};
4
+ --font-size-xl: #{$font-size-xl};
5
+ --font-size-large: #{$font-size-large};
6
+ --font-size-increased: #{$font-size-increased};
7
+ --font-size-normal: #{$font-size-normal};
8
+ --font-size-decreased: #{$font-size-decreased};
9
+ --font-size-small: #{$font-size-small};
10
+ --font-size-xs: #{$font-size-xs};
11
+
12
+ --spacer-xxs: #{$spacer-xxs};
13
+ --spacer-xs: #{$spacer-xs};
14
+ --spacer-s: #{$spacer-s};
15
+ --spacer-m: #{$spacer-m};
16
+ --spacer-l: #{$spacer-l};
17
+ --spacer-xl: #{$spacer-xl};
18
+ --spacer-xxl: #{$spacer-xxl};
19
+ }
20
+
1
21
  * {
2
22
  box-sizing: border-box;
3
23
  }
@@ -19,13 +39,12 @@ h4,
19
39
  h5,
20
40
  h6 {
21
41
  font-family: $font-family-heading;
22
- //font-weight: 500;
23
42
  margin: 0;
24
43
  }
25
44
 
26
45
  h1 {
27
- font-size: 3rem;
28
- line-height: 4.2rem;
46
+ font-size: var(--font-size-xl);
47
+ line-height: 1.25;
29
48
  }
30
49
 
31
50
  a:link {
@@ -130,7 +149,7 @@ ul.actions {
130
149
  flex-wrap: wrap;
131
150
  list-style: none;
132
151
  margin: 0;
133
- padding: 0.8rem;
152
+ padding: .8rem;
134
153
 
135
154
  &:nth-of-type(even) {
136
155
  background: $row-background-even;
@@ -182,7 +201,7 @@ ul.actions {
182
201
 
183
202
  .children {
184
203
  border-left: .1rem dotted;
185
- margin-left: 1.6rem;
204
+ margin-left: var(--spacer-s);
186
205
  }
187
206
  }
188
207
  }
@@ -224,7 +243,7 @@ form {
224
243
 
225
244
  .guideline {
226
245
  color: $text-color-secondary;
227
- font-size: $font-size-decreased;
246
+ font-size: var(--font-size-decreased);
228
247
  margin: 0;
229
248
 
230
249
  &::before {
@@ -248,7 +267,7 @@ form {
248
267
  }
249
268
 
250
269
  dt {
251
- font: 500 $font-size-increased $font-family-main;
270
+ font: 500 var(--font-size-increased) $font-family-main;
252
271
 
253
272
  &:not(:first-of-type) {
254
273
  border-top: $border-secondary;
@@ -274,7 +293,7 @@ form {
274
293
  }
275
294
 
276
295
  input {
277
- font-size: $font-size-normal;
296
+ font-size: inherit;
278
297
  }
279
298
 
280
299
  ul.flags {
@@ -346,7 +365,7 @@ form {
346
365
  }
347
366
  }
348
367
 
349
- input.control:not(:checked) + div {
368
+ input.control:not(:checked) + * {
350
369
  display: none;
351
370
  }
352
371
 
@@ -1,11 +1,15 @@
1
1
  $font-family-main: "Roboto", sans-serif !default;
2
2
  $font-family-heading: $font-family-main !default;
3
3
 
4
+ $font-size-xxxl: 5.6rem !default;
5
+ $font-size-xxl: 4.5rem !default;
6
+ $font-size-xl: 3.2rem !default;
4
7
  $font-size-large: 2.4rem !default;
5
8
  $font-size-increased: 1.8rem !default;
6
9
  $font-size-normal: 1.6rem !default;
7
10
  $font-size-decreased: 1.3rem !default;
8
11
  $font-size-small: 1.1rem !default;
12
+ $font-size-xs: 1rem !default;
9
13
 
10
14
  $content-width: 100rem !default;
11
15
  $content-width-min: 32rem !default;
@@ -40,19 +44,3 @@ $spacer-m: 3.2rem;
40
44
  $spacer-l: 4.8rem;
41
45
  $spacer-xl: 6.4rem;
42
46
  $spacer-xxl: 9.6rem;
43
-
44
- :root {
45
- --font-size-large: #{$font-size-large};
46
- --font-size-increased: #{$font-size-increased};
47
- --font-size-normal: #{$font-size-normal};
48
- --font-size-decreased: #{$font-size-decreased};
49
- --font-size-small: #{$font-size-small};
50
-
51
- --spacer-xxs: #{$spacer-xxs};
52
- --spacer-xs: #{$spacer-xs};
53
- --spacer-s: #{$spacer-s};
54
- --spacer-m: #{$spacer-m};
55
- --spacer-l: #{$spacer-l};
56
- --spacer-xl: #{$spacer-xl};
57
- --spacer-xxl: #{$spacer-xxl};
58
- }
@@ -0,0 +1,25 @@
1
+ class Admin::ForeignUsersController < AdminController
2
+ before_action :set_entity, except: :index
3
+
4
+ # get /admin/foreign_users
5
+ def index
6
+ @collection = ForeignUser.page_for_administration(current_page)
7
+ end
8
+
9
+ # get /admin/foreign_users/:id
10
+ def show
11
+ end
12
+
13
+ protected
14
+
15
+ def restrict_access
16
+ require_privilege :administrator
17
+ end
18
+
19
+ def set_entity
20
+ @entity = ForeignUser.find_by(id: params[:id])
21
+ if @entity.nil?
22
+ handle_http_404('Cannot find foreign_user')
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,6 @@
1
+ class Api::EmbedController < ApplicationController
2
+ # get /api/embed
3
+ def index
4
+ head :no_content
5
+ end
6
+ end
@@ -35,9 +35,7 @@ class AuthenticationController < ApplicationController
35
35
  def set_foreign_site
36
36
  @foreign_site = ForeignSite.with_slug(params[:provider]).first
37
37
  if @foreign_site.nil?
38
- metric = Metric::METRIC_HTTP_503
39
- status = :service_unavailable
40
- handle_http_error('Cannot set foreign site', metric, status, status)
38
+ handle_http_503('Cannot set foreign site')
41
39
  end
42
40
  end
43
41
 
@@ -0,0 +1,24 @@
1
+ class ForeignUsersController < AdminController
2
+ before_action :set_entity, only: :destroy
3
+
4
+ # delete /foreign_users/:id
5
+ def destroy
6
+ if @entity.destroy
7
+ flash[:notice] = t('foreign_users.destroy.success')
8
+ end
9
+ redirect_to admin_foreign_users_path
10
+ end
11
+
12
+ private
13
+
14
+ def restrict_access
15
+ require_privilege :administrator
16
+ end
17
+
18
+ def set_entity
19
+ @entity = ForeignUser.find_by(id: params[:id])
20
+ if @entity.nil?
21
+ handle_http_404('Cannot find foreign_user')
22
+ end
23
+ end
24
+ end
@@ -68,11 +68,27 @@ class MediaFilesController < ApplicationController
68
68
  render json: {
69
69
  uploaded: 1,
70
70
  fileName: File.basename(@entity.name),
71
- url: @entity.file.medium_2x.url
71
+ url: @entity.file.medium_2x.url
72
72
  }
73
73
  end
74
74
  end
75
75
 
76
+ # post /media_files/medium
77
+ def medium
78
+ @entity = MediaFile.create!(medium_image_parameters)
79
+ end
80
+
81
+ # post /media_files/medium-jquery
82
+ def medium_jquery
83
+ files = []
84
+ if params.key?(:files)
85
+ params[:files].each do |file|
86
+ files << MediaFile.create(name: "image-#{Time.now.strftime('%F-%H-%M-%S')}", file: file)
87
+ end
88
+ end
89
+ render json: { files: files.map { |f| { url: f.file.medium_2x.url } } }
90
+ end
91
+
76
92
  protected
77
93
 
78
94
  def restrict_access
@@ -109,4 +125,11 @@ class MediaFilesController < ApplicationController
109
125
  end
110
126
  parameters.merge(owner_for_entity(true))
111
127
  end
128
+
129
+ def medium_image_parameters
130
+ default_name = { name: "image-#{Time.now.strftime('%F-%H-%M-%S')}" }
131
+ parameters = params.require(:media_file).permit(:file)
132
+
133
+ parameters.merge(default_name).merge(owner_for_entity(true))
134
+ end
112
135
  end
@@ -30,6 +30,12 @@ module BiovisionUsersHelper
30
30
  link_to(text, admin_user_path(id: entity.id), class: 'profile')
31
31
  end
32
32
 
33
+ # @param [ForeignUser] entity
34
+ # @param [String] long_slug
35
+ def admin_foreign_user_link(entity, text = entity.long_slug)
36
+ link_to(text, admin_foreign_user_path(id: entity.id))
37
+ end
38
+
33
39
  # @param [User] entity
34
40
  def editor_user_link(entity)
35
41
  return t(:anonymous) if entity.nil?
@@ -1,5 +1,5 @@
1
1
  class ForeignUser < ApplicationRecord
2
- PER_PAGE = 20
2
+ include HasOwner
3
3
 
4
4
  belongs_to :agent, optional: true
5
5
  belongs_to :foreign_site, counter_cache: true
@@ -9,10 +9,15 @@ class ForeignUser < ApplicationRecord
9
9
  validates_uniqueness_of :slug, scope: [:foreign_site_id]
10
10
 
11
11
  scope :ordered_by_slug, -> { order('slug asc') }
12
+ scope :list_for_administration, -> { ordered_by_slug }
12
13
 
13
14
  # @param [Integer] page
14
15
  def self.page_for_administration(page = 1)
15
- ordered_by_slug.page(page).per(PER_PAGE)
16
+ list_for_administration.page(page)
17
+ end
18
+
19
+ def long_slug
20
+ "#{foreign_site.slug}-#{slug}"
16
21
  end
17
22
 
18
23
  private
@@ -0,0 +1,6 @@
1
+ <div>
2
+ <%= link_to t('.text'), admin_foreign_users_path %>
3
+ </div>
4
+ <div class="description">
5
+ <%= t('.description') %>
6
+ </div>
@@ -0,0 +1,13 @@
1
+ <div class="image">
2
+ <%= user_image_preview(entity.user) %>
3
+ </div>
4
+ <div class="data">
5
+ <div><%= admin_foreign_user_link(entity) %></div>
6
+ <div class="info">
7
+ <%= admin_user_link(entity.user) %>: <%= entity.name %>
8
+ </div>
9
+ <div class="secondary info">
10
+ <div><%= t(:created_at) %>: <%= time_tag entity.created_at %></div>
11
+ <%= render partial: 'shared/track', locals: { item: entity } %>
12
+ </div>
13
+ </div>
@@ -0,0 +1,16 @@
1
+ <% content_for :meta_title, t('.title', page: current_page) %>
2
+ <% content_for :breadcrumbs do %>
3
+ <span><%= t('admin.foreign_users.nav_item.text') %></span>
4
+ <% end %>
5
+
6
+ <article>
7
+ <h1><%= t('.heading') %></h1>
8
+
9
+ <ul class="actions">
10
+ <li><%= back_icon(admin_path) %></li>
11
+ </ul>
12
+
13
+ <%= paginate @collection %>
14
+ <%= render partial: 'shared/admin/list', locals: { collection: @collection } %>
15
+ <%= paginate @collection %>
16
+ </article>
@@ -0,0 +1,62 @@
1
+ <% content_for :meta_title, t('.title', slug: @entity.long_slug) %>
2
+ <% content_for :breadcrumbs do %>
3
+ <%= link_to(t('admin.foreign_users.nav_item.text'), admin_foreign_users_path) %>
4
+ <span><%= @entity.long_slug %></span>
5
+ <% end %>
6
+
7
+ <article>
8
+ <h1><%= @entity.long_slug %></h1>
9
+
10
+ <ul class="actions">
11
+ <li><%= back_icon(admin_foreign_users_path) %></li>
12
+ <li class="danger"><%= destroy_icon(@entity) %></li>
13
+ </ul>
14
+
15
+ <figure role="group" class="preview">
16
+ <%= profile_avatar @entity.user %>
17
+ <figcaption>
18
+ <%= user_link(@entity.user) %>
19
+ </figcaption>
20
+ </figure>
21
+
22
+ <dl>
23
+ <dt><%= t('activerecord.attributes.foreign_user.foreign_site') %></dt>
24
+ <dd><%= @entity.foreign_site.name %></dd>
25
+
26
+ <dt><%= t('activerecord.attributes.foreign_user.slug') %></dt>
27
+ <dd><%= @entity.slug %></dd>
28
+
29
+ <dt><%= t('activerecord.attributes.foreign_user.user') %></dt>
30
+ <dd><%= admin_user_link(@entity.user) %></dd>
31
+
32
+ <% unless @entity.name.blank? %>
33
+ <dt><%= t('activerecord.attributes.foreign_user.name') %></dt>
34
+ <dd><%= @entity.name %></dd>
35
+ <% end %>
36
+
37
+ <% unless @entity.email.blank? %>
38
+ <dt><%= t('activerecord.attributes.foreign_user.email') %></dt>
39
+ <dd><%= link_to @entity.email, "mailto:#{@entity.email}" %></dd>
40
+ <% end %>
41
+
42
+ <% unless @entity.ip.blank? %>
43
+ <dt><%= t('activerecord.attributes.foreign_user.ip') %></dt>
44
+ <dd><%= @entity.ip %></dd>
45
+ <% end %>
46
+
47
+ <% unless @entity.agent.blank? %>
48
+ <dt><%= t('activerecord.attributes.foreign_user.agent') %></dt>
49
+ <dd><%= @entity.agent.name %></dd>
50
+ <% end %>
51
+
52
+ <dt><%= t(:created_at) %></dt>
53
+ <dd><%= time_tag @entity.created_at %></dd>
54
+
55
+ <dt><%= t('activerecord.attributes.foreign_user.data') %></dt>
56
+ <dd>
57
+ <% JSON.parse(@entity.data).each do |k, v| %>
58
+ <%= "#{k}: #{v}" %><br/>
59
+ <% end %>
60
+ </dd>
61
+ </dl>
62
+ </article>
@@ -3,6 +3,7 @@
3
3
  <div class="heading"><%= t('.heading') %></div>
4
4
  <ul>
5
5
  <li><%= render 'admin/users/nav_item' %></li>
6
+ <li><%= render 'admin/foreign_users/nav_item' %></li>
6
7
  <li><%= render 'admin/privileges/nav_item' %></li>
7
8
  <li><%= render 'admin/privilege_groups/nav_item' %></li>
8
9
  <li><%= render 'admin/login_attempts/nav_item' %></li>
@@ -33,6 +33,14 @@
33
33
  <%= admin_user_link(entity.inviter) %>
34
34
  </div>
35
35
  <% end %>
36
+ <% if entity.foreign_users.any? %>
37
+ <div class="secondary info">
38
+ <%= t('.foreign_users') %>:
39
+ <% entity.foreign_users.each do |foreign_user| %>
40
+ <%= admin_foreign_user_link(foreign_user) %><br/>
41
+ <% end %>
42
+ </div>
43
+ <% end %>
36
44
 
37
45
  <%=
38
46
  render(
@@ -89,6 +89,17 @@
89
89
  <dd><%= time_tag @entity.last_seen %></dd>
90
90
  <% end %>
91
91
 
92
+ <% if @entity.foreign_users.any? %>
93
+ <dt><%= t('admin.users.entity.in_list.foreign_users') %></dt>
94
+ <dd>
95
+ <ul>
96
+ <% @entity.foreign_users.each do |foreign_user| %>
97
+ <li><%= admin_foreign_user_link(foreign_user) %></li>
98
+ <% end %>
99
+ </ul>
100
+ </dd>
101
+ <% end %>
102
+
92
103
  <% if @entity.user_privileges.any? %>
93
104
  <dt><%= t('.privileges') %></dt>
94
105
  <dd>
@@ -0,0 +1,13 @@
1
+ json.data do
2
+ json.id @entity.id
3
+ json.type @entity.class.table_name
4
+ json.attributes do
5
+ json.(@entity, :name)
6
+ end
7
+ json.meta do
8
+ json.file do
9
+ json.large @entity.file.medium_2x.url
10
+ json.medium @entity.file.medium.url
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,6 @@
1
+ <div class="loading_message hidden">
2
+ <div><%= t('.saving') %></div>
3
+ <div class="state_container">
4
+ <progress value="0"></progress>
5
+ </div>
6
+ </div>
@@ -109,6 +109,9 @@ en:
109
109
  site_name: "example.com"
110
110
  twitter_site: ""
111
111
  twitter_creator: ""
112
+ forms:
113
+ state_container:
114
+ saving: "Saving..."
112
115
  admin:
113
116
  index:
114
117
  index:
@@ -110,6 +110,9 @@ ru:
110
110
  site_name: "example.com"
111
111
  twitter_site: ""
112
112
  twitter_creator: ""
113
+ forms:
114
+ state_container:
115
+ saving: "Сохранение…"
113
116
  admin:
114
117
  index:
115
118
  index:
@@ -109,6 +109,9 @@ sv:
109
109
  site_name: "example.com"
110
110
  twitter_site: ""
111
111
  twitter_creator: ""
112
+ forms:
113
+ state_container:
114
+ saving: "Sparar..."
112
115
  admin:
113
116
  index:
114
117
  index:
@@ -130,6 +130,15 @@ en:
130
130
  user: "User"
131
131
  password: "Password"
132
132
  admin:
133
+ foreign_users:
134
+ nav_item:
135
+ description: "Manage foreign users (authentication via Facebook, Google, etc.)"
136
+ text: "Foreign users"
137
+ index:
138
+ heading: "Foreign users"
139
+ title: "Foreign users, page %{page}"
140
+ show:
141
+ title: "Foreign user %{slug}"
133
142
  users:
134
143
  nav_item:
135
144
  text: "Users"
@@ -152,6 +161,9 @@ en:
152
161
  heading: "Privileges of user"
153
162
  filter:
154
163
  search: "Search"
164
+ entity:
165
+ in_list:
166
+ foreign_users: "Foreign users"
155
167
  tokens:
156
168
  nav_item:
157
169
  text: "Access tokens (user sessions)"
@@ -393,3 +405,6 @@ en:
393
405
  greeting: "Hello %{name}"
394
406
  message: "Someone is trying to log in to your account. For security reasons logging in for your account is suspended for 15 minutes."
395
407
  you_can_recover_password: "If you forgot your password, you can reset it by following this link"
408
+ foreign_users:
409
+ destroy:
410
+ success: "Foreign user has been deleted"
@@ -130,6 +130,15 @@ ru:
130
130
  user: "Пользователь"
131
131
  password: "Пароль"
132
132
  admin:
133
+ foreign_users:
134
+ nav_item:
135
+ description: "Управление внешними пользователями (авторизация через Facebook, Google и так далее)"
136
+ text: "Внешние пользователи"
137
+ index:
138
+ heading: "Внешние пользователи"
139
+ title: "Внешние пользователи, страница %{page}"
140
+ show:
141
+ title: "Внешний пользователь %{slug}"
133
142
  users:
134
143
  nav_item:
135
144
  text: "Пользователи"
@@ -152,6 +161,9 @@ ru:
152
161
  heading: "Привилегии пользователя"
153
162
  filter:
154
163
  search: "Искать"
164
+ entity:
165
+ in_list:
166
+ foreign_users: "Внешние пользователи"
155
167
  tokens:
156
168
  nav_item:
157
169
  text: "Жетоны доступа (сессии пользователей)"
@@ -393,3 +405,6 @@ ru:
393
405
  greeting: "Здравствуйте, %{name}"
394
406
  message: "Кто-то бесуспешно пытается войти от вашего имени. В целях безопасности возможность входа заблокирована на 15 минут."
395
407
  you_can_recover_password: "Если это вы забыли свой пароль, его можно восстановить по этой ссылке"
408
+ foreign_users:
409
+ destroy:
410
+ success: "Сторонний пользователь успешно удалён"
@@ -130,6 +130,15 @@ sv:
130
130
  user: "Användare"
131
131
  password: "Lösenord"
132
132
  admin:
133
+ foreign_users:
134
+ nav_item:
135
+ description: "Hantera utländska användare (autentisering via Facebook, Google, etc.)"
136
+ text: "Utländska användare"
137
+ index:
138
+ heading: "Utländska användare"
139
+ title: "Utländska användare, sida %{page}"
140
+ show:
141
+ title: "Utländsk användare %{slug}"
133
142
  users:
134
143
  nav_item:
135
144
  text: "Användares"
@@ -152,6 +161,9 @@ sv:
152
161
  heading: "Privilegiums av användare"
153
162
  filter:
154
163
  search: "Sök"
164
+ entity:
165
+ in_list:
166
+ foreign_users: "Utländska användare"
155
167
  tokens:
156
168
  nav_item:
157
169
  text: "Tillgång teckens (användarsessioner)"
@@ -393,3 +405,6 @@ sv:
393
405
  greeting: "Hallå %{name}"
394
406
  message: "Någon försöker logga in på ditt konto. Av säkerhetsskäl inloggas ditt konto i 15 minuter."
395
407
  you_can_recover_password: "Om du glömde ditt lösenord kan du återställa det genom att följa den här länken"
408
+ foreign_users:
409
+ destroy:
410
+ success: "Utländsk användare har tagits bort"
data/config/routes.rb CHANGED
@@ -6,6 +6,7 @@ Rails.application.routes.draw do
6
6
  resources :stored_values, only: %i[update destroy]
7
7
 
8
8
  resources :users, only: %i[update destroy]
9
+ resources :foreign_users, only: :destroy
9
10
  resources :tokens, :codes, only: %i[update destroy]
10
11
 
11
12
  resources :metrics, only: :update
@@ -119,6 +120,8 @@ Rails.application.routes.draw do
119
120
  end
120
121
  end
121
122
 
123
+ resources :foreign_users, only: %i[index show]
124
+
122
125
  resources :login_attempts, only: :index
123
126
 
124
127
  resources :media_folders, only: %i[index show] do
@@ -152,6 +155,10 @@ Rails.application.routes.draw do
152
155
  end
153
156
  end
154
157
 
158
+ # namespace :api, defaults: { format: :json } do
159
+ # get 'embed' => 'embed#index'
160
+ # end
161
+
155
162
  namespace :my do
156
163
  get '/' => 'index#index'
157
164
 
@@ -199,6 +206,8 @@ Rails.application.routes.draw do
199
206
  resources :media_files, except: %i[index show update destroy] do
200
207
  collection do
201
208
  post :ckeditor
209
+ post :medium, defaults: { format: :json }
210
+ post :medium_jquery, defaults: { format: :json }
202
211
  end
203
212
  end
204
213
 
@@ -53,7 +53,7 @@ module Biovision
53
53
  if current_user.nil?
54
54
  "#{request.env['HTTP_X_REAL_IP'] || request.remote_ip}:#{agent.id}"
55
55
  else
56
- current_user.id
56
+ current_user.id.to_s
57
57
  end
58
58
  end
59
59
 
@@ -85,6 +85,17 @@ module Biovision
85
85
  handle_http_error(message, metric || default_metric, view, status)
86
86
  end
87
87
 
88
+ # Handle HTTP error with status 503 without raising exception
89
+ #
90
+ # @param [String] message
91
+ # @param [String] metric
92
+ # @param [Symbol|String] view
93
+ def handle_http_503(message, metric = nil, view = :service_unavailable)
94
+ status = :service_unavailable
95
+ default_metric = Metric::METRIC_HTTP_503
96
+ handle_http_error(message, metric || default_metric, view, status)
97
+ end
98
+
88
99
  # Handle generic HTTP error without raising exception
89
100
  #
90
101
  # @param [String] message
@@ -1,5 +1,5 @@
1
1
  module Biovision
2
2
  module Base
3
- VERSION = '0.20.180731.0'
3
+ VERSION = '0.21.180812.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: biovision-base
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.180731.0
4
+ version: 0.21.180812.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxim Khan-Magomedov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-31 00:00:00.000000000 Z
11
+ date: 2018-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -222,6 +222,7 @@ files:
222
222
  - app/controllers/admin/editable_blocks_controller.rb
223
223
  - app/controllers/admin/editable_pages_controller.rb
224
224
  - app/controllers/admin/feedback_requests_controller.rb
225
+ - app/controllers/admin/foreign_users_controller.rb
225
226
  - app/controllers/admin/index_controller.rb
226
227
  - app/controllers/admin/link_block_items_controller.rb
227
228
  - app/controllers/admin/link_blocks_controller.rb
@@ -236,6 +237,7 @@ files:
236
237
  - app/controllers/admin/users_controller.rb
237
238
  - app/controllers/admin_controller.rb
238
239
  - app/controllers/agents_controller.rb
240
+ - app/controllers/api/embed_controller.rb
239
241
  - app/controllers/authentication_controller.rb
240
242
  - app/controllers/browsers_controller.rb
241
243
  - app/controllers/codes_controller.rb
@@ -249,6 +251,7 @@ files:
249
251
  - app/controllers/errors_controller.rb
250
252
  - app/controllers/fallback_controller.rb
251
253
  - app/controllers/feedback_requests_controller.rb
254
+ - app/controllers/foreign_users_controller.rb
252
255
  - app/controllers/index_controller.rb
253
256
  - app/controllers/link_block_items_controller.rb
254
257
  - app/controllers/link_blocks_controller.rb
@@ -359,6 +362,10 @@ files:
359
362
  - app/views/admin/feedback_requests/_nav_item.html.erb
360
363
  - app/views/admin/feedback_requests/entity/_in_list.html.erb
361
364
  - app/views/admin/feedback_requests/index.html.erb
365
+ - app/views/admin/foreign_users/_nav_item.html.erb
366
+ - app/views/admin/foreign_users/entity/_in_list.html.erb
367
+ - app/views/admin/foreign_users/index.html.erb
368
+ - app/views/admin/foreign_users/show.html.erb
362
369
  - app/views/admin/index/_biovision_base.html.erb
363
370
  - app/views/admin/index/_custom_dashboard.html.erb
364
371
  - app/views/admin/index/dashboard/_biovision_feedback.html.erb
@@ -508,6 +515,7 @@ files:
508
515
  - app/views/media_files/ckeditor.html.erb
509
516
  - app/views/media_files/edit.html.erb
510
517
  - app/views/media_files/edit.js.erb
518
+ - app/views/media_files/medium.jbuilder
511
519
  - app/views/media_files/new.html.erb
512
520
  - app/views/media_files/new.js.erb
513
521
  - app/views/media_folders/_form.html.erb
@@ -571,6 +579,7 @@ files:
571
579
  - app/views/shared/filter/_flag.html.erb
572
580
  - app/views/shared/forms/_entity_flags.html.erb
573
581
  - app/views/shared/forms/_image_remover.html.erb
582
+ - app/views/shared/forms/_state_container.html.erb
574
583
  - app/views/shared/forms/_wysiwyg.html.erb
575
584
  - app/views/shared/forms/check.jbuilder
576
585
  - app/views/shared/forms/errors.js.erb