Skip to content

Commit

Permalink
restore dialogs controllers initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
akurinnoy committed Sep 11, 2019
1 parent 3a533c2 commit 33806c6
Show file tree
Hide file tree
Showing 24 changed files with 118 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export class AdminsAddUserController {
private $mdDialog: ng.material.IDialogService;
private lodash: any;
private cheNotification: any;
private resourcesService: che.service.IResourcesService;
private cheUser: any;
private callbackController: AdminsUserManagementCtrl;
private newUserName: string;
Expand Down Expand Up @@ -51,26 +50,27 @@ export class AdminsAddUserController {
this.cheNotification = cheNotification;
this.cheOrganization = cheOrganization;
this.chePermissions = chePermissions;
this.resourcesService = resourcesService;
this.organizationRoles = resourcesService.getOrganizationRoles();

this.organizations = [];
}

$onInit(): void {
this.organizationRoles = this.resourcesService.getOrganizationRoles();

this.cheOrganization.fetchOrganizations().then(() => {
let organizations = this.cheOrganization.getOrganizations();
let rootOrganizations = organizations.filter((organization: any) => {
return !organization.parent;
});
this.organizations = this.lodash.pluck(rootOrganizations, 'name');
this.organizations = lodash.pluck(rootOrganizations, 'name');
if (this.organizations.length > 0) {
this.organization = this.organizations[0];
}
});
}

$onInit(): void {
// this method won't be called here
// place all initialization code in constructor
}

/**
* Callback of the cancel button of the dialog.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,17 @@ export class EditRegistryController {
this.$mdDialog = $mdDialog;
this.chePreferences = chePreferences;
this.cheNotification = cheNotification;
}

$onInit(): void {
if (this.registry) {
this.originRegistryUrl = angular.copy(this.registry.url);
}
}

$onInit(): void {
// this method won't be called here
// place all initialization code in constructor
}

/**
* It will hide the dialog box.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@ export class FactoryActionDialogEditController {
*/
constructor($mdDialog: ng.material.IDialogService) {
this.$mdDialog = $mdDialog;
}

$onInit(): void {
this.isName = angular.isDefined(this.selectedValue.name);
this.isFile = angular.isDefined(this.selectedValue.file);
}

$onInit(): void {
// this method won't be called here
// place all initialization code in constructor
}

/**
* Callback of the edit button of the dialog.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ export class FactoryCommandDialogEditController {
this.$mdDialog = $mdDialog;
}

$onInit(): void { }
$onInit(): void {
// this method won't be called here
// place all initialization code in constructor
}

/**
* Callback of the edit button of the dialog.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ export class OrganizationMemberDialogController {
* Lodash library.
*/
private lodash: any;
/**
* Resources service.
*/
private resourcesService: che.service.IResourcesService;
/**
* Processing state of adding member.
*/
Expand Down Expand Up @@ -115,12 +111,10 @@ export class OrganizationMemberDialogController {
this.cheOrganization = cheOrganization;
this.$q = $q;
this.lodash = lodash;
this.resourcesService = resourcesService;
this.organizationRoles = resourcesService.getOrganizationRoles();

this.isProcessing = false;

this.organizationRoles = this.resourcesService.getOrganizationRoles();

this.emails = [];
this.members.forEach((member: che.IMember) => {
this.emails.push(member.email);
Expand All @@ -139,7 +133,7 @@ export class OrganizationMemberDialogController {
this.title = 'Edit ' + this.member.name + ' roles';
this.buttonTitle = 'Save';
this.email = this.member.email;
let roles = this.cheOrganization.getRolesFromActions(this.member.permissions.actions);
let roles = cheOrganization.getRolesFromActions(this.member.permissions.actions);
this.newRole = (roles && roles.length > 0) ? roles[0].name : this.organizationRoles.MEMBER.name;
} else {
this.email = '';
Expand All @@ -149,6 +143,11 @@ export class OrganizationMemberDialogController {
}
}

$onInit(): void {
// this method won't be called here
// place all initialization code in constructor
}

/**
* Returns title of specified role.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ export class OrganizationSelectMembersDialogController {
* Lodash library.
*/
private lodash: any;
/**
* Resources service;
*/
private resourcesService: che.service.IResourcesService;
/**
* Callback handler (is set from outside).
*/
Expand Down Expand Up @@ -103,22 +99,25 @@ export class OrganizationSelectMembersDialogController {
this.lodash = lodash;
this.cheProfile = cheProfile;
this.cheUser = cheUser;
this.resourcesService = resourcesService;
this.organizationRoles = resourcesService.getOrganizationRoles();

this.isLoading = false;

this.userSelectedStatus = {};
this.isBulkChecked = false;
this.isNoSelected = true;
this.isAllSelected = false;
}

$onInit(): void {
this.organizationRoles = this.resourcesService.getOrganizationRoles();
this.user = this.cheUser.getUser();

this.formUsersAvailableList();
}

$onInit(): void {
// this method won't be called here
// place all initialization code in constructor
}

/**
* Builds list of users that are available to be added.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ export class MemberDialogController {
this.lodash = lodash;

this.isProcessing = false;
}

$onInit(): void {
this.emails = [];
this.members.forEach((member: any) => {
this.emails.push(member.email);
Expand Down Expand Up @@ -134,6 +132,11 @@ export class MemberDialogController {
}
}

$onInit(): void {
// this method won't be called here
// place all initialization code in constructor
}

/**
* Hides the add member dialog.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ export class AfterCreationDialogController {
this.$mdDialog = $mdDialog;
}

$onInit(): void { }
$onInit(): void {
// this method won't be called here
// place all initialization code in constructor
}

/**
* It will hide the dialog box.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ export class NoGithubOauthDialogController {
this.message = ($rootScope as any).branding.oauthDocs;
}

$onInit(): void { }
$onInit(): void {
// this method won't be called here
// place all initialization code in constructor
}

/**
* It will hide the dialog box.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ export class AddDeveloperController {
this.$mdDialog = $mdDialog;
}

$onInit(): void { }
$onInit(): void {
// this method won't be called here
// place all initialization code in constructor
}

/**
* Callback of the cancel button of the dialog.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,16 @@ export class AddMemberController {
this.chePermissions = chePermissions;
this.cheProfile = cheProfile;

this.team = cheTeam.getTeamByName(this.namespace);
this.membersSelectedStatus = {};
this.isBulkChecked = false;
this.isNoSelected = true;
this.isAllSelected = true;

if (this.team) {
this.fetchTeamMembers();
}

const helperId = 'add-members';
this.cheListHelper = cheListHelperFactory.getHelper(helperId);
$scope.$on('$destroy', () => {
Expand All @@ -97,11 +102,8 @@ export class AddMemberController {
}

$onInit(): void {
this.team = this.cheTeam.getTeamByName(this.namespace);

if (this.team) {
this.fetchTeamMembers();
}
// this method won't be called here
// place all initialization code in constructor
}

fetchTeamMembers(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ export class EditVariableDialogController {
*/
constructor($mdDialog: ng.material.IDialogService) {
this.$mdDialog = $mdDialog;
}

$onInit(): void {
// build list of used names
let envVariablesCopy = angular.copy(this.envVariables);
if (this.toEdit && envVariablesCopy[this.toEdit]) {
Expand All @@ -59,6 +57,11 @@ export class EditVariableDialogController {
}
}

$onInit(): void {
// this method won't be called here
// place all initialization code in constructor
}

/**
* Check if name is unique.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ export class EditServerDialogController {
lodash: any) {
this.$mdDialog = $mdDialog;
this.lodash = lodash;
}

$onInit(): void {
// get used ports and references
let serversCopy = angular.copy(this.servers);
if (this.toEdit && serversCopy[this.toEdit]) {
Expand All @@ -75,6 +73,12 @@ export class EditServerDialogController {
this.port = this.getLowestFreePort();
this.popupTitle = 'Add a new server';
}

}

$onInit(): void {
// this method won't be called here
// place all initialization code in constructor
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,18 @@ export class DeleteDevMachineDialogController {
*/
constructor($mdDialog: ng.material.IDialogService) {
this.$mdDialog = $mdDialog;
}

$onInit(): void {
if (this.machinesList.length === 1) {
this.message = 'You can\'t delete it without having other machines configured.';
} else {
this.message = 'Select the machine to get ws-agent activated:';
}
}

$onInit(): void {
// this method won't be called here
// place all initialization code in constructor
}

/**
* Closes this dialog.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@ export class EditMachineNameDialogController {
*/
constructor($mdDialog: ng.material.IDialogService) {
this.$mdDialog = $mdDialog;
}

$onInit(): void {
this.origName = this.name;
this.machineNamesLowercase = this.machineNames.map((name: string) => name.toLowerCase());
}

$onInit(): void {
// this method won't be called here
// place all initialization code in constructor
}

isUnique(name: string): boolean {
return this.machineNamesLowercase.indexOf(name.toLowerCase()) < 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export class ExportWorkspaceDialogController {
private cheRemote: CheRemote;
private $window: ng.IWindowService;
private lodash: any;
private $scope: ng.IScope;

private editorOptions: any;
private destination: string;
Expand Down Expand Up @@ -65,7 +64,6 @@ export class ExportWorkspaceDialogController {
this.$mdDialog = $mdDialog;
this.$log = $log;
this.$window = $window;
this.$scope = $scope;

this.editorOptions = {
lineWrapping : true,
Expand All @@ -78,13 +76,16 @@ export class ExportWorkspaceDialogController {
this.privateCloudLogin = '';
this.privateCloudPassword = '';
this.importInProgress = false;
}

$onInit(): void {
this.copyOfConfig = this.getCopyOfConfig();
this.exportConfigContent = this.$filter('json')(angular.fromJson(this.copyOfConfig), 2);

(this.$scope as any).selectedIndex = this.destination === 'file' ? 0 : 1;
($scope as any).selectedIndex = this.destination === 'file' ? 0 : 1;
}

$onInit(): void {
// this method won't be called here
// place all initialization code in constructor
}

/**
Expand Down
Loading

0 comments on commit 33806c6

Please sign in to comment.