diff --git a/app/assets/javascripts/app/controllers/getting_started.js.coffee b/app/assets/javascripts/app/controllers/getting_started.js.coffee index 6cf1dd93b..5b74e861a 100644 --- a/app/assets/javascripts/app/controllers/getting_started.js.coffee +++ b/app/assets/javascripts/app/controllers/getting_started.js.coffee @@ -216,9 +216,13 @@ class Base extends App.ControllerContent else url = "#{http_type}://#{fqdn}" + logoFile = App.Config.get('product_logo') + logoUrl = App.Config.get('image_path') + "/#{logoFile}" + organization = App.Config.get('organization') @html App.view('getting_started/base')( url: url + logoUrl: logoUrl organization: organization ) @$("input, select").first().focus() @@ -237,7 +241,7 @@ class Base extends App.ControllerContent if !file return - maxSiteInMb = 3 + maxSiteInMb = 8 if file.size && file.size > 1024 * 1024 * maxSiteInMb @showAlert( 'logo', App.i18n.translateInline( 'File too big, max. %s MB allowed.', maxSiteInMb ) ) @logoPreview.attr( 'src', '' ) @@ -250,8 +254,15 @@ class Base extends App.ControllerContent # get params params = @formParam(e.target) + + # add logo params['logo'] = @logoPreview.attr('src') + # add resized image + if params['logo'] + resizeLogo = new App.ImageService( params['logo'] ) + params['logo_resize'] = resizeLogo.toDataURLForApp( @logoPreview.width(), @logoPreview.height() ) + @hideAlerts() @disable(e) diff --git a/app/assets/javascripts/app/controllers/login.js.coffee b/app/assets/javascripts/app/controllers/login.js.coffee index 86920ce6b..39572415c 100644 --- a/app/assets/javascripts/app/controllers/login.js.coffee +++ b/app/assets/javascripts/app/controllers/login.js.coffee @@ -50,11 +50,15 @@ class Index extends App.ControllerContent } auth_providers = [] for key, provider of auth_provider_all - if @Config.get( provider.config ) is true || @Config.get( provider.config ) is "true" + if @Config.get( provider.config ) is true || @Config.get( provider.config ) is 'true' auth_providers.push provider + logoFile = App.Config.get('product_logo') + logoUrl = App.Config.get('image_path') + "/#{logoFile}" + @html App.view('login')( item: data + logoUrl: logoUrl auth_providers: auth_providers ) diff --git a/app/assets/javascripts/app/lib/app_post/image_service.js.coffee b/app/assets/javascripts/app/lib/app_post/image_service.js.coffee new file mode 100644 index 000000000..ab20ee4d9 --- /dev/null +++ b/app/assets/javascripts/app/lib/app_post/image_service.js.coffee @@ -0,0 +1,46 @@ +class App.ImageService + constructor: (url) -> + @orgDataURL = url + + src: (url) => + @orgDataURL = url + + resize: ( x = 'auto', y = 'auto') => + @canvas = document.createElement('canvas') + context = @canvas.getContext('2d') + + # load image from data url + imageObject = new Image() + imageObject.src = @orgDataURL + imageWidth = imageObject.width + imageHeight = imageObject.height + + if y is 'auto' && x is 'auto' + x = imageWidth + y = imageHeight + + # get auto dimensions + if y is 'auto' + factor = imageWidth / x + y = imageHeight / factor + + if x is 'auto' + factor = imageWidth / y + x = imageHeight / factor + + console.log('BB', x, y) + # set canvas dimensions + @canvas.width = x + @canvas.height = y + + # draw image on canvas and set image dimensions + context.drawImage( imageObject, 0, 0, x, y ) + @canvas + + toDataURL: (type, quallity = 1) => + #@resize() + @canvas.toDataURL( type, quallity ) + + toDataURLForApp: ( x, y ) => + @resize( x * 2, y * 2 ) + @toDataURL( 'image/jpeg', 0.7 ) diff --git a/app/assets/javascripts/app/views/getting_started/base.jst.eco b/app/assets/javascripts/app/views/getting_started/base.jst.eco index cc70e48ff..24cf64be7 100644 --- a/app/assets/javascripts/app/views/getting_started/base.jst.eco +++ b/app/assets/javascripts/app/views/getting_started/base.jst.eco @@ -13,7 +13,7 @@
<%- @T( 'Login with %s', @C( 'fqdn' ) ) %>