add default currency option in user profile

This commit is contained in:
MaysWind
2020-11-07 21:48:58 +08:00
parent c83931fda9
commit 9bd341fb0e
15 changed files with 790 additions and 25 deletions
+1
View File
@@ -73,6 +73,7 @@ func startWebServer(c *cli.Context) error {
_ = v.RegisterValidation("notBlank", validators.NotBlank)
_ = v.RegisterValidation("validUsername", validators.ValidUsername)
_ = v.RegisterValidation("validEmail", validators.ValidEmail)
_ = v.RegisterValidation("validCurrency", validators.ValidCurrency)
}
router.NoRoute(bindApi(api.Default.ApiNotFound))
+9
View File
@@ -42,6 +42,7 @@ func (a *UsersApi) UserRegisterHandler(c *core.Context) (interface{}, *errs.Erro
Email: userRegisterReq.Email,
Nickname: userRegisterReq.Nickname,
Password: userRegisterReq.Password,
DefaultCurrency: userRegisterReq.DefaultCurrency,
}
err = a.users.CreateUser(user)
@@ -92,6 +93,7 @@ func (a *UsersApi) UserProfileHandler(c *core.Context) (interface{}, *errs.Error
Email: user.Email,
Nickname: user.Nickname,
Type: user.Type,
DefaultCurrency: user.DefaultCurrency,
CreatedAt: user.CreatedUnixTime,
UpdatedAt: user.UpdatedUnixTime,
LastLoginAt: user.LastLoginUnixTime,
@@ -151,6 +153,12 @@ func (a *UsersApi) UserUpdateProfileHandler(c *core.Context) (interface{}, *errs
userUpdateReq.Nickname = ""
}
if userUpdateReq.DefaultCurrency != "" && userUpdateReq.DefaultCurrency != user.DefaultCurrency {
anythingUpdate = true
} else {
userUpdateReq.DefaultCurrency = ""
}
if !anythingUpdate {
return nil, errs.ErrNothingWillBeUpdated
}
@@ -158,6 +166,7 @@ func (a *UsersApi) UserUpdateProfileHandler(c *core.Context) (interface{}, *errs
user.Email = userUpdateReq.Email
user.Password = userUpdateReq.Password
user.Nickname = userUpdateReq.Nickname
user.DefaultCurrency = userUpdateReq.DefaultCurrency
keyProfileUpdated, err := a.users.UpdateUser(user)
+4
View File
@@ -44,3 +44,7 @@ func GetParameterInvalidUsernameMessage(field string) string {
func GetParameterInvalidEmailMessage(field string) string {
return fmt.Sprintf("parameter \"%s\" is invalid email format", field)
}
func GetParameterInvalidCurrencylMessage(field string) string {
return fmt.Sprintf("parameter \"%s\" is invalid currency", field)
}
+20 -16
View File
@@ -17,6 +17,7 @@ type User struct {
Salt string `xorm:"VARCHAR(10) NOT NULL"`
Rands string `xorm:"VARCHAR(10) NOT NULL"`
Type UserType `xorm:"TINYINT NOT NULL"`
DefaultCurrency string `xorm:"VARCHAR(3) NOT NULL"`
IsAdmin bool `xorm:"NOT NULL"`
Deleted bool `xorm:"NOT NULL"`
EmailVerified bool `xorm:"NOT NULL"`
@@ -32,26 +33,29 @@ type UserLoginRequest struct {
}
type UserRegisterRequest struct {
Username string `json:"username" binding:"required,notBlank,max=32,validUsername"`
Email string `json:"email" binding:"required,notBlank,max=100,validEmail"`
Nickname string `json:"nickname" binding:"required,notBlank,max=64"`
Password string `json:"password" binding:"required,min=6,max=128"`
Username string `json:"username" binding:"required,notBlank,max=32,validUsername"`
Email string `json:"email" binding:"required,notBlank,max=100,validEmail"`
Nickname string `json:"nickname" binding:"required,notBlank,max=64"`
Password string `json:"password" binding:"required,min=6,max=128"`
DefaultCurrency string `json:"defaultCurrency" binding:"required,len=3,validCurrency"`
}
type UserProfileUpdateRequest struct {
Email string `json:"email" binding:"omitempty,notBlank,max=100,validEmail"`
Nickname string `json:"nickname" binding:"omitempty,notBlank,max=64"`
Password string `json:"password" binding:"omitempty,min=6,max=128"`
OldPassword string `json:"oldPassword" binding:"omitempty,min=6,max=128"`
Email string `json:"email" binding:"omitempty,notBlank,max=100,validEmail"`
Nickname string `json:"nickname" binding:"omitempty,notBlank,max=64"`
Password string `json:"password" binding:"omitempty,min=6,max=128"`
OldPassword string `json:"oldPassword" binding:"omitempty,min=6,max=128"`
DefaultCurrency string `json:"defaultCurrency" binding:"required,len=3,validCurrency"`
}
type UserProfileResponse struct {
Uid string `json:"uid"`
Username string `json:"username"`
Email string `json:"email"`
Nickname string `json:"nickname"`
Type UserType `json:"type"`
CreatedAt int64 `json:"createdAt"`
UpdatedAt int64 `json:"updatedAt"`
LastLoginAt int64 `json:"lastLoginAt"`
Uid string `json:"uid"`
Username string `json:"username"`
Email string `json:"email"`
Nickname string `json:"nickname"`
Type UserType `json:"type"`
DefaultCurrency string `json:"defaultCurrency"`
CreatedAt int64 `json:"createdAt"`
UpdatedAt int64 `json:"updatedAt"`
LastLoginAt int64 `json:"lastLoginAt"`
}
+4
View File
@@ -174,6 +174,10 @@ func (s *UserService) UpdateUser(user *models.User) (keyProfileUpdated bool, err
updateCols = append(updateCols, "nickname")
}
if user.DefaultCurrency != "" {
updateCols = append(updateCols, "default_currency")
}
user.UpdatedUnixTime = now
updateCols = append(updateCols, "updated_unix_time")
+2
View File
@@ -59,6 +59,8 @@ func getValidationErrorText(err validator.FieldError) string {
return errs.GetParameterInvalidUsernameMessage(fieldName)
case "validEmail":
return errs.GetParameterInvalidEmailMessage(fieldName)
case "validCurrency":
return errs.GetParameterInvalidCurrencylMessage(fieldName)
}
return errs.GetParameterInvalidMessage(fieldName)
+175
View File
@@ -0,0 +1,175 @@
package validators
import (
"github.com/go-playground/validator/v10"
)
// ISO 4217
var ALL_CURRENCY_NAMES = map[string]bool {
"AED": true, //UAE Dirham
"AFN": true, //Afghani
"ALL": true, //Lek
"AMD": true, //Armenian Dram
"ANG": true, //Netherlands Antillean Guilder
"AOA": true, //Kwanza
"ARS": true, //Argentine Peso
"AUD": true, //Australian Dollar
"AWG": true, //Aruban Florin
"AZN": true, //Azerbaijan Manat
"BAM": true, //Convertible Mark
"BBD": true, //Barbados Dollar
"BDT": true, //Taka
"BGN": true, //Bulgarian Lev
"BHD": true, //Bahraini Dinar
"BIF": true, //Burundi Franc
"BMD": true, //Bermudian Dollar
"BND": true, //Brunei Dollar
"BOB": true, //Boliviano
"BRL": true, //Brazilian Real
"BSD": true, //Bahamian Dollar
"BTN": true, //Ngultrum
"BWP": true, //Pula
"BYN": true, //Belarusian Ruble
"BZD": true, //Belize Dollar
"CAD": true, //Canadian Dollar
"CDF": true, //Congolese Franc
"CHF": true, //Swiss Franc
"CLP": true, //Chilean Peso
"CNY": true, //Yuan Renminbi
"COP": true, //Colombian Peso
"CRC": true, //Costa Rican Colon
"CUC": true, //Peso Convertible
"CUP": true, //Cuban Peso
"CVE": true, //Cabo Verde Escudo
"CZK": true, //Czech Koruna
"DJF": true, //Djibouti Franc
"DKK": true, //Danish Krone
"DOP": true, //Dominican Peso
"DZD": true, //Algerian Dinar
"EGP": true, //Egyptian Pound
"ERN": true, //Nakfa
"ETB": true, //Ethiopian Birr
"EUR": true, //Euro
"FJD": true, //Fiji Dollar
"FKP": true, //Falkland Islands Pound
"GBP": true, //Pound Sterling
"GEL": true, //Lari
"GHS": true, //Ghana Cedi
"GIP": true, //Gibraltar Pound
"GMD": true, //Dalasi
"GNF": true, //Guinean Franc
"GTQ": true, //Quetzal
"GYD": true, //Guyana Dollar
"HKD": true, //Hong Kong Dollar
"HNL": true, //Lempira
"HRK": true, //Kuna
"HTG": true, //Gourde
"HUF": true, //Forint
"IDR": true, //Rupiah
"ILS": true, //New Israeli Sheqel
"INR": true, //Indian Rupee
"IQD": true, //Iraqi Dinar
"IRR": true, //Iranian Rial
"ISK": true, //Iceland Krona
"JMD": true, //Jamaican Dollar
"JOD": true, //Jordanian Dinar
"JPY": true, //Yen
"KES": true, //Kenyan Shilling
"KGS": true, //Som
"KHR": true, //Riel
"KMF": true, //Comorian Franc
"KPW": true, //North Korean Won
"KRW": true, //Won
"KWD": true, //Kuwaiti Dinar
"KYD": true, //Cayman Islands Dollar
"KZT": true, //Tenge
"LAK": true, //Lao Kip
"LBP": true, //Lebanese Pound
"LKR": true, //Sri Lanka Rupee
"LRD": true, //Liberian Dollar
"LSL": true, //Loti
"LYD": true, //Libyan Dinar
"MAD": true, //Moroccan Dirham
"MDL": true, //Moldovan Leu
"MGA": true, //Malagasy Ariary
"MKD": true, //Denar
"MMK": true, //Kyat
"MNT": true, //Tugrik
"MOP": true, //Pataca
"MRU": true, //Ouguiya
"MUR": true, //Mauritius Rupee
"MVR": true, //Rufiyaa
"MWK": true, //Malawi Kwacha
"MXN": true, //Mexican Peso
"MYR": true, //Malaysian Ringgit
"MZN": true, //Mozambique Metical
"NAD": true, //Namibia Dollar
"NGN": true, //Naira
"NIO": true, //Cordoba Oro
"NOK": true, //Norwegian Krone
"NPR": true, //Nepalese Rupee
"NZD": true, //New Zealand Dollar
"OMR": true, //Rial Omani
"PAB": true, //Balboa
"PEN": true, //Sol
"PGK": true, //Kina
"PHP": true, //Philippine Peso
"PKR": true, //Pakistan Rupee
"PLN": true, //Zloty
"PYG": true, //Guarani
"QAR": true, //Qatari Rial
"RON": true, //Romanian Leu
"RSD": true, //Serbian Dinar
"RUB": true, //Russian Ruble
"RWF": true, //Rwanda Franc
"SAR": true, //Saudi Riyal
"SBD": true, //Solomon Islands Dollar
"SCR": true, //Seychelles Rupee
"SDG": true, //Sudanese Pound
"SEK": true, //Swedish Krona
"SGD": true, //Singapore Dollar
"SHP": true, //Saint Helena Pound
"SLL": true, //Leone
"SOS": true, //Somali Shilling
"SRD": true, //Surinam Dollar
"SSP": true, //South Sudanese Pound
"STN": true, //Dobra
"SVC": true, //El Salvador Colon
"SYP": true, //Syrian Pound
"SZL": true, //Lilangeni
"THB": true, //Baht
"TJS": true, //Somoni
"TMT": true, //Turkmenistan New Manat
"TND": true, //Tunisian Dinar
"TOP": true, //Paanga
"TRY": true, //Turkish Lira
"TTD": true, //Trinidad and Tobago Dollar
"TWD": true, //New Taiwan Dollar
"TZS": true, //Tanzanian Shilling
"UAH": true, //Hryvnia
"UGX": true, //Uganda Shilling
"USD": true, //US Dollar
"UYU": true, //Peso Uruguayo
"UZS": true, //Uzbekistan Sum
"VES": true, //Bolívar Soberano
"VND": true, //Dong
"VUV": true, //Vatu
"WST": true, //Tala
"XAF": true, //CFA Franc BEAC
"XCD": true, //East Caribbean Dollar
"XOF": true, //CFA Franc BCEAO
"XPF": true, //CFP Franc
"YER": true, //Yemeni Rial
"ZAR": true, //Rand
"ZMW": true, //Zambian Kwacha
"ZWL": true, //Zimbabwe Dollar
}
func ValidCurrency(fl validator.FieldLevel) bool {
if value, ok := fl.Field().Interface().(string); ok {
_, ok := ALL_CURRENCY_NAMES[value]
return ok
}
return false
}
+163
View File
@@ -0,0 +1,163 @@
const allCurrencies = [
'AED', //UAE Dirham
'AFN', //Afghani
'ALL', //Lek
'AMD', //Armenian Dram
'ANG', //Netherlands Antillean Guilder
'AOA', //Kwanza
'ARS', //Argentine Peso
'AUD', //Australian Dollar
'AWG', //Aruban Florin
'AZN', //Azerbaijan Manat
'BAM', //Convertible Mark
'BBD', //Barbados Dollar
'BDT', //Taka
'BGN', //Bulgarian Lev
'BHD', //Bahraini Dinar
'BIF', //Burundi Franc
'BMD', //Bermudian Dollar
'BND', //Brunei Dollar
'BOB', //Boliviano
'BRL', //Brazilian Real
'BSD', //Bahamian Dollar
'BTN', //Ngultrum
'BWP', //Pula
'BYN', //Belarusian Ruble
'BZD', //Belize Dollar
'CAD', //Canadian Dollar
'CDF', //Congolese Franc
'CHF', //Swiss Franc
'CLP', //Chilean Peso
'CNY', //Yuan Renminbi
'COP', //Colombian Peso
'CRC', //Costa Rican Colon
'CUC', //Peso Convertible
'CUP', //Cuban Peso
'CVE', //Cabo Verde Escudo
'CZK', //Czech Koruna
'DJF', //Djibouti Franc
'DKK', //Danish Krone
'DOP', //Dominican Peso
'DZD', //Algerian Dinar
'EGP', //Egyptian Pound
'ERN', //Nakfa
'ETB', //Ethiopian Birr
'EUR', //Euro
'FJD', //Fiji Dollar
'FKP', //Falkland Islands Pound
'GBP', //Pound Sterling
'GEL', //Lari
'GHS', //Ghana Cedi
'GIP', //Gibraltar Pound
'GMD', //Dalasi
'GNF', //Guinean Franc
'GTQ', //Quetzal
'GYD', //Guyana Dollar
'HKD', //Hong Kong Dollar
'HNL', //Lempira
'HRK', //Kuna
'HTG', //Gourde
'HUF', //Forint
'IDR', //Rupiah
'ILS', //New Israeli Sheqel
'INR', //Indian Rupee
'IQD', //Iraqi Dinar
'IRR', //Iranian Rial
'ISK', //Iceland Krona
'JMD', //Jamaican Dollar
'JOD', //Jordanian Dinar
'JPY', //Yen
'KES', //Kenyan Shilling
'KGS', //Som
'KHR', //Riel
'KMF', //Comorian Franc
'KPW', //North Korean Won
'KRW', //Won
'KWD', //Kuwaiti Dinar
'KYD', //Cayman Islands Dollar
'KZT', //Tenge
'LAK', //Lao Kip
'LBP', //Lebanese Pound
'LKR', //Sri Lanka Rupee
'LRD', //Liberian Dollar
'LSL', //Loti
'LYD', //Libyan Dinar
'MAD', //Moroccan Dirham
'MDL', //Moldovan Leu
'MGA', //Malagasy Ariary
'MKD', //Denar
'MMK', //Kyat
'MNT', //Tugrik
'MOP', //Pataca
'MRU', //Ouguiya
'MUR', //Mauritius Rupee
'MVR', //Rufiyaa
'MWK', //Malawi Kwacha
'MXN', //Mexican Peso
'MYR', //Malaysian Ringgit
'MZN', //Mozambique Metical
'NAD', //Namibia Dollar
'NGN', //Naira
'NIO', //Cordoba Oro
'NOK', //Norwegian Krone
'NPR', //Nepalese Rupee
'NZD', //New Zealand Dollar
'OMR', //Rial Omani
'PAB', //Balboa
'PEN', //Sol
'PGK', //Kina
'PHP', //Philippine Peso
'PKR', //Pakistan Rupee
'PLN', //Zloty
'PYG', //Guarani
'QAR', //Qatari Rial
'RON', //Romanian Leu
'RSD', //Serbian Dinar
'RUB', //Russian Ruble
'RWF', //Rwanda Franc
'SAR', //Saudi Riyal
'SBD', //Solomon Islands Dollar
'SCR', //Seychelles Rupee
'SDG', //Sudanese Pound
'SEK', //Swedish Krona
'SGD', //Singapore Dollar
'SHP', //Saint Helena Pound
'SLL', //Leone
'SOS', //Somali Shilling
'SRD', //Surinam Dollar
'SSP', //South Sudanese Pound
'STN', //Dobra
'SVC', //El Salvador Colon
'SYP', //Syrian Pound
'SZL', //Lilangeni
'THB', //Baht
'TJS', //Somoni
'TMT', //Turkmenistan New Manat
'TND', //Tunisian Dinar
'TOP', //Paanga
'TRY', //Turkish Lira
'TTD', //Trinidad and Tobago Dollar
'TWD', //New Taiwan Dollar
'TZS', //Tanzanian Shilling
'UAH', //Hryvnia
'UGX', //Uganda Shilling
'USD', //US Dollar
'UYU', //Peso Uruguayo
'UZS', //Uzbekistan Sum
'VES', //Bolívar Soberano
'VND', //Dong
'VUV', //Vatu
'WST', //Tala
'XAF', //CFA Franc BEAC
'XCD', //East Caribbean Dollar
'XOF', //CFA Franc BCEAO
'XPF', //CFP Franc
'YER', //Yemeni Rial
'ZAR', //Rand
'ZMW', //Zambian Kwacha
'ZWL', //Zimbabwe Dollar
];
export default {
all: allCurrencies
};
+8
View File
@@ -80,6 +80,14 @@ const parameterizedErrors = [
field: 'parameter',
localized: true
}]
},
{
localeKey: 'parameter invalid currency',
regex: /^parameter "(\w+)" is invalid currency$/,
parameters: [{
field: 'parameter',
localized: true
}]
}
];
+6 -4
View File
@@ -78,12 +78,13 @@ export default {
}
});
},
register: ({ username, email, nickname, password }) => {
register: ({ username, email, nickname, password, defaultCurrency }) => {
return axios.post('register.json', {
username,
email,
nickname,
password
password,
defaultCurrency
});
},
logout: () => {
@@ -127,12 +128,13 @@ export default {
getProfile: () => {
return axios.get('v1/users/profile/get.json');
},
updateProfile: ({ email, nickname, password, oldPassword }) => {
updateProfile: ({ email, nickname, password, oldPassword, defaultCurrency }) => {
return axios.post('v1/users/profile/update.json', {
email,
nickname,
password,
oldPassword
oldPassword,
defaultCurrency
});
},
get2FAStatus: () => {
+166
View File
@@ -4,11 +4,173 @@ export default {
'title': 'lab account book',
}
},
'default': {
'currency': 'USD',
},
'format': {
'datetime': {
'long': 'MM/DD/YYYY HH:mm:ss',
}
},
'currency': {
'AED': 'United Arab Emirates dirham',
'AFN': 'Afghan afghani',
'ALL': 'Albanian lek',
'AMD': 'Armenian dram',
'ANG': 'Netherlands Antillean guilder',
'AOA': 'Angolan kwanza',
'ARS': 'Argentine peso',
'AUD': 'Australian dollar',
'AWG': 'Aruban florin',
'AZN': 'Azerbaijani manat',
'BAM': 'Bosnia and Herzegovina convertible mark',
'BBD': 'Barbados dollar',
'BDT': 'Bangladeshi taka',
'BGN': 'Bulgarian lev',
'BHD': 'Bahraini dinar',
'BIF': 'Burundian franc',
'BMD': 'Bermudian dollar',
'BND': 'Brunei dollar',
'BOB': 'Boliviano',
'BRL': 'Brazilian real',
'BSD': 'Bahamian dollar',
'BTN': 'Bhutanese ngultrum',
'BWP': 'Botswana pula',
'BYN': 'Belarusian ruble',
'BZD': 'Belize dollar',
'CAD': 'Canadian dollar',
'CDF': 'Congolese franc',
'CHF': 'Swiss franc',
'CLP': 'Chilean peso',
'CNY': 'Chinese yuan',
'COP': 'Colombian peso',
'CRC': 'Costa Rican colon',
'CUC': 'Cuban convertible peso',
'CUP': 'Cuban peso',
'CVE': 'Cape Verdean escudo',
'CZK': 'Czech koruna',
'DJF': 'Djiboutian franc',
'DKK': 'Danish krone',
'DOP': 'Dominican peso',
'DZD': 'Algerian dinar',
'EGP': 'Egyptian pound',
'ERN': 'Eritrean nakfa',
'ETB': 'Ethiopian birr',
'EUR': 'Euro',
'FJD': 'Fiji dollar',
'FKP': 'Falkland Islands pound',
'GBP': 'Pound sterling',
'GEL': 'Georgian lari',
'GHS': 'Ghanaian cedi',
'GIP': 'Gibraltar pound',
'GMD': 'Gambian dalasi',
'GNF': 'Guinean franc',
'GTQ': 'Guatemalan quetzal',
'GYD': 'Guyanese dollar',
'HKD': 'Hong Kong dollar',
'HNL': 'Honduran lempira',
'HRK': 'Croatian kuna',
'HTG': 'Haitian gourde',
'HUF': 'Hungarian forint',
'IDR': 'Indonesian rupiah',
'ILS': 'Israeli new shekel',
'INR': 'Indian rupee',
'IQD': 'Iraqi dinar',
'IRR': 'Iranian rial',
'ISK': 'Icelandic króna',
'JMD': 'Jamaican dollar',
'JOD': 'Jordanian dinar',
'JPY': 'Japanese yen',
'KES': 'Kenyan shilling',
'KGS': 'Kyrgyzstani som',
'KHR': 'Cambodian riel',
'KMF': 'Comoro franc',
'KPW': 'North Korean won',
'KRW': 'South Korean won',
'KWD': 'Kuwaiti dinar',
'KYD': 'Cayman Islands dollar',
'KZT': 'Kazakhstani tenge',
'LAK': 'Lao kip',
'LBP': 'Lebanese pound',
'LKR': 'Sri Lankan rupee',
'LRD': 'Liberian dollar',
'LSL': 'Lesotho loti',
'LYD': 'Libyan dinar',
'MAD': 'Moroccan dirham',
'MDL': 'Moldovan leu',
'MGA': 'Malagasy ariary',
'MKD': 'Macedonian denar',
'MMK': 'Myanmar kyat',
'MNT': 'Mongolian tögrög',
'MOP': 'Macanese pataca',
'MRU': 'Mauritanian ouguiya',
'MUR': 'Mauritian rupee',
'MVR': 'Maldivian rufiyaa',
'MWK': 'Malawian kwacha',
'MXN': 'Mexican peso',
'MYR': 'Malaysian ringgit',
'MZN': 'Mozambican metical',
'NAD': 'Namibian dollar',
'NGN': 'Nigerian naira',
'NIO': 'Nicaraguan córdoba',
'NOK': 'Norwegian krone',
'NPR': 'Nepalese rupee',
'NZD': 'New Zealand dollar',
'OMR': 'Omani rial',
'PAB': 'Panamanian balboa',
'PEN': 'Peruvian sol',
'PGK': 'Papua New Guinean kina',
'PHP': 'Philippine peso',
'PKR': 'Pakistani rupee',
'PLN': 'Polish złoty',
'PYG': 'Paraguayan guaraní',
'QAR': 'Qatari riyal',
'RON': 'Romanian leu',
'RSD': 'Serbian dinar',
'RUB': 'Russian ruble',
'RWF': 'Rwandan franc',
'SAR': 'Saudi riyal',
'SBD': 'Solomon Islands dollar',
'SCR': 'Seychelles rupee',
'SDG': 'Sudanese pound',
'SEK': 'Swedish krona/kronor',
'SGD': 'Singapore dollar',
'SHP': 'Saint Helena pound',
'SLL': 'Sierra Leonean leone',
'SOS': 'Somali shilling',
'SRD': 'Surinamese dollar',
'SSP': 'South Sudanese pound',
'STN': 'São Tomé and Príncipe dobra',
'SVC': 'Salvadoran colón',
'SYP': 'Syrian pound',
'SZL': 'Swazi lilangeni',
'THB': 'Thai baht',
'TJS': 'Tajikistani somoni',
'TMT': 'Turkmenistan manat',
'TND': 'Tunisian dinar',
'TOP': 'Tongan paʻanga',
'TRY': 'Turkish lira',
'TTD': 'Trinidad and Tobago dollar',
'TWD': 'New Taiwan dollar',
'TZS': 'Tanzanian shilling',
'UAH': 'Ukrainian hryvnia',
'UGX': 'Ugandan shilling',
'USD': 'United States dollar',
'UYU': 'Uruguayan peso',
'UZS': 'Uzbekistan som',
'VES': 'Venezuelan bolívar soberano',
'VND': 'Vietnamese đồng',
'VUV': 'Vanuatu vatu',
'WST': 'Samoan tala',
'XAF': 'CFA franc BEAC',
'XCD': 'East Caribbean dollar',
'XOF': 'CFA franc BCEAO',
'XPF': 'CFP franc',
'YER': 'Yemeni rial',
'ZAR': 'South African rand',
'ZMW': 'Zambian kwacha',
'ZWL': 'Zimbabwean dollar',
},
'error': {
'system error': 'System Error',
'api not found': 'Failed to request api',
@@ -50,6 +212,7 @@ export default {
'email': 'Email',
'nickname': 'Nickname',
'oldPassword': 'Current Password',
'defaultCurrency': 'Default Currency',
},
'parameterizedError': {
'parameter invalid': '{parameter} is invalid',
@@ -60,6 +223,7 @@ export default {
'parameter cannot be blank': '{parameter} cannot be blank',
'parameter invalid username format': '{parameter} is invalid format',
'parameter invalid email format': '{parameter} is invalid format',
'parameter invalid currency': '{parameter} is invalid format',
},
'OK': 'OK',
'Cancel': 'Cancel',
@@ -92,6 +256,7 @@ export default {
'Your email address': 'Your email address',
'Nickname': 'Nickname',
'Your nickname': 'Your nickname',
'Default Currency': 'Default Currency',
'Log In': 'Log In',
'Don\'t have an account?': 'Don\'t have an account?',
'Create an account': 'Create an account',
@@ -102,6 +267,7 @@ export default {
'Password and confirmation password do not match': 'Password and confirmation password do not match',
'Email address cannot be empty': 'Email address cannot be empty',
'Nickname cannot be empty': 'Nickname cannot be empty',
'Default currency cannot be empty': 'Default currency cannot be empty',
'Unable to login': 'Unable to login',
'Two-Factor Authentication': 'Two-Factor Authentication',
'Passcode': 'Passcode',
+166
View File
@@ -4,11 +4,173 @@ export default {
'title': 'lab 轻记账',
}
},
'default': {
'currency': 'CNY',
},
'format': {
'datetime': {
'long': 'YYYY年MM月DD日 HH:mm:ss',
}
},
'currency': {
'AED': '阿联酋迪拉姆',
'AFN': '阿富汗阿富汗尼',
'ALL': '阿尔巴尼亚列克',
'AMD': '亚美尼亚德拉姆',
'ANG': '荷属安的列斯盾',
'AOA': '安哥拉宽扎',
'ARS': '阿根廷比索',
'AUD': '澳大利亚元',
'AWG': '阿鲁巴弗罗林',
'AZN': '阿塞拜疆马纳特',
'BAM': '波斯尼亚和黑塞哥维那可兑换马克',
'BBD': '巴巴多斯元',
'BDT': '孟加拉塔卡',
'BGN': '保加利亚列弗',
'BHD': '巴林第纳尔',
'BIF': '布隆迪法郎',
'BMD': '百慕大元',
'BND': '文莱元',
'BOB': '玻利维亚玻利维亚诺',
'BRL': '巴西雷亚尔',
'BSD': '巴哈马元',
'BTN': '不丹努扎姆',
'BWP': '博茨瓦纳普拉',
'BYN': '白俄罗斯卢布',
'BZD': '伯利兹元',
'CAD': '加拿大元',
'CDF': '刚果民主共和国刚果法郎',
'CHF': '瑞士法郎',
'CLP': '智利比索',
'CNY': '人民币',
'COP': '哥伦比亚比索',
'CRC': '哥斯达黎加科朗',
'CUC': '古巴可兑换比索',
'CUP': '古巴比索',
'CVE': '佛得角埃斯库多',
'CZK': '捷克克朗',
'DJF': '吉布提法郎',
'DKK': '丹麦克朗',
'DOP': '多米尼加比索',
'DZD': '阿尔及利亚第纳尔',
'EGP': '埃及镑',
'ERN': '厄立特里亚纳克法',
'ETB': '埃塞俄比亚比尔',
'EUR': '欧元',
'FJD': '斐济元',
'FKP': '福克兰镑',
'GBP': '英镑',
'GEL': '格鲁吉亚拉里',
'GHS': '加纳塞地',
'GIP': '直布罗陀镑',
'GMD': '冈比亚达拉西',
'GNF': '几内亚法郎',
'GTQ': '危地马拉格查尔',
'GYD': '圭亚那元',
'HKD': '港元',
'HNL': '洪都拉斯伦皮拉',
'HRK': '克罗地亚库纳',
'HTG': '海地古德',
'HUF': '匈牙利福林',
'IDR': '印度尼西亚盾',
'ILS': '以色列新谢克尔',
'INR': '印度卢比',
'IQD': '伊拉克第纳尔',
'IRR': '伊朗里亚尔',
'ISK': '冰岛克朗',
'JMD': '牙买加元',
'JOD': '约旦第纳尔',
'JPY': '日元',
'KES': '肯尼亚先令',
'KGS': '吉尔吉斯斯坦索姆',
'KHR': '柬埔寨瑞尔',
'KMF': '科摩罗法郎',
'KPW': '朝鲜圆',
'KRW': '韩元',
'KWD': '科威特第纳尔',
'KYD': '开曼群岛元',
'KZT': '哈萨克斯坦坚戈',
'LAK': '老挝基普',
'LBP': '黎巴嫩镑',
'LKR': '斯里兰卡卢比',
'LRD': '利比里亚元',
'LSL': '莱索托洛蒂',
'LYD': '利比亚第纳尔',
'MAD': '摩洛哥迪拉姆',
'MDL': '摩尔多瓦列伊',
'MGA': '马达加斯加阿里亚里',
'MKD': '北马其顿代纳尔',
'MMK': '缅甸元',
'MNT': '蒙古图格里克',
'MOP': '澳门元',
'MRU': '毛里塔尼亚乌吉亚',
'MUR': '毛里求斯卢比',
'MVR': '马尔代夫拉菲亚',
'MWK': '马拉维克瓦查',
'MXN': '墨西哥比索',
'MYR': '马来西亚林吉特',
'MZN': '莫桑比克梅蒂卡尔',
'NAD': '纳米比亚元',
'NGN': '尼日利亚奈拉',
'NIO': '尼加拉瓜科多巴',
'NOK': '挪威克朗',
'NPR': '尼泊尔卢比',
'NZD': '新西兰元',
'OMR': '阿曼里亚尔',
'PAB': '巴拿马巴波亚',
'PEN': '秘鲁新索尔',
'PGK': '巴布亚新几内亚基那',
'PHP': '菲律宾比索',
'PKR': '巴基斯坦卢比',
'PLN': '波兰兹罗提',
'PYG': '巴拉圭瓜拉尼',
'QAR': '卡塔尔里亚尔',
'RON': '罗马尼亚列伊',
'RSD': '塞尔维亚第纳尔',
'RUB': '俄罗斯卢布',
'RWF': '卢旺达法郎',
'SAR': '沙特里亚尔',
'SBD': '所罗门群岛元',
'SCR': '塞舌尔卢比',
'SDG': '苏丹镑',
'SEK': '瑞典克朗',
'SGD': '新加坡元',
'SHP': '圣赫勒拿镑',
'SLL': '塞拉利昂利昂',
'SOS': '索马里先令',
'SRD': '苏里南元',
'SSP': '南苏丹镑',
'STN': '圣多美和普林西比多布拉',
'SVC': '萨尔瓦多科朗',
'SYP': '叙利亚镑',
'SZL': '斯威士兰里兰吉尼',
'THB': '泰铢',
'TJS': '塔吉克斯坦索莫尼',
'TMT': '土库曼斯坦马纳特',
'TND': '突尼斯第纳尔',
'TOP': '汤加潘加',
'TRY': '土耳其里拉',
'TTD': '特立尼达和多巴哥元',
'TWD': '新台币',
'TZS': '坦桑尼亚先令',
'UAH': '乌克兰格里夫尼亚',
'UGX': '乌干达先令',
'USD': '美元',
'UYU': '乌拉圭比索',
'UZS': '乌兹别克斯坦苏姆',
'VES': '委内瑞拉玻利瓦尔',
'VND': '越南盾',
'VUV': '瓦努阿图瓦图',
'WST': '萨摩亚塔拉',
'XAF': '中非金融合作法郎',
'XCD': '东加勒比元',
'XOF': '非洲金融共同体法郎',
'XPF': '太平洋法郎',
'YER': '也门里亚尔',
'ZAR': '南非兰特',
'ZMW': '赞比亚克瓦查',
'ZWL': '津巴布韦元',
},
'error': {
'system error': '系统错误',
'api not found': '接口调用失败',
@@ -50,6 +212,7 @@ export default {
'email': '电子邮箱',
'nickname': '昵称',
'oldPassword': '当前密码',
'defaultCurrency': '默认货币',
},
'parameterizedError': {
'parameter invalid': '{parameter}无效',
@@ -60,6 +223,7 @@ export default {
'parameter cannot be blank': '{parameter}不能为空',
'parameter invalid username format': '{parameter}格式错误',
'parameter invalid email format': '{parameter}格式错误',
'parameter invalid currency': '{parameter}格式错误',
},
'OK': '确定',
'Cancel': '取消',
@@ -92,6 +256,7 @@ export default {
'Your email address': '你的电子邮箱地址',
'Nickname': '昵称',
'Your nickname': '你的昵称',
'Default Currency': '默认货币',
'Log In': '登录',
'Don\'t have an account?': '还没有账号?',
'Create an account': '创建新账号',
@@ -102,6 +267,7 @@ export default {
'Password and confirmation password do not match': '密码和确认密码不匹配',
'Email address cannot be empty': '电子邮箱地址不能为空',
'Nickname cannot be empty': '昵称不能为空',
'Default currency cannot be empty': '默认货币不能为空',
'Unable to login': '无法登录',
'Two-Factor Authentication': '两步验证',
'Passcode': '验证码',
+20
View File
@@ -13,6 +13,7 @@ import 'framework7/css/framework7.bundle.css';
import 'framework7-icons';
import { getAllLanguages, getLanguage, getDefaultLanguage, getI18nOptions, getLocalizedError } from './lib/i18n.js';
import currency from './consts/currency.js';
import version from './lib/version.js';
import settings from './lib/settings.js';
import services from './lib/services.js';
@@ -43,6 +44,25 @@ Vue.prototype.$setLanguage = function (locale) {
document.querySelector('html').setAttribute('lang', locale);
return locale;
};
Vue.prototype.$getAllCurrencies = function () {
const allCurrencyCodes = currency.all;
const allCurrencies = [];
for (let i = 0; i < allCurrencyCodes.length; i++) {
const code = allCurrencyCodes[i];
allCurrencies.push({
code: code,
displayName: i18n.t(`currency.${code}`)
});
}
allCurrencies.sort(function(c1, c2){
return c1.displayName.localeCompare(c2.displayName);
})
return allCurrencies;
};
Vue.prototype.$isUserRegistrationEnabled = settings.isUserRegistrationEnabled;
Vue.prototype.$alert = function (message, confirmCallback) {
+20 -2
View File
@@ -47,6 +47,17 @@
@input="nickname = $event.target.value"
></f7-list-input>
<f7-list-input
type="select"
:label="$t('Default Currency')"
:value="defaultCurrency"
@input="defaultCurrency = $event.target.value"
>
<option v-for="currency in allCurrencies"
:key="currency.code"
:value="currency.code">{{ currency.displayName }}</option>
</f7-list-input>
<f7-list-item class="lab-list-item-error-info" v-if="inputIsInvalid" :footer="$t(inputInvalidProblemMessage)"></f7-list-item>
</f7-list>
@@ -57,13 +68,17 @@
<script>
export default {
data() {
const self = this;
return {
username: '',
password: '',
confirmPassword: '',
email: '',
nickname: '',
signuping: false
defaultCurrency: self.$t('default.currency'),
signuping: false,
allCurrencies: self.$getAllCurrencies()
};
},
computed: {
@@ -84,6 +99,8 @@ export default {
return 'Email address cannot be empty';
} else if (!this.nickname) {
return 'Nickname cannot be empty';
} else if (!this.defaultCurrency) {
return 'Default currency cannot be empty';
} else {
return null;
}
@@ -115,7 +132,8 @@ export default {
username: self.username,
password: self.password,
email: self.email,
nickname: self.nickname
nickname: self.nickname,
defaultCurrency: self.defaultCurrency
}).then(response => {
self.signuping = false;
self.$hideLoading();
+26 -3
View File
@@ -7,6 +7,7 @@
<f7-list-input label="Confirmation Password" placeholder="Re-enter the password"></f7-list-input>
<f7-list-input label="E-mail" placeholder="Your email address"></f7-list-input>
<f7-list-input label="Nickname" placeholder="Your nickname"></f7-list-input>
<f7-list-input label="Default Currency" placeholder="Default Currency"></f7-list-input>
</f7-list>
<f7-list no-hairlines-md v-else-if="!loading">
@@ -46,6 +47,17 @@
@input="nickname = $event.target.value"
></f7-list-input>
<f7-list-input
type="select"
:label="$t('Default Currency')"
:value="defaultCurrency"
@input="defaultCurrency = $event.target.value"
>
<option v-for="currency in allCurrencies"
:key="currency.code"
:value="currency.code">{{ currency.displayName }}</option>
</f7-list-input>
<f7-list-item class="lab-list-item-error-info" v-if="inputIsInvalid" :footer="$t(inputInvalidProblemMessage)"></f7-list-item>
</f7-list>
@@ -81,6 +93,8 @@
<script>
export default {
data() {
const self = this;
return {
currentPassword: '',
password: '',
@@ -89,9 +103,12 @@ export default {
email: '',
oldNickname: '',
nickname: '',
defaultCurrency: '',
oldDefaultCurrency: '',
loading: true,
updating: false,
showInputPasswordSheet: false
showInputPasswordSheet: false,
allCurrencies: self.$getAllCurrencies()
};
},
computed: {
@@ -104,7 +121,10 @@ export default {
inputIsNotChangedProblemMessage() {
if (!this.password && !this.confirmPassword && !this.email && !this.nickname) {
return 'Nothing has been modified';
} else if (!this.password && !this.confirmPassword && this.email === this.oldEmail && this.nickname === this.oldNickname) {
} else if (!this.password && !this.confirmPassword &&
this.email === this.oldEmail &&
this.nickname === this.oldNickname &&
this.defaultCurrency === this.oldDefaultCurrency) {
return 'Nothing has been modified';
} else if (!this.password && this.confirmPassword) {
return 'Password cannot be empty';
@@ -141,9 +161,11 @@ export default {
self.oldEmail = data.result.email;
self.oldNickname = data.result.nickname;
self.oldDefaultCurrency = data.result.defaultCurrency;
self.email = self.oldEmail
self.nickname = self.oldNickname;
self.defaultCurrency = self.oldDefaultCurrency;
}).catch(error => {
self.loading = false;
@@ -184,7 +206,8 @@ export default {
password: self.password,
oldPassword: self.currentPassword,
email: self.email,
nickname: self.nickname
nickname: self.nickname,
defaultCurrency: self.defaultCurrency
}).then(response => {
self.updating = false;
self.$hideLoading();