Commit ba3d887a authored by Moises Sacal's avatar Moises Sacal
Browse files

added host info to be displayed at the login page

parent 548f357c
This diff is collapsed.
...@@ -27,6 +27,7 @@ export class LabarchivesLoginField extends FieldBase<any> { ...@@ -27,6 +27,7 @@ export class LabarchivesLoginField extends FieldBase<any> {
submitted = false; submitted = false;
errorMessage: string = undefined; errorMessage: string = undefined;
closeLabel: string; closeLabel: string;
location: string;
user: any; user: any;
loggedIn: boolean; loggedIn: boolean;
...@@ -67,6 +68,8 @@ export class LabarchivesLoginField extends FieldBase<any> { ...@@ -67,6 +68,8 @@ export class LabarchivesLoginField extends FieldBase<any> {
const userInfo = await this.labarchivesService.getUserInfo(); const userInfo = await this.labarchivesService.getUserInfo();
const user = userInfo['user']; const user = userInfo['user'];
this.userEmail = user['email']; this.userEmail = user['email'];
const info = await this.labarchivesService.info();
this.location = info['location'];
} }
async login(form) { async login(form) {
...@@ -144,6 +147,7 @@ export class LabarchivesLoginField extends FieldBase<any> { ...@@ -144,6 +147,7 @@ export class LabarchivesLoginField extends FieldBase<any> {
<div *ngIf="!field.loggedIn" class="col-md-6"> <div *ngIf="!field.loggedIn" class="col-md-6">
<div class="form-row"> <div class="form-row">
<p>{{ field.helpLoginLabel }}</p> <p>{{ field.helpLoginLabel }}</p>
<p><a href="{{ field.location }}" target="_blank" rel="noopener noreferrer">{{ field.location }}</a></p>
<ul> <ul>
<li *ngFor="let help of field.helpLoginLabelList">{{ help }}</li> <li *ngFor="let help of field.helpLoginLabelList">{{ help }}</li>
</ul> </ul>
......
...@@ -34,6 +34,19 @@ export class LabarchivesService extends BaseService { ...@@ -34,6 +34,19 @@ export class LabarchivesService extends BaseService {
} }
} }
public async info() {
const wsUrl = this.brandingAndPortalUrl + '/ws/labarchives/info';
try {
const result = await this.http.get(
wsUrl,
this.options
).toPromise();
return Promise.resolve(this.extractData(result));
} catch (e) {
return Promise.reject(new Error(e));
}
}
public async login(username, password) { public async login(username, password) {
const wsUrl = this.brandingAndPortalUrl + '/ws/labarchives/login'; const wsUrl = this.brandingAndPortalUrl + '/ws/labarchives/login';
try { try {
......
...@@ -11,6 +11,7 @@ var Controllers; ...@@ -11,6 +11,7 @@ var Controllers;
constructor() { constructor() {
super(); super();
this._exportedMethods = [ this._exportedMethods = [
'info',
'login', 'login',
'link', 'link',
'checkLink', 'checkLink',
...@@ -18,6 +19,10 @@ var Controllers; ...@@ -18,6 +19,10 @@ var Controllers;
]; ];
this.config = new Config_1.Config(sails.config.workspaces); this.config = new Config_1.Config(sails.config.workspaces);
} }
info(req, res) {
this.config.brandingAndPortalUrl = BrandingService.getFullPath(req);
this.ajaxOk(req, res, null, { location: this.config.location, status: true });
}
login(req, res) { login(req, res) {
const user = { const user = {
username: req.param('username'), username: req.param('username'),
......
...@@ -56,6 +56,7 @@ module.exports = function (sails) { ...@@ -56,6 +56,7 @@ module.exports = function (sails) {
routes: { routes: {
before: {}, before: {},
after: { after: {
'get /:branding/:portal/ws/labarchives/info': LabarchivesController.info,
'get /:branding/:portal/ws/labarchives/list': LabarchivesController.list, 'get /:branding/:portal/ws/labarchives/list': LabarchivesController.list,
'post /:branding/:portal/ws/labarchives/login': LabarchivesController.login, 'post /:branding/:portal/ws/labarchives/login': LabarchivesController.login,
'post /:branding/:portal/ws/labarchives/link': LabarchivesController.link, 'post /:branding/:portal/ws/labarchives/link': LabarchivesController.link,
......
...@@ -22,6 +22,7 @@ export module Controllers { ...@@ -22,6 +22,7 @@ export module Controllers {
export class LabarchivesController extends controller.Controllers.Core.Controller { export class LabarchivesController extends controller.Controllers.Core.Controller {
protected _exportedMethods: any = [ protected _exportedMethods: any = [
'info',
'login', 'login',
'link', 'link',
'checkLink', 'checkLink',
...@@ -36,6 +37,11 @@ export module Controllers { ...@@ -36,6 +37,11 @@ export module Controllers {
this.config = new Config(sails.config.workspaces); this.config = new Config(sails.config.workspaces);
} }
public info(req, res) {
this.config.brandingAndPortalUrl = BrandingService.getFullPath(req);
this.ajaxOk(req, res, null, {location: this.config.location, status: true});
}
login(req, res) { login(req, res) {
const user = { const user = {
username: req.param('username'), username: req.param('username'),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment