]> source.dussan.org Git - archiva.git/blob
1030390d8492dd037f6dceb58a14d5da02afea6e
[archiva.git] /
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements.  See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership.  The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License.  You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an
13  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14  * KIND, either express or implied.  See the License for the
15  * specific language governing permissions and limitations
16  * under the License.
17  */
18
19 import {NgModule} from '@angular/core';
20 import {CommonModule} from '@angular/common';
21 import {PaginatedEntitiesComponent} from "./paginated-entities/paginated-entities.component";
22 import {SortedTableHeaderComponent} from "./sorted-table-header/sorted-table-header.component";
23 import {SortedTableHeaderRowComponent} from "./sorted-table-header-row/sorted-table-header-row.component";
24 import {NgbPaginationModule, NgbTooltipModule} from "@ng-bootstrap/ng-bootstrap";
25 import {TranslateCompiler, TranslateLoader, TranslateModule} from "@ngx-translate/core";
26 import {TranslateMessageFormatCompiler} from "ngx-translate-messageformat-compiler";
27 import {HttpClient} from "@angular/common/http";
28 import {TranslateHttpLoader} from "@ngx-translate/http-loader";
29 import {RouterModule} from "@angular/router";
30
31
32 @NgModule({
33     declarations: [
34         PaginatedEntitiesComponent,
35         SortedTableHeaderComponent,
36         SortedTableHeaderRowComponent
37     ],
38     exports: [
39         CommonModule,
40         RouterModule,
41         TranslateModule,
42         NgbPaginationModule,
43         NgbTooltipModule,
44         PaginatedEntitiesComponent,
45         SortedTableHeaderComponent,
46         SortedTableHeaderRowComponent
47     ],
48     imports: [
49         CommonModule,
50         RouterModule,
51         NgbPaginationModule,
52         NgbTooltipModule,
53         TranslateModule.forChild({
54             compiler: {
55                 provide: TranslateCompiler,
56                 useClass: TranslateMessageFormatCompiler
57             },
58             loader: {
59                 provide: TranslateLoader,
60                 useFactory: httpTranslateLoader,
61                 deps: [HttpClient]
62             }
63         }),
64     ]
65 })
66 export class SharedModule {
67 }
68
69 export function httpTranslateLoader(http: HttpClient) {
70     return new TranslateHttpLoader(http);
71 }
72
73 export const Util = {
74     deepCopy(src: Object, dst: Object, overwriteWithEmptyString:boolean=true) {
75         Object.keys(src).forEach((key, idx) => {
76             let srcEl = src[key];
77             if (typeof (srcEl) == 'object') {
78                 let dstEl;
79                 if (!dst.hasOwnProperty(key)) {
80                     dst[key] = {}
81                 }
82                 dstEl = dst[key];
83                 this.deepCopy(srcEl, dstEl);
84             } else if (typeof(srcEl)=='string') {
85                 if (overwriteWithEmptyString) {
86                     dst[key]=srcEl
87                 } else {
88                     if ((srcEl as string).length>0) {
89                         dst[key]=srcEl
90                     }
91                 }
92             } else {
93                 // console.debug("setting " + key + " = " + srcEl);
94                 dst[key] = srcEl;
95             }
96         });
97     }
98 }