├── .gitattributes ├── .gitignore ├── Cemex.SSE.Test.Questions.sln ├── Problem_01_Counting_Elements ├── Problem_01_Counting_Elements.csproj └── Program.cs ├── Problem_02_Baseball_Game_Score_Calculator ├── Problem_02_Baseball_Game_Score_Calculator.csproj └── Program.cs └── Problem_03._CRUD_with_products ├── .browserslistrc ├── .editorconfig ├── .gitignore ├── README.md ├── angular.json ├── karma.conf.js ├── package-lock.json ├── package.json ├── src ├── app │ ├── add-product │ │ ├── add-product.component.html │ │ ├── add-product.component.scss │ │ ├── add-product.component.spec.ts │ │ └── add-product.component.ts │ ├── app-routing.module.ts │ ├── app.component.html │ ├── app.component.scss │ ├── app.component.spec.ts │ ├── app.component.ts │ ├── app.module.ts │ ├── auth.guard.ts │ ├── home │ │ ├── home.component.html │ │ ├── home.component.scss │ │ ├── home.component.spec.ts │ │ └── home.component.ts │ ├── login │ │ ├── login.component.css │ │ ├── login.component.html │ │ ├── login.component.spec.ts │ │ └── login.component.ts │ └── shared │ │ ├── data.service.spec.ts │ │ └── data.service.ts ├── assets │ └── .gitkeep ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── favicon.ico ├── index.html ├── main.ts ├── polyfills.ts ├── styles.scss └── test.ts ├── tsconfig.app.json ├── tsconfig.json └── tsconfig.spec.json /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd -------------------------------------------------------------------------------- /Cemex.SSE.Test.Questions.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.0.32112.339 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Problem_01_Counting_Elements", "Problem_01_Counting_Elements\Problem_01_Counting_Elements.csproj", "{A42151BE-B987-445C-8456-77A8157D4AF1}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Problem_02_Baseball_Game_Score_Calculator", "Problem_02_Baseball_Game_Score_Calculator\Problem_02_Baseball_Game_Score_Calculator.csproj", "{05CA744E-92FC-4D44-9809-2DC77E8E0657}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {A42151BE-B987-445C-8456-77A8157D4AF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {A42151BE-B987-445C-8456-77A8157D4AF1}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {A42151BE-B987-445C-8456-77A8157D4AF1}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {A42151BE-B987-445C-8456-77A8157D4AF1}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {05CA744E-92FC-4D44-9809-2DC77E8E0657}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {05CA744E-92FC-4D44-9809-2DC77E8E0657}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {05CA744E-92FC-4D44-9809-2DC77E8E0657}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {05CA744E-92FC-4D44-9809-2DC77E8E0657}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {84E3E7D8-E774-4D24-9291-F1A410D6337B} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /Problem_01_Counting_Elements/Problem_01_Counting_Elements.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Problem_01_Counting_Elements/Program.cs: -------------------------------------------------------------------------------- 1 | using static System.Console; 2 | 3 | int[] arr1 = { 1, 2, 3 }; 4 | 5 | int[] arr2 = { 1, 1, 3, 3, 5, 5, 7, 7 }; 6 | 7 | int[] arr3 = { 1, 3, 2, 3, 5, 0 }; 8 | 9 | int[] arr4 = { 1, 1, 2, 2 }; 10 | 11 | int[] arr5 = { 1, 1, 2 }; 12 | 13 | 14 | static int ElementCounter(int[] arr) 15 | { 16 | var unique = arr.Distinct(); 17 | return (from item in unique where arr.Contains(item + 1) select arr.Count(x => x == item)).ToList().Sum(); 18 | } 19 | 20 | WriteLine(ElementCounter(arr1)); 21 | WriteLine(ElementCounter(arr2)); 22 | WriteLine(ElementCounter(arr3)); 23 | WriteLine(ElementCounter(arr4)); 24 | WriteLine(ElementCounter(arr5)); -------------------------------------------------------------------------------- /Problem_02_Baseball_Game_Score_Calculator/Problem_02_Baseball_Game_Score_Calculator.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Problem_02_Baseball_Game_Score_Calculator/Program.cs: -------------------------------------------------------------------------------- 1 | using static System.Console; 2 | using static System.Int32; 3 | 4 | string[] ops1 = { "5", "2", "C", "D", "+" }; 5 | string[] ops2 = { "5", "-2", "4", "C", "D", "9", "+", "+" }; 6 | string[] ops3 = { "1" }; 7 | 8 | WriteLine(CalculatePoints(ops1)); 9 | WriteLine(CalculatePoints(ops2)); 10 | WriteLine(CalculatePoints(ops3)); 11 | 12 | 13 | static int CalculatePoints(IEnumerable ops) 14 | { 15 | Stack stack = new(); 16 | 17 | foreach (var op in ops) 18 | { 19 | switch (op) 20 | { 21 | case "+" 22 | : //Record a new score that is the sum of the previous two scores. It is guaranteed there will always be two previous scores 23 | { 24 | int top = stack.Pop(); 25 | int newTop = top + stack.Peek(); 26 | stack.Push(top); 27 | stack.Push(newTop); 28 | break; 29 | } 30 | case "C" 31 | : //Invalidate the previous score, removing it from the record. It is guaranteed there will always be a previous score. 32 | stack.Pop(); 33 | break; 34 | case "D" 35 | : //Record a new score that is double the previous score. It is guaranteed there will always be a previous score. 36 | stack.Push(2 * stack.Peek()); 37 | break; 38 | default: 39 | { 40 | if (TryParse(op, out int intOp)) 41 | stack.Push(intOp); 42 | break; 43 | } 44 | } 45 | } 46 | 47 | return stack.Aggregate(0, (current, score) => current + score); 48 | } -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line. 18 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.ts] 12 | quote_type = single 13 | 14 | [*.md] 15 | max_line_length = off 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | # Only exists if Bazel was run 8 | /bazel-out 9 | 10 | # dependencies 11 | /node_modules 12 | 13 | # profiling files 14 | chrome-profiler-events*.json 15 | 16 | # IDEs and editors 17 | /.idea 18 | .project 19 | .classpath 20 | .c9/ 21 | *.launch 22 | .settings/ 23 | *.sublime-workspace 24 | 25 | # IDE - VSCode 26 | .vscode/* 27 | !.vscode/settings.json 28 | !.vscode/tasks.json 29 | !.vscode/launch.json 30 | !.vscode/extensions.json 31 | .history/* 32 | 33 | # misc 34 | /.sass-cache 35 | /connect.lock 36 | /coverage 37 | /libpeerconnection.log 38 | npm-debug.log 39 | yarn-error.log 40 | testem.log 41 | /typings 42 | 43 | # System Files 44 | .DS_Store 45 | Thumbs.db 46 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/README.md: -------------------------------------------------------------------------------- 1 | # CemexHRM 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 12.1.4. 4 | 5 | ## Development server 6 | 7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. 8 | 9 | ## Code scaffolding 10 | 11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 12 | 13 | ## Build 14 | 15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. 16 | 17 | ## Running unit tests 18 | 19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 20 | 21 | ## Running end-to-end tests 22 | 23 | Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities. 24 | 25 | ## Further help 26 | 27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. 28 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "cli": { 4 | "analytics": "f60d8310-1a57-45a5-b2a0-29c897dc4230" 5 | }, 6 | "version": 1, 7 | "newProjectRoot": "projects", 8 | "projects": { 9 | "CemexHRM": { 10 | "projectType": "application", 11 | "schematics": { 12 | "@schematics/angular:component": { 13 | "style": "scss" 14 | }, 15 | "@schematics/angular:application": { 16 | "strict": true 17 | } 18 | }, 19 | "root": "", 20 | "sourceRoot": "src", 21 | "prefix": "app", 22 | "architect": { 23 | "build": { 24 | "builder": "@angular-devkit/build-angular:browser", 25 | "options": { 26 | "outputPath": "dist/CemexHRM", 27 | "index": "src/index.html", 28 | "main": "src/main.ts", 29 | "polyfills": "src/polyfills.ts", 30 | "tsConfig": "tsconfig.app.json", 31 | "inlineStyleLanguage": "scss", 32 | "assets": [ 33 | "src/favicon.ico", 34 | "src/assets" 35 | ], 36 | "styles": [ 37 | "./node_modules/@angular/material/prebuilt-themes/pink-bluegrey.css", 38 | "src/styles.scss" 39 | ], 40 | "scripts": [] 41 | }, 42 | "configurations": { 43 | "production": { 44 | "budgets": [ 45 | { 46 | "type": "initial", 47 | "maximumWarning": "500kb", 48 | "maximumError": "1mb" 49 | }, 50 | { 51 | "type": "anyComponentStyle", 52 | "maximumWarning": "2kb", 53 | "maximumError": "4kb" 54 | } 55 | ], 56 | "fileReplacements": [ 57 | { 58 | "replace": "src/environments/environment.ts", 59 | "with": "src/environments/environment.prod.ts" 60 | } 61 | ], 62 | "outputHashing": "all" 63 | }, 64 | "development": { 65 | "buildOptimizer": false, 66 | "optimization": false, 67 | "vendorChunk": true, 68 | "extractLicenses": false, 69 | "sourceMap": true, 70 | "namedChunks": true 71 | } 72 | }, 73 | "defaultConfiguration": "production" 74 | }, 75 | "serve": { 76 | "builder": "@angular-devkit/build-angular:dev-server", 77 | "configurations": { 78 | "production": { 79 | "browserTarget": "CemexHRM:build:production" 80 | }, 81 | "development": { 82 | "browserTarget": "CemexHRM:build:development" 83 | } 84 | }, 85 | "defaultConfiguration": "development" 86 | }, 87 | "extract-i18n": { 88 | "builder": "@angular-devkit/build-angular:extract-i18n", 89 | "options": { 90 | "browserTarget": "CemexHRM:build" 91 | } 92 | }, 93 | "test": { 94 | "builder": "@angular-devkit/build-angular:karma", 95 | "options": { 96 | "main": "src/test.ts", 97 | "polyfills": "src/polyfills.ts", 98 | "tsConfig": "tsconfig.spec.json", 99 | "karmaConfig": "karma.conf.js", 100 | "inlineStyleLanguage": "scss", 101 | "assets": [ 102 | "src/favicon.ico", 103 | "src/assets" 104 | ], 105 | "styles": [ 106 | "./node_modules/@angular/material/prebuilt-themes/pink-bluegrey.css", 107 | "src/styles.scss" 108 | ], 109 | "scripts": [] 110 | } 111 | } 112 | } 113 | } 114 | }, 115 | "defaultProject": "CemexHRM" 116 | } 117 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | jasmine: { 17 | // you can add configuration options for Jasmine here 18 | // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html 19 | // for example, you can disable the random execution with `random: false` 20 | // or set a specific seed with `seed: 4321` 21 | }, 22 | clearContext: false // leave Jasmine Spec Runner output visible in browser 23 | }, 24 | jasmineHtmlReporter: { 25 | suppressAll: true // removes the duplicated traces 26 | }, 27 | coverageReporter: { 28 | dir: require('path').join(__dirname, './coverage/CemexHRM'), 29 | subdir: '.', 30 | reporters: [ 31 | { type: 'html' }, 32 | { type: 'text-summary' } 33 | ] 34 | }, 35 | reporters: ['progress', 'kjhtml'], 36 | port: 9876, 37 | colors: true, 38 | logLevel: config.LOG_INFO, 39 | autoWatch: true, 40 | browsers: ['Chrome'], 41 | singleRun: false, 42 | restartOnFileChange: true 43 | }); 44 | }; 45 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cemex-hrm", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "watch": "ng build --watch --configuration development", 9 | "test": "ng test" 10 | }, 11 | "private": true, 12 | "dependencies": { 13 | "@angular/animations": "~12.1.0", 14 | "@angular/cdk": "^12.2.13", 15 | "@angular/common": "~12.1.0", 16 | "@angular/compiler": "~12.1.0", 17 | "@angular/core": "~12.1.0", 18 | "@angular/forms": "~12.1.0", 19 | "@angular/material": "^12.2.13", 20 | "@angular/platform-browser": "~12.1.0", 21 | "@angular/platform-browser-dynamic": "~12.1.0", 22 | "@angular/router": "~12.1.0", 23 | "rxjs": "~6.6.0", 24 | "tslib": "^2.2.0", 25 | "zone.js": "~0.11.4" 26 | }, 27 | "devDependencies": { 28 | "@angular-devkit/build-angular": "~12.1.4", 29 | "@angular/cli": "~12.1.4", 30 | "@angular/compiler-cli": "~12.1.0", 31 | "@types/jasmine": "~3.8.0", 32 | "@types/node": "^12.11.1", 33 | "jasmine-core": "~3.8.0", 34 | "karma": "~6.3.0", 35 | "karma-chrome-launcher": "~3.1.0", 36 | "karma-coverage": "~2.0.3", 37 | "karma-jasmine": "~4.0.0", 38 | "karma-jasmine-html-reporter": "~1.7.0", 39 | "typescript": "~4.3.2" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/app/add-product/add-product.component.html: -------------------------------------------------------------------------------- 1 |

Add New Product

2 | 3 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/app/add-product/add-product.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/LeetCode.Solutions/5f7ee73b8cc1953f3b8d1b84369143531e4d11aa/Problem_03._CRUD_with_products/src/app/add-product/add-product.component.scss -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/app/add-product/add-product.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { AddProductComponent } from './add-product.component'; 4 | 5 | describe('AddProductComponent', () => { 6 | let component: AddProductComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ AddProductComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(AddProductComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/app/add-product/add-product.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-add-product', 5 | templateUrl: './add-product.component.html', 6 | styleUrls: ['./add-product.component.scss'] 7 | }) 8 | export class AddProductComponent implements OnInit { 9 | 10 | constructor() { } 11 | 12 | ngOnInit(): void { 13 | } 14 | 15 | onNoClick() { 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { RouterModule, Routes } from '@angular/router'; 3 | import {LoginComponent} from "./login/login.component"; 4 | import {HomeComponent} from "./home/home.component"; 5 | 6 | const routes: Routes = [ 7 | // { path: '**', component:LoginComponent }, 8 | { path: 'login', component:LoginComponent }, 9 | { path: 'home', component:HomeComponent }, 10 | 11 | ]; 12 | 13 | @NgModule({ 14 | imports: [RouterModule.forRoot(routes)], 15 | exports: [RouterModule] 16 | }) 17 | export class AppRoutingModule { } 18 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/app/app.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/LeetCode.Solutions/5f7ee73b8cc1953f3b8d1b84369143531e4d11aa/Problem_03._CRUD_with_products/src/app/app.component.scss -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | import { RouterTestingModule } from '@angular/router/testing'; 3 | import { AppComponent } from './app.component'; 4 | 5 | describe('AppComponent', () => { 6 | beforeEach(async () => { 7 | await TestBed.configureTestingModule({ 8 | imports: [ 9 | RouterTestingModule 10 | ], 11 | declarations: [ 12 | AppComponent 13 | ], 14 | }).compileComponents(); 15 | }); 16 | 17 | it('should create the app', () => { 18 | const fixture = TestBed.createComponent(AppComponent); 19 | const app = fixture.componentInstance; 20 | expect(app).toBeTruthy(); 21 | }); 22 | 23 | it(`should have as title 'CemexHRM'`, () => { 24 | const fixture = TestBed.createComponent(AppComponent); 25 | const app = fixture.componentInstance; 26 | expect(app.title).toEqual('CemexHRM'); 27 | }); 28 | 29 | it('should render title', () => { 30 | const fixture = TestBed.createComponent(AppComponent); 31 | fixture.detectChanges(); 32 | const compiled = fixture.nativeElement as HTMLElement; 33 | expect(compiled.querySelector('.content span')?.textContent).toContain('CemexHRM app is running!'); 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root', 5 | templateUrl: './app.component.html', 6 | styleUrls: ['./app.component.scss'] 7 | }) 8 | export class AppComponent { 9 | title = 'CemexHRM'; 10 | } 11 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { AppRoutingModule } from './app-routing.module'; 4 | import { AppComponent } from './app.component'; 5 | import { HomeComponent } from './home/home.component'; 6 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; 7 | import { MatTableModule} from '@angular/material/table'; 8 | import { MatSlideToggleModule } from '@angular/material/slide-toggle'; 9 | import { MatPaginatorModule } from '@angular/material/paginator'; 10 | import { AddProductComponent } from './add-product/add-product.component'; 11 | import {MatFormFieldModule} from "@angular/material/form-field"; 12 | import {MatDialogModule} from "@angular/material/dialog"; 13 | import {MatButtonModule} from "@angular/material/button"; 14 | import {MatInputModule} from "@angular/material/input"; 15 | import { LoginComponent } from './login/login.component'; 16 | import {MatCardModule} from "@angular/material/card"; 17 | 18 | @NgModule({ 19 | declarations: [ 20 | AppComponent, 21 | HomeComponent, 22 | AddProductComponent, 23 | LoginComponent 24 | ], 25 | imports: [ 26 | BrowserModule, 27 | AppRoutingModule, 28 | BrowserAnimationsModule, 29 | MatTableModule, 30 | MatSlideToggleModule, 31 | MatPaginatorModule, 32 | MatDialogModule, 33 | MatButtonModule, 34 | MatInputModule, 35 | MatFormFieldModule, 36 | MatCardModule 37 | ], 38 | providers: [], 39 | bootstrap: [AppComponent], 40 | schemas: [CUSTOM_ELEMENTS_SCHEMA] 41 | }) 42 | export class AppModule { } 43 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/app/auth.guard.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot, UrlTree } from '@angular/router'; 3 | import { Observable } from 'rxjs'; 4 | 5 | @Injectable({ 6 | providedIn: 'root' 7 | }) 8 | export class AuthGuard implements CanActivate { 9 | canActivate( 10 | route: ActivatedRouteSnapshot, 11 | state: RouterStateSnapshot): Observable | Promise | boolean | UrlTree { 12 | return true; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/app/home/home.component.html: -------------------------------------------------------------------------------- 1 |
2 |

Search Products

3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 |
Active Product Name {{element.productName}} SKU {{element.SKU}} Created {{element.created}} Retail Price {{element.retailPrice}} Sale Price {{element.salePrice}} Lowest Price {{element.lowestPrice}}
53 | 54 | 55 | 56 |
57 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/app/home/home.component.scss: -------------------------------------------------------------------------------- 1 | table { 2 | width: 100%; 3 | } -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/app/home/home.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { HomeComponent } from './home.component'; 4 | 5 | describe('HomeComponent', () => { 6 | let component: HomeComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ HomeComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(HomeComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/app/home/home.component.ts: -------------------------------------------------------------------------------- 1 | import {Component, OnInit, AfterViewInit, ViewChild} from '@angular/core'; 2 | import {MatPaginator} from '@angular/material/paginator'; 3 | import {MatTableDataSource} from '@angular/material/table'; 4 | import {MatDialog} from '@angular/material/dialog'; 5 | import {AddProductComponent} from '../add-product/add-product.component'; 6 | import {DataService} from "../shared/data.service"; 7 | 8 | export interface ProductData { 9 | productId: number; 10 | productName: string; 11 | SKU: string; 12 | created: string; 13 | retailPrice: number; 14 | salePrice: number; 15 | lowestPrice: number; 16 | status:boolean; 17 | } 18 | 19 | @Component({ 20 | selector: 'app-home', 21 | templateUrl: './home.component.html', 22 | styleUrls: ['./home.component.scss'] 23 | }) 24 | 25 | 26 | export class HomeComponent implements OnInit, AfterViewInit { 27 | displayedColumns: string[] = ['status','productName', 'SKU', 'created', 'retailPrice', 'salePrice', 'lowestPrice' ]; 28 | dataSource: MatTableDataSource ; 29 | dataSourceService: any ; 30 | 31 | constructor(public dialog: MatDialog, data:DataService) { 32 | this.dataSource = new MatTableDataSource(data.getProductData()); 33 | this.dataSourceService = data; 34 | } 35 | 36 | ngOnInit(): void {} 37 | 38 | @ViewChild(MatPaginator) 39 | paginator!: MatPaginator; 40 | 41 | ngAfterViewInit() { 42 | this.dataSource.paginator = this.paginator; 43 | } 44 | 45 | applyFilter(event: Event): void { 46 | this.dataSource.filter = (event.target as HTMLInputElement).value.trim().toLocaleLowerCase(); 47 | } 48 | 49 | addNewProduct():void{ 50 | const dialogRef = this.dialog.open(AddProductComponent, { 51 | width: '500px', 52 | height: '500px' 53 | }); 54 | 55 | dialogRef.afterClosed().subscribe(result => { 56 | this.dataSource = this.dataSourceService.getProductData(); 57 | }); 58 | } 59 | } 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/app/login/login.component.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | height: 100%; 4 | } 5 | 6 | body { 7 | margin: 0; 8 | font-family: Roboto, "Helvetica Neue", sans-serif; 9 | min-height: 100vh; 10 | background: #e2e2e2; 11 | } 12 | 13 | .app-header { 14 | justify-content: space-between; 15 | position: fixed; 16 | top: 0; 17 | left: 0; 18 | right: 0; 19 | z-index: 2; 20 | box-shadow: 0 3px 5px -1px rgba(0, 0, 0, .2), 0 6px 10px 0 rgba(0, 0, 0, .14), 0 1px 18px 0 rgba(0, 0, 0, .12); 21 | } 22 | 23 | .login-wrapper { 24 | height: 100%; 25 | } 26 | 27 | .positronx { 28 | text-decoration: none; 29 | color: #ffffff; 30 | } 31 | 32 | .box { 33 | position: relative; 34 | top: 0; 35 | opacity: 1; 36 | float: left; 37 | padding: 60px 50px 40px 50px; 38 | width: 100%; 39 | background: #fff; 40 | border-radius: 10px; 41 | transform: scale(1); 42 | -webkit-transform: scale(1); 43 | -ms-transform: scale(1); 44 | z-index: 5; 45 | max-width: 330px; 46 | } 47 | 48 | .box.back { 49 | transform: scale(.95); 50 | -webkit-transform: scale(.95); 51 | -ms-transform: scale(.95); 52 | top: -20px; 53 | opacity: .8; 54 | z-index: -1; 55 | } 56 | 57 | .box:before { 58 | content: ""; 59 | width: 100%; 60 | height: 30px; 61 | border-radius: 10px; 62 | position: absolute; 63 | top: -10px; 64 | background: rgba(255, 255, 255, .6); 65 | left: 0; 66 | transform: scale(.95); 67 | -webkit-transform: scale(.95); 68 | -ms-transform: scale(.95); 69 | z-index: -1; 70 | } 71 | 72 | .login-wrapper .example-form { 73 | min-width: 100%; 74 | max-width: 300px; 75 | width: 100%; 76 | } 77 | 78 | .login-wrapper .example-full-width, 79 | .login-wrapper .btn-block { 80 | width: 100%; 81 | } 82 | 83 | .login-wrapper mat-card-header { 84 | text-align: center; 85 | width: 100%; 86 | display: block; 87 | font-weight: 700; 88 | } 89 | 90 | .login-wrapper mat-card-header mat-card-title { 91 | font-size: 30px; 92 | margin: 0; 93 | } 94 | 95 | .login-wrapper .mat-card { 96 | padding: 40px 70px 50px; 97 | } 98 | 99 | .login-wrapper .mat-stroked-button { 100 | border: 1px solid currentColor; 101 | line-height: 54px; 102 | background: #FFF7FA; 103 | } 104 | 105 | .login-wrapper .mat-form-field-appearance-legacy .mat-form-field-infix { 106 | padding: 0.8375em 0; 107 | } 108 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/app/login/login.component.html: -------------------------------------------------------------------------------- 1 | 23 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/app/login/login.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { LoginComponent } from './login.component'; 4 | 5 | describe('LoginComponent', () => { 6 | let component: LoginComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async () => { 10 | await TestBed.configureTestingModule({ 11 | declarations: [ LoginComponent ] 12 | }) 13 | .compileComponents(); 14 | }); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(LoginComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/app/login/login.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import {Router} from '@angular/router'; 3 | 4 | interface User { 5 | email: string; 6 | password: string; 7 | } 8 | 9 | 10 | @Component({ 11 | selector: 'app-login', 12 | templateUrl: './login.component.html', 13 | styleUrls: ['./login.component.css'] 14 | }) 15 | export class LoginComponent implements OnInit { 16 | user: User ; 17 | constructor(private route:Router) { 18 | this.user = { 19 | email: '', 20 | password: '' 21 | }; 22 | } 23 | 24 | ngOnInit(): void { 25 | } 26 | 27 | loginUser() { 28 | if(this.user.email == "admin@gmail.com" && this.user.password == "admin") { 29 | this.route.navigate(['home']); 30 | } else { 31 | alert("Invalid Credentials"); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/app/shared/data.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { DataService } from './data.service'; 4 | 5 | describe('DataService', () => { 6 | let service: DataService; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | service = TestBed.inject(DataService); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(service).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/app/shared/data.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import {ProductData} from "../home/home.component"; 3 | 4 | @Injectable({ 5 | providedIn: 'root' 6 | }) 7 | export class DataService { 8 | 9 | constructor() { } 10 | 11 | getProductData() : ProductData[]{ 12 | return productData; 13 | } 14 | } 15 | 16 | let productData: ProductData[] = [ 17 | { productId: getRandomInt(1,1000), productName: 'Apple iPhone 12', SKU: randomString(10), created: randomDate() , retailPrice: getRandomInt(500,1000), salePrice: getRandomInt(500,1000), lowestPrice: getRandomInt(500,1000) ,status: false,}, 18 | { productId: getRandomInt(1,1000), productName: 'Apple iPhone 11', SKU: randomString(10), created: randomDate() , retailPrice: getRandomInt(500,1000), salePrice: getRandomInt(500,1000), lowestPrice: getRandomInt(500,1000) ,status: true,}, 19 | { productId: getRandomInt(1,1000), productName: 'Apple iPhone XR', SKU: randomString(10), created: randomDate() , retailPrice: getRandomInt(500,1000), salePrice: getRandomInt(500,1000), lowestPrice: getRandomInt(500,1000) ,status: true,}, 20 | { productId: getRandomInt(1,1000), productName: 'Apple iPhone XS', SKU: randomString(10), created: randomDate() , retailPrice: getRandomInt(500,1000), salePrice: getRandomInt(500,1000), lowestPrice: getRandomInt(500,1000) ,status: true,}, 21 | { productId: getRandomInt(1,1000), productName: 'Apple iPhone X', SKU: randomString(10), created: randomDate() , retailPrice: getRandomInt(500,1000), salePrice: getRandomInt(500,1000), lowestPrice: getRandomInt(500,1000) ,status: true,}, 22 | { productId: getRandomInt(1,1000), productName: 'Apple iPhone 8', SKU: randomString(10), created: randomDate() , retailPrice: getRandomInt(500,1000), salePrice: getRandomInt(500,1000), lowestPrice: getRandomInt(500,1000) ,status: true,}, 23 | { productId: getRandomInt(1,1000), productName: 'Apple iPhone 7', SKU: randomString(10), created: randomDate() , retailPrice: getRandomInt(500,1000), salePrice: getRandomInt(500,1000), lowestPrice: getRandomInt(500,1000) ,status: true,}, 24 | { productId: getRandomInt(1,1000), productName: 'Apple iPhone 6', SKU: randomString(10), created: randomDate() , retailPrice: getRandomInt(500,1000), salePrice: getRandomInt(500,1000), lowestPrice: getRandomInt(500,1000) ,status: true,}, 25 | { productId: getRandomInt(1,1000), productName: 'Apple iPhone 5', SKU: randomString(10), created: randomDate() , retailPrice: getRandomInt(500,1000), salePrice: getRandomInt(500,1000), lowestPrice: getRandomInt(500,1000) ,status: true,}, 26 | { productId: getRandomInt(1,1000), productName: 'Apple iPhone 4', SKU: randomString(10), created: randomDate() , retailPrice: getRandomInt(500,1000), salePrice: getRandomInt(500,1000), lowestPrice: getRandomInt(500,1000) ,status: true,}, 27 | { productId: getRandomInt(1,1000), productName: 'Apple iPhone 3', SKU: randomString(10), created: randomDate() , retailPrice: getRandomInt(500,1000), salePrice: getRandomInt(500,1000), lowestPrice: getRandomInt(500,1000) ,status: true,}, 28 | { productId: getRandomInt(1,1000), productName: 'Apple iPhone 2', SKU: randomString(10), created: randomDate() , retailPrice: getRandomInt(500,1000), salePrice: getRandomInt(500,1000), lowestPrice: getRandomInt(500,1000) ,status: true,}, 29 | { productId: getRandomInt(1,1000), productName: 'Apple iPhone 1', SKU: randomString(10), created: randomDate() , retailPrice: getRandomInt(500,1000), salePrice: getRandomInt(500,1000), lowestPrice: getRandomInt(500,1000) ,status: true,}, 30 | ]; 31 | 32 | 33 | //create a function to generate random string of length n 34 | function randomString(n:number){ 35 | const randomChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; 36 | let result = ''; 37 | for (let i = 0; i < n; i++ ) { 38 | result += randomChars.charAt(Math.floor(Math.random() * randomChars.length)); 39 | } 40 | return result; 41 | } 42 | 43 | //create a function to generate random number of length n 44 | function getRandomInt(min:number, max:number) : number{ 45 | min = Math.ceil(min); 46 | max = Math.floor(max); 47 | return Math.floor(Math.random() * (max - min + 1)) + min; 48 | } 49 | 50 | //create a function to generate random date 51 | function randomDate(){ 52 | let date = Math.floor(Math.random() * (31 - 1 + 1)) + 1; 53 | let month = Math.floor(Math.random() * (12 - 1 + 1)) + 1; 54 | let year = Math.floor(Math.random() * (2022 - 2018 + 1)) + 2018; 55 | return date + '/' + month + '/' + year; 56 | } 57 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/LeetCode.Solutions/5f7ee73b8cc1953f3b8d1b84369143531e4d11aa/Problem_03._CRUD_with_products/src/assets/.gitkeep -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/plugins/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/LeetCode.Solutions/5f7ee73b8cc1953f3b8d1b84369143531e4d11aa/Problem_03._CRUD_with_products/src/favicon.ico -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CemexHRM 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** 22 | * IE11 requires the following for NgClass support on SVG elements 23 | */ 24 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 25 | 26 | /** 27 | * Web Animations `@angular/platform-browser/animations` 28 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 29 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 30 | */ 31 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 32 | 33 | /** 34 | * By default, zone.js will patch all possible macroTask and DomEvents 35 | * user can disable parts of macroTask/DomEvents patch by setting following flags 36 | * because those flags need to be set before `zone.js` being loaded, and webpack 37 | * will put import in the top of bundle, so user need to create a separate file 38 | * in this directory (for example: zone-flags.ts), and put the following flags 39 | * into that file, and then add the following code before importing zone.js. 40 | * import './zone-flags'; 41 | * 42 | * The flags allowed in zone-flags.ts are listed here. 43 | * 44 | * The following flags will work for all browsers. 45 | * 46 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 47 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 48 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 49 | * 50 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 51 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 52 | * 53 | * (window as any).__Zone_enable_cross_context_check = true; 54 | * 55 | */ 56 | 57 | /*************************************************************************************************** 58 | * Zone JS is required by default for Angular itself. 59 | */ 60 | import 'zone.js'; // Included with Angular CLI. 61 | 62 | 63 | /*************************************************************************************************** 64 | * APPLICATION IMPORTS 65 | */ 66 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/styles.scss: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | 3 | html, body { height: 100%; } 4 | body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; } 5 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: { 11 | context(path: string, deep?: boolean, filter?: RegExp): { 12 | keys(): string[]; 13 | (id: string): T; 14 | }; 15 | }; 16 | 17 | // First, initialize the Angular testing environment. 18 | getTestBed().initTestEnvironment( 19 | BrowserDynamicTestingModule, 20 | platformBrowserDynamicTesting() 21 | ); 22 | // Then we find all the tests. 23 | const context = require.context('./', true, /\.spec\.ts$/); 24 | // And load the modules. 25 | context.keys().map(context); 26 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/app", 6 | "types": [] 7 | }, 8 | "files": [ 9 | "src/main.ts", 10 | "src/polyfills.ts" 11 | ], 12 | "include": [ 13 | "src/**/*.d.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/tsconfig.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "compileOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": "./", 6 | "outDir": "./dist/out-tsc", 7 | "forceConsistentCasingInFileNames": true, 8 | "strict": true, 9 | "noImplicitReturns": true, 10 | "noFallthroughCasesInSwitch": true, 11 | "sourceMap": true, 12 | "declaration": false, 13 | "downlevelIteration": true, 14 | "experimentalDecorators": true, 15 | "moduleResolution": "node", 16 | "importHelpers": true, 17 | "target": "es2017", 18 | "module": "es2020", 19 | "lib": [ 20 | "es2018", 21 | "dom" 22 | ] 23 | }, 24 | "angularCompilerOptions": { 25 | "enableI18nLegacyMessageIdFormat": false, 26 | "strictInjectionParameters": true, 27 | "strictInputAccessModifiers": true, 28 | "strictTemplates": true 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Problem_03._CRUD_with_products/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/spec", 6 | "types": [ 7 | "jasmine" 8 | ] 9 | }, 10 | "files": [ 11 | "src/test.ts", 12 | "src/polyfills.ts" 13 | ], 14 | "include": [ 15 | "src/**/*.spec.ts", 16 | "src/**/*.d.ts" 17 | ] 18 | } 19 | --------------------------------------------------------------------------------