beyond_canvas 0.16.2.pre → 0.17.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/config/beyond_canvas_manifest.js +1 -0
- data/app/assets/images/icons/arrow_right.svg +1 -0
- data/app/assets/images/icons/close.svg +1 -0
- data/app/assets/images/icons/home.svg +1 -0
- data/app/assets/javascripts/beyond_canvas/base.js +120 -246
- data/app/assets/stylesheets/beyond_canvas/base.scss +8 -1
- data/app/assets/stylesheets/beyond_canvas/components/_action_bar.scss +28 -0
- data/app/assets/stylesheets/beyond_canvas/components/_breadcrumbs.scss +29 -0
- data/app/assets/stylesheets/beyond_canvas/components/_buttons.scss +1 -1
- data/app/assets/stylesheets/beyond_canvas/components/_debug.scss +10 -0
- data/app/assets/stylesheets/beyond_canvas/components/_forms.scss +11 -14
- data/app/assets/stylesheets/beyond_canvas/components/_main.scss +12 -13
- data/app/assets/stylesheets/beyond_canvas/components/_margins.scss +8 -0
- data/app/assets/stylesheets/beyond_canvas/components/_menu.scss +40 -0
- data/app/assets/stylesheets/beyond_canvas/components/_modals.scss +27 -0
- data/app/assets/stylesheets/beyond_canvas/components/_sidebar.scss +53 -0
- data/app/assets/stylesheets/beyond_canvas/components/_titles.scss +7 -0
- data/app/assets/stylesheets/beyond_canvas/settings/_variables.scss +64 -9
- data/app/controllers/beyond_canvas/application_controller.rb +2 -0
- data/app/controllers/beyond_canvas/authentications_controller.rb +37 -30
- data/app/controllers/concerns/beyond_canvas/authentication.rb +1 -12
- data/app/controllers/concerns/beyond_canvas/locale_management.rb +5 -4
- data/app/helpers/beyond_canvas/authentications_helper.rb +28 -0
- data/app/helpers/beyond_canvas/cockpit_app_helper.rb +17 -0
- data/app/helpers/beyond_canvas/debug_helper.rb +9 -0
- data/app/helpers/beyond_canvas/locale_switch_helper.rb +5 -1
- data/app/javascript/beyond_canvas/base.js +3 -0
- data/app/javascript/beyond_canvas/initializers/buttons.js +65 -19
- data/app/javascript/beyond_canvas/initializers/flash.js +9 -2
- data/app/javascript/beyond_canvas/initializers/inputs.js +4 -1
- data/app/javascript/beyond_canvas/initializers/modals.js +14 -0
- data/app/views/beyond_canvas/authentications/new.html.erb +19 -10
- data/app/views/beyond_canvas/shared/_action_bar.html.erb +15 -0
- data/app/views/beyond_canvas/shared/_breadcrumbs.html.erb +14 -0
- data/app/views/beyond_canvas/shared/_flash.html.erb +22 -12
- data/app/views/beyond_canvas/shared/_locales.html.erb +8 -0
- data/app/views/beyond_canvas/shared/_menu.html.erb +31 -0
- data/app/views/beyond_canvas/shared/_modal.html.erb +6 -0
- data/app/views/beyond_canvas/shared/_sidebar.html.erb +16 -0
- data/app/views/layouts/beyond_canvas/application.html.erb +31 -0
- data/app/views/layouts/beyond_canvas/public.html.erb +11 -4
- data/config/locales/en.yml +5 -0
- data/config/routes.rb +5 -4
- data/lib/beyond_canvas.rb +12 -12
- data/lib/beyond_canvas/configuration.rb +11 -6
- data/lib/beyond_canvas/engine.rb +4 -2
- data/lib/beyond_canvas/menu_item_registration.rb +19 -0
- data/lib/beyond_canvas/parameter_sanitizer.rb +1 -1
- data/lib/beyond_canvas/rails/routes.rb +8 -7
- data/lib/beyond_canvas/version.rb +1 -1
- data/lib/generators/beyond_canvas/controller/controller_generator.rb +1 -2
- data/lib/generators/beyond_canvas/controller/templates/controller.erb +2 -19
- data/lib/generators/beyond_canvas/custom_menu/custom_menu_generator.rb +13 -0
- data/lib/generators/beyond_canvas/custom_menu/templates/beyond_canvas_custom_menu.html.erb +32 -0
- data/lib/generators/beyond_canvas/custom_styles/custom_styles_generator.rb +1 -1
- data/lib/generators/beyond_canvas/custom_styles/templates/beyond_canvas_custom_styles.scss +55 -9
- data/lib/generators/beyond_canvas/install/install_generator.rb +3 -5
- data/lib/generators/beyond_canvas/install/templates/beyond_canvas.rb.erb +51 -13
- data/lib/generators/beyond_canvas/{auth_model/auth_model_generator.rb → model/model_generator.rb} +4 -5
- data/lib/generators/beyond_canvas/{auth_model → model}/templates/migration.erb +2 -4
- data/lib/generators/beyond_canvas/{auth_model → model}/templates/model.erb +0 -0
- data/lib/generators/beyond_canvas/views/views_generator.rb +4 -6
- data/lib/models/concerns/authentication.rb +57 -0
- data/lib/models/concerns/utils.rb +79 -0
- data/lib/models/shop.rb +12 -0
- metadata +69 -30
- data/app/controllers/concerns/beyond_canvas/resource_management.rb +0 -33
- data/app/javascript/beyond_canvas/initializers/functions.js +0 -41
- data/app/views/beyond_canvas/locales/_edit.html.erb +0 -8
- data/lib/beyond_canvas/models/authentication.rb +0 -66
- data/lib/beyond_canvas/models/shop.rb +0 -28
- data/lib/beyond_canvas/models/utils.rb +0 -55
@@ -0,0 +1,29 @@
|
|
1
|
+
.breadcrumbs {
|
2
|
+
font-size: 90%;
|
3
|
+
margin-bottom: 30px;
|
4
|
+
|
5
|
+
.home-icon {
|
6
|
+
width: 12px;
|
7
|
+
height: 12px;
|
8
|
+
fill: $breadcrum-color-current;
|
9
|
+
}
|
10
|
+
|
11
|
+
.arrow-right {
|
12
|
+
width: 8px;
|
13
|
+
height: 8px;
|
14
|
+
margin-left: 7px;
|
15
|
+
margin-right: 7px;
|
16
|
+
fill: $breadcrum-color;
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
.breadcrumb {
|
21
|
+
&__item {
|
22
|
+
color: $breadcrum-color-current;
|
23
|
+
|
24
|
+
&--current {
|
25
|
+
color: $breadcrum-color;
|
26
|
+
pointer-events: none;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
@@ -1,6 +1,5 @@
|
|
1
1
|
%form__actions {
|
2
|
-
|
3
|
-
display: flex;
|
2
|
+
overflow: auto;
|
4
3
|
}
|
5
4
|
|
6
5
|
.form {
|
@@ -14,29 +13,27 @@
|
|
14
13
|
}
|
15
14
|
|
16
15
|
&__actions {
|
17
|
-
&--spaced {
|
18
|
-
@extend %form__actions;
|
19
|
-
|
20
|
-
justify-content: space-between;
|
21
|
-
}
|
22
|
-
|
23
16
|
&--left {
|
24
17
|
@extend %form__actions;
|
25
18
|
|
26
|
-
|
19
|
+
> * {
|
20
|
+
float: left;
|
27
21
|
|
28
|
-
|
29
|
-
|
22
|
+
&:not(:first-child) {
|
23
|
+
margin-left: 30px;
|
24
|
+
}
|
30
25
|
}
|
31
26
|
}
|
32
27
|
|
33
28
|
&--right {
|
34
29
|
@extend %form__actions;
|
35
30
|
|
36
|
-
|
31
|
+
> * {
|
32
|
+
float: right;
|
37
33
|
|
38
|
-
|
39
|
-
|
34
|
+
&:not(:first-child) {
|
35
|
+
margin-right: 30px;
|
36
|
+
}
|
40
37
|
}
|
41
38
|
}
|
42
39
|
}
|
@@ -1,9 +1,12 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
.main {
|
2
|
+
position: relative;
|
3
|
+
width: 100%;
|
4
|
+
height: 100vh;
|
5
|
+
overflow-y: scroll;
|
3
6
|
}
|
4
7
|
|
5
8
|
.body--public {
|
6
|
-
|
9
|
+
background-color: $main-background-public;
|
7
10
|
|
8
11
|
.main-wrapper {
|
9
12
|
@include margin(32px auto);
|
@@ -20,20 +23,16 @@
|
|
20
23
|
}
|
21
24
|
}
|
22
25
|
|
23
|
-
.body--
|
24
|
-
|
26
|
+
.body--application {
|
27
|
+
background-color: $main-background-application;
|
25
28
|
|
26
29
|
.main-wrapper {
|
27
|
-
@include margin(
|
30
|
+
@include margin(25px auto 100px auto);
|
28
31
|
|
29
|
-
|
30
|
-
width: 94%;
|
32
|
+
width: calc(100% - 50px);
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
display: block;
|
36
|
-
width: 238px;
|
34
|
+
&--action_bar {
|
35
|
+
margin-top: 12px;
|
37
36
|
}
|
38
37
|
}
|
39
38
|
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
.menu {
|
2
|
+
@include padding(0 15px);
|
3
|
+
|
4
|
+
height: $menu-height;
|
5
|
+
background-color: $menu-background;
|
6
|
+
align-items: center;
|
7
|
+
display: flex;
|
8
|
+
box-sizing: border-box;
|
9
|
+
justify-content: space-between;
|
10
|
+
position: sticky;
|
11
|
+
top: 0;
|
12
|
+
z-index: 999;
|
13
|
+
|
14
|
+
.logo {
|
15
|
+
height: $menu-logo-height;
|
16
|
+
}
|
17
|
+
|
18
|
+
&--center {
|
19
|
+
left: 50%;
|
20
|
+
position: absolute;
|
21
|
+
transform: translateX(-50%);
|
22
|
+
}
|
23
|
+
|
24
|
+
&__item {
|
25
|
+
@include margin(0 15px);
|
26
|
+
color: $menu-item-color;
|
27
|
+
|
28
|
+
&:hover {
|
29
|
+
color: $menu-item-hover-color;
|
30
|
+
}
|
31
|
+
|
32
|
+
&--active {
|
33
|
+
color: $menu-item-selected-color;
|
34
|
+
|
35
|
+
&:hover {
|
36
|
+
color: $menu-item-selected-hover-color;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
.modal {
|
2
|
+
|
3
|
+
&__background {
|
4
|
+
width: 100%;
|
5
|
+
height: 100%;
|
6
|
+
background-color: $modal-background-color;
|
7
|
+
position: absolute;
|
8
|
+
z-index: 99999;
|
9
|
+
justify-content: center;
|
10
|
+
align-items: center;
|
11
|
+
display: none;
|
12
|
+
|
13
|
+
.card {
|
14
|
+
width: 100%;
|
15
|
+
max-width: $modal-width;
|
16
|
+
margin: 25px;
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
&__close {
|
21
|
+
@include position(absolute, $modal-padding $modal-padding null null);
|
22
|
+
@include size(14px);
|
23
|
+
|
24
|
+
cursor: pointer;
|
25
|
+
fill: $modal-close-icon-color;
|
26
|
+
}
|
27
|
+
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
.sidebar {
|
2
|
+
height: 100vh;
|
3
|
+
width: $sidebar-width;
|
4
|
+
min-width: $sidebar-width;
|
5
|
+
background-color: $sidebar-background;
|
6
|
+
position: relative;
|
7
|
+
|
8
|
+
&__header, &__footer {
|
9
|
+
width: 100%;
|
10
|
+
}
|
11
|
+
|
12
|
+
&__header {
|
13
|
+
background-color: $sidebar-header-background;
|
14
|
+
height: 73px;
|
15
|
+
padding-left: 15px;
|
16
|
+
box-sizing: border-box;
|
17
|
+
display: flex;
|
18
|
+
align-items: center;
|
19
|
+
}
|
20
|
+
|
21
|
+
&__logo {
|
22
|
+
width: 128px;
|
23
|
+
height: 30px;
|
24
|
+
background-color: white;
|
25
|
+
}
|
26
|
+
|
27
|
+
&__item {
|
28
|
+
width: 120px;
|
29
|
+
height: 14px;
|
30
|
+
background-color: $sidebar-item-background;
|
31
|
+
margin: 16px 0 24px 35px;
|
32
|
+
|
33
|
+
&--selected {
|
34
|
+
background-color: $sidebar-item-selected-background;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
&__footer {
|
39
|
+
background-color: $sidebar-footer-background;
|
40
|
+
height: 40px;
|
41
|
+
position: absolute;
|
42
|
+
bottom: 0;
|
43
|
+
display: flex;
|
44
|
+
justify-content: space-around;
|
45
|
+
align-items: center;
|
46
|
+
}
|
47
|
+
|
48
|
+
&__icon {
|
49
|
+
width: 16px;
|
50
|
+
height: 16px;
|
51
|
+
background-color: $sidebar-footer-icon-background;
|
52
|
+
}
|
53
|
+
}
|
@@ -13,7 +13,8 @@ $palette-danger: rgb(218, 60, 60) !default;
|
|
13
13
|
// General styles
|
14
14
|
// ************************************************************
|
15
15
|
|
16
|
-
$main-background: rgb(233, 232, 220) !default;
|
16
|
+
$main-background-public: rgb(233, 232, 220) !default;
|
17
|
+
$main-background-application: rgb(233, 232, 220) !default;
|
17
18
|
$main-transition: 0.125s ease-in;
|
18
19
|
|
19
20
|
// ************************************************************
|
@@ -94,19 +95,19 @@ $input-errors-color: $palette-danger !default;
|
|
94
95
|
// Checkboxes
|
95
96
|
// ************************************************************
|
96
97
|
|
97
|
-
$checkbox-checked-color: #97C344 !default;
|
98
|
-
$checkbox-checked-background: #ffffff !default;
|
99
|
-
$checkbox-unchecked-color: #C2BF9D !default;
|
100
|
-
$checkbox-unchecked-background: #ffffff !default;
|
98
|
+
$checkbox-checked-color: #97C344 !default; // This value MUST be HEX
|
99
|
+
$checkbox-checked-background: #ffffff !default; // This value MUST be HEX
|
100
|
+
$checkbox-unchecked-color: #C2BF9D !default; // This value MUST be HEX
|
101
|
+
$checkbox-unchecked-background: #ffffff !default; // This value MUST be HEX
|
101
102
|
|
102
103
|
// ************************************************************
|
103
104
|
// Radiobuttons
|
104
105
|
// ************************************************************
|
105
106
|
|
106
|
-
$radio-checked-color: #97C344 !default;
|
107
|
-
$radio-checked-background: #ffffff !default;
|
108
|
-
$radio-unchecked-color: #C2BF9D !default;
|
109
|
-
$radio-unchecked-background: #ffffff !default;
|
107
|
+
$radio-checked-color: #97C344 !default; // This value MUST be HEX
|
108
|
+
$radio-checked-background: #ffffff !default; // This value MUST be HEX
|
109
|
+
$radio-unchecked-color: #C2BF9D !default; // This value MUST be HEX
|
110
|
+
$radio-unchecked-background: #ffffff !default; // This value MUST be HEX
|
110
111
|
|
111
112
|
// ************************************************************
|
112
113
|
// Hints
|
@@ -160,6 +161,39 @@ $notice-error-background: rgb(218, 60, 60) !default;
|
|
160
161
|
$notice-border-radius: 4px !default;
|
161
162
|
$notice-color: rgb(153, 153, 153) !default;
|
162
163
|
|
164
|
+
// ************************************************************
|
165
|
+
// Breadcrums
|
166
|
+
// ************************************************************
|
167
|
+
|
168
|
+
$breadcrum-color: rgb(122, 118, 76) !default;
|
169
|
+
$breadcrum-color-current: rgb(61, 149, 137) !default;
|
170
|
+
|
171
|
+
// ************************************************************
|
172
|
+
// Titles
|
173
|
+
// ************************************************************
|
174
|
+
|
175
|
+
$title-color: rgb(122, 118, 76) !default;
|
176
|
+
|
177
|
+
// ************************************************************
|
178
|
+
// Menu
|
179
|
+
// ************************************************************
|
180
|
+
|
181
|
+
$menu-background: #1c3445 !default;
|
182
|
+
$menu-height: 60px !default;
|
183
|
+
$menu-logo-height: 30px !default;
|
184
|
+
$menu-item-color: #9ab5c6 !default;
|
185
|
+
$menu-item-hover-color: lighten($menu-item-color, 13%) !default;
|
186
|
+
$menu-item-selected-color: #4eb7a8 !default;
|
187
|
+
$menu-item-selected-hover-color: lighten($menu-item-selected-color, 13%) !default;
|
188
|
+
|
189
|
+
// ************************************************************
|
190
|
+
// Action bar
|
191
|
+
// ************************************************************
|
192
|
+
|
193
|
+
$action-bar-background: rgb(255, 255, 255) !default;
|
194
|
+
$action-bar-shadow: 1px solid rgba(0, 0, 0, 0.2) !default;
|
195
|
+
$action-bar-height: 73px !default;
|
196
|
+
|
163
197
|
// ************************************************************
|
164
198
|
// Markdown
|
165
199
|
// ************************************************************
|
@@ -169,3 +203,24 @@ $markdown-table-border-color: #dfe2e5;
|
|
169
203
|
$markdown-blockquote-font-color: #6a737d;
|
170
204
|
$markdown-blockquote-border-color: #dfe2e5;
|
171
205
|
$markdown-hr-background: #e1e4e8;
|
206
|
+
|
207
|
+
// ************************************************************
|
208
|
+
// Sidebar
|
209
|
+
// ************************************************************
|
210
|
+
|
211
|
+
$sidebar-width: 250px;
|
212
|
+
$sidebar-background: #1d3544;
|
213
|
+
$sidebar-header-background: #12222c;
|
214
|
+
$sidebar-footer-background: #12222c;
|
215
|
+
$sidebar-footer-icon-background: #9ab5c5;
|
216
|
+
$sidebar-item-background: #9ab5c6;
|
217
|
+
$sidebar-item-selected-background: #4eb7a8;
|
218
|
+
|
219
|
+
// ************************************************************
|
220
|
+
// Modals
|
221
|
+
// ************************************************************
|
222
|
+
|
223
|
+
$modal-padding: 10px;
|
224
|
+
$modal-width: 650px;
|
225
|
+
$modal-close-icon-color: #8b8b8b !default;
|
226
|
+
$modal-background-color: rgba(0, 0, 0, 0.5) !default;
|
@@ -7,56 +7,63 @@ module BeyondCanvas
|
|
7
7
|
layout 'beyond_canvas/public'
|
8
8
|
|
9
9
|
include ::BeyondCanvas::Authentication
|
10
|
-
include ::BeyondCanvas::ResourceManagement
|
11
10
|
|
12
11
|
before_action :validate_app_installation_request!, only: :new
|
13
12
|
|
14
13
|
def new
|
15
|
-
|
14
|
+
@shop = Shop.find_or_initialize_by(beyond_api_url: params[:api_url])
|
15
|
+
|
16
|
+
if @shop&.authenticated?
|
17
|
+
open_app(@shop)
|
18
|
+
elsif BeyondCanvas.configuration.preinstalled
|
19
|
+
preinstall
|
20
|
+
end
|
16
21
|
end
|
17
22
|
|
18
|
-
def
|
19
|
-
|
20
|
-
resource_params = new_resource_params
|
21
|
-
self.resource = resource_class.find_or_create_by(beyond_api_url: resource_params[:api_url])
|
22
|
-
# Assign the attributes to the record
|
23
|
-
raise ActiveRecord::RecordNotSaved unless resource.update(resource_params)
|
24
|
-
# Get and save access_token and refresh_token using the authentication code
|
25
|
-
raise BeyondApi::Error if resource.authenticate.is_a?(BeyondApi::Error)
|
23
|
+
def install
|
24
|
+
@shop = Shop.create_with(shop_params).create_or_find_by(beyond_api_url: params[:shop][:api_url])
|
26
25
|
|
27
|
-
|
28
|
-
rescue ActiveRecord::RecordNotSaved, BeyondApi::Error, StandardError => e
|
29
|
-
logger.error "[BeyondCanvas] #{e.message}".red
|
30
|
-
send "handle_#{e.class.name.split('::').first.underscore}_exception", e
|
31
|
-
end
|
26
|
+
@shop.assign_attributes(shop_params)
|
32
27
|
|
33
|
-
|
34
|
-
|
28
|
+
if @shop.save
|
29
|
+
@shop.authenticate(params[:shop][:code])
|
30
|
+
|
31
|
+
redirect_to after_installation_path
|
32
|
+
else
|
33
|
+
render :new
|
34
|
+
end
|
35
35
|
end
|
36
36
|
|
37
37
|
private
|
38
38
|
|
39
|
-
def
|
40
|
-
|
39
|
+
def shop_params
|
40
|
+
beyond_canvas_parameter_sanitizer.sanitize
|
41
41
|
end
|
42
42
|
|
43
|
-
def
|
44
|
-
|
43
|
+
def after_preinstallation_path
|
44
|
+
params[:return_url]
|
45
45
|
end
|
46
46
|
|
47
|
-
def
|
48
|
-
|
49
|
-
render :new
|
47
|
+
def after_installation_path
|
48
|
+
params[:shop][:return_url]
|
50
49
|
end
|
51
50
|
|
52
|
-
def
|
53
|
-
|
54
|
-
render :new
|
51
|
+
def after_sign_in_path
|
52
|
+
BeyondCanvas.configuration.open_app_url
|
55
53
|
end
|
56
54
|
|
57
|
-
def
|
58
|
-
|
59
|
-
|
55
|
+
def preinstall
|
56
|
+
@shop = Shop.create_or_find_by(beyond_api_url: params[:api_url])
|
57
|
+
@shop.authenticate(params[:code])
|
58
|
+
|
59
|
+
redirect_to after_preinstallation_path
|
60
|
+
end
|
61
|
+
|
62
|
+
def open_app(shop)
|
63
|
+
reset_session
|
64
|
+
log_in shop
|
65
|
+
|
66
|
+
redirect_to after_sign_in_path
|
60
67
|
end
|
61
68
|
end
|
62
69
|
end
|