import { Input, Output, Component } from 'angular-ts-decorators'; @Component({ selector: 'manageTriggerGithost', templateUrl: '/static/js/directives/ui/manage-trigger-githost/manage-trigger-githost.component.html' }) export class ManageTriggerGithostComponent implements ng.IComponentController { @Input('=') public repository: any; @Input('=') public trigger: Trigger; @Output() public activateTrigger: (trigger: {config: any, pull_robot: any}) => void; private config: any; private local: Local = { namespaceOptions: { filter: '', predicate: 'score', reverse: false, page: 0 }, repositoryOptions: { filter: '', predicate: 'score', reverse: false, page: 0, hideStale: true }, robotOptions: { filter: '', predicate: 'score', reverse: false, page: 0 } }; private currentState: any | null; private namespacesPerPage: number = 10; private repositoriesPerPage: number = 10; private robotsPerPage: number = 10; constructor(private ApiService: any, private TableService: any, private TriggerService: any, private RolesService: any) { } public $onInit(): void { } public $onChanges(changes: ng.IOnChangesObject): void { } public getTriggerIcon(): any { return this.TriggerService.getIcon(this.trigger.service); } public createTrigger(): void { var config: any = { build_source: this.local.selectedRepository.full_name, subdir: this.local.dockerfilePath.substr(1) // Remove starting / }; if (this.local.triggerOptions.hasBranchTagFilter && this.local.triggerOptions.branchTagFilter) { config['branchtag_regex'] = this.local.triggerOptions.branchTagFilter; } var activate = () => { this.activateTrigger({'config': config, 'pull_robot': this.local.robotAccount}); }; if (this.local.robotAccount) { if (this.local.robotAccount.can_read) { activate(); } else { // Add read permission onto the base repository for the robot and then activate the // trigger. var robot_name = this.local.robotAccount.name; this.RolesService.setRepositoryRole(this.repository, 'read', 'robot', robot_name, activate); } } else { activate(); } } private buildOrderedNamespaces(): void { } private loadNamespaces(): void { } private buildOrderedRepositories(): void { } private loadRepositories(): void { } private loadRepositoryRefs(repository: any): void { } private loadDockerfileLocations(repository: any): void { } private buildOrderedRobotAccounts(): void { } private checkDockerfilePath(repository: any, path: string): void { } } export type Local = { namespaceOptions: { filter: string; predicate: string; reverse: boolean; page: number; }; repositoryOptions: { filter: string; predicate: string; reverse: boolean; page: number; hideStale: boolean; }; robotOptions: { filter: string; predicate: string; reverse: boolean; page: number; }; } export type Trigger = { id: number; service: any; }