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

TypeScript operator.service.OperatorService类代码示例

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

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



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

示例1: login

 /**
  * Try to log in a user.
  *
  * Returns an observable with the correct login information or an error.
  * errors will be forwarded to the parents error function.
  *
  * @param username
  * @param password
  * @returns The login response.
  */
 public async login(username: string, password: string, earlySuccessCallback: () => void): Promise<WhoAmI> {
     const user = {
         username: username,
         password: password
     };
     const response = await this.http.post<WhoAmI>(environment.urlPrefix + '/users/login/', user);
     earlySuccessCallback();
     await this.operator.setWhoAmI(response);
     await this.redirectUser(response.user_id);
     return response;
 }
开发者ID:CatoTH,项目名称:OpenSlides,代码行数:21,代码来源:auth.service.ts


示例2: logout

 /**
  * Logout function for both the client and the server.
  *
  * Will clear the datastore, update the current operator and
  * send a `post`-request to `/apps/users/logout/'`. Restarts OpenSlides.
  */
 public async logout(): Promise<void> {
     let response = null;
     try {
         response = await this.http.post<WhoAmI>(environment.urlPrefix + '/users/logout/', {});
     } catch (e) {
         // We do nothing on failures. Reboot OpenSlides anyway.
     }
     await this.DS.clear();
     await this.operator.setWhoAmI(response);
     await this.OpenSlides.reboot();
     this.router.navigate(['/']);
 }
开发者ID:CatoTH,项目名称:OpenSlides,代码行数:18,代码来源:auth.service.ts


示例3: toggleElected

    /**
     * Mark/unmark an option as elected
     *
     * @param option
     */
    public toggleElected(option: ViewAssignmentPollOption): void {
        if (!this.operator.hasPerms('assignments.can_manage')) {
            return;
        }

        // TODO additional conditions: assignment not finished?
        const viewAssignmentRelatedUser = this.assignment.assignmentRelatedUsers.find(
            user => user.user_id === option.user_id
        );
        if (viewAssignmentRelatedUser) {
            this.assignmentRepo.markElected(viewAssignmentRelatedUser, this.assignment, !option.is_elected);
        }
    }
开发者ID:CatoTH,项目名称:OpenSlides,代码行数:18,代码来源:assignment-poll.component.ts


示例4: isAllowed

 /**
  * Determine if the user (Operator) has the correct permission to perform the given action.
  *
  * actions might be:
  * - create
  * - support
  * - unsupport
  * - createpoll
  * - update
  * - update_submitters
  * - delete
  * - change_metadata
  * - reset_state
  * - change_recommendation
  * - can_create_amendments
  * - can_manage_metadata
  * - manage
  *
  * @param action the action the user tries to perform
  * @param motion the motion for which to perform the action
  */
 public isAllowed(action: string, motion?: ViewMotion): boolean {
     switch (action) {
         case 'create': {
             return this.operator.hasPerms('motions.can_create');
         }
         case 'support': {
             if (!motion || !motion.state) {
                 return false;
             }
             return (
                 this.operator.hasPerms('motions.can_support') &&
                 this.configMinSupporters > 0 &&
                 motion.state &&
                 motion.state.allow_support &&
                 motion.submitters &&
                 motion.submitters.indexOf(this.operator.viewUser) === -1 &&
                 motion.supporters &&
                 motion.supporters.indexOf(this.operator.viewUser) === -1
             );
         }
         case 'unsupport': {
             if (!motion) {
                 return false;
             }
             return (
                 motion.state &&
                 motion.state.allow_support &&
                 motion.supporters &&
                 motion.supporters.indexOf(this.operator.viewUser) !== -1
             );
         }
         case 'createpoll': {
             if (!motion) {
                 return false;
             }
             return (
                 (this.operator.hasPerms('motions.can_manage') ||
                     this.operator.hasPerms('motions.can_manage_metadata')) &&
                 motion.state &&
                 motion.state.allow_create_poll
             );
         }
         case 'update': {
             // check also for empty ViewMotion object (e.g. if motion.id is null)
             // important for creating new motion as normal user
             if (!motion || !motion.id) {
                 return false;
             }
             return (
                 this.operator.hasPerms('motions.can_manage') ||
                 (motion.state &&
                     motion.state.allow_submitter_edit &&
                     motion.submitters &&
                     motion.submitters.length &&
                     motion.submitters.some(submitter => submitter.id === this.operator.user.id))
             );
         }
         case 'update_submitters': {
             return this.operator.hasPerms('motions.can_manage');
         }
         case 'delete': {
             if (!motion) {
                 return false;
             }
             return (
                 this.operator.hasPerms('motions.can_manage') &&
                 motion.state &&
                 motion.state.allow_submitter_edit &&
                 motion.submitters &&
                 motion.submitters.length &&
                 motion.submitters.some(submitter => submitter.id === this.operator.user.id)
             );
         }
         case 'change_state': {
             // check also for empty ViewMotion object (e.g. if motion.id is null)
             // important for creating new motion as normal user
             if (!motion || !motion.id) {
                 return false;
             }
//.........这里部分代码省略.........
开发者ID:jwinzer,项目名称:OpenSlides,代码行数:101,代码来源:local-permissions.service.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript projector.service.ProjectorService类代码示例发布时间:2022-05-25
下一篇:
TypeScript http.service.HttpService类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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