Skip to content
Snippets Groups Projects
Commit d5847ad8 authored by vkovtun's avatar vkovtun
Browse files

SSDM-8751 Added a control to change Zenodo API token.

parent f6b31296
No related branches found
No related tags found
No related merge requests found
...@@ -19,6 +19,8 @@ function UserProfileController(mainController, mode) { ...@@ -19,6 +19,8 @@ function UserProfileController(mainController, mode) {
this._userProfileModel = new UserProfileModel(mode); this._userProfileModel = new UserProfileModel(mode);
this._userProfileView = new UserProfileView(this, this._userProfileModel); this._userProfileView = new UserProfileView(this, this._userProfileModel);
this._zenodoApiTokenKey = "personal-zenodo-api-token";
this.init = function(views) { this.init = function(views) {
this._userProfileView.repaint(views); this._userProfileView.repaint(views);
} }
...@@ -49,6 +51,8 @@ function UserProfileController(mainController, mode) { ...@@ -49,6 +51,8 @@ function UserProfileController(mainController, mode) {
return; return;
} }
var userId = this._mainController.serverFacade.getUserId(); var userId = this._mainController.serverFacade.getUserId();
this.setSettingValue(this._zenodoApiTokenKey, userInformation.zenodoToken);
this._mainController.serverFacade.updateUserInformation(userId, userInformation, (function(ok) { this._mainController.serverFacade.updateUserInformation(userId, userInformation, (function(ok) {
if (ok) { if (ok) {
Util.showInfo("Profile saved. You will be logged out automatically in order to reload the profile data upon login.", (function() { Util.showInfo("Profile saved. You will be logged out automatically in order to reload the profile data upon login.", (function() {
...@@ -74,4 +78,12 @@ function UserProfileController(mainController, mode) { ...@@ -74,4 +78,12 @@ function UserProfileController(mainController, mode) {
this._mainController.profile.isFileAuthenticationUser; this._mainController.profile.isFileAuthenticationUser;
} }
this.getSettingValue = function (key, callback) {
this._mainController.serverFacade.getSetting(key, callback);
};
this.setSettingValue = function (key, value) {
this._mainController.serverFacade.setSetting(key, value);
};
} }
\ No newline at end of file
...@@ -21,6 +21,7 @@ function UserProfileView(userProfileController, userProfileModel) { ...@@ -21,6 +21,7 @@ function UserProfileView(userProfileController, userProfileModel) {
this._$firstNameInput = null; this._$firstNameInput = null;
this._$lastNameInput = null; this._$lastNameInput = null;
this._$emailInput = null; this._$emailInput = null;
this._$zenodoToken = null;
this.repaint = function(views) { this.repaint = function(views) {
...@@ -71,6 +72,16 @@ function UserProfileView(userProfileController, userProfileModel) { ...@@ -71,6 +72,16 @@ function UserProfileView(userProfileController, userProfileModel) {
this._$emailInput = $("<input>", { type : "text", class : "form-control" }); this._$emailInput = $("<input>", { type : "text", class : "form-control" });
this._$emailInput.val(getUserInformation.email); this._$emailInput.val(getUserInformation.email);
$formColumn.append(this._getFormGroup(this._$emailInput, "Email:")); $formColumn.append(this._getFormGroup(this._$emailInput, "Email:"));
// personal Zenodo API token
this._$zenodoToken = $("<input>", { type : "text", class : "form-control" });
this._userProfileController.getSettingValue(this._userProfileController._zenodoApiTokenKey, (function (settingsValue) {
if (settingsValue) {
this._$zenodoToken.val(settingsValue);
}
}).bind(this));
$formColumn.append(this._getFormGroup(this._$zenodoToken, "Zenodo API Token:"));
// disable in view mode // disable in view mode
if (this._userProfileModel.mode === FormMode.VIEW || if (this._userProfileModel.mode === FormMode.VIEW ||
!this._userProfileController.isFileAuthentication()) { !this._userProfileController.isFileAuthentication()) {
...@@ -78,6 +89,10 @@ function UserProfileView(userProfileController, userProfileModel) { ...@@ -78,6 +89,10 @@ function UserProfileView(userProfileController, userProfileModel) {
this._$lastNameInput.prop("disabled", true); this._$lastNameInput.prop("disabled", true);
this._$emailInput.prop("disabled", true); this._$emailInput.prop("disabled", true);
} }
if (this._userProfileModel.mode === FormMode.VIEW) {
this._$zenodoToken.prop("disabled", true);
}
}).bind(this)); }).bind(this));
} }
...@@ -97,6 +112,7 @@ function UserProfileView(userProfileController, userProfileModel) { ...@@ -97,6 +112,7 @@ function UserProfileView(userProfileController, userProfileModel) {
firstName : this._$firstNameInput.val(), firstName : this._$firstNameInput.val(),
lastName : this._$lastNameInput.val(), lastName : this._$lastNameInput.val(),
email : this._$emailInput.val(), email : this._$emailInput.val(),
zenodoToken : this._$zenodoToken.val()
}; };
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment