Skip to content

Commit

Permalink
feat: drop list
Browse files Browse the repository at this point in the history
  • Loading branch information
meta-d committed Feb 1, 2024
1 parent b5e92bf commit 534efa7
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 17 deletions.
15 changes: 9 additions & 6 deletions apps/cloud/src/app/features/features.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</pac-menu>
</mat-sidenav>

<mat-sidenav-content class="pac_sidenav-content max-h-full overflow-hidden" >
<mat-sidenav-content class="pac_sidenav-content max-h-full overflow-hidden" cdkDropListGroup>
<mat-toolbar class="pac__shell-bar mat-elevation-z2 flex justify-between items-center md:gap-2">
<div class="flex justify-start items-center overflow-hidden">
<button *ngIf="!(sidenav.opened && sidenavMode==='side')" class="w-12 outline-none hover:text-yellow-600 transition-colors"
Expand Down Expand Up @@ -104,7 +104,10 @@
</button>
</mat-toolbar>

<mat-drawer-container class="flex-1 h-full" [ngClass]="{'pac-fullscreen': fullscreenIndex$() > 1}" [hasBackdrop]="false" autosize>
<mat-drawer-container class="flex-1 h-full" [ngClass]="{'pac-fullscreen': fullscreenIndex$() > 1}"
[hasBackdrop]="false"
autosize
>
<mat-drawer #copilotDrawer class="mat-elevation-z" position="end" mode="side" ngmResizer [resizerWidth]="380"
[(opened)]="copilotDrawerOpened"
>
Expand All @@ -113,6 +116,7 @@
assistantAvatar="assets/images/copilot_sparkle_resting.gif"
[user]="user$()"
cdkDropList
(cdkDropListDropped)="dropCopilot($event)"
(enableCopilot)="toEnableCopilot()"
></ngm-copilot-chat>
}
Expand All @@ -123,12 +127,11 @@
></div>
</mat-drawer>
<mat-drawer-content class="pac-app__page-outlet relative z-0"
[@routeAnimations]="o.isActivated && o.activatedRoute.routeConfig.data && o.activatedRoute.routeConfig.data.title">
<router-outlet #o="outlet"></router-outlet>

[@routeAnimations]="o.isActivated && o.activatedRoute.routeConfig?.data?.title">
@if(copilotEnabled$()) {
<ngm-drawer-trigger class="absolute -right-2 top-1/2 -translate-y-1/2 z-40" [(opened)]="copilotDrawerOpened" side="right"></ngm-drawer-trigger>
<ngm-drawer-trigger class="absolute -right-2 top-1/2 -translate-y-1/2 z-40" [(opened)]="copilotDrawerOpened" side="right"></ngm-drawer-trigger>
}
<router-outlet #o="outlet"></router-outlet>
</mat-drawer-content>
</mat-drawer-container>

Expand Down
30 changes: 23 additions & 7 deletions apps/cloud/src/app/features/features.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Location } from '@angular/common'
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit, Renderer2, ViewChild } from '@angular/core'
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, DestroyRef, OnInit, Renderer2, ViewChild, inject } from '@angular/core'
import { MatDialog } from '@angular/material/dialog'
import {
Event,
Expand All @@ -10,7 +10,6 @@ import {
Router,
RouterEvent
} from '@angular/router'
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'
import { TranslateService } from '@ngx-translate/core'
import { PacMenuItem } from '@metad/cloud/auth'
import { UsersService } from '@metad/cloud/state'
Expand Down Expand Up @@ -42,10 +41,11 @@ import { QueryCreationDialogComponent } from './semantic-model/query-creation.co
import { ModelCreationComponent } from './semantic-model/creation/creation.component'
import { StoryCreationComponent } from '../@shared'
import { MatDrawerMode, MatSidenav } from '@angular/material/sidenav'
import { toSignal } from '@angular/core/rxjs-interop'
import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop'
import { CdkDragDrop } from '@angular/cdk/drag-drop'
import { NgmCopilotChatComponent } from '@metad/ocap-angular/copilot'


@UntilDestroy({ checkProperties: true })
@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
selector: 'pac-features',
Expand All @@ -58,8 +58,11 @@ export class FeaturesComponent implements OnInit {
NgxPopperjsTriggers = NgxPopperjsTriggers
NgxPopperjsPlacements = NgxPopperjsPlacements
AbilityActions = AbilityActions

readonly #destroyRef = inject(DestroyRef)

@ViewChild('sidenav') sidenav: MatSidenav
@ViewChild('copilotChat') copilotChat!: NgmCopilotChatComponent

sidenavMode = 'over' as MatDrawerMode
isEmployee: boolean
Expand Down Expand Up @@ -137,13 +140,12 @@ export class FeaturesComponent implements OnInit {
loading = false
isDark$ = this.appService.isDark$

// public readonly copilotEnabled$ = this.appService.copilotEnabled$
readonly copilotEnabled$ = toSignal(this.appService.copilotEnabled$)

copilotDrawerOpened = false

// Is mobile event listener
private _isMobileSub = this.appService.isMobile$.subscribe((isMobile) => {
private _isMobileSub = this.appService.isMobile$.pipe(takeUntilDestroyed()).subscribe((isMobile) => {
this.isMobile = isMobile
if (isMobile) {
this.isCollapsedHidden = isMobile
Expand All @@ -152,6 +154,7 @@ export class FeaturesComponent implements OnInit {
private _userSub = this.store.user$
.pipe(
filter((user: IUser) => !!user),
takeUntilDestroyed()
)
.subscribe((value) => {
this.checkForEmployee()
Expand Down Expand Up @@ -196,7 +199,7 @@ export class FeaturesComponent implements OnInit {
map((permissions) => permissions.map(({ permission }) => permission)),
tap((permissions) => this.ngxPermissionsService.loadPermissions(permissions)),
combineLatestWith(this.translateService.onLangChange.pipe(startWith(null))),
untilDestroyed(this)
takeUntilDestroyed(this.#destroyRef)
)
.subscribe(([permissions]) => {
this.menu = this.getMenuItems()
Expand Down Expand Up @@ -733,4 +736,17 @@ export class FeaturesComponent implements OnInit {
toEnableCopilot() {
this.router.navigate(['settings', 'copilot'])
}

/**
* Drop data on copilot chat:
* 1. table schema
* 2. table data
* 3. name of data
*
* @param event
*/
async dropCopilot(event: CdkDragDrop<any[], any[], any>) {
const data = event.item.data
console.log(event)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

</mat-toolbar>

<mat-drawer-container class="flex-1" [hasBackdrop]="false" autosize cdkDropListGroup>
<mat-drawer-container class="flex-1" [hasBackdrop]="false" autosize>
<mat-drawer #drawer class="ngm-story__designer-drawer mat-elevation-z"
[(opened)]="sideMenuOpened"
[mode]="(isMobile$ | async) ? 'over' : 'side'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
display: flex;
flex-direction: column;
flex: 1;
position: absolute;
top: 0;
left: 0;
// position: absolute;
// top: 0;
// left: 0;
width: 100%;
max-width: 100%;
height: 100%;
Expand Down

0 comments on commit 534efa7

Please sign in to comment.