+ ng-repeat="template in filteredTemplates = (selectTemplateController.templates | samplesTagFilter:selectTemplateController.stack.tags | orderBy:['projectType', selectTemplateController.projectsOrderBy])">
;
+ private projectService: CheProject;
+ private invalidProject: boolean;
+ private projectDetails: che.IProjectTemplate;
+ private projectDescription: string;
+
/**
* Default constructor that is using resource injection
* @ngInject for Dependency injection
*/
- constructor($scope, $log, $route, $location, cheAPI, confirmDialogService, cheNotification, lodash, $timeout) {
+ constructor($scope: ng.IScope,
+ $log: ng.ILogService,
+ $route: ng.route.IRouteService,
+ $location: ng.ILocationService,
+ $timeout: ng.ITimeoutService,
+ cheAPI: CheAPI,
+ confirmDialogService: ConfirmDialogService,
+ cheNotification: CheNotification,
+ lodash: any) {
this.$log = $log;
this.cheNotification = cheNotification;
this.cheAPI = cheAPI;
@@ -51,7 +80,7 @@ export class ProjectDetailsController {
} else {
this.loading = false;
}
- }, (error) => {
+ }, (error: any) => {
this.cheNotification.showError(error.data.message ? error.data.message : 'Failed to get runtime of the project workspace.');
this.$log.log('error', error);
});
@@ -59,7 +88,6 @@ export class ProjectDetailsController {
this.fetchProjectDetails();
}
- this.timeoutPromise;
$scope.$on('$destroy', () => {
if (this.timeoutPromise) {
$timeout.cancel(this.timeoutPromise);
@@ -67,7 +95,7 @@ export class ProjectDetailsController {
});
}
- fetchProjectDetails() {
+ fetchProjectDetails(): void {
this.loading = true;
if (this.workspace.status !== 'STARTING' && this.workspace.status !== 'RUNNING') {
@@ -88,7 +116,7 @@ export class ProjectDetailsController {
this.projectService.fetchProjectDetails(this.workspace.id, this.projectPath).then(() => {
this.loading = false;
this.updateProjectDetails();
- }, (error) => {
+ }, (error: any) => {
if (error.status === 304) {
this.loading = false;
this.updateProjectDetails();
@@ -99,27 +127,27 @@ export class ProjectDetailsController {
}
});
}
- }, (error) => {
+ }, (error: any) => {
this.$log.error(error);
this.loading = false;
});
}
- updateProjectDetails() {
+ updateProjectDetails(): void {
this.projectDetails = this.projectService.getProjectDetailsByKey(this.projectPath);
this.projectName = angular.copy(this.projectDetails.name);
this.projectDescription = angular.copy(this.projectDetails.description);
this.loading = false;
}
- updateLocation() {
+ updateLocation(): void {
if (this.$location.path().endsWith(this.projectDetails.name)) {
return;
}
- this.$location.path('/project/' + this.namespace + '/' + this.workspaceName + '/' + this.projectDetails.name);
+ this.$location.path('/workspace/' + this.namespace + '/' + this.workspaceName + '/' + this.projectDetails.name);
}
- setProjectDetails(projectDetails) {
+ setProjectDetails(projectDetails: che.IProjectTemplate): void {
projectDetails.description = this.projectDescription;
let promise = this.projectService.updateProjectDetails(projectDetails);
@@ -127,13 +155,13 @@ export class ProjectDetailsController {
this.cheNotification.showInfo('Project information successfully updated.');
this.updateLocation();
if (this.isNameChanged()) {
- this.projectService.fetchProjectDetails(this.projectPath).then(() => {
+ this.projectService.fetchProjectDetails(this.workspace.id, this.projectPath).then(() => {
this.updateProjectDetails();
});
} else {
this.projectDescription = projectDetails.description;
}
- }, (error) => {
+ }, (error: any) => {
this.projectDetails.description = this.projectDescription;
this.cheNotification.showError(error.data.message ? error.data.message : 'Update information failed.');
this.$log.log('error', error);
@@ -141,7 +169,7 @@ export class ProjectDetailsController {
}
- isNameChanged() {
+ isNameChanged(): boolean {
if (this.projectDetails) {
return this.projectName !== this.projectDetails.name;
} else {
@@ -149,7 +177,7 @@ export class ProjectDetailsController {
}
}
- isDescriptionChanged() {
+ isDescriptionChanged(): boolean {
if (this.projectDetails) {
return this.projectDescription !== this.projectDetails.description;
} else {
@@ -157,7 +185,7 @@ export class ProjectDetailsController {
}
}
- updateInfo(isInputFormValid) {
+ updateInfo(isInputFormValid: boolean): void {
this.$timeout.cancel(this.timeoutPromise);
if (!isInputFormValid || !(this.isNameChanged() || this.isDescriptionChanged())) {
@@ -169,7 +197,7 @@ export class ProjectDetailsController {
}, 500);
}
- doUpdateInfo() {
+ doUpdateInfo(): void {
if (this.isNameChanged()) {
let promise = this.projectService.rename(this.projectDetails.name, this.projectName);
@@ -184,7 +212,7 @@ export class ProjectDetailsController {
} else {
this.setProjectDetails(this.projectDetails);
}
- }, (error) => {
+ }, (error: any) => {
this.projectDetails.name = this.projectName;
this.cheNotification.showError(error.data.message ? error.data.message : 'Update information failed.');
this.$log.log('error', error);
@@ -194,7 +222,7 @@ export class ProjectDetailsController {
}
}
- deleteProject() {
+ deleteProject(): void {
let content = 'Would you like to delete the project \'' + this.projectDetails.name + '\' ?';
this.confirmDialogService.showConfirmDialog('Remove project', content, 'Delete').then(() => {
// remove it !
@@ -213,7 +241,7 @@ export class ProjectDetailsController {
* Returns list of projects of current workspace excluding current project
* @returns {*|Array}
*/
- getWorkspaceProjects() {
+ getWorkspaceProjects(): Array {
let projects = this.cheAPI.getWorkspace().getWorkspaceProjects()[this.workspace.id];
let _projects = this.lodash.filter(projects, (project) => { return project.name !== this.projectName});
return _projects;
@@ -223,7 +251,7 @@ export class ProjectDetailsController {
* Returns current status of workspace
* @returns {String}
*/
- getWorkspaceStatus() {
+ getWorkspaceStatus(): string {
if (!this.workspace) {
return 'unknown';
}
diff --git a/dashboard/src/app/projects/project-details/project-details.html b/dashboard/src/app/workspaces/workspace-details/workspace-projects/project-details/project-details.html
similarity index 100%
rename from dashboard/src/app/projects/project-details/project-details.html
rename to dashboard/src/app/workspaces/workspace-details/workspace-projects/project-details/project-details.html
diff --git a/dashboard/src/app/projects/project-details/project-details.styl b/dashboard/src/app/workspaces/workspace-details/workspace-projects/project-details/project-details.styl
similarity index 100%
rename from dashboard/src/app/projects/project-details/project-details.styl
rename to dashboard/src/app/workspaces/workspace-details/workspace-projects/project-details/project-details.styl
diff --git a/dashboard/src/app/projects/project-details/repository/project-repository-data.ts b/dashboard/src/app/workspaces/workspace-details/workspace-projects/project-details/repository/project-repository-data.ts
similarity index 100%
rename from dashboard/src/app/projects/project-details/repository/project-repository-data.ts
rename to dashboard/src/app/workspaces/workspace-details/workspace-projects/project-details/repository/project-repository-data.ts
diff --git a/dashboard/src/app/projects/project-details/repository/project-repository.controller.ts b/dashboard/src/app/workspaces/workspace-details/workspace-projects/project-details/repository/project-repository.controller.ts
similarity index 63%
rename from dashboard/src/app/projects/project-details/repository/project-repository.controller.ts
rename to dashboard/src/app/workspaces/workspace-details/workspace-projects/project-details/repository/project-repository.controller.ts
index 64ef6b808c..d3e09cf9c3 100644
--- a/dashboard/src/app/projects/project-details/repository/project-repository.controller.ts
+++ b/dashboard/src/app/workspaces/workspace-details/workspace-projects/project-details/repository/project-repository.controller.ts
@@ -10,30 +10,38 @@
*/
'use strict';
-import {gitMixinId, subversionMixinId} from '../repository/project-repository-data';
+import {gitMixinId, subversionMixinId} from './project-repository-data';
+import {CheAPI} from '../../../../../../components/api/che-api.factory';
+import {WorkspaceStatus} from '../../../../../../components/api/workspace/che-workspace.factory';
+import {CheWorkspaceAgent} from '../../../../../../components/api/che-workspace-agent';
export class ProjectRepositoryController {
+ private cheAPI: CheAPI;
+ private lodash: any;
+
+ private remoteGitRepositories: any[] = [];
+ private localGitRepository: any = null;
+ private remoteSvnRepository: any = null;
+ private isEmptyState: boolean = false;
+ private wsagent: CheWorkspaceAgent;
/**
* Controller for the project local repository and remote repositories details
* @ngInject for Dependency injection
* @author Oleksii Orel
*/
- constructor($route, cheAPI, lodash) {
+ constructor($route: ng.route.IRouteService,
+ cheAPI: CheAPI,
+ lodash: any) {
this.cheAPI = cheAPI;
this.lodash = lodash;
- this.remoteGitRepositories = [];
- this.localGitRepository = null;
- this.remoteSvnRepository = null;
- this.isEmptyState = false;
+ const namespace = $route.current.params.namespace;
+ const workspaceName = $route.current.params.workspaceName;
+ const projectPath = '/' + $route.current.params.projectName;
- var namespace = $route.current.params.namespace;
- var workspaceName = $route.current.params.workspaceName;
- var projectPath = '/' + $route.current.params.projectName;
-
- let workspace = this.cheAPI.getWorkspace().getWorkspaceByName(namespace, workspaceName);
- if (workspace && (workspace.status === 'STARTING' || workspace.status === 'RUNNING')) {
+ const workspace = this.cheAPI.getWorkspace().getWorkspaceByName(namespace, workspaceName);
+ if (workspace && (WorkspaceStatus[workspace.status] === WorkspaceStatus.RUNNING || WorkspaceStatus[workspace.status] === 'RUNNING')) {
this.cheAPI.getWorkspace().fetchStatusChange(workspace.id, 'RUNNING').then(() => {
return this.cheAPI.getWorkspace().fetchWorkspaceDetails(workspace.id);
}).then(() => {
@@ -43,11 +51,11 @@ export class ProjectRepositoryController {
let promise = this.wsagent.getProject().fetchProjectDetails(workspace.id, projectPath);
promise.then(() => {
- var projectDetails = this.wsagent.getProject().getProjectDetailsByKey(projectPath);
+ const projectDetails = this.wsagent.getProject().getProjectDetailsByKey(projectPath);
this.updateRepositories(projectDetails);
});
} else {
- var projectDetails = this.wsagent.getProject().getProjectDetailsByKey(projectPath);
+ const projectDetails = this.wsagent.getProject().getProjectDetailsByKey(projectPath);
this.updateRepositories(projectDetails);
}
}
@@ -55,7 +63,7 @@ export class ProjectRepositoryController {
}
}
- updateRepositories(projectDetails) {
+ updateRepositories(projectDetails: che.IProjectTemplate): void {
if (!projectDetails.mixins || !projectDetails.mixins.length) {
this.isEmptyState = true;
return;
@@ -64,7 +72,7 @@ export class ProjectRepositoryController {
if (projectDetails.mixins.indexOf(subversionMixinId) !== -1) {
//update remote svn url
if (!this.wsagent.getSvn().getRemoteUrlByKey(projectDetails.workspaceId, projectDetails.path)) {
- let promise = this.wsagent.getSvn().fetchRemoteUrl(projectDetails.workspaceId, projectDetails.path);
+ const promise = this.wsagent.getSvn().fetchRemoteUrl(projectDetails.workspaceId, projectDetails.path);
promise.then(() => {
this.remoteSvnRepository = this.wsagent.getSvn().getRemoteUrlByKey(projectDetails.workspaceId, projectDetails.path);
@@ -77,7 +85,7 @@ export class ProjectRepositoryController {
if (projectDetails.mixins.indexOf(gitMixinId) !== -1) {
//update git local url
if (!this.wsagent.getGit().getLocalUrlByKey(projectDetails.path)) {
- let promise = this.wsagent.getGit().fetchLocalUrl(projectDetails.path);
+ const promise = this.wsagent.getGit().fetchLocalUrl(projectDetails.path);
promise.then(() => {
this.localGitRepository = this.wsagent.getGit().getLocalUrlByKey(projectDetails.path);
@@ -88,7 +96,7 @@ export class ProjectRepositoryController {
//update git remote urls
if (!this.wsagent.getGit().getRemoteUrlArrayByKey(projectDetails.path)) {
- let promise = this.wsagent.getGit().fetchRemoteUrlArray(projectDetails.path);
+ const promise = this.wsagent.getGit().fetchRemoteUrlArray(projectDetails.path);
promise.then(() => {
this.remoteGitRepositories = this.wsagent.getGit().getRemoteUrlArrayByKey(projectDetails.path);
diff --git a/dashboard/src/app/projects/project-details/repository/project-repository.directive.ts b/dashboard/src/app/workspaces/workspace-details/workspace-projects/project-details/repository/project-repository.directive.ts
similarity index 52%
rename from dashboard/src/app/projects/project-details/repository/project-repository.directive.ts
rename to dashboard/src/app/workspaces/workspace-details/workspace-projects/project-details/repository/project-repository.directive.ts
index fe32106e31..a619a677b9 100644
--- a/dashboard/src/app/projects/project-details/repository/project-repository.directive.ts
+++ b/dashboard/src/app/workspaces/workspace-details/workspace-projects/project-details/repository/project-repository.directive.ts
@@ -14,24 +14,16 @@
* Defines a directive for displaying project repository widget.
* @author Oleksii Orel
*/
-export class ProjectRepository {
+export class ProjectRepository implements ng.IDirective {
+ restrict = 'E';
- /**
- * Default constructor that is using resource
- * @ngInject for Dependency injection
- */
- constructor() {
- this.restrict = 'E';
+ templateUrl = 'app/workspaces/workspace-details/workspace-projects/project-details/repository/project-repository.html';
- this.templateUrl = 'app/projects/project-details/repository/project-repository.html';
+ controller = 'ProjectRepositoryController';
+ controllerAs = 'projectRepositoryController';
- this.controller = 'ProjectRepositoryController';
- this.controllerAs = 'projectRepositoryController';
+ bindToController = true;
- this.bindToController = true;
-
- this.scope = true;
-
- }
+ scope = true;
}
diff --git a/dashboard/src/app/projects/project-details/repository/project-repository.html b/dashboard/src/app/workspaces/workspace-details/workspace-projects/project-details/repository/project-repository.html
similarity index 100%
rename from dashboard/src/app/projects/project-details/repository/project-repository.html
rename to dashboard/src/app/workspaces/workspace-details/workspace-projects/project-details/repository/project-repository.html
diff --git a/dashboard/src/app/projects/project-details/repository/project-repository.styl b/dashboard/src/app/workspaces/workspace-details/workspace-projects/project-details/repository/project-repository.styl
similarity index 100%
rename from dashboard/src/app/projects/project-details/repository/project-repository.styl
rename to dashboard/src/app/workspaces/workspace-details/workspace-projects/project-details/repository/project-repository.styl
diff --git a/dashboard/src/app/projects/list-projects/project-item/project-item.controller.ts b/dashboard/src/app/workspaces/workspace-details/workspace-projects/project-item/project-item.controller.ts
similarity index 61%
rename from dashboard/src/app/projects/list-projects/project-item/project-item.controller.ts
rename to dashboard/src/app/workspaces/workspace-details/workspace-projects/project-item/project-item.controller.ts
index c564cbdb10..e6dd51c8ba 100644
--- a/dashboard/src/app/projects/list-projects/project-item/project-item.controller.ts
+++ b/dashboard/src/app/workspaces/workspace-details/workspace-projects/project-item/project-item.controller.ts
@@ -9,6 +9,7 @@
* Red Hat, Inc. - initial API and implementation
*/
'use strict';
+import {CheWorkspace} from '../../../../../components/api/workspace/che-workspace.factory';
/**
* @ngdoc controller
@@ -17,18 +18,24 @@
* @author Florent Benoit
*/
export class ProjectItemCtrl {
+ private $location: ng.ILocationService;
+ private cheWorkspace: CheWorkspace;
+
+ private workspace: che.IWorkspace;
+ private project: che.IProject;
/**
* Default constructor that is using resource
* @ngInject for Dependency injection
*/
- constructor($location, cheWorkspace) {
+ constructor($location: ng.ILocationService,
+ cheWorkspace: CheWorkspace) {
this.$location = $location;
this.cheWorkspace = cheWorkspace;
}
- redirectToProjectDetails() {
- this.$location.path('/project/' + this.workspace.namespace + '/' + this.workspace.config.name + '/' + this.project.name);
+ redirectToProjectDetails(): void {
+ this.$location.path('/workspace/' + this.workspace.namespace + '/' + this.workspace.config.name + '/' + this.project.name);
}
}
diff --git a/dashboard/src/app/workspaces/workspace-details/workspace-projects/project-item/project-item.directive.ts b/dashboard/src/app/workspaces/workspace-details/workspace-projects/project-item/project-item.directive.ts
new file mode 100644
index 0000000000..f5bfa13ee2
--- /dev/null
+++ b/dashboard/src/app/workspaces/workspace-details/workspace-projects/project-item/project-item.directive.ts
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2015-2017 Red Hat, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ */
+'use strict';
+
+/**
+ * Defines a directive for items in project list.
+ * Expects in parent scope:
+ * @param{string} workspaceId
+ * @param{object} project
+ */
+export class CheProjectItem implements ng.IDirective {
+ restrict = 'E';
+
+ // we require ngModel as we want to use it inside our directive
+ require = ['ngModel'];
+
+ // scope values
+ scope = {
+ workspace: '=cheProjectItemWorkspace',
+ project: '=cheProjectItemProject',
+ profileCreationDate: '=cheProfileCreationDate',
+ isDisplayWorkspace: '=cheDisplayWorkspace',
+ isSelectable: '=cheSelectable',
+ isSelect: '=?ngModel',
+ onCheckboxClick: '&?cheOnCheckboxClick',
+ hasAction: '=?cheHasAction'
+ };
+
+ templateUrl = 'app/workspaces/workspace-details/workspace-projects/project-item/project-item.html';
+
+ controller = 'ProjectItemCtrl';
+ controllerAs = 'projectItemCtrl';
+ bindToController = true;
+
+}
diff --git a/dashboard/src/app/projects/list-projects/project-item/project-item.html b/dashboard/src/app/workspaces/workspace-details/workspace-projects/project-item/project-item.html
similarity index 100%
rename from dashboard/src/app/projects/list-projects/project-item/project-item.html
rename to dashboard/src/app/workspaces/workspace-details/workspace-projects/project-item/project-item.html
diff --git a/dashboard/src/app/projects/list-projects/project-item/project-item.styl b/dashboard/src/app/workspaces/workspace-details/workspace-projects/project-item/project-item.styl
similarity index 100%
rename from dashboard/src/app/projects/list-projects/project-item/project-item.styl
rename to dashboard/src/app/workspaces/workspace-details/workspace-projects/project-item/project-item.styl
diff --git a/dashboard/src/app/workspaces/workspaces-config.ts b/dashboard/src/app/workspaces/workspaces-config.ts
index d967817459..b8ffb676c2 100644
--- a/dashboard/src/app/workspaces/workspaces-config.ts
+++ b/dashboard/src/app/workspaces/workspaces-config.ts
@@ -24,6 +24,11 @@ import {WorkspaceDetailsSshCtrl} from './workspace-details/workspace-ssh/workspa
import {WorkspaceDetailsProjectsCtrl} from './workspace-details/workspace-projects/workspace-details-projects.controller';
import {WorkspaceDetailsProjects} from './workspace-details/workspace-projects/workspace-details-projects.directive';
import {WorkspaceDetailsProjectsService} from './workspace-details/workspace-projects/workspace-details-projects.service';
+import {ProjectDetailsController} from './workspace-details/workspace-projects/project-details/project-details.controller';
+import {ProjectRepositoryController} from './workspace-details/workspace-projects/project-details/repository/project-repository.controller';
+import {ProjectRepository} from './workspace-details/workspace-projects/project-details/repository/project-repository.directive';
+import {CheProjectItem} from './workspace-details/workspace-projects/project-item/project-item.directive';
+import {ProjectItemCtrl} from './workspace-details/workspace-projects/project-item/project-item.controller';
import {AddProjectPopoverController} from './workspace-details/workspace-projects/add-project-popover/add-project-popover.controller';
import {AddProjectPopover} from './workspace-details/workspace-projects/add-project-popover/add-project-popover.directive';
import {WorkspaceDetailsService} from './workspace-details/workspace-details.service';
@@ -70,6 +75,7 @@ import {ImportZipProjectController} from './create-workspace/project-source-sele
import {ImportZipProjectService} from './create-workspace/project-source-selector/add-import-project/import-zip-project/import-zip-project.service';
import {ImportZipProject} from './create-workspace/project-source-selector/add-import-project/import-zip-project/import-zip-project.directive';
import {ImportGithubProjectController} from './create-workspace/project-source-selector/add-import-project/import-github-project/import-github-project.controller';
+import {NoGithubOauthDialogController} from './create-workspace/project-source-selector/add-import-project/import-github-project/oauth-dialog/no-github-oauth-dialog.controller';
import {ImportGithubProjectService} from './create-workspace/project-source-selector/add-import-project/import-github-project/import-github-project.service';
import {ImportGithubProject} from './create-workspace/project-source-selector/add-import-project/import-github-project/import-github-project.directive';
import {GithubRepositoryItem} from './create-workspace/project-source-selector/add-import-project/import-github-project/github-repository-item/github-repository-item.directive';
@@ -142,7 +148,6 @@ import {MachineAgents} from './workspace-details/workspace-machine-agents/machin
import {MachineAgentsController} from './workspace-details/workspace-machine-agents/machine-agents.controller';
import {CheWorkspace} from '../../components/api/workspace/che-workspace.factory';
-
/**
* @ngdoc controller
* @name workspaces:WorkspacesConfig
@@ -177,6 +182,11 @@ export class WorkspacesConfig {
register.controller('WorkspaceDetailsProjectsCtrl', WorkspaceDetailsProjectsCtrl);
register.directive('workspaceDetailsProjects', WorkspaceDetailsProjects);
+ register.controller('ProjectDetailsController', ProjectDetailsController);
+ register.controller('ProjectRepositoryController', ProjectRepositoryController);
+ register.directive('projectRepository', ProjectRepository);
+ register.directive('cheProjectItem', CheProjectItem);
+ register.controller('ProjectItemCtrl', ProjectItemCtrl);
register.service('workspaceDetailsProjectsService', WorkspaceDetailsProjectsService);
register.controller('AddProjectPopoverController', AddProjectPopoverController);
register.directive('addProjectPopover', AddProjectPopover);
@@ -242,6 +252,7 @@ export class WorkspacesConfig {
register.service('importGithubProjectService', ImportGithubProjectService);
register.directive('importGithubProject', ImportGithubProject);
register.directive('githubRepositoryItem', GithubRepositoryItem);
+ register.controller('NoGithubOauthDialogController', NoGithubOauthDialogController);
register.controller('ImportZipProjectController', ImportZipProjectController);
register.service('importZipProjectService', ImportZipProjectService);
register.directive('importZipProject', ImportZipProject);
@@ -333,6 +344,14 @@ export class WorkspacesConfig {
controller: 'ListWorkspacesCtrl',
controllerAs: 'listWorkspacesCtrl'
})
+ .accessWhen('/workspace/:namespace*/:workspaceName/:projectName', {
+ title: (params: any) => {
+ return params.workspaceName + ' | ' + params.projectName;
+ },
+ templateUrl: 'app/workspaces/workspace-details/workspace-projects/project-details/project-details.html',
+ controller: 'ProjectDetailsController',
+ controllerAs: 'projectDetailsController'
+ })
.accessWhen('/workspace/:namespace*/:workspaceName', {
title: (params: any) => {
return params.workspaceName;