• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

TypeScript global.service.GlobalService类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中app/services/global.service.GlobalService的典型用法代码示例。如果您正苦于以下问题:TypeScript service.GlobalService类的具体用法?TypeScript service.GlobalService怎么用?TypeScript service.GlobalService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了service.GlobalService类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: addAdmin

  addAdmin(newEmail: string, newRole: string) {
    if (newEmail && newRole) {

      this.db.object('/admins/' + this.globalService.hashCode(newEmail)).update({
        email: newEmail,
        role: newRole
      });

      this.newEmail = null;
      this.newRole = null;

      let snackBarRef = this.snackBar.open('Admin saved', 'OK!', {
        duration: 3000
      });

    } else if (!newEmail) {
      let snackBarRef = this.snackBar.open('You must add an email for the user', 'OK!', {
        duration: 3000
      });
    } else if (!newRole) {
      let snackBarRef = this.snackBar.open('You must add a role for the user', 'OK!', {
        duration: 3000
      });
    }
  }
开发者ID:mogeta,项目名称:firebase-cms,代码行数:25,代码来源:add-admin.component.ts


示例2:

 this.user.subscribe(currentUser => {
   if (!currentUser) {
     this.router.navigateByUrl('login');
   } else {
     this.db.object('/admins/' + this.globalService.hashCode(currentUser.email)).valueChanges().subscribe((a:any) => {
       if (a && a.email) {
         this.globalService.admin.next(currentUser);
         this.db.object('/admins/' + currentUser.uid).valueChanges().subscribe((a:any) => {
           this.globalService.admin.next(a);
           this.currentAdmin.role = a.role;
         });
       } else {
         this.router.navigateByUrl('');
         let snackBarRef = this.snackBar.open('You are not an authorized administrator', 'OK!', {
           duration: 3000
         });
       }
     }, (err) => {
       console.log('Permission Error', err);
       this.router.navigateByUrl('');
       let snackBarRef = this.snackBar.open('You are not an authorized administrator', 'OK!', {
         duration: 3000
       });
     });
   }
 });
开发者ID:mogeta,项目名称:firebase-cms,代码行数:26,代码来源:admin.component.ts


示例3: addCategory

  addCategory(newName: string, newWeight: number) {
    if (newName) {
      let categoryObject = {
        name: newName,
        weight: newWeight,
        slug: this.globalService.slugify(newName),
        dateUpdated: Date.now().toString(),
        rdateUpdated: (Date.now() * -1).toString(),
        updatedBy: this.currentAdmin.uid,
        entityKey: this.editMode && this.categoryKey ? this.categoryKey : null,
        products: this.newProducts ? this.newProducts : null
      };

      if (this.editMode && this.categoryKey) {
        this.db.object('/categories/' + this.categoryKey).update(categoryObject);
      } else {
        this.categories.push(categoryObject).then((item) => {
          this.db.object('/categories/' + item.key + '/entityKey').set(item.key);
        });
      }

      let snackBarRef = this.snackBar.open('Category saved', 'OK!', {
        duration: 3000
      });

    }
    this.validateFields(newName);
  }
开发者ID:mogeta,项目名称:firebase-cms,代码行数:28,代码来源:add-product-category.component.ts


示例4: submitForModeration

  submitForModeration(newTitle: string, newPrice: string, newCategory: any, newWeight: number, newDescription: string, newPublished: boolean) {
    if (!newPublished) {
      newPublished = false;
    }

    if (newTitle && newPrice && newDescription && this.currentAdmin.uid) {

      let approvalObject = {
        entityKey: this.router.url.includes('approval') ? this.entityObject.entityKey : this.productKey,
        url: this.globalService.slugify(newTitle),
        dateUpdated: Date.now().toString(),
        rdateUpdated: (Date.now() * -1).toString(),
        title: newTitle,
        thumbnail: this.newThumbnail ? this.newThumbnail : null,
        description: newDescription,
        price: newPrice,
        published: newPublished,
        weight: newWeight,
        updatedBy: this.currentAdmin.uid,
        category: newCategory ? newCategory : null
      };

      if (this.editMode && this.productKey) {

        this.currentModeratedProducts = this.db.list('/approvals/products/');

        let adminApprovalProducts = this.db.list('/approvals/products/', ref => ref.orderByChild('updatedBy').equalTo(this.currentAdmin.uid)).valueChanges();
        adminApprovalProducts.take(1).subscribe((approvals:any) => {

          let matchingApprovals = [];
          if (this.router.url.includes('approval')) {
            matchingApprovals = approvals.filter((match) => {
              return match.entityKey === this.entityObject.entityKey;
            });
          } else {
            matchingApprovals = approvals.filter((match) => {
              return match.entityKey === this.productKey;
            });
          }

          if (matchingApprovals.length === 0 || !this.router.url.includes('approval')) {
            this.currentModeratedProducts.push(approvalObject);
          } else {
            this.db.object('/approvals/products/' + this.productKey).update(approvalObject);
          }
        });
      } else {
          this.db.list('/approvals/products/').push(approvalObject);
      }
      let snackBarRef = this.snackBar.open('Product submitted for moderation', 'OK!', {
        duration: 3000
      });
      snackBarRef.onAction().subscribe(() => {
        this.router.navigateByUrl('admin/approvals');
      });
    }

    this.validateFields(newTitle, newDescription, newPrice);
  }
