Removed unneeded ERB tags, which caused error. Minor refactoring.

This commit is contained in:
Matej Zrimšek 2016-10-13 10:00:36 +02:00
parent ece89da391
commit a6a2a237aa
27 changed files with 169 additions and 113 deletions

View file

@ -36,7 +36,7 @@ var DEFAULT_CONNECTOR_STYLE =
} ];
var DEFAULT_CONNECTOR_STYLE_2 =
{
strokeStyle: "#FFFFFF",
strokeStyle: "<%= Constants::COLOR_WHITE %>",
lineWidth: 1.5,
outlineColor: "transparent",
outlineWidth: 0
@ -57,7 +57,7 @@ var EDIT_ENDPOINT_STYLE =
} ];
var EDIT_CONNECTOR_STYLE_2 =
{
strokeStyle: "#FFFFFF",
strokeStyle: "<%= Constants::COLOR_WHITE %>",
lineWidth: 3,
outlineColor: "transparent",
outlineWidth: 0

View file

@ -466,12 +466,12 @@
.find('.form-submit-link')
.css({
'pointer-events': 'none',
'color': '#d2d2d2'});
'color': <%= Constants::COLOR_ALTO %>});
$(el)
.find('[data-action="edit"]')
.css({
'pointer-events': 'none',
'color': '#d2d2d2'});
'color': <%= Constants::COLOR_ALTO %>});
});
}
});
@ -489,12 +489,12 @@
.find('.form-submit-link')
.css({
'pointer-events': 'auto',
'color': '#262626'});
'color': <%= Constants::COLOR_NERO %>});
$(el)
.find('[data-action="edit"]')
.css({
'pointer-events': 'auto',
'color': '#262626'});
'color': <%= Constants::COLOR_NERO %>});
});
}

View file

