diff --git a/common/ASC.Api.Core/ASC.Api.Core.csproj b/common/ASC.Api.Core/ASC.Api.Core.csproj index 70bbadfa74..9505d7d0c3 100644 --- a/common/ASC.Api.Core/ASC.Api.Core.csproj +++ b/common/ASC.Api.Core/ASC.Api.Core.csproj @@ -8,8 +8,13 @@ + + + + + diff --git a/common/ASC.Api.Core/Core/CustomApiAttribute.cs b/common/ASC.Api.Core/Core/CustomApiAttribute.cs deleted file mode 100644 index 1e1b92ac4f..0000000000 --- a/common/ASC.Api.Core/Core/CustomApiAttribute.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace ASC.Api.Core -{ - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - public class CustomApiAttribute : Attribute - { - } -} diff --git a/common/ASC.Common/DependencyInjection/AutofacExtension.cs b/common/ASC.Common/DependencyInjection/AutofacExtension.cs new file mode 100644 index 0000000000..ed18b1c17f --- /dev/null +++ b/common/ASC.Common/DependencyInjection/AutofacExtension.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using Autofac; +using Autofac.Configuration; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; + +namespace ASC.Common.DependencyInjection +{ + internal class AutofacComponent + { + public string Type { get; set; } + public IEnumerable Services { get; set; } + } + internal class AutofacService + { + public string Type { get; set; } + } + + public static class AutofacExtension + { + public static IContainer AddAutofac(this IServiceCollection services, IConfiguration configuration) + { + var sectionSettings = configuration.GetSection("components"); + + var cs = new List(); + sectionSettings.Bind(cs); + + var currentDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + + foreach (var component in cs) + { + try + { + LoadAssembly(component.Type); + + foreach (var s in component.Services) + { + LoadAssembly(s.Type); + } + } + catch (System.Exception) + { + //TODO + } + } + + + var module = new ConfigurationModule(configuration); + var builder = new ContainerBuilder(); + builder.RegisterModule(module); + + var container = builder.Build(); + + services.AddSingleton(container); + + return container; + + void LoadAssembly(string type) + { + var path = Path.Combine(currentDir, type.Substring(type.IndexOf(",") + 1).Trim()); + Assembly.LoadFrom($"{path}.dll"); + } + } + } +} diff --git a/common/ASC.Common/Logging/Log.cs b/common/ASC.Common/Logging/Log.cs index 18e397093c..fbdadd71d2 100644 --- a/common/ASC.Common/Logging/Log.cs +++ b/common/ASC.Common/Logging/Log.cs @@ -785,18 +785,9 @@ namespace ASC.Common.Logging public static class LogExtension { - public static IServiceCollection AddLogManager(this IServiceCollection services, IConfiguration configuration) + public static IServiceCollection AddLogManager(this IServiceCollection services) { - var module = new ConfigurationModule(configuration); - var builder = new ContainerBuilder(); - builder.RegisterModule(module); - - var container = builder.Build(); - - services.AddSingleton(container) - .AddSingleton(); - - return services; + return services.AddSingleton(); } } } diff --git a/common/ASC.Data.Storage/Configuration/Appender.cs b/common/ASC.Data.Storage/Configuration/Appender.cs index b30a9ca57a..cc6bd85536 100644 --- a/common/ASC.Data.Storage/Configuration/Appender.cs +++ b/common/ASC.Data.Storage/Configuration/Appender.cs @@ -2,17 +2,15 @@ using System.Collections.Generic; using System.Linq; using ASC.Common.Utils; +using Microsoft.Extensions.DependencyInjection; namespace ASC.Data.Storage.Configuration { public static class StorageConfigFactory { - public static Storage Instance + public static IServiceCollection AddStorage(this IServiceCollection services) { - get - { - return ConfigurationManager.GetSetting("Storage"); - } + return services.AddSingleton(r => ConfigurationManager.GetSetting("Storage")); } } diff --git a/common/ASC.Data.Storage/S3/S3UploadGuard.cs b/common/ASC.Data.Storage/S3/S3UploadGuard.cs index 46d7ce66fe..9c31b20efa 100644 --- a/common/ASC.Data.Storage/S3/S3UploadGuard.cs +++ b/common/ASC.Data.Storage/S3/S3UploadGuard.cs @@ -30,8 +30,8 @@ using System.Threading.Tasks; using Amazon; using Amazon.S3; using Amazon.S3.Model; +using ASC.Common.DependencyInjection; using ASC.Core; -using ASC.Data.Storage.Configuration; namespace ASC.Data.Storage.S3 { @@ -121,7 +121,7 @@ namespace ASC.Data.Storage.S3 { if (!configured) { - var config = StorageConfigFactory.Instance; + var config = CommonServiceProvider.GetService(); var handler = config.GetHandler("s3"); if (handler != null) { diff --git a/common/ASC.Data.Storage/StorageFactory.cs b/common/ASC.Data.Storage/StorageFactory.cs index cf10bbf2dc..8f020df90f 100644 --- a/common/ASC.Data.Storage/StorageFactory.cs +++ b/common/ASC.Data.Storage/StorageFactory.cs @@ -26,8 +26,6 @@ using System; using System.Collections.Generic; -using System.Configuration; -using System.IO; using System.Linq; using ASC.Common.Caching; @@ -35,8 +33,6 @@ using ASC.Core; using ASC.Data.Storage.Configuration; using ASC.Core.Common.Configuration; using ASC.Data.Storage.DiscStorage; - -using Microsoft.AspNetCore.Builder; using ASC.Common.DependencyInjection; using Microsoft.AspNetCore.Routing; @@ -83,7 +79,7 @@ namespace ASC.Data.Storage var store = DataStoreCache.Get(tenant, module); if (store == null) { - var section = StorageConfigFactory.Instance; + var section = CommonServiceProvider.GetService(); if (section == null) { throw new InvalidOperationException("config section not found"); @@ -103,7 +99,7 @@ namespace ASC.Data.Storage //Make tennant path tenant = TennantPath.CreatePath(tenant); - var section = StorageConfigFactory.Instance; + var section = CommonServiceProvider.GetService(); if (section == null) { throw new InvalidOperationException("config section not found"); @@ -116,7 +112,7 @@ namespace ASC.Data.Storage public static IEnumerable GetModuleList(string configpath, bool exceptDisabledMigration = false) { - var section = StorageConfigFactory.Instance; + var section = CommonServiceProvider.GetService(); return section.Module .Where(x => x.Visible) .Where(x=> !exceptDisabledMigration || !x.DisableMigrate) @@ -125,7 +121,7 @@ namespace ASC.Data.Storage public static IEnumerable GetDomainList(string configpath, string modulename) { - var section = StorageConfigFactory.Instance; + var section = CommonServiceProvider.GetService(); if (section == null) { throw new ArgumentException("config section not found"); @@ -146,7 +142,7 @@ namespace ASC.Data.Storage // throw new InvalidOperationException("Application not hosted."); //} - var section = StorageConfigFactory.Instance; + var section = CommonServiceProvider.GetService(); if (section != null) { //old scheme @@ -224,7 +220,7 @@ namespace ASC.Data.Storage private static IDataStore GetDataStore(string tenant, string module, DataStoreConsumer consumer, IQuotaController controller) { - var storage = StorageConfigFactory.Instance; + var storage = CommonServiceProvider.GetService(); var moduleElement = storage.GetModuleElement(module); if (moduleElement == null) { diff --git a/common/ASC.Data.Storage/WebPath.cs b/common/ASC.Data.Storage/WebPath.cs index 8fb0ae88bb..8a5bcfb134 100644 --- a/common/ASC.Data.Storage/WebPath.cs +++ b/common/ASC.Data.Storage/WebPath.cs @@ -46,7 +46,7 @@ namespace ASC.Data.Storage static WebPath() { - var section = StorageConfigFactory.Instance; + var section = CommonServiceProvider.GetService(); if (section != null) { Appenders = section.Appender; diff --git a/products/ASC.People/ASC.People.csproj b/products/ASC.People/ASC.People.csproj index bf5124462d..af8bac2127 100644 --- a/products/ASC.People/ASC.People.csproj +++ b/products/ASC.People/ASC.People.csproj @@ -8,6 +8,10 @@ ClientApp\ $(DefaultItemExcludes);$(SpaRoot)node_modules\** true + ASC.People + Ascensio System SIA + ASC.People + (c) Ascensio System SIA. All rights reserved @@ -25,8 +29,7 @@ - - + diff --git a/products/ASC.People/AssemblyInfo.cs b/products/ASC.People/AssemblyInfo.cs deleted file mode 100644 index 235582bfd6..0000000000 --- a/products/ASC.People/AssemblyInfo.cs +++ /dev/null @@ -1,4 +0,0 @@ - -using ASC.Api.Core; - -[assembly: CustomApi] diff --git a/products/ASC.People/PeopleProduct.cs b/products/ASC.People/PeopleProduct.cs new file mode 100644 index 0000000000..a2a379aedd --- /dev/null +++ b/products/ASC.People/PeopleProduct.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using ASC.Web.Core; + +namespace ASC.People +{ + public class PeopleProduct : Product + { + internal const string ProductPath = "/products/people/"; + + private ProductContext _context; + + public static Guid ID + { + get { return new Guid("{F4D98AFD-D336-4332-8778-3C6945C81EA0}"); } + } + + public override bool Visible { get { return true; } } + + public override ProductContext Context + { + get { return _context; } + } + + public override string Name + { + get { return "People"; }//PeopleResource.ProductName; } + } + + public override string Description + { + get { return "People Description"; }//PeopleResource.ProductDescription; } + } + + public override string ExtendedDescription + { + get { return "People ExtendedDescription"; }//PeopleResource.ProductDescription; } + } + + public override Guid ProductID + { + get { return ID; } + } + + public override string StartURL + { + get { return ProductPath; } + } + + public override string HelpURL + { + get { return string.Concat(ProductPath, "help.aspx"); } + } + + public override string ProductClassName + { + get { return "people"; } + } + + public override void Init() + { + _context = new ProductContext + { + DisabledIconFileName = "product_disabled_logo.png", + IconFileName = "product_logo.png", + LargeIconFileName = "images/people_logolarge.png", + DefaultSortOrder = 50, + AdminOpportunities = () => new List(),//PeopleResource.ProductAdminOpportunities.Split('|').ToList(), + UserOpportunities = () => new List() //PeopleResource.ProductUserOpportunities.Split('|').ToList() + }; + + //SearchHandlerManager.Registry(new SearchHandler()); + } + } +} diff --git a/web/ASC.Web.Api/ASC.Web.Api.csproj b/web/ASC.Web.Api/ASC.Web.Api.csproj index 0aadaaf538..b0f21be3c0 100644 --- a/web/ASC.Web.Api/ASC.Web.Api.csproj +++ b/web/ASC.Web.Api/ASC.Web.Api.csproj @@ -14,6 +14,7 @@ + diff --git a/web/ASC.Web.Api/Controllers/ModulesController.cs b/web/ASC.Web.Api/Controllers/ModulesController.cs index 87764d9602..73c2bcb286 100644 --- a/web/ASC.Web.Api/Controllers/ModulesController.cs +++ b/web/ASC.Web.Api/Controllers/ModulesController.cs @@ -1,8 +1,10 @@ using System.Collections.Generic; using ASC.Web.Api.Models; using ASC.Web.Api.Routing; +using ASC.Web.Core; +using ASC.Web.Core.WebZones; using Microsoft.AspNetCore.Mvc; - + namespace ASC.Web.Api.Controllers { [DefaultRoute] @@ -13,8 +15,8 @@ namespace ASC.Web.Api.Controllers [FormatIndexRoute()] [FormatIndexRoute(false)] public IEnumerable GetAll() - { - return new List { + { + var result = new List(){ new Module { Title = "Documents", Link = "/products/files/", @@ -37,17 +39,25 @@ namespace ASC.Web.Api.Controllers Link = "/products/mail/", ImageUrl = "images/mail_logolarge.png" }, - new Module { - Title = "People", - Link = "/products/people/", - ImageUrl = "images/people_logolarge.png" - }, new Module { Title = "Community", Link = "products/community/", ImageUrl = "images/community_logolarge.png" } - }; + }; + + foreach (var a in WebItemManager.Instance.GetItems(WebZoneType.StartProductList)) + { + result.Add(new Module() { + Title = a.Name, + Description = a.Description, + ImageUrl = a.Context.LargeIconFileName, + Link = a.StartURL + }); + } + + + return result; } } } diff --git a/web/ASC.Web.Api/Startup.cs b/web/ASC.Web.Api/Startup.cs index 30a0613bab..310d5d86f9 100644 --- a/web/ASC.Web.Api/Startup.cs +++ b/web/ASC.Web.Api/Startup.cs @@ -1,6 +1,5 @@ using System.Linq; -using System.Reflection; -using System.IO; +using System.Collections.Generic; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Builder; @@ -12,15 +11,16 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -using ASC.Api.Core; using ASC.Common.Logging; using ASC.Web.Api.Handlers; using ASC.Api.Core.Middleware; using ASC.Common.Utils; -using ASC.Core; -using ASC.Core.Common; -using ASC.Common; using ASC.Common.DependencyInjection; +using ASC.Web.Core; +using ASC.Data.Storage.Configuration; + +using Autofac; + namespace ASC.Web.Api { @@ -55,16 +55,18 @@ namespace ASC.Web.Api config.Filters.Add(new AuthorizeFilter(policy)); }); - var assemblies = Directory.GetFiles(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "ASC*.dll") - .Select(Assembly.LoadFrom) - .Where(r => r.GetCustomAttribute() != null); + var container = services.AddAutofac(Configuration); + + var assemblies = container.Resolve>().Select(r=> r.GetType().Assembly).Distinct(); foreach (var a in assemblies) { builder.AddApplicationPart(a); } - services.AddLogManager(Configuration); + services.AddLogManager() + .AddStorage() + .AddWebItemManager(); } public void Configure(IApplicationBuilder app, IWebHostEnvironment env) @@ -95,7 +97,8 @@ namespace ASC.Web.Api app.InitCommonServiceProvider() - .InitConfigurationManager(); + .InitConfigurationManager() + .UseWebItemManager(); } } } diff --git a/web/ASC.Web.Api/autofac.json b/web/ASC.Web.Api/autofac.json index ccfe87ecaa..aa23907069 100644 --- a/web/ASC.Web.Api/autofac.json +++ b/web/ASC.Web.Api/autofac.json @@ -7,6 +7,14 @@ "type": "ASC.Common.Logging.ILog, ASC.Common" } ] + }, + { + "type": "ASC.People.PeopleProduct, ASC.People", + "services": [ + { + "type": "ASC.Web.Core.IWebItem, ASC.Web.Core" + } + ] } ] } diff --git a/web/ASC.Web.Components/example/stories/drop-down/base/README.md b/web/ASC.Web.Components/example/stories/drop-down/base/README.md new file mode 100644 index 0000000000..6f9f289724 --- /dev/null +++ b/web/ASC.Web.Components/example/stories/drop-down/base/README.md @@ -0,0 +1,23 @@ +# DropDown + +## Usage + +```js +import { DropDown } from 'asc-web-components'; +``` + +#### Description + +Is a dropdown with any number of action + +#### Usage + +```js + +``` + +#### Properties + +| Props | Type | Required | Values | Default | Description | +| ------------------ | -------- | :------: | --------------------------- | -------------- | ----------------------------------------------------------------- | +| `opened` | `bool` | - | - | `false` | Tells when the dropdown should be opened | \ No newline at end of file diff --git a/web/ASC.Web.Components/example/stories/drop-down/base/index.stories.js b/web/ASC.Web.Components/example/stories/drop-down/base/index.stories.js new file mode 100644 index 0000000000..4a1259d295 --- /dev/null +++ b/web/ASC.Web.Components/example/stories/drop-down/base/index.stories.js @@ -0,0 +1,49 @@ +import React from 'react' +import { action } from '@storybook/addon-actions'; +import { storiesOf } from '@storybook/react' +import withReadme from 'storybook-readme/with-readme' +import Readme from './README.md' +import { Container, Row, Col } from 'reactstrap'; +import { GroupButton, Button, DropDown } from 'asc-web-components' + +const rowStyle = { marginTop: 8 }; + +storiesOf('Components| DropDown', module) + .addDecorator(withReadme(Readme)) + .add('base', () => ( + + + Only dropdown + With Button + + + + Used for demonstration without active button + + + + + + + + + + + + + + console.log('Group button clicked')} + /> +