[795] | 1 | /* permission index */ |
---|
| 2 | var IP_CHANGE_PRIORITY = 0; |
---|
| 3 | var IP_CHANGE_USER = 1; |
---|
| 4 | var IP_CHANGE_STATUS = 2; |
---|
| 5 | var IP_CHANGE_NAME = 3; |
---|
| 6 | var IP_CHANGE_ACTIVITY = 4; |
---|
| 7 | var IP_VIEW_PROPERTIES = 5; |
---|
| 8 | var IP_CHANGE_PROPERTIES = 6; |
---|
| 9 | var IP_VIEW_STATISTICS = 7; |
---|
| 10 | var IP_REMOVE_COMPLETED_INSTANCES = 8; |
---|
| 11 | var IP_REPLACE_USER = 9; |
---|
| 12 | var IP_SEND_EMAILS = 10; |
---|
| 13 | |
---|
| 14 | /* general use variables */ |
---|
| 15 | var permissions; |
---|
| 16 | var statusCorrelation = new Array(); |
---|
| 17 | var statusQuickTranslation = new Array(); |
---|
| 18 | for (var k = 0; k < 4; k++) |
---|
| 19 | statusCorrelation[k] = new Array(); |
---|
| 20 | statusCorrelation[0]['id'] = 'completed'; |
---|
| 21 | statusCorrelation[0]['name'] = 'completada'; |
---|
| 22 | statusCorrelation[1]['id'] = 'active'; |
---|
| 23 | statusCorrelation[1]['name'] = 'ativa'; |
---|
| 24 | statusCorrelation[2]['id'] = 'aborted'; |
---|
| 25 | statusCorrelation[2]['name'] = 'abortada'; |
---|
| 26 | statusCorrelation[3]['id'] = 'exception'; |
---|
| 27 | statusCorrelation[3]['name'] = 'em exceção'; |
---|
| 28 | |
---|
| 29 | for (var k = 0; k < 4; k++) |
---|
| 30 | statusQuickTranslation[statusCorrelation[k]['id']] = statusCorrelation[k]['name']; |
---|
| 31 | |
---|
| 32 | /* constrói tabelas */ |
---|
| 33 | function constructTable(header, content, atributes) |
---|
| 34 | { |
---|
| 35 | /*** constrói a tabela ***/ |
---|
| 36 | var table = document.createElement("TABLE"); |
---|
| 37 | /* configura a tabela */ |
---|
| 38 | if (atributes) |
---|
| 39 | for (var i = 0; i < atributes.length; i++) |
---|
| 40 | table.setAttribute(atributes[i].key, atributes[i].value); |
---|
| 41 | var tbody = document.createElement("TBODY"); |
---|
| 42 | var tr; |
---|
| 43 | var td; |
---|
| 44 | |
---|
| 45 | /* cabeçalho */ |
---|
| 46 | tr = document.createElement("TR"); |
---|
| 47 | for (var j = 0; j < header.length; j++) |
---|
| 48 | { |
---|
| 49 | td = document.createElement("TH"); |
---|
| 50 | td.innerHTML = header[j].name; |
---|
| 51 | tr.appendChild(td); |
---|
| 52 | } |
---|
| 53 | tbody.appendChild(tr); |
---|
| 54 | /* elementos da tabela */ |
---|
| 55 | for (var i = 0; i < content.length; i++) |
---|
| 56 | { |
---|
| 57 | tr = document.createElement("TR"); |
---|
| 58 | if (content[i]['id']) |
---|
| 59 | tr.setAttribute('id', content[i]['id']); |
---|
| 60 | for (var j = 0; j < header.length; j++) |
---|
| 61 | { |
---|
| 62 | td = document.createElement("TD"); |
---|
| 63 | td.innerHTML = content[i][header[j].id]; |
---|
| 64 | tr.appendChild(td); |
---|
| 65 | } |
---|
| 66 | tbody.appendChild(tr); |
---|
| 67 | } |
---|
| 68 | table.appendChild(tbody); |
---|
| 69 | |
---|
| 70 | return table; |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | /* constrói select boxes */ |
---|
| 74 | function constructSelectBox(name, items, selected) |
---|
| 75 | { |
---|
| 76 | var output = ''; |
---|
| 77 | |
---|
| 78 | output = '<select name=\"' + name + '\" id=\"' + name + '\">'; |
---|
| 79 | for (var i = 0; i < items.length; i++) |
---|
| 80 | { |
---|
| 81 | output += '<option value=\"' + items[i]['id'] + '\"'; |
---|
| 82 | output += ((items[i]['id'] == selected) ? ' selected' : '') + '>'; |
---|
| 83 | output += items[i]['name'] + '</option>'; |
---|
| 84 | } |
---|
| 85 | output += '</select>'; |
---|
| 86 | |
---|
| 87 | return output; |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | /* constrói o esqueleto da interface */ |
---|
| 91 | function buildProcessInterface() |
---|
| 92 | { |
---|
| 93 | var divContent = document.getElementById('content_id_0'); |
---|
| 94 | var center = document.createElement("CENTER"); |
---|
| 95 | var table = document.createElement("TABLE"); |
---|
| 96 | var tbody = document.createElement("TBODY"); |
---|
| 97 | var tr = document.createElement("TR"); |
---|
| 98 | var td1 = document.createElement("TD"); |
---|
| 99 | var td2 = document.createElement("TD"); |
---|
| 100 | var div = document.createElement("DIV"); |
---|
| 101 | var h2 = document.createElement("H2"); |
---|
| 102 | |
---|
| 103 | table.setAttribute('class', 'container'); |
---|
| 104 | table.setAttribute('className', 'container'); /* required for IE */ |
---|
| 105 | h2.innerHTML = "Processos"; |
---|
| 106 | td1.setAttribute('id', 'divProcess'); |
---|
| 107 | td2.setAttribute('id', 'divOptions'); |
---|
| 108 | div.setAttribute('id', 'divInstance'); |
---|
| 109 | tr.appendChild(td1); |
---|
| 110 | tr.appendChild(td2); |
---|
| 111 | tbody.appendChild(tr); |
---|
| 112 | table.appendChild(tbody); |
---|
| 113 | center.appendChild(h2); |
---|
| 114 | center.appendChild(table); |
---|
| 115 | center.appendChild(div); |
---|
| 116 | |
---|
| 117 | divContent.appendChild(center); |
---|
| 118 | } |
---|
| 119 | |
---|
| 120 | /* gerencia possíveis erros oriundos do método chamado pelo Ajax */ |
---|
| 121 | function handleError(data) |
---|
| 122 | { |
---|
| 123 | if (typeof(data) == "string") |
---|
| 124 | { |
---|
| 125 | write_errors(data); |
---|
| 126 | return false; |
---|
| 127 | } |
---|
| 128 | else |
---|
| 129 | return true; |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | /* gerencia a mudança de aba */ |
---|
| 133 | function changeFolder(index) |
---|
| 134 | { |
---|
| 135 | if (alternate_border(index) == 0) |
---|
| 136 | { |
---|
| 137 | switch (index) |
---|
| 138 | { |
---|
| 139 | case 0: |
---|
| 140 | buildProcessInterface(); |
---|
| 141 | listProcesses(); |
---|
| 142 | break; |
---|
| 143 | } |
---|
| 144 | } |
---|
| 145 | } |
---|
| 146 | |
---|
| 147 | /* inicia a interface */ |
---|
| 148 | function initMonitoringInterface() |
---|
| 149 | { |
---|
| 150 | initBorders(1); |
---|
| 151 | |
---|
| 152 | var main_body = document.getElementById("main_body"); |
---|
| 153 | main_body.style.display = ''; |
---|
| 154 | |
---|
| 155 | changeFolder(0); |
---|
| 156 | } |
---|
| 157 | |
---|
| 158 | Event.observe(window, 'load', function() { |
---|
| 159 | initMonitoringInterface(); |
---|
| 160 | }); |
---|