如何将Jira问题收集器与Angular应用程序集成?

时间:2019-04-22 19:18:14

标签: jquery typescript angular6 jira angular7

我希望创建一个Angular 7应用程序,该应用程序使用Jira问题收集器直接将问题提交到各自的项目。

当我以现在的方式构建应用程序时,什么也没有发生。当我将代码从方法“ submitIssue”移到“ ngOnInIt”下时,直接出现问题收集器对话框。该代码段应添加到何处?

任何帮助将不胜感激。谢谢!

吉拉代码段示例

// Requires jQuery!
jQuery.ajax({
    url: "https://<domain>.atlassian.net/s/_/download/batch/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector/com",
    type: "get",
    cache: true,
    dataType: "script"
});

 window.ATL_JQ_PAGE_PROPS =  {
    "triggerFunction": function(showCollectorDialog) {
        //Requires that jQuery is available! 
        jQuery("#myCustomTrigger").click(function(e) {
            e.preventDefault();
            showCollectorDialog();
        });
    }};

这是我的阵列,用于在问题收集器组件上用不同的项目和按钮填充卡片。

db-data.ts

export const PROJECTS: any = [

    {
        id: 1,
        title: 'Project Title',
        /** The url is taken directly from the issue collector section within the Jira project. Link below is modified
         * for security purposes. */
        url: 'https://<domain>.atlassian.net/s/_/download/batch/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector/com'
    },
    {
        id: 2,
        title: 'Project Title',
        /** The url is taken directly from the issue collector section within the Jira project. Link below is modified
         * for security purposes. */
        url: 'https://<domain>.atlassian.net/s/_/download/batch/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector/com'
    },

];


export function findCourseById(projectId:number) {
    return PROJECTS.find(project => project.id === projectId);


}

jira-card.component.ts

import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core';
import { Project } from 'src/app/model/project';
import { PROJECTS } from 'src/db-data';
import { projection } from '@angular/core/src/render3';
import * as $ from 'jquery';

declare global {
  interface Window { ATL_JQ_PAGE_PROPS: any; }
}

window.ATL_JQ_PAGE_PROPS = window.ATL_JQ_PAGE_PROPS || {};

@Component({
  selector: 'app-jira-card',
  templateUrl: './jira-card.component.html',
  styleUrls: ['./jira-card.component.scss']
})

export class JiraCardComponent implements OnInit {

  @Input()
  project: Project;

  constructor() { }

   ngOnInit() {}

   submitIssue() {

            // Requires jQuery!
            jQuery.ajax({
              url: this.project.url,
              type: 'get',
              cache: true,
              dataType: 'script'
            });

        window.ATL_JQ_PAGE_PROPS =  {
        "triggerFunction": function(showCollectorDialog) {
          jQuery("#submit").on('click', function(e) {
            e.preventDefault();
            showCollectorDialog();
          });
        }};
       }
   }


jira-card.component.html

<div class="main-div">
  <mat-card class="jira-card">
      <mat-card-header>
        <mat-card-title>{{ project.title }}</mat-card-title>
        <mat-card-subtitle></mat-card-subtitle>
      </mat-card-header>
      <mat-card-actions>
        <button mat-raised-button id (click)="submitIssue()" id="#submit">Submit Issue</button>
      </mat-card-actions>
    </mat-card>
</div>    

1 个答案:

答案 0 :(得分:0)

import java.io.BufferedReader; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.InputStreamReader; public class GaleShapley { private int N, engagedCount; private String[][] menPref; private String[][] womenPref; private String[] men; private String[] women; private String[] womenPartner; private boolean[] menEngaged; /** Constructor **/ public GaleShapley() { } public GaleShapley(String[] m, String[] w, String[][] mp, String[][] wp) { N = mp.length; engagedCount = 0; men = m; women = w; menPref = mp; womenPref = wp; menEngaged = new boolean[N]; womenPartner = new String[N]; calcMatches(); } /** function to calculate all matches **/ private void calcMatches() { while (engagedCount < N) { int free; for (free = 0; free < N; free++) if (!menEngaged[free]) break; for (int i = 0; i < N && !menEngaged[free]; i++) { int index = womenIndexOf(menPref[free][i]); if (womenPartner[index] == null) { womenPartner[index] = men[free]; menEngaged[free] = true; engagedCount++; } else { String currentPartner = womenPartner[index]; if (morePreference(currentPartner, men[free], index)) { womenPartner[index] = men[free]; menEngaged[free] = true; menEngaged[menIndexOf(currentPartner)] = false; } engagedCount++; } } } printCouples(); } /** function to check if women prefers new partner over old assigned partner **/ private boolean morePreference(String curPartner, String newPartner, int index) { for (int i = 0; i < N; i++) { if (womenPref[index][i].equals(newPartner)) return true; if (womenPref[index][i].equals(curPartner)) return false; } return false; } /** get men index **/ private int menIndexOf(String str) { for (int i = 0; i < N; i++) if (men[i].equals(str)) return i; return -1; } /** get women index **/ private int womenIndexOf(String str) { for (int i = 0; i < N; i++) { if (women[i].equals(str)) return i; } return -1; } /** print couples **/ public void printCouples() { System.out.println("Couples are : "); for (int i = 0; i < N; i++) { System.out.println(womenPartner[i] + " " + women[i]); } } /** main function **/ public static void main(String[] args) { System.out.println("Gale Shapley Marriage Algorithm\n"); /** list of men **/ String[] m = { "1", "2", "3" }; /** list of women **/ String[] w = { "1", "2", "3" }; /** men preference **/ String[][] mp = null; /** women preference **/ String[][] wp = null; try { FileInputStream fstream = new FileInputStream("C:\\Users\\Youssef\\Projects\\STS\\TEST\\src\\input"); DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; int line = 0; int n = 0; int i = 0; while ((strLine = br.readLine()) != null) { if (line == 0) { n = Integer.valueOf(strLine.trim()); mp = new String[n][n]; wp = new String[n][n]; line++; } else { if (strLine != null && !strLine.equals("") && !strLine.contains("male") && !strLine.contains("female")) { String[] preferences = strLine.split(" "); if (i < n) { mp[i] = preferences; } else { if (i - n < w.length) { wp[i - n] = preferences; } } i++; } } } in.close(); new GaleShapley(m, w, mp, wp); } catch (Exception e) {// Catch exception if any e.printStackTrace(); System.err.println("Error: " + e.getMessage()); } } } 中使showCollectorDialog函数成为全局函数

index.html

然后在<script type="text/javascript" src="<jira-issue-collector-URL>"></script> <script> window.ATL_JQ_PAGE_PROPS = { triggerFunction: function(showCollectorDialog) { window.showCollectorDialog = showCollectorDialog } }; </script> 中调用它:

some.component.ts