community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From humbed...@apache.org
Subject svn commit: r1864243 - in /comdev/reporter.apache.org/trunk/site/wizard/js: source/drafts.js source/reportdate.js source/unified.js wizard.js
Date Fri, 02 Aug 2019 16:47:03 GMT
Author: humbedooh
Date: Fri Aug  2 16:47:03 2019
New Revision: 1864243

URL: http://svn.apache.org/viewvc?rev=1864243&view=rev
Log:
Add publishing features via whimsy

Modified:
    comdev/reporter.apache.org/trunk/site/wizard/js/source/drafts.js
    comdev/reporter.apache.org/trunk/site/wizard/js/source/reportdate.js
    comdev/reporter.apache.org/trunk/site/wizard/js/source/unified.js
    comdev/reporter.apache.org/trunk/site/wizard/js/wizard.js

Modified: comdev/reporter.apache.org/trunk/site/wizard/js/source/drafts.js
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/wizard/js/source/drafts.js?rev=1864243&r1=1864242&r2=1864243&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/site/wizard/js/source/drafts.js (original)
+++ comdev/reporter.apache.org/trunk/site/wizard/js/source/drafts.js Fri Aug  2 16:47:03 2019
@@ -42,6 +42,7 @@ function load_draft(filename) {
 function read_draft(state, json) {
     if (json.report) {
         draft_stepper.editor.object.value = json.report;
+        draft_stepper.editor.report = json.report;
         window.setTimeout(() => { draft_stepper.editor.highlight() }, 250);
         draft_stepper.build(0, false, false);
         modal("Draft was successfully loaded and is ready.");
@@ -112,3 +113,37 @@ function deleted_draft(state, json) {
         modal("Could not remove report draft :/");
     }
 }
+
+
+function publish_report() {
+    let agendafile = getReportDate(cycles, project, false, true);
+    if (!window.confirm("This will publish your report to %s - are you sure?".format(agendafile)))
{
+      return;
+    }
+    let js = {
+        'project': project,
+        'agenda': agendafile,
+        'report': draft_stepper.editor.report
+    };
+    
+    let formdata = $.param(js);
+    
+    // Enable spinner, hide main wrapper
+    document.getElementById('loader_text').innerText = "Publishing report, hang on...";
+    document.getElementById('wizard_spinner').style.display = 'block';
+    document.getElementById('wrapper').style.display = 'none';
+    
+    POST('whimsy.py', report_published, {}, formdata);
+}
+
+function report_published(state, json) {
+  // Disengage spinner
+  document.getElementById('wizard_spinner').style.display = 'none';
+  document.getElementById('wrapper').style.display = 'block';
+  
+  if (json && json.okay) {
+    modal("Your report was successfully posted to the board agenda!");
+  } else {
+    modal("Something went wrong, and we couldn't publish your report.<br/>Please check
with the Whimsy tool to see if there is already a report posted!");
+  }
+}
\ No newline at end of file

Modified: comdev/reporter.apache.org/trunk/site/wizard/js/source/reportdate.js
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/wizard/js/source/reportdate.js?rev=1864243&r1=1864242&r2=1864243&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/site/wizard/js/source/reportdate.js (original)
+++ comdev/reporter.apache.org/trunk/site/wizard/js/source/reportdate.js Fri Aug  2 16:47:03
2019
@@ -46,7 +46,7 @@ function formatRm(array) {
 
 // Called by: GetAsyncJSON("reportingcycles.json?" + Math.random(), [pmc, reportdate, json.pdata[pmc].name],
setReportDate) 
 
-function getReportDate(json, pmc, dateOnly) {
+function getReportDate(json, pmc, dateOnly, agenda) {
 	var today = new Date()
 
 	var dates = [] // the entries must be in date order
@@ -90,6 +90,7 @@ function getReportDate(json, pmc, dateOn
 	while (nextdate < today && dates.length > 0) {
 		nextdate = dates.shift();
 	}
+	if (agenda) return "board_agenda_%s.txt".format(moment(nextdate).format('YYYY_MM_DD'));
 	if (dateOnly) return nextdate ? (nextdate.toDateString() + " ("  + moment(nextdate).fromNow()
+ ")"): "Unknown(?)";
 	let txt = "";
 	txt += "<b>Reporting schedule:</b> " + (json[pmc] ? formatRm(json[pmc]) : "Unknown(?)")
+ "<br>"

Modified: comdev/reporter.apache.org/trunk/site/wizard/js/source/unified.js
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/wizard/js/source/unified.js?rev=1864243&r1=1864242&r2=1864243&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/site/wizard/js/source/unified.js (original)
+++ comdev/reporter.apache.org/trunk/site/wizard/js/source/unified.js Fri Aug  2 16:47:03
2019
@@ -225,7 +225,7 @@ function UnifiedEditor_compile() {
         text += "That's it, your board report compiled a-okay and is potentially ready for
submission! If you'd like more time to work on it, you can save it as a draft, and return
later to make some final edits. Or you can publish it to the agenda via Whimsy.";
     }
     text += "<br/><button class='btn btn-warning' onclick='save_draft();'>Save
as draft</button>"
-    if (this.compiles) text += " &nbsp; &nbsp; <button class='btn btn-success'>Publish
via Whimsy</button>"
+    if (this.compiles) text += " &nbsp; &nbsp; <button onclick='publish_report();'
class='btn btn-success'>Publish via Whimsy</button>"
     return text;
 }
 

Modified: comdev/reporter.apache.org/trunk/site/wizard/js/wizard.js
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/wizard/js/wizard.js?rev=1864243&r1=1864242&r2=1864243&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/site/wizard/js/wizard.js (original)
+++ comdev/reporter.apache.org/trunk/site/wizard/js/wizard.js Fri Aug  2 16:47:03 2019
@@ -1057,6 +1057,7 @@ function load_draft(filename) {
 function read_draft(state, json) {
     if (json.report) {
         draft_stepper.editor.object.value = json.report;
+        draft_stepper.editor.report = json.report;
         window.setTimeout(() => { draft_stepper.editor.highlight() }, 250);
         draft_stepper.build(0, false, false);
         modal("Draft was successfully loaded and is ready.");
@@ -1129,6 +1130,39 @@ function deleted_draft(state, json) {
 }
 
 
+function publish_report() {
+    let agendafile = getReportDate(cycles, project, false, true);
+    if (!window.confirm("This will publish your report to %s - are you sure?".format(agendafile)))
{
+      return;
+    }
+    let js = {
+        'project': project,
+        'agenda': agendafile,
+        'report': draft_stepper.editor.report
+    };
+    
+    let formdata = $.param(js);
+    
+    // Enable spinner, hide main wrapper
+    document.getElementById('loader_text').innerText = "Publishing report, hang on...";
+    document.getElementById('wizard_spinner').style.display = 'block';
+    document.getElementById('wrapper').style.display = 'none';
+    
+    POST('whimsy.py', report_published, {}, formdata);
+}
+
+function report_published(state, json) {
+  // Disengage spinner
+  document.getElementById('wizard_spinner').style.display = 'none';
+  document.getElementById('wrapper').style.display = 'block';
+  
+  if (json && json.okay) {
+    modal("Your report was successfully posted to the board agenda!");
+  } else {
+    modal("Something went wrong, and we couldn't publish your report.<br/>Please check
with the Whimsy tool to see if there is already a report posted!");
+  }
+}
+
 /******************************************
  Fetched from source/generators.js
 ******************************************/
@@ -1556,7 +1590,7 @@ function formatRm(array) {
 
 // Called by: GetAsyncJSON("reportingcycles.json?" + Math.random(), [pmc, reportdate, json.pdata[pmc].name],
setReportDate) 
 
-function getReportDate(json, pmc, dateOnly) {
+function getReportDate(json, pmc, dateOnly, agenda) {
 	var today = new Date()
 
 	var dates = [] // the entries must be in date order
@@ -1600,6 +1634,7 @@ function getReportDate(json, pmc, dateOn
 	while (nextdate < today && dates.length > 0) {
 		nextdate = dates.shift();
 	}
+	if (agenda) return "board_agenda_%s.txt".format(moment(nextdate).format('YYYY_MM_DD'));
 	if (dateOnly) return nextdate ? (nextdate.toDateString() + " ("  + moment(nextdate).fromNow()
+ ")"): "Unknown(?)";
 	let txt = "";
 	txt += "<b>Reporting schedule:</b> " + (json[pmc] ? formatRm(json[pmc]) : "Unknown(?)")
+ "<br>"
@@ -2090,7 +2125,7 @@ function UnifiedEditor_compile() {
         text += "That's it, your board report compiled a-okay and is potentially ready for
submission! If you'd like more time to work on it, you can save it as a draft, and return
later to make some final edits. Or you can publish it to the agenda via Whimsy.";
     }
     text += "<br/><button class='btn btn-warning' onclick='save_draft();'>Save
as draft</button>"
-    if (this.compiles) text += " &nbsp; &nbsp; <button class='btn btn-success'>Publish
via Whimsy</button>"
+    if (this.compiles) text += " &nbsp; &nbsp; <button onclick='publish_report();'
class='btn btn-success'>Publish via Whimsy</button>"
     return text;
 }
 



Mime
View raw message