bsima / SuperTech

A little extension to make an RIT Desktop Support Representative's life just super.
0 stars 1 forks source link

Tcenter - Autofill new tickets #5

Open bsima opened 11 years ago

bsima commented 11 years ago

Nobody likes creating Tcenter tickets. A script can be made that pulls the requisite information from Footprints, and then enters the info into the necessary fields.

First, I will need to scrape the page with JavaScript. This can be done with pjscrape. The code should look something like this:

pjs.addSuite({
    url: 'https://footprints-ticket-page/',
    scraper: '#id-ofelement.class'
});

That's simple enough. A separate function would have to be executed for each element on the page, most likely (i.e. each pjs function would need a different scraper value), but that's no problem either. The difficult part would be figuring out how to open the proper ticket page. I think I first have to write the Footprints search before I can write the function to scrape the ticket page.


There are a few things that the Tcenter ticket requires that I cannot get from the Footprints page. In addition, I will need the Footprints ticket ID to begin with. So, when one opens the Tcenter ticket creation page, they should be greeted with a modal that guides them through the process.

<div class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="ture">&times;</button>
        <h4 class="modal-title">Autofill Tcenter Ticket</h4>
      </div>
      <div class="modal-body">
        <p>Put stuff here</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-xs btn-danger" data-dismiss="modal">No! Close without autofilling ticket :(</button>
        <button type="button" class="btn btn-lg btn-success">Yes, Autofill!</button>
      </div>
    </div>
  </div>
</div>

That's the basic code. Replace "Put stuff here" with the code for the form required info.

For some of these, we can attempt to scrape the Footprints ticket, and then ask for user input if no data is found.

Of course, there should also be a step to verify the information before submitting.

bsima commented 11 years ago

A question: How to actually open a scrape the Footprints ticket

The issue is that Footprints' authentication method is difficult to work with. The SuperDSR Jumpfield is run in a separate context from the rest of the browser pages. So, there must be some way of passing information between the extension and the Tcenter ticket pages.

Solution: Chrome Message Passing. This allows you to send a notification from a content script to the background scripts of the extension. Especially see the Long-lived connections section.

Since the we will only be passing a notification to the extension from the content script, this means that we can piggyback on the current authentication session. No need to develop a separate authentication method for SuperDSR to interface with Shibboleth or Footprints.


So, what I need to do in order to develop this feature:

  1. Create the content script as if I were writing a Greasemonkey script or something
    1. Identify that the page is https://apps.rit.edu/~a-tcent/index.php?manualTicket=true&type=2
    2. Display a button at the top of the page (for now, until I get to number 2 below)
    3. On button click, open a modal that prompts the user for the following:
      • Footprints Ticket Number
      • Description (i.e.Computer Model)
      • Task
      • Location
      • Triage (assume moderate?)
      • Problem Description
    4. Then, present a submit button that injects the form information and submits the TCenter form.
  2. Write a messaging function to notify the extension when the TCenter ticket creation page is opened
bsima commented 11 years ago

After research and a few attempts, using a modal to capture user input will prove to be a difficult way to program this. Instead, perhaps I could use jQuery to walk the user through the necessary information. Like those demos or tutorials, a field would be selected and a tooltip would instruct them what to do.