@ -280,8 +280,8 @@ function initHandsOnTable(root) {
var contents = $(this).find('.hot-contents');
$container.handsontable({
startRows: 5,
startCols: 5,
startRows: <%= Constants::HANDSONTABLE_INIT_ROWS_CNT %>,
startCols: <%= Constants::HANDSONTABLE_INIT_COLS_CNT %>,
rowHeaders: true,
colHeaders: true,
fillHandle: false,
@ -326,8 +326,8 @@ function initEditableHandsOnTable(root) {
$container.handsontable({
data: data,
startRows: 5,
startCols: 5,
startRows: <%= Constants::HANDSONTABLE_INIT_ROWS_CNT %>,
startCols: <%= Constants::HANDSONTABLE_INIT_COLS_CNT %>,
minRows: 1,
minCols: 1,
rowHeaders: true,

View file

@ -1125,7 +1125,7 @@ function initializeReportSidebartruncation() {
$.each($("a.report-nav-link"),
function(){
truncateLongString($(this),
<%= Constants::NAME_TRUNCATION_LENGTH %>);
<%= Constants::NAME_TRUNCATION_LENGTH %>);
});
}
);

View file

@ -10,8 +10,8 @@ function initEditableHandsOnTable(root) {
$container.handsontable({
data: data,
startRows: 5,
startCols: 5,
startRows: <%= Constants::HANDSONTABLE_INIT_ROWS_CNT %>,
startCols: <%= Constants::HANDSONTABLE_INIT_COLS_CNT %>,
minRows: 1,
minCols: 1,
rowHeaders: true,

View file

@ -38,4 +38,4 @@ $("form#form-import")
// Populate the errors container
$("#import-errors-container").html(data.responseJSON.html);
}
});
});

View file

@ -5,7 +5,6 @@
var STORAGE_TREE_KEY = "scinote-sidebar-tree-collapsed-ids";
var STORAGE_TOGGLE_KEY = "scinote-sidebar-toggled";
var SCREEN_SIZE_LARGE = 928;
/**
* Get all collapsed sidebar elements.
@ -251,7 +250,8 @@ function initializeSidebarToggle() {
var wrapper = $("#wrapper");
var toggled = sessionIsSidebarToggled();
if (toggled || toggled === null && $(window).width() < SCREEN_SIZE_LARGE) {
if (toggled || toggled === null && $(window).width() <
<%= Constants::SCREEN_WIDTH_LARGE %>) {
wrapper.addClass("no-animation");
wrapper.addClass("toggled");
// Cause reflow of the wrapper element
@ -283,7 +283,7 @@ function resizeSidebarContents() {
}
// Automatic toggling of sidebar for smaller devices
if (toggled === null) {
if ($(window).width() < SCREEN_SIZE_LARGE) {
if ($(window).width() < <%= Constants::SCREEN_WIDTH_LARGE %>) {
wrapper.addClass("toggled");
navbar.addClass("navbar-without-sidebar");
} else {

View file

@ -3,26 +3,28 @@ $color-theme-primary: #37a0d9;
$color-theme-secondary: #8fd13f;
$color-theme-dark: #6d6e71;
// Grayscales
// Grayscale colors
$color-white: #fff;
$color-alabaster: #fcfcfc;
$color-wild-sand: #f5f5f5;
$color-concrete: #f2f2f2;
$color-gallery: #EEE;
$color-gallery: #eee;
$color-alto: #d2d2d2;
$color-silver: #c5c5c5;
$color-dark-gray: #adadad;
$color-silver-chalice: #a0a0a0;
$color-gray: #909088;
$color-dove-gray: #666666;
$color-dove-gray: #666;
$color-emperor: #555;
$color-mine-shaft: #333;
$color-nero: #262626;
$color-black: #000;
// Misc.
// Miscelaneous colors
$color-mystic: #eaeff2;
$color-candlelight: #ffda23;
// Reds
// Red colors
$color-mojo: #cf4b48;
$color-apple-blossom: #a94442;
$color-milano-red: #a70b05;

View file

@ -2,8 +2,10 @@
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
@import 'colors';
#search-content {
background-color: #fff;
background-color: $color-white;
padding-top: 20px;
}
.search-asset-text-data{

View file

@ -650,7 +650,7 @@ a[data-toggle="tooltip"] {
&:focus, &:active, &:hover {
box-shadow: none;
background-color: $color-theme-primary;
border-color: #adadad;
border-color: $color-dark-gray;
}
}
}
@ -1064,7 +1064,7 @@ ul.content-module-activities {
}
.badge-preview {
background-color:#c5c5c5;
background-color: $color-silver;
border-radius: 2em;
float: left;
font-size: 20px;
@ -1247,12 +1247,12 @@ table.dataTable {
top: 50%;
margin-top: -19px;
border-top: 19px solid transparent;
border-left: 13px solid #37A0D9;
border-left: 13px solid $color-theme-primary;
border-bottom: 19px solid transparent;
}
.nav-stacked-arrow > li.active > a:hover:after {
border-left: 13px solid #337ab7;
border-left: 13px solid darken($color-theme-primary, 15%);
}
/* Overlay to disable interaction while loading ajax */

View file

@ -2,7 +2,7 @@ class ActivitiesController < ApplicationController
before_filter :load_vars
def index
@per_page = 10
@per_page = Constants::ACTIVITY_AND_NOTIF_SEARCH_LIMIT
@activities = current_user.last_activities(@last_activity_id,
@per_page + 1)

View file

@ -3,7 +3,7 @@ class SampleMyModulesController < ApplicationController
def index
@number_of_samples = @my_module.number_of_samples
@samples = @my_module.first_n_samples(5)
@samples = @my_module.first_n_samples
respond_to do |format|
format.json {

View file

@ -3,7 +3,7 @@ class UserNotificationsController < ApplicationController
def index
@last_notification_id = params[:from].to_i || 0
@per_page = 10
@per_page = Constants::ACTIVITY_AND_NOTIF_SEARCH_LIMIT
@notifications =
UserNotification.last_notifications(@current_user,

View file

@ -179,7 +179,11 @@ class Users::RegistrationsController < Devise::RegistrationsController
def sign_up_params
tmp = params.require(:user).permit(:full_name, :initials, :email, :password, :password_confirmation)
initials = tmp[:full_name].titleize.scan(/[A-Z]+/).join()
initials = initials.strip.empty? ? "PLCH" : initials[0..3]
initials = if initials.strip.empty?
'PLCH'
else
initials[0..Constants::USER_INITIALS_MAX_LENGTH]
end
tmp.merge(:initials => initials)
end

View file

@ -16,7 +16,7 @@ module AssetsHelper
<script type='text/javascript'>
$('#asset-loading-spinner-#{asset.id}').spin(
{ lines: 9, length: 4, width: 3, radius: 4, scale: 1, corners: 1,
color: '#000', opacity: 0.25, rotate: 0, direction: 1, speed: 1,
color: #{Constants::COLOR_BLACK}, opacity: 0.25, rotate: 0, direction: 1, speed: 1,
trail: 60, fps: 20, zIndex: 100, className: 'spinner', top: '75%',
left: '50%', shadow: false, hwaccel: false, position: 'relative' }
);
@ -24,4 +24,4 @@ module AssetsHelper
eos
res.html_safe
end
end
end

View file

@ -218,14 +218,14 @@ class Experiment < ActiveRecord::Base
use: :neato)
graph[:size] = '4,4'
graph.node[color: '#d2d2d2',
graph.node[color: Constants::COLOR_ALTO,
style: :filled,
fontcolor: '#555555',
fontcolor: Constants::COLOR_EMPEROR,
shape: 'circle',
fontname: 'Arial',
fontsize: '16.0']
graph.edge[color: '#d2d2d2']
graph.edge[color: Constants::COLOR_ALTO]
label = ''
subg = {}

View file

@ -146,7 +146,7 @@ class MyModule < ActiveRecord::Base
)
end
def last_activities(count = Constants::ACTIVITY_SEARCH_LIMIT)
def last_activities(count = Constants::ACTIVITY_AND_NOTIF_SEARCH_LIMIT)
Activity.where(my_module_id: id).order(:created_at).last(count)
end
@ -162,7 +162,8 @@ class MyModule < ActiveRecord::Base
comments.reverse
end
def last_activities(last_id = 1, count = Constants::ACTIVITY_SEARCH_LIMIT)
def last_activities(last_id = 1,
count = Constants::ACTIVITY_AND_NOTIF_SEARCH_LIMIT)
last_id = 9999999999999 if last_id <= 1
Activity.joins(:my_module)
.where(my_module_id: id)
@ -178,7 +179,7 @@ class MyModule < ActiveRecord::Base
protocols.count > 0 ? protocols.first : nil
end
def first_n_samples(count)
def first_n_samples(count = Constants::SEARCH_LIMIT)
samples.order(name: :asc).limit(count)
end

View file

@ -74,7 +74,7 @@ class Project < ActiveRecord::Base
end
end
def last_activities(count = Constants::ACTIVITY_SEARCH_LIMIT)
def last_activities(count = Constants::ACTIVITY_AND_NOTIF_SEARCH_LIMIT)
activities.order(created_at: :desc).first(count)
end

View file

@ -1,8 +1,9 @@
class User < ActiveRecord::Base
include SearchableModel
devise :invitable, :confirmable, :database_authenticatable, :registerable, :async,
:recoverable, :rememberable, :trackable, :validatable, stretches: 10
devise :invitable, :confirmable, :database_authenticatable, :registerable,
:async, :recoverable, :rememberable, :trackable, :validatable,
stretches: Constants::PASSWORD_STRETCH_FACTOR
has_attached_file :avatar,
styles: {
medium: Constants::MEDIUM_PIC_FORMAT,
@ -239,7 +240,7 @@ class User < ActiveRecord::Base
# is not an owner of the project, user must be also assigned to
# module.
def last_activities(last_activity_id = nil,
per_page = Constants::ACTIVITY_SEARCH_LIMIT)
per_page = Constants::ACTIVITY_AND_NOTIF_SEARCH_LIMIT)
# TODO replace with some kind of Infinity value
last_activity_id = 999999999999999999999999 if last_activity_id < 1
Activity

View file

@ -6,7 +6,11 @@ class UserNotification < ActiveRecord::Base
after_save :send_email
def self.last_notifications(user, last_notification_id = nil, per_page = 10)
def self.last_notifications(
user,
last_notification_id = nil,
per_page = Constants::ACTIVITY_AND_NOTIF_SEARCH_LIMIT
)
last_notification_id = 999999999999999999999999 if last_notification_id < 1
Notification.joins(:user_notifications)
.where('user_notifications.user_id = ?', user.id)
@ -19,7 +23,7 @@ class UserNotification < ActiveRecord::Base
Notification.joins(:user_notifications)
.where('user_notifications.user_id = ?', user.id)
.order(created_at: :DESC)
.limit(10)
.limit(Constants::COMMENTS_SEARCH_LIMIT)
end
def self.unseen_notification_count(user)

View file

@ -41,19 +41,19 @@ module FirstTimeDataGenerator
SampleGroup.create(
name: "Fodder",
organization: org,
color: "#159B5E"
color: Constants::TAG_COLORS[1]
)
SampleGroup.create(
name: "Nutrient",
organization: org,
color: "#6C159E"
color: Constants::TAG_COLORS[0]
)
SampleGroup.create(
name: "Seed",
organization: org,
color: "#FF4500"
color: Constants::TAG_COLORS[2]
)
samples = []
@ -360,21 +360,21 @@ module FirstTimeDataGenerator
# Create tags and add them to module
drylab_tag = Tag.create(
name: "Drylab",
color: "#15369E",
color: Constants::TAG_COLORS[8],
project: project,
created_by: user,
last_modified_by: user
)
wetlab_tag = Tag.create(
name: "Wetlab",
color: "#FF8C00",
color: Constants::TAG_COLORS[14],
project: project,
created_by: user,
last_modified_by: user
)
decide_tag = Tag.create(
name: "Decide",
color: "#32CD32",
color: Constants::TAG_COLORS[5],
project: project,
created_by: user,
last_modified_by: user

View file

@ -7,7 +7,7 @@
<% if activity.my_module %>
[<%=t 'Project' %>:
<% if activity.my_module.experiment.project.name.length >
<%= Constants::NAME_TRUNCATION_LENGTH %> %>
Constants::NAME_TRUNCATION_LENGTH %>
<div class="modal-tooltip">
<%= truncate(activity.my_module.experiment.project.name,
lenght: Constants::NAME_TRUNCATION_LENGTH).strip %>
@ -17,7 +17,7 @@
<%= activity.my_module.experiment.project.name %>
<% end %>, <%=t 'Module' %>:
<% if activity.my_module.name.length >
<%= Constants::NAME_TRUNCATION_LENGTH %> %>
Constants::NAME_TRUNCATION_LENGTH %>
<div class="modal-tooltip"><%= truncate(
activity.my_module.name,
lenght: Constants::NAME_TRUNCATION_LENGTH) %>

View file

@ -40,7 +40,7 @@
<%= f.text_field :name, hide_label: true %>
</div>
<div class="pull-right">
<%= f.color_picker_select :color, <%= Constants::TAG_COLORS %>, class: "edit-tag-color" %>
<%= f.color_picker_select :color, Constants::TAG_COLORS, class: "edit-tag-color" %>
<%= f.button class: "btn btn-link save-tag-link", title: t("experiments.canvas.modal_manage_tags.save_tag") do %>
<span class="glyphicon glyphicon-ok"></span>
<% end %>
@ -84,7 +84,7 @@
<%= hidden_field_tag :my_module_id, @my_module.id %>
<%= f.hidden_field :project_id, :value => @my_module.experiment.project.id %>
<%= f.hidden_field :name, :value => t("tags.create.new_name") %>
<%= f.hidden_field :color, :value => <%= Constants::TAG_COLORS[0] %> %>
<%= f.hidden_field :color, :value => Constants::TAG_COLORS[0] %>
<%= f.button class: "btn btn-primary" do %>
<span class="glyphicon glyphicon-tag"></span>
<span class="hidden-xs"><%=t "experiments.canvas.modal_manage_tags.create_new" %></span>

View file

@ -27,7 +27,7 @@
<div class="workflowimg-container">
<%= image_tag(
experiment.workflowimg.expiring_url(
<%= Constants::URL_SHORT_EXPIRE_TIME %>
Constants::URL_SHORT_EXPIRE_TIME
),
class: 'img-responsive center-block') %>
</div>

View file

@ -1,5 +1,5 @@
<%= link_to image_tag(@experiment.workflowimg.expiring_url(
<%= Constants::URL_SHORT_EXPIRE_TIME %>
Constants::URL_SHORT_EXPIRE_TIME
),
class: 'img-responsive center-block'),
canvas_experiment_path(@experiment) %>

View file

@ -8,7 +8,7 @@
<%= bootstrap_form_for SampleGroup.new, remote: true, url: organization_sample_groups_path(@organization) do |f| %>
<div class="modal-body">
<%= f.text_field :name, id: "name-input" %>
<%= f.color_picker_btn_group :color, <%= Constants::TAG_COLORS %>, id: "color-input", class: "btn-group-sample-group-color", label: t("sample_groups.color_label")%>
<%= f.color_picker_btn_group :color, Constants::TAG_COLORS, id: "color-input", class: "btn-group-sample-group-color", label: t("sample_groups.color_label")%>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><%= t("general.cancel")%></button>

View file

@ -1,51 +1,6 @@
class Constants
#=============================================================================
# Defaults
#=============================================================================
# Application version
APP_VERSION = '1.3.1'.freeze
TAG_COLORS = [
'#6C159E',
'#159B5E',
'#FF4500',
'#008B8B',
'#757575',
'#32CD32',
'#FFD700',
'#48D1CC',
'#15369E',
'#FF69B4',
'#CD5C5C',
'#C9C9C9',
'#6495ED',
'#DC143C',
'#FF8C00',
'#C71585',
'#000000'
].freeze
TEXT_EXTRACT_FILE_TYPES = [
'application/pdf',
'application/rtf',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'application/vnd.oasis.opendocument.presentation',
'application/vnd.oasis.opendocument.spreadsheet',
'application/vnd.oasis.opendocument.text',
'application/vnd.ms-excel',
'application/vnd.ms-powerpoint',
'application/vnd.ms-word',
'text/plain'
].freeze
# Organization name for default admin user
DEFAULT_PRIVATE_ORG_NAME = 'My projects'.freeze
#=============================================================================
# String length
# String lengths
#=============================================================================
# Min characters for short text fields
@ -64,6 +19,8 @@ class Constants
FILENAME_TRUNCATION_LENGTH = 50
USER_INITIALS_MAX_LENGTH = 4
# Password 'key stretching' factor
PASSWORD_STRETCH_FACTOR = 10
# Standard max length for email
EMAIL_MAX_LENGTH = 254
@ -79,7 +36,7 @@ class Constants
# Comments limited query/display elements for pages
COMMENTS_SEARCH_LIMIT = 10
# Activity limited query/display elements for pages
ACTIVITY_SEARCH_LIMIT = 20
ACTIVITY_AND_NOTIF_SEARCH_LIMIT = 10
#=============================================================================
# File and data memory size
@ -93,14 +50,33 @@ class Constants
AVATAR_MAX_SIZE_MB = 0.2
#=============================================================================
# Picture size format
# Application space
#=============================================================================
# Minimal space needed for organization (in B)
MINIMAL_ORGANIZATION_SPACE_TAKEN = 1.megabyte
# Additional space of each file is added to its estimated size to account for
# DB indexes size etc.
ASSET_ESTIMATED_SIZE_FACTOR = 1.1
#=============================================================================
# Format sizes
#=============================================================================
# Picture size formats
MEDIUM_PIC_FORMAT = '300x300>'.freeze
THUMB_PIC_FORMAT = '100x100>'.freeze
ICON_PIC_FORMAT = '40x40>'.freeze
ICON_SMALL_PIC_FORMAT = '30x30>'.freeze
# Hands-on-table number of starting columns and rows
HANDSONTABLE_INIT_COLS_CNT = 5
HANDSONTABLE_INIT_ROWS_CNT = 5
# Screen width which is still suitable for sidebar to be shown, otherwise
# hidden
SCREEN_WIDTH_LARGE = 928
#=============================================================================
# Styling
#=============================================================================
@ -122,17 +98,62 @@ class Constants
URL_LONG_EXPIRE_TIME = 86_400
#=============================================================================
# Space
# Application colors
#=============================================================================
# 1 MB of space is minimal for organizations (in B)
MINIMAL_ORGANIZATION_SPACE_TAKEN = 1.megabyte
# additional space of each file is added to its estimated
# size to account for DB indexes size etc.
ASSET_ESTIMATED_SIZE_FACTOR = 1.1
TAG_COLORS = [
'#6C159E',
'#159B5E',
'#FF4500',
'#008B8B',
'#757575',
'#32CD32',
'#FFD700',
'#48D1CC',
'#15369E',
'#FF69B4',
'#CD5C5C',
'#C9C9C9',
'#6495ED',
'#DC143C',
'#FF8C00',
'#C71585',
'#000'
].freeze
# Theme colors
COLOR_THEME_PRIMARY = '#37a0d9'.freeze # $color-theme-primary
COLOR_THEME_SECONDARY = '#8fd13f'.freeze # $color-theme-secondary
COLOR_THEME_DARK = '#6d6e71'.freeze # $color-theme-dark
# Grayscale colors
COLOR_WHITE = '#fff'.freeze # $color-white
COLOR_ALABASTER = '#fcfcfc'.freeze # $color-alabaster
COLOR_WILD_SAND = '#f5f5f5'.freeze # $color-wild-sand
COLOR_CONCRETE = '#f2f2f2'.freeze # $color-concrete
COLOR_GALLERY = '#eee'.freeze # $color-gallery
COLOR_ALTO = '#d2d2d2'.freeze # $color-alto
COLOR_SILVER = '#c5c5c5'.freeze # $color-silver
COLOR_DARK_GRAY = '#adadad'.freeze # $color-dark-gray
COLOR_SILVER_CHALICE = '#a0a0a0'.freeze # $color-silver-chalice
COLOR_GRAY = '#909088'.freeze # $color-gray
COLOR_DOVE_GRAY = '#666'.freeze # $color-dove-gray
COLOR_EMPEROR = '#555'.freeze # $color-emperor
COLOR_MINE_SHAFT = '#333'.freeze # $color-mine-shaft
COLOR_NERO = '#262626'.freeze # $color-nero
COLOR_BLACK = '#000'.freeze # $color-black
# Miscelaneous colors
COLOR_MYSTIC = '#eaeff2'.freeze # $color-mystic
COLOR_CANDLELIGHT = '#ffda23'.freeze # $color-candlelight
# Red colors
COLOR_MOJO = '#cf4b48'.freeze # $color-mojo
COLOR_APPLE_BLOSSOM = '#a94442'.freeze # $color-apple-blossom
COLOR_MILANO_RED = '#a70b05'.freeze # $color-milano-red
#=============================================================================
# External URL
# External URLs
#=============================================================================
HTTP = 'http://'.freeze
@ -149,6 +170,27 @@ class Constants
# Other
#=============================================================================
# Application version
APP_VERSION = '1.3.1'.freeze
TEXT_EXTRACT_FILE_TYPES = [
'application/pdf',
'application/rtf',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'application/vnd.oasis.opendocument.presentation',
'application/vnd.oasis.opendocument.spreadsheet',
'application/vnd.oasis.opendocument.text',
'application/vnd.ms-excel',
'application/vnd.ms-powerpoint',
'application/vnd.ms-word',
'text/plain'
].freeze
# Organization name for default admin user
DEFAULT_PRIVATE_ORG_NAME = 'My projects'.freeze
# ) \ / (
# /|\ )\_/( /|\
# * / | \ (/\|/\) / | \ *