diff --git a/src/blenderbim/blenderbim/bim/data/gantt/index.mustache b/src/blenderbim/blenderbim/bim/data/gantt/index.mustache index e75c171e3b..a368889cc2 100644 --- a/src/blenderbim/blenderbim/bim/data/gantt/index.mustache +++ b/src/blenderbim/blenderbim/bim/data/gantt/index.mustache @@ -1,67 +1,53 @@ + - -Print Mode -
- + + +
+

Choose a language: + +

+ +
+

+ +
+
+ + \ No newline at end of file diff --git a/src/blenderbim/blenderbim/bim/module/sequence/gantt/index.js b/src/blenderbim/blenderbim/bim/module/sequence/gantt/index.js new file mode 100644 index 0000000000..05096293da --- /dev/null +++ b/src/blenderbim/blenderbim/bim/module/sequence/gantt/index.js @@ -0,0 +1,57 @@ +let g; + +function create_gantt_chart(json_data) { + g = new JSGantt.GanttChart(document.getElementById('GanttChartDIV'), 'week'); + g.setOptions({ + vCaptionType: 'Caption', // Set to Show Caption : None,Caption,Resource,Duration,Complete, + vQuarterColWidth: 36, + vDateTaskDisplayFormat: 'day dd month yyyy', // Shown in tool tip box + vDayMajorDateDisplayFormat: 'mon yyyy - Week ww',// Set format to dates in the "Major" header of the "Day" view + vWeekMinorDateDisplayFormat: 'dd mon', // Set format to display dates in the "Minor" header of the "Week" view + vLang: "en", + vShowTaskInfoLink: 1, // Show link in tool tip (0/1) + vShowEndWeekDate: 0, // Show/Hide the date for the last day of the week in header for daily + vUseSingleCell: 10000, // Set the threshold cell per table row (Helps performance for large data. + vFormatArr: ['Day', 'Week', 'Month', 'Quarter'], // Even with setUseSingleCell using Hour format on such a large chart can cause issues in some browsers, + vShowRes: false, // Disable the resource column. + vShowComp: false, // Disable the completion column. + vShowDur: false, // Disable the duration column, because jsgantt doesn't calculate durations the way we want. + vAdditionalHeaders: {ifcduration: {title: 'Duration'}}, + vUseToolTip: false, // Disable tooltips. + vTotalHeight: 900, + }); + JSGantt.parseJSONString(json_data, g); + g.Draw(); +} +function set_language(e){ + lang = e && e.target ? e.target.value : "en"; + g.setOptions({ + vLang: lang, + }); + g.Draw(); +} + +function setupPage(name){ + let print_button = document.createElement("button"); + print_button.id = "print-schedule"; + print_button.innerHTML = "Print"; + print_button.addEventListener("click", function(){ + g.setTotalHeight(""); + g.Draw(); + var values = document.getElementById("print_page_size").value.split(",") + let css = + "@media print {\n @page {\n size: " + values[0] + "mm " + values[1] + "mm;\n }\n /* set gantt container to the same width as the page */\n .gantt {\n width: " + values[0] + "mm;\n }\n };"; + g.printChart(values[0], values[1], css); + g.setTotalHeight(900); + g.Draw(); + }); + document.getElementById("print_options").appendChild(print_button); + + // add a nice layout to show the schedule name + let schedule_name = document.createElement("h1"); + // create string to say "Schedule: " + let schedule_name_string = document.createTextNode("Schedule: " + name); + // add the string to the h1 element + schedule_name.appendChild(schedule_name_string); + document.getElementById("schedule-data").appendChild(schedule_name); +} \ No newline at end of file diff --git a/src/blenderbim/blenderbim/bim/module/sequence/gantt/main.css b/src/blenderbim/blenderbim/bim/module/sequence/gantt/main.css new file mode 100644 index 0000000000..cb76c9c069 --- /dev/null +++ b/src/blenderbim/blenderbim/bim/module/sequence/gantt/main.css @@ -0,0 +1,122 @@ +.gtaskcellwkend, +.gtaskcellcurrent, +.gminorheadingwkend { + background-color: #e1e1e1; +} + +.gitemhighlight td { + background-color: #ffdaaa; +} + +.gtaskblue { + background: #4281A4; +} + +.gtaskred { + background: #C1666B; +} + +.gtaskgreen { + background: #48A9A6; +} + +.gtaskyellow { + background: #D4B483; +} + +.gmainleft { + overflow: visible; + flex: 0 1 auto; +} + +.gname.ggroupitem { + background-color: #4c92ec; + font-weight: bold; +} + +.gtaskcellwkend, +.gtaskcellcurrent, +.gminorheadingwkend { + background-color: #e1e1e1; +} + +.gitemhighlight td { + background-color: #ffdaaa; +} + +.gtaskblue { + background: #4281A4; +} + +.gtaskred { + background: #C1666B; +} + +.gtaskgreen { + background: #48A9A6; +} + +.gtaskyellow { + background: #D4B483; +} + +.gmainleft { + resize: horizontal; + height:100%; + overflow-x: visible; + flex: 0 1 auto; +} + +.gmainright { + height:100%; + overflow: auto; + font-size: 1.5rem; +} + +.gcaption { + /* github style header 3 */ + font-size: 0.75rem; + font-weight: 200; + line-height: 1.25; + color: black; +} + +.gchartgrid { + background-color: transparent; + height: fit-content; +} + +.gchartcontainer { + border: 1px solid #e1e1e1; + height: fit-content; +} + +@media print { + .no-print { + display: none; + } +} + +button, .sweet_button { + border: none; + background-color: #ffffff; + color: black; + padding: 0.5rem 1rem; + text-align: center; + text-decoration: none; + display: inline-block; + font-size: 1rem; + margin: 0.25rem 0.5rem; + cursor: pointer; + border-radius: 0.25rem; + /* add shadow */ + box-shadow: 0 0 0.7rem rgba(95, 95, 95, 0.4); +} + +h4 { + font-size: 1.2rem; + font-weight: 500; + line-height: 1.25; + color: black; +} + diff --git a/src/blenderbim/blenderbim/tool/sequence.py b/src/blenderbim/blenderbim/tool/sequence.py index e02d28eb3f..2e3e18eb08 100644 --- a/src/blenderbim/blenderbim/tool/sequence.py +++ b/src/blenderbim/blenderbim/tool/sequence.py @@ -1498,7 +1498,7 @@ class Sequence(blenderbim.core.tool.Sequence): "pParent": task.Nests[0].RelatingObject.id() if task.Nests else 0, "pOpen": 1, "pCost": 1, - "ifcduration": task_time.ScheduleDuration if task_time else "", + "ifcduration": str(ifcopenshell.util.date.ifc2datetime(task_time.ScheduleDuration)) if (task_time and task_time.ScheduleDuration) else "", } if task_time and task_time.IsCritical: @@ -1519,9 +1519,10 @@ class Sequence(blenderbim.core.tool.Sequence): @classmethod def generate_gantt_browser_chart(cls, task_json): + active_work_schedule = cls.get_active_work_schedule() with open(os.path.join(bpy.context.scene.BIMProperties.data_dir, "gantt", "index.html"), "w") as f: with open(os.path.join(bpy.context.scene.BIMProperties.data_dir, "gantt", "index.mustache"), "r") as t: - f.write(pystache.render(t.read(), {"json_data": json.dumps(task_json)})) + f.write(pystache.render(t.read(), {"json_data": json.dumps(task_json), "name":active_work_schedule.Name or "Unnamed"})) webbrowser.open("file://" + os.path.join(bpy.context.scene.BIMProperties.data_dir, "gantt", "index.html")) @classmethod