From 8d99c88af55041ff06e6b9372b6b1f66220bed38 Mon Sep 17 00:00:00 2001
From: rsanchez <rsanchez@curisit.net>
Date: Mon, 10 Apr 2017 16:08:58 +0000
Subject: [PATCH] #3529 feature - Added applications to user profile and upgrade to angular4
---
securis/src/main/webapp/src/app/forms/user.form.component.ts | 29 ++++++++++++++++++++++++++++-
1 files changed, 28 insertions(+), 1 deletions(-)
diff --git a/securis/src/main/webapp/src/app/forms/user.form.component.ts b/securis/src/main/webapp/src/app/forms/user.form.component.ts
index c579366..bdf543b 100644
--- a/securis/src/main/webapp/src/app/forms/user.form.component.ts
+++ b/securis/src/main/webapp/src/app/forms/user.form.component.ts
@@ -29,12 +29,16 @@
})
export class UserFormComponent extends FormBase {
allOrganizations: IComboOption[];
+ allApplications: IComboOption[];
orgNames: string[] = [];
- allRoles: any[] = [{"id":1, "code": "advance", "label":"Advance"}, {"id":2, "code": "admin","label":"Admin"}];
+ appNames: string[] = [];
+ allRoles: any[] = [{"id":4, "code": "basic","label":"Basic"}, {"id":1, "code": "advance", "label":"Advance"}, {"id":2, "code": "admin","label":"Admin"}];
user_orgs: string[] = [];
+ user_apps: string[] = [];
user_roles: any = {};
constructor(private http: Http,
private users: UsersService,
+ private applications: ApplicationsService,
private organizations: OrganizationsService,
router: Router,
toaster: ToastsManager,
@@ -50,6 +54,10 @@
this.user_orgs.forEach(orgName => {
var selectedOrg = this.allOrganizations.find(org => org.label === orgName);
this.data.organizations_ids.push(selectedOrg.id);
+ });
+ this.user_apps.forEach(appName => {
+ var selectedApp = this.allApplications.find(app => app.label === appName);
+ this.data.applications_ids.push(selectedApp.id);
});
this.user_roles.advance && this.data.roles.push(1);
this.user_roles.admin && this.data.roles.push(2);
@@ -71,6 +79,16 @@
},
err => console.error('Error loading organizations')
);
+ this.applications.get()
+ .map(list => list.map((app : any) => <IComboOption>{id: app.id, label: app.name}))
+ .subscribe(
+ data => {
+ this.allApplications = (<IComboOption[]>data).sort((e1, e2) => e1.label.localeCompare(e2.label));
+ this.appNames = this.allApplications.map(org => org.label);
+ this._loadApps();
+ },
+ err => console.error('Error loading organizations')
+ );
}
goBack(): void {
@@ -84,6 +102,14 @@
});
}
}
+ _loadApps() {
+ if (this.data && this.data.applications_ids && this.allApplications && this.allApplications.length > 0) {
+ this.data.applications_ids.forEach((appId : number) => {
+ var selectedApp = this.allApplications.find(app => app.id === appId);
+ this.user_apps.push(selectedApp.label);
+ });
+ }
+ }
init() : void {
this.loadCombos();
this.user_orgs = [];
@@ -92,6 +118,7 @@
super.reset();
super.prepareInitialData('username', {
organizations_ids: [],
+ applications_ids: [],
roles: []
}, (data) => {
this._loadOrgs();
--
Gitblit v1.3.2