DigitalData.UserManager/DigitalData.UserManager.NgWebUI/ClientApp/.angular/cache/17.3.0/babel-webpack/76802b9582f2c5f581fbad0212302d952a65616a8adc7a878c175f6dd876a62f.json

1 line
5.9 KiB
JSON

{"ast":null,"code":"import { GuiRowSelectionMode, GuiRowSelectionType } from '@generic-ui/ngx-grid';\nimport Swal from 'sweetalert2';\nimport { forkJoin, of } from 'rxjs';\nimport { catchError, finalize } from 'rxjs/operators';\nimport * as i0 from \"@angular/core\";\nimport * as i1 from \"src/app/services/group.service\";\nimport * as i2 from \"src/app/services/user.service\";\nimport * as i3 from \"@angular/forms\";\nimport * as i4 from \"../tables/dir-group-table/dir-group-table.component\";\nimport * as i5 from \"../tables/dir-user-table/dir-user-table.component\";\nconst _c0 = [\"dirGroups\"];\nconst _c1 = [\"dirUsers\"];\nexport let UserGroupDirImportComponent = /*#__PURE__*/(() => {\n class UserGroupDirImportComponent {\n constructor(gService, uService) {\n this.gService = gService;\n this.uService = uService;\n this.initWithoutData = () => {};\n this.dirGroupsRowSelection = {\n enabled: true,\n type: GuiRowSelectionType.ROW,\n mode: GuiRowSelectionMode.SINGLE\n };\n this.dirUsersRowSelection = {\n enabled: true,\n type: GuiRowSelectionType.CHECKBOX,\n mode: GuiRowSelectionMode.MULTIPLE\n };\n this.dirGroupOnSelectedRows = rows => {\n if (rows.length > 0) {\n this.dirGroups.safelyUnselectAll();\n let groupName = rows[rows.length - 1].source.samaccountname;\n this.dirUsers.fetchDataByGroupName(groupName);\n }\n };\n }\n ngOnInit() {}\n ngAfterViewInit() {\n this.dirUsers.loading = false;\n }\n addSelectedUsers() {\n let requests = [];\n let numAdded = 0;\n for (let row of this.dirUsers.selectedRows) {\n // Create an Observable for each request and add it to the requests array\n requests.push(this.uService.create({\n email: row?.source.emailAddress,\n prename: row.source.givenName,\n username: row.source.samAccountName,\n name: row.source.surname\n }).pipe(catchError(err => {\n console.log('An error occurred', err);\n // In case of error, return a 'null' observable for this request, so it doesn't affect other requests\n return of(null);\n })));\n }\n forkJoin(requests).pipe(\n // finalize is executed after all requests are completed or when an error occurs\n finalize(() => {\n // Show Swal notification after all requests are completed\n Swal.fire({\n icon: \"success\",\n title: \"Completed\",\n text: `${numAdded} new users added`,\n position: \"center\",\n showConfirmButton: false,\n timer: 3000\n });\n this.dirUsers.safelyUnselectAll();\n })).subscribe({\n next: results => {\n // Increment numAdded for each successful request\n // You can increment numAdded for each result that is not null\n numAdded += results.filter(result => result !== null).length;\n },\n error: err => {\n // You may need to handle any potential errors here\n console.log('An error occurred', err);\n }\n });\n }\n static #_ = this.ɵfac = function UserGroupDirImportComponent_Factory(t) {\n return new (t || UserGroupDirImportComponent)(i0.ɵɵdirectiveInject(i1.GroupService), i0.ɵɵdirectiveInject(i2.UserService));\n };\n static #_2 = this.ɵcmp = /*@__PURE__*/i0.ɵɵdefineComponent({\n type: UserGroupDirImportComponent,\n selectors: [[\"app-user-group-dir-import\"]],\n viewQuery: function UserGroupDirImportComponent_Query(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵviewQuery(_c0, 5);\n i0.ɵɵviewQuery(_c1, 5);\n }\n if (rf & 2) {\n let _t;\n i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.dirGroups = _t.first);\n i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.dirUsers = _t.first);\n }\n },\n decls: 15,\n vars: 4,\n consts: [[\"dirGroups\", \"\"], [\"dirUsers\", \"\"], [1, \"row\", \"p-0\", \"m-0\"], [1, \"col\", \"p-0\", \"m-0\"], [1, \"navbar\", \"bg-body-tertiary\"], [1, \"container-fluid\", \"justify-content-start\"], [\"type\", \"button\", 1, \"btn\", \"btn-outline-success\", \"me-2\", 3, \"click\"], [1, \"row\", \"align-items-start\", \"p-0\", \"m-0\"], [1, \"col-6\", \"p-0\", \"m-0\"], [3, \"rowSelection\", \"onSelectedRows\"], [3, \"initData\", \"rowSelection\"]],\n template: function UserGroupDirImportComponent_Template(rf, ctx) {\n if (rf & 1) {\n const _r1 = i0.ɵɵgetCurrentView();\n i0.ɵɵelementStart(0, \"div\", 2)(1, \"div\", 3)(2, \"nav\", 4)(3, \"form\", 5)(4, \"button\", 6);\n i0.ɵɵlistener(\"click\", function UserGroupDirImportComponent_Template_button_click_4_listener() {\n i0.ɵɵrestoreView(_r1);\n return i0.ɵɵresetView(ctx.addSelectedUsers());\n });\n i0.ɵɵtext(5, \"Benutzer\");\n i0.ɵɵelement(6, \"br\");\n i0.ɵɵtext(7, \"Hinzuf\\u00FCgen\");\n i0.ɵɵelementEnd()()()()();\n i0.ɵɵelementStart(8, \"div\", 7)(9, \"div\", 8);\n i0.ɵɵelement(10, \"app-dir-group-table\", 9, 0);\n i0.ɵɵelementEnd();\n i0.ɵɵelementStart(12, \"div\", 8);\n i0.ɵɵelement(13, \"app-dir-user-table\", 10, 1);\n i0.ɵɵelementEnd()();\n }\n if (rf & 2) {\n i0.ɵɵadvance(10);\n i0.ɵɵproperty(\"rowSelection\", ctx.dirGroupsRowSelection)(\"onSelectedRows\", ctx.dirGroupOnSelectedRows);\n i0.ɵɵadvance(3);\n i0.ɵɵproperty(\"initData\", ctx.initWithoutData)(\"rowSelection\", ctx.dirUsersRowSelection);\n }\n },\n dependencies: [i3.ɵNgNoValidate, i3.NgControlStatusGroup, i3.NgForm, i4.DirGroupTableComponent, i5.DirUserTableComponent]\n });\n }\n return UserGroupDirImportComponent;\n})();","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]}