Skip to content

Commit bd2ea09

Browse files
authored
CHE-5802: transplantation of Codenvy dashboard stuff to Che dashboard (eclipse-che#6381)
* code clean-up Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com> * move user-management and its related components Signed-off-by: Oleksii Kurinnyi <okurinnyi@codenvy.com> * move organizations and its related components Signed-off-by: Oleksii Kurinnyi <okurinnyi@codenvy.com> * add Keycloak authorization Signed-off-by: Oleksii Kurinnyi <okurinnyi@codenvy.com> * move teams and its related components Signed-off-by: Oleksii Kurinnyi <okurinnyi@codenvy.com> * move share-workspace and its related components Signed-off-by: Oleksii Kurinnyi <okurinnyi@codenvy.com> * update assembly * fixup! update assembly
1 parent de347be commit bd2ea09

162 files changed

Lines changed: 15292 additions & 195 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

assembly-multiuser/assembly-main/pom.xml

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
<artifactId>assembly-wsmaster-war</artifactId>
4343
<type>war</type>
4444
</dependency>
45+
<dependency>
46+
<groupId>org.eclipse.che.dashboard</groupId>
47+
<artifactId>che-dashboard-war</artifactId>
48+
<type>war</type>
49+
</dependency>
4550
<dependency>
4651
<groupId>org.postgresql</groupId>
4752
<artifactId>postgresql</artifactId>
@@ -95,22 +100,4 @@
95100
</plugin>
96101
</plugins>
97102
</build>
98-
<profiles>
99-
<profile>
100-
<id>withDashboard</id>
101-
<activation>
102-
<property>
103-
<name>withoutDashboard</name>
104-
<value>!true</value>
105-
</property>
106-
</activation>
107-
<dependencies>
108-
<dependency>
109-
<groupId>org.eclipse.che.assembly-multiuser</groupId>
110-
<artifactId>che-dashboard-war</artifactId>
111-
<type>war</type>
112-
</dependency>
113-
</dependencies>
114-
</profile>
115-
</profiles>
116103
</project>

assembly-multiuser/assembly-main/src/assembly/assembly.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
<outputDirectory>tomcat/webapps</outputDirectory>
5656
<outputFileNameMapping>dashboard.war</outputFileNameMapping>
5757
<includes>
58-
<include>org.eclipse.che.assembly-multiuser:che-dashboard-war</include>
58+
<include>org.eclipse.che.dashboard:che-dashboard-war</include>
5959
</includes>
6060
</dependencySet>
6161
<dependencySet>

assembly-multiuser/pom.xml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -188,18 +188,4 @@
188188
</plugins>
189189
</pluginManagement>
190190
</build>
191-
<profiles>
192-
<profile>
193-
<id>withDashboard</id>
194-
<activation>
195-
<property>
196-
<name>withoutDashboard</name>
197-
<value>!true</value>
198-
</property>
199-
</activation>
200-
<modules>
201-
<module>dashboard</module>
202-
</modules>
203-
</profile>
204-
</profiles>
205191
</project>

dashboard/bower.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"angular-charts": "0.2.6",
1515
"angular-cookies": "1.4.8",
1616
"angular-dropdowns": "1.0.0",
17+
"angular-gravatar": "0.2.4",
1718
"angular-filter": "0.5.4",
1819
"angular-material": "1.0.1",
1920
"angular-moment": "0.9.0",

dashboard/gulp/proxy.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ var serverOptions = {
2222

2323
var options = minimist(process.argv.slice(2), serverOptions);
2424

25-
var patterns = ['/api', '/ext', '/ws', '/datasource', '/java-ca', '/im', '/che', '/admin'];
26-
27-
var proxies = []
25+
var patterns = ['/api', '/ext', '/ws', '/datasource', '/java-ca', '/im', '/che', '/admin', '/wsmaster'];
2826

27+
var proxies = [];
2928

3029
patterns.forEach(function(pattern) {
3130
var proxyOptions = url.parse(options.server + pattern);
@@ -37,6 +36,8 @@ patterns.forEach(function(pattern) {
3736
proxyOptions.route = '/admin';
3837
} else if (pattern === '/ext') {
3938
proxyOptions.route = '/ext';
39+
} else if (pattern === '/wsmaster') {
40+
proxyOptions.route = '/wsmaster';
4041
} else {
4142
proxyOptions.route = '/api';
4243
}

dashboard/src/app/admin/admin-config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@
1111
'use strict';
1212

1313
import {AdminsPluginsConfig} from './plugins/plugins-config';
14+
import {AdminsUserManagementConfig} from './user-management/user-management-config';
1415

1516
/**
1617
* @author Florent Benoit
1718
*/
1819
export class AdminsConfig {
1920

20-
constructor(register) {
21+
constructor(register: che.IRegisterService) {
2122
new AdminsPluginsConfig(register);
22-
23+
new AdminsUserManagementConfig(register);
2324
}
2425
}
2526

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright (c) 2015-2017 Red Hat, Inc.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Red Hat, Inc. - initial API and implementation
10+
*/
11+
'use strict';
12+
13+
interface IAccountProfileScope extends ng.IScope {
14+
profileAttributes: {
15+
phone?: string;
16+
country?: string;
17+
employer?: string;
18+
jobtitle?: string;
19+
lastName?: string;
20+
firstName?: string;
21+
};
22+
profileInformationForm: ng.IFormController;
23+
countries?: Array<{ 'name': string, 'code': string }>;
24+
jobs?: Array<{ 'name': string }>;
25+
}
26+
27+
/**
28+
* @ngdoc directive
29+
* @name account.profile.directive:accountProfile
30+
* @restrict E
31+
* @element
32+
*
33+
* @description
34+
* <account-profile profile-attributes="ctrl.profileAttributes"></account-profile>` for displaying account profile.
35+
*
36+
* @usage
37+
* <account-profile profile-attributes="ctrl.profileAttributes"></account-profile>
38+
*
39+
* @author Florent Benoit
40+
*/
41+
export class AccountProfile implements ng.IDirective {
42+
restrict = 'E';
43+
templateUrl = 'app/account/account-profile/account-profile.html';
44+
replace = true;
45+
scope = {
46+
profileAttributes: '=profileAttributes',
47+
profileInformationForm: '=?profileInformationForm'
48+
};
49+
50+
jsonCountries: string;
51+
jsonJobs: string;
52+
53+
/**
54+
* Default constructor that is using resource
55+
* @ngInject for Dependency injection
56+
*/
57+
constructor(jsonCountries: string, jsonJobs: string) {
58+
this.jsonCountries = jsonCountries;
59+
this.jsonJobs = jsonJobs;
60+
}
61+
62+
link($scope: IAccountProfileScope) {
63+
$scope.countries = angular.fromJson(this.jsonCountries);
64+
$scope.jobs = angular.fromJson(this.jsonJobs);
65+
}
66+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<div class="account-profile">
2+
<ng-form name="profileInformationForm">
3+
<che-label-container che-label-name="First Name">
4+
<che-input che-form="profileInformationForm"
5+
che-name="firstName"
6+
che-place-holder="First Name"
7+
ng-model="profileAttributes.firstName"
8+
required
9+
ng-maxlength="128">
10+
<div ng-message="required">A name is required.</div>
11+
<div ng-message="maxlength">The name has to be less than 128 characters long.</div>
12+
</che-input>
13+
</che-label-container>
14+
15+
<che-label-container che-label-name="Last Name">
16+
<che-input che-form="profileInformationForm"
17+
che-name="lastName"
18+
che-place-holder="Last Name"
19+
ng-model="profileAttributes.lastName"
20+
required
21+
ng-maxlength="128">
22+
<div ng-message="required">A last name is required.</div>
23+
<div ng-message="maxlength">The name has to be less than 128 characters long.</div>
24+
</che-input>
25+
</che-label-container>
26+
27+
<che-label-container che-label-name="Phone">
28+
<che-input che-form="profileInformationForm"
29+
che-name="phone"
30+
che-place-holder="phone"
31+
che-pattern="(^[+]{0,1}[0-9-]{0,}$)"
32+
ng-model="profileAttributes.phone"
33+
ng-maxlength="15"
34+
ng-minlength="7">
35+
<div ng-message="pattern">Should be numbers and may start with a '+'.</div>
36+
<div ng-message="minlength">The phone number has to be more than 7 characters long.</div>
37+
<div ng-message="maxlength">The phone number has to be less than 15 characters long.</div>
38+
</che-input>
39+
</che-label-container>
40+
41+
<che-label-container che-label-name="Country">
42+
<che-select che-form="profileInformationForm"
43+
che-name="country"
44+
che-option-values="countries"
45+
che-place-holder="Select Your Country"
46+
che-value="profileAttributes.country">
47+
</che-select>
48+
</che-label-container>
49+
50+
<che-label-container che-label-name="Company">
51+
<che-input che-form="profileInformationForm"
52+
che-name="department"
53+
che-place-holder="Company"
54+
ng-model="profileAttributes.employer"
55+
ng-maxlength="128">
56+
<div ng-message="maxlength">The name has to be less than 128 characters long.</div>
57+
</che-input>
58+
</che-label-container>
59+
60+
<che-label-container che-label-name="Role">
61+
<che-select che-option-values="jobs"
62+
che-place-holder="Select Your Role"
63+
che-value="profileAttributes.jobtitle">
64+
</che-select>
65+
</che-label-container>
66+
</ng-form>
67+
</div>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.account-profile
2+
padding 0 14px
3+
4+
.che-input-desktop
5+
margin-top -1px
6+
7+
.che-select
8+
margin-top -2px
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/*
2+
* Copyright (c) 2015-2017 Red Hat, Inc.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Red Hat, Inc. - initial API and implementation
10+
*/
11+
'use strict';
12+
import {AdminsUserManagementCtrl} from '../user-management.controller';
13+
14+
/**
15+
* This class is handling the controller for the add user
16+
* @author Oleksii Orel
17+
*/
18+
export class AdminsAddUserController {
19+
private $mdDialog: ng.material.IDialogService;
20+
private lodash: any;
21+
private cheNotification: any;
22+
private cheUser: any;
23+
private callbackController: AdminsUserManagementCtrl;
24+
private newUserName: string;
25+
private newUserEmail: string;
26+
private newUserPassword: string;
27+
private organizations: Array<string>;
28+
private organization: string;
29+
private cheOrganization: che.api.ICheOrganization;
30+
private chePermissions: che.api.IChePermissions;
31+
private organizationRoles: che.resource.ICheOrganizationRoles;
32+
33+
/**
34+
* Default constructor.
35+
* @ngInject for Dependency injection
36+
*/
37+
constructor($mdDialog: ng.material.IDialogService,
38+
cheUser: any,
39+
cheNotification: any,
40+
lodash: any,
41+
cheOrganization: che.api.ICheOrganization,
42+
chePermissions: che.api.IChePermissions,
43+
resourcesService: che.service.IResourcesService) {
44+
this.$mdDialog = $mdDialog;
45+
this.lodash = lodash;
46+
this.cheUser = cheUser;
47+
this.cheNotification = cheNotification;
48+
this.cheOrganization = cheOrganization;
49+
this.chePermissions = chePermissions;
50+
this.organizationRoles = resourcesService.getOrganizationRoles();
51+
52+
this.organizations = [];
53+
54+
this.cheOrganization.fetchOrganizations().then(() => {
55+
let organizations = this.cheOrganization.getOrganizations();
56+
let rootOrganizations = organizations.filter((organization: any) => {
57+
return !organization.parent;
58+
});
59+
this.organizations = lodash.pluck(rootOrganizations, 'name');
60+
if (this.organizations.length > 0) {
61+
this.organization = this.organizations[0];
62+
}
63+
});
64+
}
65+
66+
/**
67+
* Callback of the cancel button of the dialog.
68+
*/
69+
abort(): void {
70+
this.$mdDialog.hide();
71+
}
72+
73+
/**
74+
* Callback of the add button of the dialog(create new user).
75+
*/
76+
createUser(): void {
77+
let promise = this.cheUser.createUser(this.newUserName, this.newUserEmail, this.newUserPassword);
78+
79+
promise.then((data: any) => {
80+
if (this.organization) {
81+
this.addUserToOrganization(data.id);
82+
} else {
83+
this.finish();
84+
}
85+
}, (error: any) => {
86+
this.cheNotification.showError(error.data.message ? error.data.message : 'Failed to create user.');
87+
});
88+
}
89+
90+
/**
91+
* Finish user creation.
92+
*/
93+
private finish(): void {
94+
this.$mdDialog.hide();
95+
this.callbackController.updateUsers();
96+
this.cheNotification.showInfo('User successfully created.');
97+
}
98+
99+
/**
100+
* Adds user to chosen organization.
101+
*
102+
* @param userId
103+
*/
104+
private addUserToOrganization(userId: string): void {
105+
let organizations = this.cheOrganization.getOrganizations();
106+
let organization = this.lodash.find(organizations, (organization: any) => {
107+
return organization.name === this.organization;
108+
});
109+
110+
let actions = this.organizationRoles.MEMBER.actions;
111+
let permissions = {
112+
instanceId: organization.id,
113+
userId: userId,
114+
domainId: 'organization',
115+
actions: actions
116+
};
117+
this.chePermissions.storePermissions(permissions).then(() => {
118+
this.finish();
119+
}, (error: any) => {
120+
this.cheNotification.showError(error.data.message ? error.data.message : 'Failed to add user to organization' + this.organization + '.');
121+
});
122+
}
123+
}

0 commit comments

Comments
 (0)