@syngrisi/syngrisi 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nvmrc +1 -0
- package/LICENSE.md +9 -0
- package/README.md +139 -0
- package/config.js +17 -0
- package/dist/config.js +16 -0
- package/dist/src/server/models/index.js +508 -0
- package/dist/src/server/models/plugins/index.js +4 -0
- package/dist/src/server/models/plugins/paginate.plugin.js +76 -0
- package/dist/src/server/models/plugins/paginateDistinct.plugin.js +76 -0
- package/dist/src/server/models/plugins/toJSON.plugin.js +39 -0
- package/dist/src/server/schemas/createCheck.shema.js +17 -0
- package/dist/src/server/schemas/getBaseline.shema.js +12 -0
- package/dist/src/server/utils/paramsGuard.js +18 -0
- package/dist/src/tasks/backup.js +68 -0
- package/dist/src/tasks/lib/common.js +14 -0
- package/dist/src/tasks/lib/utils.js +14 -0
- package/dist/src/tasks/migrations/2.0.migration.js +86 -0
- package/dist/src/tasks/migrations/2.0.migration_mql.js +57 -0
- package/dist/src/tasks/reindex.js +28 -0
- package/dist/src/tasks/restore.js +86 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/docker-compose.yml +70 -0
- package/mvc/views/react/admin/index.html +22 -0
- package/mvc/views/react/assets/LogicalGroup.95929360.js +15993 -0
- package/mvc/views/react/assets/PasswordInput.8a73fdd2.js +299 -0
- package/mvc/views/react/assets/admin.94703bdc.js +14448 -0
- package/mvc/views/react/assets/auth.748478ef.js +673 -0
- package/mvc/views/react/assets/bg_2_0_dark_L2.3a31edc0.png +0 -0
- package/mvc/views/react/assets/favicon.bf5828d5.svg +7 -0
- package/mvc/views/react/assets/index.a5606313.css +23 -0
- package/mvc/views/react/assets/roboto-v30-latin-100.0f303f31.woff2 +0 -0
- package/mvc/views/react/assets/roboto-v30-latin-100.34e9582c.woff +0 -0
- package/mvc/views/react/assets/roboto-v30-latin-500.9ce7f3ac.woff +0 -0
- package/mvc/views/react/assets/roboto-v30-latin-500.b0195382.woff2 +0 -0
- package/mvc/views/react/assets/roboto-v30-latin-700.e0fd57c0.woff +0 -0
- package/mvc/views/react/assets/roboto-v30-latin-700.f5aebdfe.woff2 +0 -0
- package/mvc/views/react/assets/roboto-v30-latin-regular.f2abf7fb.woff +0 -0
- package/mvc/views/react/assets/roboto-v30-latin-regular.f6734f81.woff2 +0 -0
- package/mvc/views/react/assets/root.136e0ea3.js +25451 -0
- package/mvc/views/react/assets/use-form.57ebe175.js +24472 -0
- package/mvc/views/react/assets/use-form.ecb4391b.css +36 -0
- package/mvc/views/react/auth/index.html +22 -0
- package/mvc/views/react/index.html +19 -0
- package/mvc/views/react/index2/index.html +21 -0
- package/package.json +144 -0
- package/server.js +166 -0
- package/src/server/controllers/app.controller.js +21 -0
- package/src/server/controllers/auth.controller.js +156 -0
- package/src/server/controllers/baseline.controller.js +24 -0
- package/src/server/controllers/check.controller.js +56 -0
- package/src/server/controllers/client.controller.js +173 -0
- package/src/server/controllers/index.js +12 -0
- package/src/server/controllers/logs.controller.js +30 -0
- package/src/server/controllers/runs.controller.js +25 -0
- package/src/server/controllers/settings.controller.js +23 -0
- package/src/server/controllers/snapshots.controller.js +17 -0
- package/src/server/controllers/suite.controller.js +24 -0
- package/src/server/controllers/tasks.controller.js +47 -0
- package/src/server/controllers/test.controller.js +70 -0
- package/src/server/controllers/users.controller.js +79 -0
- package/src/server/data/custom_devices.json +8 -0
- package/src/server/data/devices.json +773 -0
- package/src/server/data/get_devices.sh +2 -0
- package/src/server/lib/AppSettings.js +56 -0
- package/src/server/lib/admin.json +9 -0
- package/src/server/lib/comparator.js +147 -0
- package/src/server/lib/compareImagesNode.js +60 -0
- package/src/server/lib/dbItems.js +215 -0
- package/src/server/lib/ensureLogin/ensureLoggedIn.js +223 -0
- package/src/server/lib/ensureLogin/ensureLoggedOut.js +44 -0
- package/src/server/lib/getElementsByPixPositionsFromDump.js +72 -0
- package/src/server/lib/guest.json +9 -0
- package/src/server/lib/initialAppSettings.json +18 -0
- package/src/server/lib/logger.js +95 -0
- package/src/server/lib/onStart.js +53 -0
- package/src/server/lib/parseDiff.js.bak +72 -0
- package/src/server/lib/testAdmin.json +9 -0
- package/src/server/lib/testUsers.json +41 -0
- package/src/server/middlewares/authorization.js +50 -0
- package/src/server/middlewares/disableCors.js +19 -0
- package/src/server/models/index.js +534 -0
- package/src/server/models/plugins/index.js +3 -0
- package/src/server/models/plugins/paginate.plugin.js +83 -0
- package/src/server/models/plugins/paginateDistinct.plugin.js +80 -0
- package/src/server/models/plugins/toJSON.plugin.js +44 -0
- package/src/server/routes/ui/admin.js +20 -0
- package/src/server/routes/ui/auth.js +15 -0
- package/src/server/routes/ui/index.js +19 -0
- package/src/server/routes/v1/app.route.js +9 -0
- package/src/server/routes/v1/auth.route.js +12 -0
- package/src/server/routes/v1/baselines.route.js +14 -0
- package/src/server/routes/v1/checks.route.js +25 -0
- package/src/server/routes/v1/client.route.js +39 -0
- package/src/server/routes/v1/index.js +82 -0
- package/src/server/routes/v1/logs.route.js +16 -0
- package/src/server/routes/v1/runs.route.js +15 -0
- package/src/server/routes/v1/settings.route.js +23 -0
- package/src/server/routes/v1/snapshots.route.js +11 -0
- package/src/server/routes/v1/suites.route.js +15 -0
- package/src/server/routes/v1/tasks.route.js +59 -0
- package/src/server/routes/v1/test.route.js +20 -0
- package/src/server/routes/v1/test_distinct.route.js +14 -0
- package/src/server/routes/v1/users.route.js +36 -0
- package/src/server/schemas/createCheck.shema.ts +17 -0
- package/src/server/schemas/getBaseline.shema.ts +12 -0
- package/src/server/services/app.service.js +23 -0
- package/src/server/services/check.service.js +178 -0
- package/src/server/services/client.service.js +648 -0
- package/src/server/services/generic.service.js +51 -0
- package/src/server/services/index.js +12 -0
- package/src/server/services/logs.service.js +38 -0
- package/src/server/services/run.service.js +40 -0
- package/src/server/services/suite.service.js +39 -0
- package/src/server/services/tasks.service.js +536 -0
- package/src/server/services/test.service.js +72 -0
- package/src/server/services/user.service.js +128 -0
- package/src/server/utils/ApiError.js +14 -0
- package/src/server/utils/catchAsync.js +8 -0
- package/src/server/utils/check.js +58 -0
- package/src/server/utils/dateToISO8601.js +2 -0
- package/src/server/utils/deserializeIfJSON.js +9 -0
- package/src/server/utils/formatISOToDateTime.js +6 -0
- package/src/server/utils/index.js +10 -0
- package/src/server/utils/isJSON.js +6 -0
- package/src/server/utils/paramsGuard.ts +15 -0
- package/src/server/utils/pick.js +15 -0
- package/src/server/utils/prettyCheckParams.js +13 -0
- package/src/server/utils/snapshots.js +73 -0
- package/src/server/utils/subDays.js +7 -0
- package/src/server/utils/tests.js +36 -0
- package/src/server/utils/utils.js +146 -0
- package/src/tasks/backup.js.bak +84 -0
- package/src/tasks/backup.ts +53 -0
- package/src/tasks/lib/common.js +24 -0
- package/src/tasks/lib/utils.js +15 -0
- package/src/tasks/migrations/2.0.migration.js +86 -0
- package/src/tasks/migrations/2.0.migration.ts +95 -0
- package/src/tasks/migrations/2.0.migration_mql.js +63 -0
- package/src/tasks/reindex.js +36 -0
- package/src/tasks/restore.js.bak +100 -0
- package/src/tasks/restore.ts +75 -0
- package/src/ui-app/.eslintrc.json +119 -0
- package/src/ui-app/README.md +15 -0
- package/src/ui-app/admin/AdminLayout.tsx +38 -0
- package/src/ui-app/admin/App.tsx +108 -0
- package/src/ui-app/admin/AppContext.ts +3 -0
- package/src/ui-app/admin/components/Header/AdminHeader.tsx +148 -0
- package/src/ui-app/admin/components/Logs/AdminLogs.tsx +142 -0
- package/src/ui-app/admin/components/Logs/RefreshActionIcon.tsx +60 -0
- package/src/ui-app/admin/components/Logs/Table/AdminLogsTable.tsx +81 -0
- package/src/ui-app/admin/components/Logs/Table/AdminLogsTableFilter.tsx +170 -0
- package/src/ui-app/admin/components/Logs/Table/AdminLogsTableHeads.tsx +50 -0
- package/src/ui-app/admin/components/Logs/Table/AdminLogsTableRows.tsx +207 -0
- package/src/ui-app/admin/components/Logs/Table/AdminLogsTableSettings.tsx +95 -0
- package/src/ui-app/admin/components/Logs/Table/InfinityScrollSkeleton.tsx +77 -0
- package/src/ui-app/admin/components/Logs/Table/InfinityScrollSkeletonFIller.tsx +57 -0
- package/src/ui-app/admin/components/Logs/Table/PagesCountAffix.tsx +61 -0
- package/src/ui-app/admin/components/Logs/Table/adminLogsCreateStyle.tsx +36 -0
- package/src/ui-app/admin/components/Logs/Table/adminLogsTableColumns.ts +52 -0
- package/src/ui-app/admin/components/Logs/UnfoldActionIcon.tsx +39 -0
- package/src/ui-app/admin/components/Navbar/AdminNavbar.tsx +50 -0
- package/src/ui-app/admin/components/Navbar/NavbarLinksGroup.tsx +104 -0
- package/src/ui-app/admin/components/Settings/AdminSettings.tsx +51 -0
- package/src/ui-app/admin/components/Settings/Forms/Boolean.tsx +59 -0
- package/src/ui-app/admin/components/Settings/Forms/FormWrapper.tsx +45 -0
- package/src/ui-app/admin/components/Settings/Forms/index.tsx +5 -0
- package/src/ui-app/admin/components/Settings/Forms/interfaces.tsx +17 -0
- package/src/ui-app/admin/components/Tasks/Task.tsx +138 -0
- package/src/ui-app/admin/components/Tasks/TaskWrapper.tsx +11 -0
- package/src/ui-app/admin/components/Tasks/tasksList.ts +59 -0
- package/src/ui-app/admin/components/Users/AdminUsers.tsx +182 -0
- package/src/ui-app/admin/components/Users/UserAddForm.tsx +137 -0
- package/src/ui-app/admin/components/Users/UserForm.tsx +196 -0
- package/src/ui-app/admin/hooks/useParams.tsx +18 -0
- package/src/ui-app/admin/index.html +17 -0
- package/src/ui-app/admin/main.tsx +24 -0
- package/src/ui-app/asserts/css/auth/index.css +23 -0
- package/src/ui-app/asserts/css/styles.css +36 -0
- package/src/ui-app/asserts/fonts/roboto/roboto-v30-latin-100.eot +0 -0
- package/src/ui-app/asserts/fonts/roboto/roboto-v30-latin-100.svg +313 -0
- package/src/ui-app/asserts/fonts/roboto/roboto-v30-latin-100.ttf +0 -0
- package/src/ui-app/asserts/fonts/roboto/roboto-v30-latin-100.woff +0 -0
- package/src/ui-app/asserts/fonts/roboto/roboto-v30-latin-100.woff2 +0 -0
- package/src/ui-app/asserts/fonts/roboto/roboto-v30-latin-500.eot +0 -0
- package/src/ui-app/asserts/fonts/roboto/roboto-v30-latin-500.svg +305 -0
- package/src/ui-app/asserts/fonts/roboto/roboto-v30-latin-500.ttf +0 -0
- package/src/ui-app/asserts/fonts/roboto/roboto-v30-latin-500.woff +0 -0
- package/src/ui-app/asserts/fonts/roboto/roboto-v30-latin-500.woff2 +0 -0
- package/src/ui-app/asserts/fonts/roboto/roboto-v30-latin-700.eot +0 -0
- package/src/ui-app/asserts/fonts/roboto/roboto-v30-latin-700.svg +309 -0
- package/src/ui-app/asserts/fonts/roboto/roboto-v30-latin-700.ttf +0 -0
- package/src/ui-app/asserts/fonts/roboto/roboto-v30-latin-700.woff +0 -0
- package/src/ui-app/asserts/fonts/roboto/roboto-v30-latin-700.woff2 +0 -0
- package/src/ui-app/asserts/fonts/roboto/roboto-v30-latin-regular.eot +0 -0
- package/src/ui-app/asserts/fonts/roboto/roboto-v30-latin-regular.svg +308 -0
- package/src/ui-app/asserts/fonts/roboto/roboto-v30-latin-regular.ttf +0 -0
- package/src/ui-app/asserts/fonts/roboto/roboto-v30-latin-regular.woff +0 -0
- package/src/ui-app/asserts/fonts/roboto/roboto-v30-latin-regular.woff2 +0 -0
- package/src/ui-app/asserts/images/background.jpg +0 -0
- package/src/ui-app/asserts/images/bg_2_0_dark_L2.png +0 -0
- package/src/ui-app/asserts/images/favicon.svg +7 -0
- package/src/ui-app/auth/App.tsx +82 -0
- package/src/ui-app/auth/commonStyles.tsx +26 -0
- package/src/ui-app/auth/components/AuthFooter.tsx +51 -0
- package/src/ui-app/auth/components/AuthLogo.tsx +58 -0
- package/src/ui-app/auth/components/ChangePasswordForm.tsx +216 -0
- package/src/ui-app/auth/components/ChangePasswordSuccessForm.tsx +38 -0
- package/src/ui-app/auth/components/LoginForm.tsx +148 -0
- package/src/ui-app/auth/components/LogoutForm.tsx +89 -0
- package/src/ui-app/auth/components/ToggleThemeButton.tsx +41 -0
- package/src/ui-app/auth/components/change-password/Bars.tsx +45 -0
- package/src/ui-app/auth/components/change-password/PasswordRequirement.tsx +14 -0
- package/src/ui-app/auth/components/change-password/requirements.tsx +6 -0
- package/src/ui-app/auth/index.html +17 -0
- package/src/ui-app/auth/main.tsx +12 -0
- package/src/ui-app/auth/routes.tsx +26 -0
- package/src/ui-app/config.ts +15 -0
- package/src/ui-app/index.html +12 -0
- package/src/ui-app/index2/App.tsx +162 -0
- package/src/ui-app/index2/AppContext.ts +3 -0
- package/src/ui-app/index2/IndexLayout.tsx +34 -0
- package/src/ui-app/index2/components/Header/HeaderIndex.tsx +248 -0
- package/src/ui-app/index2/components/Header/QuickFilter.tsx +312 -0
- package/src/ui-app/index2/components/Navbar/Items/AcceptStatusItem.tsx +42 -0
- package/src/ui-app/index2/components/Navbar/Items/BaseItemWrapper.tsx +94 -0
- package/src/ui-app/index2/components/Navbar/Items/BrowserItem.tsx +42 -0
- package/src/ui-app/index2/components/Navbar/Items/PlatformItem.tsx +42 -0
- package/src/ui-app/index2/components/Navbar/Items/RemoveItemModalAsk.tsx +71 -0
- package/src/ui-app/index2/components/Navbar/Items/RemoveItemPopover.tsx +58 -0
- package/src/ui-app/index2/components/Navbar/Items/RemoveSuiteModalAsk.tsx +61 -0
- package/src/ui-app/index2/components/Navbar/Items/RunItem.tsx +149 -0
- package/src/ui-app/index2/components/Navbar/Items/StatusItem.tsx +42 -0
- package/src/ui-app/index2/components/Navbar/Items/SuiteItem.tsx +109 -0
- package/src/ui-app/index2/components/Navbar/Items/index.tsx +6 -0
- package/src/ui-app/index2/components/Navbar/NavbarFilter.tsx +93 -0
- package/src/ui-app/index2/components/Navbar/NavbarGroupBySelect.tsx +83 -0
- package/src/ui-app/index2/components/Navbar/NavbarIndex.tsx +247 -0
- package/src/ui-app/index2/components/Navbar/NavbarItems.tsx +38 -0
- package/src/ui-app/index2/components/Navbar/NavbarSort.tsx +105 -0
- package/src/ui-app/index2/components/Navbar/Skeletons/RunsDummySkeleton.tsx +27 -0
- package/src/ui-app/index2/components/Navbar/Skeletons/SimpleDummySkeleton.tsx +23 -0
- package/src/ui-app/index2/components/Navbar/Skeletons/SkeletonWrapper.tsx +45 -0
- package/src/ui-app/index2/components/Navbar/Skeletons/SuitesDummySkeleton.tsx +27 -0
- package/src/ui-app/index2/components/Tests/Table/AcceptTestModalAsk.tsx +68 -0
- package/src/ui-app/index2/components/Tests/Table/AcceptTestsButton.tsx +44 -0
- package/src/ui-app/index2/components/Tests/Table/Cells/Branch.tsx +35 -0
- package/src/ui-app/index2/components/Tests/Table/Cells/BrowserName.tsx +33 -0
- package/src/ui-app/index2/components/Tests/Table/Cells/BrowserVersion.tsx +31 -0
- package/src/ui-app/index2/components/Tests/Table/Cells/CellWrapper.tsx +49 -0
- package/src/ui-app/index2/components/Tests/Table/Cells/Os.tsx +32 -0
- package/src/ui-app/index2/components/Tests/Table/Cells/StartDate.tsx +34 -0
- package/src/ui-app/index2/components/Tests/Table/Cells/Status.tsx +50 -0
- package/src/ui-app/index2/components/Tests/Table/Cells/ViewPort.tsx +46 -0
- package/src/ui-app/index2/components/Tests/Table/Checks/AcceptButton.tsx +142 -0
- package/src/ui-app/index2/components/Tests/Table/Checks/Check.tsx +281 -0
- package/src/ui-app/index2/components/Tests/Table/Checks/CheckDetails/Canvas/Canvas.tsx +36 -0
- package/src/ui-app/index2/components/Tests/Table/Checks/CheckDetails/Canvas/helpers.ts +72 -0
- package/src/ui-app/index2/components/Tests/Table/Checks/CheckDetails/Canvas/mainView.ts +495 -0
- package/src/ui-app/index2/components/Tests/Table/Checks/CheckDetails/Canvas/sideToSideView.ts +398 -0
- package/src/ui-app/index2/components/Tests/Table/Checks/CheckDetails/Canvas/simpleView.ts +21 -0
- package/src/ui-app/index2/components/Tests/Table/Checks/CheckDetails/CheckDetails.tsx +237 -0
- package/src/ui-app/index2/components/Tests/Table/Checks/CheckDetails/Header.tsx +221 -0
- package/src/ui-app/index2/components/Tests/Table/Checks/CheckDetails/RelatedChecks/RelatedCheckItem.tsx +167 -0
- package/src/ui-app/index2/components/Tests/Table/Checks/CheckDetails/RelatedChecks/RelatedCheckSort.tsx +81 -0
- package/src/ui-app/index2/components/Tests/Table/Checks/CheckDetails/RelatedChecks/RelatedChecks.tsx +197 -0
- package/src/ui-app/index2/components/Tests/Table/Checks/CheckDetails/RelatedChecks/RelatedChecksItems.tsx +31 -0
- package/src/ui-app/index2/components/Tests/Table/Checks/CheckDetails/RelatedChecks/RelatedChecksSkeleton.tsx +37 -0
- package/src/ui-app/index2/components/Tests/Table/Checks/CheckDetails/Toolbar/HighlightButton.tsx +56 -0
- package/src/ui-app/index2/components/Tests/Table/Checks/CheckDetails/Toolbar/RegionsToolbar.tsx +150 -0
- package/src/ui-app/index2/components/Tests/Table/Checks/CheckDetails/Toolbar/ScreenshotDetails.tsx +137 -0
- package/src/ui-app/index2/components/Tests/Table/Checks/CheckDetails/Toolbar/Toolbar.tsx +101 -0
- package/src/ui-app/index2/components/Tests/Table/Checks/CheckDetails/Toolbar/ViewSegmentedControl.tsx +159 -0
- package/src/ui-app/index2/components/Tests/Table/Checks/CheckDetails/Toolbar/ZoomToolbar.tsx +326 -0
- package/src/ui-app/index2/components/Tests/Table/Checks/CheckDetails/Toolbar/highlightDiff.ts +167 -0
- package/src/ui-app/index2/components/Tests/Table/Checks/CheckDetails/hooks/useRelatedChecks.tsx +43 -0
- package/src/ui-app/index2/components/Tests/Table/Checks/CheckModal.tsx +119 -0
- package/src/ui-app/index2/components/Tests/Table/Checks/Checks.tsx +91 -0
- package/src/ui-app/index2/components/Tests/Table/Checks/ChecksSkeleton.tsx +21 -0
- package/src/ui-app/index2/components/Tests/Table/Checks/PreviewCheckTooltipLabel.tsx +121 -0
- package/src/ui-app/index2/components/Tests/Table/Checks/RemoveButton.tsx +63 -0
- package/src/ui-app/index2/components/Tests/Table/Checks/ViewPortLabel.tsx +94 -0
- package/src/ui-app/index2/components/Tests/Table/Checks/checkSizes.ts +27 -0
- package/src/ui-app/index2/components/Tests/Table/Filter.tsx +179 -0
- package/src/ui-app/index2/components/Tests/Table/Heads.tsx +54 -0
- package/src/ui-app/index2/components/Tests/Table/InfinityScrollSkeleton.tsx +71 -0
- package/src/ui-app/index2/components/Tests/Table/PagesCountAffix.tsx +61 -0
- package/src/ui-app/index2/components/Tests/Table/RefreshActionIcon.tsx +65 -0
- package/src/ui-app/index2/components/Tests/Table/RemoveTestModalAsk.tsx +66 -0
- package/src/ui-app/index2/components/Tests/Table/RemoveTestsButton.tsx +43 -0
- package/src/ui-app/index2/components/Tests/Table/Row.tsx +128 -0
- package/src/ui-app/index2/components/Tests/Table/Rows.tsx +87 -0
- package/src/ui-app/index2/components/Tests/Table/Settings.tsx +121 -0
- package/src/ui-app/index2/components/Tests/Table/TestsTable.tsx +140 -0
- package/src/ui-app/index2/components/Tests/Table/UnfoldActionIcon.tsx +39 -0
- package/src/ui-app/index2/components/Tests/Table/tableColumns.ts +80 -0
- package/src/ui-app/index2/components/Tests/Table/testsCreateStyle.tsx +35 -0
- package/src/ui-app/index2/components/Tests/Tests.tsx +157 -0
- package/src/ui-app/index2/hooks/useIndexSubpageEffect.tsx +14 -0
- package/src/ui-app/index2/hooks/useNavbarActiveItems.tsx +66 -0
- package/src/ui-app/index2/hooks/useParams.tsx +25 -0
- package/src/ui-app/index2/index.html +17 -0
- package/src/ui-app/index2/main.tsx +33 -0
- package/src/ui-app/package-lock.json +6150 -0
- package/src/ui-app/package.json +58 -0
- package/src/ui-app/shared/components/ActionPopoverIcon.tsx +116 -0
- package/src/ui-app/shared/components/Check/AcceptedStatusIcon.tsx +51 -0
- package/src/ui-app/shared/components/Check/BrowserIcon.tsx +50 -0
- package/src/ui-app/shared/components/Check/OsIcon.tsx +73 -0
- package/src/ui-app/shared/components/Check/Status.tsx +37 -0
- package/src/ui-app/shared/components/Check/StatusIcon.tsx +66 -0
- package/src/ui-app/shared/components/Email.tsx +83 -0
- package/src/ui-app/shared/components/Header/ApiKeyModalAsk.tsx +31 -0
- package/src/ui-app/shared/components/Header/ApiKeyModalResult.tsx +89 -0
- package/src/ui-app/shared/components/Header/HeaderLogo.tsx +82 -0
- package/src/ui-app/shared/components/Header/UserInfoModal.tsx +92 -0
- package/src/ui-app/shared/components/Header/UserMenu.tsx +151 -0
- package/src/ui-app/shared/components/Password.tsx +95 -0
- package/src/ui-app/shared/components/RelativeDrawer.tsx +43 -0
- package/src/ui-app/shared/components/SafeSelect.tsx +95 -0
- package/src/ui-app/shared/components/Tests/StatusesRing.tsx +66 -0
- package/src/ui-app/shared/components/ToggleThemeButton.tsx +33 -0
- package/src/ui-app/shared/components/Users/LabelUser.tsx +60 -0
- package/src/ui-app/shared/components/errors/ErrorFallback.tsx +66 -0
- package/src/ui-app/shared/components/filter/AcceptedFilter.tsx +20 -0
- package/src/ui-app/shared/components/filter/BrowserNameFilter.tsx +20 -0
- package/src/ui-app/shared/components/filter/CommonDistinctFilter.tsx +104 -0
- package/src/ui-app/shared/components/filter/DateFilter.tsx +54 -0
- package/src/ui-app/shared/components/filter/FilterWrapper.tsx +80 -0
- package/src/ui-app/shared/components/filter/IdFilter.tsx +60 -0
- package/src/ui-app/shared/components/filter/LogLevelFilter.tsx +77 -0
- package/src/ui-app/shared/components/filter/LogicalGroup.tsx +179 -0
- package/src/ui-app/shared/components/filter/OsFilter.tsx +20 -0
- package/src/ui-app/shared/components/filter/StatusFilter.tsx +20 -0
- package/src/ui-app/shared/components/filter/StringFilter.tsx +55 -0
- package/src/ui-app/shared/components/filter/index.ts +19 -0
- package/src/ui-app/shared/components/heaserLinks.tsx +4 -0
- package/src/ui-app/shared/hooks/index.ts +3 -0
- package/src/ui-app/shared/hooks/useColorSheme.ts +22 -0
- package/src/ui-app/shared/hooks/useDistinctLogQuery.tsx +33 -0
- package/src/ui-app/shared/hooks/useDistinctQuery.tsx +37 -0
- package/src/ui-app/shared/hooks/useInfinityScroll.tsx +163 -0
- package/src/ui-app/shared/hooks/useInfinityScrollRelatedChecks.tsx +60 -0
- package/src/ui-app/shared/hooks/useNavProgressFetchEffect.tsx +17 -0
- package/src/ui-app/shared/hooks/useSubpageEffect.tsx +28 -0
- package/src/ui-app/shared/hooks/user.hooks.ts +49 -0
- package/src/ui-app/shared/interfaces/ILog.tsx +13 -0
- package/src/ui-app/shared/interfaces/IUser.tsx +13 -0
- package/src/ui-app/shared/interfaces/logQueries.tsx +31 -0
- package/src/ui-app/shared/navigation/interfaces.tsx +7 -0
- package/src/ui-app/shared/navigation/navigationData.tsx +191 -0
- package/src/ui-app/shared/services/checks.service.ts +39 -0
- package/src/ui-app/shared/services/generic.service.ts +115 -0
- package/src/ui-app/shared/services/index.ts +6 -0
- package/src/ui-app/shared/services/runs.service.ts +20 -0
- package/src/ui-app/shared/services/suites.service.ts +20 -0
- package/src/ui-app/shared/services/tests.service.ts +39 -0
- package/src/ui-app/shared/services/users.service.ts +29 -0
- package/src/ui-app/shared/utils/Logger.ts +12 -0
- package/src/ui-app/shared/utils/SearchParams.ts +17 -0
- package/src/ui-app/shared/utils/filters.tsx +14 -0
- package/src/ui-app/shared/utils/index.ts +5 -0
- package/src/ui-app/shared/utils/utils.tsx +70 -0
- package/src/ui-app/stub.html +12 -0
- package/src/ui-app/stub.tsx +58 -0
- package/src/ui-app/stubDemoColors.tsx +47 -0
- package/src/ui-app/stubDemoNav.tsx +41 -0
- package/src/ui-app/tsconfig.json +21 -0
- package/src/ui-app/tsconfig.node.json +12 -0
- package/static/A.png +0 -0
- package/static/B.png +0 -0
- package/static/affected.html +39 -0
- package/static/affected_2.html +40 -0
- package/static/data/custom_devices.json +14 -0
- package/static/grids/desktop-higher.html +72 -0
- package/static/grids/desktop-wider.html +72 -0
- package/static/grids/desktop.html +61 -0
- package/static/grids/fit-in-view.html +62 -0
- package/static/js/canvasjs.min.js.bak +957 -0
- package/static/js/chart.js.bak +92 -0
- package/static/js/jquery-3.3.1.slim.js.bak +8269 -0
- package/static/js/jquery-3.3.1.slim.min.js.bak +2 -0
- package/static/js/moment.min.js.bak +2 -0
- package/static/low_diff_0.png +0 -0
- package/static/low_diff_1.png +0 -0
- package/static/vShift.png +0 -0
- package/static/vShift_bottom.png +0 -0
- package/static/vShift_top.png +0 -0
|
@@ -0,0 +1,495 @@
|
|
|
1
|
+
import { fabric } from 'fabric';
|
|
2
|
+
import { SimpleView } from './simpleView';
|
|
3
|
+
import { SideToSideView } from './sideToSideView';
|
|
4
|
+
import { lockImage } from './helpers';
|
|
5
|
+
import { errorMsg, successMsg } from '../../../../../../../shared/utils/utils';
|
|
6
|
+
import config from '../../../../../../../config';
|
|
7
|
+
import { log } from '../../../../../../../shared/utils/Logger';
|
|
8
|
+
|
|
9
|
+
/* eslint-disable dot-notation,no-underscore-dangle */
|
|
10
|
+
interface IRectParams {
|
|
11
|
+
name: any;
|
|
12
|
+
fill: any;
|
|
13
|
+
stroke: any;
|
|
14
|
+
strokeWidth: any;
|
|
15
|
+
top: any;
|
|
16
|
+
left: any;
|
|
17
|
+
width: any;
|
|
18
|
+
height: any;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface Props {
|
|
22
|
+
canvasElementWidth: number;
|
|
23
|
+
canvasElementHeight: number;
|
|
24
|
+
canvasId: string;
|
|
25
|
+
// url: string
|
|
26
|
+
actual: any;
|
|
27
|
+
expectedImage: any;
|
|
28
|
+
actualImage: any;
|
|
29
|
+
diffImage: any;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export class MainView {
|
|
33
|
+
canvasElementWidth: number;
|
|
34
|
+
|
|
35
|
+
canvasElementHeight: number;
|
|
36
|
+
|
|
37
|
+
sliderView: SideToSideView;
|
|
38
|
+
|
|
39
|
+
canvas: fabric.Canvas;
|
|
40
|
+
|
|
41
|
+
actualImage: any;
|
|
42
|
+
|
|
43
|
+
currentMode: any;
|
|
44
|
+
|
|
45
|
+
defaultMode: string;
|
|
46
|
+
|
|
47
|
+
// currentView: string;
|
|
48
|
+
|
|
49
|
+
actualView: SimpleView;
|
|
50
|
+
|
|
51
|
+
expectedView: SimpleView;
|
|
52
|
+
|
|
53
|
+
diffView: SimpleView;
|
|
54
|
+
|
|
55
|
+
expectedImage: any;
|
|
56
|
+
|
|
57
|
+
diffImage: any;
|
|
58
|
+
|
|
59
|
+
// _currentView: string;
|
|
60
|
+
//
|
|
61
|
+
// public get currentView() {
|
|
62
|
+
// return this._currentView;
|
|
63
|
+
// }
|
|
64
|
+
//
|
|
65
|
+
// public set currentView(value: string) {
|
|
66
|
+
// this._currentView = value;
|
|
67
|
+
// }
|
|
68
|
+
|
|
69
|
+
constructor(
|
|
70
|
+
{
|
|
71
|
+
canvasElementWidth,
|
|
72
|
+
canvasElementHeight,
|
|
73
|
+
canvasId,
|
|
74
|
+
actual,
|
|
75
|
+
expectedImage,
|
|
76
|
+
actualImage,
|
|
77
|
+
diffImage,
|
|
78
|
+
}: Props,
|
|
79
|
+
) {
|
|
80
|
+
fabric.Object.prototype.objectCaching = false;
|
|
81
|
+
// init properties
|
|
82
|
+
this.canvasElementWidth = canvasElementWidth;
|
|
83
|
+
this.canvasElementHeight = canvasElementHeight;
|
|
84
|
+
|
|
85
|
+
this.actualImage = lockImage(actualImage);
|
|
86
|
+
this.expectedImage = lockImage(expectedImage);
|
|
87
|
+
this.diffImage = diffImage ? lockImage(diffImage) : null;
|
|
88
|
+
|
|
89
|
+
this.canvas = new fabric.Canvas(canvasId, {
|
|
90
|
+
width: this.canvasElementWidth,
|
|
91
|
+
height: this.canvasElementHeight,
|
|
92
|
+
preserveObjectStacking: true,
|
|
93
|
+
uniformScaling: false,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// this._currentView = 'actual';
|
|
97
|
+
// this.expectedCanvasViewportAreaSize = MainView.calculateExpectedCanvasViewportAreaSize();
|
|
98
|
+
|
|
99
|
+
this.defaultMode = '';
|
|
100
|
+
|
|
101
|
+
if (actual) {
|
|
102
|
+
this.sliderView = new SideToSideView(
|
|
103
|
+
{
|
|
104
|
+
mainView: this,
|
|
105
|
+
},
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// events
|
|
110
|
+
this.selectionEvents();
|
|
111
|
+
this.zoomEvents();
|
|
112
|
+
this.panEvents();
|
|
113
|
+
|
|
114
|
+
// views
|
|
115
|
+
this.expectedView = new SimpleView(this, 'expected');
|
|
116
|
+
this.actualView = new SimpleView(this, 'actual');
|
|
117
|
+
this.diffView = new SimpleView(this, 'diff');
|
|
118
|
+
this.actualView.render();
|
|
119
|
+
// this.sideToSideView.render()
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/*
|
|
123
|
+
this is the area from the left top canvas corner till the end of the viewport
|
|
124
|
+
┌──────┬─────────────┐
|
|
125
|
+
│ │xxxxxxxx │
|
|
126
|
+
│ │xxxxxxxx │
|
|
127
|
+
│ │xxxxxxxx │
|
|
128
|
+
│ │xxxxxxxx │
|
|
129
|
+
│ │ │
|
|
130
|
+
│ │ │
|
|
131
|
+
│ │ the area │
|
|
132
|
+
│ │ │
|
|
133
|
+
│ │ │
|
|
134
|
+
└──────┴─────────────┘
|
|
135
|
+
*/
|
|
136
|
+
|
|
137
|
+
static calculateExpectedCanvasViewportAreaSize() {
|
|
138
|
+
const viewportWidth = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0);
|
|
139
|
+
const viewportHeight = Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0);
|
|
140
|
+
const canvasDimensions = document.getElementById('snapshoot')!
|
|
141
|
+
.getBoundingClientRect();
|
|
142
|
+
return {
|
|
143
|
+
width: Number(viewportWidth - canvasDimensions.x),
|
|
144
|
+
height: Number(viewportHeight - canvasDimensions.y),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
zoomEvents() {
|
|
149
|
+
this.canvas.on('mouse:wheel', (opt: any) => {
|
|
150
|
+
if (!opt.e.ctrlKey) return;
|
|
151
|
+
const delta = opt.e.deltaY;
|
|
152
|
+
let zoomVal = this.canvas.getZoom();
|
|
153
|
+
|
|
154
|
+
zoomVal *= 0.999 ** delta;
|
|
155
|
+
if (zoomVal > 9) zoomVal = 9;
|
|
156
|
+
if (zoomVal < 0.01) zoomVal = 0.01;
|
|
157
|
+
this.canvas.zoomToPoint({
|
|
158
|
+
x: opt.e.offsetX,
|
|
159
|
+
y: opt.e.offsetY,
|
|
160
|
+
}, zoomVal);
|
|
161
|
+
|
|
162
|
+
// setZoomPercent(() => zoomVal * 100);
|
|
163
|
+
document.dispatchEvent(new Event('zoom'));
|
|
164
|
+
opt.e.preventDefault();
|
|
165
|
+
opt.e.stopPropagation();
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
panEvents() {
|
|
170
|
+
this.canvas.on(
|
|
171
|
+
'mouse:move', (e) => {
|
|
172
|
+
// log.debug(e.e.buttons);
|
|
173
|
+
if ((e.e.buttons === 4)) {
|
|
174
|
+
this.canvas.setCursor('grab');
|
|
175
|
+
|
|
176
|
+
const mEvent = e.e;
|
|
177
|
+
const delta = new fabric.Point(mEvent.movementX, mEvent.movementY);
|
|
178
|
+
this.canvas.relativePan(delta);
|
|
179
|
+
this.canvas.renderAll();
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
this.canvas.on('mouse:wheel', (opt) => {
|
|
185
|
+
if (opt.e.ctrlKey) return;
|
|
186
|
+
const delta = new fabric.Point(-opt.e.deltaX / 2, -opt.e.deltaY / 2);
|
|
187
|
+
this.canvas.relativePan(delta);
|
|
188
|
+
// this.canvas.dispatchEvent(new Event('pan'));
|
|
189
|
+
this.canvas.fire('pan', opt);
|
|
190
|
+
this.canvas.renderAll();
|
|
191
|
+
opt.e.preventDefault();
|
|
192
|
+
opt.e.stopPropagation();
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
selectionEvents() {
|
|
197
|
+
// disable rotation point for selections
|
|
198
|
+
this.canvas.on('selection:created', (e) => {
|
|
199
|
+
const activeSelection: any = e.target;
|
|
200
|
+
if (!activeSelection?._objects?.length || (activeSelection?._objects?.length < 2)) return;
|
|
201
|
+
activeSelection.hasControls = false;
|
|
202
|
+
this.canvas.renderAll();
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
// fired e.g. when you select one object first,
|
|
206
|
+
// then add another via shift+click
|
|
207
|
+
this.canvas.on('selection:updated', (e) => {
|
|
208
|
+
const activeSelection: any = e.target;
|
|
209
|
+
if (!activeSelection?._objects?.length || (activeSelection?._objects?.length < 2)) return;
|
|
210
|
+
if (activeSelection.hasControls) {
|
|
211
|
+
activeSelection.hasControls = false;
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// get objects() {
|
|
217
|
+
// return this.canvas.getObjects();
|
|
218
|
+
// }
|
|
219
|
+
|
|
220
|
+
async destroyAllViews() {
|
|
221
|
+
this.expectedView.destroy();
|
|
222
|
+
this.actualView.destroy();
|
|
223
|
+
this.diffView.destroy();
|
|
224
|
+
await this.sliderView.destroy();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
async switchView(view: string) {
|
|
228
|
+
// this.currentView = view;
|
|
229
|
+
await this.destroyAllViews();
|
|
230
|
+
this.sliderView = new SideToSideView(
|
|
231
|
+
{
|
|
232
|
+
mainView: this,
|
|
233
|
+
},
|
|
234
|
+
);
|
|
235
|
+
this[`${view}View`].render();
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
panToCanvasWidthCenter(imageName: string) {
|
|
239
|
+
// if (this.pannedOnInit) return;
|
|
240
|
+
// this.pannedOnInit = true;
|
|
241
|
+
|
|
242
|
+
this.canvas.absolutePan(new fabric.Point(0, 0));
|
|
243
|
+
const delta = new fabric.Point(
|
|
244
|
+
((this.canvas.width / 2)
|
|
245
|
+
- ((this[imageName].width * this.canvas.getZoom()) / 2)
|
|
246
|
+
),
|
|
247
|
+
// ((this.canvas.width / 2) - (this[imageName].getScaledWidth() / 2)),
|
|
248
|
+
0,
|
|
249
|
+
);
|
|
250
|
+
this.canvas.relativePan(delta);
|
|
251
|
+
// this.canvas.renderAll(); console.log('render!!!');
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
removeActiveIgnoreRegions() {
|
|
255
|
+
const els = this.canvas.getActiveObjects()
|
|
256
|
+
.filter((x) => x.name === 'ignore_rect');
|
|
257
|
+
this.canvas.discardActiveObject()
|
|
258
|
+
.renderAll();
|
|
259
|
+
if (els.length === 0) {
|
|
260
|
+
// eslint-disable-next-line no-undef,no-alert
|
|
261
|
+
alert('there is no active regions for removing');
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
els.forEach((el) => {
|
|
265
|
+
this.canvas.remove(el);
|
|
266
|
+
});
|
|
267
|
+
this.canvas.renderAll();
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
addRect(params: IRectParams) {
|
|
271
|
+
// eslint-disable-next-line no-param-reassign
|
|
272
|
+
params.name = params.name ? params.name : 'default_rect';
|
|
273
|
+
let lastLeft = null;
|
|
274
|
+
let lastTop = null;
|
|
275
|
+
let width = null;
|
|
276
|
+
let height = null;
|
|
277
|
+
if ((this.getLastRegion() !== undefined) && (this.getLastRegion().name === 'ignore_rect')) {
|
|
278
|
+
lastLeft = this.getLastRegion().left || 50;
|
|
279
|
+
lastTop = this.getLastRegion().top;
|
|
280
|
+
width = this.getLastRegion()
|
|
281
|
+
.getScaledWidth();
|
|
282
|
+
height = this.getLastRegion()
|
|
283
|
+
.getScaledHeight();
|
|
284
|
+
}
|
|
285
|
+
// if last elements fit in current viewport create new region near this region
|
|
286
|
+
const top = (lastTop > document.documentElement.scrollTop
|
|
287
|
+
&& lastTop < document.documentElement.scrollTop + window.innerHeight)
|
|
288
|
+
? lastTop + 20
|
|
289
|
+
: document.documentElement.scrollTop + 50;
|
|
290
|
+
const left = (lastLeft < (this.canvas.width - 80)) ? lastLeft + 20 : lastLeft - 50;
|
|
291
|
+
return new fabric.Rect({
|
|
292
|
+
left: params.left || left,
|
|
293
|
+
top: params.top || top,
|
|
294
|
+
fill: params.fill || 'blue',
|
|
295
|
+
width: params.width || width || 200,
|
|
296
|
+
height: params.height || height || 100,
|
|
297
|
+
strokeWidth: params.strokeWidth || 2,
|
|
298
|
+
// stroke: params.stroke || 'rgba(100,200,200,0.5)',
|
|
299
|
+
stroke: params.stroke || 'black',
|
|
300
|
+
opacity: 0.5,
|
|
301
|
+
name: params.name,
|
|
302
|
+
// uniformScaling: true,
|
|
303
|
+
strokeUniform: true,
|
|
304
|
+
noScaleCache: false,
|
|
305
|
+
cornerSize: 9,
|
|
306
|
+
transparentCorners: false,
|
|
307
|
+
cornerColor: 'rgb(26, 115, 232)',
|
|
308
|
+
cornerStrokeColor: 'rgb(255, 255, 255)',
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
addIgnoreRegion(params) {
|
|
313
|
+
Object.assign(params, { fill: 'MediumVioletRed' });
|
|
314
|
+
const r = this.addRect(params);
|
|
315
|
+
r.setControlsVisibility({
|
|
316
|
+
bl: true,
|
|
317
|
+
br: true,
|
|
318
|
+
tl: true,
|
|
319
|
+
tr: true,
|
|
320
|
+
mt: true,
|
|
321
|
+
mb: true,
|
|
322
|
+
mtr: false,
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
this.canvas.add(r);
|
|
326
|
+
r.bringToFront();
|
|
327
|
+
// become selected
|
|
328
|
+
if (params.noSelect) {
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
this.canvas.setActiveObject(r);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
addBoundingRegion(name) {
|
|
335
|
+
const params = {
|
|
336
|
+
name,
|
|
337
|
+
fill: 'rgba(0,0,0,0)',
|
|
338
|
+
stroke: 'green',
|
|
339
|
+
strokeWidth: 3,
|
|
340
|
+
top: 1,
|
|
341
|
+
left: 1,
|
|
342
|
+
width: this.expectedImage.getScaledWidth() - 10,
|
|
343
|
+
height: this.expectedImage.getScaledHeight() - 10,
|
|
344
|
+
};
|
|
345
|
+
const r = this.addRect(params);
|
|
346
|
+
this.canvas.add(r);
|
|
347
|
+
r.bringToFront();
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
removeAllRegions() {
|
|
351
|
+
const regions = this.allRects;
|
|
352
|
+
regions.forEach((region) => {
|
|
353
|
+
this.canvas.remove(region);
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
get allRects() {
|
|
358
|
+
return this.canvas.getObjects()
|
|
359
|
+
.filter((r) => (r.name === 'ignore_rect') || (r.name === 'bound_rect'));
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
getLastRegion() {
|
|
363
|
+
return this.canvas.item(this.canvas.getObjects().length - 1);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* 1. collect data about all rects
|
|
368
|
+
* 2. convert the data to resemble.js format
|
|
369
|
+
* 3. return json string
|
|
370
|
+
*/
|
|
371
|
+
getRectData() {
|
|
372
|
+
const rects = this.allRects;
|
|
373
|
+
const data = [];
|
|
374
|
+
const coef = parseFloat(this.coef);
|
|
375
|
+
|
|
376
|
+
rects.forEach((reg) => {
|
|
377
|
+
const right = reg.left + reg.getScaledWidth();
|
|
378
|
+
const bottom = reg.top + reg.getScaledHeight();
|
|
379
|
+
if (coef) {
|
|
380
|
+
data.push({
|
|
381
|
+
name: reg.name,
|
|
382
|
+
top: reg.top * coef,
|
|
383
|
+
left: reg.left * coef,
|
|
384
|
+
bottom: bottom * coef,
|
|
385
|
+
right: right * coef,
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
return JSON.stringify(data);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
get coef() {
|
|
393
|
+
return this.expectedImage.height / this.expectedImage.getScaledHeight();
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
static async sendIgnoreRegions(id: string, regionsData) {
|
|
397
|
+
try {
|
|
398
|
+
const response = await fetch(`${config.baseUri}/v1/baselines/${id}`, {
|
|
399
|
+
method: 'PUT',
|
|
400
|
+
headers: { 'Content-Type': 'application/json' },
|
|
401
|
+
body: JSON.stringify({ id, ignoreRegions: regionsData }),
|
|
402
|
+
});
|
|
403
|
+
const text = await response.text();
|
|
404
|
+
if (response.status === 200) {
|
|
405
|
+
log.debug(`Successful send baseline ignored regions, id: '${id}' resp: '${text}'`);
|
|
406
|
+
successMsg({ message: 'ignored regions was saved' });
|
|
407
|
+
// MainView.showToaster('ignored regions was saved');
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
log.error(`Cannot set baseline ignored regions , status: '${response.status}', resp: '${text}'`);
|
|
411
|
+
errorMsg({ error: 'Cannot set baseline ignored regions' });
|
|
412
|
+
// MainView.showToaster('Cannot set baseline ignored regions', 'Error');
|
|
413
|
+
} catch (e) {
|
|
414
|
+
log.error(`Cannot set baseline ignored regions: ${e.stack || e.toString()}`);
|
|
415
|
+
errorMsg({ error: 'Cannot set baseline ignored regions' });
|
|
416
|
+
// MainView.showToaster('Cannot set baseline ignored regions', 'Error');
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* convert json to fabric.js format
|
|
422
|
+
* @param {string} regions JSON string that contain data about regions in resemble.js format
|
|
423
|
+
* @returns {object} region data in fabric.js format
|
|
424
|
+
*/
|
|
425
|
+
convertRegionsDataFromServer(regions) {
|
|
426
|
+
const data = [];
|
|
427
|
+
const coef = parseFloat(this.coef);
|
|
428
|
+
regions
|
|
429
|
+
.forEach((reg) => {
|
|
430
|
+
const width = reg.right - reg.left;
|
|
431
|
+
const height = reg.bottom - reg.top;
|
|
432
|
+
if (coef) {
|
|
433
|
+
data.push({
|
|
434
|
+
name: reg.name,
|
|
435
|
+
top: reg.top / coef,
|
|
436
|
+
left: reg.left / coef,
|
|
437
|
+
width: width / coef,
|
|
438
|
+
height: height / coef,
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
return data;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
drawRegions(data) {
|
|
446
|
+
// log.debug({ data });
|
|
447
|
+
if (!data || data === 'undefined') {
|
|
448
|
+
return;
|
|
449
|
+
// log.error('The regions data is empty')
|
|
450
|
+
}
|
|
451
|
+
const regs = this.convertRegionsDataFromServer(JSON.parse(data));
|
|
452
|
+
// log.debug('converted:', regs.length, regs);
|
|
453
|
+
const classThis = this;
|
|
454
|
+
regs.forEach((regParams) => {
|
|
455
|
+
// eslint-disable-next-line no-param-reassign
|
|
456
|
+
regParams['noSelect'] = true;
|
|
457
|
+
classThis.addIgnoreRegion(regParams);
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
static async getRegionsData(baselineId: string) {
|
|
462
|
+
try {
|
|
463
|
+
if (!baselineId) {
|
|
464
|
+
// log.debug('Cannot get regions, baseline id is empty');
|
|
465
|
+
return [];
|
|
466
|
+
}
|
|
467
|
+
const url = `${config.baseUri}/v1/baselines?filter={"_id":"${baselineId}"}`;
|
|
468
|
+
// log.debug({ url });
|
|
469
|
+
const response = await fetch(url);
|
|
470
|
+
const text = await response.text();
|
|
471
|
+
if (response.status === 200) {
|
|
472
|
+
log.debug(`Successfully got ignored regions, id: '${baselineId}' resp: '${text}'`);
|
|
473
|
+
return JSON.parse(text).results[0];
|
|
474
|
+
}
|
|
475
|
+
if (response.status === 202) {
|
|
476
|
+
log.debug('No regions');
|
|
477
|
+
return [];
|
|
478
|
+
}
|
|
479
|
+
log.error(`Cannot get baseline ignored regions , status: '${response.status}', resp: '${text}'`);
|
|
480
|
+
// MainView.showToaster('Cannot get baseline ignored regions', 'Error');
|
|
481
|
+
errorMsg({ error: 'Cannot get baseline ignored regions' });
|
|
482
|
+
} catch (e) {
|
|
483
|
+
log.error(`Cannot get baseline ignored regions: ${e.stack || e.toString()}`);
|
|
484
|
+
// MainView.showToaster('Cannot get baseline ignored regions', 'Error');
|
|
485
|
+
errorMsg({ error: 'Cannot get baseline ignored regions' });
|
|
486
|
+
}
|
|
487
|
+
return null;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
async getSnapshotIgnoreRegionsDataAndDrawRegions(id: string) {
|
|
491
|
+
this.removeAllRegions();
|
|
492
|
+
const regionData = await MainView.getRegionsData(id);
|
|
493
|
+
this.drawRegions(regionData.ignoreRegions);
|
|
494
|
+
}
|
|
495
|
+
}
|