Open Closed

How to implement package as project #3530


User avatar
0
ldacnfinit created
  • ABP Framework version: v5.3.3
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): Identity Server Separated (Angular)
  • Exception message and stack trace:

index.js:561 [webpack-dev-server] ERROR projects/file-management/src/lib/components/file-management-directory-tree/file-management-directory-tree.component.html:4:9 - error NG8007: The property and event halves of the two-way binding 'nodes' are not bound to the same target. Find more at https://angular.io/guide/two-way-binding#how-two-way-binding-works

4 [(nodes)]="directories" ~~~~~

node_modules/@abp/ng.components/tree/lib/components/tree.component.d.ts:10:22 10 export declare class TreeComponent { ~~~~~~~~~~~~~ The property half of the binding is to the 'TreeComponent' component. projects/file-management/src/lib/components/file-management-directory-tree/file-management-directory-tree.component.ts:1:51 1 import { SubscriptionService, TreeNode } from '@abp/ng.core'; ~~~~~~~~ The event half of the binding is to a native event called 'nodes' on the <abp-tree> DOM element.

Are you missing an output declaration called 'nodesChange'? projects/file-management/src/lib/components/file-management-directory-tree/file-management-directory-tree.component.ts:22:16 22 templateUrl: './file-management-directory-tree.component.html', ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Error occurs in the template of component FileManagementDirectoryTreeComponent.

logger @ index.js:561 (anonymous) @ index.js:731 error @ index.js:180 errors @ index.js:246 (anonymous) @ socket.js:57 client.onmessage @ WebSocketClient.js:50 index.js:561 [webpack-dev-server] ERROR projects/file-management/src/lib/components/file-management-directory-tree/file-management-directory-tree.component.html:7:26 - error TS2345: Argument of type 'DropEvent' is not assignable to parameter of type '{ dragNode: NzTreeNode; node: NzTreeNode; }'. Property 'dragNode' is optional in type 'DropEvent' but required in type '{ dragNode: NzTreeNode; node: NzTreeNode; }'.

7 (dropOver)="onDrop($event)" ~~~~~~

projects/file-management/src/lib/components/file-management-directory-tree/file-management-directory-tree.component.ts:22:16 22 templateUrl: './file-management-directory-tree.component.html', ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Error occurs in the template of component FileManagementDirectoryTreeComponent.

  • Steps to reproduce the issue:" Hi, I don't know how to implement module as project, for example file management module.
  • Add package as project by suite
  • Solve building errors
  • Add routing setting app-routing.module.ts
{
    path: 'file-management',
    loadChildren: () =>
      import('../../projects/file-management/src/lib/file-management.module').then(m =>
        m.FileManagementModule.forLazy()
      ),
},
  • run yarn in the projects/file-management folder

I have read some article about this topic in docs.api.io, but I still don't know what should I do, pls help me, thank you in advance!


5 Answer(s)
  • User Avatar
    0
    muhammedaltug created

    Hello,

    Please don't use the yarn command in the packages folder. It should be one node_modules folder in an angular project. Do not import with relative path in app-routing.module.ts please define a tsconfig path with the following code.

    //tsconfig.json
    {
        "compilerOptions": {
            "paths": {
                //...other paths
                "@volo/abp.ng.file-management": "projects/file-management/src/public-api.ts"
            }
        }
    }
    

    And change your routing with the following code

    {
        path: 'file-management',
        loadChildren: () =>
          import('@volo/abp.ng.file-management').then(m =>
            m.FileManagementModule.forLazy()
          ),
    },
    

    Remove the node_modules folder which placed in projects/file-management

    You can read the documentation about "How to Add a Feature Library to Your Project"

  • User Avatar
    0
    ldacnfinit created

    Hi, I have build the project success, but I got a error is like this when I visit the file management page:

    [15:57:54 ERR] Failed executing DbCommand (2ms) [Parameters=[@__ef_filter__p_0='?' (DbType = Boolean)], CommandType='Text', CommandTimeout='30']
    SELECT COUNT(*)
    FROM [FmDirectoryDescriptors] AS [f]
    WHERE ((@__ef_filter__p_0 = CAST(1 AS bit)) OR ([f].[TenantId] IS NULL)) AND ([f].[ParentId] IS NULL)
    [15:57:54 ERR] An exception occurred while iterating over the results of a query for context type 'Volo.FileManagement.EntityFrameworkCore.FileManagementDbContext'.
    Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid object name 'FmDirectoryDescriptors'.
       at Microsoft.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__188_0(Task`1 result)
       at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
    --- End of stack trace from previous location ---
       at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
    --- End of stack trace from previous location ---
       at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
       at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
       at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken)
       at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
       at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
    ClientConnectionId:b5ccd131-29d0-416a-a46e-8262476988b0
    Error Number:208,State:1,Class:16
    
    

    It seem looks like the database don't have specified FmDirectoryDescriptors table/entity, but when I use dotnet ef migrations xxx , and I got nothing migration script, what I should to do to generate FmDirectoryDescriptors table/entity? PS: This entity's name looks like strange.

  • User Avatar
    0
    enisn created
    Support Team .NET Developer

    Hi, I have build the project success, but I got a error is like this when I visit the file management page:

    [15:57:54 ERR] Failed executing DbCommand (2ms) [Parameters=[@__ef_filter__p_0='?' (DbType = Boolean)], CommandType='Text', CommandTimeout='30'] 
    SELECT COUNT(*) 
    FROM [FmDirectoryDescriptors] AS [f] 
    WHERE ((@__ef_filter__p_0 = CAST(1 AS bit)) OR ([f].[TenantId] IS NULL)) AND ([f].[ParentId] IS NULL) 
    [15:57:54 ERR] An exception occurred while iterating over the results of a query for context type 'Volo.FileManagement.EntityFrameworkCore.FileManagementDbContext'. 
    Microsoft.Data.SqlClient.SqlException (0x80131904): Invalid object name 'FmDirectoryDescriptors'. 
       at Microsoft.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__188_0(Task`1 result) 
       at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke() 
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) 
    --- End of stack trace from previous location --- 
       at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) 
    --- End of stack trace from previous location --- 
       at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) 
       at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken) 
       at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken) 
       at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken) 
       at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync() 
    ClientConnectionId:b5ccd131-29d0-416a-a46e-8262476988b0 
    Error Number:208,State:1,Class:16 
     
    

    It seem looks like the database don't have specified FmDirectoryDescriptors table/entity, but when I use dotnet ef migrations xxx , and I got nothing migration script, what I should to do to generate FmDirectoryDescriptors table/entity? PS: This entity's name looks like strange.

    It seems your database wasn't updated. Did you install FileManagement module via ABP CLI/Suite or just installed manually?

    Make sure you've added builder.ConfigureFileManagement() method in your DbContext before adding migration

  • User Avatar
    0
    ldacnfinit created

    It seems your database wasn't updated. Did you install FileManagement module via ABP CLI/Suite or just installed manually? Make sure you've added builder.ConfigureFileManagement() method in your DbContext before adding migration

    Yes, I install FileManangement module via ABP Suite, and builder.ConfigureFileManagement() is added to DbContext, like below screen:

    But I guess your refer DbContext maybe is Volo.FileManagement.EntityFrameworkCore.FileManagementDbContext? If is it, so I should run dotnet ef database migrations xxx in Volo.FileManagement.EntityFrameworkCore?

  • User Avatar
    0
    ldacnfinit created

    Sorry, I make a mistake, It's stupid, I forget run dotnet ef database update command.

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11