From b2a8f5b6cf0bd826151b23beaade6cc024c96d24 Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Sun, 23 Sep 2012 13:39:57 -0500
Subject: supplemental-web/xymon:  When restoring the database from the webui,
 prompt to make sure it's really what the user wants. Also limit db dropdown
 to 30 entries

---
 abs/core/supplemental-web/PKGBUILD            |   2 +-
 abs/core/supplemental-web/contents/back.png   | Bin 0 -> 3133 bytes
 abs/core/supplemental-web/contents/go.png     | Bin 0 -> 2471 bytes
 abs/core/supplemental-web/contents/process.py |   6 +-
 abs/core/xymon/PKGBUILD                       |   4 +-
 abs/core/xymon/hbnotes.py                     | 142 ++++++++++++++++++--------
 6 files changed, 105 insertions(+), 49 deletions(-)
 create mode 100644 abs/core/supplemental-web/contents/back.png
 create mode 100644 abs/core/supplemental-web/contents/go.png

diff --git a/abs/core/supplemental-web/PKGBUILD b/abs/core/supplemental-web/PKGBUILD
index afbf678..573278d 100644
--- a/abs/core/supplemental-web/PKGBUILD
+++ b/abs/core/supplemental-web/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=supplemental-web
 pkgver=1.0
-pkgrel=26
+pkgrel=27
 arch=('i686' 'x86_64')
 MVDIR=$startdir/pkg/usr/MythVantage
 install=supplemental-web.install
diff --git a/abs/core/supplemental-web/contents/back.png b/abs/core/supplemental-web/contents/back.png
new file mode 100644
index 0000000..6b5da48
Binary files /dev/null and b/abs/core/supplemental-web/contents/back.png differ
diff --git a/abs/core/supplemental-web/contents/go.png b/abs/core/supplemental-web/contents/go.png
new file mode 100644
index 0000000..c70bf2a
Binary files /dev/null and b/abs/core/supplemental-web/contents/go.png differ
diff --git a/abs/core/supplemental-web/contents/process.py b/abs/core/supplemental-web/contents/process.py
index f6c6db1..22ffb0f 100644
--- a/abs/core/supplemental-web/contents/process.py
+++ b/abs/core/supplemental-web/contents/process.py
@@ -297,7 +297,11 @@ if __name__ == '__main__':
         print line + '</br> \r\n'
 
     print endbox
-    print '<a href=',  oldurl,     '  > Back </a> '
+    print "</br></br>"
+    #print '<a href=',  oldurl,     '  > Back </a> '
+    s='<a href="%s"><img src="back.png"></a>' %oldurl
+    print s
+    #<a href="myfile.htm"><img src="rainbow.gif"></a>
     #print oldurl
     print javascript
 
diff --git a/abs/core/xymon/PKGBUILD b/abs/core/xymon/PKGBUILD
index b68d1fe..8247592 100755
--- a/abs/core/xymon/PKGBUILD
+++ b/abs/core/xymon/PKGBUILD
@@ -1,7 +1,7 @@
 pkgbase=xymon
 pkgname=(xymonserver xymonclient)
 pkgver=4.3.5
-pkgrel=33
+pkgrel=35
 pkgdesc="Hobbit is a system for monitoring servers and networks. "
 license="GPL"
 arch=('i686' 'x86_64')
