zahra_amiri 5 years ago
parent
commit
f9c6242bd7
100 changed files with 1274 additions and 3938 deletions
  1. 3 16
      .angular-cli.json
  2. 1 1
      .gitignore
  3. 1 2
      README.md
  4. 0 0
      git
  5. BIN
      node_modules.zip
  6. 103 708
      package-lock.json
  7. 10 34
      package.json
  8. 1 1
      src/app/app.component.html
  9. 58 83
      src/app/app.component.ts
  10. 26 73
      src/app/app.module.ts
  11. 6 7
      src/app/app.routing.ts
  12. 0 56
      src/app/auth/auth.module.ts
  13. 0 39
      src/app/auth/auth.routing.ts
  14. 0 9
      src/app/auth/error/error.component.html
  15. 0 15
      src/app/auth/error/error.component.ts
  16. 0 25
      src/app/auth/lockscreen/lockscreen.component.html
  17. 0 24
      src/app/auth/lockscreen/lockscreen.component.ts
  18. 0 59
      src/app/classes/apps.service.ts
  19. 0 242
      src/app/classes/auth.service.ts
  20. 1 7
      src/app/classes/base_components/dialog/dialog.component.ts
  21. 1 5
      src/app/classes/base_components/dialog/dialog.ts
  22. 45 45
      src/app/classes/base_components/list/list.component.ts
  23. 0 50
      src/app/classes/center.service.ts
  24. 0 21
      src/app/classes/doc.service.ts
  25. 14 0
      src/app/classes/guards/auth.guard.ts
  26. 17 0
      src/app/classes/guards/guest.guard.ts
  27. 230 0
      src/app/classes/jalali/jalali-moment-dateAdapter.ts
  28. 13 0
      src/app/classes/jalali/jalali-moment-formats.ts
  29. 0 112
      src/app/classes/message.service.ts
  30. 0 72
      src/app/classes/messaging.service.ts
  31. 0 15
      src/app/classes/product-pivots.ts
  32. 11 27
      src/app/classes/resorcess/permissions.service.ts
  33. 1 1
      src/app/classes/resorcess/roles.service.ts
  34. 14 0
      src/app/classes/resorcess/users.service.ts
  35. 197 0
      src/app/classes/servicess/auth.service.ts
  36. 7 4
      src/app/classes/servicess/global.service.ts
  37. 5 24
      src/app/classes/utils.ts
  38. 61 0
      src/app/components/auth/auth.module.ts
  39. 29 0
      src/app/components/auth/auth.routing.ts
  40. 0 38
      src/app/components/auth/forgot/forgot.component.html
  41. 0 46
      src/app/components/auth/forgot/forgot.component.ts
  42. 0 33
      src/app/components/auth/newpassword/new-password.component.html
  43. 0 0
      src/app/components/auth/newpassword/new-password.component.scss
  44. 0 54
      src/app/components/auth/newpassword/new-password.component.ts
  45. 0 0
      src/app/components/auth/not-found/not-found.component.html
  46. 0 0
      src/app/components/auth/not-found/not-found.component.scss
  47. 0 0
      src/app/components/auth/not-found/not-found.component.ts
  48. 13 11
      src/app/components/auth/passwordSignin/passwordSignin.component.html
  49. 0 0
      src/app/components/auth/passwordSignin/passwordSignin.component.scss
  50. 63 0
      src/app/components/auth/passwordSignin/passwordSignin.component.ts
  51. 0 12
      src/app/components/auth/selected/selected.component.html
  52. 0 0
      src/app/components/auth/selected/selected.component.scss
  53. 0 53
      src/app/components/auth/selected/selected.component.ts
  54. 0 0
      src/app/components/auth/signin/signin.component.scss
  55. 0 74
      src/app/components/auth/signin/signin.component.ts
  56. 64 0
      src/app/components/auth/smstokenSignin/smstokenSignin.component.html
  57. 0 0
      src/app/components/auth/smstokenSignin/smstokenSignin.component.scss
  58. 97 0
      src/app/components/auth/smstokenSignin/smstokenSignin.component.ts
  59. 0 43
      src/app/components/auth/submit/submit.component.html
  60. 0 0
      src/app/components/auth/submit/submit.component.scss
  61. 0 86
      src/app/components/auth/submit/submit.component.ts
  62. 0 58
      src/app/components/basic/basic.module.ts
  63. 0 19
      src/app/components/basic/basic.routing.ts
  64. 0 26
      src/app/components/basic/products/edit-product/edit-product.component.html
  65. 0 0
      src/app/components/basic/products/edit-product/edit-product.component.scss
  66. 0 67
      src/app/components/basic/products/edit-product/edit-product.component.ts
  67. 0 78
      src/app/components/basic/products/products.component.html
  68. 0 0
      src/app/components/basic/products/products.component.scss
  69. 0 54
      src/app/components/basic/products/products.component.ts
  70. 0 35
      src/app/components/basic/products/products.service.ts
  71. 0 43
      src/app/components/basic/services/edit-services/edit-services.component.html
  72. 0 0
      src/app/components/basic/services/edit-services/edit-services.component.scss
  73. 0 78
      src/app/components/basic/services/edit-services/edit-services.component.ts
  74. 0 86
      src/app/components/basic/services/services.component.html
  75. 0 0
      src/app/components/basic/services/services.component.scss
  76. 0 127
      src/app/components/basic/services/services.component.ts
  77. 0 103
      src/app/components/basic/services/services.service.ts
  78. 0 18
      src/app/components/basic/types/edit-types/edit-types.component.html
  79. 0 0
      src/app/components/basic/types/edit-types/edit-types.component.scss
  80. 0 66
      src/app/components/basic/types/edit-types/edit-types.component.ts
  81. 0 69
      src/app/components/basic/types/types.component.html
  82. 0 0
      src/app/components/basic/types/types.component.scss
  83. 0 44
      src/app/components/basic/types/types.component.ts
  84. 0 25
      src/app/components/basic/types/types.service.ts
  85. 3 3
      src/app/components/user/permissions/edit-permissions/edit-permissions.component.ts
  86. 1 2
      src/app/components/user/permissions/permissions.component.html
  87. 7 7
      src/app/components/user/permissions/permissions.component.ts
  88. 7 7
      src/app/components/user/roles/edit-roles/edit-roles.component.html
  89. 4 4
      src/app/components/user/roles/edit-roles/edit-roles.component.ts
  90. 8 9
      src/app/components/user/roles/roles.component.ts
  91. 42 10
      src/app/components/user/user.module.ts
  92. 29 13
      src/app/components/user/user.routing.ts
  93. 0 59
      src/app/components/user/users/edit-users/edit-users.component.html
  94. 21 48
      src/app/components/user/users/edit-users/edit-users.component.ts
  95. 17 33
      src/app/components/user/users/users.component.html
  96. 16 38
      src/app/components/user/users/users.component.ts
  97. 0 432
      src/app/components/user/users/users.service.ts
  98. 12 7
      src/app/core/admin-layout/admin-layout.component.html
  99. 12 16
      src/app/core/admin-layout/admin-layout.component.ts
  100. 3 27
      src/app/core/header/header.component.html

+ 3 - 16
.angular-cli.json

@@ -9,10 +9,7 @@
       "outDir": "dist",
       "outDir": "dist",
       "assets": [
       "assets": [
         "assets",
         "assets",
-        "favicon.ico",
-        "firebase-messaging-sw.js",
-        "./index.js",
-        "manifest.json"
+        "favicon.ico"
       ],
       ],
       "index": "index.html",
       "index": "index.html",
       "main": "main.ts",
       "main": "main.ts",
@@ -22,25 +19,15 @@
       "testTsconfig": "tsconfig.spec.json",
       "testTsconfig": "tsconfig.spec.json",
       "prefix": "app",
       "prefix": "app",
       "styles": [
       "styles": [
-        "../node_modules/quill/dist/quill.snow.css",
-        "../node_modules/quill/dist/quill.bubble.css",
-        "../node_modules/dragula/dist/dragula.css",
-        "../node_modules/leaflet/dist/leaflet.css",
-        "../node_modules/angular-calendar/scss/angular-calendar.scss",
         "../node_modules/@swimlane/ngx-datatable/release/index.css",
         "../node_modules/@swimlane/ngx-datatable/release/index.css",
         "../node_modules/@swimlane/ngx-datatable/release/themes/material.css",
         "../node_modules/@swimlane/ngx-datatable/release/themes/material.css",
         "assets/fonts/pe/css/pe-icon-set-weather.css",
         "assets/fonts/pe/css/pe-icon-set-weather.css",
         "assets/fonts/data-table/icons.css",
         "assets/fonts/data-table/icons.css",
         "assets/styles/app.scss",
         "assets/styles/app.scss",
-        "../node_modules/datatables.net-dt/css/jquery.dataTables.css",
-        "../node_modules/angular5-toaster/dist/toaster.css"
+        "../node_modules/ngx-lightbox/lightbox.css"
       ],
       ],
       "scripts": [
       "scripts": [
-        "../node_modules/hammerjs/hammer.min.js",
-        "../node_modules/chart.js/dist/Chart.bundle.min.js",
-        "../node_modules/jquery/dist/jquery.js",
-        "../node_modules/datatables.net/js/jquery.dataTables.js"
-
+        "../node_modules/hammerjs/hammer.min.js"
       ],
       ],
       "environmentSource": "environments/environment.ts",
       "environmentSource": "environments/environment.ts",
       "environments": {
       "environments": {

+ 1 - 1
.gitignore

@@ -1,7 +1,7 @@
 # See http://help.github.com/ignore-files/ for more about ignoring files.
 # See http://help.github.com/ignore-files/ for more about ignoring files.
 
 
 # compiled output
 # compiled output
-/dist
+/dist/*
 /tmp
 /tmp
 
 
 # dependencies
 # dependencies

+ 1 - 2
README.md

@@ -1,2 +1 @@
-# common_Prj
-
+document zahra 

+ 0 - 0
src/app/auth/error/error.component.scss → git


BIN
node_modules.zip


File diff suppressed because it is too large
+ 103 - 708
package-lock.json


+ 10 - 34
package.json

@@ -18,7 +18,6 @@
     "@angular/common": "5.2.9",
     "@angular/common": "5.2.9",
     "@angular/compiler": "5.2.9",
     "@angular/compiler": "5.2.9",
     "@angular/core": "5.2.9",
     "@angular/core": "5.2.9",
-    "@angular/fire": "5.0.2",
     "@angular/flex-layout": "5.0.0-beta.13",
     "@angular/flex-layout": "5.0.0-beta.13",
     "@angular/forms": "5.2.9",
     "@angular/forms": "5.2.9",
     "@angular/http": "5.2.9",
     "@angular/http": "5.2.9",
@@ -26,64 +25,40 @@
     "@angular/platform-browser": "5.2.9",
     "@angular/platform-browser": "5.2.9",
     "@angular/platform-browser-dynamic": "5.2.9",
     "@angular/platform-browser-dynamic": "5.2.9",
     "@angular/router": "5.2.9",
     "@angular/router": "5.2.9",
-    "@asymmetrik/ngx-leaflet": "3.0.2",
-    "@ngx-loading-bar/http": "^2.0.0",
-    "@ngx-loading-bar/router": "1.3.1",
     "@ngx-progressbar/core": "^5.0.0-rc.0",
     "@ngx-progressbar/core": "^5.0.0-rc.0",
-    "@ngx-translate/core": "9.1.1",
-    "@ngx-translate/http-loader": "2.0.1",
-    "@retailify/ngx-mat-numberpicker": "^1.0.1",
     "@swimlane/ngx-datatable": "^11.3.2",
     "@swimlane/ngx-datatable": "^11.3.2",
-    "@types/googlemaps": "^3.30.10",
-    "angular-calendar": "0.23.7",
-    "angular-datatables": "^5.0.0",
-    "angular-file-saver": "^1.1.3",
-    "angular-tree-component": "7.0.1",
     "angular5-toaster": "^1.0.2",
     "angular5-toaster": "^1.0.2",
-    "chart.js": "2.7.2",
     "core-js": "2.5.3",
     "core-js": "2.5.3",
-    "d3": "4.13.0",
-    "datatables.net": "^1.10.16",
-    "datatables.net-dt": "^1.10.16",
-    "dragula": "3.7.2",
-    "firebase": "5.0.3",
     "hammerjs": "2.0.8",
     "hammerjs": "2.0.8",
     "intl": "1.2.5",
     "intl": "1.2.5",
-    "is-path-in-cwd": "^2.0.0",
+    "jalaali-js": "^1.1.0",
     "jalali-moment": "^3.3.1",
     "jalali-moment": "^3.3.1",
-    "jquery": "^3.3.1",
-    "leaflet": "1.3.1",
-    "mdi": "^2.2.43",
+    "material-design-icons-iconfont": "^5.0.1",
     "moment": "2.21.0",
     "moment": "2.21.0",
     "moment-jalaali": "^0.8.3",
     "moment-jalaali": "^0.8.3",
-    "ng2-charts": "1.6.0",
-    "ng2-dragula": "1.5.0",
     "ng2-file-upload": "^1.3.0",
     "ng2-file-upload": "^1.3.0",
-    "ng2-pdf-viewer": "^5.2.3",
-    "ng2-validation": "4.2.0",
     "ngx-cookie-service": "^1.0.10",
     "ngx-cookie-service": "^1.0.10",
     "ngx-jsonapi": "^1.0.0-rc.12",
     "ngx-jsonapi": "^1.0.0-rc.12",
+    "ngx-lightbox": "^2.0.0",
     "ngx-loading": "^1.0.14",
     "ngx-loading": "^1.0.14",
     "ngx-loading-bar": "0.0.9",
     "ngx-loading-bar": "0.0.9",
     "ngx-perfect-scrollbar": "5.3.5",
     "ngx-perfect-scrollbar": "5.3.5",
     "ngx-progressbar": "^2.1.1",
     "ngx-progressbar": "^2.1.1",
-    "ngx-quill": "2.2.0",
-    "ngx-spinner": "^2.0.1",
     "node-sass": "^4.12.0",
     "node-sass": "^4.12.0",
-    "rxjs": "5.5.7",
+    "pusher-js": "^4.4.0",
+    "rxjs": "6.0.0",
+    "rxjs-compat": "6.0.0",
+    "sass": "^1.22.7",
     "screenfull": "3.3.2",
     "screenfull": "3.3.2",
-    "xlsx": "^0.14.1",
     "zone.js": "0.8.20"
     "zone.js": "0.8.20"
   },
   },
   "devDependencies": {
   "devDependencies": {
     "@angular/cli": "1.7.3",
     "@angular/cli": "1.7.3",
     "@angular/compiler-cli": "5.2.9",
     "@angular/compiler-cli": "5.2.9",
     "@angular/language-service": "5.2.9",
     "@angular/language-service": "5.2.9",
-    "@types/datatables.net": "^1.10.9",
     "@types/jasmine": "~2.8.3",
     "@types/jasmine": "~2.8.3",
     "@types/jasminewd2": "~2.0.2",
     "@types/jasminewd2": "~2.0.2",
-    "@types/jquery": "^3.3.1",
-    "@types/node": "^6.0.118",
+    "@types/node": "6.0.118",
     "codelyzer": "^4.0.1",
     "codelyzer": "^4.0.1",
     "jasmine-core": "~2.8.0",
     "jasmine-core": "~2.8.0",
     "jasmine-spec-reporter": "~4.2.1",
     "jasmine-spec-reporter": "~4.2.1",
@@ -96,6 +71,7 @@
     "protractor": "~5.1.2",
     "protractor": "~5.1.2",
     "ts-node": "~4.1.0",
     "ts-node": "~4.1.0",
     "tslint": "~5.9.1",
     "tslint": "~5.9.1",
-    "typescript": "~2.5.3"
+    "typescript": "~2.5.3",
+    "webpack-bundle-analyzer": "^3.3.2"
   }
   }
 }
 }

+ 1 - 1
src/app/app.component.html

@@ -1,4 +1,4 @@
 <!--for test toaster-->
 <!--for test toaster-->
 <router-outlet></router-outlet>
 <router-outlet></router-outlet>
 <!--<button (click)="prop()">TEST</button>-->
 <!--<button (click)="prop()">TEST</button>-->
-<toaster-container [toasterconfig]="toasterconfig"></toaster-container>
+

+ 58 - 83
src/app/app.component.ts

@@ -1,95 +1,70 @@
-import {Component, OnInit, ViewContainerRef} from '@angular/core';
-import {TranslateService} from '@ngx-translate/core';
-import {AuthService} from './classes/auth.service';
-import {Router} from '@angular/router';
-import {Dialog} from './classes/dialog';
+import {Component, OnInit} from '@angular/core';
+import {AuthService} from './classes/servicess/auth.service';
+import { Router} from '@angular/router';
+import {Dialog} from './classes/base_components/dialog/dialog';
 import {ToasterConfig} from 'angular5-toaster/dist';
 import {ToasterConfig} from 'angular5-toaster/dist';
 import {JsonapiCore} from 'ngx-jsonapi';
 import {JsonapiCore} from 'ngx-jsonapi';
-import {Http} from '@angular/http';
-import {MessagingService} from './classes/messaging.service';
 
 
 
 
 @Component({
 @Component({
-  selector: 'app-root',
-  templateUrl: './app.component.html',
+    selector: 'app-root',
+    templateUrl: './app.component.html',
 })
 })
-export class AppComponent implements OnInit {
-  message;
-  toasterconfig: ToasterConfig;
-  test;
+export class AppComponent {
+    message;
+    toasterconfig: ToasterConfig;
+    test;
 
 
-  constructor(translate: TranslateService,
-              private authService: AuthService,
-              private router: Router,
-              private dialog: Dialog,
-              private jsonapiCore: JsonapiCore,
-              private http: Http,
-              private msg: MessagingService,
-  ) {
-    /***
-     * in vase gereftan data az background notification firebase hast
-     */
-    navigator.serviceWorker.addEventListener('message', function (event) {
-      if (event.data.from) {
-// todo type of messages
-        // if (event.data.data.request)
-        //     listRequest.updateRequests();
-      }
-    });
-    this.toasterconfig = new ToasterConfig({
-      limit: 5,
-      showCloseButton: false,
-      timeout: 5000
-    });
-    translate.addLangs(['en', 'fr']);
-    translate.setDefaultLang('en');
-    const browserLang: string = translate.getBrowserLang();
-    translate.use(browserLang.match(/en|fr/) ? browserLang : 'en');
-    jsonapiCore.loadingsStart = (): void => {
-      // this.loading = 'LOADING...';
-    };
-    jsonapiCore.loadingsDone = (): void => {
-      // this.loading = '';
-      jsonapiCore.loadingsOffline = (error): void => {
-        dialog.openForAlert('دسترسی به سرور را کنترل نمایید');
-      };
-      // this.loading = 'No connection!!!';
-    };
-    jsonapiCore.loadingsError = (errors): void => {
-      // this.loading = 'No connection 2!!!';
-      if (errors['errors'][0]['status'] === '401') {
+    constructor(
+        private authService: AuthService,
+        private router: Router,
+        private dialog: Dialog,
+        private jsonapiCore: JsonapiCore,
+    ) {
 
 
-        this.router.navigateByUrl('/auth/signin');
-        this.authService.logout();
-      } else if (errors['errors'][0]['status'] === '403') {
+        /***
+         * in vase gereftan data az background notification firebase hast
+         */
+        this.toasterconfig = new ToasterConfig({
+            limit: 5,
+            showCloseButton: false,
+            timeout: 5000
+        });
+        jsonapiCore.loadingsStart = (): void => {
+            // this.loading = 'LOADING...';
+        };
+        jsonapiCore.loadingsDone = (): void => {
+            // this.loading = '';
+            jsonapiCore.loadingsOffline = (error): void => {
+                dialog.openForAlert('دسترسی به سرور را کنترل نمایید');
+            };
+            // this.loading = 'No connection!!!';
+        };
+        jsonapiCore.loadingsError = (errors): void => {
+            // this.loading = 'No connection 2!!!';
+            if (errors['errors'][0]['status'] === '401') {
+                // todo in test shavad
+                // this.router.navigateByUrl('/auth/passwordSignin');
+                // this.authService.logout();
+            } else if (errors['errors'][0]['status'] === '403') {
+                dialog.openForAlert('شما دسترسی ندارید.');
+            } else {
+                dialog.openForAlert('دسترسی به سرور را کنترل نمایید');
+            }
+        };
+    }
 
 
-        dialog.openForAlert('شما دسترسی ندارید.');
-      } else {
-        dialog.openForAlert('دسترسی به سرور را کنترل نمایید');
-      }
-    };
-    this.msg.getPermission();
-    this.msg.receiveMessage();
-    this.message = this.msg.currentMessage;
-  }
 
 
-  ngOnInit() {
-    this.authService.cloud_token.subscribe(x => {
-      if (this.authService.getNoAuthUrls().indexOf(this.router.url) === -1) {
-        this.authService.init(x)
-          .subscribe(
-            res => {
-              if (!res) {
-                // this.loading = false;
-                // this.router.navigateByUrl('/auth/signin');
-                this.authService.logout();
-              }
-            },
-            error => {
-              this.authService.logout();
-            });
-      }
-    });
-  }
+
+    // prop() {
+    //   let toast: Toast = {
+    //     requestType: 'info',
+    //     title: 'salam',
+    //     body: ToasterButtonComponent,
+    //     bodyOutputType: BodyOutputType.Component,
+    //
+    //   };
+    //   this.toastService.pop(toast);
+    // }
 }
 }
 
 

+ 26 - 73
src/app/app.module.ts

@@ -1,21 +1,21 @@
 import {BrowserModule, DomSanitizer} from '@angular/platform-browser';
 import {BrowserModule, DomSanitizer} from '@angular/platform-browser';
 import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
 import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
 import {RouterModule} from '@angular/router';
 import {RouterModule} from '@angular/router';
-import {NgModule, ViewContainerRef} from '@angular/core';
+import {NgModule} from '@angular/core';
 import {FormsModule} from '@angular/forms';
 import {FormsModule} from '@angular/forms';
-import {HttpClientModule, HttpClient} from '@angular/common/http';
+import {HttpClientModule} from '@angular/common/http';
 import {HttpModule} from '@angular/http';
 import {HttpModule} from '@angular/http';
 import {CookieService} from 'ngx-cookie-service';
 import {CookieService} from 'ngx-cookie-service';
 import {NgxJsonapiModule} from 'ngx-jsonapi';
 import {NgxJsonapiModule} from 'ngx-jsonapi';
 import {
 import {
+  DateAdapter,
+  MAT_DATE_FORMATS, MAT_DATE_LOCALE,
   MatAutocompleteModule, MatDatepickerModule,
   MatAutocompleteModule, MatDatepickerModule,
   MatDialogModule,
   MatDialogModule,
   MatIconRegistry,
   MatIconRegistry,
   MatInputModule, MatNativeDateModule
   MatInputModule, MatNativeDateModule
 } from '@angular/material';
 } from '@angular/material';
 import {ReactiveFormsModule} from '@angular/forms';
 import {ReactiveFormsModule} from '@angular/forms';
-import {TranslateModule, TranslateLoader} from '@ngx-translate/core';
-import {TranslateHttpLoader} from '@ngx-translate/http-loader';
 import {PerfectScrollbarModule} from 'ngx-perfect-scrollbar';
 import {PerfectScrollbarModule} from 'ngx-perfect-scrollbar';
 import {PERFECT_SCROLLBAR_CONFIG} from 'ngx-perfect-scrollbar';
 import {PERFECT_SCROLLBAR_CONFIG} from 'ngx-perfect-scrollbar';
 import {PerfectScrollbarConfigInterface} from 'ngx-perfect-scrollbar';
 import {PerfectScrollbarConfigInterface} from 'ngx-perfect-scrollbar';
@@ -51,47 +51,33 @@ import {
 } from './core';
 } from './core';
 import {AppRoutes} from './app.routing';
 import {AppRoutes} from './app.routing';
 import {AppComponent} from './app.component';
 import {AppComponent} from './app.component';
-import {AuthService} from './classes/auth.service';
+import {AuthService} from './classes/servicess/auth.service';
+import {AuthGuard} from './classes/guards/auth.guard';
 import {ListComponent} from './classes/base_components/list/list.component';
 import {ListComponent} from './classes/base_components/list/list.component';
 import {DialogComponent} from './classes/base_components/dialog/dialog.component' ;
 import {DialogComponent} from './classes/base_components/dialog/dialog.component' ;
-import {Dialog} from './classes/dialog';
-import {NgxSpinnerService} from 'ngx-spinner';
+import {Dialog} from './classes/base_components/dialog/dialog';
 import {LoadingModule} from 'ngx-loading';
 import {LoadingModule} from 'ngx-loading';
+import {GuestGuard} from './classes/guards/guest.guard';
 import {EditUsersComponent} from './components/user/users/edit-users/edit-users.component';
 import {EditUsersComponent} from './components/user/users/edit-users/edit-users.component';
-import {UsersService} from './components/user/users/users.service';
-import {RolesService} from './components/user/roles/roles.service';
+import {UsersService} from './classes/resorcess/users.service';
+import {RolesService} from './classes/resorcess/roles.service';
 import {EditRolesComponent} from './components/user/roles/edit-roles/edit-roles.component';
 import {EditRolesComponent} from './components/user/roles/edit-roles/edit-roles.component';
 import {EditComponent} from './classes/base_components/edit/edit.component';
 import {EditComponent} from './classes/base_components/edit/edit.component';
-import {PermissionGroupsService, PermissionsService} from './components/user/permissions/permissions.service';
-import {ServicesService} from './components/basic/services/services.service';
-import {ProductsService} from './components/basic/products/products.service';
-import {TypesService} from './components/basic/types/types.service';
-import {EditProductComponent} from './components/basic/products/edit-product/edit-product.component';
-import {EditServicesComponent} from './components/basic/services/edit-services/edit-services.component';
-import {EditTypesComponent} from './components/basic/types/edit-types/edit-types.component';
+import {PermissionGroupsService, PermissionsService} from './classes/resorcess/permissions.service';
 import {EditPermissionsComponent} from './components/user/permissions/edit-permissions/edit-permissions.component';
 import {EditPermissionsComponent} from './components/user/permissions/edit-permissions/edit-permissions.component';
-import {AgmCoreModule} from '@agm/core';
-import {DocService} from './classes/doc.service';
 import {MatRadioModule} from '@angular/material/radio';
 import {MatRadioModule} from '@angular/material/radio';
 import {MatChipsModule} from '@angular/material/chips';
 import {MatChipsModule} from '@angular/material/chips';
 import {NgxDatatableModule} from '@swimlane/ngx-datatable';
 import {NgxDatatableModule} from '@swimlane/ngx-datatable';
-import {GlobalService} from './classes/global.service';
+
+
+import {GlobalService} from './classes/servicess/global.service';
 import {environment} from '../environments/environment';
 import {environment} from '../environments/environment';
-import {SelectedComponent} from './components/auth/selected/selected.component';
 import {MatTooltipModule} from '@angular/material/tooltip';
 import {MatTooltipModule} from '@angular/material/tooltip';
