source: branches/1.2/workflow/js/monitors/general.js @ 1349

Revision 1349, 3.9 KB checked in by niltonneto, 15 years ago (diff)

Ticket #561 - Inclusão do módulo Workflow faltante nessa versão.

  • Property svn:executable set to *
Line 
1/* permission index */
2var IP_CHANGE_PRIORITY = 0;
3var IP_CHANGE_USER = 1;
4var IP_CHANGE_STATUS = 2;
5var IP_CHANGE_NAME = 3;
6var IP_CHANGE_ACTIVITY = 4;
7var IP_VIEW_PROPERTIES = 5;
8var IP_CHANGE_PROPERTIES = 6;
9var IP_VIEW_STATISTICS = 7;
10var IP_REMOVE_COMPLETED_INSTANCES = 8;
11var IP_REPLACE_USER = 9;
12var IP_SEND_EMAILS = 10;
13
14/* general use variables */
15var permissions;
16var statusCorrelation = new Array();
17var statusQuickTranslation = new Array();
18for (var k = 0; k < 4; k++)
19        statusCorrelation[k] = new Array();
20statusCorrelation[0]['id'] = 'completed';
21statusCorrelation[0]['name'] = 'completada';
22statusCorrelation[1]['id'] = 'active';
23statusCorrelation[1]['name'] = 'ativa';
24statusCorrelation[2]['id'] = 'aborted';
25statusCorrelation[2]['name'] = 'abortada';
26statusCorrelation[3]['id'] = 'exception';
27statusCorrelation[3]['name'] = 'em exceção';
28
29for (var k = 0; k < 4; k++)
30        statusQuickTranslation[statusCorrelation[k]['id']] = statusCorrelation[k]['name'];
31
32/* constrói tabelas */
33function 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 */
74function 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 */
91function 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 */
121function 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 */
133function 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 */
148function 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
158Event.observe(window, 'load', function() {
159        initMonitoringInterface();
160});
Note: See TracBrowser for help on using the repository browser.