diff --git a/core/catalog.go b/core/catalog.go index 7ef5940..d760e5a 100644 --- a/core/catalog.go +++ b/core/catalog.go @@ -372,6 +372,9 @@ func (c *Catalog) ListRequest(query string) ([]TransferRequest, error) { case "error": stm := getSQL("request_by_status") // Error occured while transfering data rows, err = DB.Query(stm, query) + case "processing": + stm := getSQL("request_by_status") // Error occured while transfering data + rows, err = DB.Query(stm, query) default: return nil, errors.New("Requested request type could not find") } diff --git a/html/index.html b/html/index.html deleted file mode 100644 index 05c9ee7..0000000 --- a/html/index.html +++ /dev/null @@ -1,131 +0,0 @@ - -
Transfer portal
- - - - - - - - diff --git a/html/main.css b/html/main.css new file mode 100644 index 0000000..8e905b8 --- /dev/null +++ b/html/main.css @@ -0,0 +1,134 @@ +/* -------------------------------------------------- + :: General + -------------------------------------------------- */ +body { + font-family: 'Open Sans', sans-serif; + color: #353535; +} +.content h1 { + text-align: center; +} +.content .content-footer p { + color: #6d6d6d; + font-size: 12px; + text-align: center; +} +.content .content-footer p a { + color: inherit; + font-weight: bold; +} + +/* -------------------------------------------------- + :: Table Filter + -------------------------------------------------- */ +.panel { + border: 1px solid #ddd; + background-color: #fcfcfc; +} +.panel .btn-group { + margin: 15px 0 30px; +} +.panel .btn-group .btn { + transition: background-color .3s ease; +} +.table-filter { + background-color: #fff; + border-bottom: 1px solid #eee; +} +.table-filter tbody tr td { + padding: 10px; + vertical-align: middle; + border-top-color: #eee; +} +.reqdiv:hover { + cursor: pointer; + background-color: #eee; +} +.table-filter tbody tr.selected td { + background-color: #eee; +} +.table-filter tr td:first-child { + width: 38px; +} +.table-filter tr td:nth-child(2) { + width: 35px; +} +.ckbox { + position: relative; +} +.ckbox input[type="checkbox"] { + opacity: 0; +} +.ckbox label { + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} +.ckbox label:before { + content: ''; + top: 1px; + left: 0; + width: 18px; + height: 18px; + display: block; + position: absolute; + border-radius: 2px; + border: 1px solid #bbb; + background-color: #fff; +} +.ckbox input[type="checkbox"]:checked + label:before { + border-color: #2BBCDE; + background-color: #2BBCDE; +} +.ckbox input[type="checkbox"]:checked + label:after { + top: 3px; + left: 3.5px; + content: '\e013'; + color: #fff; + font-size: 11px; + font-family: 'Glyphicons Halflings'; + position: absolute; +} +.table-filter .star { + color: #ccc; + text-align: center; + display: block; +} +.table-filter .star.star-checked { + color: #F0AD4E; +} +.table-filter .media-photo { + width: 35px; +} +.table-filter .media-body { + display: block; + /* Had to use this style to force the div to expand (wasn't necessary with my bootstrap version 3.3.6) */ +} +.table-filter .media-meta { + font-size: 11px; + color: #999; +} +.table-filter .media .title { + color: #2BBCDE; + font-size: 14px; + font-weight: bold; + line-height: normal; + margin: 0; +} +.table-filter .media .title span { + font-size: .8em; + margin-right: 20px; +} +.table-filter .media .title span.pagado { + color: #5cb85c; +} +.table-filter .media .title span.pendiente { + color: #f0ad4e; +} +.table-filter .media .title span.cancelado { + color: #d9534f; +} +.table-filter .media .summary { + font-size: 14px; +} diff --git a/html/main.html b/html/main.html new file mode 100644 index 0000000..da69fc5 --- /dev/null +++ b/html/main.html @@ -0,0 +1,38 @@ + +
Transfer portal
+ + + + + +
+
+
+

Requests

+
+
+
+
+
+ + + + + +
+
+
+
+ + +
+ + + + +
+ +
+ + + diff --git a/html/main.js b/html/main.js new file mode 100644 index 0000000..7323f3a --- /dev/null +++ b/html/main.js @@ -0,0 +1,100 @@ +var HttpClient = function() { + + this.get = function(aUrl, aCallback) { + var anHttpRequest = new XMLHttpRequest(); + anHttpRequest.onreadystatechange = function() { + if (anHttpRequest.readyState == 4 && anHttpRequest.status == 200) + aCallback(anHttpRequest.responseText); + } + anHttpRequest.open( "GET", aUrl, true ); + anHttpRequest.send( null ); + } + + this.post = function(aUrl, body, aCallback) { + var anHttpRequest = new XMLHttpRequest(); + anHttpRequest.onreadystatechange = function() { + if (anHttpRequest.readyState == 4 && anHttpRequest.status == 200) + aCallback(anHttpRequest.responseText); + } + anHttpRequest.open( "POST", aUrl, true ); + anHttpRequest.setRequestHeader("Content-Type", "application/json"); + anHttpRequest.send( JSON.stringify(body) ); + } +} + +var client = new HttpClient(); + +$(document).ready(function () { + + renderRequest("pending"); + + $('.rsubmit').on('click', function () { + var $table = $('table'); + var actionArr = []; + $('table tr').each(function() { + var id = $(this).find(".id").html(); + var action = $(this).find(".action").val(); + console.log("action" + action) + if(action=="transfer"){ + actionArr.push({ + action: "pull" + action, // TODO: make it configurable. + request: {id: parseInt(id)} + }); + }else if(action=="delete"){ + actionArr.push({ + action: action, + request: {id: parseInt(id)} + }); + }else{ + console.log(action); + } + }); + if(actionArr.length>0) { + client.post('http://'+window.location.host+'/action', actionArr, function(response) { + console.log(response) + }) + } + }); + + $('.btn-filter').on('click', function () { + var $target = $(this).data('target'); + renderRequest($target); + }) +}); + +function renderRequest(type) { + client.get('http://' + window.location.host + '/list?type=' + type, function(response) { + var tRequests = JSON.parse(response); + $('.table tr').css('display', 'none'); + $('.table tr').remove() + $.each(tRequests, function(index) { + var rid = 'request-'+tRequests[index].id; + var html = '
'; + html += 'Request: '+tRequests[index].id+' '; + html += 'Status: '+tRequests[index].status+' '; + html += 'Priority: '+tRequests[index].priority+' '; + html += '
' + html += ''; + html += '' + html += '
'; + html += 'Source: '+tRequests[index].srcUrl+' 
'; + html += 'Dest: '+tRequests[index].dstUrl+' 
'; + html += 'Block: '+tRequests[index].block+' 
'; + html += 'Dataset: '+tRequests[index].dataset+' 
'; + html += 'File: '+tRequests[index].file; + html += '
' + tRow = $(''); + tRow.append(html) + $('table').append(tRow); + }); + }); +} + +function genColor(s) { + var color = '#'+s.toString().substr(0,6); + return color; +} diff --git a/server/handlers.go b/server/handlers.go index 383252b..f2a6e93 100644 --- a/server/handlers.go +++ b/server/handlers.go @@ -350,6 +350,7 @@ func ActionHandler(w http.ResponseWriter, r *http.Request) { // Push the job onto the queue. core.TransferQueue <- job } + w.WriteHeader(http.StatusOK) } // TFCHandler registers given record in local TFC diff --git a/server/server.go b/server/server.go index 9c88f81..14d5609 100644 --- a/server/server.go +++ b/server/server.go @@ -207,11 +207,11 @@ func Server(config Config) { // define handlers http.HandleFunc(fmt.Sprintf("%s/", base), AuthHandler) - http.Handle("/index/", http.StripPrefix("/index/",http.FileServer(http.Dir("html")))) + http.Handle("/html/", http.StripPrefix("/html/",http.FileServer(http.Dir("html")))) // initialize transfer model core.TransferType = config.Type - + // initialize job queues core.InitQueue(config.QueueSize, config.QueueSize, config.Mfile, config.Minterval)