-import {ToasterModule, ToasterService} from 'angular5-toaster/dist';
-import {AngularFireModule} from '@angular/fire';
-import {AngularFireDatabaseModule} from '@angular/fire/database';
-import {AngularFireAuthModule} from '@angular/fire/auth';
-import {NumberPickerModule} from '@retailify/ngx-mat-numberpicker';
-import {MessageService} from './classes/message.service';
-import {CentersService} from './classes/center.service';
-import {AppsService} from './classes/apps.service';
-import {MessagingService} from './classes/messaging.service';
+import {JalaliMomentDateAdapter} from './classes/jalali/jalali-moment-dateAdapter';
+import {JALALI_MOMENT_FORMATS} from './classes/jalali/jalali-moment-formats';
+import {MatExpansionModule} from '@angular/material/expansion';
+import {LightboxModule} from 'ngx-lightbox';
 
 
-export function createTranslateLoader(http: HttpClient) {
-  return new TranslateHttpLoader(http, './assets/i18n/', '.json');
-}
 
 
 const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = {
 const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = {
   suppressScrollX: true,
   suppressScrollX: true,
@@ -102,11 +88,7 @@ const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = {
 
 
 @NgModule({
 @NgModule({
   declarations: [
   declarations: [
-    SelectedComponent,
     EditPermissionsComponent,
     EditPermissionsComponent,
-    EditTypesComponent,
-    EditServicesComponent,
-    EditProductComponent,
     EditComponent,
     EditComponent,
     EditRolesComponent,
     EditRolesComponent,
     EditUsersComponent,
     EditUsersComponent,
@@ -125,22 +107,12 @@ const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = {
     DialogComponent,
     DialogComponent,
   ],
   ],
   imports: [
   imports: [
+    LightboxModule,
+    MatExpansionModule,
     MatGridListModule,
     MatGridListModule,
-    NumberPickerModule,
     MatNativeDateModule,
     MatNativeDateModule,
     MatDatepickerModule,
     MatDatepickerModule,
     BrowserAnimationsModule,
     BrowserAnimationsModule,
-    ToasterModule,
-    AngularFireModule.initializeApp({
-      apiKey: 'AIzaSyCzrKn-mozOkz3Eh1dm9K1iZbO2A8RxWLU',
-      authDomain: 'hpennurse.firebaseapp.com',
-      databaseURL: 'https://hpennurse.firebaseio.com',
-      projectId: 'hpennurse',
-      storageBucket: 'hpennurse.appspot.com',
-      messagingSenderId: '628214501041'
-    }),
-    AngularFireDatabaseModule,
-    AngularFireAuthModule,
     LoadingModule.forRoot({
     LoadingModule.forRoot({
       backdropBackgroundColour: 'rgba(0,0,0,0.1)',
       backdropBackgroundColour: 'rgba(0,0,0,0.1)',
       backdropBorderRadius: '4px',
       backdropBorderRadius: '4px',
@@ -152,7 +124,6 @@ const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = {
     MatAutocompleteModule,
     MatAutocompleteModule,
     MatChipsModule,
     MatChipsModule,
     MatRadioModule,
     MatRadioModule,
-    AgmCoreModule.forRoot({apiKey: 'AIzaSyDwvNEVZT6CNth_aJEM0uhTf8ksbDjNQIw'}),
     LoadingModule,
     LoadingModule,
     ReactiveFormsModule,
     ReactiveFormsModule,
     MatInputModule,
     MatInputModule,
@@ -162,16 +133,9 @@ const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = {
       url: environment.app_url,
       url: environment.app_url,
     }),
     }),
     BrowserModule,
     BrowserModule,
-    RouterModule.forRoot(AppRoutes),
+    RouterModule.forRoot(AppRoutes, {useHash: true}),
     FormsModule,
     FormsModule,
     HttpClientModule,
     HttpClientModule,
-    TranslateModule.forRoot({
-      loader: {
-        provide: TranslateLoader,
-        useFactory: (createTranslateLoader),
-        deps: [HttpClient]
-      }
-    }),
     MatSidenavModule,
     MatSidenavModule,
     MatCardModule,
     MatCardModule,
     MatMenuModule,
     MatMenuModule,
@@ -190,46 +154,35 @@ const DEFAULT_PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = {
     MatTooltipModule,
     MatTooltipModule,
   ],
   ],
   providers: [
   providers: [
-    MessagingService,
-    AppsService,
-    CentersService,
-    MessageService,
-    ToasterService,
-    DocService,
     GlobalService,
     GlobalService,
+    AuthService,
     UsersService,
     UsersService,
     CookieService,
     CookieService,
-    AuthService,
-    NgxSpinnerService,
+    AuthGuard,
+    GuestGuard,
     Dialog,
     Dialog,
     RolesService,
     RolesService,
     PermissionsService,
     PermissionsService,
     PermissionGroupsService,
     PermissionGroupsService,
-    TypesService,
-    ProductsService,
-    ServicesService,
     {
     {
       provide: PERFECT_SCROLLBAR_CONFIG,
       provide: PERFECT_SCROLLBAR_CONFIG,
       useValue: DEFAULT_PERFECT_SCROLLBAR_CONFIG,
       useValue: DEFAULT_PERFECT_SCROLLBAR_CONFIG,
 
 
     },
     },
+    {provide: DateAdapter, useClass: JalaliMomentDateAdapter, deps: [MAT_DATE_LOCALE]},
+    {provide: MAT_DATE_FORMATS, useValue: JALALI_MOMENT_FORMATS}
   ],
   ],
 
 
   bootstrap: [AppComponent],
   bootstrap: [AppComponent],
   entryComponents: [
   entryComponents: [
-    SelectedComponent,
     EditPermissionsComponent,
     EditPermissionsComponent,
-    EditTypesComponent,
-    EditServicesComponent,
     DialogComponent,
     DialogComponent,
     EditComponent,
     EditComponent,
     EditUsersComponent,
     EditUsersComponent,
     EditRolesComponent,
     EditRolesComponent,
-    EditProductComponent,
   ]
   ]
 })
 })
 export class AppModule {
 export class AppModule {
-  url;
 
 
   constructor(matIconRegistry: MatIconRegistry, domSanitizer: DomSanitizer, private global: GlobalService) {
   constructor(matIconRegistry: MatIconRegistry, domSanitizer: DomSanitizer, private global: GlobalService) {
     matIconRegistry.addSvgIconSet(domSanitizer.bypassSecurityTrustResourceUrl('./assets/mdi.svg'));
     matIconRegistry.addSvgIconSet(domSanitizer.bypassSecurityTrustResourceUrl('./assets/mdi.svg'));

+ 6 - 7
src/app/app.routing.ts

@@ -1,25 +1,24 @@
 import {Routes} from '@angular/router';
 import {Routes} from '@angular/router';
 import {AuthLayoutComponent} from './core';
 import {AuthLayoutComponent} from './core';
 import {AdminLayoutComponent} from './core/admin-layout/admin-layout.component';
 import {AdminLayoutComponent} from './core/admin-layout/admin-layout.component';
+import {AuthGuard} from './classes/guards/auth.guard';
 
 
 export const AppRoutes: Routes = [{
 export const AppRoutes: Routes = [{
   path: '',
   path: '',
+  canActivate: [AuthGuard],
   component: AdminLayoutComponent,
   component: AdminLayoutComponent,
   children: [{
   children: [{
-    path: '',
+    canActivate: [AuthGuard],
+    path: 'user',
     loadChildren: './components/user/user.module#UserModule'
     loadChildren: './components/user/user.module#UserModule'
   },
   },
-    {
-      path: '',
-      loadChildren: './components/basic/basic.module#BasicModule'
-    },
-    ]
+  ]
 }, {
 }, {
   path: '',
   path: '',
   component: AuthLayoutComponent,
   component: AuthLayoutComponent,
   children: [{
   children: [{
     path: 'auth',
     path: 'auth',
-    loadChildren: './auth/auth.module#AuthModule'
+    loadChildren: './components/auth/auth.module#AuthModule'
   }]
   }]
 }, {
 }, {
   path: '**',
   path: '**',

+ 0 - 56
src/app/auth/auth.module.ts

@@ -1,56 +0,0 @@
-import {NgModule} from '@angular/core';
-import {RouterModule} from '@angular/router';
-import {CommonModule} from '@angular/common';
-import {MatIconModule, MatCardModule, MatInputModule, MatCheckboxModule, MatButtonModule, MatSelectModule} from '@angular/material';
-import {FormsModule, ReactiveFormsModule} from '@angular/forms';
-import {FlexLayoutModule} from '@angular/flex-layout';
-import {NgxSpinnerModule, NgxSpinnerService} from 'ngx-spinner';
-import {LoadingModule} from 'ngx-loading';
-import {AuthRoutes} from './auth.routing';
-import {NotFoundComponent} from './not-found/not-found.component';
-import {ErrorComponent} from './error/error.component';
-import {ForgotComponent} from '../components/auth/forgot/forgot.component';
-import {LockscreenComponent} from './lockscreen/lockscreen.component';
-import {SigninComponent} from '../components/auth/signin/signin.component';
-import {SubmitComponent} from '../components/auth/submit/submit.component';
-import {NewPasswordComponent} from '../components/auth/newpassword/new-password.component';
-
-
-@NgModule({
-    imports: [
-        LoadingModule.forRoot({
-            backdropBackgroundColour: 'rgba(0,0,0,0.1)',
-            backdropBorderRadius: '4px',
-            primaryColour: '#0000ff',
-            secondaryColour: '#0000ff',
-            tertiaryColour: '#0000ff'
-        }),
-        LoadingModule,
-        MatSelectModule,
-        NgxSpinnerModule,
-        CommonModule,
-        RouterModule.forChild(AuthRoutes),
-        MatIconModule,
-        MatCardModule,
-        MatInputModule,
-        MatCheckboxModule,
-        MatButtonModule,
-        FlexLayoutModule,
-        FormsModule,
-        ReactiveFormsModule,
-    ],
-    declarations: [
-        NotFoundComponent,
-        ErrorComponent,
-        ForgotComponent,
-        LockscreenComponent,
-        SigninComponent,
-        SubmitComponent,
-        NewPasswordComponent,
-    ],
-    providers: [NgxSpinnerService]
-
-})
-
-export class AuthModule {
-}

+ 0 - 39
src/app/auth/auth.routing.ts

@@ -1,39 +0,0 @@
-import {Routes} from '@angular/router';
-import {NotFoundComponent} from './not-found/not-found.component';
-import {ErrorComponent} from './error/error.component';
-import {ForgotComponent} from '../components/auth/forgot/forgot.component';
-import {LockscreenComponent} from './lockscreen/lockscreen.component';
-import {SigninComponent} from '../components/auth/signin/signin.component';
-import {SubmitComponent} from '../components/auth/submit/submit.component';
-import {NewPasswordComponent} from '../components/auth/newpassword/new-password.component';
-
-export const AuthRoutes: Routes = [
-    {
-        path: '',
-        children: [{
-            path: '404',
-            component: NotFoundComponent
-        }, {
-            path: 'error',
-            component: ErrorComponent
-        }, {
-            path: 'forgot',
-            component: ForgotComponent
-        }, {
-            path: 'lockscreen',
-            component: LockscreenComponent
-        }, {
-            path: 'signin',
-            component: SigninComponent,
-        }, {
-            path: 'submit',
-            component: SubmitComponent,
-
-        },
-            {
-                path: 'newpassword',
-                component: NewPasswordComponent,
-            },
-        ]
-    }
-];

+ 0 - 9
src/app/auth/error/error.component.html

@@ -1,9 +0,0 @@
-<div class="session">
-  <div class="session-content text-xs-center">
-    <div>
-      <div class="error-title">500</div>
-      <div class="error-subtitle">We have an internal server error!</div>
-      <p class="mat-text-muted">Sorry, but the page you were trying to view does not exist. <a href="javascript:;">Report this error?</a></p>
-    </div>
-  </div>
-</div>

+ 0 - 15
src/app/auth/error/error.component.ts

@@ -1,15 +0,0 @@
-import { Component, OnInit } from '@angular/core';
-
-@Component({
-  selector: 'app-error',
-  templateUrl: './error.component.html',
-  styleUrls: ['./error.component.scss']
-})
-export class ErrorComponent implements OnInit {
-
-  constructor() { }
-
-  ngOnInit() {
-  }
-
-}

+ 0 - 25
src/app/auth/lockscreen/lockscreen.component.html

@@ -1,25 +0,0 @@
-<div class="session mat-indigo">
-  <div class="session-content">
-    <div class="lockscreen-wrapper text-xs-center">
-      <mat-card>
-        <mat-card-content>
-          <form [formGroup]="form" (ngSubmit)="onSubmit()">
-            <div class="lockscreen-avatar">
-              <img src="assets/images/avatar.jpg" class="radius-round" alt="user" title="user"/>
-            </div>
-            <p class="center-block mt-1">David Miller</p>
-            <div fxLayout="column" fxLayoutAlign="space-around">
-              <div class="pb-1">
-                <mat-form-field style="width: 100%">
-                  <input matInput placeholder="Username" [formControl]="form.controls['uname']">
-                </mat-form-field>
-                <small *ngIf="form.controls['uname'].hasError('required') && form.controls['uname'].touched" class="mat-text-warn">Username is required.</small>
-              </div>
-              <div> <button mat-raised-button color="primary" type="submit" [disabled]="!form.valid">Unlock</button></div>
-            </div>
-          </form>
-        </mat-card-content>
-      </mat-card>   
-    </div>
-  </div>
-</div>

+ 0 - 24
src/app/auth/lockscreen/lockscreen.component.ts

@@ -1,24 +0,0 @@
-import { Component, OnInit } from '@angular/core';
-import { Router } from '@angular/router';
-import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
-
-@Component({
-  selector: 'app-lockscreen',
-  templateUrl: './lockscreen.component.html',
-  styleUrls: ['./lockscreen.component.scss']
-})
-export class LockscreenComponent implements OnInit {
-
-  public form: FormGroup;
-  constructor(private fb: FormBuilder, private router: Router) {}
-  ngOnInit() {
-    this.form = this.fb.group ( {
-      uname: [ null, Validators.compose( [ Validators.required ] ) ]
-    });
-  }
-
-  onSubmit() {
-    this.router.navigate ( ['/user'] );
-  }
-
-}

+ 0 - 59
src/app/classes/apps.service.ts

@@ -1,59 +0,0 @@
-import {Injectable} from '@angular/core';
-import {Resource, Service} from 'ngx-jsonapi';
-
-@Injectable()
-export class AppsService extends Service<App> {
-
-  public resource = App;
-  public type = 'apps';
-}
-
-export class App extends Resource {
-  public attributes: {
-    sdk: string,
-    version: string,
-    package: string,
-    key: string,
-    name: string,
-  };
-
-  get sdk() {
-    return this.attributes.sdk;
-  }
-
-  set sdk(sdk: string) {
-    this.attributes.sdk = sdk;
-  }
-
-  get version() {
-    return this.attributes.version;
-  }
-
-  set version(version: string) {
-    this.attributes.version = version;
-  }
-
-  get package() {
-    return this.attributes.package;
-  }
-
-  set package(p: string) {
-    this.attributes.package = p;
-  }
-
-  get key() {
-    return this.attributes.key;
-  }
-
-  set key(key: string) {
-    this.attributes.key = key;
-  }
-
-  get name() {
-    return this.attributes.key;
-  }
-
-  set name(name: string) {
-    this.attributes.name = name;
-  }
-}

+ 0 - 242
src/app/classes/auth.service.ts

@@ -1,242 +0,0 @@
-import {Injectable} from '@angular/core';
-import {Observable} from 'rxjs/Observable';
-import {Http} from '@angular/http';
-import {BehaviorSubject} from 'rxjs/BehaviorSubject';
-import {Headers} from '@angular/http';
-import {CookieService} from 'ngx-cookie-service';
-import {User, UsersService} from '../components/user/users/users.service';
-import {TypesService} from '../components/basic/types/types.service';
-import {RolesService} from '../components/user/roles/roles.service';
-import {Router} from '@angular/router';
-import {GlobalService} from './global.service';
-import {environment} from '../../environments/environment';
-import {MessageService} from './message.service';
-
-
-@Injectable()
-export class AuthService {
-  auth: AuthService;
-  currentUser: any = new BehaviorSubject(false);
-  cloud_token = new BehaviorSubject('');
-  firebase;
-
-
-  /**
-   * @param {Http} http  baray darkhadt hay http estefade mishe
-   * @param {CookieService} cookieService baray save kardan token
-   */
-  constructor(private http: Http,
-              private cookieService: CookieService,
-              private router: Router,
-              private userService: UsersService,
-              private typeService: TypesService,
-              private roleService: RolesService,
-              private global: GlobalService,
-              private MessageService: MessageService,
-  ) {
-    this.cloud_token.subscribe(x => {
-      if (x) {
-        this.firebase = x;
-      }
-    });
-
-    this.typeService.register();
-    this.roleService.register();
-  }
-
-  /**
-   *
-   * @param username email user hast
-   * @param password
-   * @param type type user hast mesl dr ya parastar
-   * @param cloud_token
-   * @param remember
-   * @returns {Observable<boolean>}
-   */
-
-  login(username, password, type, cloud_token, remember): Observable<boolean> {
-    const headers = new Headers();
-    headers.append('Content-Type', 'application/x-www-form-urlencoded');
-    return this.http.post(environment.app_url + 'login',
-      'username=' + (username) + '&password=' + (password) +
-      '&type=' + (type) + '&cloud_token=' + (cloud_token),
-      {headers: headers})
-      .map(res => res.json())
-      .map(res => {
-        if (res) {
-          this.currentUser.next(this.convertUserFromText(res['user']));
-          this.global.tokenLogin = res['token'];
-          this.setLoginParams(res, remember, true);
-        }
-        return this.isLoggedIn();
-      });
-  }
-
-  getUser(): User {
-    const user = localStorage.getItem('user');
-    if (user) {
-      const us: User = this.convertUserFromText(user);
-      return us;
-    }
-    return null;
-  }
-
-
-  setUser(user: string) {
-    if (user === '') {
-      localStorage.removeItem('user');
-    }
-    localStorage.setItem('user', user);
-  }
-
-  /**
-   * auth token
-   */
-  getToken(): string {
-    return this.cookieService.get('token');
-  }
-
-  /**
-   * auth token
-   */
-
-
-  setToken(token: string, remember: boolean) {
-    if (token === '') {
-      this.cookieService.delete('token');
-      localStorage.removeItem('token');
-    } else {
-      this.cookieService.set('token', token, remember ? 60 : 0);
-      localStorage.setItem('token', token);
-    }
-  }
-
-
-  isLoggedIn(): boolean {
-    return !!this.getUser();
-  }
-
-  logout() {
-    this.setUser('');
-    this.setToken('', false);
-    if (!this.isLoggedIn()) {
-      this.router.navigateByUrl('/auth/signin');
-    } else {
-      // tood ino test kon
-      this.router.navigateByUrl('');
-      return false;
-    }
-  }
-
-  convertUserFromText(userString: string): User {
-    const userObj = this.userService.new();
-    if (userString !== 'null') {
-      this.userService.convert(JSON.parse(userString), userObj);
-    }
-    return userObj;
-  }
-
-  /**
-   *
-   * @returns {Observable<boolean>}
-   */
-  init(cloudeToken: string): Observable<boolean> {
-    const headers = new Headers();
-    headers.append('Content-Type', 'application/x-www-form-urlencoded');
-    headers.append('Accept', 'application/vnd.api+json');
-    headers.append('Authorization', 'Bearer ' + this.getToken());
-    return this.http.post(environment.app_url + 'init',
-      'app_packagename=' + 'hpen_web' +
-      '&app_version=' + '1' +
-      '&app_sdk=' + '1' +
-      '&cloud_token=' + cloudeToken
-      ,
-      {headers: headers})
-      .map(res => res.json())
-      .map(res => {
-        if (res) {
-          this.currentUser.next(this.convertUserFromText(res['user']));
-          this.setLoginParams(res, null, false);
-        }
-        return this.isLoggedIn();
-      });
-  }
-
-  getNoAuthUrls(): string[] {
-    return ['/auth/signin', '/auth/forgot'];
-  }
-
-  forgotPass1(username, type_id): Observable<any> {
-    const headers = new Headers();
-    headers.append('Content-Type', 'application/x-www-form-urlencoded');
-    return this.http.post(environment.app_url + 'forgotpass/step1',
-      'username=' + (username) + '&type_id=' + (type_id), {headers: headers});
-    // todo errore cheie
-    // .map(res => res.json());
-  }
-
-  forgotPass2(username, key, type_id): Observable<any> {
-    const headers = new Headers();
-    headers.append('Content-Type', 'application/x-www-form-urlencoded');
-    return this.http.post(environment.app_url + 'forgotpass/step2',
-      'username=' + (username) + '&key=' + (key) + '&type_id=' + (type_id), {headers: headers});
-    // .map(res => res.json());
-  }
-
-  forgotPass3(username, type_id, sms_token): Observable<any> {
-    const headers = new Headers();
-    headers.append('Content-Type', 'application/x-www-form-urlencoded');
-    return this.http.post(environment.app_url + 'forgotpass/step3',
-      'username=' + (username) + '&type_id=' + (type_id) + '&sms_token=' + (sms_token)
-      , {headers: headers});
-    // .map(res => res.json());
-  }
-
-
-  forgotPass4(username, sms_token, password, type_id): Observable<boolean> {
-    const headers = new Headers();
-    headers.append('Content-Type', 'application/x-www-form-urlencoded');
-    return this.http.post('https:' + environment.app_url + 'forgotpass/step4',
-      'username=' + (username)
-      + '&sms_token=' + (sms_token) + '&password=' + (password) + '&type_id=' + (type_id)
-      , {headers: headers})
-      .map(res => res.json())
-      .map(res => {
-        if (res) {
-          this.setLoginParams(res);
-        }
-        return this.isLoggedIn();
-      });
-  }
-
-// Bearer bayad ba fasele bashe
-  // in tabe request id va status ro mifreste be server
-
-
-  setLoginParams(loginResponse, remember?: boolean, fromLogin?: boolean) {
-    if (remember == null) {
-      remember = false;
-    }
-    if (fromLogin) {
-      this.setToken(loginResponse['token'], remember);
-    }
-    localStorage.setItem('basics', JSON.stringify(loginResponse['basics']));
-    localStorage.setItem('columns', JSON.stringify(loginResponse['columns']));
-    this.setUser(loginResponse['user']);
-    // todo for available bebinnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
-    // this.currentUser.value.available = true;
-    // this.currentUser.value.save();
-    // this.menuService.refreshItems();
-  }
-
-
-  sendRequestToNurse(receiver_id, request_id, status) {
-    const headers = new Headers();
-    headers.append('Content-Type', 'application/x-www-form-urlencoded');
-    headers.append('Accept', 'application/vnd.api+json');
-    headers.append('Authorization', 'Bearer ' + this.getToken());
-    return this.http.post(environment.app_url + 'center_action',
-      'receiver_id=' + (receiver_id) + '&request_id=' + (request_id) + '&status=' + (status), {headers: headers})
-      ;
-  }
-}

+ 1 - 7
src/app/classes/base_components/dialog/dialog.component.ts

@@ -11,22 +11,17 @@ export class DialogComponent {
     message = 'آیا مطمئن هستید؟';
     message = 'آیا مطمئن هستید؟';
     //alert default
     //alert default
     type = 'alert';
     type = 'alert';
-
     /**
     /**
      * @param {MatDialogRef<DialogComponent>} dialogRef  baray amaliat dialog
      * @param {MatDialogRef<DialogComponent>} dialogRef  baray amaliat dialog
      * @param data pass kardan etelaat be dialog
      * @param data pass kardan etelaat be dialog
      */
      */
     constructor(private dialogRef: MatDialogRef<DialogComponent>, @Inject(MAT_DIALOG_DATA) data) {
     constructor(private dialogRef: MatDialogRef<DialogComponent>, @Inject(MAT_DIALOG_DATA) data) {
-
         if (data.message) {
         if (data.message) {
             this.message = data.message;
             this.message = data.message;
         }
         }
-
         if (data.type) {
         if (data.type) {
             this.type = data.type;
             this.type = data.type;
         }
         }
-
-
     }
     }
 
 
     close() {
     close() {
@@ -34,7 +29,7 @@ export class DialogComponent {
     }
     }
 
 
     /**
     /**
-     * برای بستن دیالوگ وقتی که type برابر 'yesno'بود
+     * برای بستن دیالوگ وقتی که requestType برابر 'yesno'بود
      */
      */
     no() {
     no() {
         this.close();
         this.close();
@@ -43,5 +38,4 @@ export class DialogComponent {
     yes() {
     yes() {
         this.dialogRef.close(true);
         this.dialogRef.close(true);
     }
     }
-
 }
 }

+ 1 - 5
src/app/classes/dialog.ts → src/app/classes/base_components/dialog/dialog.ts

@@ -1,16 +1,13 @@
 import {MatDialog, MatDialogConfig} from '@angular/material';
 import {MatDialog, MatDialogConfig} from '@angular/material';
 import {Resource} from 'ngx-jsonapi';
 import {Resource} from 'ngx-jsonapi';
-import {DialogComponent} from './base_components/dialog/dialog.component';
+import {DialogComponent} from './dialog.component';
 
 
 export class Dialog extends MatDialog {
 export class Dialog extends MatDialog {
-
-
     /**
     /**
      * @param componentOrTemplateRef  baray baz kardan dialog marbot be component khodesh
      * @param componentOrTemplateRef  baray baz kardan dialog marbot be component khodesh
      * @param {Resource} resource
      * @param {Resource} resource
      * @returns {MatDialogRef<any>}
      * @returns {MatDialogRef<any>}
      */
      */
-
     openWithData<T>(componentOrTemplateRef, resource: Resource) {
     openWithData<T>(componentOrTemplateRef, resource: Resource) {
         const dialogConfig = new MatDialogConfig();
         const dialogConfig = new MatDialogConfig();
         dialogConfig.disableClose = true;
         dialogConfig.disableClose = true;
@@ -39,6 +36,5 @@ export class Dialog extends MatDialog {
             type: 'alert'
             type: 'alert'
         };
         };
         return super.open(DialogComponent, dialogConfig);
         return super.open(DialogComponent, dialogConfig);
-
     }
     }
 }
 }

+ 45 - 45
src/app/classes/base_components/list/list.component.ts

@@ -2,7 +2,7 @@ import {Component, OnInit} from '@angular/core';
 import {ICollection, Resource, Service} from 'ngx-jsonapi';
 import {ICollection, Resource, Service} from 'ngx-jsonapi';
 import {MatDialogConfig} from '@angular/material';
 import {MatDialogConfig} from '@angular/material';
 import {DialogComponent} from '../dialog/dialog.component';
 import {DialogComponent} from '../dialog/dialog.component';
-import {Dialog} from '../../dialog';
+import {Dialog} from '../dialog/dialog';
 import {EditComponent} from '../edit/edit.component';
 import {EditComponent} from '../edit/edit.component';
 import {IParamsResource} from 'ngx-jsonapi/interfaces';
 import {IParamsResource} from 'ngx-jsonapi/interfaces';
 import {Headers, Http} from '@angular/http';
 import {Headers, Http} from '@angular/http';
@@ -10,7 +10,6 @@ import {Observable} from 'rxjs/Observable';
 import {CookieService} from 'ngx-cookie-service';
 import {CookieService} from 'ngx-cookie-service';
 import {environment} from '../../../../environments/environment';
 import {environment} from '../../../../environments/environment';
 
 
-
 @Component({
 @Component({
   selector: 'app-list',
   selector: 'app-list',
   template: '',
   template: '',
@@ -38,13 +37,13 @@ export class ListComponent implements OnInit {
   sortProp = 'id';
   sortProp = 'id';
   sortDir = 'asc';
   sortDir = 'asc';
   count = 0;
   count = 0;
-  limit = 4;
+  limit = 10;
   offset = 0;
   offset = 0;
   is_loading = false;
   is_loading = false;
   filters = {};
   filters = {};
   filteredOptions = [];
   filteredOptions = [];
   lists;
   lists;
-  appUrl : any;
+  appUrl: any;
   includes;
   includes;
 
 
   /**
   /**
@@ -53,10 +52,10 @@ export class ListComponent implements OnInit {
    * @param {Dialog} dialog  baray baz kardan dialog
    * @param {Dialog} dialog  baray baz kardan dialog
    * @param {EditComponent} editComponent ye component pedar baray ers barie dialog
    * @param {EditComponent} editComponent ye component pedar baray ers barie dialog
    */
    */
-  constructor(protected listService: Service,
-              protected dialog: Dialog,
-              protected editComponent: EditComponent,
-              protected http: Http,
+  constructor(public listService: Service,
+              public dialog: Dialog,
+              public editComponent: EditComponent,
+              public http: Http,
   ) {
   ) {
     this.appUrl = environment.app_url;
     this.appUrl = environment.app_url;
   }
   }
@@ -69,10 +68,11 @@ export class ListComponent implements OnInit {
     this.fetchList('null');
     this.fetchList('null');
     // set columns from server
     // set columns from server
     let cols = JSON.parse(localStorage.getItem('columns'));
     let cols = JSON.parse(localStorage.getItem('columns'));
-    if (cols[window.location.pathname])
+    if (cols[window.location.pathname]) {
       cols = cols[window.location.pathname].toString();
       cols = cols[window.location.pathname].toString();
-    else
+    } else {
       cols = '';
       cols = '';
+    }
     cols = cols.split(',');
     cols = cols.split(',');
     // column haei ro bede ke too cols array bashe
     // column haei ro bede ke too cols array bashe
     if (cols[0] != '') {
     if (cols[0] != '') {
@@ -94,14 +94,18 @@ export class ListComponent implements OnInit {
         this.sortDir = event.sorts[0].dir;
         this.sortDir = event.sorts[0].dir;
         this.setDefaultNumberts();
         this.setDefaultNumberts();
       }
       }
-      if (event.hasOwnProperty('count'))
+      if (event.hasOwnProperty('count')) {
         this.count = event.count;
         this.count = event.count;
-      if (event.hasOwnProperty('limit'))
+      }
+      if (event.hasOwnProperty('limit')) {
         this.limit = event.limit;
         this.limit = event.limit;
-      if (event.hasOwnProperty('offset'))
+      }
+      if (event.hasOwnProperty('offset')) {
         this.offset = event.offset;
         this.offset = event.offset;
-      if (event == 'filter')
+      }
+      if (event == 'filter') {
         this.setDefaultNumberts();
         this.setDefaultNumberts();
+      }
       if (event == 'refresh') {
       if (event == 'refresh') {
         this.setDefaultSorts();
         this.setDefaultSorts();
         this.setDefaultFilters();
         this.setDefaultFilters();
@@ -110,9 +114,9 @@ export class ListComponent implements OnInit {
     this.includes = [];
     this.includes = [];
     let that = this;
     let that = this;
     for (let key in this.columns) {
     for (let key in this.columns) {
-      if (this.columns[key].mustIncluded)
-
+      if (this.columns[key].mustIncluded) {
         that.includes.push(this.columns[key].prop);
         that.includes.push(this.columns[key].prop);
+      }
     }
     }
     this.listService.all(
     this.listService.all(
       {
       {
@@ -122,22 +126,22 @@ export class ListComponent implements OnInit {
         include: that.includes
         include: that.includes
       }
       }
     ).subscribe(lists => {
     ).subscribe(lists => {
-        if (lists.$source != 'server' || lists.$is_loading)
+        if (lists.$source != 'server' || lists.$is_loading) {
           return;
           return;
+        }
         this.rows = [];
         this.rows = [];
-        let listsArray = lists.$toArray;
+      let listsArray = lists.$toArray;
         let page: any = lists.page.number;
         let page: any = lists.page.number;
-
         this.count = page.total;
         this.count = page.total;
         this.limit = page['per-page'];
         this.limit = page['per-page'];
         this.offset = page['current-page'] - 1;
         this.offset = page['current-page'] - 1;
         for (let list_key in listsArray) {
         for (let list_key in listsArray) {
           let row = [];
           let row = [];
+          row['id'] = listsArray[list_key].id;
           for (let key in this.columns) {
           for (let key in this.columns) {
             let prop = this.columns[key].prop;
             let prop = this.columns[key].prop;
-            if (prop == 'id')
-              row['id'] = listsArray[list_key].id;
-            else if (this.columns[key].replaceFunc) {
+            if (prop == 'id') {
+            } else if (this.columns[key].replaceFunc) {
               row[prop] = this.columns[key].replaceFunc(listsArray[list_key].attributes[prop]);
               row[prop] = this.columns[key].replaceFunc(listsArray[list_key].attributes[prop]);
             } else {
             } else {
               if (this.columns[key].isRelationship) {
               if (this.columns[key].isRelationship) {
@@ -167,17 +171,21 @@ export class ListComponent implements OnInit {
                     }
                     }
                   }
                   }
                   row[prop] = (names.join(',')).substr(0, 10) + '...';
                   row[prop] = (names.join(',')).substr(0, 10) + '...';
-                } else
+                } else {
                   row[prop] = '';
                   row[prop] = '';
-              } else
+                }
+              } else {
                 row[prop] = listsArray[list_key].attributes[prop];
                 row[prop] = listsArray[list_key].attributes[prop];
+              }
 
 
             }
             }
           }
           }
           let exists = false;
           let exists = false;
+
           for (let key in this.rows) {
           for (let key in this.rows) {
-            if (this.rows[key]['id'] == row['id'])
+            if (this.rows[key]['id'] == row['id']) {
               exists = true;
               exists = true;
+            }
           }
           }
           if (!exists) {
           if (!exists) {
             this.rows.push(row);
             this.rows.push(row);
@@ -185,6 +193,7 @@ export class ListComponent implements OnInit {
 
 
         }
         }
         this.lists = lists;
         this.lists = lists;
+
       }, error => {
       }, error => {
         console.log(error);
         console.log(error);
       }, () => {
       }, () => {
@@ -225,8 +234,9 @@ export class ListComponent implements OnInit {
     for (var key in filters) {
     for (var key in filters) {
       if (Array.isArray(filters[key])) {
       if (Array.isArray(filters[key])) {
         ret[key] = filters[key].join(',');
         ret[key] = filters[key].join(',');
-      } else
+      } else {
         ret[key] = filters[key];
         ret[key] = filters[key];
+      }
     }
     }
 
 
     return ret;
     return ret;
@@ -241,15 +251,13 @@ export class ListComponent implements OnInit {
     dialogConfig.disableClose = true;
     dialogConfig.disableClose = true;
     dialogConfig.autoFocus = true;
     dialogConfig.autoFocus = true;
     dialogConfig.data = {
     dialogConfig.data = {
-      message: 'این کاربر حذف خواهد شد .' +
-        'آیا مطمئن هستید؟',
+      message: 'آیا مطمئن هستید؟',
       type: 'yesno'
       type: 'yesno'
     };
     };
 
 
     const dialogRef = this.dialog.open(DialogComponent, dialogConfig);
     const dialogRef = this.dialog.open(DialogComponent, dialogConfig);
     dialogRef.afterClosed().subscribe(
     dialogRef.afterClosed().subscribe(
       result => {
       result => {
-
         if (result) {
         if (result) {
           this.listService.delete(id).subscribe(ok => {
           this.listService.delete(id).subscribe(ok => {
             this.fetchList(null);
             this.fetchList(null);
@@ -270,7 +278,7 @@ export class ListComponent implements OnInit {
 
 
     if (!id) {
     if (!id) {
       const resource = this.listService.new();
       const resource = this.listService.new();
-      // let requiredPermission = this.listService.type + '.create';
+      // let requiredPermission = this.listService.requestType + '.create';
       // if(hasAccess(requiredPermission))
       // if(hasAccess(requiredPermission))
       // {
       // {
       const dialogRef = this.dialog.openWithData(this.editComponent, resource);
       const dialogRef = this.dialog.openWithData(this.editComponent, resource);
@@ -287,7 +295,7 @@ export class ListComponent implements OnInit {
 
 
     } else {
     } else {
       //   {
       //   {
-      // let requiredPermission = this.listService.type + '.update';
+      // let requiredPermission = this.listService.requestType + '.update';
       // if (hasAccess(requiredPermission)) {
       // if (hasAccess(requiredPermission)) {
       this.listService.get(id, params)
       this.listService.get(id, params)
         .subscribe(
         .subscribe(
@@ -324,8 +332,9 @@ export class ListComponent implements OnInit {
       remotefilter: remoteFilter,
       remotefilter: remoteFilter,
       page: {number: 1, size: 5}
       page: {number: 1, size: 5}
     }).subscribe(data => {
     }).subscribe(data => {
-      if (data.$source != 'server' || data.$is_loading)
+      if (data.$source != 'server' || data.$is_loading) {
         return;
         return;
+      }
       this.filteredOptions[prop] = data.$toArray;
       this.filteredOptions[prop] = data.$toArray;
 
 
     });
     });
@@ -337,45 +346,36 @@ export class ListComponent implements OnInit {
    * @param value مقداری که قراره فیلتر کنیم
    * @param value مقداری که قراره فیلتر کنیم
    */
    */
   protected setFiltersVarAndRefresh(key, value) {
   protected setFiltersVarAndRefresh(key, value) {
-
     this.filters[key] = value;
     this.filters[key] = value;
     this.fetchList('filter');
     this.fetchList('filter');
   }
   }
 
 
-
   toggle(col): Observable<boolean> {
   toggle(col): Observable<boolean> {
     const isChecked = this.isChecked(col);
     const isChecked = this.isChecked(col);
     if (isChecked) {
     if (isChecked) {
-      if (this.columns.length < 2 || col.prop == 'id')
+      if (this.columns.length < 2 || col.prop == 'id') {
         return;
         return;
+      }
       this.columns = this.columns.filter(c => {
       this.columns = this.columns.filter(c => {
         return c.prop !== col.prop;
         return c.prop !== col.prop;
       });
       });
     } else {
     } else {
-      this.columns = [...this.columns, col];
+      this.columns = [col , ...this.columns];
     }
     }
     // sort ba asase all columns
     // sort ba asase all columns
-    this.columns = this.allColumns.filter(c => {
+    this.columns = this.columns.filter(c => {
       return this.columns.find(c2 => {
       return this.columns.find(c2 => {
         return c.prop === c2.prop;
         return c.prop === c2.prop;
       });
       });
     });
     });
-
-
     let cols = [];
     let cols = [];
     for (let key in this.columns) {
     for (let key in this.columns) {
       cols.push(this.columns[key]['prop']);
       cols.push(this.columns[key]['prop']);
     }
     }
-
-
     this.setColumns(cols).subscribe(result => {
     this.setColumns(cols).subscribe(result => {
-
-
       this.fetchList('null');
       this.fetchList('null');
     }, error1 => {
     }, error1 => {
     });
     });
-
-
   }
   }
 
 
   isChecked(col) {
   isChecked(col) {

+ 0 - 50
src/app/classes/center.service.ts

@@ -1,50 +0,0 @@
-import {Injectable} from '@angular/core';
-import {ISchema, Resource, Service} from 'ngx-jsonapi';
-
-
-@Injectable()
-export class CentersService extends Service<Center> {
-  public resource = Center;
-  public type = 'centers';
-}
-
-export class Center extends Resource {
-  public attributes: {
-    lat: string,
-    lng: string,
-    address: string,
-    department: string,
-  };
-
-  get lat(): string {
-    return this.attributes.lat;
-  }
-
-  set lat(lat: string) {
-    this.attributes.lat = lat;
-  }
-
-  get lng(): string {
-    return this.attributes.lng;
-  }
-
-  set lng(lng: string) {
-    this.attributes.lng = lng;
-  }
-
-  get address(): string {
-    return this.attributes.address;
-  }
-
-  set address(address: string) {
-    this.attributes.address = address;
-  }
-
-  get department(): string {
-    return this.attributes.department;
-  }
-
-  set department(department: string) {
-    this.attributes.department = department;
-  }
-}

+ 0 - 21
src/app/classes/doc.service.ts

@@ -1,21 +0,0 @@
-import {Resource, Service} from 'ngx-jsonapi';
-import {Injectable} from '@angular/core';
-@Injectable()
-
-export class DocService extends Service<Doc> {
-    public resource = Doc;
-    public type = 'docs';
-}
-
-export class Doc extends Resource {
-    public attributes: {
-        url: string,
-    };
-
-    get url(): string {
-        return this.attributes.url;
-    }
-    set url(url: string) {
-        this.attributes.url = url;
-    }
-}

+ 14 - 0
src/app/classes/guards/auth.guard.ts

@@ -0,0 +1,14 @@
+import {Injectable} from '@angular/core';
+import {CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router} from '@angular/router';
+import {Observable} from 'rxjs/Observable';
+
+@Injectable()
+export class AuthGuard implements CanActivate {
+  constructor(
+  ) {
+  }
+
+  canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean {
+    return undefined;
+  }
+}

+ 17 - 0
src/app/classes/guards/guest.guard.ts

@@ -0,0 +1,17 @@
+import {Injectable} from '@angular/core';
+import {ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot} from '@angular/router';
+import {Observable} from 'rxjs/Observable';
+
+
+@Injectable()
+export class GuestGuard implements CanActivate {
+
+
+  constructor() {
+  }
+
+  canActivate(route: ActivatedRouteSnapshot,
+              state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean {
+    return undefined;
+  }
+}

+ 230 - 0
src/app/classes/jalali/jalali-moment-dateAdapter.ts

@@ -0,0 +1,230 @@
+import * as  moment from 'jalali-moment';
+import { DateAdapter, MAT_DATE_LOCALE } from '@angular/material';
+
+/** Creates an array and fills it with values. */
+function range<T>(length: number, valueFunction: (index: number) => T): T[] {
+  const valuesArray = Array(length);
+  for (let i = 0; i < length; i++) {
+    valuesArray[i] = valueFunction(i);
+  }
+  return valuesArray;
+}
+export class JalaliMomentDateAdapter extends DateAdapter<moment.Moment> {
+
+  constructor() {
+    // @Optional() @Inject(MAT_DATE_LOCALE) dateLocale: string
+    super();
+    // this.setLocale(dateLocale || jmoment.locale(dateLocale));
+    super.setLocale('fa');
+  }
+
+
+  /**
+   * returns year in jalali calendar system.
+   */
+  getYear(date: moment.Moment): number {
+    return this.clone(date).jYear();
+  }
+
+  /**
+   * returns month in jalali calendar system.
+   */
+  getMonth(date: moment.Moment): number {
+    return this.clone(date).jMonth();
+  }
+
+  /**
+   * returns day in jalali calendar system.
+   */
+  getDate(date: moment.Moment): number {
+    return this.clone(date).jDate();
+  }
+
+  /**
+   * returns Day Of Week in jalali calendar system.
+   */
+  getDayOfWeek(date: moment.Moment): number {
+    return this.clone(date).day();
+  }
+
+  /**
+   * returns Month Names in jalali calendar system.
+   * most of the time we use long format. short or narrow format for month names is a little odd.
+   */
+  getMonthNames(style: 'long' | 'short' | 'narrow'): string[] {
+    switch (style) {
+      case 'long':
+      case 'short':
+        return moment.localeData('fa').jMonths().slice(0);
+      case 'narrow':
+        return moment.localeData('fa').jMonthsShort().slice(0);
+    }
+  }
+
+  /**
+   * borrowed from angular material code.
+   */
+  getDateNames(): string[] {
+    return range(31, i => String(i + 1));
+    // return this._localeData.dates;
+  }
+
+  /**
+   * returns Day Of Week names in jalali calendar system.
+   */
+  getDayOfWeekNames(style: 'long' | 'short' | 'narrow'): string[] {
+    switch (style) {
+      case 'long':
+        return moment.localeData('fa').weekdays().slice(0);
+      case 'short':
+        return moment.localeData('fa').weekdaysShort().slice(0);
+      case 'narrow':
+        return ['ی', 'د', 'س', 'چ', 'پ', 'ج', 'ش'];
+    }
+  }
+
+  /**
+   * returns year in jalali calendar system.
+   */
+  getYearName(date: moment.Moment): string {
+    return this.clone(date).jYear().toString();
+  }
+
+  /**
+   * returns first day of week in jalali calendar system.
+   * first day of week is saturday, شنبه
+   */
+  getFirstDayOfWeek(): number {
+    return moment.localeData('fa').firstDayOfWeek();
+  }
+
+  /**
+   * returns Number of Days In Month in jalali calendar system.
+   */
+  getNumDaysInMonth(date: moment.Moment): number {
+    return this.clone(date).jDaysInMonth();
+  }
+
+  clone(date: moment.Moment): moment.Moment {
+    return date.clone().locale('fa');
+  }
+
+  /**
+   * Pass 3 number in jalali calendar system to this function and it returns a moment object
+   * @param year jalali year
+   * @param month zero indexed jalali month
+   * @param date jalali day
+   */
+  createDate(year: number, month: number, date: number): moment.Moment {
+    if (month < 0 || month > 11) {
+      throw Error(
+        `Invalid month index "${month}". Month index has to be between 0 and 11.`
+      );
+    }
+    if (date < 1) {
+      throw Error(`Invalid date "${date}". Date has to be greater than 0.`);
+    }
+    const result = moment()
+      .jYear(year).jMonth(month).jDate(date)
+      .hours(0).minutes(0).seconds(0).milliseconds(0)
+      .locale('fa');
+    // Check that the date wasn't above the upper bound for the month, causing the month to overflow
+    if (this.getMonth(result) !== month) {
+      throw Error(`Invalid date ${date} for month with index ${month}.`);
+    }
+    if (!result.isValid()) {
+      throw Error(`Invalid date "${date}" for month with index "${month}".`);
+    }
+    return result;
+  }
+
+  today(): moment.Moment {
+    return moment().locale('fa');
+  }
+
+  parse(value: any, parseFormat: string | string[]): moment.Moment | null {
+    if (value && typeof value === 'string') {
+      const result = moment(value, parseFormat, 'fa');
+      return result;
+    }
+    return value ? moment(value).locale('fa') : null;
+  }
+
+  format(date: moment.Moment, displayFormat: string): string {
+    date = this.clone(date);
+    if (!this.isValid(date)) {
+      throw Error('JalaliMomentDateAdapter: Cannot format invalid date.');
+    }
+    return date.format(displayFormat);
+  }
+
+  addCalendarYears(date: moment.Moment, years: number): moment.Moment {
+    return this.clone(date).add(years, 'jYear');
+  }
+
+  addCalendarMonths(date: moment.Moment, months: number): moment.Moment {
+    return this.clone(date).add(months, 'jmonth');
+  }
+
+  addCalendarDays(date: moment.Moment, days: number): moment.Moment {
+    return this.clone(date).add(days, 'jDay');
+  }
+
+  /**
+   *Gets the RFC 3339 compatible string (https://tools.ietf.org/html/rfc3339) for the given date.
+   * This method is used to generate date strings that are compatible with native HTML attributes
+   *such as the `min` or `max` attribute of an `<input>`.
+   *@param date The date to get the ISO date string for.
+   *@returns The ISO date string date string.
+   */
+  toIso8601(date: moment.Moment): string {
+    return this.clone(date).format();
+  }
+
+  isDateInstance(obj: any): boolean {
+    return moment.isMoment(obj);
+  }
+
+  isValid(date: moment.Moment): boolean {
+    return this.clone(date).isValid();
+  }
+
+  invalid(): moment.Moment {
+    return moment.invalid();
+  }
+
+  /**
+   * Returns the given value if given a valid Moment or null. Deserializes valid ISO 8601 strings
+   * (https://www.ietf.org/rfc/rfc3339.txt) and valid Date objects into valid Moments and empty
+   * string into null. Returns an invalid date for all other values.
+   */
+
+  /**
+   * Attempts to deserialize a value to a valid date object. This is different from parsing in that
+   * deserialize should only accept non-ambiguous, locale-independent formats (e.g. a ISO 8601
+   * string). The default implementation does not allow any deserialization, it simply checks that
+   * the given value is already a valid date object or null. The `<mat-datepicker>` will call this
+   * method on all of it's `@Input()` properties that accept dates. It is therefore possible to
+   * support passing values from your backend directly to these properties by overriding this method
+   * to also deserialize the format used by your backend.
+   * @param value The value to be deserialized into a date object.
+   * @returns The deserialized date object, either a valid date, null if the value can be
+   *     deserialized into a null date (e.g. the empty string), or an invalid date.
+   */
+  deserialize(value: any): moment.Moment | null {
+    let date;
+    if (value instanceof Date) {
+      date = moment(value);
+    }
+    if (typeof value === 'string') {
+      if (!value) {
+        return null;
+      }
+      date = moment(value).locale('fa');
+    }
+    if (date && this.isValid(date)) {
+      return date;
+    }
+    return super.deserialize(value);
+  }
+}

+ 13 - 0
src/app/classes/jalali/jalali-moment-formats.ts

@@ -0,0 +1,13 @@
+import { MatDateFormats } from '@angular/material';
+export const JALALI_MOMENT_FORMATS: MatDateFormats = {
+  parse: {
+    dateInput: 'jYYYY/jMM/jDD',
+  },
+  display: {
+    dateInput: 'jYYYY/jMM/jDD',
+    monthYearLabel: 'jYYYY jMMMM',
+    dateA11yLabel: 'jYYYY/jMM/jDD',
+    monthYearA11yLabel: 'jYYYY jMMMM'
+  }
+};
+

+ 0 - 112
src/app/classes/message.service.ts

@@ -1,112 +0,0 @@
-import {Injectable} from '@angular/core';
-import {ICollection, ISchema, Resource, Service} from 'ngx-jsonapi';
-import {Base} from 'ngx-jsonapi/services/base';
-
-import {User, UsersService} from '../components/user/users/users.service';
-import {App, AppsService} from './apps.service';
-
-
-@Injectable()
-export class MessageService extends Service<Message> {
-  public resource = Message;
-  public type = 'messages';
-  public schema: ISchema = {
-    relationships: {
-      apps: {
-        hasMany: true
-      },
-      receivers: {
-        hasMany: true
-      },
-    }
-  };
-}
-
-
-export class Message extends Resource {
-  public attributes: {
-    title: string;
-    body: string;
-    send_type: string;
-  };
-
-  get title() {
-    return this.attributes.title;
-  }
-
-  set title(title: string) {
-    this.attributes.title = title;
-  }
-
-  get body() {
-    return this.attributes.body;
-  }
-
-  set body(Body: string) {
-    this.attributes.body = Body;
-  }
-
-  get send_type() {
-    return this.attributes.send_type;
-  }
-
-  set send_type(send_type: string) {
-    this.attributes.send_type = send_type;
-  }
-
-  // baray relationship app ke chand be chand hast
-
-  get apps(): ICollection<App> {
-    return <ICollection<App>>this.relationships.apps.data;
-  }
-
-  set apps(apps: ICollection<App>) {
-    this.relationships.apps.data = apps;
-  }
-
-  get appsIds(): string[] {
-    let ids: string[] = [];
-    Base.forEach(this.apps, (app: App) => {
-      ids.push(app.id);
-    });
-    return ids;
-  }
-
-  set appsIds(ids: string[]) {
-    let selected_apps: ICollection<App> = Base.newCollection<App>();
-    ids.forEach(function (id) {
-      let app = (new AppsService()).new();
-      app.id = id;
-      selected_apps[id] = app;
-    });
-    this.apps = selected_apps;
-  }
-
-  // baray relationship receiver hast ke chand be chande
-  get receivers(): ICollection<User> {
-    return <ICollection<User>>this.relationships.receivers.data;
-  }
-
-  set receivers(user: ICollection<User>) { // todo
-    this.relationships.receivers.data = user;
-  }
-
-  get receiversIds(): string[] {
-    let ids: string[] = [];
-    Base.forEach(this.receivers, (user: User) => {
-      ids.push(user.id);
-    });
-    return ids;
-  }
-
-
-  set receiversIds(ids: string[]) {
-    let selected_users: ICollection<User> = Base.newCollection<User>();
-    ids.forEach(function (id) {
-      let user = (new UsersService()).new();
-      user.id = id;
-      selected_users[id] = user;
-    });
-    this.receivers =  selected_users
-  }
-}

+ 0 - 72
src/app/classes/messaging.service.ts

@@ -1,72 +0,0 @@
-import {Inject, Injectable, Output, ViewContainerRef} from '@angular/core';
-import * as firebase from 'firebase';
-import 'rxjs/add/operator/take';
-import {BehaviorSubject} from 'rxjs/BehaviorSubject';
-import {AuthService} from './auth.service';
-import {User} from '../components/user/users/users.service';
-import {GlobalService} from './global.service';
-import {Dialog} from './dialog';
-import {Toast, ToasterService} from 'angular5-toaster/dist';
-import {AngularFireDatabase} from '@angular/fire/database';
-import {AngularFireAuth} from '@angular/fire/auth';
-
-@Injectable()
-export class MessagingService {
-    user: User;
-    test;
-    messaging = firebase.messaging();
-
-    currentMessage = new BehaviorSubject(null);
-
-
-    constructor(private db: AngularFireDatabase,
-                private afAuth: AngularFireAuth,
-                private authService: AuthService,
-                private global: GlobalService,
-                private dialog: Dialog,
-                private toastService: ToasterService,
-    ) {
-
-    }
-    updateToken(token) {
-        // inja ma token firebase ro migirim
-        this.afAuth.authState.take(1).subscribe(user => {
-            if (!user) {
-                return;
-            }
-            const data = {[user.uid]: token};
-            this.db.object('fcmTokens/').update(data);
-        });
-    }
-
-    getPermission() {
-        this.messaging.requestPermission()
-            .then(() => {
-                return this.messaging.getToken();
-            })
-            .then(token => {
-                this.authService.cloud_token.next(token);
-                this.updateToken(token);
-
-            })
-            .catch((err) => {
-                console.log('Unable to get permission to notify.', err);
-            });
-    }
-
-    receiveMessage() {
-        // todo tabe update request ro inja bezar
-        this.messaging.onMessage((payload) => {
-            let notification = JSON.parse(payload['data']['notification']);
-            let toast: Toast = {
-                type: 'info',
-                title: notification['title'],
-                // body: ToasterButtonComponent,
-                // bodyOutputType: BodyOutputType.Component,
-                //data: payload,
-            };
-            this.toastService.pop(toast);
-            //this.currentMessage.next(payload);
-        });
-    }
-}

+ 0 - 15
src/app/classes/product-pivots.ts

@@ -1,15 +0,0 @@
-export class ProductPivots {
-  id: string;
-  name: string;
-  price: number;
-  num: number;
-
-  constructor(id, name, price, num) {
-    this.id = id;
-    this.name = name;
-    this.price = price;
-    this.num = num;
-  }
-
-
-}

+ 11 - 27
src/app/components/user/permissions/permissions.service.ts → src/app/classes/resorcess/permissions.service.ts

@@ -23,27 +23,23 @@ export class Permission extends Resource {
     slug: string;
     slug: string;
   };
   };
 
 
-  get name():string {
+  get name(): string {
     return this.attributes.name;
     return this.attributes.name;
   }
   }
+
   set name(name: string) {
   set name(name: string) {
     this.attributes.name = name;
     this.attributes.name = name;
   }
   }
 
 
-  get slug():string {
+  get slug(): string {
     return this.attributes.slug;
     return this.attributes.slug;
   }
   }
 
 
   set slug(slug: string) {
   set slug(slug: string) {
     this.attributes.slug = slug;
     this.attributes.slug = slug;
   }
   }
-// in vase relationship group hast yek be yeke
-  // ino beporse
-  // get group(): PermissionGroup {
-  //   return <PermissionGroup>this.relationships.group.data;
-  // }
 
 
-  get group():Permission {
+  get group(): Permission {
     return <Permission>this.relationships.group.data;
     return <Permission>this.relationships.group.data;
   }
   }
 
 
@@ -51,23 +47,11 @@ export class Permission extends Resource {
     this.relationships.group.data = group;
     this.relationships.group.data = group;
   }
   }
 
 
-
-  // set group(group: PermissionGroup) {
-  //   this.relationships.group.data = group;
-  // }
-// // todo ino beporse
-//   set groupId(id: string) {
-//     const permissionGroupService = new PermissionGroupsService();
-//     const group = permissionGroupService.new();
-//     group.id = id;
-//     this.group = group
-//   }
- // todo ino beporse
   set groupId(id: string) {
   set groupId(id: string) {
     const permissionService = new PermissionsService();
     const permissionService = new PermissionsService();
     const group = permissionService.new();
     const group = permissionService.new();
     group.id = id;
     group.id = id;
-    this.group = group
+    this.group = group;
   }
   }
 
 
 }
 }
@@ -93,21 +77,22 @@ export class PermissionGroup extends Resource {
     slug: string;
     slug: string;
   };
   };
 
 
-  get name():string {
+  get name(): string {
     return this.attributes.name;
     return this.attributes.name;
   }
   }
+
   set name(name: string) {
   set name(name: string) {
     this.attributes.name = name;
     this.attributes.name = name;
   }
   }
 
 
-  get slug():string {
+  get slug(): string {
     return this.attributes.slug;
     return this.attributes.slug;
   }
   }
 
 
   set slug(slug: string) {
   set slug(slug: string) {
     this.attributes.slug = slug;
     this.attributes.slug = slug;
   }
   }
-  // in vase relation pemisions hast ke chand be chand hast
+
   get permissions(): ICollection<Permission> {
   get permissions(): ICollection<Permission> {
     return <ICollection<Permission>>this.relationships.permissions.data;
     return <ICollection<Permission>>this.relationships.permissions.data;
   }
   }
@@ -116,7 +101,6 @@ export class PermissionGroup extends Resource {
     this.relationships.permissions.data = permissions;
     this.relationships.permissions.data = permissions;
   }
   }
 
 
-  // in permision haro migire foreach mizane ideshon ro bar migardone
   get permissionsIds(): string[] {
   get permissionsIds(): string[] {
     let ids: string[] = [];
     let ids: string[] = [];
     Base.forEach(this.permissions, (Permission: Permission) => {
     Base.forEach(this.permissions, (Permission: Permission) => {
@@ -124,7 +108,7 @@ export class PermissionGroup extends Resource {
     });
     });
     return ids;
     return ids;
   }
   }
-  // in baray new kardan ye permision hast
+
   set PermissionsIds(ids: string[]) {
   set PermissionsIds(ids: string[]) {
     const selected_permissions: ICollection<Permission> = Base.newCollection<Permission>();
     const selected_permissions: ICollection<Permission> = Base.newCollection<Permission>();
     for (const key in ids) {
     for (const key in ids) {
@@ -135,7 +119,7 @@ export class PermissionGroup extends Resource {
         permission.id = permission_id;
         permission.id = permission_id;
         selected_permissions[permission_id] = permission;
         selected_permissions[permission_id] = permission;
       }
       }
-      this.permissions = selected_permissions
+      this.permissions = selected_permissions;
     }
     }
   }
   }
 }
 }

+ 1 - 1
src/app/components/user/roles/roles.service.ts → src/app/classes/resorcess/roles.service.ts

@@ -1,6 +1,6 @@
 import {Injectable} from '@angular/core';
 import {Injectable} from '@angular/core';
 import {ICollection, ISchema, Resource, Service} from 'ngx-jsonapi';
 import {ICollection, ISchema, Resource, Service} from 'ngx-jsonapi';
-import {Permission, PermissionsService} from '../permissions/permissions.service';
+import {Permission, PermissionsService} from './permissions.service';
 import {Base} from 'ngx-jsonapi/services/base';
 import {Base} from 'ngx-jsonapi/services/base';
 
 
 
 

+ 14 - 0
src/app/classes/resorcess/users.service.ts

@@ -0,0 +1,14 @@
+import {Injectable} from '@angular/core';
+import {Resource, Service} from 'ngx-jsonapi';
+
+
+@Injectable()
+export class UsersService extends Service<User> {
+  public resource = User;
+  public type = 'users';
+}
+
+export class User extends Resource {
+  public static NURSE_TYPE_ID = '2';
+  public attributes: {};
+}

+ 197 - 0
src/app/classes/servicess/auth.service.ts

@@ -0,0 +1,197 @@
+import {Injectable} from '@angular/core';
+import {Observable} from 'rxjs/Observable';
+import {Http} from '@angular/http';
+import {Headers} from '@angular/http';
+import {CookieService} from 'ngx-cookie-service';
+import {User, UsersService} from '../resorcess/users.service';
+import {RolesService} from '../resorcess/roles.service';
+import {Router} from '@angular/router';
+import {environment} from '../../../environments/environment';
+import {Dialog} from '../base_components/dialog/dialog';
+@Injectable()
+export class AuthService {
+  auth: AuthService;
+  private _currentUser: User;
+  private _auth_token: string;
+  /**
+   * وقتی برنامه رفرش میشه به صورت پیش فرض ture هست وقتی init اجرا میشه false میشه دیگه تا وثتی که رفرش نشه init بررسی نمیشه و لاگین باقی میمونه
+   */
+  needToRunInit = true;
+
+  /**
+   * @param {Http} http  baray darkhadt hay http estefade mishe
+   * @param {CookieService} cookieService baray save kardan token
+   * @param router
+   * @param userService
+   * @param roleService
+   * @param dialog
+   * @param toasterService
+   */
+  constructor(private http: Http,
+              private cookieService: CookieService,
+              private router: Router,
+              private userService: UsersService,
+              private roleService: RolesService,
+              private dialog: Dialog,
+  ) {
+    this.roleService.register();
+  }
+
+  get auth_token(): string {
+    return this.cookieService.get('token');
+  }
+
+  set auth_token(value: string) {
+    this._auth_token = value;
+  }
+
+  get currentUser(): User {
+    return this._currentUser;
+  }
+
+  set currentUser(value: User) {
+    this._currentUser = value;
+  }
+
+  /**
+   *
+   * @param username email user hast
+   * @param password
+   * @param type requestType user hast mesl dr ya parastar
+   * @param cloud_token
+   * @param remember
+   * @returns {Observable<boolean>}
+   */
+
+  loginWithPassword(mobile, password, remember, app_package_name, app_version, app_sdk): Observable<boolean> {
+    const headers = new Headers();
+    headers.append('Content-Type', 'application/x-www-form-urlencoded');
+    return this.http.post(environment.app_url + 'login',
+      'mobile=' + (mobile) + '&password=' + (password) +
+      +'&app_package_name=' + (app_package_name)
+      + '&app_version=' + (app_version) + '&app_sdk=' + (app_sdk)
+      ,
+      {headers: headers})
+      .map(res => res.json())
+      .map(res => {
+        if (res) {
+          this.setLoginParams(res, remember, true);
+        }
+        return this.isLoggedIn();
+      });
+  }
+
+  loginWithSmsToken(mobile, sms_token, remember, app_package_name, app_version, app_sdk): Observable<boolean> {
+    const headers = new Headers();
+    headers.append('Content-Type', 'application/x-www-form-urlencoded');
+    return this.http.post(environment.app_url + 'login',
+      'mobile=' + (mobile) + '&sms_token=' + (sms_token) + '&app_package_name=' + (app_package_name)
+      + '&app_version=' + (app_version) + '&app_sdk=' + (app_sdk)
+      ,
+      {headers: headers})
+      .map(res => res.json())
+      .map(res => {
+        if (res) {
+          this.setLoginParams(res, remember, true);
+        }
+        return this.isLoggedIn();
+      });
+  }
+
+
+  /**
+   * auth token
+   */
+
+  setToken(token: string, remember: boolean) {
+    if (token === '') {
+      this.cookieService.delete('token');
+    } else {
+      this.cookieService.set('token', token, remember ? 60 : 0);
+    }
+  }
+
+
+  isLoggedIn(): boolean {
+    return !!this.currentUser;
+  }
+
+  logout() {
+    this.currentUser = null;
+    this.setToken('', false);
+    if (!this.isLoggedIn()) {
+      this.router.navigateByUrl('/auth/passwordSignin');
+    } else {
+      // todo ino test kon
+      this.router.navigateByUrl('');
+      return false;
+    }
+  }
+
+  convertUserFromText(userString: string): User {
+    const userObj = this.userService.new();
+    if (userString !== 'null') {
+      this.userService.convert(JSON.parse(userString), userObj);
+    }
+    return userObj;
+  }
+
+  /**
+   *
+   * @returns {Observable<boolean>}
+   */
+  init(): Promise<boolean> {
+    const headers = new Headers();
+    headers.append('Content-Type', 'application/x-www-form-urlencoded');
+    headers.append('Accept', 'application/vnd.api+json');
+    headers.append('Authorization', 'Bearer ' + this.auth_token);
+    return this.http.post(environment.app_url + 'init',
+      'app_package_name=' + 'hpen_web' +
+      '&app_version=' + '1' +
+      '&app_sdk=' + '1',
+      {headers: headers})
+      .toPromise()
+      .then(response => {
+
+        response = response.json();
+        this.setLoginParams(response, null, false);
+        if (this.isLoggedIn()) {
+          return Promise.resolve(true);
+        } else {
+          return Promise.reject(false);
+        }
+      }).catch(reason => {
+        console.log('reason is', reason);
+        this.needToRunInit = false;
+        return Promise.reject(false);
+      });
+  }
+
+  // in tabe request id va status ro mifreste be server
+  /***
+   *
+   * @param loginResponse رسپانس init  و login  هست
+   * @param remember این واسه ی مرا بخاطر بسپار هست
+   * @param fromLogin سرور در صورتی به ما توکن میده که لاگین کنیم  اینجا میگه  اگه لاگین  بود توکن ست کن
+   */
+  setLoginParams(loginResponse, remember?: boolean, fromLogin?: boolean) {
+    this.needToRunInit = false;
+    this.currentUser = this.convertUserFromText(loginResponse['user']);
+    if (remember == null) {
+      remember = false;
+    }
+    if (fromLogin) {
+      this.setToken(loginResponse['token'], remember);
+    }
+    localStorage.setItem('basics', JSON.stringify(loginResponse['basics']));
+    localStorage.setItem('columns', JSON.stringify(loginResponse['columns']));
+  }
+
+  mobileExists(mobile, type): Observable<any> {
+    const headers = new Headers();
+    headers.append('Content-Type', 'application/x-www-form-urlencoded');
+    headers.append('Accept', 'application/vnd.api+json');
+    return this.http.post(environment.app_url + 'mobileExists',
+      'mobile=' + (mobile) + '&type=' + (type), {headers: headers});
+  }
+}

+ 7 - 4
src/app/classes/global.service.ts → src/app/classes/servicess/global.service.ts

@@ -5,13 +5,16 @@ import {BehaviorSubject} from 'rxjs';
 export class GlobalService {
 export class GlobalService {
   // in akharin request ro bar mighardone ke betonam be har parastar ke mikham bedam
   // in akharin request ro bar mighardone ke betonam be har parastar ke mikham bedam
   request = new BehaviorSubject<any>('');
   request = new BehaviorSubject<any>('');
-  emailData;
-  smstoken;
   tokenLogin;
   tokenLogin;
   notificationData = new BehaviorSubject<any>('');
   notificationData = new BehaviorSubject<any>('');
   nurse = new BehaviorSubject<any>('');
   nurse = new BehaviorSubject<any>('');
   //  dar component map request estefade shode baray gereftan data y request , dar component resume ham estefade mishe
   //  dar component map request estefade shode baray gereftan data y request , dar component resume ham estefade mishe
   requests = new BehaviorSubject<any>('');
   requests = new BehaviorSubject<any>('');
-  // todo in baray data request hast
-
+  replaceStatus(status: string) {
+    const statusRequest = JSON.parse(localStorage.getItem('basics'))['statuses'];
+    const result = statusRequest.find(obj => {
+      return obj.id === status;
+    });
+    return result.name;
+  }
 }
 }

+ 5 - 24
src/app/classes/utils.ts

@@ -1,8 +1,5 @@
-import {Dialog} from './dialog';
-import {ICollection, Resource} from 'ngx-jsonapi';
-import {Service, Service as Srv, ServicesService} from '../components/basic/services/services.service';
-import {Base} from 'ngx-jsonapi/services/base';
-import {Product, ProductsService} from '../components/basic/products/products.service';
+import {Dialog} from './base_components/dialog/dialog';
+
 
 
 export function setErrors(errors: any[], controls, dialog: Dialog) {
 export function setErrors(errors: any[], controls, dialog: Dialog) {
   let errorStrings: string[] = [];
   let errorStrings: string[] = [];
@@ -21,9 +18,9 @@ export function setErrors(errors: any[], controls, dialog: Dialog) {
       errorStrings[errorStrings.length] = err.detail;
       errorStrings[errorStrings.length] = err.detail;
     }
     }
   }
   }
-  if (errorStrings.length > 0) {
-    dialog.openForAlert(errorStrings.join(','));
-  }
+  // if (errorStrings.length > 0) {
+  //   // dialog.openForAlert(errorStrings.join(','));
+  // }
 }
 }
 
 
 // az server username barmigardone
 // az server username barmigardone
@@ -36,19 +33,3 @@ export function repairErrors(errors) {
   return errors;
   return errors;
 }
 }
 
 
-export function getBaseServices(): Service[] {
-  const basics = JSON.parse(localStorage.getItem('basics'));
-  const basicServicess = JSON.parse(basics['services']);
-  const resource: ICollection<Srv> = Base.newCollection<Srv>();
-  (new ServicesService()).convert(basicServicess, resource);
-  return resource.$toArray;
-}
-
-export function getBaseProduct(): Product[] {
-  const basics = JSON.parse(localStorage.getItem('basics'));
-  const basicProducts = JSON.parse(basics['products']);
-  // todo in porside shavad
-  const resource: ICollection<Product> = Base.newCollection<Product>();
-  (new ProductsService()).convert(basicProducts, resource);
-  return resource.$toArray;
-}

+ 61 - 0
src/app/components/auth/auth.module.ts

@@ -0,0 +1,61 @@
+import {NgModule} from '@angular/core';
+import {RouterModule} from '@angular/router';
+import {CommonModule} from '@angular/common';
+import {
+  MatIconModule,
+  MatCardModule,
+  MatInputModule,
+  MatCheckboxModule,
+  MatButtonModule,
+  MatSelectModule,
+  DateAdapter, MAT_DATE_LOCALE, MAT_DATE_FORMATS, MatDatepickerModule, MatAutocompleteModule, MatProgressBarModule
+} from '@angular/material';
+import {FormsModule, ReactiveFormsModule} from '@angular/forms';
+import {FlexLayoutModule} from '@angular/flex-layout';
+import {LoadingModule} from 'ngx-loading';
+import {AuthRoutes} from './auth.routing';
+import {NotFoundComponent} from './not-found/not-found.component';
+import {PasswordSigninComponent} from './passwordSignin/passwordSignin.component';
+import {SmstokenSigninComponent} from './smstokenSignin/smstokenSignin.component';
+import {MatDialogModule} from '@angular/material/dialog';
+import {JalaliMomentDateAdapter} from '../../classes/jalali/jalali-moment-dateAdapter';
+import {JALALI_MOMENT_FORMATS} from '../../classes/jalali/jalali-moment-formats';
+@NgModule({
+  imports: [
+    MatDatepickerModule,
+    LoadingModule.forRoot({
+      backdropBackgroundColour: 'rgba(0,0,0,0.1)',
+      backdropBorderRadius: '4px',
+      primaryColour: '#0000ff',
+      secondaryColour: '#0000ff',
+      tertiaryColour: '#0000ff'
+    }),
+    LoadingModule,
+    MatSelectModule,
+    CommonModule,
+    RouterModule.forChild(AuthRoutes),
+    MatIconModule,
+    MatCardModule,
+    MatInputModule,
+    MatCheckboxModule,
+    MatButtonModule,
+    FlexLayoutModule,
+    FormsModule,
+    ReactiveFormsModule,
+    MatDialogModule,
+    MatAutocompleteModule,
+    MatProgressBarModule,
+  ],
+  declarations: [
+    NotFoundComponent,
+    PasswordSigninComponent,
+    SmstokenSigninComponent,
+
+  ],
+  providers: [
+    { provide: DateAdapter, useClass: JalaliMomentDateAdapter, deps: [MAT_DATE_LOCALE] },
+    { provide: MAT_DATE_FORMATS, useValue: JALALI_MOMENT_FORMATS }],
+})
+
+export class AuthModule {
+}

+ 29 - 0
src/app/components/auth/auth.routing.ts

@@ -0,0 +1,29 @@
+import {Routes} from '@angular/router';
+import {NotFoundComponent} from './not-found/not-found.component';
+import {PasswordSigninComponent} from './passwordSignin/passwordSignin.component';
+import {SmstokenSigninComponent} from './smstokenSignin/smstokenSignin.component';
+import {GuestGuard} from '../../classes/guards/guest.guard';
+
+export const AuthRoutes: Routes = [
+    {
+        path: '',
+        children: [{
+            path: '404',
+            component: NotFoundComponent,
+            canActivate: [GuestGuard]
+
+        }, {
+            path: 'passwordSignin',
+            component: PasswordSigninComponent,
+            canActivate: [GuestGuard]
+
+        },
+            {
+                path: 'smstokenSignin',
+                component: SmstokenSigninComponent,
+                canActivate: [GuestGuard]
+
+            },
+        ]
+    }
+];

+ 0 - 38
src/app/components/auth/forgot/forgot.component.html

@@ -1,38 +0,0 @@
-<div class="session mat-indigo">
-  <div class="session-content">
-    <div class="session-wrapper">
-      <mat-card>
-        <mat-card-content>
-          <form [formGroup]="form" >
-            <div class="text-xs-center pb-1">
-              <!--<img src="assets/images/logo-dark.svg" alt=""/>-->
-              <!--یه توضیحی در مورد روند کار اینجا بنویس -->
-              <p class="mat-text-muted">لطفا ایمیل یا موبایل خود را وارد کنید </p>
-            </div>
-            <div  fxLayout="column"  fxLayoutAlign="space-around">
-              <div class="pb-1">
-                <mat-form-field style="width: 100%">
-                  <input matInput placeholder="لطفا username خود را وارد کنید"  type="email"  formControlName="usernameCtrl">
-                </mat-form-field>
-                <div [hidden]="usernameCtrl.valid || usernameCtrl.untouched">
-                  <div [hidden]="usernameCtrl.valid">
-                    {{usernameCtrl.getError("error")? usernameCtrl.getError("error") : 'لطفا شماره همراه خود را وارد کنید '}}
-                  </div>
-                </div>
-              </div>
-              <button mat-raised-button color="primary"  (click)="onSubmit()" [disabled]="!form.valid">ارسال</button>
-            </div>
-            <div class="pt-1 pb-1 text-xs-center">
-              <a [routerLink]="['/auth/signin']">بازگشت به صفحه ی لاگین </a>
-              <a [routerLink]="['/auth/signup']">ثبت نام</a>
-            </div>
-            <div class="my-container">
-              <ngx-loading [show]="loading" [config]="{ backdropBorderRadius: '14px' }"></ngx-loading>
-            </div>
-          </form>
-        </mat-card-content>
-      </mat-card>
-    </div>
-  </div>
-</div>
-

+ 0 - 46
src/app/components/auth/forgot/forgot.component.ts

@@ -1,46 +0,0 @@
-import {Component, OnInit} from '@angular/core';
-import {Router} from '@angular/router';
-import {FormBuilder, FormGroup, Validators, FormControl} from '@angular/forms';
-import {Dialog} from '../../../classes/dialog';
-import {AuthService} from '../../../classes/auth.service';
-import {SelectedComponent} from '../selected/selected.component';
-import {repairErrors, setErrors} from '../../../classes/utils';
-
-@Component({
-    selector: 'app-forgot',
-    templateUrl: './forgot.component.html',
-    styleUrls: ['./forgot.component.scss']
-})
-export class ForgotComponent implements OnInit {
-    public form: FormGroup;
-  usernameCtrl = new FormControl('', [Validators.required]);
-  public loading = false;
-    constructor(private fb: FormBuilder,
-                private router: Router,
-                private dialog: Dialog,
-                private auth: AuthService,
-    ) {
-      this.loading = false ;
-    }
-
-    ngOnInit() {
-        this.form = this.fb.group({
-          usernameCtrl: this.usernameCtrl,
-        });
-    }
-
-    onSubmit() {
-      this.loading = true ;
-        this.auth.forgotPass1(this.form.controls['usernameCtrl'].value , '1').subscribe(
-            res =>{
-              // this.loading = false ;
-              this.dialog.openWithData(SelectedComponent , this.form.controls['usernameCtrl'].value);
-            } ,
-            error =>{
-              this.loading = false ;
-              let errors = error.json().errors;
-                setErrors(repairErrors(errors), this.form.controls, this.dialog);
-            }
-        );
-    }
-}

+ 0 - 33
src/app/components/auth/newpassword/new-password.component.html

@@ -1,33 +0,0 @@
-<!--inja  ye use name bezzar ke set bashe khoshgel beshe-->
-<div class="session mat-indigo" dir="rtl">
-  <div class="session-content">
-    <div class="session-wrapper">
-      <mat-card>
-        <mat-card-content>
-          <form [formGroup]="form" (ngSubmit)="onSubmit()">
-            <div  fxLayout="column"  fxLayoutAlign="space-around">
-              <!--میخوام این ست بشه -->
-              <div class="pb-1">
-                <mat-form-field style="width: 100%">
-                  <input matInput placeholder="لطفا رمز جدید خود را وارد کنید " type="password"  formControlName="passwordCtrl">
-                </mat-form-field>
-              </div>
-              <div class="pb-1">
-                <mat-form-field style="width: 100%">
-                  <input matInput placeholder="رمز خود را دوباره وارد کنید " type="password" formControlName="confirmPassCtrl">
-                </mat-form-field>
-                <div [hidden]="confirmPassCtrl.valid || confirmPassCtrl.untouched">
-                  <div [hidden]="confirmPassCtrl.valid">
-                    {{confirmPassCtrl.getError("error")? confirmPassCtrl.getError("error") : 'لطفا کد خود را وارد کنید '}}
-                  </div>
-                </div>
-              </div>
-              <button mat-raised-button color="primary" type="submit" [disabled]="!form.valid">ارسال</button>
-            </div>
-          </form>
-        </mat-card-content>
-      </mat-card>
-    </div>
-  </div>
-</div>
-

+ 0 - 0
src/app/components/auth/newpassword/new-password.component.scss


+ 0 - 54
src/app/components/auth/newpassword/new-password.component.ts

@@ -1,54 +0,0 @@
-import {Component, OnInit} from '@angular/core';
-import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
-import {Router} from '@angular/router';
-import {GlobalService} from '../../../classes/global.service';
-import {AuthService} from '../../../classes/auth.service';
-import {Dialog} from '../../../classes/dialog';
-
-@Component({
-    selector: 'app-new-password',
-    templateUrl: './new-password.component.html',
-    styleUrls: ['./new-password.component.scss']
-})
-export class NewPasswordComponent implements OnInit {
-    public loading = false;
-    passwordCtrl = new FormControl('', [Validators.required]);
-    confirmPassCtrl = new FormControl('', [Validators.required]);
-    public form: FormGroup;
-
-    constructor(private fb: FormBuilder,
-                private router: Router,
-                private global: GlobalService,
-                private auth: AuthService,
-                private dialog: Dialog,
-    ) {
-    }
-
-    ngOnInit() {
-        this.form = this.fb.group({
-            passwordCtrl: this.passwordCtrl,
-            confirmPassCtrl: this.confirmPassCtrl,
-        });
-    }
-
-    onSubmit() {
-        this.loading = true;
-        if (this.form.controls['passwordCtrl'].value == this.form.controls['confirmPassCtrl'].value) {
-                this.auth.forgotPass4( this.global.emailData , this.global.smstoken , this.form.controls['passwordCtrl'].value  , '1')
-                    .subscribe(
-                        loggedIn => {
-                            console.log('login' , loggedIn)
-                            if (loggedIn) {
-                                this.loading = false;
-                                this.router.navigateByUrl('');
-                            }
-
-                        }, (error) => {
-                            this.loading = false;
-                            this.dialog.openForAlert('رمز عبور جدید را مجددا صحیح وارد نمایید.');
-                        });
-            }
-        }
-
-}
-

+ 0 - 0
src/app/auth/not-found/not-found.component.html → src/app/components/auth/not-found/not-found.component.html


+ 0 - 0
src/app/auth/not-found/not-found.component.scss → src/app/components/auth/not-found/not-found.component.scss


+ 0 - 0
src/app/auth/not-found/not-found.component.ts → src/app/components/auth/not-found/not-found.component.ts


+ 13 - 11
src/app/components/auth/signin/signin.component.html → src/app/components/auth/passwordSignin/passwordSignin.component.html

@@ -9,11 +9,12 @@
             <div fxLayout="column" fxLayoutAlign="space-around">
             <div fxLayout="column" fxLayoutAlign="space-around">
               <div class="pb-1">
               <div class="pb-1">
                 <mat-form-field style="width: 100%">
                 <mat-form-field style="width: 100%">
-                  <input matInput placeholder="ایمیل " formControlName="usernameCtrl">
+                  <input matInput placeholder="لطفا شماره همراه خود را وارد کنید " formControlName="mobileCtrl">
                 </mat-form-field>
                 </mat-form-field>
-                <div [hidden]="usernameCtrl.valid || usernameCtrl.untouched">
-                  <div [hidden]="usernameCtrl.valid">
-                    {{usernameCtrl.getError("error")? usernameCtrl.getError("error") : 'لطفاایمیل خود را وارد کنید  '}}
+                <div [hidden]="mobileCtrl.valid || mobileCtrl.untouched">
+                  <div [hidden]="mobileCtrl.valid">
+                    {{mobileCtrl.getError("error") ? mobileCtrl.getError("error") :
+                    ' لطفا شماره همراه خود را وارد کنید'}}
                   </div>
                   </div>
                 </div>
                 </div>
               </div>
               </div>
@@ -23,22 +24,23 @@
                 </mat-form-field>
                 </mat-form-field>
                 <div [hidden]="passwordCtrl.valid || passwordCtrl.untouched">
                 <div [hidden]="passwordCtrl.valid || passwordCtrl.untouched">
                   <div [hidden]="passwordCtrl.valid">
                   <div [hidden]="passwordCtrl.valid">
-                    {{passwordCtrl.getError("error")? passwordCtrl.getError("error") : 'لطفا رمز عبور خود را وارد کنید '}}
+                    {{passwordCtrl.getError("error") ? passwordCtrl.getError("error") : 'لطفا رمز عبور خود را وارد کنید '}}
                   </div>
                   </div>
-                 </div>
+                </div>
               </div>
               </div>
+
               <div class="pb-1">
               <div class="pb-1">
-                <mat-checkbox [(ngModel)]="remember" [ngModelOptions]="{standalone: true}">مرا بخاطر بسپار </mat-checkbox>
+                <mat-checkbox [(ngModel)]="remember" [ngModelOptions]="{standalone: true}">مرا بخاطر بسپار
+                </mat-checkbox>
               </div>
               </div>
-              <button mat-raised-button color="primary" type="submit" [disabled]="!form.valid">ورود </button>
+              <button mat-raised-button color="primary" type="submit">ورود</button>
             </div>
             </div>
             <div class="pt-1 pb-1 text-xs-center">
             <div class="pt-1 pb-1 text-xs-center">
-              <a [routerLink]="['/auth/forgot']">آیا رمز عبور خود را فراموش کرده اید؟</a>&nbsp;&nbsp;&nbsp;&nbsp;
-              <a [routerLink]="['/auth/signup']">آیا ثبت نام نکرده اید؟</a>
+              <a [routerLink]="['/auth/smstokenSignin']">ورود با پیام کوتاه</a>
             </div>
             </div>
             <div class="my-container">
             <div class="my-container">
               <ngx-loading [show]="loading" [config]="{ backdropBorderRadius: '14px' }"></ngx-loading>
               <ngx-loading [show]="loading" [config]="{ backdropBorderRadius: '14px' }"></ngx-loading>
-          </div>
+            </div>
           </form>
           </form>
         </mat-card-content>
         </mat-card-content>
       </mat-card>
       </mat-card>

+ 0 - 0
src/app/auth/lockscreen/lockscreen.component.scss → src/app/components/auth/passwordSignin/passwordSignin.component.scss


+ 63 - 0
src/app/components/auth/passwordSignin/passwordSignin.component.ts

@@ -0,0 +1,63 @@
+import {Component, OnInit, ViewChild} from '@angular/core';
+import {Router} from '@angular/router';
+import {FormBuilder, FormGroup, Validators, FormControl} from '@angular/forms';
+import {HttpClient} from '@angular/common/http';
+import {AuthService} from '../../../classes/servicess/auth.service';
+import {Dialog} from '../../../classes/base_components/dialog/dialog';
+import {repairErrors, setErrors} from '../../../classes/utils';
+
+@Component({
+  selector: 'app-signin',
+  templateUrl: './passwordSignin.component.html',
+  styleUrls: ['./passwordSignin.component.scss']
+})
+export class PasswordSigninComponent implements OnInit {
+  public loading = false;
+  passwordCtrl = new FormControl('', [Validators.required]);
+  type;
+  mobileCtrl = new FormControl('', [Validators.required, Validators.minLength(4)]);
+  public form: FormGroup;
+  remember: boolean = false;
+
+  /**
+   * @param {FormBuilder} fb marbot be form
+   * @param {Router} router baray navigate kardan hast
+   * @param {HttpClient} http baray darkhast hay http estefade mishe
+   * @param {AuthService} auth baray moshakhas kardan inke login hast ya na
+   */
+  constructor(
+    private fb: FormBuilder,
+    private router: Router,
+    private http: HttpClient,
+    private auth: AuthService,
+    private dialog: Dialog,
+  ) {
+  }
+
+  ngOnInit() {
+    this.form = this.fb.group({
+      passwordCtrl: this.passwordCtrl,
+      mobileCtrl: this.mobileCtrl,
+    });
+  }
+
+  onSubmit() {
+    this.loading = true;
+    this.auth.loginWithPassword(this.form.controls['mobileCtrl'].value, this.form.controls['passwordCtrl'].value
+      , this.remember, '1', '1', '1')
+      .subscribe(
+        loggedIn => {
+          if (loggedIn) {
+            this.loading = false;
+            this.router.navigateByUrl('/');
+          }
+        },
+        error => {
+          this.loading = false;
+          let errors = error.json().errors;
+          setErrors(repairErrors(errors), this.form.controls, this.dialog);
+        });
+  }
+}
+
+

+ 0 - 12
src/app/components/auth/selected/selected.component.html

@@ -1,12 +0,0 @@
-<form dir="rtl" [formGroup]="form" style="width: 100%;" (ngSubmit)="onSubmit()">
-<h3 >کد کجا فرستاده بشه</h3>
-  <mat-radio-group  formControlName="completeCtrl" >
-    <mat-radio-button  value="email">email</mat-radio-button>
-    <mat-radio-button value="mobile">mobile</mat-radio-button>
-  </mat-radio-group>
-  <br>
-  <button mat-raised-button color="primary" type="submit" [disabled] = "!completeCtrl.value">ارسال</button>
-  <div class="my-container">
-    <ngx-loading [show]="loading" [config]="{ backdropBorderRadius: '14px' }"></ngx-loading>
-  </div>
-</form>

+ 0 - 0
src/app/components/auth/selected/selected.component.scss


+ 0 - 53
src/app/components/auth/selected/selected.component.ts

@@ -1,53 +0,0 @@
-import {Component, Inject, OnInit, Optional} from '@angular/core';
-import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
-import {MAT_DIALOG_DATA} from '@angular/material';
-import {ActivatedRoute, Router} from '@angular/router';
-import {AuthService} from '../../../classes/auth.service';
-import {Dialog} from '../../../classes/dialog';
-import {GlobalService} from '../../../classes/global.service';
-
-@Component({
-  selector: 'app-select-button',
-  templateUrl: './selected.component.html',
-  styleUrls: ['./selected.component.scss']
-})
-export class SelectedComponent implements OnInit {
-  loading : boolean ;
-  completeCtrl = new FormControl();
-  public form: FormGroup;
-
-  constructor(private fb: FormBuilder,
-              @Inject(MAT_DIALOG_DATA) public data,
-              private auth: AuthService,
-              private router: Router,
-              private dialog: Dialog,
-              private global: GlobalService,
-  ) {
-    this.loading = false ;
-
-    this.global.emailData = data;
-      console.log(this.global.emailData , 'data')
-}
-
-  ngOnInit() {
-    this.form = this.fb.group({
-      completeCtrl: this.completeCtrl,
-    });
-  }
-
-  onSubmit() {
-    this.loading = true ;
-    console.log('data is  ' , this.data);
-    this.auth.forgotPass2(  this.data , this.form.controls['completeCtrl'].value , '2').subscribe(
-      (next) => {
-        this.loading = false ;
-        this.router.navigate(['/auth/submit']);
-        this.dialog.closeAll();
-      },
-      (error) => {
-        this.loading = false ;
-        console.log('error', error);
-      }
-    );
-  }
-}

+ 0 - 0
src/app/components/auth/signin/signin.component.scss


+ 0 - 74
src/app/components/auth/signin/signin.component.ts

@@ -1,74 +0,0 @@
-import {Component, OnInit} from '@angular/core';
-import {Router} from '@angular/router';
-import {FormBuilder, FormGroup, Validators, FormControl} from '@angular/forms';
-import {HttpClient} from '@angular/common/http';
-import {AuthService} from '../../../classes/auth.service';
-import {TypesService} from '../../basic/types/types.service';
-import {Dialog} from '../../../classes/dialog';
-import {repairErrors, setErrors} from '../../../classes/utils';
-
-@Component({
-    selector: 'app-signin',
-    templateUrl: './signin.component.html',
-    styleUrls: ['./signin.component.scss']
-})
-export class SigninComponent implements OnInit {
-    public loading = false;
-    usernameCtrl = new FormControl('', [Validators.required]);
-    type;
-    passwordCtrl = new FormControl('', [Validators.required, Validators.minLength(5)]);
-    public form: FormGroup;
-    remember: boolean = false;
-
-    /**
-     * @param {FormBuilder} fb marbot be form
-     * @param {Router} router baray navigate kardan hast
-     * @param {HttpClient} http baray darkhast hay http estefade mishe
-     * @param {AuthService} auth baray moshakhas kardan inke login hast ya na
-     * @param {TypesService} typeservice baray ferestadan type be server baray login
-     * @param {AppsService} appservice  baray  ferestadan version va ... baray login
-     */
-    constructor(
-        private fb: FormBuilder,
-        private router: Router,
-        private http: HttpClient,
-        private auth: AuthService,
-        private typeservice: TypesService,
-        private dialog: Dialog,
-        private authService: AuthService,
-    ) {
-        this.type = this.typeservice.new();
-        this.type.id = '3';
-    }
-
-    ngOnInit() {
-        this.form = this.fb.group({
-            usernameCtrl: this.usernameCtrl,
-            passwordCtrl: this.passwordCtrl,
-        });
-
-    }
-
-    onSubmit() {
-        this.loading = true;
-        this.auth.login(this.form.controls['usernameCtrl'].value,
-            this.form.controls['passwordCtrl'].value
-            , '3', this.auth.firebase, this.remember)
-            .subscribe(
-                loggedIn => {
-                    if (loggedIn) {
-                        console.log('salam');
-                        this.loading = false;
-                        this.router.navigateByUrl('');
-                    }
-                },
-                error => {
-                    console.log('errors', error);
-                    this.loading = false;
-                    let errors = error.json().errors;
-                    setErrors(repairErrors(errors), this.form.controls, this.dialog);
-                });
-    }
-}
-
-

+ 64 - 0
src/app/components/auth/smstokenSignin/smstokenSignin.component.html

@@ -0,0 +1,64 @@
+<div class="session mat-indigo">
+  <div class="session-content">
+    <div class="session-wrapper">
+      <mat-card>
+        <mat-card-content>
+          <form [formGroup]="form">
+            <div class="text-xs-center pb-1">
+            </div>
+            <div fxLayout="column" fxLayoutAlign="space-around">
+              <div class="pb-1">
+                <mat-form-field style="width: 100%">
+                  <input matInput placeholder="لطفا شماره همراه خود را وارد کنید " formControlName="mobileCtrl">
+                </mat-form-field>
+                <div [hidden]="mobileCtrl.valid || mobileCtrl.untouched">
+                  <div [hidden]="mobileCtrl.valid">
+                    {{mobileCtrl.getError("error") ? mobileCtrl.getError("error") :
+                    ' لطفا شماره همراه خود را وارد کنید'}}
+                  </div>
+                </div>
+              </div>
+              <div class="pb-1" *ngIf="showSms">
+                <mat-form-field style="width: 100%">
+                  <input matInput type="password" placeholder=" کدارسالی" formControlName="passwordCtrl">
+                </mat-form-field>
+                <div [hidden]="passwordCtrl.valid || passwordCtrl.untouched">
+                  <div [hidden]="passwordCtrl.valid">
+                    {{passwordCtrl.getError("error") ? passwordCtrl.getError("error")
+                    : 'لطفا کد ارسال شده را وارد کنید '}}
+                  </div>
+                </div>
+                <div class="pb-1">
+                  <mat-checkbox [(ngModel)]="remember" [ngModelOptions]="{standalone: true}">مرا بخاطر بسپار
+                  </mat-checkbox>
+                </div>
+              </div>
+              <button *ngIf="showSms === false" mat-raised-button color="primary" type="submit"
+                      (click)="mobileExists()">ارسال
+              </button>
+              <button *ngIf="showSms === true" mat-raised-button color="primary" type="submit"
+                      (click)="onSubmit()">ارسال
+              </button>
+            </div>
+            <div class="pt-1 pb-1 text-xs-center">
+              <a [routerLink]="['/auth/passwordSignin']">ورود با رمز عبور </a><br>
+              <div *ngIf="showTime">
+                <div *ngIf="timer ; then timeleft  ; else receiveCode"></div>
+                <ng-template #receiveCode>
+                  <a (click)="receiveData()">دریافت مجدد کد </a>
+                </ng-template>
+                <ng-template #timeleft>
+                  <p>لطفا بعد از گذشت {{timeLeft}}ثانیه دوباره تلاش کنید </p>
+                </ng-template>
+              </div>
+
+            </div>
+            <div class="my-container">
+              <!--              <ngx-loading [show]="loading" [config]="{ backdropBorderRadius: '14px' }"></ngx-loading>-->
+            </div>
+          </form>
+        </mat-card-content>
+      </mat-card>
+    </div>
+  </div>
+</div>

+ 0 - 0
src/app/components/auth/forgot/forgot.component.scss → src/app/components/auth/smstokenSignin/smstokenSignin.component.scss


+ 97 - 0
src/app/components/auth/smstokenSignin/smstokenSignin.component.ts

@@ -0,0 +1,97 @@
+import {Component, OnInit} from '@angular/core';
+import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
+import {Router} from '@angular/router';
+import {HttpClient} from '@angular/common/http';
+import {AuthService} from '../../../classes/servicess/auth.service';
+import {Dialog} from '../../../classes/base_components/dialog/dialog';
+
+@Component({
+  selector: 'app-smstoken',
+  templateUrl: './smstokenSignin.component.html',
+  styleUrls: ['./smstokenSignin.component.scss']
+})
+export class SmstokenSigninComponent implements OnInit {
+  showSms: Boolean = false;
+  public form: FormGroup;
+  mobileCtrl = new FormControl('', [Validators.required, Validators.minLength(4)]);
+  passwordCtrl = new FormControl('', [Validators.required, Validators.minLength(4)]);
+  timer: boolean;
+  timeLeft: number = 60;
+  interval;
+  showTime: Boolean = false;
+  remember: boolean = false;
+
+  constructor(
+    private fb: FormBuilder,
+    private router: Router,
+    private http: HttpClient,
+    private auth: AuthService,
+    private dialog: Dialog,
+  ) {
+    this.form = this.fb.group({
+      passwordCtrl: this.passwordCtrl,
+      mobileCtrl: this.mobileCtrl,
+    });
+
+    this.timer = false;
+  }
+
+  ngOnInit() {
+  }
+
+  onSubmit() {
+    // this.loading = true;
+    this.auth.loginWithSmsToken(this.form.controls['mobileCtrl'].value,
+      this.form.controls['passwordCtrl'].value
+      , this.remember, '1', '1', '1')
+      .subscribe(
+        loggedIn => {
+          if (loggedIn) {
+            // this.loading = false;
+            this.router.navigateByUrl('');
+          }
+        },
+        error => {
+          // console.log('errors', error);
+          // this.loading = false;
+          // let errors = error.json().errors;
+          // setErrors(repairErrors(errors), this.form.controls, this.dialog);
+        });
+  }
+
+  mobileExists() {
+    this.getSmsToken();
+  }
+
+  receiveData() {
+    this.timer = true;
+    this.getSmsToken();
+  }
+
+  getSmsToken() {
+    this.auth.mobileExists(this.form.controls['mobileCtrl'].value, '3').subscribe(res => {
+      if (res['_body'] === '1') {
+        this.showSms = true;
+        this.showTime = true;
+        this.timer = true;
+        this.interval = setInterval(() => {
+          if (this.timeLeft > 0) {
+            this.timeLeft--;
+            if (this.timeLeft == 0) {
+              // for test
+              this.timer = false;
+            }
+          } else {
+            this.timeLeft = 60;
+          }
+        }, 1000);
+      } else {
+        this.form.controls['mobileCtrl'].setErrors({'error': 'کاربر مورد نظر یافت نشد '});
+      }
+    }, error => {
+      console.log('error hast', error);
+      this.dialog.openForAlert('دسترسی به سرور ممکن نیست');
+      console.log('error');
+    });
+  }
+}

+ 0 - 43
src/app/components/auth/submit/submit.component.html

@@ -1,43 +0,0 @@
-<!--inja  ye use name bezzar ke set bashe khoshgel beshe-->
-<div class="session mat-indigo" dir="rtl">
-  <div class="session-content">
-    <div class="session-wrapper">
-      <mat-card>
-        <mat-card-content>
-          <form [formGroup]="form" (ngSubmit)="onSubmit()">
-            <div fxLayout="column" fxLayoutAlign="space-around">
-              <!--میخوام این ست بشه -->
-              <div class="pb-1">
-                <mat-form-field style="width: 100%">
-                  <input matInput placeholder="ایمیل" type="text" [(ngModel)]="emailCtrl" formControlName="email">
-                </mat-form-field>
-              </div>
-              <div class="pb-1">
-                <mat-form-field style="width: 100%">
-                  <input matInput placeholder="لطفا کد خود را وارد کنید " type="text" formControlName="smstoken">
-                </mat-form-field>
-                <div [hidden]="smstoken.valid || smstoken.untouched">
-                  <div [hidden]="smstoken.valid">
-                    {{smstoken.getError("error") ? smstoken.getError("error") : 'لطفا کد خود را وارد کنید '}}
-                  </div>
-                </div>
-              </div>
-              <button mat-raised-button color="primary" type="submit" [disabled]="!form.valid">ارسال</button>
-            </div>
-            <div *ngIf="timer ; then timeleft  ; else receiveCode"></div>
-            <ng-template #timeleft>
-              <p>00:{{timeLeft}}</p>
-            </ng-template>
-            <ng-template #receiveCode>
-              <button mat-button color="primary" type="button"  (click)="receiveData()">دریافت
-                مجدد کد
-              </button>
-            </ng-template>
-
-          </form>
-        </mat-card-content>
-      </mat-card>
-    </div>
-  </div>
-</div>
-

+ 0 - 0
src/app/components/auth/submit/submit.component.scss


+ 0 - 86
src/app/components/auth/submit/submit.component.ts

@@ -1,86 +0,0 @@
-import {Component, Inject, OnDestroy, OnInit, Optional} from '@angular/core';
-import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
-
-import {Router} from '@angular/router';
-import {GlobalService} from '../../../classes/global.service';
-import {AuthService} from '../../../classes/auth.service';
-import {Dialog} from '../../../classes/dialog';
-
-@Component({
-  selector: 'app-submit-code',
-  templateUrl: './submit.component.html',
-  styleUrls: ['./submit.component.scss']
-})
-export class SubmitComponent implements OnInit, OnDestroy {
-  smstoken = new FormControl('', [Validators.required]);
-  email = new FormControl('', [Validators.required]);
-  emailCtrl;
-  public form: FormGroup;
-  timeLeft: number = 60;
-  interval;
-  timer: boolean;
-
-  constructor(private fb: FormBuilder,
-              private global: GlobalService,
-              private  auth: AuthService,
-              private  router: Router,
-              private  dialog: Dialog,
-  ) {
-    // for test
-    this.timer = true;
-    this.emailCtrl = this.global.emailData;
-    console.log('emaildata', this.global.emailData);
-    this.interval = setInterval(() => {
-      if (this.timeLeft > 0) {
-        this.timeLeft--;
-        if (this.timeLeft == 0) {
-          // for test
-          this.timer = false;
-        }
-      } else {
-        this.timeLeft = 60;
-      }
-    }, 1000);
-  }
-
-  ngOnInit() {
-    this.form = this.fb.group({
-      smstoken: this.smstoken,
-      email: this.email,
-    });
-  }
-
-  onSubmit() {
-    this.global.smstoken = this.form.controls['smstoken'].value;
-    this.auth.forgotPass3(this.global.emailData, '1', this.form.controls['smstoken'].value).subscribe(x => {
-      const t = JSON.parse(x._body);
-      if (t['allowed'] === true) {
-        this.router.navigate(['/auth/newpassword']);
-      } else this.dialog.openForAlert('کد وارد شده صحیح نمی باشد ');
-    }, error => {
-      console.log('erro ', error);
-    }
-    );
-  }
-
-  forgotPass() {
-    this.auth.forgotPass2(this.global.emailData, '1', '1').subscribe(x => {
-      console.log(x) ,
-        success => {
-          console.log(success);
-        } , error => {
-        this.dialog.openForAlert('کد ارسال نشد')
-        console.log('error', error);
-      };
-    });
-  }
-
-  receiveData() {
-    this.timer = true;
-    this.forgotPass();
-  }
-
-  ngOnDestroy() {
-
-  }
-}

+ 0 - 58
src/app/components/basic/basic.module.ts

@@ -1,58 +0,0 @@
-import {forwardRef, NgModule} from '@angular/core';
-import {RouterModule} from '@angular/router';
-import {CommonModule} from '@angular/common';
-import {MatAutocompleteModule, MatDialogModule, MatIconModule, MatInputModule, MatMenuModule, MatSelectModule} from '@angular/material';
-import {FlexLayoutModule} from '@angular/flex-layout';
-import {DataTablesModule} from 'angular-datatables';
-import {FormsModule, NG_VALUE_ACCESSOR, ReactiveFormsModule} from '@angular/forms';
-import {MatButtonModule} from '@angular/material/button';
-import {MatOptionModule} from '@angular/material';
-import {MatCheckboxModule} from '@angular/material';
-import {MatCardModule} from '@angular/material';
-import {MatFormFieldModule} from '@angular/material/form-field';
-import {NgxSpinnerModule, NgxSpinnerService} from 'ngx-spinner';
-import {LoadingModule} from 'ngx-loading';
-import {NgxDatatableModule} from '@swimlane/ngx-datatable';
-import {TypesComponent} from './types/types.component';
-import {ServicesComponent} from './services/services.component';
-import {ProductsComponent} from './products/products.component';
-import {BasicRoutes} from './basic.routing';
-
-
-@NgModule({
-    imports: [
-        MatMenuModule,
-        MatAutocompleteModule,
-        MatDialogModule,
-        LoadingModule,
-        NgxSpinnerModule,
-        MatInputModule,
-        MatFormFieldModule,
-        MatCardModule,
-        MatButtonModule,
-        MatCheckboxModule,
-        NgxDatatableModule,
-        FormsModule,
-        ReactiveFormsModule,
-        CommonModule,
-        RouterModule.forChild(BasicRoutes),
-        FlexLayoutModule,
-        DataTablesModule,
-        MatInputModule,
-        MatOptionModule,
-        MatSelectModule,
-        MatIconModule
-    ],
-    declarations: [
-        ServicesComponent,
-        ProductsComponent,
-        TypesComponent,
-
-
-    ],
-    providers: [NgxSpinnerService],
-
-})
-
-export class BasicModule {
-}

+ 0 - 19
src/app/components/basic/basic.routing.ts

@@ -1,19 +0,0 @@
-import {Routes} from '@angular/router';
-import {TypesComponent} from './types/types.component';
-import {ServicesComponent} from './services/services.component';
-import {ProductsComponent} from './products/products.component';
-
-
-export const BasicRoutes: Routes = [{
-  path: ''
-},
-  {
-    path: 'basic/products', component: ProductsComponent
-  },
-  {
-    path: 'basic/services', component: ServicesComponent
-  },
-  {
-    path: 'basic/types', component: TypesComponent
-}];
-

+ 0 - 26
src/app/components/basic/products/edit-product/edit-product.component.html

@@ -1,26 +0,0 @@
-<form [formGroup]="form">
-  <mat-form-field style="width: 100%">
-    <input matInput type="text" placeholder="نام " [(ngModel)]="product.name" formControlName="nameCtrl">
-  </mat-form-field>
-  <div [hidden]="nameCtrl.valid || nameCtrl.untouched">
-    <div [hidden]="nameCtrl.valid">
-      {{nameCtrl.getError("error")? nameCtrl.getError("error") : 'لطفا نام خود را وراد کنید '}}
-    </div>
-  </div>
-  <mat-form-field style="width: 100%">
-    <input matInput type="text" placeholder="قیمت " [(ngModel)]="product.price" formControlName="priceCtrl">
-  </mat-form-field>
-  <div [hidden]="priceCtrl.valid || priceCtrl.untouched">
-    <div [hidden]="priceCtrl.valid">
-      {{priceCtrl.getError("error")? priceCtrl.getError("error") : 'لطفا قیمت محصول رو وارد کنید'}}
-    </div>
-  </div>
-  <mat-dialog-actions>
-    <button mat-raised-button color="primary" (click)="onSubmit()">ثبت</button>
-    <button mat-raised-button  (click)="close()">بازگشت</button>
-  </mat-dialog-actions>
-  <div class="my-container">
-    <ngx-loading [show]="loading" [config]="{ backdropBorderRadius: '14px' }"></ngx-loading>
-  </div>
-</form>
-

+ 0 - 0
src/app/components/basic/products/edit-product/edit-product.component.scss


+ 0 - 67
src/app/components/basic/products/edit-product/edit-product.component.ts

@@ -1,67 +0,0 @@
-import {Component, Inject} from '@angular/core';
-import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
-import {EditUsersComponent} from '../../../user/users/edit-users/edit-users.component';
-import {Router} from '@angular/router';
-import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material';
-import {EditComponent} from '../../../../classes/base_components/edit/edit.component';
-import {Product} from '../products.service';
-import {Dialog} from '../../../../classes/dialog';
-import {setErrors} from '../../../../classes/utils';
-
-
-@Component({
-    selector: 'app-edit-product',
-    templateUrl: './edit-product.component.html',
-    styleUrls: ['./edit-product.component.scss']
-})
-export class EditProductComponent extends EditComponent {
-    public loading = false;
-    nameCtrl = new FormControl('', [Validators.required]);
-    priceCtrl = new FormControl('', [Validators.required]);
-    product: Product;
-    form: FormGroup;
-
-    /**
-     *
-     * @param {FormBuilder} fb ye service baray etelaat form
-     * @param {Router} router baray navigate hast bein component hay dege
-     * @param {Dialog} dialog baray diaog hast
-     * @param {MatDialogRef<EditProductComponent>} dialogRef
-     * @param data  etelaat dialog
-     */
-    constructor(private fb: FormBuilder,
-                private router: Router,
-                protected  dialog: Dialog,
-                public  dialogRef: MatDialogRef<EditProductComponent>,
-                @Inject(MAT_DIALOG_DATA) data,
-    ) {
-        super();
-        this.product = data;
-        this.form = this.fb.group({
-            nameCtrl: this.nameCtrl,
-            priceCtrl: this.priceCtrl,
-        });
-    }
-
-    onSubmit() {
-        this.loading = true;
-        if (!this.form.valid) {
-            this.loading = false;
-            return;
-        }
-        this.product.save({},
-            () => {
-                this.loading = false;
-                this.close();
-            },
-            (error) => {
-                this.loading = false;
-                const JsonV = error.errors;
-                setErrors(JsonV , this.form.controls, this.dialog);
-            });
-    }
-
-    close() {
-        this.dialogRef.close(true);
-    }
-}

+ 0 - 78
src/app/components/basic/products/products.component.html

@@ -1,78 +0,0 @@
-<div dir="ltr">
-    <button mat-button color="primary" (click)="edit()">
-        محصول جدید
-        <mat-icon>add</mat-icon>
-    </button>
-    <button mat-button [matMenuTriggerFor]="menu">
-        <mat-icon>more_vert</mat-icon>
-    </button>
-    <mat-menu #menu="matMenu">
-        <button (click)='toggle(column)' *ngFor="let column of allColumns" mat-menu-item>
-            <input
-                    type='checkbox'
-                    [id]="column.prop"
-                    [checked]='isChecked(column)'
-                    [disabled]="(column.prop == 'id')"
-            />
-            {{column.name}}
-        </button>
-    </mat-menu>
-</div>
-
-<ngx-datatable
-        class="material"
-        [rows]="rows"
-        [columns]="columns"
-        [columnMode]="'force'"
-        [headerHeight]="30"
-        [footerHeight]="50"
-        [rowHeight]="30"
-        [limit]="limit"
-        [count]="count"
-        [offset]="offset"
-        [filterRow]="true"
-        [externalSorting]="true"
-        [loadingIndicator]="is_loading"
-        [externalPaging]="true"
-        [appUrl] = "appUrl"
-        (sort)="fetchList($event)"
-        (page)='fetchList($event)'
-        [filters] = "filters"
-        [sortDir]="sortDir"
-        [sortProp]="sortProp"
-        [includes]="includes"
-        [resource] = 'listService.type'
->
-    <ngx-datatable-column  *ngFor="let column of columns" prop="{{column.prop}}"
-                           name="{{column.name}}" [filterTemplate]="column.filter">
-        <ng-template *ngIf="column.prop == 'id'" let-row="row" let-value="value" ngx-datatable-cell-template>
-            <button mat-button color="primary" (click)="remove(value)"><mat-icon svgIcon="delete"></mat-icon></button>
-            <button mat-button color="primary" (click)="edit(value)">
-                <mat-icon>edit</mat-icon>
-            </button>
-        </ng-template>
-    </ngx-datatable-column>
-</ngx-datatable>
-<ng-template #filter_name>
-    <mat-form-field>
-        <input matInput [(ngModel)]="filters['name']" (change)="fetchList('filter')">
-    </mat-form-field>
-</ng-template>
-
-<ng-template #filter_price>
-    <mat-form-field>
-        <input matInput [(ngModel)]="filters['price']" (change)="fetchList('filter')">
-    </mat-form-field>
-</ng-template>
-
-<ng-template #filter_id>
-    <button mat-icon-button (click)="fetchList('refresh')">
-        <mat-icon svgIcon="refresh"></mat-icon>
-    </button>
-</ng-template>
-
-
-
-
-
-

+ 0 - 0
src/app/components/basic/products/products.component.scss


+ 0 - 54
src/app/components/basic/products/products.component.ts

@@ -1,54 +0,0 @@
-import {ListComponent} from '../../../classes/base_components/list/list.component';
-import {Dialog} from '../../../classes/dialog';
-import {Component, OnInit, TemplateRef, ViewChild} from '@angular/core';
-import {ProductsService} from './products.service';
-import {EditProductComponent} from './edit-product/edit-product.component';
-import {Http} from '@angular/http';
-
-
-@Component({
-  selector: 'app-products',
-  templateUrl: './products.component.html',
-  styleUrls: ['./products.component.scss']
-})
-export class ProductsComponent extends ListComponent implements OnInit {
-  @ViewChild('filter_id') public filter_id_ref: TemplateRef<any>;
-  @ViewChild('filter_name') public filter_name_ref: TemplateRef<any>;
-  @ViewChild('filter_price') public filter_price_ref: TemplateRef<any>;
-
-  /**
-   *
-   * @param {ProductsService} listService  inject kardan ptoduct service
-   * @param {Dialog} dialog  for dialog
-   */
-  constructor(
-    protected listService: ProductsService,
-    protected dialog: Dialog,
-    protected http: Http,
-  ) {
-    super(listService, dialog, EditProductComponent, http);
-    this.listService.register();
-  }
-
-  ngOnInit() {
-    this.columns = [
-      {
-        prop: 'price',
-        name: 'قیمت پایه',
-        filter: this.filter_price_ref,
-      }, {
-        prop: 'name',
-        name: 'نام محصول',
-        filter: this.filter_name_ref,
-      },
-      {
-        prop: 'id',
-        name: 'شناسه',
-        filter: this.filter_id_ref,
-      },
-
-    ];
-    super.ngOnInit();
-  }
-
-}

+ 0 - 35
src/app/components/basic/products/products.service.ts

@@ -1,35 +0,0 @@
-import {Injectable} from '@angular/core';
-import {Resource, Service} from 'ngx-jsonapi';
-
-
-@Injectable()
-export class ProductsService extends Service<Product> {
-  public resource = Product;
-  public type = 'products';
-
-}
-
-
-export class Product extends Resource {
-  public attributes: {
-    name: string,
-    price: number,
-  };
-
-  get name() {
-    return this.attributes.name;
-  }
-
-  set name(name: string) {
-    this.attributes.name = name;
-  }
-
-  get price() {
-    return this.attributes.price;
-  }
-
-  set price(price: number) {
-    this.attributes.price = price;
-  }
-
-}

+ 0 - 43
src/app/components/basic/services/edit-services/edit-services.component.html

@@ -1,43 +0,0 @@
-<form [formGroup]="form">
-  <mat-form-field style="width: 100%">
-    <input matInput type="text" placeholder="نام " [(ngModel)]="service.name" formControlName="nameCtrl">
-  </mat-form-field>
-  <div [hidden]="nameCtrl.valid || nameCtrl.untouched">
-    <div [hidden]="nameCtrl.valid">
-      {{nameCtrl.getError("error") ? nameCtrl.getError("error") : 'لطفا نام خود را وراد کنید '}}
-    </div>
-  </div>
-  <mat-form-field style="width: 100%">
-    <input matInput type="text" placeholder="قیمت " [(ngModel)]="service.price" formControlName="priceCtrl">
-  </mat-form-field>
-  <div [hidden]="priceCtrl.valid || priceCtrl.untouched">
-    <div [hidden]="priceCtrl.valid">
-      {{priceCtrl.getError("error") ? priceCtrl.getError("error") : 'لطفا قیمت محصول رو وارد کنید'}}
-    </div>
-  </div>
-  <mat-form-field style="width: 100%" floatLabel="never" dir="rtl">
-    <mat-select [(ngModel)]="service.typesIds" formControlName="typesCtrl" multiple placeholder="انتخاب نقش ها">
-      <mat-option *ngFor="let type of types" [value]="type.id">
-        {{ type.name }}
-      </mat-option>
-    </mat-select>
-  </mat-form-field>
-  <div [hidden]="typesCtrl.valid || typesCtrl.untouched">
-    <div [hidden]="typesCtrl.valid">
-      {{typesCtrl.getError("error") ? typesCtrl.getError("error") : 'انتخاب حداقل یک نوع ضروری می باشد '}}
-    </div>
-  </div>
-
-  <mat-form-field style="width: 100%" floatLabel="never" dir="rtl">
-    <mat-select placeholder="محصولات" [formControl]="productCtrl" multiple >
-      <mat-option *ngFor="let product of service.products.$toArray" [value]="product.id">{{product.attributes.name}}</mat-option>
-    </mat-select>
-  </mat-form-field>
-
-  <mat-dialog-actions>
-    <button mat-raised-button color="primary" (click)="onSubmit()">ثبت</button>
-    <button mat-raised-button (click)="close()">بازگشت</button>
-  </mat-dialog-actions>
-
-</form>
-

+ 0 - 0
src/app/components/basic/services/edit-services/edit-services.component.scss


+ 0 - 78
src/app/components/basic/services/edit-services/edit-services.component.ts

@@ -1,78 +0,0 @@
-import {Component, Inject} from '@angular/core';
-import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
-import {Router} from '@angular/router';
-import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material';
-import {EditComponent} from '../../../../classes/base_components/edit/edit.component';
-
-import {Dialog} from '../../../../classes/dialog';
-import {Service, ServicesService} from '../services.service';
-import {TypesService} from '../../types/types.service';
-import {setErrors} from '../../../../classes/utils';
-
-
-@Component({
-  selector: 'app-edit-product',
-  templateUrl: './edit-services.component.html',
-  styleUrls: ['./edit-services.component.scss']
-})
-export class EditServicesComponent extends EditComponent {
-  public loading = false;
-  types;
-  nameCtrl = new FormControl('', [Validators.required]);
-  priceCtrl = new FormControl('', [Validators.required]);
-  typesCtrl = new FormControl('', [Validators.required]);
-  productCtrl = new FormControl('', [Validators.required]);
-  service: Service;
-  form: FormGroup;
-
-
-  /**
-   *
-   * @param {FormBuilder} fb ye service baray etelaat form
-   * @param {Router} router baray navigate hast bein component hay dege
-   * @param {Dialog} dialog baray diaog hast
-   * @param {MatDialogRef<EditProductComponent>} dialogRef
-   * @param data  etelaat dialog
-   */
-  constructor(
-    private typeservice: TypesService,
-    private  serviceservices: ServicesService,
-    private fb: FormBuilder,
-    private router: Router,
-    protected  dialog: Dialog,
-    public  dialogRef: MatDialogRef<EditServicesComponent>,
-    @Inject(MAT_DIALOG_DATA) data,
-  ) {
-    super();
-    const basics = JSON.parse(localStorage.getItem('basics'));
-    this.types = basics['types'];
-    this.service = data;
-    this.form = this.fb.group({
-      nameCtrl: this.nameCtrl,
-      priceCtrl: this.priceCtrl,
-      typesCtrl: this.typesCtrl,
-      productCtrl: this.productCtrl,
-    });
-  }
-
-  onSubmit() {
-    this.loading = true;
-    if (!this.form.valid)
-      return;
-    this.service.save({},
-      () => {
-        this.loading = false;
-        this.close();
-      },
-      (error) => {
-        this.loading = false;
-        const JsonV = error.errors;
-        setErrors(JsonV, this.form.controls, this.dialog);
-      });
-  }
-
-  close() {
-    this.dialogRef.close(true);
-  }
-}
-

+ 0 - 86
src/app/components/basic/services/services.component.html

@@ -1,86 +0,0 @@
-<div dir="ltr">
-  <button mat-button color="primary" (click)="edit()">سرویس جدید
-    <mat-icon>add</mat-icon>
-  </button>
-  <button mat-button [matMenuTriggerFor]="menu">
-    <mat-icon>more_vert</mat-icon>
-  </button>
-  <mat-menu #menu="matMenu">
-    <button (click)='toggle(column)' *ngFor="let column of allColumns" mat-menu-item>
-      <input
-        type='checkbox'
-        [id]="column.prop"
-        [checked]='isChecked(column)'
-        [disabled]="(column.prop == 'id')"
-      />
-      {{column.name}}
-    </button>
-  </mat-menu>
-</div>
-<ngx-datatable
-  class="material"
-  [rows]="rows"
-  [columns]="columns"
-  [columnMode]="'force'"
-  [headerHeight]="30"
-  [footerHeight]="50"
-  [rowHeight]="30"
-  [limit]="limit"
-  [count]="count"
-  [offset]="offset"
-  [filterRow]="true"
-  [externalSorting]="true"
-  [loadingIndicator]="is_loading"
-  [externalPaging]="true"
-  (sort)="fetchList($event)"
-  (page)='fetchList($event)'
-  [appUrl]="appUrl"
-  [filters] = "filters"
-  [sortDir]="sortDir"
-  [sortProp]="sortProp"
-  [includes]="includes"
-  [resource] = 'listService.type'
->
-  <ngx-datatable-column *ngFor="let column of columns" prop="{{column.prop}}" name="{{column.name}}"
-                        [filterTemplate]="column.filter">
-    <ng-template *ngIf="column.prop == 'id'" let-row="row" let-value="value" ngx-datatable-cell-template>
-      <button mat-button color="primary" (click)="remove(value)">
-        <mat-icon svgIcon="delete"></mat-icon>
-      </button>
-      <button mat-button color="primary" (click)="edit(value)">
-        <mat-icon>edit</mat-icon>
-      </button>
-    </ng-template>
-  </ngx-datatable-column>
-
-</ngx-datatable>
-
-<ng-template #filter_name>
-  <mat-form-field>
-    <input matInput [(ngModel)]="filters['name']" (change)="fetchList('filter')">
-  </mat-form-field>
-</ng-template>
-
-
-<ng-template #filter_price>
-  <mat-form-field>
-    <input matInput [(ngModel)]="filters['price']" (change)="fetchList('filter')">
-  </mat-form-field>
-</ng-template>
-
-<ng-template #filter_id>
-  <button mat-icon-button (click)="fetchList('refresh')">
-    <mat-icon svgIcon="refresh"></mat-icon>
-  </button>
-</ng-template>
-
-
-<ng-template #filter_types>
-  <mat-form-field style="width: 100%" floatLabel="never">
-    <mat-select multiple placeholder="نوع" [(ngModel)]="filters['types']" (change)="fetchList('filter')">
-      <mat-option *ngFor="let type of types" [value]="type.id">
-        {{ type.name }}
-      </mat-option>
-    </mat-select>
-  </mat-form-field>
-</ng-template>

+ 0 - 0
src/app/components/basic/services/services.component.scss


+ 0 - 127
src/app/components/basic/services/services.component.ts

@@ -1,127 +0,0 @@
-import {ListComponent} from '../../../classes/base_components/list/list.component';
-import {Dialog} from '../../../classes/dialog';
-import {ServicesService} from './services.service';
-import {Component, OnInit, TemplateRef, ViewChild} from '@angular/core';
-import {EditServicesComponent} from './edit-services/edit-services.component';
-import {FormControl} from '@angular/forms';
-import {TypesService} from '../types/types.service';
-import 'rxjs/add/operator/debounceTime';
-import {Http} from '@angular/http';
-import {ProductsService} from '../products/products.service';
-import {IParamsResource} from 'ngx-jsonapi';
-
-@Component({
-  selector: 'app-services',
-  templateUrl: './services.component.html',
-  styleUrls: ['./services.component.scss']
-})
-export class ServicesComponent extends ListComponent implements OnInit {
-  @ViewChild('filter_id') public filter_id_ref: TemplateRef<any>;
-  @ViewChild('filter_name') public filter_name_ref: TemplateRef<any>;
-  @ViewChild('filter_price') public filter_price_ref: TemplateRef<any>;
-  @ViewChild('filter_types') public filter_types_ref: TemplateRef<any>;
-  typesControl = new FormControl();
-  types;
-
-  includes: ['products'];
-
-//  har doe in parametr ha baray ers bary az listcomponent hast
-  constructor(
-    protected listService: ServicesService,
-    protected productService: ProductsService,
-    protected typeService: TypesService,
-    protected dialog: Dialog,
-    protected http: Http,
-  ) {
-    super(listService, dialog, EditServicesComponent, http);
-    this.typeService.register();
-    this.productService.register();
-    this.listService.all().subscribe(x => {
-    });
-    const basics = JSON.parse(localStorage.getItem('basics'));
-    this.types = basics['types'];
-    this.typesControl.valueChanges
-      .debounceTime(400)
-      .subscribe(word => {
-        this._filter(this.typeService, word, 'types');
-      });
-  }
-
-  ngOnInit() {
-    this.columns = [
-
-      {
-        prop: 'name',
-        name: 'خدمات',
-        filter: this.filter_name_ref,
-      },
-      {
-        prop: 'price',
-        name: 'قیمت پایه',
-        filter: this.filter_price_ref,
-      },
-      {
-        prop: 'types',
-        name: 'نوع سرویس',
-        isRelationship: true,
-        mustIncluded: true,
-        filter: this.filter_types_ref,
-      },
-      {
-        prop: 'id',
-        name: 'شناسه',
-        filter: this.filter_id_ref,
-      },
-
-    ];
-    super.ngOnInit();
-  }
-
-  //
-  // replaceTypes(types: string) {
-  //     console.log(types, 'salam');
-  //     const serviceTypes = JSON.parse(localStorage.getItem('basics'))['types'];
-  //     const result = serviceTypes.find(obj => {
-  //         return obj.id === types;
-  //     });
-  //     return result.name;
-  // }
-  // edit(id?, params?: IParamsResource | null) {
-  //   super.edit(id, params);
-  //   if (!id) {
-  //     const resource = this.listService.new();
-  //     let requiredPermission = this.listService.type + '.create';
-  //     const dialogRef = this.dialog.openWithData(EditServicesComponent, resource);
-  //     dialogRef.afterClosed().subscribe(
-  //       (ok) => {
-  //         this.fetchList(null);
-  //       }
-  //     );
-  //     this.dialog.openForAlert('access denied');
-  //   }
-  //
-  //   let requiredPermission = this.listService.type + '.update';
-  //   this.listService.get(id, params)
-  //     .subscribe(
-  //       resource => {
-  //         if (resource.is_loading) {
-  //           return;
-  //         }
-  //         console.log('id', id, params);
-  //         const dialogRef = this.dialog.openWithData(this.editComponent, resource);
-  //         dialogRef.afterClosed().subscribe(
-  //           (ok) => {
-  //             this.fetchList(null);
-  //           }
-  //         );
-  //       }
-  //     );
-  // }
-
-
-  edit(id: string) {
-    const params: IParamsResource = {include: ['products']};
-    super.edit(id, params);
-  }
-}
-

+ 0 - 103
src/app/components/basic/services/services.service.ts

@@ -1,103 +0,0 @@
-import {Injectable} from '@angular/core';
-import {ICollection, ISchema, Resource} from 'ngx-jsonapi';
-import {Service as Srv} from 'ngx-jsonapi';
-import {Base} from 'ngx-jsonapi/services/base';
-import {Type, TypesService} from '../types/types.service';
-import {Product, ProductsService} from '../products/products.service';
-
-
-@Injectable()
-export class ServicesService extends Srv<Service> {
-  public resource = Service;
-  public type = 'services';
-  public schema: ISchema = {
-    relationships: {
-      types: {
-        hasMany: true
-      },
-      products: {
-        hasMany: true
-      }
-    }
-  };
-}
-
-export class Service extends Resource {
-  public attributes: {
-    name: string,
-    price: number,
-  };
-
-  get name(): string {
-    return this.attributes.name;
-  }
-
-  set name(name: string) {
-    this.attributes.name = name;
-  }
-
-  get price(): number {
-    return this.attributes.price;
-  }
-
-  set price(price: number) {
-    this.attributes.price = price;
-  }
-
-  //  in baray relationship type hast ke  chand be chande
-  get types(): ICollection<Type> {
-    return <ICollection<Type>>this.relationships.types.data;
-  }
-
-  set types(types: ICollection<Type>) {
-    this.relationships.types.data = types;
-  }
-
-  get typesIds(): string[] {
-    let ids: string[] = [];
-    Base.forEach(this.types, (type: Type) => {
-      ids.push(type.id);
-    });
-    return ids;
-  }
-
-  set typesIds(ids: string[]) {
-    let selected_types: ICollection<Type> = Base.newCollection<Type>();
-    ids.forEach(function (id) {
-      let type = (new TypesService()).new();
-      type.id = id;
-      selected_types[id] = type;
-    });
-    this.types = selected_types;
-  }
-
-
-//  in baray relation product hast ke chand be chand hast
-  get products(): ICollection<Product> {
-    console.log('zahra',this.relationships.products.data) ;
-
-    return <ICollection<Product>>this.relationships.products.data;
-  }
-
-  set products(Product: ICollection<Product>) {
-    this.relationships.products.data = Product;
-  }
-
-  get productsIds(): string[] {
-    let ids: string[] = [];
-    Base.forEach(this.products, (products: Product) => {
-      ids.push(products.id);
-    });
-    return ids;
-  }
-
-  set productsIds(ids: string[]) {
-    let selected_products: ICollection<Product> = Base.newCollection<Product>();
-    ids.forEach(function (id) {
-      let product = (new ProductsService()).new();
-      product.id = id;
-      selected_products[id] = product;
-    });
-    this.products = selected_products;
-  }
-}

+ 0 - 18
src/app/components/basic/types/edit-types/edit-types.component.html

@@ -1,18 +0,0 @@
-<form [formGroup]="form">
-  <mat-form-field style="width: 100%">
-    <input matInput type="text" placeholder="نام " [(ngModel)]="type.name" formControlName="nameCtrl">
-  </mat-form-field>
-  <div [hidden]="nameCtrl.valid || nameCtrl.untouched">
-    <div [hidden]="nameCtrl.valid">
-      {{nameCtrl.getError("error")? nameCtrl.getError("error") : 'لطفا نام خود را وراد کنید '}}
-    </div>
-  </div>
-  <mat-dialog-actions>
-    <button mat-raised-button color="primary" (click)="onSubmit()">ثبت</button>
-    <button mat-raised-button  (click)="close()">بازگشت</button>
-  </mat-dialog-actions>
-  <div class="my-container">
-    <ngx-loading [show]="loading" [config]="{ backdropBorderRadius: '14px' }"></ngx-loading>
-  </div>
-</form>
-

+ 0 - 0
src/app/components/basic/types/edit-types/edit-types.component.scss


+ 0 - 66
src/app/components/basic/types/edit-types/edit-types.component.ts

@@ -1,66 +0,0 @@
-import {Component, Inject} from '@angular/core';
-import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
-import {Router} from '@angular/router';
-import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material';
-import {EditComponent} from '../../../../classes/base_components/edit/edit.component';
-import {Dialog} from '../../../../classes/dialog';
-import {Type} from '../types.service';
-import {setErrors} from '../../../../classes/utils';
-
-
-@Component({
-    selector: 'app-edit-product',
-    templateUrl: './edit-types.component.html',
-    styleUrls: ['./edit-types.component.scss']
-})
-export class EditTypesComponent extends EditComponent {
-    public loading = false;
-    nameCtrl = new FormControl('', [Validators.required]);
-    type: Type;
-    form: FormGroup;
-
-    /***
-     *
-     * @param {FormBuilder} fb baray service form hast
-     * @param {Router} router navigate mikhone
-     * @param {Dialog} dialog
-     * @param {MatDialogRef<EditTypesComponent>} dialogRef
-     * @param data
-     */
-    constructor(private fb: FormBuilder,
-                private router: Router,
-                protected  dialog: Dialog,
-                public  dialogRef: MatDialogRef<EditTypesComponent>,
-                @Inject(MAT_DIALOG_DATA) data,
-    ) {
-        super();
-        this.type = data;
-        this.form = this.fb.group({
-            nameCtrl: this.nameCtrl,
-
-        });
-
-    }
-
-    onSubmit() {
-        this.loading = true;
-        if (!this.form.valid) {
-            this.loading = false;
-            return;
-        }
-        this.type.save({},
-            () => {
-                this.loading = false;
-                this.close();
-            },
-            (error) => {
-                this.loading = false;
-                const JsonV = error.errors;
-                setErrors(JsonV , this.form.controls, this.dialog);
-            });
-    }
-
-    close() {
-        this.dialogRef.close(true);
-    }
-}

+ 0 - 69
src/app/components/basic/types/types.component.html

@@ -1,69 +0,0 @@
-<div dir="ltr">
-  <button mat-button color="primary" (click)="edit()">افزودن
-    <mat-icon>add</mat-icon></button>
-  <button mat-button [matMenuTriggerFor]="menu">  <mat-icon>more_vert</mat-icon>
-  </button>
-  <mat-menu #menu="matMenu">
-    <button (click)='toggle(column)' *ngFor="let column of allColumns"  mat-menu-item>
-      <input
-              type='checkbox'
-              [id]="column.prop"
-              [checked]='isChecked(column)'
-              [disabled]="(column.prop == 'id')"
-      />
-      {{column.name}}
-    </button>
-  </mat-menu>
-</div>
-<ngx-datatable
-  class="material"
-  [rows]="rows"
-  [columns]="columns"
-  [columnMode]="'force'"
-  [headerHeight]="30"
-  [footerHeight]="50"
-  [rowHeight]="30"
-  [limit]="limit"
-  [count]="count"
-  [offset]="offset"
-  [filterRow]="true"
-  [externalSorting]="true"
-  [loadingIndicator]="is_loading"
-  [externalPaging]="true"
-  (sort)="fetchList($event)"
-  (page)='fetchList($event)'
-  [appUrl] = "appUrl"
-  [resource] = 'listService.type'
-
-
->
-
-  <ngx-datatable-column  *ngFor="let column of columns" prop="{{column.prop}}" name="{{column.name}}" [filterTemplate]="column.filter">
-    <ng-template *ngIf="column.prop == 'id'" let-row="row" let-value="value" ngx-datatable-cell-template>
-      <button mat-button color="primary" (click)="remove(value)"><mat-icon svgIcon="delete"></mat-icon></button>
-      <button mat-button color="primary" (click)="edit(value)">
-        <mat-icon>edit</mat-icon>
-      </button>
-    </ng-template>
-  </ngx-datatable-column>
-
-</ngx-datatable>
-
-
-<ng-template #filter_name>
-  <mat-form-field>
-    <input matInput [(ngModel)]="filters['name']" (change)="fetchList('filter')">
-  </mat-form-field>
-</ng-template>
-
-<ng-template #filter_id>
-  <button mat-icon-button (click)="fetchList('refresh')">
-    <mat-icon svgIcon="refresh"></mat-icon>
-  </button>
-</ng-template>
-
-
-
-
-
-

+ 0 - 0
src/app/components/basic/types/types.component.scss


+ 0 - 44
src/app/components/basic/types/types.component.ts

@@ -1,44 +0,0 @@
-import {Component, OnInit, TemplateRef, ViewChild} from '@angular/core';
-import {Dialog} from '../../../classes/dialog';
-import {ListComponent} from '../../../classes/base_components/list/list.component';
-import {TypesService} from './types.service';
-import {EditTypesComponent} from './edit-types/edit-types.component';
-import {Http} from '@angular/http';
-import {GlobalService} from '../../../classes/global.service';
-
-
-@Component({
-  selector: 'app-type',
-  templateUrl: './types.component.html',
-  styleUrls: ['./types.component.scss']
-})
-export class TypesComponent extends ListComponent implements OnInit{
-    @ViewChild('filter_id') public filter_id_ref: TemplateRef<any>;
-    @ViewChild('filter_name') public filter_name_ref: TemplateRef<any>;
-  constructor(
-    protected listService: TypesService,
-    protected dialog: Dialog,
-    protected http: Http,
-
-  ) {
-    super(listService, dialog, EditTypesComponent , http );
-  }
-    ngOnInit() {
-    this.columns = [
-
-        {
-            prop: 'name',
-            name: 'نام',
-            filter: this.filter_name_ref,
-        },
-      {
-        prop: 'id',
-        name: 'شناسه',
-        filter: this.filter_id_ref,
-      },
-
-    ];
-        super.ngOnInit();
-    }
-
-}

+ 0 - 25
src/app/components/basic/types/types.service.ts

@@ -1,25 +0,0 @@
-import {Injectable} from '@angular/core';
-import {Resource, Service} from 'ngx-jsonapi';
-
-
-@Injectable()
-export class TypesService extends Service<Type> {
-  public resource = Type;
-  public type = 'types';
-}
-
-
-export class Type extends Resource {
-  public attributes: {
-    name: string;
-  };
-
-  get name():string {
-    return this.attributes.name;
-  }
-
-  set name(name: string) {
-    this.attributes.name = name;
-  }
-
-}

+ 3 - 3
src/app/components/user/permissions/edit-permissions/edit-permissions.component.ts

@@ -1,10 +1,10 @@
 import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
 import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
 import {Router} from '@angular/router';
 import {Router} from '@angular/router';
 import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material';
 import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material';
-import {Role, RolesService} from '../../roles/roles.service';
-import {Dialog} from '../../../../classes/dialog';
+import {Role, RolesService} from '../../../../classes/resorcess/roles.service';
+import {Dialog} from '../../../../classes/base_components/dialog/dialog';
 import {Component, Inject} from '@angular/core';
 import {Component, Inject} from '@angular/core';
-import {Permission, PermissionGroupsService} from '../permissions.service';
+import {Permission, PermissionGroupsService} from '../../../../classes/resorcess/permissions.service';
 import {setErrors} from '../../../../classes/utils';
 import {setErrors} from '../../../../classes/utils';
 
 
 @Component({
 @Component({

+ 1 - 2
src/app/components/user/permissions/permissions.component.html

@@ -10,7 +10,6 @@
             <input
             <input
                     type='checkbox'
                     type='checkbox'
                     [id]="column.prop"
                     [id]="column.prop"
-
                     [checked]='isChecked(column)'
                     [checked]='isChecked(column)'
                     [disabled]="(column.prop == 'id')"
                     [disabled]="(column.prop == 'id')"
             />
             />
@@ -78,7 +77,7 @@
 <!--todo ino beporse-->
 <!--todo ino beporse-->
 <ng-template #filter_group>
 <ng-template #filter_group>
     <mat-form-field style="width: 100%" floatLabel="never">
     <mat-form-field style="width: 100%" floatLabel="never">
-        <mat-select multiple placeholder="گروه" [(ngModel)]="filters['group']" (change)="fetchList('filter')">
+        <mat-select multiple  [(ngModel)]="filters['group']" (change)="fetchList('filter')">
             <mat-option *ngFor="let permission_group of permission_groups" [value]="permission_group.id">
             <mat-option *ngFor="let permission_group of permission_groups" [value]="permission_group.id">
                 {{ permission_group.name }}
                 {{ permission_group.name }}
             </mat-option>
             </mat-option>

+ 7 - 7
src/app/components/user/permissions/permissions.component.ts

@@ -1,10 +1,9 @@
 import {Component, OnInit, TemplateRef, ViewChild} from '@angular/core';
 import {Component, OnInit, TemplateRef, ViewChild} from '@angular/core';
-import {PermissionGroupsService, PermissionsService} from './permissions.service';
+import {PermissionGroupsService, PermissionsService} from '../../../classes/resorcess/permissions.service';
 import {ListComponent} from '../../../classes/base_components/list/list.component';
 import {ListComponent} from '../../../classes/base_components/list/list.component';
-import {Dialog} from '../../../classes/dialog';
+import {Dialog} from '../../../classes/base_components/dialog/dialog';
 import {EditPermissionsComponent} from './edit-permissions/edit-permissions.component';
 import {EditPermissionsComponent} from './edit-permissions/edit-permissions.component';
 import {Http} from '@angular/http';
 import {Http} from '@angular/http';
-import {GlobalService} from '../../../classes/global.service';
 
 
 @Component({
 @Component({
   selector: 'app-permissions',
   selector: 'app-permissions',
@@ -21,10 +20,10 @@ export class PermissionsComponent extends ListComponent implements OnInit {
   permission_groups = [];
   permission_groups = [];
 
 
   constructor(
   constructor(
-    protected listService: PermissionsService,
-    protected dialog: Dialog,
-    protected permissionGroupsService: PermissionGroupsService,
-    protected http: Http,
+    public listService: PermissionsService,
+    public dialog: Dialog,
+    public permissionGroupsService: PermissionGroupsService,
+    public http: Http,
   ) {
   ) {
     super(listService, dialog, EditPermissionsComponent, http);
     super(listService, dialog, EditPermissionsComponent, http);
     permissionGroupsService.register();
     permissionGroupsService.register();
@@ -63,6 +62,7 @@ export class PermissionsComponent extends ListComponent implements OnInit {
       },
       },
     ];
     ];
     super.ngOnInit();
     super.ngOnInit();
+
   }
   }
 
 
 }
 }

+ 7 - 7
src/app/components/user/roles/edit-roles/edit-roles.component.html

@@ -1,14 +1,14 @@
 <form [formGroup]="form">
 <form [formGroup]="form">
   <mat-form-field style="width: 100%">
   <mat-form-field style="width: 100%">
-    <input matInput type="text" placeholder="نام " [(ngModel)]="role.name" formControlName="nameCtrl">
+    <input matInput type="text" placeholder="نام" [(ngModel)]="role.name" formControlName="nameCtrl">
   </mat-form-field>
   </mat-form-field>
   <div [hidden]="nameCtrl.valid || nameCtrl.untouched">
   <div [hidden]="nameCtrl.valid || nameCtrl.untouched">
     <div [hidden]="nameCtrl.valid">
     <div [hidden]="nameCtrl.valid">
-      {{nameCtrl.getError("error")? nameCtrl.getError("error") : 'لطفا نام  را وراد کنید '}}
+      {{nameCtrl.getError("error")? nameCtrl.getError("error") : 'لطفا نام  را وارد کنید '}}
     </div>
     </div>
   </div>
   </div>
   <mat-form-field style="width: 100%">
   <mat-form-field style="width: 100%">
-    <input matInput type="text" placeholder="اسلاگ " [(ngModel)]="role.slug" formControlName="slugCtrl">
+    <input matInput type="text"  placeholder="اسلاگ" [(ngModel)]="role.slug" formControlName="slugCtrl">
   </mat-form-field>
   </mat-form-field>
   <div [hidden]="slugCtrl.valid || slugCtrl.untouched">
   <div [hidden]="slugCtrl.valid || slugCtrl.untouched">
     <div [hidden]="slugCtrl.valid">
     <div [hidden]="slugCtrl.valid">
@@ -16,7 +16,7 @@
     </div>
     </div>
   </div>
   </div>
   <mat-form-field style="width: 100%">
   <mat-form-field style="width: 100%">
-  <mat-select placeholder="دسترسی ها" [(ngModel)]="role.permissionsIds" formControlName="permissionsCtrl" multiple>
+  <mat-select  [(ngModel)]="role.permissionsIds"  placeholder="دسترسی" formControlName="permissionsCtrl" multiple>
     <mat-optgroup *ngFor="let group of permissionGroups.$toArray" [label]="group.name">
     <mat-optgroup *ngFor="let group of permissionGroups.$toArray" [label]="group.name">
       <mat-option *ngFor="let permission of group.permissions.$toArray" [value]="permission.id">
       <mat-option *ngFor="let permission of group.permissions.$toArray" [value]="permission.id">
         {{ permission.name }}
         {{ permission.name }}
@@ -30,9 +30,9 @@
     </div>
     </div>
   </div>
   </div>
   <mat-dialog-actions>
   <mat-dialog-actions>
-    <button mat-raised-button  color="primary" (click)="onSubmit()">ثبت</button>
-    <button mat-raised-button (click)="close()">بازگشت</button>
-  </mat-dialog-actions>
+  <button mat-raised-button  color="primary" (click)="onSubmit()">ثبت</button>
+  <button mat-raised-button (click)="close()">بازگشت</button>
+</mat-dialog-actions>
   <div class="my-container">
   <div class="my-container">
     <ngx-loading [show]="loading" [config]="{ backdropBorderRadius: '14px' }"></ngx-loading>
     <ngx-loading [show]="loading" [config]="{ backdropBorderRadius: '14px' }"></ngx-loading>
   </div>
   </div>

+ 4 - 4
src/app/components/user/roles/edit-roles/edit-roles.component.ts

@@ -1,10 +1,10 @@
 import {Component, Inject} from '@angular/core';
 import {Component, Inject} from '@angular/core';
 import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
 import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
 import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material';
 import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material';
-import {Role, RolesService} from '../../roles/roles.service';
-import {Dialog} from '../../../../classes/dialog';
+import {Role, RolesService} from '../../../../classes/resorcess/roles.service';
+import {Dialog} from '../../../../classes/base_components/dialog/dialog';
 import {EditComponent} from '../../../../classes/base_components/edit/edit.component';
 import {EditComponent} from '../../../../classes/base_components/edit/edit.component';
-import {PermissionGroup, PermissionGroupsService, PermissionsService} from '../../permissions/permissions.service';
+import {PermissionGroup, PermissionGroupsService, PermissionsService} from '../../../../classes/resorcess/permissions.service';
 import {ICollection} from 'ngx-jsonapi';
 import {ICollection} from 'ngx-jsonapi';
 import {Base} from 'ngx-jsonapi/services/base';
 import {Base} from 'ngx-jsonapi/services/base';
 import {setErrors} from '../../../../classes/utils';
 import {setErrors} from '../../../../classes/utils';
@@ -25,7 +25,7 @@ export class EditRolesComponent extends EditComponent {
   role: Role;
   role: Role;
   permissionGroups: ICollection<PermissionGroup> = Base.newCollection<PermissionGroup>();
   permissionGroups: ICollection<PermissionGroup> = Base.newCollection<PermissionGroup>();
   constructor(private fb: FormBuilder,
   constructor(private fb: FormBuilder,
-              private rolesService: RolesService,
+              public rolesService: RolesService,
               private permision: PermissionsService,
               private permision: PermissionsService,
               private permissionGroupsService: PermissionGroupsService,
               private permissionGroupsService: PermissionGroupsService,
               protected  dialog: Dialog,
               protected  dialog: Dialog,

+ 8 - 9
src/app/components/user/roles/roles.component.ts

@@ -1,11 +1,10 @@
 import {Component, OnInit, TemplateRef, ViewChild} from '@angular/core';
 import {Component, OnInit, TemplateRef, ViewChild} from '@angular/core';
-import {RolesService} from './roles.service';
+import {RolesService} from '../../../classes/resorcess/roles.service';
 import {ListComponent} from '../../../classes/base_components/list/list.component';
 import {ListComponent} from '../../../classes/base_components/list/list.component';
-import {Dialog} from '../../../classes/dialog';
+import {Dialog} from '../../../classes/base_components/dialog/dialog';
 import {EditRolesComponent} from './edit-roles/edit-roles.component';
 import {EditRolesComponent} from './edit-roles/edit-roles.component';
-import {PermissionGroupsService, PermissionsService} from '../permissions/permissions.service';
+import {PermissionGroupsService, PermissionsService} from '../../../classes/resorcess/permissions.service';
 import {Http} from '@angular/http';
 import {Http} from '@angular/http';
-import {GlobalService} from '../../../classes/global.service';
 
 
 @Component({
 @Component({
   selector: 'app-roles',
   selector: 'app-roles',
@@ -18,11 +17,11 @@ export class RolesComponent extends ListComponent implements OnInit {
   @ViewChild('filter_slug') public filter_slug_ref: TemplateRef<any>;
   @ViewChild('filter_slug') public filter_slug_ref: TemplateRef<any>;
 
 
   constructor(
   constructor(
-    protected listService: RolesService,
-    private permissionsService: PermissionsService,
-    private permissionGroupsService: PermissionGroupsService,
-    protected dialog: Dialog,
-    protected http: Http,
+    public listService: RolesService,
+    public permissionsService: PermissionsService,
+    public permissionGroupsService: PermissionGroupsService,
+    public dialog: Dialog,
+    public http: Http,
   ) {
   ) {
     super(listService, dialog, EditRolesComponent, http);
     super(listService, dialog, EditRolesComponent, http);
     this.permissionsService.register();
     this.permissionsService.register();

+ 42 - 10
src/app/components/user/user.module.ts

@@ -1,29 +1,39 @@
 import {NgModule} from '@angular/core';
 import {NgModule} from '@angular/core';
 import {RouterModule} from '@angular/router';
 import {RouterModule} from '@angular/router';
 import {CommonModule} from '@angular/common';
 import {CommonModule} from '@angular/common';
-import {MatIconModule, MatInputModule, MatMenuModule, MatSelectModule} from '@angular/material';
+import {
+  DateAdapter,
+  MAT_DATE_FORMATS,
+  MAT_DATE_LOCALE, MatAutocompleteModule, MatDatepickerModule, MatGridListModule,
+  MatIconModule,
+  MatInputModule,
+  MatMenuModule, MatProgressBarModule,
+  MatSelectModule, MatTabsModule
+} from '@angular/material';
 import {FlexLayoutModule} from '@angular/flex-layout';
 import {FlexLayoutModule} from '@angular/flex-layout';
-import {DataTablesModule} from 'angular-datatables';
 import {FormsModule, ReactiveFormsModule} from '@angular/forms';
 import {FormsModule, ReactiveFormsModule} from '@angular/forms';
 import {MatButtonModule} from '@angular/material/button';
 import {MatButtonModule} from '@angular/material/button';
 import {MatOptionModule} from '@angular/material';
 import {MatOptionModule} from '@angular/material';
 import {MatCheckboxModule} from '@angular/material';
 import {MatCheckboxModule} from '@angular/material';
 import {MatCardModule} from '@angular/material';
 import {MatCardModule} from '@angular/material';
 import {MatFormFieldModule} from '@angular/material/form-field';
 import {MatFormFieldModule} from '@angular/material/form-field';
-import {NgxSpinnerModule, NgxSpinnerService} from 'ngx-spinner';
+
 import {LoadingModule} from 'ngx-loading';
 import {LoadingModule} from 'ngx-loading';
 import {UserRoutes} from './user.routing';
 import {UserRoutes} from './user.routing';
 import {NgxDatatableModule} from '@swimlane/ngx-datatable';
 import {NgxDatatableModule} from '@swimlane/ngx-datatable';
 import {RolesComponent} from './roles/roles.component';
 import {RolesComponent} from './roles/roles.component';
 import {UsersComponent} from './users/users.component';
 import {UsersComponent} from './users/users.component';
 import {PermissionsComponent} from './permissions/permissions.component';
 import {PermissionsComponent} from './permissions/permissions.component';
+import {AgmCoreModule} from '@agm/core';
+import {HttpClientModule} from '@angular/common/http';
+import {FileUploadModule} from 'ng2-file-upload';
 
 
 @NgModule({
 @NgModule({
     imports: [
     imports: [
-        MatMenuModule,
+      MatDatepickerModule,
+      MatMenuModule,
         LoadingModule,
         LoadingModule,
-        NgxSpinnerModule,
-        MatInputModule,
+            MatInputModule,
         MatFormFieldModule,
         MatFormFieldModule,
         MatCardModule,
         MatCardModule,
         MatButtonModule,
         MatButtonModule,
@@ -34,18 +44,40 @@ import {PermissionsComponent} from './permissions/permissions.component';
         CommonModule,
         CommonModule,
         RouterModule.forChild(UserRoutes),
         RouterModule.forChild(UserRoutes),
         FlexLayoutModule,
         FlexLayoutModule,
-        DataTablesModule,
         MatInputModule,
         MatInputModule,
         MatOptionModule,
         MatOptionModule,
         MatSelectModule,
         MatSelectModule,
-        MatIconModule
+        MatIconModule,
+      MatDatepickerModule,
+      MatGridListModule,
+      HttpClientModule,
+      FileUploadModule,
+      AgmCoreModule,
+      LoadingModule,
+        MatInputModule,
+      MatFormFieldModule,
+      MatCardModule,
+      MatButtonModule,
+      MatCheckboxModule,
+      NgxDatatableModule,
+      FormsModule,
+      ReactiveFormsModule,
+      CommonModule,
+      FlexLayoutModule,
+      MatInputModule,
+      MatOptionModule,
+      MatSelectModule,
+      MatIconModule,
+      MatTabsModule,
+      MatAutocompleteModule,
+      MatProgressBarModule
     ],
     ],
     declarations: [
     declarations: [
         UsersComponent,
         UsersComponent,
         RolesComponent,
         RolesComponent,
-        PermissionsComponent
+        PermissionsComponent,
     ],
     ],
-    providers: [NgxSpinnerService],
+    providers: [],
     entryComponents: []
     entryComponents: []
 
 
 })
 })

+ 29 - 13
src/app/components/user/user.routing.ts

@@ -1,19 +1,35 @@
 import {Routes} from '@angular/router';
 import {Routes} from '@angular/router';
 import {UsersComponent} from './users/users.component';
 import {UsersComponent} from './users/users.component';
 import {RolesComponent} from './roles/roles.component';
 import {RolesComponent} from './roles/roles.component';
+import {AuthGuard} from '../../classes/guards/auth.guard';
 import {PermissionsComponent} from './permissions/permissions.component';
 import {PermissionsComponent} from './permissions/permissions.component';
 
 
 
 
-export const UserRoutes: Routes = [{
-  path: '',
-},
-  {
-    path: 'user/users', component: UsersComponent
-  },
-  {
-    path: 'user/roles', component: RolesComponent
-  },
-  {
-    path: 'user/permissions', component: PermissionsComponent
-  }];
-
+export const UserRoutes: Routes =
+//   [
+//   {
+//   path: '', canActivate: [AuthGuard]
+// },
+//   {
+//     path: 'user/users', component: UsersComponent
+//   },
+//   {
+//     path: 'user/roles', component: RolesComponent, canActivate: [AuthGuard]
+//   },
+//   {
+//     path: 'user/permissions', component: PermissionsComponent, canActivate: [AuthGuard]
+//   },
+//  ];
+  [{
+    path: '',
+    children: [{
+      path: 'users',
+      component: UsersComponent
+    }, {
+      path: 'roles',
+      component: RolesComponent
+    }, {
+      path: 'permissions',
+      component: PermissionsComponent
+    }]
+  }]

+ 0 - 59
src/app/components/user/users/edit-users/edit-users.component.html

@@ -1,59 +0,0 @@
-<form [formGroup]="form">
-  <mat-form-field style="width: 100%">
-    <input matInput type="text" placeholder="نام " [(ngModel)]="user.name" formControlName="nameCtrl">
-  </mat-form-field>
-  <div [hidden]="nameCtrl.valid || nameCtrl.untouched">
-    <div [hidden]="nameCtrl.valid">
-      {{nameCtrl.getError("error") ? nameCtrl.getError("error") : 'لطفا نام خود را وارد کنید '}}
-    </div>
-  </div>
-  <mat-form-field style="width: 100%">
-    <input matInput type="text" placeholder="ایمیل " [(ngModel)]="user.email" formControlName="emailCtrl">
-  </mat-form-field>
-  <div [hidden]="emailCtrl.valid || emailCtrl.untouched">
-    <div [hidden]="emailCtrl.valid">
-      {{emailCtrl.getError("error") ? emailCtrl.getError("error") : 'لطفاایمیل خود را وارد کنید '}}
-    </div>
-  </div>
-  <mat-form-field style="width: 100%">
-    <input matInput type="password" placeholder="رمز عبور " [(ngModel)]="user.password" formControlName="passwordCtrl">
-  </mat-form-field>
-  <div [hidden]="passwordCtrl.valid || passwordCtrl.untouched">
-    <div [hidden]="passwordCtrl.valid">
-      {{passwordCtrl.getError("error") ? passwordCtrl.getError("error") : 'لطفا رمز خود را وارد نمایید '}}
-    </div>
-  </div>
-  <mat-form-field style="width: 100%">
-    <input matInput type="text" placeholder="شماره همراه" [(ngModel)]="user.mobile"
-           formControlName="mobileCtrl">
-  </mat-form-field>
-  <div [hidden]="mobileCtrl.valid || mobileCtrl.untouched">
-    <div [hidden]="mobileCtrl.valid">
-      {{mobileCtrl.getError("error") ? mobileCtrl.getError("error") : 'لطفا شماره همراه خود را وارد کنید '}}
-    </div>
-  </div>
-  <mat-form-field style="width: 100%" floatLabel="never" dir="rtl">
-    <mat-select [(ngModel)]="user.type2.id" formControlName="typesCtrl" placeholder="نوع">
-      <mat-option *ngFor="let type of types" [value]="type.id"
-      >
-        {{ type.name }}
-      </mat-option>
-    </mat-select>
-  </mat-form-field>
-  <mat-form-field style="width: 100%" floatLabel="never" dir="rtl">
-    <mat-select [(ngModel)]="user.role.id" formControlName="rolesCtrl" placeholder="نقش">
-      <mat-option *ngFor="let role of roles" [value]="role.id">
-        {{role.name}}
-      </mat-option>
-    </mat-select>
-  </mat-form-field>
-
-  <mat-dialog-actions>
-    <button mat-raised-button color="primary" (click)="onSubmit()">ثبت</button>
-    <button mat-raised-button (click)="close()">بازگشت</button>
-  </mat-dialog-actions>
-  <div class="my-container">
-    <ngx-loading [show]="loading" [config]="{ backdropBorderRadius: '14px' }"></ngx-loading>
-  </div>
-</form>
-

+ 21 - 48
src/app/components/user/users/edit-users/edit-users.component.ts

@@ -1,13 +1,12 @@
 import {Component, Inject, Injectable} from '@angular/core';
 import {Component, Inject, Injectable} from '@angular/core';
 import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
 import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
 import {Router} from '@angular/router';
 import {Router} from '@angular/router';
-import {User, UsersService} from '../users.service';
+import {User, UsersService} from '../../../../classes/resorcess/users.service';
 import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material';
 import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material';
-import {Role, RolesService} from '../../roles/roles.service';
-import {Dialog} from '../../../../classes/dialog';
+import {RolesService} from '../../../../classes/resorcess/roles.service';
+import {Dialog} from '../../../../classes/base_components/dialog/dialog';
 import {EditComponent} from '../../../../classes/base_components/edit/edit.component';
 import {EditComponent} from '../../../../classes/base_components/edit/edit.component';
-import {TypesService} from '../../../basic/types/types.service';
-import {repairErrors, setErrors} from '../../../../classes/utils';
+import {HttpClient, HttpEventType} from '@angular/common/http';
 
 
 
 
 @Component({
 @Component({
@@ -17,60 +16,34 @@ import {repairErrors, setErrors} from '../../../../classes/utils';
 })
 })
 
 
 export class EditUsersComponent extends EditComponent {
 export class EditUsersComponent extends EditComponent {
-  public loading = false;
-  nameCtrl = new FormControl('', [Validators.required]);
-  emailCtrl = new FormControl('', [Validators.required]);
-  passwordCtrl = new FormControl('', [Validators.required]);
-  mobileCtrl = new FormControl('', [Validators.required]);
-  typesCtrl = new FormControl('', [Validators.required]);
-  rolesCtrl = new FormControl('', [Validators.required]);
-  form: FormGroup;
-  user: User;
-  types;
-  roles;
-
 
 
   constructor(private fb: FormBuilder,
   constructor(private fb: FormBuilder,
               private roleService: RolesService,
               private roleService: RolesService,
               private router: Router,
               private router: Router,
-              private  typeService: TypesService,
               private usersService: UsersService,
               private usersService: UsersService,
               protected  dialog: Dialog,
               protected  dialog: Dialog,
+              private http: HttpClient,
               public  dialogRef: MatDialogRef<EditUsersComponent>,
               public  dialogRef: MatDialogRef<EditUsersComponent>,
-              @Inject(MAT_DIALOG_DATA)  data
+              @Inject(MAT_DIALOG_DATA)  data,
   ) {
   ) {
     super();
     super();
-    this.loading = false;
-    const basics = JSON.parse(localStorage.getItem('basics'));
-    this.types = basics['types'];
-    this.roles = basics['roles'];
-    this.user = data;
-    this.form = this.fb.group({
-      emailCtrl: this.emailCtrl,
-      nameCtrl: this.nameCtrl,
-      mobileCtrl: this.mobileCtrl,
-      passwordCtrl: this.passwordCtrl,
-      typesCtrl: this.typesCtrl,
-      rolesCtrl: this.rolesCtrl,
-    });
   }
   }
 
 
-  onSubmit(){
-    this.loading = true;
-    if (!this.form.valid) {
-      this.loading = false;
-      return;
-    }
-    this.user.save({},
-      () => {
-        this.loading = false;
-        this.close();
-      },
-      (error) => {
-        this.loading = false;
-        const JsonV = error.errors;
-        setErrors(JsonV, this.form.controls, this.dialog);
-      });
+  onSubmit() {
+    // if (!this.form.valid) {
+    //   this.loading = false;
+    //   return;
+    // }
+    // this.user.save({},
+    //   () => {
+    //     this.close();
+    //   },
+    //   (error) => {
+    //     console.log('error', error);
+    //
+    //     const JsonV = error.errors;
+    //     setErrors(JsonV, this.form.controls, this.dialog);
+    //   });
   }
   }
 
 
   close() {
   close() {

+ 17 - 33
src/app/components/user/users/users.component.html

@@ -3,15 +3,16 @@
     افزودن کاربر جدید
     افزودن کاربر جدید
     <mat-icon>add</mat-icon>
     <mat-icon>add</mat-icon>
   </button>
   </button>
-  <button mat-button [matMenuTriggerFor]="menu">  <mat-icon>more_vert</mat-icon>
+  <button mat-button [matMenuTriggerFor]="menu">
+    <mat-icon>more_vert</mat-icon>
   </button>
   </button>
   <mat-menu #menu="matMenu">
   <mat-menu #menu="matMenu">
-    <button (click)='toggle(column)' *ngFor="let column of allColumns"  mat-menu-item>
+    <button (click)='toggle(column)' *ngFor="let column of allColumns" mat-menu-item>
       <input
       <input
-              type='checkbox'
-              [id]="column.prop"
-              [checked]='isChecked(column)'
-              [disabled]="(column.prop == 'id')"
+        type='checkbox'
+        [id]="column.prop"
+        [checked]='isChecked(column)'
+        [disabled]="(column.prop == 'id')"
       />
       />
       {{column.name}}
       {{column.name}}
     </button>
     </button>
@@ -32,27 +33,29 @@
   [externalSorting]="true"
   [externalSorting]="true"
   [loadingIndicator]="is_loading"
   [loadingIndicator]="is_loading"
   [externalPaging]="true"
   [externalPaging]="true"
-  [appUrl] = "appUrl"
+  [appUrl]="appUrl"
   (sort)="fetchList($event)"
   (sort)="fetchList($event)"
   (page)='fetchList($event)'
   (page)='fetchList($event)'
-  (perPage) = "fetchList($event)"
-  [filters] = "filters"
+  (perPage)="fetchList($event)"
+  [filters]="filters"
   [sortDir]="sortDir"
   [sortDir]="sortDir"
   [sortProp]="sortProp"
   [sortProp]="sortProp"
   [includes]="includes"
   [includes]="includes"
-  [resource] = 'listService.type'
-  id = 'my-table'
+  [resource]='listService.type'
+  id='my-table'
 >
 >
 
 
-  <ngx-datatable-column  *ngFor="let column of columns" prop="{{column.prop}}" name="{{column.name}}" [filterTemplate]="column.filter">
+  <ngx-datatable-column *ngFor="let column of columns" prop="{{column.prop}}" name="{{column.name}}"
+                        [filterTemplate]="column.filter">
     <ng-template *ngIf="column.prop == 'id'" let-row="row" let-value="value" ngx-datatable-cell-template>
     <ng-template *ngIf="column.prop == 'id'" let-row="row" let-value="value" ngx-datatable-cell-template>
-      <button mat-button color="primary" (click)="remove(value)"><mat-icon svgIcon="delete"></mat-icon></button>
+      <button mat-button color="primary" (click)="remove(value)">
+        <mat-icon style="margin: 5px" svgIcon="delete"></mat-icon>
+      </button>
       <button mat-button color="primary" (click)="edit(value)">
       <button mat-button color="primary" (click)="edit(value)">
         <mat-icon>edit</mat-icon>
         <mat-icon>edit</mat-icon>
       </button>
       </button>
     </ng-template>
     </ng-template>
   </ngx-datatable-column>
   </ngx-datatable-column>
-
 </ngx-datatable>
 </ngx-datatable>
 
 
 
 
@@ -68,32 +71,13 @@
   </mat-form-field>
   </mat-form-field>
 </ng-template>
 </ng-template>
 
 
-
 <ng-template #filter_email>
 <ng-template #filter_email>
   <mat-form-field style="width: 100%" floatLabel="never">
   <mat-form-field style="width: 100%" floatLabel="never">
     <input matInput [(ngModel)]="filters['email']" (change)="fetchList('filter')">
     <input matInput [(ngModel)]="filters['email']" (change)="fetchList('filter')">
   </mat-form-field>
   </mat-form-field>
 </ng-template>
 </ng-template>
 
 
-<ng-template #filter_type>
-  <mat-form-field style="width: 100%" floatLabel="never">
-    <mat-select multiple placeholder="نوع" [(ngModel)]="filters['type']" (change)="fetchList('filter')">
-      <mat-option *ngFor="let type of types" [value]="type.id">
-        {{ type.name }}
-      </mat-option>
-    </mat-select>
-  </mat-form-field>
-</ng-template>
 
 
-<ng-template #filter_role>
-  <mat-form-field style="width: 100%" floatLabel="never">
-    <mat-select multiple placeholder="نقش" [(ngModel)]="filters['role']" (change)="fetchList('filter')">
-      <mat-option *ngFor="let role of roles" [value]="role.id">
-        {{ role.name }}
-      </mat-option>
-    </mat-select>
-  </mat-form-field>
-</ng-template>
 <ng-template #filter_id>
 <ng-template #filter_id>
   <button mat-icon-button (click)="fetchList('refresh')">
   <button mat-icon-button (click)="fetchList('refresh')">
     <mat-icon svgIcon="refresh"></mat-icon>
     <mat-icon svgIcon="refresh"></mat-icon>

+ 16 - 38
src/app/components/user/users/users.component.ts

@@ -1,14 +1,11 @@
 import {Component, OnChanges, OnInit, TemplateRef, ViewChild} from '@angular/core';
 import {Component, OnChanges, OnInit, TemplateRef, ViewChild} from '@angular/core';
-import {User, UsersService} from './users.service';
+import {User, UsersService} from '../../../classes/resorcess/users.service';
 import {ICollection} from 'ngx-jsonapi';
 import {ICollection} from 'ngx-jsonapi';
-import {RolesService} from '../roles/roles.service';
 import {ListComponent} from '../../../classes/base_components/list/list.component';
 import {ListComponent} from '../../../classes/base_components/list/list.component';
-import {Dialog} from '../../../classes/dialog';
+import {Dialog} from '../../../classes/base_components/dialog/dialog';
 import {EditUsersComponent} from './edit-users/edit-users.component';
 import {EditUsersComponent} from './edit-users/edit-users.component';
-import {TypesService} from '../../basic/types/types.service';
 import {Http} from '@angular/http';
 import {Http} from '@angular/http';
 
 
-
 @Component({
 @Component({
   selector: 'app-user',
   selector: 'app-user',
   templateUrl: './users.component.html',
   templateUrl: './users.component.html',
@@ -19,26 +16,17 @@ export class UsersComponent extends ListComponent implements OnInit {
   @ViewChild('filter_name') public filter_name_ref: TemplateRef<any>;
   @ViewChild('filter_name') public filter_name_ref: TemplateRef<any>;
   @ViewChild('filter_mobile') public filter_mobile_ref: TemplateRef<any>;
   @ViewChild('filter_mobile') public filter_mobile_ref: TemplateRef<any>;
   @ViewChild('filter_email') public filter_email_ref: TemplateRef<any>;
   @ViewChild('filter_email') public filter_email_ref: TemplateRef<any>;
-  @ViewChild('filter_type') public filter_type_ref: TemplateRef<any>;
-  @ViewChild('filter_role') public filter_role_ref: TemplateRef<any>;
-  types;
-  roles;
+  @ViewChild('filter_docDegree') public filter_docDegree_ref: TemplateRef<any>;
   users: ICollection<User>;
   users: ICollection<User>;
   data: any;
   data: any;
 
 
 
 
-  constructor(protected listService: UsersService,
-              protected typeService: TypesService,
-              protected roleService: RolesService,
-              protected dialog: Dialog,
-              protected http: Http,
+  constructor(public listService: UsersService,
+              public dialog: Dialog,
+              public http: Http,
   ) {
   ) {
     super(listService, dialog, EditUsersComponent, http);
     super(listService, dialog, EditUsersComponent, http);
-    const basics = JSON.parse(localStorage.getItem('basics'));
-    this.types = basics['types'];
-    this.roles = basics['roles'];
-    typeService.register();
-    roleService.register();
+    this.listService.register();
   }
   }
 
 
   ngOnInit() {
   ngOnInit() {
@@ -58,31 +46,21 @@ export class UsersComponent extends ListComponent implements OnInit {
         name: 'ایمیل',
         name: 'ایمیل',
         filter: this.filter_email_ref,
         filter: this.filter_email_ref,
       },
       },
-      {
-        prop: 'type',
-        name: 'نوع',
-        isRelationship: true,
-        mustIncluded: true,
-        filter: this.filter_type_ref,
-      },
-      {
-        prop: 'role',
-        name: 'نقش',
-        isRelationship: true,
-        mustIncluded: true,
-        filter: this.filter_role_ref,
-
-      },
       {
       {
         prop: 'id',
         prop: 'id',
         name: 'شناسه',
         name: 'شناسه',
         filter: this.filter_id_ref,
         filter: this.filter_id_ref,
       },
       },
     ];
     ];
-
     super.ngOnInit();
     super.ngOnInit();
-
   }
   }
-
-
 }
 }
+
+// todo test
+//      {
+//         prop: 'university',
+//         name: 'دانشگاه',
+//         filter: this.filter_university_ref,
+//         isRelationship: true,
+//         mustIncluded: true,
+//},

+ 0 - 432
src/app/components/user/users/users.service.ts

@@ -1,432 +0,0 @@
-import {Injectable} from '@angular/core';
-import {ICollection, ISchema, Resource, Service} from 'ngx-jsonapi';
-import {Type, TypesService} from '../../basic/types/types.service';
-import {Role, RolesService} from '../roles/roles.service';
-import {Base} from 'ngx-jsonapi/services/base';
-import {Doc, DocService} from '../../../classes/doc.service';
-import {Center, CentersService} from '../../../classes/center.service';
-import {Message} from '../../../classes/message.service';
-
-
-@Injectable()
-export class UsersService extends Service<User> {
-
-
-  public resource = User;
-  public type = 'users';
-  public schema: ISchema = {
-    relationships: {
-      type: {
-        hasMany: false
-      },
-      role: {
-        hasMany: false
-      },
-      messages: {
-        hasMany: true
-      },
-      centers: {
-        hasMany: true
-      },
-      docshenasname: {
-        hasMany: false
-      },
-      doccardmelli: {
-        hasMany: false
-      },
-      docdegree: {
-        hasMany: false
-      },
-      docimage: {
-        hasMany: false
-      },
-      docmsn: {
-        hasMany: false
-      },
-
-    }
-  };
-}
-
-export class User extends Resource {
-  public static NURSE_TYPE_ID = '2';
-  public attributes: {
-    id: string,
-    name: string,
-    mobile: string,
-    password: string,
-    email: string,
-    cloud_token: string,
-    gender: string,
-    identifyNumber: string,
-    birth_day: string,
-    father_name: string,
-    resume: string,
-    address: string,
-    postal_code: string,
-    expertise: string,
-    msns: string,
-    lat: string,
-    lng: string,
-    available: boolean,
-  };
-
-// وفتی میخوای از اینا داخل برنامه استفاده کنی بدون پرانتز استفاده کن
-  get available(): boolean {
-    return this.attributes.available;
-  }
-
-  set available(available: boolean) {
-    this.attributes.available = available;
-  }
-
-  get lat(): string {
-    return this.attributes.lat;
-  }
-
-  set lat(lat: string) {
-    this.attributes.lat = lat;
-  }
-
-  get lng(): string {
-    return this.attributes.lng;
-  }
-
-  set lng(lng: string) {
-    this.attributes.lng = lng;
-  }
-
-  get name(): string {
-    return this.attributes.name;
-  }
-
-  set name(name: string) {
-    this.attributes.name = name;
-  }
-
-  get mobile(): string {
-    return this.attributes.mobile;
-  }
-
-  set mobile(mobile: string) {
-    this.attributes.mobile = mobile;
-  }
-
-  get password(): string {
-    return this.attributes.password;
-  }
-
-  set password(password: string) {
-    this.attributes.password = password;
-  }
-
-  get email(): string {
-    return this.attributes.email;
-  }
-
-  set email(email: string) {
-    this.attributes.email = email;
-  }
-
-  get gender(): string {
-    return this.attributes.gender;
-  }
-
-  set gender(gender: string) {
-    this.attributes.gender = gender;
-  }
-
-  get identifyNumber(): string {
-    return this.attributes.identifyNumber;
-  }
-
-  set identifyNumber(identifyNumber: string) {
-    this.attributes.identifyNumber = identifyNumber;
-  }
-
-  get birth_day(): string {
-    return this.attributes.birth_day;
-  }
-
-  set birth_day(birth_day: string) {
-    this.attributes.birth_day = birth_day;
-  }
-
-  get father_name(): string {
-    return this.attributes.father_name;
-  }
-
-  set father_name(father_name: string) {
-    this.attributes.father_name = father_name;
-  }
-
-  get resume(): string {
-    return this.attributes.resume;
-  }
-
-  set resume(resume: string) {
-    this.attributes.resume = resume;
-  }
-
-  get address(): string {
-    return this.attributes.address;
-  }
-
-  set address(address: string) {
-    this.attributes.address = address;
-  }
-
-  get postal_code(): string {
-    return this.attributes.postal_code;
-  }
-
-  set postal_code(postal_code: string) {
-    this.attributes.postal_code = postal_code;
-  }
-
-  get expertise(): string {
-    return this.attributes.expertise;
-  }
-
-  set expertise(expertise: string) {
-    this.attributes.expertise = expertise;
-  }
-
-  get msns(): string {
-    return this.attributes.msns;
-  }
-
-  set msns(msns: string) {
-    this.attributes.msns = msns;
-  }
-
-  get cloud_token() {
-    return this.attributes.cloud_token;
-  }
-
-  set cloud_token(cloud_token: string) {
-    this.attributes.cloud_token = cloud_token;
-  }
-
-  get Id(): string {
-    return this.attributes.id;
-  }
-
-  set Id(id: string) {
-    this.attributes.id = id;
-  }
-
-  // in baray relationship type hast ke yek be yek hast
-  // todo
-  get type2(): Type {
-    if (Object.keys(this.relationships.type.data).length === 0) {
-      const type = (new TypesService()).new();
-      this.type2 = type;
-    }
-    return <Type>this.relationships.type.data;
-  }
-
-  set type2(type: Type) {
-    this.relationships.type.data = type;
-  }
-
-  set typeId(id: string) {
-    let typeService = new TypesService();
-    let type = typeService.new();
-    type.id = id;
-    this.type2 = type;
-  }
-
-  // in baray relationship role hast ke yek be yek hast
-
-  get role(): Role {
-    if (Object.keys(this.relationships.role.data).length === 0) {
-      const role = (new RolesService()).new();
-      this.role = role;
-    }
-    return <Role>this.relationships.role.data;
-  }
-
-  set role(role: Role) {
-    this.relationships.role.data = role;
-  }
-
-  set roleId(id: string) {
-    let roleService = new RolesService();
-    let role = roleService.new();
-    role.id = id;
-    this.role = role;
-  }
-
-  // in baray relationship centers hast ke chand be chand hast
-  //  تمام سنتر هارو بر میگردونه
-  get centers(): ICollection<Center> {
-    return <ICollection<Center>>this.relationships.centers.data;
-  }
-
-  //   برای ست کردن یه سنتر استفاده میشه
-  set centers(center: ICollection<Center>) {
-    this.relationships.centers.data = center;
-  }
-
-// این  برای وقتی که id های سنتر هارو میخوای بگیری این جا روی data های ریلیشن سنتر foreach میرنه
-  get centersIds(): string[] {
-
-    let ids: string[] = [];
-    Base.forEach(this.centers, (center: Center) => {
-      ids.push(center.id);
-    });
-    return ids;
-  }
-
-  //  زمانی  استفاده میشه که مثلا بخوای یه سنتر create کنی
-  set centersIds(centersIds: string[]) {
-    if (centersIds == null) {
-      centersIds = [];
-    }
-    const selected_centers: ICollection<Center> = Base.newCollection<Center>();
-    for (const key in centersIds) {
-      if (key in centersIds) {
-        const center_id = centersIds[key];
-        const center = (new CentersService()).new();
-        center.id = center_id;
-        selected_centers[center_id] = center;
-      }
-    }
-    this.centers = selected_centers;
-  }
-
-// in baray relationship messages hast ke chand be chand hast
-  // in tamam datae relationship messages ro bar migardone
-  get messages(): ICollection<Message> {
-    return <ICollection<Message>>this.relationships.messages.data;
-  }
-
-  set messages(messages: ICollection<Message>) {
-    this.relationships.Message.data = messages;
-  }
-
-// in tamam  center haro migire va foreach mizane idesh ham bar migardone
-  get messagesIds(): string[] {
-    let ids: string[] = [];
-    Base.forEach(this.messages, (messages: Message) => {
-      ids.push(messages.id);
-    });
-    return ids;
-  }
-
-  // in zamani estefade mishe ke bekhay message create koni
-  set messagesIds(messagesIds: string[]) {
-    const selected_messages: ICollection<Message> = Base.newCollection<Message>();
-    for (const key in messagesIds) {
-      if (key in messagesIds) {
-        const message_id = messagesIds[key];
-        const message = (new CentersService()).new();
-        message.id = message_id;
-        selected_messages[message_id] = message;
-      }
-    }
-    this.messages = selected_messages;
-  }
-
-  // // in baray docshenasname hast ke yek be yek hast
-  get docshenasname(): Doc {
-    if (Object.keys(this.relationships.docshenasname.data).length === 0) {
-      const doc = (new DocService()).new();
-      this.docshenasname = doc;
-    }
-    return <Doc>this.relationships.docshenasname.data;
-  }
-
-  set docshenasname(docshenasname: Doc) {
-    this.relationships.docshenasname.data = docshenasname;
-  }
-
-  set docshenasnameId(id: string) {
-    let docService = new DocService();
-    let doc = docService.new();
-    doc.id = id;
-    this.docshenasname = doc;
-  }
-
-  // in baray docshenasname hast ke yek be yek hast
-  get doccardmelli(): Doc {
-    if (Object.keys(this.relationships.doccardmelli.data).length === 0) {
-      const doc = (new DocService()).new();
-      this.doccardmelli = doc;
-    }
-    return <Doc>this.relationships.doccardmelli.data;
-  }
-
-  set doccardmelli(doccardmelli: Doc) {
-    this.relationships.doccardmelli.data = doccardmelli;
-  }
-
-  set doccardmelliId(id: string) {
-    let docService = new DocService();
-    let doc = docService.new();
-    doc.id = id;
-    this.doccardmelli = doc;
-  }
-
-  // in baray degree hast  ke yek be yek hast
-  get docdegree(): Doc {
-    if (Object.keys(this.relationships.docdegree.data).length === 0) {
-      const doc = (new DocService()).new();
-      this.docdegree = doc;
-    }
-    return <Doc>this.relationships.docdegree.data;
-  }
-
-  set docdegree(docdegree: Doc) {
-    this.relationships.docdegree.data = docdegree;
-  }
-
-  set docdegreeId(id: string) {
-    let docService = new DocService();
-    let doc = docService.new();
-    doc.id = id;
-    this.docdegree = doc;
-  }
-
-  // in baray relation image hast ke yek be yek hast
-  get docimage(): Doc {
-    if (Object.keys(this.relationships.docimage.data).length === 0) {
-      const doc = (new DocService()).new();
-      this.docimage = doc;
-    }
-    return <Doc>this.relationships.docimage.data;
-  }
-
-  set docimage(docimage: Doc) {
-    this.relationships.docimage.data = docimage;
-  }
-
-  set docimageId(id: string) {
-    let docService = new DocService();
-    let doc = docService.new();
-    doc.id = id;
-    this.docimage = doc;
-  }
-
-  // in baray relation docmsn hast ke yek be yek hast , msn hamon parvane nezam pezeshki hast
-  get docmsn(): Doc {
-    if (Object.keys(this.relationships.docmsn.data).length === 0) {
-      const doc = (new DocService()).new();
-      this.docmsn = doc;
-    }
-    return <Doc>this.relationships.docmsn.data;
-  }
-
-  set docmsn(docmsn: Doc) {
-    this.relationships.docmsn.data = docmsn;
-  }
-
-  set docmsnId(id: string) {
-    let docService = new DocService();
-    let doc = docService.new();
-    doc.id = id;
-    this.docmsn = doc;
-  }
-
-}

+ 12 - 7
src/app/core/admin-layout/admin-layout.component.html

@@ -1,22 +1,27 @@
-<div class="app mat-typography"  dir="rtl"   [ngClass]="{'app-dark': options.dark, 'boxed': options.boxed, 'collapsed-sidebar': options.collapsed, 'compact-sidebar': options.compact, 'side-panel-opened': sidePanelOpened, 'side-panel-closed': !sidePanelOpened }">
-  <!-- <ngx-loading-bar color="#009688"></ngx-loading-bar> -->
-  <app-header (toggleSidenav)="sidemenu.toggle()" (toggleNotificationSidenav)="notifications.toggle()"></app-header>
 
 
+<div class="app mat-typography" dir="rtl"
+     [ngClass]="{'app-dark': options.dark, 'boxed': options.boxed, 'collapsed-sidebar': options.collapsed, 'compact-sidebar': options.compact, 'side-panel-opened': sidePanelOpened, 'side-panel-closed': !sidePanelOpened }">
+  <!-- <ngx-loading-bar color="#009688"></ngx-loading-bar> -->
+  <app-header (toggleSidenav)="sidemenu.toggle()" (toggleNotificationSidenav)="notifications.toggle()"
+              (login)="loginUser()"
+  ></app-header>
   <mat-sidenav-container class="app-inner">
   <mat-sidenav-container class="app-inner">
-    <mat-sidenav #sidemenu class="sidebar-panel" id="sidebar-panel" [mode]="isOver() ? 'over' : 'side'" [opened]="!isOver()" (open)="sidePanelOpened = true"
-    (close)="sidePanelOpened = false" (mouseover)="menuMouseOver()" (mouseout)="menuMouseOut()" [perfectScrollbar]="config" [disabled]="mediaMatcher.matches">
+    <mat-sidenav #sidemenu class="sidebar-panel" id="sidebar-panel" [mode]="isOver() ? 'over' : 'side'"
+                 [opened]="!isOver()" (open)="sidePanelOpened = true"
+                 (close)="sidePanelOpened = false" (mouseover)="menuMouseOver()" (mouseout)="menuMouseOut()"
+                 [perfectScrollbar]="config" [disabled]="mediaMatcher.matches">
       <app-sidebar (click)="updatePS()"></app-sidebar>
       <app-sidebar (click)="updatePS()"></app-sidebar>
     </mat-sidenav>
     </mat-sidenav>
     <mat-sidenav #notifications position="end" class="chat-panel" mode="over" opened="false">
     <mat-sidenav #notifications position="end" class="chat-panel" mode="over" opened="false">
       <app-notification></app-notification>
       <app-notification></app-notification>
     </mat-sidenav>
     </mat-sidenav>
+
     <div [perfectScrollbar]="config" [disabled]="mediaMatcher.matches">
     <div [perfectScrollbar]="config" [disabled]="mediaMatcher.matches">
       <router-outlet></router-outlet>
       <router-outlet></router-outlet>
     </div>
     </div>
   </mat-sidenav-container>
   </mat-sidenav-container>
-
   <!-- Demo Purposes Only -->
   <!-- Demo Purposes Only -->
-  <app-options (messageEvent)="receiveOptions($event)"></app-options>
+<!--  <app-options (messageEvent)="receiveOptions($event)"></app-options>-->
   <!-- /Demo Purposes Only -->
   <!-- /Demo Purposes Only -->
 </div>
 </div>
 
 

+ 12 - 16
src/app/core/admin-layout/admin-layout.component.ts

@@ -1,11 +1,9 @@
-import { Component, ElementRef, NgZone, OnInit, OnDestroy, ViewChild, HostListener } from '@angular/core';
-import { Router, NavigationEnd } from '@angular/router';
-import { Subscription } from 'rxjs/Subscription';
+import {Component, ElementRef, NgZone, OnInit, OnDestroy, ViewChild, HostListener} from '@angular/core';
+import {Router, NavigationEnd} from '@angular/router';
+import {Subscription} from 'rxjs/Subscription';
 import 'rxjs/add/operator/filter';
 import 'rxjs/add/operator/filter';
-
-import { TranslateService } from '@ngx-translate/core';
-
-import { PerfectScrollbarConfigInterface, PerfectScrollbarDirective } from 'ngx-perfect-scrollbar';
+import {PerfectScrollbarConfigInterface, PerfectScrollbarDirective} from 'ngx-perfect-scrollbar';
+import {AuthService} from '../../classes/servicess/auth.service';
 
 
 const SMALL_WIDTH_BREAKPOINT = 960;
 const SMALL_WIDTH_BREAKPOINT = 960;
 
 
@@ -14,9 +12,7 @@ const SMALL_WIDTH_BREAKPOINT = 960;
   templateUrl: './admin-layout.component.html'
   templateUrl: './admin-layout.component.html'
 })
 })
 export class AdminLayoutComponent implements OnInit, OnDestroy {
 export class AdminLayoutComponent implements OnInit, OnDestroy {
-
   private _router: Subscription;
   private _router: Subscription;
-
   mediaMatcher: MediaQueryList = matchMedia(`(max-width: ${SMALL_WIDTH_BREAKPOINT}px)`);
   mediaMatcher: MediaQueryList = matchMedia(`(max-width: ${SMALL_WIDTH_BREAKPOINT}px)`);
   url: string;
   url: string;
   sidePanelOpened;
   sidePanelOpened;
@@ -27,13 +23,12 @@ export class AdminLayoutComponent implements OnInit, OnDestroy {
     dark: false,
     dark: false,
     dir: 'ltr'
     dir: 'ltr'
   };
   };
-
   @ViewChild('sidemenu') sidemenu;
   @ViewChild('sidemenu') sidemenu;
   @ViewChild(PerfectScrollbarDirective) directiveScroll: PerfectScrollbarDirective;
   @ViewChild(PerfectScrollbarDirective) directiveScroll: PerfectScrollbarDirective;
-
   public config: PerfectScrollbarConfigInterface = {};
   public config: PerfectScrollbarConfigInterface = {};
 
 
   constructor(
   constructor(
+    private  authService: AuthService,
     private _element: ElementRef,
     private _element: ElementRef,
     private router: Router,
     private router: Router,
     zone: NgZone) {
     zone: NgZone) {
@@ -43,9 +38,7 @@ export class AdminLayoutComponent implements OnInit, OnDestroy {
   }
   }
 
 
   ngOnInit(): void {
   ngOnInit(): void {
-
     this.url = this.router.url;
     this.url = this.router.url;
-
     this._router = this.router.events.filter(event => event instanceof NavigationEnd).subscribe((event: NavigationEnd) => {
     this._router = this.router.events.filter(event => event instanceof NavigationEnd).subscribe((event: NavigationEnd) => {
       document.querySelector('.app-inner > .mat-drawer-content > div').scrollTop = 0;
       document.querySelector('.app-inner > .mat-drawer-content > div').scrollTop = 0;
       this.url = event.url;
       this.url = event.url;
@@ -53,7 +46,7 @@ export class AdminLayoutComponent implements OnInit, OnDestroy {
     });
     });
   }
   }
 
 
-  ngOnDestroy(): void  {
+  ngOnDestroy(): void {
     this._router.unsubscribe();
     this._router.unsubscribe();
   }
   }
 
 
@@ -61,7 +54,6 @@ export class AdminLayoutComponent implements OnInit, OnDestroy {
     if (this.isOver()) {
     if (this.isOver()) {
       this.sidemenu.close();
       this.sidemenu.close();
     }
     }
-
     this.updatePS();
     this.updatePS();
   }
   }
 
 
@@ -93,11 +85,15 @@ export class AdminLayoutComponent implements OnInit, OnDestroy {
     }
     }
   }
   }
 
 
-  updatePS(): void  {
+  updatePS(): void {
     if (!this.mediaMatcher.matches && !this.options.compact) {
     if (!this.mediaMatcher.matches && !this.options.compact) {
       setTimeout(() => {
       setTimeout(() => {
         this.directiveScroll.update();
         this.directiveScroll.update();
       }, 350);
       }, 350);
     }
     }
   }
   }
+
+  loginUser() {
+  }
+
 }
 }

+ 3 - 27
src/app/core/header/header.component.html

@@ -2,41 +2,17 @@
   <button (click)="toggleSidenav.emit()" mat-icon-button>
   <button (click)="toggleSidenav.emit()" mat-icon-button>
     <mat-icon>menu</mat-icon>
     <mat-icon>menu</mat-icon>
   </button>
   </button>
-
+  <div class="branding">
+  </div>
   <div class="search-bar" fxFlex>
   <div class="search-bar" fxFlex>
-    <!--    <form class="search-form" [ngStyle.xs]="{display: 'none'}">-->
-    <!--      <mat-icon>search</mat-icon>-->
-    <!--      <input type="text" placeholder="Search" autofocus="true" />-->
-    <!--    </form>-->
-
   </div>
   </div>
-  <!--  <button (click)="fullScreenToggle()" mat-icon-button>-->
-  <!--    <mat-icon>fullscreen</mat-icon>-->
-  <!--  </button>-->
-  <!--  <button (click)="toggleNotificationSidenav.emit()" mat-icon-button class="ml-xs overflow-visible">-->
-  <!--    <mat-icon>notifications</mat-icon>-->
-  <!--    <span class="notification-label">5</span>-->
-  <!--  </button>-->
-
   <button [matMenuTriggerFor]="user" mat-icon-button class="ml-xs">
   <button [matMenuTriggerFor]="user" mat-icon-button class="ml-xs">
     <mat-icon>person</mat-icon>
     <mat-icon>person</mat-icon>
   </button>
   </button>
   <mat-menu #user="matMenu" x-position="before">
   <mat-menu #user="matMenu" x-position="before">
-    <!--    <button mat-menu-item>-->
-    <!--      <mat-icon>settings</mat-icon>-->
-    <!--      Settings-->
-    <!--    </button>-->
-    <!--    <button mat-menu-item>-->
-    <!--      <mat-icon>account_box</mat-icon>-->
-    <!--      Profile-->
-    <!--    </button>-->
-    <!--    <button mat-menu-item>-->
-    <!--      <mat-icon>notifications_off</mat-icon>-->
-    <!--      Disable notifications-->
-    <!--    </button>-->
     <button mat-menu-item (click)="logout()">
     <button mat-menu-item (click)="logout()">
       <mat-icon>exit_to_app</mat-icon>
       <mat-icon>exit_to_app</mat-icon>
-      Sign Out
+      خروج
     </button>
     </button>
   </mat-menu>
   </mat-menu>
   {{ name }}
   {{ name }}

Some files were not shown because too many files changed in this diff