diff --git a/dashboard/src/app/index.module.ts b/dashboard/src/app/index.module.ts index ef6fb9f1d5..f81db921ed 100755 --- a/dashboard/src/app/index.module.ts +++ b/dashboard/src/app/index.module.ts @@ -24,7 +24,6 @@ import {DashboardConfig} from './dashboard/dashboard-config'; // switch to a config import {IdeConfig} from './ide/ide-config'; import {NavbarConfig} from './navbar/navbar-config'; -import {ProjectsConfig} from './projects/projects-config'; import {ProxySettingsConfig} from './proxy/proxy-settings.constant'; import {WorkspacesConfig} from './workspaces/workspaces-config'; import {StacksConfig} from './stacks/stacks-config'; @@ -409,7 +408,6 @@ new IdeConfig(instanceRegister); new DiagnosticsConfig(instanceRegister); new NavbarConfig(instanceRegister); -new ProjectsConfig(instanceRegister); new WorkspacesConfig(instanceRegister); new DashboardConfig(instanceRegister); new StacksConfig(instanceRegister); diff --git a/dashboard/src/app/projects/create-project/add-ssh-key-notification/add-ssh-key-notification.controller.ts b/dashboard/src/app/projects/create-project/add-ssh-key-notification/add-ssh-key-notification.controller.ts deleted file mode 100644 index fd2e0fc709..0000000000 --- a/dashboard/src/app/projects/create-project/add-ssh-key-notification/add-ssh-key-notification.controller.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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'; -import {CheWorkspace} from '../../../../components/api/workspace/che-workspace.factory'; - -/** - * This class is handling the controller for the add secret key error notification - * @author Oleksii Orel - */ -export class AddSecretKeyNotificationController { - repoURL: string; - workspaceId: string; - workspace: che.IWorkspace; - - private $mdDialog: ng.material.IDialogService; - private $location: ng.ILocationService; - - /** - * Default constructor. - * @ngInject for Dependency injection - */ - constructor($mdDialog: ng.material.IDialogService, $location: ng.ILocationService, cheWorkspace: CheWorkspace) { - this.$mdDialog = $mdDialog; - this.$location = $location; - - this.workspace = cheWorkspace.getWorkspacesById().get(this.workspaceId); - } - - /** - * Redirect to IDE preferences. - */ - redirectToConfig(): void { - this.$location.path('ide/' + this.workspace.namespace + '/' + this.workspace.config.name).search({action: 'showPreferences'}); - this.$mdDialog.hide(); - } - - /** - * Callback of the cancel button of the dialog. - */ - hide(): void { - this.$mdDialog.hide(); - } -} diff --git a/dashboard/src/app/projects/create-project/add-ssh-key-notification/add-ssh-key-notification.html b/dashboard/src/app/projects/create-project/add-ssh-key-notification/add-ssh-key-notification.html deleted file mode 100644 index 6b89ed7e40..0000000000 --- a/dashboard/src/app/projects/create-project/add-ssh-key-notification/add-ssh-key-notification.html +++ /dev/null @@ -1,14 +0,0 @@ - -
-
- This repository requires an SSH key that is not configured: {{addSecretKeyNotificationController.repoURL}}. -
- - - - -
-
diff --git a/dashboard/src/app/projects/create-project/add-ssh-key-notification/add-ssh-key-notification.styl b/dashboard/src/app/projects/create-project/add-ssh-key-notification/add-ssh-key-notification.styl deleted file mode 100644 index 2d94225da3..0000000000 --- a/dashboard/src/app/projects/create-project/add-ssh-key-notification/add-ssh-key-notification.styl +++ /dev/null @@ -1,4 +0,0 @@ -.ssh-key-notification - width 100% - margin-top 10px - min-height 30px diff --git a/dashboard/src/app/projects/create-project/config-file/create-project-conf-file.directive.ts b/dashboard/src/app/projects/create-project/config-file/create-project-conf-file.directive.ts deleted file mode 100644 index 509334f101..0000000000 --- a/dashboard/src/app/projects/create-project/config-file/create-project-conf-file.directive.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 creating project from configuration file. - * @author Florent Benoit - */ -export class CreateProjectConfFile { - - /** - * Default constructor that is using resource - * @ngInject for Dependency injection - */ - constructor ($filter) { - this.$filter = $filter; - this.restrict='E'; - this.templateUrl = 'app/projects/create-project/config-file/create-project-conf-file.html'; - } - - - /** - * watch data and update json content each time the value is updated - * @param $scope - */ - link($scope) { - - // Watch data of the createProject controller and update content with these parameters - $scope.$watch('createProjectCtrl.importProjectData', (newValue) => { - $scope.createProjectCtrl.jsonConfig.content = this.$filter('json')(angular.fromJson(newValue), 2); - }, true); - - } - -} diff --git a/dashboard/src/app/projects/create-project/config-file/create-project-conf-file.html b/dashboard/src/app/projects/create-project/config-file/create-project-conf-file.html deleted file mode 100644 index 5f16b36ceb..0000000000 --- a/dashboard/src/app/projects/create-project/config-file/create-project-conf-file.html +++ /dev/null @@ -1,24 +0,0 @@ - -
-
- - -
-
diff --git a/dashboard/src/app/projects/create-project/create-project.controller.ts b/dashboard/src/app/projects/create-project/create-project.controller.ts deleted file mode 100755 index a4b0d893c6..0000000000 --- a/dashboard/src/app/projects/create-project/create-project.controller.ts +++ /dev/null @@ -1,1224 +0,0 @@ -/* - * 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'; -import {CheAPI} from '../../../components/api/che-api.factory'; -import {CheStack} from '../../../components/api/che-stack.factory'; -import {CreateProjectSvc} from './create-project.service'; -import {CheNotification} from '../../../components/notification/che-notification.factory'; -import {CheEnvironmentRegistry} from '../../../components/api/environment/che-environment-registry.factory'; -import {IEnvironmentManagerMachine} from '../../../components/api/environment/environment-manager-machine'; -import {CheJsonRpcApi} from '../../../components/api/json-rpc/che-json-rpc-api.factory'; -import {CheJsonRpcMasterApi} from '../../../components/api/json-rpc/che-json-rpc-master-api'; - -/** - * This class is handling the controller for the projects - * @author Florent Benoit - */ -export class CreateProjectController { - $document: ng.IDocumentService; - $location: ng.ILocationService; - $log: ng.ILogService; - $mdDialog: ng.material.IDialogService; - $q: ng.IQService; - $rootScope: che.IRootScopeService; - $scope: ng.IScope; - $timeout: ng.ITimeoutService; - $window: ng.IWindowService; - createProjectSvc: CreateProjectSvc; - lodash: any; - cheNotification: CheNotification; - cheAPI: CheAPI; - cheStack: CheStack; - cheEnvironmentRegistry: CheEnvironmentRegistry; - jsonRpcMasterApi: CheJsonRpcMasterApi; - - stackMachines: any; - importProjectData: che.IImportProject; - enableWizardProject: boolean; - currentStackTags: any; - stacksInitialized: boolean; - workspaces: any[]; - selectSourceOption: string; - templatesChoice: string; - workspaceRam: number; - selectedTabIndex: number; - currentTab: string; - state: string; - forms: Map; - jsonConfig: any; - isReady: boolean; - defaultProjectName: string; - projectName: string; - defaultProjectDescription: string; - projectDescription: string; - workspaceName: string; - stackLibraryOption: string; - existingWorkspaceName: string; - defaultWorkspaceName: string; - workspaceResource: any; - workspaceSelected: any; - workspaceConfig: any; - stack: any; - isCustomStack: boolean; - - workspaceResourceForm: ng.IFormController; - workspaceInformationForm: ng.IFormController; - projectInformationForm: ng.IFormController; - - private stackId: string; - private stacks: Array; - private recipeContentCopy: string; - - private agentOutputHandler: Function; - private statusHandler: Function; - private environmentOutputHandler: Function; - private projectImportHandler: Function; - - /** - * Default constructor that is using resource - * @ngInject for Dependency injection - */ - constructor($document: ng.IDocumentService, $filter: ng.IFilterService, $location: ng.ILocationService, - $log: ng.ILogService, $mdDialog: ng.material.IDialogService, $rootScope: che.IRootScopeService, - $routeParams: che.route.IRouteParamsService, $q: ng.IQService, $scope: ng.IScope, - $timeout: ng.ITimeoutService, $window: ng.IWindowService, cheJsonRpcApi: CheJsonRpcApi, - lodash: any, cheAPI: CheAPI, cheStack: CheStack, createProjectSvc: CreateProjectSvc, - cheNotification: CheNotification, cheEnvironmentRegistry: CheEnvironmentRegistry) { - this.$log = $log; - this.cheAPI = cheAPI; - this.cheStack = cheStack; - this.$timeout = $timeout; - this.$location = $location; - this.$mdDialog = $mdDialog; - this.$scope = $scope; - this.$rootScope = $rootScope; - this.createProjectSvc = createProjectSvc; - this.lodash = lodash; - this.cheNotification = cheNotification; - this.$q = $q; - this.$document = $document; - this.$window = $window; - this.cheEnvironmentRegistry = cheEnvironmentRegistry; - this.stackMachines = {}; - - this.resetCreateProgress(); - - this.importProjectData = this.getDefaultProjectJson(); - this.jsonRpcMasterApi = cheJsonRpcApi.getJsonRpcMasterApi(cheAPI.getWorkspace().getJsonRpcApiLocation()); - - this.enableWizardProject = true; - - this.currentStackTags = null; - - // stacks not yet completed - this.stacksInitialized = false; - - // keep references on workspaces and projects - this.workspaces = []; - - // default options - this.selectSourceOption = 'select-source-new'; - - this.templatesChoice = 'templates-samples'; - - // default RAM value for workspaces - this.workspaceRam = 2 * Math.pow(1024, 3); - - this.generateWorkspaceName(); - - - // search the selected tab - let routeParams = $routeParams.tabName; - if (!routeParams) { - this.selectedTabIndex = 0; - } else { - switch (routeParams) { - case 'blank': - this.selectedTabIndex = 0; - break; - case 'samples': - this.selectedTabIndex = 1; - break; - case 'git': - this.selectedTabIndex = 2; - break; - case 'github': - this.selectedTabIndex = 3; - break; - case 'zip': - this.selectedTabIndex = 4; - break; - case 'config': - this.selectedTabIndex = 2; - break; - default: - $location.path('/create-project'); - } - } - - if (cheStack.getStacks().length) { - this.updateWorkspaces(); - } else { - cheStack.fetchStacks().then(() => { - this.updateWorkspaces(); - }, (error: any) => { - if (error.status === 304) { - this.updateWorkspaces(); - return; - } - this.state = 'error'; - }); - } - - // selected current tab - this.currentTab = ''; - // all forms that we have - this.forms = new Map(); - - this.jsonConfig = {}; - this.jsonConfig.content = '{}'; - try { - this.jsonConfig.content = $filter('json')(this.importProjectData); - } catch (e) { - // ignore the error - } - - let deregFunc1 = $rootScope.$on('create-project-stacks:initialized', () => { - this.stacksInitialized = true; - }); - - // sets isReady status after selection - let deregFunc2 = $rootScope.$on('create-project-github:selected', () => { - if (!this.isReady && this.currentTab === 'github') { - this.isReady = true; - } - }); - let deregFunc3 = $rootScope.$on('create-project-samples:selected', () => { - if (!this.isReady && this.currentTab === 'samples') { - this.isReady = true; - } - }); - $rootScope.$on('$destroy', () => { - deregFunc1(); - deregFunc2(); - deregFunc3(); - }); - - this.projectName = null; - this.projectDescription = null; - this.defaultWorkspaceName = null; - - cheAPI.getWorkspace().getWorkspaces(); - - this.stacks = cheStack.getStacks(); - if (!this.stacks || !this.stacks.length) { - cheStack.fetchStacks(); - } - } - - /** - * Gets object keys from target object. - * - * @param targetObject - * @returns [*] - */ - getObjectKeys(targetObject: any): string[] { - return Object.keys(targetObject); - } - - /** - * Fetch workspaces when initializing - */ - updateWorkspaces(): void { - this.workspaces = this.cheAPI.getWorkspace().getWorkspaces(); - // fetch workspaces when initializing - let promise = this.cheAPI.getWorkspace().fetchWorkspaces(); - promise.then(() => { - this.updateData(); - }, - (error: any) => { - // retrieve last data that were fetched before - if (error.status === 304) { - // ok - this.updateData(); - return; - } - this.state = 'error'; - }); - } - - /** - * Gets default project JSON used for import data - */ - getDefaultProjectJson(): che.IImportProject { - return { - source: { - location: '', - parameters: {} - }, - project: { - name: '', - description: '' - } - }; - } - - /** - * Fetching operation has been done, so get workspaces and websocket connection - */ - updateData(): void { - this.workspaceResource = this.workspaces.length > 0 ? 'existing-workspace' : 'from-stack'; - // if create project in progress and workspace have started - if (this.createProjectSvc.isCreateProjectInProgress() && this.createProjectSvc.getCurrentProgressStep() > 0) { - let workspaceName = this.createProjectSvc.getWorkspaceOfProject(); - let findWorkspace = this.lodash.find(this.workspaces, (workspace: any) => { - return workspace.config.name === workspaceName; - }); - // check current workspace - if (!findWorkspace) { - this.resetCreateProgress(); - }; - } else { - let preselectWorkspaceId = this.$location.search().workspaceId; - if (preselectWorkspaceId) { - this.workspaceSelected = this.lodash.find(this.workspaces, (workspace: any) => { - return workspace.id === preselectWorkspaceId; - }); - } - } - } - - /** - * Force codemirror editor to be refreshed - */ - refreshCM(): void { - // hack to make a refresh of the zone - this.importProjectData.cm = 'aaa'; - this.$timeout(() => { - delete this.importProjectData.cm; - }, 500); - } - - /** - * Update internal json data from JSON codemirror editor config file - */ - update(): void { - try { - this.importProjectData = angular.fromJson(this.jsonConfig.content); - } catch (e) { - // invalid JSON, ignore - } - - } - - /** - * Select the given github repository - * @param gitHubRepository the repository selected - */ - selectGitHubRepository(gitHubRepository: any): void { - this.setProjectName(gitHubRepository.name); - this.setProjectDescription(gitHubRepository.description); - this.importProjectData.source.location = gitHubRepository.clone_url; - } - - /** - * Checks if the current forms are being validated - * @returns {boolean|FormController.$valid|*|ngModel.NgModelController.$valid|context.ctrl.$valid|Ic.$valid} - */ - checkValidFormState(): boolean { - // check workspace resource form - if (this.workspaceResourceForm && this.workspaceResourceForm.$invalid) { - return false; - } - - // check workspace information form - if (this.workspaceInformationForm && this.workspaceInformationForm.$invalid) { - return false; - } - - // check project information form and selected tab form - if (this.selectSourceOption === 'select-source-new') { - return this.projectInformationForm && this.projectInformationForm.$valid; - } else if (this.selectSourceOption === 'select-source-existing') { - let currentForm = this.forms.get(this.currentTab); - if (currentForm) { - return this.projectInformationForm && this.projectInformationForm.$valid && currentForm.$valid; - } - } - } - - /** - * Defines the project information form - * @param form - */ - setProjectInformationForm(form: ng.IFormController): void { - this.projectInformationForm = form; - } - - setWorkspaceResourceForm(form: ng.IFormController): void { - this.workspaceResourceForm = form; - } - - setWorkspaceInformationForm(form: ng.IFormController): void { - this.workspaceInformationForm = form; - } - - /** - * Sets the form for a given mode - * @param form the selected form - * @param mode the tab selected - */ - setForm(form: ng.IFormController, mode: string): void { - this.forms.set(mode, form); - } - - /** - * Sets the current selected tab - * @param tab the selected tab - */ - setCurrentTab(tab: string): void { - this.currentTab = tab; - this.importProjectData = this.getDefaultProjectJson(); - - if ('blank' === tab) { - this.importProjectData.project.type = 'blank'; - } else if ('git' === tab || 'github' === tab) { - this.importProjectData.source.type = 'git'; - } else if ('zip' === tab) { - this.importProjectData.project.type = ''; - this.importProjectData.source.type = 'zip'; - } else if ('config' === tab) { - this.importProjectData.project.type = 'blank'; - this.importProjectData.source.type = 'git'; - // try to set default values - this.setProjectDescription(this.importProjectData.project.description); - this.setProjectName(this.importProjectData.project.name); - this.refreshCM(); - } - // github and samples tabs have broadcast selection events for isReady status - this.isReady = !('github' === tab || 'samples' === tab); - } - - /** - * Returns current selected tab - * @returns {string|*} - */ - getCurrentTab(): string { - return this.currentTab; - } - - startWorkspace(workspace: che.IWorkspace): ng.IPromise { - // then we've to start workspace - this.createProjectSvc.setCurrentProgressStep(1); - let workspaceId = workspace.id; - - this.agentOutputHandler = (message: any) => { - if (this.createProjectSvc.getCurrentProgressStep() < 2) { - this.createProjectSvc.setCurrentProgressStep(2); - } - let agentStep = 2; - if (this.getCreationSteps()[agentStep].logs.length > 0) { - this.getCreationSteps()[agentStep].logs = this.getCreationSteps()[agentStep].logs + '\n' + message; - } else { - this.getCreationSteps()[agentStep].logs = message; - } - }; - - this.jsonRpcMasterApi.subscribeWsAgentOutput(workspaceId, this.agentOutputHandler); - - this.statusHandler = (message: any) => { - message = this.getDisplayMachineLog(message); - if (message.eventType === 'DESTROYED' && message.workspaceId === workspace.id) { - this.getCreationSteps()[this.getCurrentProgressStep()].hasError = true; - - // need to show the error - this.$mdDialog.show( - this.$mdDialog.alert() - .title('Unable to start workspace') - .content('Unable to start workspace. It may be linked to OutOfMemory or the container has been destroyed') - .ariaLabel('Workspace start') - .ok('OK') - ); - } - if (message.eventType === 'ERROR' && message.workspaceId === workspace.id) { - this.getCreationSteps()[this.getCurrentProgressStep()].hasError = true; - let errorMessage = 'Error when trying to start the workspace'; - if (message.error) { - errorMessage += ': ' + message.error; - } else { - errorMessage += '.'; - } - // need to show the error - this.$mdDialog.show( - this.$mdDialog.alert() - .title('Error when starting workspace') - .content('Unable to start workspace. ' + errorMessage) - .ariaLabel('Workspace start') - .ok('OK') - ); - } - this.$log.log('Status channel of workspaceID', workspaceId, message); - }; - this.jsonRpcMasterApi.subscribeEnvironmentStatus(workspaceId, this.statusHandler); - - this.environmentOutputHandler = (message: any) => { - message = this.getDisplayMachineLog(message); - if (this.getCreationSteps()[this.getCurrentProgressStep()].logs.length > 0) { - this.getCreationSteps()[this.getCurrentProgressStep()].logs = this.getCreationSteps()[this.getCurrentProgressStep()].logs + '\n' + message; - } else { - this.getCreationSteps()[this.getCurrentProgressStep()].logs = message; - } - }; - - this.jsonRpcMasterApi.subscribeEnvironmentOutput(workspaceId, this.environmentOutputHandler); - - let startWorkspacePromise = this.cheAPI.getWorkspace().startWorkspace(workspace.id, workspace.config.defaultEnv); - startWorkspacePromise.then(() => { - // update list of workspaces - // for new workspace to show in recent workspaces - this.cheAPI.getWorkspace().fetchWorkspaces(); - }, (error: any) => { - let errorMessage; - - if (!error || !error.data) { - errorMessage = 'Unable to start this workspace.'; - } else if (error.data.errorCode === 10000 && error.data.attributes) { - let attributes = error.data.attributes; - - errorMessage = 'Unable to start this workspace.' + - ' There are ' + attributes.workspaces_count + ' running workspaces consuming ' + - attributes.used_ram + attributes.ram_unit + ' RAM.' + - ' Your current RAM limit is ' + attributes.limit_ram + attributes.ram_unit + - '. This workspace requires an additional ' + - attributes.required_ram + attributes.ram_unit + '.' + - ' You can stop other workspaces to free resources.'; - } else { - errorMessage = error.data.message; - } - - this.cheNotification.showError(errorMessage); - this.getCreationSteps()[this.getCurrentProgressStep()].logs = errorMessage; - this.getCreationSteps()[this.getCurrentProgressStep()].hasError = true; - }); - return startWorkspacePromise; - } - - /** - * Gets the log to be displayed per machine. - * - * @param log origin log content - * @returns {*} parsed log - */ - getDisplayMachineLog(log: any): string { - log = angular.fromJson(log); - if (angular.isObject(log)) { - return '[' + log.machineName + '] ' + log.content; - } else { - return log; - } - } - - createProjectInWorkspace(workspaceId: string, projectName: string, projectData: any): void { - this.updateRecentWorkspace(workspaceId); - - this.createProjectSvc.setCurrentProgressStep(3); - - let promise; - // select mode (create or import) - if (this.selectSourceOption === 'select-source-new' && this.templatesChoice === 'templates-wizard') { - - // we do not create project as it will be done through wizard - let deferred = this.$q.defer(); - promise = deferred.promise; - deferred.resolve(true); - - } else { - - // if it's a user-defined location we need to cleanup commands that may have been configured by templates - if (this.selectSourceOption === 'select-source-existing') { - projectData.project.commands = []; - } - - this.projectImportHandler = (message: any) => { - this.getCreationSteps()[this.getCurrentProgressStep()].logs = message.line; - }; - this.cheAPI.getWorkspace().getWorkspaceAgent(workspaceId).getWsAgentApi().subscribeProjectImport(projectName, this.projectImportHandler); - - let deferredImport = this.$q.defer(); - let deferredImportPromise = deferredImport.promise; - let deferredAddCommand = this.$q.defer(); - let deferredAddCommandPromise = deferredAddCommand.promise; - let deferredResolve = this.$q.defer(); - let deferredResolvePromise = deferredResolve.promise; - - let projects = this.processMultiproject(projectData); - let importPromise = this.cheAPI.getWorkspace().getWorkspaceAgent(workspaceId).getProject().createProjects(projects); - - importPromise.then(() => { - // add commands if there are some that have been defined - let commands = projectData.project.commands; - if (commands && commands.length > 0) { - this.addCommand(workspaceId, projectName, commands, 0, deferredAddCommand); - } else { - deferredAddCommand.resolve('no commands to add'); - } - deferredImport.resolve(); - }, (error: any) => { - deferredImport.reject(error); - }); - - // now, resolve the project - deferredAddCommandPromise.then(() => { - this.resolveProjectType(workspaceId, projectName, projectData, deferredResolve); - }); - promise = this.$q.all([deferredImportPromise, deferredAddCommandPromise, deferredResolvePromise]); - } - promise.then(() => { - this.cheAPI.getWorkspace().fetchWorkspaces(); - - this.cleanupChannels(workspaceId, projectName); - this.createProjectSvc.setCurrentProgressStep(4); - - // redirect to IDE from crane loader page - let currentPath = this.$location.path(); - if (/create-project/.test(currentPath)) { - this.createProjectSvc.redirectToIDE(); - } - }, (error: any) => { - this.cleanupChannels(workspaceId, projectName); - this.getCreationSteps()[this.getCurrentProgressStep()].hasError = true; - // if we have a SSH error - if (error.data && error.data.errorCode === 32068) { - this.showAddSecretKeyDialog(projectData.source.location, workspaceId); - return; - } - this.$mdDialog.show({ - bindToController: true, - clickOutsideToClose: true, - controller: 'ProjectErrorNotificationController', - controllerAs: 'projectErrorNotificationController', - locals: { title: 'Error while creating the project', content: error.statusText + ': ' + error.data.message}, - templateUrl: 'app/projects/create-project/project-error-notification/project-error-notification.html' - }); - }); - - } - - /** - * Process multi-project and prepare batch of projects to be created. - * - * @param projectData project data to process - * @returns {Array|any} array of projects - */ - processMultiproject(projectData: che.IImportProject): che.IProjectTemplate[] { - let currentPath = '/' + projectData.project.name; - - let projects = projectData.projects || []; - let project = angular.copy(projectData.project); - project.path = currentPath; - project.source = projectData.source; - - // update path of sub-projects: - projects.forEach((project : any) => { - let index = project.path.indexOf('/' + project.name); - project.path = currentPath + project.path.substr(index); - }); - - projects.push(project); - return projects; - } - - resolveProjectType(workspaceId: string, projectName: string, projectData: che.IImportProject, deferred: ng.IDeferred): void { - let workspaceAgent = this.cheAPI.getWorkspace().getWorkspaceAgent(workspaceId); - let copyProjectData = angular.copy(projectData); - if (copyProjectData && copyProjectData.project) { - copyProjectData.project.name = projectName; - } - workspaceAgent.getProjectTypeResolver().resolveImportProjectType(copyProjectData).then(() => { - deferred.resolve(); - }, (error: any) => { - // a second attempt with type blank - copyProjectData.project.attributes = {}; - copyProjectData.project.type = 'blank'; - workspaceAgent.getProjectTypeResolver().resolveImportProjectType(copyProjectData).then(() => { - deferred.resolve(); - }, (error: any) => { - deferred.reject(error); - }); - deferred.reject(error); - }); - } - - /** - * Show the add ssh key dialog - * @param repoURL the repository URL - * @param workspaceId the workspace IDL - */ - showAddSecretKeyDialog(repoURL: string, workspaceId: string): void { - this.$mdDialog.show({ - bindToController: true, - clickOutsideToClose: true, - controller: 'AddSecretKeyNotificationController', - controllerAs: 'addSecretKeyNotificationController', - locals: {repoURL: repoURL, workspaceId: workspaceId}, - templateUrl: 'app/projects/create-project/add-ssh-key-notification/add-ssh-key-notification.html' - }); - } - - /** - * Cleanup the websocket elements after actions are finished - */ - cleanupChannels(workspaceId: string, projectName: string): void { - let workspace = this.cheAPI.getWorkspace().getWorkspaceById(workspaceId); - this.jsonRpcMasterApi.unSubscribeEnvironmentStatus(workspaceId, this.statusHandler); - this.jsonRpcMasterApi.unSubscribeWsAgentOutput(workspaceId, this.agentOutputHandler); - this.jsonRpcMasterApi.unSubscribeEnvironmentOutput(workspaceId, this.environmentOutputHandler); - this.cheAPI.getWorkspace().getWorkspaceAgent(workspaceId).getWsAgentApi().unSubscribeProjectImport(projectName, this.projectImportHandler); - } - - - /** - * Add commands sequentially by iterating on the number of the commands. - * Wait the ack of remote addCommand before adding a new command to avoid concurrent access - * @param workspaceId the ID of the workspace to use for adding commands - * @param projectName the name that will be used to prefix the commands inserted - * @param commands the array to follow - * @param index the index of the array of commands to register - * @param deferred - */ - addCommand(workspaceId: string, projectName: string, commands: any[], index: number, deferred: ng.IDeferred): void { - if (index < commands.length) { - let newCommand = angular.copy(commands[index]); - - // update project command lines using current.project.path with actual path based on workspace runtime configuration - // so adding the same project twice allow to use commands for each project without first selecting project in tree - let workspace = this.cheAPI.getWorkspace().getWorkspaceById(workspaceId); - if (workspace && workspace.runtime) { - let runtime = workspace.runtime.devMachine.runtime; - if (runtime) { - let envVar = runtime.envVariables; - if (envVar) { - let cheProjectsRoot = envVar.CHE_PROJECTS_ROOT; - if (cheProjectsRoot) { - // replace current project path by the full path of the project - let projectPath = cheProjectsRoot + '/' + projectName; - newCommand.commandLine = newCommand.commandLine.replace(/\$\{current.project.path\}/g, projectPath); - } - } - } - } - newCommand.name = projectName + ': ' + newCommand.name; - let addPromise = this.cheAPI.getWorkspace().addCommand(workspaceId, newCommand); - addPromise.then(() => { - // call the method again - this.addCommand(workspaceId, projectName, commands, ++index, deferred); - }, (error: any) => { - deferred.reject(error); - }); - } else { - deferred.resolve('All commands added'); - } - } - - /** - * Call the create operation that may create or import a project - */ - create(): void { - this.importProjectData.project.description = this.projectDescription; - this.importProjectData.project.name = this.projectName; - this.createProjectSvc.setProject(this.projectName); - - if (this.templatesChoice === 'templates-wizard') { - this.createProjectSvc.setIDEAction('createProject:projectName=' + this.projectName); - } - - // reset logs and errors - this.resetCreateProgress(); - this.setCreateProjectInProgress(); - - if (this.workspaceResource === 'existing-workspace') { - // reuse existing workspace - this.createProjectSvc.setWorkspaceOfProject(this.workspaceSelected.config.name); - this.createProjectSvc.setWorkspaceNamespace(this.workspaceSelected.namespace); - this.checkExistingWorkspaceState(this.workspaceSelected); - } else if (this.workspaceResource === 'from-stack') { - // create workspace based on a workspaceConfig - this.createProjectSvc.setWorkspaceOfProject(this.workspaceName); - let attributes = this.stack && this.stack.id ? {stackId: this.stack.id} : {}; - this.setEnvironment(this.workspaceConfig); - let workspaceConfig = this.cheAPI.getWorkspace().formWorkspaceConfig(this.workspaceConfig, this.workspaceName, null, this.workspaceRam); - this.createWorkspace(workspaceConfig, attributes); - - } else { - // create workspace based on config - this.createWorkspace(this.workspaceConfig); - } - } - - /** - * Check whether existing workspace in running (runtime should be present) - * - * @param workspace {che.IWorkspace} existing workspace - */ - checkExistingWorkspaceState(workspace: che.IWorkspace): void { - if (workspace.status === 'RUNNING') { - this.cheAPI.getWorkspace().fetchWorkspaceDetails(workspace.id).finally(() => { - this.createProjectInWorkspace(workspace.id, this.projectName, this.importProjectData); - }); - } else { - this.subscribeStatusChannel(workspace); - this.startWorkspace(workspace); - } - } - - /** - * Subscribe on workspace status channel - * - * @param workspace workspace for listening status - */ - subscribeStatusChannel(workspace: any): void { - this.cheAPI.getWorkspace().fetchStatusChange(workspace.id, 'ERROR').then((message: any) => { - this.createProjectSvc.setCurrentProgressStep(2); - this.getCreationSteps()[this.getCurrentProgressStep()].hasError = true; - // need to show the error - this.$mdDialog.show( - this.$mdDialog.alert() - .title('Error when starting agent') - .content('Unable to start workspace agent. Error when trying to start the workspace agent: ' + message.error) - .ariaLabel('Workspace agent start') - .ok('OK') - ); - }); - this.cheAPI.getWorkspace().fetchStatusChange(workspace.id, 'RUNNING').then(() => { - this.createProjectSvc.setCurrentProgressStep(2); - - this.importProjectData.project.name = this.projectName; - - let promiseWorkspace = this.cheAPI.getWorkspace().fetchWorkspaceDetails(workspace.id); - promiseWorkspace.then(() => { - this.createProjectInWorkspace(workspace.id, this.importProjectData.project.name, this.importProjectData); - }); - }); - } - - /** - * Create new workspace with workspace config - * - * @param workspaceConfig {che.IWorkspaceConfig} - * @param attributes {any} - */ - createWorkspace(workspaceConfig: che.IWorkspaceConfig, attributes?: any): void { - // todo: no account in che ? it's null when testing on localhost - let creationPromise = this.cheAPI.getWorkspace().createWorkspaceFromConfig(null, workspaceConfig, attributes); - creationPromise.then((workspace: any) => { - this.createProjectSvc.setWorkspaceNamespace(workspace.namespace); - this.updateRecentWorkspace(workspace.id); - - this.cheAPI.getWorkspace().fetchWorkspaceDetails(workspace.id).then(() => { - this.subscribeStatusChannel(workspace); - }); - - this.$timeout(() => { - this.startWorkspace(workspace); - }, 1000); - - }, (error: any) => { - if (error.data.message) { - this.getCreationSteps()[this.getCurrentProgressStep()].logs = error.data.message; - } - this.getCreationSteps()[this.getCurrentProgressStep()].hasError = true; - - }); - } - - /** - * Generates a default workspace name - */ - generateWorkspaceName(): void { - // starts with wksp - let name = 'wksp-' + this.generateRandomStr(); - this.setWorkspaceName(name); - } - - /** - * Generates a random string - * - * @returns {string} - */ - generateRandomStr(): string { - /* tslint:disable */ - return (('0000' + (Math.random() * Math.pow(36, 4) << 0).toString(36)).slice(-4)); - /* tslint:enable */ - } - - isImporting(): boolean { - return this.isCreateProjectInProgress(); - } - - isReadyToCreate(): boolean { - let isCreateProjectInProgress = this.isCreateProjectInProgress(); - return !isCreateProjectInProgress && this.isReady; - } - - resetCreateProgress(): void { - if (this.isResourceProblem()) { - this.$location.path('/workspaces'); - } - this.createProjectSvc.resetCreateProgress(); - } - - showIDE(): void { - this.$rootScope.showIDE = !this.$rootScope.showIDE; - } - - getStepText(stepNumber: number): string { - return this.createProjectSvc.getStepText(stepNumber); - } - - getCreationSteps(): any[] { - return this.createProjectSvc.getProjectCreationSteps(); - } - - getCurrentProgressStep(): number { - return this.createProjectSvc.getCurrentProgressStep(); - } - - isCreateProjectInProgress(): boolean { - return this.createProjectSvc.isCreateProjectInProgress(); - } - - setCreateProjectInProgress(): void { - this.createProjectSvc.setCreateProjectInProgress(true); - } - - getWorkspaceOfProject(): string { - return this.createProjectSvc.getWorkspaceOfProject(); - } - - getIDELink(): string { - return this.createProjectSvc.getIDELink(); - } - - isResourceProblem(): boolean { - let currentCreationStep = this.getCreationSteps()[this.getCurrentProgressStep()]; - return currentCreationStep.hasError && currentCreationStep.logs.indexOf('You can stop other workspaces') >= 0; - } - - /** - * Update data for selected workspace - */ - onWorkspaceChange(): void { - if (!this.workspaceSelected) { - return; - } - this.setWorkspaceName(this.workspaceSelected.config.name); - this.updateCurrentStack(this.workspaceSelected.attributes.stackId); - this.updateWorkspaceStatus(true); - } - - /** - * Update creation flow state when source option changes - */ - onSourceOptionChanged(): void { - if ('select-source-existing' !== this.selectSourceOption) { - this.isReady = true; - return; - } - this.setCurrentTab(this.currentTab); - } - - /** - * Update creation flow state when workspace resource changes - */ - workspaceResourceOnChange(): void { - this.workspaceConfig = undefined; - if (this.workspaceResource === 'existing-workspace') { - this.updateWorkspaceStatus(true); - } else { - if (this.workspaceResource === 'from-config') { - this.stack = null; - this.currentStackTags = null; - } - this.updateWorkspaceStatus(false); - } - } - - - /** - * Use of an existing stack - * @param config {che.IWorkspaceConfig} - * @param stackId {string} - */ - changeWorkspaceStack(config: che.IWorkspaceConfig, stackId: string) { - if (this.workspaceResource === 'existing-workspace') { - return; - } - this.workspaceConfig = config; - if (stackId !== this.stackId) { - this.updateCurrentStack(stackId); - } - } - - /** - * Callback when workspace config in editor is changed - * - * @param config {Object} workspace config - */ - updateWorkspaceConfigImport(config: any): void { - this.workspaceConfig = angular.copy(config); - this.stackId = 'config-import-' + this.generateRandomStr(); - this.stack = { - workspaceConfig: this.workspaceConfig - }; - this.workspaceName = this.workspaceConfig.name; - - delete this.stackMachines[this.stackId]; - } - - /** - * Changes workspace name in workspace config provided by user - * - * @param form {Object} - */ - workspaceNameChange(form: ng.IFormController): void { - if (form.$invalid || !this.workspaceConfig) { - return; - } - - this.workspaceConfig.name = this.workspaceName; - } - - /** - * Changes workspace RAM in workspace config provided by user - * - * @param machineName {string} - * @param machineRam {number} - */ - workspaceRamChange(machineName: string, machineRam: number): void { - if (!this.workspaceConfig) { - return; - } - - try { - let config = this.workspaceConfig, - machines = config.environments[config.defaultEnv].machines; - if (machines[machineName]) { - machines[machineName].attributes.memoryLimitBytes = machineRam; - } else { - machines[machineName] = { - attributes: { - memoryLimitBytes: machineRam - } - }; - } - } catch (e) { - this.$log.error('Cannot set memory limit for "' + machineName + '"', e); - } - - } - - updateWorkspaceStatus(isExistingWorkspace: boolean): void { - if (isExistingWorkspace) { - this.stackLibraryOption = 'existing-workspace'; - this.existingWorkspaceName = this.workspaceSelected.config.name; - } else { - this.stackLibraryOption = 'new-workspace'; - this.generateWorkspaceName(); - this.existingWorkspaceName = ''; - } - this.$rootScope.$broadcast('chePanel:disabled', {id: 'create-project-workspace', disabled: isExistingWorkspace}); - } - - /** - * Update current stack - * @param {string} stackId - */ - updateCurrentStack(stackId: string): void { - let stack: che.IStack = null; - if (stackId) { - stack = this.stacks.find((stack: che.IStack) => { - return stack.id === stackId; - }); - } - this.isCustomStack = !stack; - this.stackId = stack && stack.id ? stack.id : 'custom-stack'; - delete this.stackMachines[this.stackId]; - this.stack = stack; - this.currentStackTags = stack && stack.tags ? angular.copy(stack.tags) : null; - if (!stack) { - return; - } - - this.templatesChoice = 'templates-samples'; - - // enable wizard only if - // - ready-to-go-stack with PT - // - custom stack - if (stack === null || 'general' !== stack.scope) { - this.enableWizardProject = true; - return; - } - this.enableWizardProject = 'Java' === stack.name; - } - - selectWizardProject(): void { - this.importProjectData.source.location = ''; - } - - /** - * Set workspace name - * @param name - */ - setWorkspaceName(name: string): void { - if (!name) { - return; - } - if (!this.defaultWorkspaceName || this.defaultWorkspaceName === this.workspaceName) { - this.defaultWorkspaceName = name; - this.workspaceName = angular.copy(name); - } - } - - /** - * Set project name - * @param name - */ - setProjectName(name: string): void { - if (!name) { - return; - } - if (!this.projectName || !this.defaultProjectName || this.defaultProjectName === this.projectName) { - this.defaultProjectName = name; - this.projectName = angular.copy(name); - } - this.importProjectData.project.name = this.projectName; - } - - /** - * Set project description - * @param description - */ - setProjectDescription(description: string): void { - if (!description) { - return; - } - if (!this.projectDescription || !this.defaultProjectDescription || this.defaultProjectDescription === this.projectDescription) { - this.defaultProjectDescription = description; - this.projectDescription = angular.copy(description); - } - this.importProjectData.project.description = this.projectDescription; - } - - downloadLogs(): void { - let logs = ''; - this.getCreationSteps().forEach((step: any) => { - logs += step.logs + '\n'; - }); - this.$window.open('data:text/csv,' + encodeURIComponent(logs)); - } - - /** - * Returns list of projects of current workspace - * @returns {*|Array} - */ - getWorkspaceProjects(): any[] { - if (this.workspaceSelected && this.workspaceResource === 'existing-workspace') { - return this.cheAPI.getWorkspace().getWorkspaceProjects()[this.workspaceSelected.id]; - } - return []; - } - - /** - * Emit event to move workspace immediately - * to top of the recent workspaces list - * - * @param workspaceId - */ - updateRecentWorkspace(workspaceId: string): any { - this.$rootScope.$broadcast('recent-workspace:set', workspaceId); - } - - getStackMachines(environment: any): any { - let recipeType = environment.recipe.type; - let environmentManager = this.cheEnvironmentRegistry.getEnvironmentManager(recipeType); - if (this.recipeContentCopy && angular.equals(this.recipeContentCopy, environment.recipe.content)) { - return this.stackMachines[this.stackId]; - } - if (!this.stackMachines[this.stackId] || !this.stackMachines[this.stackId].length) { - let machines = environmentManager.getMachines(environment); - machines.forEach((machine: IEnvironmentManagerMachine) => { - let memoryLimit = environmentManager.getMemoryLimit(machine); - if (!memoryLimit || memoryLimit === -1) { - environmentManager.setMemoryLimit(machine, this.workspaceRam); - } - }); - this.recipeContentCopy = angular.copy(environment.recipe.content); - this.stackMachines[this.stackId] = machines; - } - - return this.stackMachines[this.stackId]; - } - - /** - * Updates the workspace's environment with data entered by user. - * - * @param workspace workspace to update - */ - setEnvironment(workspace: any): void { - if (!workspace.defaultEnv || !workspace.environments || workspace.environments.length === 0) { - return; - } - - let environment = workspace.environments[workspace.defaultEnv]; - - if (!environment) { - return; - } - - let recipeType = environment.recipe.type; - let environmentManager = this.cheEnvironmentRegistry.getEnvironmentManager(recipeType); - let machines = this.getStackMachines(environment); - let hasDevMachine = machines.some((machine: IEnvironmentManagerMachine) => { - return environmentManager.isDev(machine); - }); - if (!hasDevMachine) { - environmentManager.setDev(machines[0], true); - } - workspace.environments[workspace.defaultEnv] = environmentManager.getEnvironment(environment, machines); - } - - /** - * Callback which is called when sample project is selected. - * - * @param {che.IProjectTemplate} template template to import - */ - projectSampleOnSelect(template: che.IProjectTemplate): void { - // update source details - this.importProjectData.source.type = template.source.type; - this.importProjectData.source.location = template.source.location; - this.importProjectData.source.parameters = template.source.parameters; - // update name, type, description - this.setProjectDescription(template.description); - this.importProjectData.project.type = template.projectType; - this.importProjectData.project.commands = template.commands; - this.importProjectData.project.attributes = template.attributes; - this.importProjectData.project.options = template.options; - this.importProjectData.projects = angular.copy(template.projects); - - let name: string = template.displayName; - // strip space - name = name.replace(/\s/g, '_'); - // strip dot - name = name.replace(/\./g, '_'); - this.setProjectName(name); - } - -} diff --git a/dashboard/src/app/projects/create-project/create-project.html b/dashboard/src/app/projects/create-project/create-project.html deleted file mode 100644 index b85d92b9e3..0000000000 --- a/dashboard/src/app/projects/create-project/create-project.html +++ /dev/null @@ -1,275 +0,0 @@ - - - - - - - - -
-
- - -
-
- - -
-
- -
-
- -
-
-
-
-
-
-
-
-
- -
- - - - - New from blank, template, or sample project - Import from existing location - - -
- - - - Git Repository - - - - - - - - GitHub - - -
- -
- -
-
- - - Zip - - - - - -
-
-
- - - - - - - - Select existing workspace -
- -
- - - Create from configuration -
- -
- - - Create new workspace from stack -
- -
-
-
-
- - - - -
- -
- -
A name is required.
-
Workspace name may contain digits, latin letters, _ , . , - and should start - only with digits, latin - letters or underscores -
-
The name has to be more than 3 characters long.
-
The name has to be less than 100 characters long.
-
This workspace name is already used.
-
-
-
- -
- ENVIRONMENT: {{environmentKey}} - -
-
-
- MACHINE: {{machine.name}} - -
-
-
-
-
-
-
-
- - - - - Ready-to-run project samples - - Wizard-driven templates - - - - - - - -
- -
- -
A name is required.
-
This project name is already used.
-
The name should not contain special characters like space, dollar, etc.
-
The name has to be less than 128 characters long.
-
The name has to be less than 128 characters long.
-
-
-
- -
- -
The name has to be less than 256 characters long.
-
The name has to be less than 256 characters long.
-
-
-
-
-
-
- - - -
- -
- -
diff --git a/dashboard/src/app/projects/create-project/create-project.service.ts b/dashboard/src/app/projects/create-project/create-project.service.ts deleted file mode 100644 index 85fd9a0631..0000000000 --- a/dashboard/src/app/projects/create-project/create-project.service.ts +++ /dev/null @@ -1,144 +0,0 @@ -/* - * 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'; - -/** - * This class is handling the service for the creation of projects - * @author Florent Benoit - */ -export class CreateProjectSvc { - - /** - * Default constructor that is using resource - * @ngInject for Dependency injection - */ - constructor ($timeout, $compile, $location) { - this.$timeout = $timeout; - this.$compile = $compile; - this.$location = $location; - this.init = false; - - - this.ideAction = ''; - this.createProjectInProgress = false; - - this.currentProgressStep = 0; - - - this.creationSteps = [ - {text: 'Creating and initializing workspace', inProgressText: 'Provision workspace and associating it with the existing user', logs: '', hasError: false}, - {text: 'Starting workspace runtime', inProgressText: 'Retrieving the stack\'s image and launching it', logs: '', hasError: false}, - {text: 'Starting workspace agent', inProgressText: 'Agents provide RESTful services like intellisense and SSH', logs: '', hasError: false}, - {text: 'Creating project', inProgressText: 'Creating and configuring project', logs: '', hasError: false}, - {text: 'Project created', inProgressText: 'Opening project', logs: '', hasError: false} - ]; - - } - - - getStepText(stepNumber) { - let entry = this.creationSteps[stepNumber]; - if (this.currentProgressStep >= stepNumber) { - return entry.inProgressText; - } else { - return entry.text; - } - } - - getProjectCreationSteps() { - return this.creationSteps; - } - - setCurrentProgressStep(currentProgressStep) { - this.currentProgressStep = currentProgressStep; - } - - getCurrentProgressStep() { - return this.currentProgressStep; - } - - hasInit() { - return this.init; - } - - resetCreateProgress() { - this.creationSteps.forEach((step) => { - step.logs = ''; - step.hasError = false; - }); - this.currentProgressStep = 0; - - this.createProjectInProgress = false; - } - - - isCreateProjectInProgress() { - return this.createProjectInProgress; - } - - setCreateProjectInProgress(value) { - this.createProjectInProgress = value; - } - - setWorkspaceOfProject(workspaceOfProject) { - this.workspaceOfProject = workspaceOfProject; - } - - getWorkspaceOfProject() { - return this.workspaceOfProject; - } - - setWorkspaceNamespace(namespace) { - this.namespace = namespace; - } - - getWorkspaceNamespace() { - return this.namespace; - } - - setProject(project) { - this.project = project; - } - - getProject() { - return this.project; - } - - hasIdeAction() { - return this.getIDEAction().length > 0; - } - - getIDEAction() { - return this.ideAction; - } - - setIDEAction(ideAction) { - this.ideAction = ideAction; - } - - getIDELink() { - let link = '#/ide/' + this.getWorkspaceNamespace() + '/' + this.getWorkspaceOfProject(); - if (this.hasIdeAction()) { - link = link + '?action=' + this.ideAction; - } - return link; - } - - redirectToIDE() { - let path = '/ide/' + this.getWorkspaceNamespace() + '/' + this.getWorkspaceOfProject(); - this.$location.path(path); - - if (this.getIDEAction()) { - this.$location.search({'action': this.getIDEAction()}); - } - } - -} diff --git a/dashboard/src/app/projects/create-project/create-project.styl b/dashboard/src/app/projects/create-project/create-project.styl deleted file mode 100644 index 8aa75a6f42..0000000000 --- a/dashboard/src/app/projects/create-project/create-project.styl +++ /dev/null @@ -1,81 +0,0 @@ -//TODO change colors -$item-enabled-color-bg = $default-dark-color -$item-enabled-color-fg = $white-color -$item-disabled-color-bg = $clear-foggy-sky-color -$item-disabled-color-fg = $stroke-color -$item-error-color-bg = $auth-error-color -$item-output-bg = $cat-gray-color -$item-output-fg = $dark-menacing-sky-color - -che-button-primary#create-project-button-import button - margin 30px 0 100px - font-size 1.2em - width 100% !important - -.create-project-box md-icon - font-size 24px - -md-select.create-project-select - width 100% - margin-top 0 - margin-bottom 0 - -.projects-create-project > md-card:first-child .che-panel-content - padding 0 - -.projects-create-project > md-card:first-child md-tabs-content-wrapper - padding-left 24px - padding-right 24px - padding-bottom 25px - -.create-project-progress-panel - margin-left 24px - margin-top 32px - margin-bottom 10px - margin-right 24px - background-color #fff - box-shadow 0 2px 6px 0 rgba(0, 0, 0, 0.4) - -.create-project-header-button .che-button - font-size 15px !important - box-shadow 0 0 0 0 rgba(0, 0, 0, 0.26) !important - -.create-project-minimize-icon - font-size 40px - cursor pointer - outline none - -.stack-label-info - color $label-info-color - margin-bottom 12px - margin-top 7px - -.create-project-progress-panel .che-loader-animation-panel - border none !important - -.create-project-working-log - margin-top 35px - -.create-project-download-logs-link - margin-right 8px - -.projects-create-project - padding 0 14px - - md-tabs - min-height 185px - - .che-label-container-content .create-project-input - margin -6px 0 - - .che-label-container-content .create-project-nested-container - margin -25px 0 - - .workspace-environment-name + div - margin-top 8px - - .workspace-machine - margin-left 45px - - .che-ram-allocation-slider .slider-wrapper - margin-bottom -15px diff --git a/dashboard/src/app/projects/create-project/git/create-project-git.controller.ts b/dashboard/src/app/projects/create-project/git/create-project-git.controller.ts deleted file mode 100644 index 836b27aefb..0000000000 --- a/dashboard/src/app/projects/create-project/git/create-project-git.controller.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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'; - -/** - * This class is handling the controller for the git part - * @author Florent Benoit - */ -export class CreateProjectGitController { - - /** - * Default constructor that is using resource - * @ngInject for Dependency injection - */ - constructor() { - this.focus = false; - } - - /** - * Input for setting the GIT URL gets the focus - */ - setFocus() { - this.focus = true; - } - - /** - * Input for setting the GIT URL losts the focus - */ - lostFocus() { - this.focus = false; - } - - -} diff --git a/dashboard/src/app/projects/create-project/git/create-project-git.directive.ts b/dashboard/src/app/projects/create-project/git/create-project-git.directive.ts deleted file mode 100644 index 4d6d1af941..0000000000 --- a/dashboard/src/app/projects/create-project/git/create-project-git.directive.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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 creating project from git. - * @author Florent Benoit - */ -export class CreateProjectGit { - - /** - * Default constructor that is using resource - * @ngInject for Dependency injection - */ - constructor() { - - this.controller = 'CreateProjectGitController'; - this.controllerAs = 'createProjectGitCtrl'; - this.bindToController = true; - - this.restrict = 'E'; - this.templateUrl = 'app/projects/create-project/git/create-project-git.html'; - } - - - /** - * Watch the data and update project name if location is updated - * @param $scope - */ - link($scope) { - - // Watch data of the createProject controller and update project name - $scope.$watch('createProjectCtrl.importProjectData', (newValue) => { - - - if ('git' !== $scope.createProjectCtrl.currentTab) { - return; - } - - // no focus, abort - if (!$scope.createProjectGitCtrl.focus) { - return; - } - - // get current url - var uri = newValue.source.location; - - if (!uri || uri === '') { - return; - } - - // search if repository is ending with . (for example .git) or the last name - var indexFinishProjectName = uri.lastIndexOf('.'); - var indexStartProjectName; - if (uri.lastIndexOf('/') !== -1) { - indexStartProjectName = uri.lastIndexOf('/') + 1; - } else { - indexStartProjectName = uri.lastIndexOf(':') + 1; - } - - - var name; - - // extract name with .../dummy.git - if (indexStartProjectName !== 0 && indexStartProjectName < indexFinishProjectName) { - name = uri.substring(indexStartProjectName, indexFinishProjectName); - } else if (indexStartProjectName !== 0) { - // extract ...../dummy - name = uri.substring(indexStartProjectName); - } else { - // unable to do something - name = ''; - } - - // able to extract something, change it - if (name !== '') { - $scope.createProjectCtrl.importProjectData.project.name = name; - } - - }, true); - - - } -} diff --git a/dashboard/src/app/projects/create-project/git/create-project-git.html b/dashboard/src/app/projects/create-project/git/create-project-git.html deleted file mode 100644 index 8b7ae38317..0000000000 --- a/dashboard/src/app/projects/create-project/git/create-project-git.html +++ /dev/null @@ -1,33 +0,0 @@ - -
-
- -
- -
Invalid Git URL
-
A repository URL is required.
-
-
-
- -
diff --git a/dashboard/src/app/projects/create-project/git/create-project-git.styl b/dashboard/src/app/projects/create-project/git/create-project-git.styl deleted file mode 100644 index c9b44c1ae8..0000000000 --- a/dashboard/src/app/projects/create-project/git/create-project-git.styl +++ /dev/null @@ -1,6 +0,0 @@ -.create-project-git - .che-label-container - padding-bottom 0 - - .che-label-container-content .create-project-git-input - margin -6px 0 diff --git a/dashboard/src/app/projects/create-project/github/create-project-github.controller.ts b/dashboard/src/app/projects/create-project/github/create-project-github.controller.ts deleted file mode 100644 index fcef39582b..0000000000 --- a/dashboard/src/app/projects/create-project/github/create-project-github.controller.ts +++ /dev/null @@ -1,209 +0,0 @@ -/* - * 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'; - -/** - * This class is handling the controller for the GitHub part - * @author Stéphane Daviet - * @author Florent Benoit - */ -export class CreateProjectGithubController { - - /** - * Default constructor that is using resource - * @ngInject for Dependency injection - */ - constructor (cheAPI, $rootScope, $http, $q, $window, $mdDialog, $location, $browser, $filter, GitHub, githubPopup, gitHubTokenStore, - cheBranding, githubOrganizationNameResolver, $timeout, $scope) { - this.cheAPI = cheAPI; - this.$http = $http; - this.$rootScope = $rootScope; - this.$q = $q; - this.$window = $window; - this.$mdDialog = $mdDialog; - this.$location = $location; - this.$browser = $browser; - this.$filter = $filter; - this.GitHub = GitHub; - this.gitHubTokenStore = gitHubTokenStore; - this.githubPopup = githubPopup; - this.cheBranding = cheBranding; - this.githubOrganizationNameResolver = githubOrganizationNameResolver; - this.$timeout = $timeout; - - this.productName = cheBranding.getName(); - - this.profile = cheAPI.getProfile().getProfile(); - - this.currentTokenCheck = null; - this.resolveOrganizationName = this.githubOrganizationNameResolver.resolve; - - this.organizations = []; - this.gitHubRepositories = []; - - this.state = 'IDLE'; - this.isGitHubOAuthProviderAvailable = false; - - - let oAuthProviderPromise = this.cheAPI.getOAuthProvider().fetchOAuthProviders().then(() => { - this.isGitHubOAuthProviderAvailable = this.cheAPI.getOAuthProvider().isOAuthProviderRegistered('github'); - }); - - let tabOpenDefer = this.$q.defer(); - $scope.$watch(() => {return this.isCurrentTab;}, (isVisible) => { - if (isVisible) { - tabOpenDefer.resolve(); - } - }); - - // check token validity and load repositories - this.$q.all([ - oAuthProviderPromise, - tabOpenDefer.promise, - this.profile.$promise - ]).then(() => { - if (this.isGitHubOAuthProviderAvailable) { - this.currentUserId = this.profile.userId; - this.askLoad(); - } else { - this.state = 'NO_REPO'; - } - }); - } - - askLoad() { - this.state = 'LOADING'; - this.checkTokenValidity().then(() => { - this.loadRepositories(); - }).catch(() => { - this.state = 'NO_REPO'; - }); - - } - - authenticateWithGitHub() { - if (!this.isGitHubOAuthProviderAvailable) { - this.$mdDialog.show({ - controller: 'NoGithubOauthDialogController', - controllerAs: 'noGithubOauthDialogController', - bindToController: true, - clickOutsideToClose: true, - templateUrl: 'app/projects/create-project/github/oauth-dialog/no-github-oauth-dialog.html' - }); - - return; - } - - var redirectUrl = this.$location.protocol() + '://' - + this.$location.host() + ':' - + this.$location.port() - + this.$browser.baseHref() - + 'gitHubCallback.html'; - return this.githubPopup.open('/api/oauth/authenticate' - + '?oauth_provider=github' - + '&scope=' + ['user', 'repo', 'write:public_key'].join(',') - + '&userId=' + this.currentUserId - + '&redirect_after_login=' - + redirectUrl, - { - width: 1020, - height: 618 - }) - .then( () => { - return this.getAndStoreRemoteToken(); - }, (rejectionReason) => { - return this.$q.reject(rejectionReason); - }); - } - - getAndStoreRemoteToken() { - return this.$http({method: 'GET', url: '/api/oauth/token?oauth_provider=github'}).then( (result) => { - if (!result.data) { - return false; - } - this.gitHubTokenStore.setToken(result.data.token); - this.$http({method: 'POST', url: '/api/github/ssh/generate'}); - this.askLoad(); - return true; - }); - - } - - - checkTokenValidity() { - if (this.currentTokenCheck) { - return this.currentTokenCheck; - } - this.currentTokenCheck = this.GitHub.user().get( () => { - this.currentTokenCheck = null; - return this.$q.defer().resolve(true); - }, () => { - this.currentTokenCheck = null; - return this.$q.defer().reject(false); - }).$promise; - return this.currentTokenCheck; - } - - checkGitHubAuthentication() { - return this.checkTokenValidity().then( () => { - return this.$q.defer().resolve('true'); - }); - } - - - loadRepositories() { - - - this.checkGitHubAuthentication().then( () => { - var user = this.GitHub.user().get(); - - this.organizations.push(user); - this.GitHub.organizations().query().$promise.then((organizations) => { - - this.organizations = this.organizations.concat(organizations); - - var organizationNames = []; //'login' - this.organizations.forEach((organization) => { - if (organization.login) { - organizationNames.push(organization.login); - } - }); - - this.GitHub.userRepositories().query().$promise.then((repositories) => { - this.gitHubRepositories = this.$filter('filter')(repositories, (repository) => { - return organizationNames.indexOf(repository.owner.login) >= 0; - }); - this.state = 'LOADED'; - }); - }); - - }, function () { - this.state = 'LOAD_ERROR'; - }); - } - - - - selectRepository(gitHubRepository) { - this.selectedRepository = gitHubRepository; - this.$timeout(() => { - this.repositorySelectNotify(); - // broadcast event - this.$rootScope.$broadcast('create-project-github:selected'); - }); - } - - - resolveOrganizationType(organization) { - return organization.name ? 'Your account' : 'Your organization\'s account'; - } - -} diff --git a/dashboard/src/app/projects/create-project/github/create-project-github.directive.ts b/dashboard/src/app/projects/create-project/github/create-project-github.directive.ts deleted file mode 100644 index d78d6cfc4b..0000000000 --- a/dashboard/src/app/projects/create-project/github/create-project-github.directive.ts +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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 creating project from github. - * @author Florent Benoit - */ -export class CreateProjectGithub { - - /** - * Default constructor that is using resource - * @ngInject for Dependency injection - */ - constructor($http, $q, $window, $location, $browser, $filter, GitHub, githubPopup, gitHubTokenStore, githubOrganizationNameResolver) { - this.$http = $http; - this.$q = $q; - this.$window = $window; - this.$location = $location; - this.$browser = $browser; - this.$filter = $filter; - this.GitHub = GitHub; - this.gitHubTokenStore = gitHubTokenStore; - this.githubPopup = githubPopup; - this.githubOrganizationNameResolver = githubOrganizationNameResolver; - - this.controller = 'CreateProjectGithubController'; - this.controllerAs = 'createProjectGithubCtrl'; - this.bindToController = true; - - this.restrict = 'E'; - this.templateUrl = 'app/projects/create-project/github/create-project-github.html'; - - // scope values - this.scope = { - createProjectGitHubForm: '=cheForm', - selectedRepository: '=cheRepositoryModel', - repositorySelectNotify: '&cheRepositorySelect', - isCurrentTab: '=cheIsCurrentTab' - }; - } - - link($scope) { - // Watch data of the createProject controller and update content with these parameters - $scope.$watch('createProjectCtrl.importProjectData.source.project.location', (newValue) => { - var matchRepository = this.$filter('filter')($scope.createProjectGithubCtrl.gitHubRepositories, function (repository) { - return repository.clone_url === newValue; - }); - if (matchRepository) { - $scope.createProjectGithubCtrl.selectedRepository = matchRepository[0]; - } else { - $scope.createProjectGithubCtrl.selectedRepository = undefined; - } - }); - - } -} diff --git a/dashboard/src/app/projects/create-project/github/create-project-github.html b/dashboard/src/app/projects/create-project/github/create-project-github.html deleted file mode 100644 index da9ff57bad..0000000000 --- a/dashboard/src/app/projects/create-project/github/create-project-github.html +++ /dev/null @@ -1,72 +0,0 @@ - -
- -

- We have a problem authenticating you with GitHub. -

- -
-
Your GitHub repositories will appear here
-
GitHub repositories can easily be imported in {{createProjectGithubCtrl.productName}}
- - -
- -
- -   -
- -
-
- -
- - -
-
- -
-
- - -
-
- - - -
-
-
{{gitHubRepository.name}}
-
{{gitHubRepository.description}}
-
- -
- {{gitHubRepository.clone_url}} -
-
-
-
-
diff --git a/dashboard/src/app/projects/create-project/github/create-project-github.styl b/dashboard/src/app/projects/create-project/github/create-project-github.styl deleted file mode 100644 index bc50047ac0..0000000000 --- a/dashboard/src/app/projects/create-project/github/create-project-github.styl +++ /dev/null @@ -1,64 +0,0 @@ -.github-create-project span - margin-left 5px - -.github-create-project - cursor pointer - -.create-project-github-panel - margin 15px - -.github-create-project .icons - margin-right 20px - -.github-create-project-select - display block - width 100% - background-color #fafafa - background-image none - border 1px solid #e5e5e5 - border-radius 0 - -webkit-box-shadow inset 0 1px 1px rgba(0, 0, 0, .075) - -webkit-transition border-color ease-in-out .15s, box-shadow ease-in-out .15s - transition border-color ease-in-out .15s, box-shadow ease-in-out .15s - -.github-create-project-repository-name - font-size 16px - line-height 19px - color $label-primary-color - margin-bottom 3px - -.github-create-project-repositories-list - max-height 400px - overflow auto - margin 2px - -.github-create-project-repository-details - font-size 12px - line-height 15px - color $label-info-color - -.github-create-project-icons - color $label-info-color - -.github-create-project-icon - margin-left 10px - -.github-create-project-search-component - border-bottom $label-primary-color 1px solid - margin-bottom 30px - -.github-create-project-search-input - border none - outline none - -.github-create-project-dropdown-component - margin-bottom 27px - -.github-create-project-github-button - margin-top 10px - button - margin-left 0 - -.github-create-project-github-warningempty - margin-bottom 10px - color $label-info-color diff --git a/dashboard/src/app/projects/create-project/github/oauth-dialog/no-github-oauth-dialog.controller.ts b/dashboard/src/app/projects/create-project/github/oauth-dialog/no-github-oauth-dialog.controller.ts deleted file mode 100644 index b5b206e098..0000000000 --- a/dashboard/src/app/projects/create-project/github/oauth-dialog/no-github-oauth-dialog.controller.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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'; - -/** - * @ngdoc controller - * @name projects.create-project.github.oauth-dialog.controller:NoGithubOauthDialogController - * @description This class is handling the controller for the no Github oAuth dialog - * @author Florent Benoit - */ -export class NoGithubOauthDialogController { - - /** - * Default constructor that is using resource - * @ngInject for Dependency injection - */ - constructor($mdDialog, $rootScope) { - this.$mdDialog = $mdDialog; - - this.name = $rootScope.branding.name; - this.message = $rootScope.branding.oauthDocs; - } - - /** - * It will hide the dialog box. - */ - hide() { - this.$mdDialog.hide(); - } -} diff --git a/dashboard/src/app/projects/create-project/github/oauth-dialog/no-github-oauth-dialog.html b/dashboard/src/app/projects/create-project/github/oauth-dialog/no-github-oauth-dialog.html deleted file mode 100644 index 0a6ed07ac6..0000000000 --- a/dashboard/src/app/projects/create-project/github/oauth-dialog/no-github-oauth-dialog.html +++ /dev/null @@ -1,7 +0,0 @@ - -
-
GitHub oAuth is not configured. {{noGithubOauthDialogController.message}}
- -
-
diff --git a/dashboard/src/app/projects/create-project/github/oauth-dialog/no-github-oauth-dialog.styl b/dashboard/src/app/projects/create-project/github/oauth-dialog/no-github-oauth-dialog.styl deleted file mode 100644 index a0fe7641fa..0000000000 --- a/dashboard/src/app/projects/create-project/github/oauth-dialog/no-github-oauth-dialog.styl +++ /dev/null @@ -1,6 +0,0 @@ -.no-github-oauth-content - width 100% - - & > div - margin-top 10px - min-height 40px diff --git a/dashboard/src/app/projects/create-project/project-error-notification/project-error-notification.controller.ts b/dashboard/src/app/projects/create-project/project-error-notification/project-error-notification.controller.ts deleted file mode 100644 index c355d0d219..0000000000 --- a/dashboard/src/app/projects/create-project/project-error-notification/project-error-notification.controller.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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'; - -/** - * This class is handling the controller for the project error notification - * @author Oleksii Orel - */ -export class ProjectErrorNotificationController { - title: string; - content: string; - - private $mdDialog: ng.material.IDialogService; - - /** - * Default constructor. - * @ngInject for Dependency injection - */ - constructor($mdDialog: ng.material.IDialogService) { - this.$mdDialog = $mdDialog; - } - - /** - * Callback of the cancel button of the dialog. - */ - hide() { - this.$mdDialog.hide(); - } -} diff --git a/dashboard/src/app/projects/create-project/project-error-notification/project-error-notification.html b/dashboard/src/app/projects/create-project/project-error-notification/project-error-notification.html deleted file mode 100644 index f57b7e469f..0000000000 --- a/dashboard/src/app/projects/create-project/project-error-notification/project-error-notification.html +++ /dev/null @@ -1,8 +0,0 @@ - -
-
{{projectErrorNotificationController.content}}
- - -
-
diff --git a/dashboard/src/app/projects/create-project/project-error-notification/project-error-notification.styl b/dashboard/src/app/projects/create-project/project-error-notification/project-error-notification.styl deleted file mode 100644 index 2d94225da3..0000000000 --- a/dashboard/src/app/projects/create-project/project-error-notification/project-error-notification.styl +++ /dev/null @@ -1,4 +0,0 @@ -.ssh-key-notification - width 100% - margin-top 10px - min-height 30px diff --git a/dashboard/src/app/projects/create-project/samples/create-project-samples-tag.filter.ts b/dashboard/src/app/projects/create-project/samples/create-project-samples-tag.filter.ts deleted file mode 100644 index 04b1f40dd7..0000000000 --- a/dashboard/src/app/projects/create-project/samples/create-project-samples-tag.filter.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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'; - -export class CreateProjectSamplesTagFilter { - - constructor(register: che.IRegisterService) { - // register this factory - register.filter('sampleTagFilter', () => { - return (templates: Array, tagFilter: Array) => { - if (!templates) { - return []; - } - if (!tagFilter || !tagFilter.length) { - return templates; - } - - let filtered: Array = []; - templates.forEach((template: che.IStack) => { - for (let i: number = 0; i < template.tags.length; i++) { - for (let j: number = 0; j < tagFilter.length; j++) { - if (template.tags[i].toLowerCase() === tagFilter[j].toLowerCase()) { - filtered.push(template); - return; - } - } - } - }); - return filtered.length ? filtered : templates; - }; - }); - } -} diff --git a/dashboard/src/app/projects/create-project/samples/create-project-samples.controller.ts b/dashboard/src/app/projects/create-project/samples/create-project-samples.controller.ts deleted file mode 100644 index db5ee0f203..0000000000 --- a/dashboard/src/app/projects/create-project/samples/create-project-samples.controller.ts +++ /dev/null @@ -1,116 +0,0 @@ -/* - * 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'; -import {CheAPI} from '../../../../components/api/che-api.factory'; - -/** - * This class is handling the controller for the samples part - * @author Florent Benoit - */ -export class CreateProjectSamplesController { - $filter: ng.IFilterService; - - templates: Array; - filteredAndSortedTemplates: Array; - selectedTemplateName: string = ''; - - currentStackTags: string[]; - projectSampleOnSelect: Function; - - /** - * Default constructor that is using resource - * @ngInject for Dependency injection - */ - constructor($scope: ng.IScope, $filter: ng.IFilterService, cheAPI: CheAPI) { - this.$filter = $filter; - - this.templates = cheAPI.getProjectTemplate().getAllProjectTemplates(); - if (!this.templates.length) { - const templatesPromise = cheAPI.getProjectTemplate().fetchTemplates(); - templatesPromise.finally(() => { - this.templates = cheAPI.getProjectTemplate().getAllProjectTemplates(); - this.filterAndSortTemplates(); - }); - } - - $scope.$watch(() => { - return this.currentStackTags; - }, () => { - this.filterAndSortTemplates(); - }); - } - - /** - * Returns list of filtered and sorted templates. - * - * @return {che.IProjectTemplate[]} - */ - getTemplates(): che.IProjectTemplate[] { - return this.filteredAndSortedTemplates; - } - - /** - * Filters templates by tags and sort them by project type and template name. - */ - filterAndSortTemplates(): void { - let stackTags = !this.currentStackTags ? [] : this.currentStackTags.map((tag: string) => tag.toLowerCase()); - - let filteredTemplates; - if (!stackTags.length) { - filteredTemplates = this.templates; - } else { - filteredTemplates = this.templates.filter((template: che.IProjectTemplate) => { - let templateTags = template.tags.map((tag: string) => tag.toLowerCase()); - return stackTags.some((tag: string) => templateTags.indexOf(tag) > -1); - }); - } - - this.filteredAndSortedTemplates = this.$filter('orderBy')(filteredTemplates, ['projectType', 'displayName']); - - if (this.filteredAndSortedTemplates.length) { - this.initItem(this.filteredAndSortedTemplates[0]); - } - } - - /** - * Callback when a template is selected and also give the controller on which to select the data - * @param template: che.IProjectTemplate - the selected template - */ - selectTemplate(template: che.IProjectTemplate): void { - if (!template) { - return; - } - - // set selected item - this.selectedTemplateName = template.name; - this.projectSampleOnSelect({template: template}); - } - - /** - * Select the first element in the list - * @param {che.IProjectTemplate} template - */ - initItem(template: che.IProjectTemplate): void { - if (!template || this.selectedTemplateName === template.name) { - return; - } - this.selectTemplate(template); - } - - /** - * Helper method used to get the length of keys of the given object - * @param {Array} items - * @returns {number} length of keys - */ - getItemsSize(items: Array): number { - return items.length; - } -} diff --git a/dashboard/src/app/projects/create-project/samples/create-project-samples.directive.ts b/dashboard/src/app/projects/create-project/samples/create-project-samples.directive.ts deleted file mode 100644 index a606ba7c7a..0000000000 --- a/dashboard/src/app/projects/create-project/samples/create-project-samples.directive.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 creating project from samples. - * @author Florent Benoit - */ -export class CreateProjectSamples { - bindToController: boolean; - restrict: string; - controller: string; - templateUrl: string; - controllerAs: string; - - scope: { - [propName: string]: string - }; - - /** - * Default constructor that is using resource - * @ngInject for Dependency injection - */ - constructor() { - this.restrict = 'E'; - this.templateUrl = 'app/projects/create-project/samples/create-project-samples.html'; - - this.controller = 'CreateProjectSamplesController'; - this.controllerAs = 'createProjectSamplesController'; - this.bindToController = true; - - this.scope = { - currentStackTags: '=', - projectSampleOnSelect: '&' - }; - } -} diff --git a/dashboard/src/app/projects/create-project/samples/create-project-samples.html b/dashboard/src/app/projects/create-project/samples/create-project-samples.html deleted file mode 100644 index 3f3563c86f..0000000000 --- a/dashboard/src/app/projects/create-project/samples/create-project-samples.html +++ /dev/null @@ -1,34 +0,0 @@ - - - -
- -
-
-
{{template.displayName}}
-
{{template.description}}
-
-
-
-
-
- No matching sample. -
-
-
diff --git a/dashboard/src/app/projects/create-project/samples/create-project-samples.styl b/dashboard/src/app/projects/create-project/samples/create-project-samples.styl deleted file mode 100644 index 00807c0e38..0000000000 --- a/dashboard/src/app/projects/create-project/samples/create-project-samples.styl +++ /dev/null @@ -1,44 +0,0 @@ -.projects-create-project-samples-list-item - outline none - padding 5px 10px - cursor pointer - -.projects-create-project-samples-list-item-active - background-color $primary-color - -.projects-create-project-samples-list-samplename - line-height initial - font-size 12px - color $label-primary-color - -.projects-create-project-samples-list-sampledescription - line-height initial - font-size 10px - color $label-info-color - -.projects-create-project-samples-list-item-active .projects-create-project-samples-list-samplename - color white - -.projects-create-project-samples-list-item-active .projects-create-project-samples-list-sampledescription - color white - -.projects-create-project-samples-header-projecttype - color $label-info-color - -.projects-create-project-samples-search-component - border-bottom $label-primary-color 1px solid - margin-bottom 30px - -#create-project-templates md-radio-button - margin-left 0 - margin-bottom 20px - -.projects-create-project-samples-list - margin 0 - -.projects-create-project-samples-list .che-list-content>div:first-child - border-top 1px solid $list-separator-color - -.projects-create-project-samples - padding-left 30px - max-height 400px diff --git a/dashboard/src/app/projects/create-project/workspaces/create-project-workspaces.controller.ts b/dashboard/src/app/projects/create-project/workspaces/create-project-workspaces.controller.ts deleted file mode 100644 index 20722ad164..0000000000 --- a/dashboard/src/app/projects/create-project/workspaces/create-project-workspaces.controller.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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'; - -/** - * @ngdoc controller - * @name projects.create-project.controller:CreateProjectWorkspacesController - * @description This class is handling the controller for the 'select existing workspace' widget. - * @author Oleksii Orel - */ -export class CreateProjectWorkspacesController { - - /** - * Default constructor that is using resource - * @ngInject for Dependency injection - */ - constructor($timeout, cheAPI) { - this.$timeout = $timeout; - - this.workspaces = cheAPI.getWorkspace().getWorkspaces(); - } - - /** - * Callback when workspace has been select - * @param workspace the workspace to use - */ - onWorkspaceSelect(workspace) { - this.workspace = workspace; - this.$timeout(() => { - this.onWorkspaceChange(); - }); - } -} diff --git a/dashboard/src/app/projects/create-project/workspaces/create-project-workspaces.directive.ts b/dashboard/src/app/projects/create-project/workspaces/create-project-workspaces.directive.ts deleted file mode 100644 index 3104bda87f..0000000000 --- a/dashboard/src/app/projects/create-project/workspaces/create-project-workspaces.directive.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 displaying select workspace widget. - * @author Oleksii Orel - */ -export class CreateProjectWorkspaces { - - /** - * Default constructor that is using resource - * @ngInject for Dependency injection - */ - constructor() { - this.restrict = 'E'; - this.templateUrl = 'app/projects/create-project/workspaces/create-project-workspaces.html'; - this.bindToController = true; - this.controller = 'CreateProjectWorkspacesController'; - this.controllerAs = 'createProjectWorkspacesController'; - - // scope values - this.scope = { - workspace: '=cheWorkspace', - onWorkspaceChange: '&cheWorkspaceChange' - }; - - } - -} diff --git a/dashboard/src/app/projects/create-project/workspaces/create-project-workspaces.html b/dashboard/src/app/projects/create-project/workspaces/create-project-workspaces.html deleted file mode 100644 index 4b4d4eb116..0000000000 --- a/dashboard/src/app/projects/create-project/workspaces/create-project-workspaces.html +++ /dev/null @@ -1,35 +0,0 @@ - - -
- - -
-
-
{{workspace.config.name}}
-
- {{workspace.attributes.stackId}} stack -
-
-
-
-
-
-
- - No workspaces inside -
-
diff --git a/dashboard/src/app/projects/create-project/workspaces/create-project-workspaces.styl b/dashboard/src/app/projects/create-project/workspaces/create-project-workspaces.styl deleted file mode 100644 index 598fee35e0..0000000000 --- a/dashboard/src/app/projects/create-project/workspaces/create-project-workspaces.styl +++ /dev/null @@ -1,37 +0,0 @@ -.create-project-workspace-list - padding-left 30px - max-height 400px - - .samples-list - box-sizing content-box - max-height 205px - overflow-y auto - margin 0 - - .che-list-item:first-child - border-top 1px solid $list-separator-color - - .list-item - outline none - padding 5px 10px - cursor pointer - min-height 41px - - .list-item-name - font-size 12px - line-height initial - color $label-primary-color - - .list-item-description - font-size 10px - line-height initial - color $label-info-color - - .list-item-active - background-color $primary-color - - .list-item-active * - color $white-color - - .list-empty - font-size 12px diff --git a/dashboard/src/app/projects/create-project/zip/create-project-zip.directive.ts b/dashboard/src/app/projects/create-project/zip/create-project-zip.directive.ts deleted file mode 100644 index 7bed977326..0000000000 --- a/dashboard/src/app/projects/create-project/zip/create-project-zip.directive.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 creating project from zip. - * @author Florent Benoit - */ -export class CreateProjectZip { - - /** - * Default constructor that is using resource - * @ngInject for Dependency injection - */ - constructor () { - this.restrict='E'; - this.templateUrl = 'app/projects/create-project/zip/create-project-zip.html'; - } - -} diff --git a/dashboard/src/app/projects/create-project/zip/create-project-zip.html b/dashboard/src/app/projects/create-project/zip/create-project-zip.html deleted file mode 100644 index 38b797d132..0000000000 --- a/dashboard/src/app/projects/create-project/zip/create-project-zip.html +++ /dev/null @@ -1,33 +0,0 @@ - -
-
- -
- -
A zip URL is required.
-
- - Skip the root folder of the archive - -
-
-
diff --git a/dashboard/src/app/projects/create-project/zip/create-project-zip.styl b/dashboard/src/app/projects/create-project/zip/create-project-zip.styl deleted file mode 100644 index f97680c644..0000000000 --- a/dashboard/src/app/projects/create-project/zip/create-project-zip.styl +++ /dev/null @@ -1,10 +0,0 @@ -.create-project-zip - .che-label-container - padding-bottom 0 - - .che-label-container-content .create-project-zip-input - margin -6px 0 - -.create-project-zip-checkbox - margin-top 20px - color $label-primary-color diff --git a/dashboard/src/app/projects/list-projects/project-item/project-item.directive.ts b/dashboard/src/app/projects/list-projects/project-item/project-item.directive.ts deleted file mode 100644 index f98164f3cf..0000000000 --- a/dashboard/src/app/projects/list-projects/project-item/project-item.directive.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 { - - /** - * Default constructor. - */ - constructor() { - this.restrict = 'E'; - - // we require ngModel as we want to use it inside our directive - this.require = ['ngModel']; - - // scope values - this.scope = { - workspace: '=cheProjectItemWorkspace', - project: '=cheProjectItemProject', - profileCreationDate: '=cheProfileCreationDate', - isDisplayWorkspace: '=cheDisplayWorkspace', - isSelectable: '=cheSelectable', - isSelect: '=?ngModel', - onCheckboxClick: '&?cheOnCheckboxClick', - hasAction: '=?cheHasAction' - }; - - this.templateUrl = 'app/projects/list-projects/project-item/project-item.html'; - - - this.controller = 'ProjectItemCtrl'; - this.controllerAs = 'projectItemCtrl'; - this.bindToController = true; - - } - -} diff --git a/dashboard/src/app/projects/project-details/repository/project-repository-config.ts b/dashboard/src/app/projects/project-details/repository/project-repository-config.ts deleted file mode 100644 index 112b97e5ee..0000000000 --- a/dashboard/src/app/projects/project-details/repository/project-repository-config.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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'; - -import {ProjectRepositoryController} from '../repository/project-repository.controller'; -import {ProjectRepository} from '../repository/project-repository.directive'; - - -export class ProjectRepositoryConfig { - - constructor(register) { - register.controller('ProjectRepositoryController', ProjectRepositoryController); - register.directive('projectRepository', ProjectRepository); - - } -} diff --git a/dashboard/src/app/projects/projects-config.styl b/dashboard/src/app/projects/projects-config.styl deleted file mode 100644 index fb3bdb7cd4..0000000000 --- a/dashboard/src/app/projects/projects-config.styl +++ /dev/null @@ -1,3 +0,0 @@ -/*@import 'create-project/create-project' -@import 'list-projects/list-projects' -*/ diff --git a/dashboard/src/app/projects/projects-config.ts b/dashboard/src/app/projects/projects-config.ts deleted file mode 100644 index 19b06f0745..0000000000 --- a/dashboard/src/app/projects/projects-config.ts +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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'; - -import {CreateProjectController} from './create-project/create-project.controller'; -import {CreateProjectSvc} from './create-project/create-project.service'; -import {CreateProjectGithubController} from './create-project/github/create-project-github.controller'; - -import {CreateProjectGit} from './create-project/git/create-project-git.directive'; -import {CreateProjectGitController} from './create-project/git/create-project-git.controller'; -import {CreateProjectGithub} from './create-project/github/create-project-github.directive'; -import {AddSecretKeyNotificationController} from './create-project/add-ssh-key-notification/add-ssh-key-notification.controller'; -import {NoGithubOauthDialogController} from './create-project/github/oauth-dialog/no-github-oauth-dialog.controller'; -import {CreateProjectSamplesController} from './create-project/samples/create-project-samples.controller'; -import {CreateProjectSamples} from './create-project/samples/create-project-samples.directive'; -import {CreateProjectWorkspacesController} from './create-project/workspaces/create-project-workspaces.controller'; -import {CreateProjectWorkspaces} from './create-project/workspaces/create-project-workspaces.directive'; - -import {CreateProjectSamplesTagFilter} from './create-project/samples/create-project-samples-tag.filter'; - -import {CreateProjectZip} from './create-project/zip/create-project-zip.directive'; -import {CreateProjectConfFile} from './create-project/config-file/create-project-conf-file.directive'; -import {ProjectDetailsController} from './project-details/project-details.controller'; -import {ProjectRepositoryConfig} from './project-details/repository/project-repository-config'; -import {CheProjectItem} from './list-projects/project-item/project-item.directive'; -import {ProjectItemCtrl} from './list-projects/project-item/project-item.controller'; -import {ProjectErrorNotificationController} from './create-project/project-error-notification/project-error-notification.controller'; - -export class ProjectsConfig { - - constructor(register: che.IRegisterService) { - new CreateProjectSamplesTagFilter(register); - - - register.controller('ProjectDetailsController', ProjectDetailsController); - - register.controller('CreateProjectGitController', CreateProjectGitController); - register.directive('createProjectGit', CreateProjectGit); - - register.controller('CreateProjectGithubController', CreateProjectGithubController); - register.directive('createProjectGithub', CreateProjectGithub); - - register.controller('NoGithubOauthDialogController', NoGithubOauthDialogController); - - register.controller('AddSecretKeyNotificationController', AddSecretKeyNotificationController); - - register.controller('ProjectErrorNotificationController', ProjectErrorNotificationController); - - register.controller('CreateProjectSamplesController', CreateProjectSamplesController); - register.directive('createProjectSamples', CreateProjectSamples); - - register.controller('CreateProjectWorkspacesController', CreateProjectWorkspacesController); - register.directive('createProjectWorkspaces', CreateProjectWorkspaces); - - register.directive('createProjectZip', CreateProjectZip); - - register.directive('createProjectConfFile', CreateProjectConfFile); - - register.service('createProjectSvc', CreateProjectSvc); - register.controller('CreateProjectController', CreateProjectController); - - register.directive('cheProjectItem', CheProjectItem); - - register.controller('ProjectItemCtrl', ProjectItemCtrl); - - - let locationCreateProjectProvider = { - title: 'New Project', - templateUrl: 'app/projects/create-project/create-project.html', - controller: 'CreateProjectController', - controllerAs: 'createProjectCtrl' - }; - - // config routes - register.app.config(function ($routeProvider) { - $routeProvider.accessWhen('/project/:namespace*/:workspaceName/:projectName', { - title: (params) => {return params.workspaceName + ' | ' + params.projectName}, - templateUrl: 'app/projects/project-details/project-details.html', - controller: 'ProjectDetailsController', - controllerAs: 'projectDetailsController' - }) - .accessWhen('/create-project', locationCreateProjectProvider) - .accessWhen('/create-project/:tabName', locationCreateProjectProvider); - - }); - - //// config files - new ProjectRepositoryConfig(register); - - } -} diff --git a/dashboard/src/app/stacks/stack-details/select-template/samples-tag.filter.ts b/dashboard/src/app/stacks/stack-details/select-template/samples-tag.filter.ts new file mode 100644 index 0000000000..8bba0d8a70 --- /dev/null +++ b/dashboard/src/app/stacks/stack-details/select-template/samples-tag.filter.ts @@ -0,0 +1,39 @@ +/* + * 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'; + +export class SamplesTagFilter { + + static filter() { + return (templates: Array, tagFilter: Array) => { + if (!templates) { + return []; + } + if (!tagFilter || !tagFilter.length) { + return templates; + } + + const filtered: Array = []; + templates.forEach((template: che.IStack) => { + for (let i: number = 0; i < template.tags.length; i++) { + for (let j: number = 0; j < tagFilter.length; j++) { + if (template.tags[i].toLowerCase() === tagFilter[j].toLowerCase()) { + filtered.push(template); + return; + } + } + } + }); + return filtered.length ? filtered : templates; + }; + } + +} diff --git a/dashboard/src/app/stacks/stack-details/select-template/select-template.html b/dashboard/src/app/stacks/stack-details/select-template/select-template.html index 311dca4931..03e9ca06f0 100644 --- a/dashboard/src/app/stacks/stack-details/select-template/select-template.html +++ b/dashboard/src/app/stacks/stack-details/select-template/select-template.html @@ -37,7 +37,7 @@ + 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;