@@ -119,7 +119,7 @@ md5sums=('31923ec126fe1c264fceb459d2175161'
          '2d88e59ab17114030da514ba3f0a5b64'
          'ee608dcafc050d790e28647a670f6b60'
          'b2f98ac0df013332deedc1efae0a270d'
-         '94e561bc2d9ba5755f04ed642485e83b'
+         '69439732c9f81c663d1cdd65be453631'
          '0f70e76a164f648f0a4a01110137cb20'
          'f6921f0413215ae174e81306be80d37f'
          '54ba9d7bff5875150e511c608ffc1e6a'
diff --git a/abs/core/xymon/hbnotes.py b/abs/core/xymon/hbnotes.py
index 6751865..78145f2 100644
--- a/abs/core/xymon/hbnotes.py
+++ b/abs/core/xymon/hbnotes.py
@@ -24,17 +24,26 @@ def createdropdown(currenthostype):
     dropdown=" "
     dropdown='''
      <input name="param2" type="radio"  value="Restore" />Restore database </>
-     <select name="param1">
-    '''
+     <select name="param1">\n'''
+    os.chdir(dir)
     if os.path.exists(dir):
         files = os.listdir(dir)
-        for file in os.listdir(dir):
+        files.sort(key=lambda x: os.path.getmtime(x) , reverse=True)
+        #for file in os.listdir(dir):
+        if len(files) > 20:
+            del files[20:]
+
+
+        for file in files:
             if (file.endswith(".tgz")):
-                dropdown+='<option value="' + file + '">' + file + '</option> '
-    dropdown+='</select> <br><input name="param2" type="radio" value="Backup" checked="checked" />Backup database<br />  '
-    dropdown+='<input name="param2" type="radio" value="Optimize"  />Optimize database<br />  '
+                dropdown+='        <option value="' + file + '">' + file + '</option> \n'
+    dropdown+='''     </select>
+    <br>
+    <input name="param2" type="radio" value="Backup" checked="checked" />Backup database<br />
+    <input name="param2" type="radio" value="Optimize"  />Optimize database<br />
+    '''
     if currenthostype == "Master_backend":
-        dropdown+='<input name="param2" type="radio" value="ShutdownAll"  />Shutdown All Systems (expect MBE)<br />  '
+        dropdown+='<input name="param2" type="radio" value="ShutdownAll"  />Shutdown All Systems (expect MBE)<br /> \n'
     #dropdown+='''<input name="param2" type="radio"  value="UpdateAll" />Update All Systems </>           <select name="param5">
                    #<option value="Myth_only">Myth only</option>
                    #<option value="All"> Full System</option>
@@ -43,7 +52,7 @@ def createdropdown(currenthostype):
        #</br>
            #</br>'''
 
-    dropdown+=''' </br></br>'''
+    dropdown+='''    </br></br>\n'''
     return dropdown
 
 def main(argv):
@@ -266,14 +275,55 @@ def main(argv):
 
        file = open(filename,'w')
        string='''
-        <html>
-        <head>
-            <style type="text/css">@import "/frame.css";</style>
-        </head>
-       '''
+<html>
+<head>  <style type="text/css">@import "/frame.css";</style>
+<SCRIPT>
+
+function do_submission()
+{
+  document.form.submit();
+}
+
+
+function Do_it ()
+{
+    chosen = ""
+    len = document.form.param2.length
+    for (i = 0; i <len; i++)
+    {
+        if (document.form.param2[i].checked)
+        {
+            chosen = document.form.param2[i].value
+        }
+    }
+
+
+  if (chosen == "Restore")
+  {
+      if (confirm('Continue with database restore?'))
+        {
+          do_submission();
+          }
+        else
+        {
+          alert(" database was not restored");
+        }
+
+
+  }
+  else
+  {
+    //alert("not restore")
+    do_submission();
+  }
+}
+
+</SCRIPT>
+</head>
+
+'''
        file.write(string)
 
-
        for i in range( 0 , len(hostvalues)):
             value=hostvalues[i][0]
             data=hostvalues[i][1]
@@ -284,7 +334,6 @@ def main(argv):
                     found_uuid="true"
                     uuid=data
             if value == "HostSystemType" :
-
                 currenthostname= str(row[0]).strip()
                 currenthostype=str(data).strip()
                 header="<h1>" + currenthostname + " (" + currenthostype + ") </h1>"
@@ -292,7 +341,7 @@ def main(argv):
 
 
        if found_uuid == "true" :
-            string=str("http://smolt.mythvantage.com/client/show?uuid=")
+            string=str("http://smolt.mythtv.org/client/show?uuid=")
             string+=str(uuid)
             file.write("<A href=\""  )
             file.write(string)
@@ -303,42 +352,45 @@ def main(argv):
 
 
        buttonform_top='''
-         <div class="content" style="solid #aaa; width:500px; height:350px; overflow:auto; color:#FFF;text-align:left;">
-         <form action="/process.py" method="get">
+    <div class="content" style="solid #aaa; width:500px; height:350px; overflow:auto; color:#FFF;text-align:left;">
+    <form name="form" action="/process.py" method="get">
          '''
 
 
        buttonform_bottom='''
-           <input name="param2" type="radio"  value="Update" />Update System </>
-           <select name="param3">
-                   <option value="Myth_only">Myth only</option>
-                   <option value="All"> Full System</option>
-           </select>
-           </br>
-           <input name="param2" type="radio"  value="Kill" />Restart interface: </>
-           <select name="param6">
-                   <option value="killX">Full UI</option>
-                   <option value="killmyth">MythFrontend</option>
-           </select>
-           </br>
-           <input name="param2" type="radio"  value="Shutdown" />Shutdown System<br />
-           <input name="param2" type="radio"  value="Reboot" />Reboot System<br />
-           <input name="param2" type="radio"  value="WOL" />Wake on Lan<br />
-           <input name="hiddenparam" type="hidden" value="
-            '''
-       oldurlform='''
-                   "/>
-            <input name="param4" type="hidden" value="
-            '''
+    <input name="param2" type="radio"  value="Update" />Update System </>
+        <select name="param3">
+            <option value="Myth_only">Myth only</option>
+            <option value="All"> Full System</option>
+        </select>
+    </br>
+
+    <input name="param2" type="radio"  value="Kill" />Restart interface: </>
+        <select name="param6">
+            <option value="killX">Full UI</option>
+            <option value="killmyth">MythFrontend</option>
+        </select>
+    </br>
+
+    <input name="param2" type="radio"  value="Shutdown" />Shutdown System<br />
+    <input name="param2" type="radio"  value="Reboot" />Reboot System<br />
+    <input name="param2" type="radio"  value="WOL" />Wake on Lan<br />
+    <input name="hiddenparam" type="hidden" value=" '''
+
+       oldurlform=''' "/>
+    <input name="param4" type="hidden" value="
+    '''
 
 
        closetag='''
            "/>
-            </br>
-            <input id="submitbutton" type="submit" />
-        </form>
-        </div>
-        '''
+    </br>
+    <!--<input id="submitbutton" type="submit" />-->
+    <a href="Javascript:Do_it();">
+    <img src="/go.png"></a>
+    </form>
+    </div>
+'''
 
        if currenthostype == "Master_backend" or currenthostype == "Standalone":
             mbeoptions=createdropdown(currenthostype)
@@ -356,7 +408,7 @@ def main(argv):
        file.write(returnurl)
        file.write(closetag)
 
-       string=(' </html>')
+       string=('</html>')
        file.write(string)
 
 if __name__ == "__main__":
-- 
cgit v0.12

