diff --git a/.gitignore b/.gitignore index c3027042dd..973ae09131 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,6 @@ testem.log # System Files .DS_Store Thumbs.db + +#Environment +.env \ No newline at end of file diff --git a/apps/angular-console/src/app/app.component.css b/apps/angular-console/src/app/app.component.css index 71c6609104..5a1b4f658e 100644 --- a/apps/angular-console/src/app/app.component.css +++ b/apps/angular-console/src/app/app.component.css @@ -3,3 +3,15 @@ height: 100vh; overflow: hidden; } + +mat-sidenav-container { + height: 100%; +} + +a { + background: rgba(0, 0, 0, 0) !important; +} + +a.active-link { + background: rgba(0, 0, 0, 0.12) !important; +} diff --git a/apps/angular-console/src/app/app.component.html b/apps/angular-console/src/app/app.component.html index 63c1c67b53..359de147aa 100644 --- a/apps/angular-console/src/app/app.component.html +++ b/apps/angular-console/src/app/app.component.html @@ -1,9 +1,25 @@ -
- + + + + +
+ + {{ link.icon }} + + {{ link.text }} +
+
+
+
+ +
+ -
- -
+
+ +
- -
+ +
+ + diff --git a/apps/angular-console/src/app/app.component.ts b/apps/angular-console/src/app/app.component.ts index 000a021819..55d699baa8 100644 --- a/apps/angular-console/src/app/app.component.ts +++ b/apps/angular-console/src/app/app.component.ts @@ -4,18 +4,20 @@ import { IMPORT_WORKSPACE, WORKSPACES } from '@angular-console/feature-workspaces'; -import { ContextualActionBarService, FADE_IN } from '@angular-console/ui'; +import { FADE_IN } from '@angular-console/ui'; +import { Settings } from '@angular-console/utils'; import { transition, trigger } from '@angular/animations'; -import { - ChangeDetectionStrategy, - Component, - OnInit, - ViewChild -} from '@angular/core'; +import { ChangeDetectionStrategy, Component, OnInit, ViewChild } from '@angular/core'; import { NavigationEnd, Router, RouterOutlet } from '@angular/router'; +import { AuthService, ContextualActionBarService } from '@nrwl/angular-console-enterprise-frontend'; import { Observable } from 'rxjs'; import { filter, map } from 'rxjs/operators'; -import { Settings } from '@angular-console/utils'; + +interface SidenavLink { + icon: string; + route: string; + text: string; +} @Component({ changeDetection: ChangeDetectionStrategy.OnPush, @@ -38,12 +40,25 @@ export class AppComponent implements OnInit { this.routerTransition = this.routerOutlet.activateEvents.pipe( map(() => this.routerOutlet.activatedRouteData.state) ); + this.authService.isAuthenticated$.subscribe(isAuthenticated => { + console.log('is authenticated?', isAuthenticated); + }); } + sidenavLinks: SidenavLink[] = [ + { icon: 'view_list', route: '/workspaces', text: 'Recent Workspaces' }, + { + icon: 'question_answer', + route: '/support', + text: 'Ask a Narwhal Engineer' + } + ]; + constructor( router: Router, public settings: Settings, - contextualActionBarService: ContextualActionBarService + contextualActionBarService: ContextualActionBarService, + private authService: AuthService ) { settings.fetch().subscribe(() => { this.settingsLoaded = true; diff --git a/apps/angular-console/src/app/app.module.ts b/apps/angular-console/src/app/app.module.ts index c0d774f451..5c7b9dd1b0 100644 --- a/apps/angular-console/src/app/app.module.ts +++ b/apps/angular-console/src/app/app.module.ts @@ -1,23 +1,13 @@ +import { FeatureWorkspacesModule, workspaceRoutes } from '@angular-console/feature-workspaces'; +import { UiModule } from '@angular-console/ui'; +import { AnalyticsCollector, CancelCommandGuard, Messenger } from '@angular-console/utils'; import { HttpClientModule } from '@angular/common/http'; import { NgModule } from '@angular/core'; -import { - MatIconModule, - MatIconRegistry, - MatSnackBarModule -} from '@angular/material'; +import { MatIconModule, MatIconRegistry, MatListModule, MatSidenavModule, MatSnackBarModule } from '@angular/material'; import { BrowserModule } from '@angular/platform-browser'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { RouterModule } from '@angular/router'; -import { - FeatureWorkspacesModule, - workspaceRoutes -} from '@angular-console/feature-workspaces'; -import { UiModule } from '@angular-console/ui'; -import { - AnalyticsCollector, - CancelCommandGuard, - Messenger -} from '@angular-console/utils'; +import { AngularConsoleEnterpriseFrontendModule, SupportComponent } from '@nrwl/angular-console-enterprise-frontend'; import { APOLLO_OPTIONS, ApolloModule } from 'apollo-angular'; import { HttpLink, HttpLinkModule } from 'apollo-angular-link-http'; import { InMemoryCache } from 'apollo-cache-inmemory'; @@ -64,6 +54,8 @@ export function initApollo( @NgModule({ declarations: [AppComponent], imports: [ + MatSidenavModule, + MatListModule, MatIconModule, MatSnackBarModule, BrowserModule, @@ -73,6 +65,7 @@ export function initApollo( HttpClientModule, FeatureWorkspacesModule, UiModule, + AngularConsoleEnterpriseFrontendModule.forRoot(), RouterModule.forRoot( [ { path: '', pathMatch: 'full', redirectTo: '/workspaces' }, @@ -80,6 +73,10 @@ export function initApollo( path: '', children: workspaceRoutes, canActivateChild: [CancelCommandGuard] + }, + { + path: 'support', + component: SupportComponent } ], { paramsInheritanceStrategy: 'always', initialNavigation: 'disabled' } diff --git a/apps/angular-console/src/assets/nrwl_background.svg b/apps/angular-console/src/assets/nrwl_background.svg new file mode 100644 index 0000000000..bb8fbef067 --- /dev/null +++ b/apps/angular-console/src/assets/nrwl_background.svg @@ -0,0 +1,49 @@ + + + + bgArt_footerPattern + Created with Sketch. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/apps/angular-console/src/assets/nrwl_logo.png b/apps/angular-console/src/assets/nrwl_logo.png new file mode 100644 index 0000000000..4d4e2bc7a0 Binary files /dev/null and b/apps/angular-console/src/assets/nrwl_logo.png differ diff --git a/libs/feature-extensions/src/lib/extension/extension.component.ts b/libs/feature-extensions/src/lib/extension/extension.component.ts index ba9ce8d1a6..d750839b4b 100644 --- a/libs/feature-extensions/src/lib/extension/extension.component.ts +++ b/libs/feature-extensions/src/lib/extension/extension.component.ts @@ -1,28 +1,13 @@ -import { - ChangeDetectionStrategy, - Component, - OnInit, - ViewChild -} from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; -import { - ContextualActionBarService, - TaskRunnerComponent, - TerminalComponent -} from '@angular-console/ui'; -import { CommandOutput, CommandRunner } from '@angular-console/utils'; import { Extension } from '@angular-console/schema'; +import { TaskRunnerComponent, TerminalComponent } from '@angular-console/ui'; +import { CommandOutput, CommandRunner } from '@angular-console/utils'; +import { ChangeDetectionStrategy, Component, OnInit, ViewChild } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { ContextualActionBarService } from '@nrwl/angular-console-enterprise-frontend'; import { Apollo } from 'apollo-angular'; import gql from 'graphql-tag'; import { BehaviorSubject, Observable, of, Subject } from 'rxjs'; -import { - map, - publishReplay, - refCount, - switchMap, - tap, - withLatestFrom -} from 'rxjs/operators'; +import { map, publishReplay, refCount, switchMap, tap, withLatestFrom } from 'rxjs/operators'; @Component({ changeDetection: ChangeDetectionStrategy.OnPush, diff --git a/libs/feature-generate/src/lib/schematic/schematic.component.ts b/libs/feature-generate/src/lib/schematic/schematic.component.ts index 60c4fdc3c0..5534846fa5 100644 --- a/libs/feature-generate/src/lib/schematic/schematic.component.ts +++ b/libs/feature-generate/src/lib/schematic/schematic.component.ts @@ -1,36 +1,13 @@ -import { - ChangeDetectionStrategy, - Component, - ElementRef, - OnInit, - ViewChild -} from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; -import { - ContextualActionBarService, - FlagsComponent, - TaskRunnerComponent, - TerminalComponent -} from '@angular-console/ui'; -import { - CommandOutput, - CommandRunner, - Serializer -} from '@angular-console/utils'; import { Schematic } from '@angular-console/schema'; +import { FlagsComponent, TaskRunnerComponent, TerminalComponent } from '@angular-console/ui'; +import { CommandOutput, CommandRunner, Serializer } from '@angular-console/utils'; +import { ChangeDetectionStrategy, Component, ElementRef, OnInit, ViewChild } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { ContextualActionBarService } from '@nrwl/angular-console-enterprise-frontend'; import { Apollo } from 'apollo-angular'; import gql from 'graphql-tag'; import { BehaviorSubject, merge, Observable, of, Subject } from 'rxjs'; -import { - debounceTime, - map, - publishReplay, - refCount, - startWith, - switchMap, - tap, - withLatestFrom -} from 'rxjs/operators'; +import { debounceTime, map, publishReplay, refCount, startWith, switchMap, tap, withLatestFrom } from 'rxjs/operators'; const DEBOUNCE_TIME = 300; diff --git a/libs/feature-run/src/lib/npmscript/npmscript.component.ts b/libs/feature-run/src/lib/npmscript/npmscript.component.ts index 114957812d..666685a088 100644 --- a/libs/feature-run/src/lib/npmscript/npmscript.component.ts +++ b/libs/feature-run/src/lib/npmscript/npmscript.component.ts @@ -1,33 +1,13 @@ -import { - Component, - ChangeDetectionStrategy, - OnInit, - ViewChild -} from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; -import { - ContextualActionBarService, - FlagsComponent, - TaskRunnerComponent, - TerminalComponent -} from '@angular-console/ui'; -import { - CommandOutput, - CommandRunner, - Serializer -} from '@angular-console/utils'; import { NpmScript } from '@angular-console/schema'; +import { FlagsComponent, TaskRunnerComponent, TerminalComponent } from '@angular-console/ui'; +import { CommandOutput, CommandRunner, Serializer } from '@angular-console/utils'; +import { ChangeDetectionStrategy, Component, OnInit, ViewChild } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { ContextualActionBarService } from '@nrwl/angular-console-enterprise-frontend'; import { Apollo } from 'apollo-angular'; import gql from 'graphql-tag'; import { BehaviorSubject, Observable, of, Subject } from 'rxjs'; -import { - map, - publishReplay, - refCount, - switchMap, - tap, - withLatestFrom -} from 'rxjs/operators'; +import { map, publishReplay, refCount, switchMap, tap, withLatestFrom } from 'rxjs/operators'; @Component({ changeDetection: ChangeDetectionStrategy.OnPush, diff --git a/libs/feature-run/src/lib/target/target.component.ts b/libs/feature-run/src/lib/target/target.component.ts index f2103b5811..0f2917c9ff 100644 --- a/libs/feature-run/src/lib/target/target.component.ts +++ b/libs/feature-run/src/lib/target/target.component.ts @@ -1,33 +1,13 @@ -import { - Component, - ChangeDetectionStrategy, - OnInit, - ViewChild -} from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; -import { - ContextualActionBarService, - FlagsComponent, - TaskRunnerComponent, - TerminalComponent -} from '@angular-console/ui'; -import { - CommandOutput, - CommandRunner, - Serializer -} from '@angular-console/utils'; import { Project } from '@angular-console/schema'; +import { FlagsComponent, TaskRunnerComponent, TerminalComponent } from '@angular-console/ui'; +import { CommandOutput, CommandRunner, Serializer } from '@angular-console/utils'; +import { ChangeDetectionStrategy, Component, OnInit, ViewChild } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { ContextualActionBarService } from '@nrwl/angular-console-enterprise-frontend'; import { Apollo } from 'apollo-angular'; import gql from 'graphql-tag'; import { BehaviorSubject, Observable, of, Subject } from 'rxjs'; -import { - map, - publishReplay, - refCount, - switchMap, - tap, - withLatestFrom -} from 'rxjs/operators'; +import { map, publishReplay, refCount, switchMap, tap, withLatestFrom } from 'rxjs/operators'; @Component({ changeDetection: ChangeDetectionStrategy.OnPush, diff --git a/libs/feature-workspaces/src/lib/import-workspace/import-workspace.component.ts b/libs/feature-workspaces/src/lib/import-workspace/import-workspace.component.ts index d5cf90d81d..d09f17ffcf 100644 --- a/libs/feature-workspaces/src/lib/import-workspace/import-workspace.component.ts +++ b/libs/feature-workspaces/src/lib/import-workspace/import-workspace.component.ts @@ -1,11 +1,10 @@ -import { Component, ChangeDetectionStrategy, OnDestroy } from '@angular/core'; -import { WorkspacesService } from '../workspaces.service'; -import { - DynamicFlatNode, - ContextualActionBarService -} from '@angular-console/ui'; +import { DynamicFlatNode } from '@angular-console/ui'; +import { ChangeDetectionStrategy, Component, OnDestroy } from '@angular/core'; +import { ContextualActionBarService } from '@nrwl/angular-console-enterprise-frontend'; import { Subject } from 'rxjs'; +import { WorkspacesService } from '../workspaces.service'; + @Component({ changeDetection: ChangeDetectionStrategy.OnPush, selector: 'angular-console-import-workspace', diff --git a/libs/feature-workspaces/src/lib/new-workspace/new-workspace.component.ts b/libs/feature-workspaces/src/lib/new-workspace/new-workspace.component.ts index 8e3fa185d2..2e077de9e4 100644 --- a/libs/feature-workspaces/src/lib/new-workspace/new-workspace.component.ts +++ b/libs/feature-workspaces/src/lib/new-workspace/new-workspace.component.ts @@ -1,31 +1,14 @@ -import { - ContextualActionBarService, - DynamicFlatNode -} from '@angular-console/ui'; -import { - Component, - OnInit, - QueryList, - ViewChildren, - ViewEncapsulation -} from '@angular/core'; +import { DynamicFlatNode } from '@angular-console/ui'; +import { Component, OnInit, QueryList, ViewChildren, ViewEncapsulation } from '@angular/core'; import { FormControl, FormGroup, Validators } from '@angular/forms'; import { MatDialog, MatExpansionPanel } from '@angular/material'; +import { ContextualActionBarService } from '@nrwl/angular-console-enterprise-frontend'; import { Apollo } from 'apollo-angular'; import gql from 'graphql-tag'; import { BehaviorSubject, Observable, Subject } from 'rxjs'; -import { - filter, - map, - publishReplay, - refCount, - switchMap -} from 'rxjs/operators'; - -import { - NewWorkspaceDialogComponent, - NgNewInvocation -} from './new-workspace-dialog.component'; +import { filter, map, publishReplay, refCount, switchMap } from 'rxjs/operators'; + +import { NewWorkspaceDialogComponent, NgNewInvocation } from './new-workspace-dialog.component'; interface SchematicCollectionForNgNew { name: string; diff --git a/libs/ui/src/index.ts b/libs/ui/src/index.ts index 85e2777a5e..ed0f2412ff 100644 --- a/libs/ui/src/index.ts +++ b/libs/ui/src/index.ts @@ -1,7 +1,6 @@ export * from './lib/ui.module'; export * from './lib/terminal/terminal.component'; export * from './lib/task-selector/task-selector.component'; -export * from './lib/contextual-action-bar/contextual-action-bar.service'; export * from './lib/contextual-action-bar/contextual-action-bar.component'; export * from './lib/task-runner/task-runner.component'; export * from './lib/flags/flags.component'; diff --git a/libs/ui/src/lib/contextual-action-bar/contextual-action-bar.component.html b/libs/ui/src/lib/contextual-action-bar/contextual-action-bar.component.html index 3a6d94ea36..7991a38302 100644 --- a/libs/ui/src/lib/contextual-action-bar/contextual-action-bar.component.html +++ b/libs/ui/src/lib/contextual-action-bar/contextual-action-bar.component.html @@ -1,9 +1,10 @@
- - Home - + +
{{ breadcrumb.title }} diff --git a/libs/ui/src/lib/contextual-action-bar/contextual-action-bar.component.scss b/libs/ui/src/lib/contextual-action-bar/contextual-action-bar.component.scss index a0e1ea98fc..400117c570 100644 --- a/libs/ui/src/lib/contextual-action-bar/contextual-action-bar.component.scss +++ b/libs/ui/src/lib/contextual-action-bar/contextual-action-bar.component.scss @@ -40,11 +40,8 @@ mat-toolbar.title-bar { padding: 0 12px; } - a.branding { - text-decoration: none; - position: relative; - left: -4px; - margin-right: 10px; + .hamburger-button { + margin-right: 12px; } // tslint:disable-next-line diff --git a/libs/ui/src/lib/contextual-action-bar/contextual-action-bar.component.ts b/libs/ui/src/lib/contextual-action-bar/contextual-action-bar.component.ts index 2c3b96ac83..4577c3835e 100644 --- a/libs/ui/src/lib/contextual-action-bar/contextual-action-bar.component.ts +++ b/libs/ui/src/lib/contextual-action-bar/contextual-action-bar.component.ts @@ -1,16 +1,7 @@ -import { - animate, - state, - style, - transition, - trigger -} from '@angular/animations'; -import { Component, ChangeDetectionStrategy } from '@angular/core'; -import { - ContextualActionBarService, - ContextualTab -} from './contextual-action-bar.service'; import { CommandRunner, Messenger } from '@angular-console/utils'; +import { animate, state, style, transition, trigger } from '@angular/animations'; +import { ChangeDetectionStrategy, Component, EventEmitter, Output } from '@angular/core'; +import { AuthService, ContextualActionBarService, ContextualTab } from '@nrwl/angular-console-enterprise-frontend'; @Component({ changeDetection: ChangeDetectionStrategy.OnPush, @@ -32,12 +23,23 @@ import { CommandRunner, Messenger } from '@angular-console/utils'; ] }) export class ContextualActionBarComponent { + @Output() hamburgerClicked = new EventEmitter(); + constructor( readonly contextualActionBarService: ContextualActionBarService, readonly commandRunner: CommandRunner, - readonly messenger: Messenger + readonly messenger: Messenger, + public readonly authService: AuthService ) {} + login() { + this.authService.auth(); + } + + logout() { + this.authService.unauth(); + } + trackByName(_: number, tab: ContextualTab) { return tab.name; } diff --git a/libs/ui/src/lib/contextual-action-bar/contextual-action-bar.service.ts b/libs/ui/src/lib/contextual-action-bar/contextual-action-bar.service.ts deleted file mode 100644 index 9f6360ad67..0000000000 --- a/libs/ui/src/lib/contextual-action-bar/contextual-action-bar.service.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { Injectable } from '@angular/core'; -import { BehaviorSubject, Subject } from 'rxjs'; - -export interface Breadcrumb { - title: string; -} - -export interface MenuOption { - name: string; - image: string; - invoke: () => void; -} - -export interface NonContextualAction { - name: string; - description: string; - icon: string; - options: Array; -} - -export interface ContextualAction { - name: string; - invoke: Subject; - disabled: Subject; -} - -export interface ContextualActions { - contextTitle: string; - actions: Array; -} - -export interface ContextualTab { - name: string; - icon: string; - routerLink: any[] | string; -} - -export interface ContextualTabs { - tabs: Array; -} - -@Injectable({ - providedIn: 'root' -}) -export class ContextualActionBarService { - readonly breadcrumbs$ = new BehaviorSubject>([]); - - readonly nonContextualActions$ = new BehaviorSubject< - Array - >([]); - - readonly contextualActions$ = new Subject(); - - readonly contextualTabs$ = new BehaviorSubject(null); -} diff --git a/libs/ui/src/lib/task-selector/task-selector.component.ts b/libs/ui/src/lib/task-selector/task-selector.component.ts index a3fee74ef5..c9fb5699e4 100644 --- a/libs/ui/src/lib/task-selector/task-selector.component.ts +++ b/libs/ui/src/lib/task-selector/task-selector.component.ts @@ -1,25 +1,10 @@ -import { - animate, - state, - style, - transition, - trigger -} from '@angular/animations'; -import { - Component, - EventEmitter, - Input, - OnDestroy, - OnInit, - ChangeDetectionStrategy, - Output -} from '@angular/core'; +import { animate, state, style, transition, trigger } from '@angular/animations'; +import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core'; import { FormControl } from '@angular/forms'; +import { ContextualActionBarService } from '@nrwl/angular-console-enterprise-frontend'; import { combineLatest, Observable, Subject } from 'rxjs'; import { map, startWith, take } from 'rxjs/operators'; -import { ContextualActionBarService } from '../contextual-action-bar/contextual-action-bar.service'; - export interface Task { taskName: string; taskDescription?: string; diff --git a/libs/ui/src/lib/ui.module.ts b/libs/ui/src/lib/ui.module.ts index ae602149bf..60f7dd7b9b 100644 --- a/libs/ui/src/lib/ui.module.ts +++ b/libs/ui/src/lib/ui.module.ts @@ -1,19 +1,8 @@ +import { CdkTreeModule } from '@angular/cdk/tree'; import { CommonModule } from '@angular/common'; -import { DomSanitizer } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; -import { ReactiveFormsModule } from '@angular/forms'; -import { RouterModule } from '@angular/router'; - -import { ContextualActionBarComponent } from './contextual-action-bar/contextual-action-bar.component'; -import { ContextualActionBarService } from './contextual-action-bar/contextual-action-bar.service'; -import { DirectorySelectorComponent } from './directory-selector/directory-selector.component'; -import { FlagsComponent } from './flags/flags.component'; -import { TaskRunnerComponent } from './task-runner/task-runner.component'; -import { TaskSelectorComponent } from './task-selector/task-selector.component'; -import { TerminalComponent } from './terminal/terminal.component'; - -import { CdkTreeModule } from '@angular/cdk/tree'; import { FlexLayoutModule } from '@angular/flex-layout'; +import { ReactiveFormsModule } from '@angular/forms'; import { MatAutocompleteModule, MatButtonModule, @@ -24,6 +13,7 @@ import { MatIconRegistry, MatInputModule, MatListModule, + MatMenuModule, MatOptionModule, MatRadioModule, MatRippleModule, @@ -33,11 +23,19 @@ import { MatTabsModule, MatToolbarModule, MatTooltipModule, - MatTreeModule, - MatMenuModule + MatTreeModule } from '@angular/material'; -import { NormalizePathPipe } from './normalize-path.pipe'; +import { DomSanitizer } from '@angular/platform-browser'; +import { RouterModule } from '@angular/router'; + +import { ContextualActionBarComponent } from './contextual-action-bar/contextual-action-bar.component'; import { DataCollectionComponent } from './data-collection/data-collection.component'; +import { DirectorySelectorComponent } from './directory-selector/directory-selector.component'; +import { FlagsComponent } from './flags/flags.component'; +import { NormalizePathPipe } from './normalize-path.pipe'; +import { TaskRunnerComponent } from './task-runner/task-runner.component'; +import { TaskSelectorComponent } from './task-selector/task-selector.component'; +import { TerminalComponent } from './terminal/terminal.component'; const IMPORTS = [ MatMenuModule, @@ -97,7 +95,6 @@ const IMPORTS = [ NormalizePathPipe, DataCollectionComponent ], - providers: [ContextualActionBarService], exports: [ ...IMPORTS, ContextualActionBarComponent, diff --git a/package.json b/package.json index 016e328b29..503aa14471 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,8 @@ "@angular/platform-browser": "6.1.1", "@angular/platform-browser-dynamic": "6.1.1", "@angular/router": "6.1.1", + "@nrwl/angular-console-enterprise-electron": "0.0.1", + "@nrwl/angular-console-enterprise-frontend": "0.0.1", "@nrwl/schematics": "6.2.1", "@types/express": "^4.16.0", "@types/graphql": "0.13.0", @@ -98,6 +100,7 @@ "codelyzer": "~4.4.3", "core-js": "^2.5.7", "cypress": "3.0.3", + "dotenv": "6.0.0", "drivelist": "6.3.0", "electron": "2.0.8", "electron-builder": "20.28.4", diff --git a/server/package.json b/server/package.json index b41f3678c1..6882d28af3 100644 --- a/server/package.json +++ b/server/package.json @@ -11,6 +11,7 @@ "dependencies": { "@angular/cli": "6.1.2", "@ngrx/schematics": "6.1.0", + "@nrwl/angular-console-enterprise-electron": "0.0.1", "@nrwl/schematics": "6.2.1", "drivelist": "6.3.0", "electron-updater": "^3.0.3", diff --git a/server/src/schema/resolvers.ts b/server/src/schema/resolvers.ts index 265e90c201..46bf98c048 100644 --- a/server/src/schema/resolvers.ts +++ b/server/src/schema/resolvers.ts @@ -1,3 +1,4 @@ +import { authUtils } from '@nrwl/angular-console-enterprise-electron'; import * as path from 'path'; import { SchematicCollectionResolvers, @@ -19,9 +20,9 @@ import { cacheFiles } from '../utils'; import { + completeAbsoluteModules, completeFiles, completeLocalModules, - completeAbsoluteModules, completeProjects } from '../api/completions'; @@ -31,12 +32,6 @@ import { readSchema, readDescription } from '../api/read-projects'; -import { availableExtensions, readExtensions } from '../api/read-extensions'; -import { readDependencies } from '../api/read-dependencies'; -import { schematicCollectionsForNgNew } from '../api/read-ngnews'; -import { openInEditor, readEditors } from '../api/read-editors'; -import { readNpmScripts, readNpmScriptSchema } from '../api/read-npm-scripts'; -import { readDirectory } from '../api/read-directory'; import { commandInProgress, runCommand, @@ -44,6 +39,13 @@ import { } from '../api/commands'; import { storeSettings, readSettings } from '../api/read-settings'; +import { openInEditor, readEditors } from '../api/read-editors'; +import { readDirectory } from '../api/read-directory'; +import { availableExtensions, readExtensions } from '../api/read-extensions'; +import { readNpmScriptSchema, readNpmScripts } from '../api/read-npm-scripts'; +import { schematicCollectionsForNgNew } from '../api/read-ngnews'; +import { readDependencies } from '../api/read-dependencies'; + const SchematicCollection: SchematicCollectionResolvers.Resolvers = { schematics(collection: any, args: any) { return filterByName(collection.schematics, args); @@ -282,6 +284,33 @@ const Mutation: MutationResolvers.Resolvers = { updateSettings(_root: any, args: any) { storeSettings(JSON.parse(args.data)); return readSettings(); + }, + async authenticate(_root: any, _args: any) { + try { + const authResult = await authUtils.authenticate(); + authUtils.setSession(authResult); + return { response: 'Success' }; + } catch (e) { + console.log(e); + if (e.message === 'Auth window closed') { + return { response: 'Not authed' }; + } + authUtils.clearSession(); + throw new Error( + `Error when attempting to authenticate. Message: "${e.message}"` + ); + } + }, + async unauthenticate(_root: any, _args: any) { + try { + authUtils.clearSession(); + return { response: 'Success' }; + } catch (e) { + console.log(e); + throw new Error( + `Error when attempting to unauthenticate. Message: "${e.message}"` + ); + } } }; diff --git a/yarn.lock b/yarn.lock index 896c0020a3..f451b37da6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -281,6 +281,16 @@ tree-kill "^1.0.0" webpack-sources "^1.1.0" +"@nrwl/angular-console-enterprise-electron@file:../angular-console-nrwl-extensions/dist/libs/angular-console-enterprise-electron": + version "0.0.1" + dependencies: + tslib "^1.9.0" + +"@nrwl/angular-console-enterprise-frontend@file:../angular-console-nrwl-extensions/dist/libs/angular-console-enterprise-frontend": + version "0.0.1" + dependencies: + tslib "^1.9.0" + "@nrwl/nx@6.2.1": version "6.2.1" resolved "https://registry.yarnpkg.com/@nrwl/nx/-/nx-6.2.1.tgz#b75a5c35bab53675a89320e1d8d16f40b70e66d1" @@ -3244,7 +3254,7 @@ dotenv-expand@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/dotenv-expand/-/dotenv-expand-4.2.0.tgz#def1f1ca5d6059d24a766e587942c21106ce1275" -dotenv@^6.0.0: +dotenv@6.0.0, dotenv@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-6.0.0.tgz#24e37c041741c5f4b25324958ebbc34bca965935"