Dowload user profile

stable
Daniel García 2018-05-16 18:18:35 +02:00 committed by Alex Hermida
parent 5c635cb5df
commit 912f9928fe
6 changed files with 42 additions and 2 deletions

View File

@ -234,6 +234,10 @@ class AuthService extends taiga.Service
data = _.clone(data, false)
return @http.post(url, data)
exportProfile: () ->
url = @urls.resolve("users-export")
return @http.post(url)
module.service("$tgAuth", AuthService)

View File

@ -40,6 +40,7 @@ urls = {
"users-change-password": "/users/change_password"
"users-change-email": "/users/change_email"
"users-cancel-account": "/users/cancel"
"users-export": "/users/export"
"user-stats": "/users/%s/stats"
"user-liked": "/users/%s/liked"
"user-voted": "/users/%s/voted"

View File

@ -47,10 +47,11 @@ class UserSettingsController extends mixOf(taiga.Controller, taiga.PageMixin)
"$tgAuth",
"$translate",
"tgErrorHandlingService"
"$window"
]
constructor: (@scope, @rootscope, @config, @repo, @confirm, @rs, @params, @q, @location, @navUrls,
@auth, @translate, @errorHandlingService) ->
@auth, @translate, @errorHandlingService, @window) ->
@scope.sectionName = "USER_SETTINGS.MENU.SECTION_TITLE"
@scope.project = {}
@ -90,6 +91,18 @@ class UserSettingsController extends mixOf(taiga.Controller, taiga.PageMixin)
@config.get("defaultTheme") ||
"taiga"
exportProfile: ->
onSuccess = (result) ->
dumpUrl = result.data.url
@window.open(dumpUrl, "_blank")
onError = (response) =>
if response.data?._error_message
@confirm.notify("error", response.data._error_message)
@auth.exportProfile().then(onSuccess, onError)
module.controller("UserSettingsController", UserSettingsController)

View File

@ -1516,6 +1516,7 @@
"USER_PROFILE": {
"ACTION_USE_GRAVATAR": "Use default image",
"ACTION_DELETE_ACCOUNT": "Delete Taiga account",
"ACTION_DOWNLOAD_PROFILE": "Download Taiga profile",
"CHANGE_EMAIL_SUCCESS": "<strong>Check your inbox!</strong><br />We have sent a mail to your account<br />with the instructions to set your new address",
"CHANGE_PHOTO": "Change photo",
"FIELD": {

View File

@ -116,6 +116,14 @@ div.wrapper(
title="{{'COMMON.SAVE' | translate}}",
translate="COMMON.SAVE"
)
div.actions
a.download-profile(
href=""
title="{{'USER_PROFILE.ACTION_DOWNLOAD_PROFILE' | translate}}"
ng-click="ctrl.exportProfile()"
translate="USER_PROFILE.ACTION_DOWNLOAD_PROFILE"
)
a.delete-account(
href=""
title="{{'USER_PROFILE.ACTION_DELETE_ACCOUNT' | translate}}"

View File

@ -6,9 +6,22 @@
.submit-button {
width: 100%;
}
.actions {
align-items: center;
display: flex;
justify-content: center;
margin-top: .5rem;
}
.download-profile,
.delete-account {
@include font-size(small);
display: block;
margin-top: 1rem;
flex: 1;
margin-top: .5rem;
}
.delete-account {
text-align: right;
}
}