-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Anna Shumilova <ashumilo@redhat.com>
- Loading branch information
1 parent
64129a8
commit 799c246
Showing
14 changed files
with
406 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...board/src/app/workspaces/create-workspace/devfile-selector/devfile-selector.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright (c) 2015-2018 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
'use strict'; | ||
import {CheWorkspace} from '../../../../components/api/workspace/che-workspace.factory'; | ||
import {DevfileRegistry, IDevfileMetaData} from '../../../../components/api/devfile-registry.factory'; | ||
|
||
/** | ||
* @description This class is handling the controller of devfile selector. | ||
* @author Ann Shumilova | ||
*/ | ||
export class DevfileSelectorController { | ||
|
||
static $inject = ['devfileRegistry', 'cheWorkspace']; | ||
|
||
private devfileRegistry: DevfileRegistry; | ||
private cheWorkspace: CheWorkspace; | ||
private devfiles: Array<IDevfileMetaData>; | ||
onDevfileSelect: Function; | ||
selectedDevfile: any; | ||
|
||
/** | ||
* Default constructor that is using resource injection | ||
*/ | ||
constructor(devfileRegistry: DevfileRegistry, cheWorkspace: CheWorkspace) { | ||
this.devfileRegistry = devfileRegistry; | ||
this.cheWorkspace = cheWorkspace; | ||
this.loadDevfiles(); | ||
} | ||
|
||
loadDevfiles(): void { | ||
let location = this.cheWorkspace.getWorkspaceSettings().devfileRegistry; | ||
this.devfileRegistry.fetchDevfiles(location).then((data: Array<IDevfileMetaData>) => { | ||
this.devfiles = data; | ||
|
||
if (this.devfiles && this.devfiles.length > 0) { | ||
this.devfileOnClick(this.devfiles[0]); | ||
} | ||
}); | ||
} | ||
|
||
devfileOnClick(devfile: any): void { | ||
this.selectedDevfile = devfile; | ||
|
||
let location = this.cheWorkspace.getWorkspaceSettings().devfileRegistry; | ||
|
||
let devfileContent = this.devfileRegistry.getDevfile(location, devfile.links.self); | ||
if (devfileContent) { | ||
this.onDevfileSelect({devfile: devfileContent}); | ||
} else { | ||
this.devfileRegistry.fetchDevfile(location, devfile.links.self).then((devfileContent: che.IWorkspaceDevfile) => { | ||
this.onDevfileSelect({devfile: devfileContent}); | ||
}); | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
dashboard/src/app/workspaces/create-workspace/devfile-selector/devfile-selector.directive.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (c) 2018-2018 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
'use strict'; | ||
|
||
/** | ||
* Defines a directive for displaying devfile selector widget. | ||
* | ||
* @author Ann Shumilova | ||
*/ | ||
export class DevfileSelector implements ng.IDirective { | ||
restrict: string = 'E'; | ||
templateUrl: string = 'app/workspaces/create-workspace/devfile-selector/devfile-selector.html'; | ||
replace: boolean = true; | ||
|
||
controller: string = 'DevfileSelectorController'; | ||
controllerAs: string = 'devfileSelectorController'; | ||
|
||
bindToController: boolean = true; | ||
|
||
scope: { | ||
[propName: string]: string | ||
}; | ||
|
||
/** | ||
* Default constructor that is using resource | ||
*/ | ||
constructor() { | ||
this.scope = { | ||
devfileIdSelected: '=', | ||
onDevfileSelect: '&' | ||
}; | ||
} | ||
} |
Oops, something went wrong.