开发者ID:mogeta,项目名称:firebase-cms,代码行数:59,代码来源:add-product.component.ts


示例5: confirm

 confirm() {
   this.submitNewCharge();
   let newKey = Math.abs(this.globalService.hashCode(this.order.date) + this.globalService.hashCode(this.order.shipping.email));
   this.db.list('/orders').push(this.order).then((item) => {
     this.globalService.cart.next(null);
     this.globalService.order.next(null);
     this.localCart.clearAll();
     if (this.user) {
       this.db.object('/users/' + this.user.uid + '/cart').remove();
       this.db.object('/users/' + this.user.uid + '/orders/' + item.key).set(Date.now().toString());
     }
     this.router.navigateByUrl('checkout/confirmation');
   });
 }
开发者ID:mogeta,项目名称:firebase-cms,代码行数:14,代码来源:checkout-review.component.ts


示例6: submitForModeration

  submitForModeration(newName: string, newWeight: number) {
    if (newName && this.currentAdmin.uid) {

      let approvalObject = {
        entityKey: this.router.url.includes('approval') ? this.entityObject.entityKey : this.categoryKey,
        name: newName,
        weight: newWeight,
        slug: this.globalService.slugify(newName),
        dateUpdated: Date.now().toString(),
        rdateUpdated: (Date.now() * -1).toString(),
        updatedBy: this.currentAdmin.uid,
        products: this.newProducts ? this.newProducts : null
      };

      if (this.editMode && this.categoryKey) {
        this.currentModeratedCategories = this.db.list('/approvals/categories/');

        let adminApprovalCategories = this.db.list('/approvals/categories/', ref => ref.orderByChild('updatedBy').equalTo(this.currentAdmin.uid)).valueChanges();

        adminApprovalCategories.take(1).subscribe((approvals:any) => {
          let matchingApprovals = [];
          if (this.router.url.includes('approval')) {
            matchingApprovals = approvals.filter((match) => {
              return match.entityKey === this.entityObject.entityKey;
            });
          } else {
            matchingApprovals = approvals.filter((match) => {
              return match.entityKey === this.categoryKey;
            });
          }

          if (matchingApprovals.length === 0 || !this.router.url.includes('approval')) {
            this.currentModeratedCategories.push(approvalObject);
          } else {
            this.db.object('/approvals/categories/' + this.categoryKey).update(approvalObject);
          }
        });
      } else {
          this.db.list('/approvals/categories/').push(approvalObject);
      }
      let snackBarRef = this.snackBar.open('Category submitted for moderation', 'OK!', {
        duration: 3000
      });
      snackBarRef.onAction().subscribe(() => {
        this.router.navigateByUrl('admin/approvals');
      });
    }

    this.validateFields(newName);
  }
开发者ID:mogeta,项目名称:firebase-cms,代码行数:50,代码来源:add-product-category.component.ts


示例7: addProduct

  addProduct(newTitle: string, newPrice: string, newCategory: any, newWeight: number, newDescription: string, newPublished: boolean) {
    if (!newPublished) {
      newPublished = false;
    }

    if (newTitle && newPrice && newDescription && this.currentAdmin.uid) {

      let productObject = {
        url: this.globalService.slugify(newTitle),
        dateUpdated: Date.now().toString(),
        rdateUpdated: (Date.now() * -1).toString(),
        title: newTitle,
        thumbnail: this.newThumbnail ? this.newThumbnail : null,
        description: newDescription,
        price: newPrice,
        published: newPublished,
        updatedBy: this.currentAdmin.uid,
        weight: newWeight,
        category: newCategory ? newCategory : null,
        entityKey: this.editMode && this.productKey ? this.productKey : null
      };

      // if (this.imageUrl && !this.newThumbnail) {
      //   this.deleteImageRef();
      // }

      if (this.editMode && this.productKey) {
        this.currentProduct = this.db.object('/products/' + this.productKey);
        this.currentProduct.update(productObject);
        this.updateCategory(this.ogCategory, this.newCategory, this.productKey);
      } else {
        this.products.push(productObject).then((item) => {
          if (this.newCategory) {
            this.db.object('/products/' + item.key + '/entityKey').set(item.key);
            this.db.object('/categories/' + this.newCategory + '/products/' + item.key).set(Date.now().toString());
          }
        });
      }

      let snackBarRef = this.snackBar.open('Product saved', 'OK!', {
        duration: 3000
      });
    }

    this.validateFields(newTitle, newDescription, newPrice);
  }
开发者ID:mogeta,项目名称:firebase-cms,代码行数:46,代码来源:add-product.component.ts



注:本文中的app/services/global.service.GlobalService类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap