From 97120c13f51a5efb946ef627a6256018ab3f6431 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sat, 3 Mar 2018 18:38:21 +0100 Subject: [PATCH] Removed avatar source settings --- pages/settings/settings.pixy | 57 ++++++++++++++++++------------------ scripts/Actions/Upload.ts | 8 +++-- 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/pages/settings/settings.pixy b/pages/settings/settings.pixy index 38b9bf71..be6dcbc2 100644 --- a/pages/settings/settings.pixy +++ b/pages/settings/settings.pixy @@ -27,40 +27,41 @@ component SettingsPersonal(user *arn.User) Icon("picture-o") span Avatar - .widget-section - label(for="Avatar.Source") Source: - select.widget-ui-element.action(id="Avatar.Source", data-field="Avatar.Source", value=user.Settings().Avatar.Source, data-action="save", data-trigger="change") - option(value="") Automatic - option(value="Gravatar") Gravatar - option(value="URL") Link - option(value="FileSystem") Upload + //- .widget-section + //- label(for="Avatar.Source") Source: + //- select.widget-ui-element.action(id="Avatar.Source", data-field="Avatar.Source", value=user.Settings().Avatar.Source, data-action="save", data-trigger="change") + //- option(value="") Automatic + //- option(value="Gravatar") Gravatar + //- option(value="URL") Link + //- option(value="FileSystem") Upload - //- URL input - if user.Settings().Avatar.Source == "URL" - InputText("Avatar.SourceURL", user.Settings().Avatar.SourceURL, "Link", "Post the link to the image here") + //- //- URL input + //- if user.Settings().Avatar.Source == "URL" + //- InputText("Avatar.SourceURL", user.Settings().Avatar.SourceURL, "Link", "Post the link to the image here") - //- Gravatar preview image - if user.Settings().Avatar.Source == "Gravatar" || (user.Settings().Avatar.Source == "" && user.Avatar.Source == "Gravatar") - .profile-image-container.avatar-preview - img.profile-image.mountable(src=user.Gravatar(), alt="Gravatar (" + user.Email + ")", title="Gravatar (" + user.Email + ")") + //- //- Gravatar preview image + //- if user.Settings().Avatar.Source == "Gravatar" || (user.Settings().Avatar.Source == "" && user.Avatar.Source == "Gravatar") + //- .profile-image-container.avatar-preview + //- img.profile-image.mountable(src=user.Gravatar(), alt="Gravatar (" + user.Email + ")", title="Gravatar (" + user.Email + ")") - //- URL preview image - if user.Settings().Avatar.Source == "URL" && user.Settings().Avatar.SourceURL != "" - .profile-image-container.avatar-preview - img.profile-image.mountable(src=strings.Replace(user.Settings().Avatar.SourceURL, "http://", "https://", 1), alt="Avatar preview") + //- //- URL preview image + //- if user.Settings().Avatar.Source == "URL" && user.Settings().Avatar.SourceURL != "" + //- .profile-image-container.avatar-preview + //- img.profile-image.mountable(src=strings.Replace(user.Settings().Avatar.SourceURL, "http://", "https://", 1), alt="Avatar preview") - //- File upload - if user.Settings().Avatar.Source == "FileSystem" - InputImage("avatar-input", "File") + //- //- File upload + //- if user.Settings().Avatar.Source == "FileSystem" + + InputImage("avatar-input", "File") - .profile-image-container.avatar-preview - if user.HasAvatar() - img#avatar-input-preview.profile-image.mountable(src=user.LargeAvatar(), alt="Profile image") - else - img#avatar-input-preview.profile-image.hidden(src=user.LargeAvatar(), alt="Profile image") + .profile-image-container.avatar-preview + if user.HasAvatar() + img#avatar-input-preview.profile-image.mountable(src=user.LargeAvatar(), alt="Profile image") + else + img#avatar-input-preview.profile-image.hidden(src=user.LargeAvatar(), alt="Profile image") - #avatar-input-preview-svg - SVGProfileImage(user) + #avatar-input-preview-svg + SVGProfileImage(user) component SettingsNotifications(user *arn.User) SettingsTabs diff --git a/scripts/Actions/Upload.ts b/scripts/Actions/Upload.ts index afb32414..e176271f 100644 --- a/scripts/Actions/Upload.ts +++ b/scripts/Actions/Upload.ts @@ -9,6 +9,10 @@ export function selectFile(arn: AnimeNotifier, button: HTMLButtonElement) { input.onchange = () => { let file = input.files[0] + if(!file) { + return + } + previewImage(file, preview) uploadFile(file, "/api/upload/avatar", arn) } @@ -31,9 +35,7 @@ function previewImage(file: File, preview: HTMLImageElement) { preview.src = reader.result } - if(file) { - reader.readAsDataURL(file) - } + reader.readAsDataURL(file) } // Upload file