示例#1
0
    def get_display(self):

        div = DivWdg()
        div.add_style("margin: 0px 0px")
        div.add_class("centered")

        div.add(HtmlElement.br(7))

        table = Table(css="login")
        table.center()
        table.set_attr("cellpadding", "3px")
        table.add_row()

        div.add(table)

        error_div = DivWdg()
        error_div.add_class("maq_search_bar")
        error_div.add_style("font-size: 1.5em")
        error_div.add_style("padding: 5px")
        error_div.add_style("margin: 0 5px 0 5px")
        error_div.add_style("text-align: center")
        icon = IconWdg("Database Error", IconWdg.ERROR)
        error_div.add(icon)
        error_div.add("Databsae Error")
        table.add_cell(error_div)

        error = self.get_error()
        table.add_row()
        td = table.add_cell("<b>%s</b>" % error)
        td.add_style("padding: 5px 20px 5px 20px")
        table.add_row()
        td = table.add_cell(
            "<b>Please contact your Admistrator. In the meantime, you can login with 'admin'</b>"
        )
        td.add_style("padding: 5px 20px 5px 20px")
        table.add_row()
        table.add_row()
        OK = ProdIconSubmitWdg('Return to Login')

        return div
示例#2
0
    def get_display(self):

        
        div = DivWdg()
        div.add_style("margin: 0px 0px")
        div.add_class("centered")

        div.add(HtmlElement.br(7))

        table = Table(css="login")
        table.center()
        table.set_attr("cellpadding", "3px")
        table.add_row()

        div.add(table)

        error_div = DivWdg()
        error_div.add_class("maq_search_bar")
        error_div.add_style("font-size: 1.5em")
        error_div.add_style("padding: 5px")
        error_div.add_style("margin: 0 5px 0 5px")
        error_div.add_style("text-align: center")
        icon = IconWdg("Database Error", IconWdg.ERROR)
        error_div.add(icon)
        error_div.add("Databsae Error")
        table.add_cell( error_div)

        error = self.get_error()
        table.add_row()
        td = table.add_cell( "<b>%s</b>" % error )
        td.add_style("padding: 5px 20px 5px 20px")
        table.add_row()
        td = table.add_cell( "<b>Please contact your Admistrator. In the meantime, you can login with 'admin'</b>" )
        td.add_style("padding: 5px 20px 5px 20px")
        table.add_row()
        table.add_row()
        OK = ProdIconSubmitWdg('Return to Login')

        return div
示例#3
0
    def get_display(self):

        table = Table()
        table.add_row()

        count = 0
        for btn_wdg in self.button_widgets:
            td = table.add_cell()
            if self.spacing and count:
                td.add_styles("padding-left: %spx;" % self.spacing)
            count += 1
            td.add(btn_wdg)

        if self.float:
            table.add_styles("float: %s;" % self.float)
        if self.align:
            if self.align == "left":
                table.push_left()
            elif self.align == "right":
                table.push_right()
            elif self.align == "center":
                table.center()

        return table
示例#4
0
    def get_display(my):
        
        table = Table()
        table.add_row()

        count = 0
        for btn_wdg in my.button_widgets:
            td = table.add_cell()
            if my.spacing and count:
                td.add_styles( "padding-left: %spx;" % my.spacing )
            count += 1
            td.add( btn_wdg )

        if my.float:
            table.add_styles("float: %s;" % my.float)
        if my.align:
            if my.align == "left":
                table.push_left()
            elif my.align == "right":
                table.push_right()
            elif my.align == "center":
                table.center()

        return table
示例#5
0
    def get_display(my):

        web = WebContainer.get_web()
        login_name = web.get_form_value('login')
        hidden = HiddenWdg('login', login_name)
        box = DivWdg(css='login')

        if web.is_IE():
            box.add_style("margin-top: 150px")
            box.add_style("margin-bottom: 150px")
        else:
            box.add_style("margin-top: auto")
            box.add_style("margin-bottom: auto")
        box.add_style("text-align: center")

        div = DivWdg()
        div.add_style("margin: 0px 0px")
        div.add_class("centered")

        div.add_style("padding-top: 95px")

        sthpw = SpanWdg("SOUTHPAW TECHNOLOGY INC", css="login_sthpw")
        sthpw.add_style("color: #CCCCCC")
        div.add(sthpw)
        div.add(HtmlElement.br())
        div.add(hidden)
        box.add(div)

        # hidden element in the form to pass message that this was not
        # actually a typical submitted form, but rather the result
        # of a login page
        div.add(HiddenWdg("is_from_login", "yes"))
        div.add_style("font-size: 10px")

        table = Table(css="login")
        table.center()
        table.set_attr("cellpadding", "3px")
        table.add_row()

        table2 = Table(css="login")
        table2.center()
        table2.add_style("width: 240px")

        table2.add_row()

        td = table2.add_header(
            'After reset, the new password will be sent to the email address for [ %s ].'
            % login_name)
        td.add_color('color', 'color', +80)
        table2.add_row_cell('&nbsp;')
        # build the button manually
        from tactic.ui.widget import ActionButtonWdg
        button = ActionButtonWdg(tip='Reset Password', title='Reset')
        button.add_style('margin: auto')
        button.add_event(
            'onclick',
            "document.form.elements['reset_password'].value='true'; document.form.submit()"
        )
        table2.add_row()
        td = table2.add_cell(button)
        hidden = HiddenWdg('reset_password')
        td.add(hidden)

        #th.add_class('center_content')

        table2.add_row()

        div.add(HtmlElement.br())
        div.add(table)

        div.add(HtmlElement.spacer_div(1, 14))
        div.add(table2)
        #div.add(HiddenWdg(my.LOGIN_MSG))

        #box.add(script)

        widget = Widget()
        #widget.add( HtmlElement.br(3) )
        table = Table()
        table.add_style("width: 100%")
        table.add_style("height: 85%")
        table.add_row()
        td = table.add_cell()
        td.add_style("vertical-align: middle")
        td.add_style("text-align: center")
        td.add_style("background: transparent")
        td.add(box)
        widget.add(table)

        return widget
示例#6
0
    def get_display(my):

        top = DivWdg()
        top.add_border()
        top.add_style("padding: 10px")
        top.add_color("color", "color")
        top.add_gradient("background", "background", 0, -5)
        #top.add_style("height: 550px")

        top.add_behavior({
            'type':
            'load',
            'cbjs_action':
            '''
            spt.named_events.fire_event("side_bar|hide", {} );
            '''
        })

        project = Project.get()

        title = TitleWdg(title='Client Home')
        top.add(title)

        shelf = DivWdg()
        top.add(shelf)
        shelf.add_style("margin-left: -8px")
        shelf.add_style("width: 130px")

        security = Environment.get_security()
        view_side_bar = security.check_access("builtin",
                                              "view_side_bar",
                                              "allow",
                                              default='allow')
        if view_side_bar:
            button_div = DivWdg()
            shelf.add(button_div)
            button_div.add_style("float: left")
            button_div.add_style("margin-top: -3px")

            button = IconButtonWdg(title="Side Bar", icon=IconWdg.ARROW_LEFT)
            button_div.add(button)
            shelf.add("Toggle Side Bar")
            button.add_behavior({
                'type':
                'click_up',
                'cbjs_action':
                '''
                spt.named_events.fire_event("side_bar|toggle");
                '''
            })

            shelf.add_behavior({
                'type':
                'click_up',
                'cbjs_action':
                '''
                spt.named_events.fire_event("side_bar|toggle");
                '''
            })
            shelf.add_class("hand")
        else:
            shelf.add("&nbsp;")

        search_wdg = DivWdg()
        search_wdg.add_class("spt_main_top")
        top.add(search_wdg)
        search_wdg.add_style("padding: 10px")
        search_wdg.add_style("margin: 10px auto")
        search_wdg.add_style("width: 430px")
        search_wdg.add("Search: ")
        search_wdg.add("&nbsp;" * 3)

        custom_cbk = {}
        custom_cbk['enter'] = '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords != '') {
                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    'search_type': 'sthpw/sobject_list',
                    'view': 'table',
                    'keywords': keywords,
                    'simple_search_view': 'simple_search',
                    //'show_shelf': false,
                }
                spt.tab.set_main_body_tab();
                spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            }
        '''

        from tactic.ui.input import TextInputWdg, LookAheadTextInputWdg
        #text = TextInputWdg(name="search")
        text = LookAheadTextInputWdg(name="search", custom_cbk=custom_cbk)
        #text = TextWdg("search")
        text.add_class("spt_main_search")
        text.add_style("width: 290px")
        search_wdg.add(text)
        search_wdg.add_style("font-weight: bold")
        search_wdg.add_style("font-size: 16px")

        button = ActionButtonWdg(title="Search")
        #search_wdg.add(button)
        button.add_style("float: right")
        #button.add_style("margin-top: -28px")

        icon_div = DivWdg()
        search_wdg.add(icon_div)
        icon_div.add_style("width: 38px")
        icon_div.add_style("height: 27px")
        icon_div.add_style("padding-top: 3px")
        icon_div.add_style("padding-left: 4px")
        icon_div.add_style("text-align: center")
        #icon_div.add_gradient("background", "background3", 15, -10)
        icon_div.add_color("background", "background3", 10)
        over_color = icon_div.get_color("background3", 0)
        out_color = icon_div.get_color("background3", 10)
        icon_div.set_round_corners(5)
        icon_div.set_box_shadow("1px 1px 1px 1px")
        icon = IconWdg("Search", IconWdg.SEARCH_32, width=24)
        icon_div.add(icon)
        icon_div.add_style("float: right")
        icon_div.add_style("margin-top: -5px")
        button = icon_div
        icon_div.add_class("hand")
        icon_div.add_behavior({
            'type':
            'mouseover',
            'color':
            over_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("background", bvr.color);
            '''
        })
        icon_div.add_behavior({
            'type':
            'mouseout',
            'color':
            out_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("background", bvr.color);
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        })
        icon_div.add_behavior({
            'type':
            'click',
            'color':
            out_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("box-shadow", "0px 0px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-3");
            bvr.src_el.setStyle("margin-right", "-2");
            '''
        })
        icon_div.add_behavior({
            'type':
            'click_up',
            'color':
            out_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        })

        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords == '') {
                return;
            }

            var class_name = 'tactic.ui.panel.ViewPanelWdg';
            var kwargs = {
                'search_type': 'sthpw/sobject_list',
                'view': 'table',
                'keywords': keywords,
                'simple_search_view': 'simple_search',
                //'show_shelf': false,
            }
            spt.tab.set_main_body_tab();
            spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            '''
        })

        #desc = DivWdg()
        #top.add(desc)
        #desc.add("Dashboard")
        #desc.add_style("width: 600px")

        # create a bunch of panels
        table = Table()
        table.add_color("color", "color")
        table.add_style("margin-bottom: 20px")
        table.center()
        top.add(table)
        table.add_row()

        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "My Approvals"
        description = '''View all pending items for approval<br/><br/>
        '''
        #image = "<img src='/context/images/getting_started_pipeline.png'/>"
        image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.panel.ViewPanelWdg';
        var kwargs = {
            search_type: 'sthpw/sobject_list',
            view: 'client_approval',
            show_shelf: false,
            show_select: false,
            element_names: ['preview', 'name', 'description', 'task_pipeline_vertical','notes'],
            is_editable: false,
            //expression: "@SOBJECT(sthpw/task['project_code','fickle3'].fickle3/cars.sthpw/sobject_list)"
        };
        spt.tab.add_new("approvals", "Approvals", class_name, kwargs);
        '''
        }
        config_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(config_wdg)

        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "My Dashboard"
        image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''Dashboards display key project data in single views. Drill down further to work on tasks, make status changes or add notes.'''

        # read the config file
        from pyasm.widget import WidgetConfig
        tmp_path = __file__
        dir_name = os.path.dirname(tmp_path)
        file_path = "%s/../config/dashboard-conf.xml" % (dir_name)
        config = WidgetConfig.get(file_path=file_path, view="definition")

        #element_name = "my_dashboard"
        element_name = "my_dashboard"
        attrs = config.get_element_attributes(element_name)
        dashboard_data = {}
        kwargs = config.get_display_options(element_name)
        class_name = kwargs.get('class_name')

        dashboard_data['class_name'] = class_name
        dashboard_data['kwargs'] = kwargs
        dashboard_data['title'] = attrs.get("title")
        dashboard_data['description'] = attrs.get("description")
        dashboard_data['image'] = attrs.get("image")

        behavior = {
            'type':
            'click_up',
            'dashboard':
            dashboard_data,
            'cbjs_action':
            '''
        var class_name = 'tactic.ui.startup.dashboards_wdg.DashboardsWdg';
        var kwargs = {};
        spt.tab.set_main_body_tab();
        spt.tab.add_new("my_dashboard", "My Dashboard", bvr.dashboard.class_name, bvr.dashboard.kwargs);
        '''
        }
        pipeline_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(pipeline_wdg)

        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "My Reports"
        image = "<img src='/context/icons/64x64/report_64.png'/>"
        description = '''TACTIC provides a number of predefined reports that project managers can access instantly to get real-time analytics.'''

        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        var class_name = 'tactic.ui.startup.reports_wdg.ReportsWdg';
        var kwargs = {};
        spt.tab.set_main_body_tab();
        spt.tab.add_new("reports", "Reports", class_name, kwargs);
        //spt.panel.load_popup("Reports", class_name, kwargs);
        '''
        }

        side_bar_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(side_bar_wdg)
        """
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
	title = "Documentation"

        description = '''TACTIC Documentation.
        <br/><br/>
        * Project Setup Documentation<br/>
        <br/>
        * End User Documentation<br/>
        <br/>
        * Developer Documentation<br/>
        <br/>
        * System Administrator Documentation<br/>
        <br/>
        '''
        image = "<img src='/context/images/getting_started_pipeline.png'/>"
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.help.load_alias("main")
        '''
        }
        doc_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(doc_wdg)
        """

        tr, td = table.add_row_cell()
        td.add_style("font-size: 14px")
        td.add("<br/>" * 2)

        quick_links_wdg = QuickLinksWdg()
        td.add(quick_links_wdg)

        return top
示例#7
0
    def get_simple_definition_wdg(self):

        detail_wdg = DivWdg()
        detail_wdg.add_color("color", "color")
        detail_wdg.add_style("width: 350px")
        detail_wdg.add_style("margin-top: 10px")
        detail_wdg.add_style("padding: 10px")
        detail_wdg.add_border()
        title = DivWdg()
        title.add_style("margin-top: -23px")
        detail_wdg.add(title)
        if not self.name_string:
            title.add('No database column')
            return detail_wdg
        
        title.add("Column Definition")
       


        # add a name entry
        detail_wdg.add("<br/>")
        title = SpanWdg()
        detail_wdg.add("Name: ")
        detail_wdg.add(title)
        input = SpanWdg()
        input.add_style('padding-top: 6px')
        input.set_id("config_element_name")
        input.add(HtmlElement.b(self.name_string))
        detail_wdg.add(input)
        hidden = HiddenWdg('column_name', self.name_string)
        detail_wdg.add(hidden)
        hidden = HiddenWdg('target_search_type', self.search_type)
        detail_wdg.add(hidden)

        detail_wdg.add(HtmlElement.br(2))

        # add data_type entry
        data_type = SpanWdg()
        default_data_types = ['varchar(256)','varchar', 'character', 'text', 'integer', 'float', 'boolean', 'timestamp', 'Other...']
        select = SelectWdg('config_data_type', label ='Data Type: ')
        #detail_wdg.add(": ")
        select.set_option('values', default_data_types )
        select.set_value(self.data_type_string)
        
        select.add_behavior({'type': 'change', 
            'cbjs_action': "if (bvr.src_el.value=='Other...') {spt.show('config_data_type_custom');}\
                    else {spt.hide('config_data_type_custom');}"})
        data_type.add(select) 

        text = TextWdg('config_data_type_custom')
        span = SpanWdg("Other: ", css='med')
        span.add(text)
        span.set_id('config_data_type_custom')
        span.add_style('display','none')
        text.set_value(self.data_type_string)

        data_type.add("<br/>")
        data_type.add(span)
        detail_wdg.add(data_type)
            
        detail_wdg.add("<br/>")
        # add a nullable entry
        nullable = SpanWdg()
        checkbox = CheckboxWdg('config_nullable', label ='Allow null(empty) value: ')
        #detail_wdg.add(": ")
        nullable.add(checkbox)
   

        if self.nullable_string in ['True', 'true']:
            checkbox.set_checked()
        
        detail_wdg.add(nullable)


        #constraint = DivWdg()
        #detail_wdg.add(constraint)
        #constraint.add_style("margin-top: 10px")
        #constraint.add("Constraint: ")
        #select = SelectWdg("config_constraint")
        #constraint.add(select)
        #select.set_option("values", "unique|indexed")
        #select.add_empty_option("-- None --")




        button_div = DivWdg()
        button_div.add_style("text-align: center")


        button_div.add_behavior( {
            'type': 'load',
            'cbjs_action': '''
spt.manage_search_type = {};

spt.manage_search_type.change_column_cbk = function(bvr) {
    var class_name = 'tactic.ui.panel.AlterSearchTypeCbk';
    var options ={
        'alter_mode': bvr.alter_mode,
        'title': bvr.title
    };

    try {
        var server = TacticServerStub.get();
        var panel = $('search_type_detail');
        if (! panel.getAttribute("spt_class_name") ) {
            panel = panel.getParent(".spt_panel");
        }
        var values = spt.api.Utility.get_input_values(panel);
        rtn = server.execute_cmd(class_name, options, values);
        if (bvr.alter_mode == 'Remove Column')
            spt.info("Column [" + bvr.column + "] has been deleted.");
        else if (bvr.alter_mode == 'Modify Column')
            spt.notify.show_message("Column [" + bvr.column + "] has been modified.");
    }
    catch (e) {
        spt.alert(spt.exception.handler(e));
    }
    var view = 'db_column';
    spt.panel.refresh("ManageSearchTypeMenuWdg_" + view);
    var view = 'definition';
    spt.panel.refresh("ManageSearchTypeMenuWdg_" + view);
}


            '''
        } )


        detail_wdg.add(button_div)
        button_div.add("<hr/><br/>")
        if self.is_new_column:
            button = ActionButtonWdg(title="Commit") 
            #button = ProdIconButtonWdg("Commit New Column")
            button.add_behavior({"type": "click_up", 
                "cbjs_action": "spt.manage_search_type.change_column_cbk(bvr)", \
                        
                        "alter_mode": self.ADD_COLUMN})
            button_div.add(button)
        else:

            table = Table()
            button_div.add(table)
            table.add_row()
            table.center()

            button = ActionButtonWdg(title="Modify") 
            #button = ProdIconButtonWdg("Modify Column")
            button.add_behavior({"type": "click_up", 
            "cbjs_action": '''spt.manage_search_type.change_column_cbk(bvr);
                           ''',
                    "alter_mode": self.MODIFY_COLUMN,
                    "column": self.name_string,
                    "title": self.title_string
                    })
            table.add_cell(button)

            button = ActionButtonWdg(title="Delete") 
            #button = ProdIconButtonWdg("Delete Column")
            #button.add_style('background-color: #BF462E')
            button.add_behavior({"type": "click_up", 
                "cbjs_action": '''
                
                var yes = function() {
                    spt.manage_search_type.change_column_cbk(bvr);
                    
                }
                spt.confirm("Are you sure you wish to delete this column?", yes) 
                ''',
                "alter_mode": self.REMOVE_COLUMN,
                "column": self.name_string
                
                })
            table.add_cell(button)
            button_div.add(HiddenWdg('delete_column'))
            button_div.add(HiddenWdg('modify_column'))

        return detail_wdg
示例#8
0
    def get_display(my):

        top = DivWdg()
        top.add_border()
        top.add_style("padding: 10px")
        top.add_color("color", "color")
        top.add_color("background", "background")
        #top.add_style("height: 550px")

        top.add_class("spt_reports_top")


        title = DivWdg()
        title.add("Searchable Lists")
        title.add_style("font-size: 18px")
        title.add_style("font-weight: bold")
        title.add_style("text-align: center")
        title.add_style("padding: 10px")
        title.add_style("margin: -10px -10px 0px -10px")

        top.add(title)
        title.add_gradient("background", "background3", 5, -10)
        top.add("<br/>")

        button_div = DivWdg()
        top.add(button_div)
        button = SingleButtonWdg(title="Collapse", icon=IconWdg.ARROW_UP)
        button_div.add(button)
        top.add(button_div)
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_reports_top");
            var element = top.getElement(".spt_reports_list");
            spt.toggle_show_hide(element)

            '''
        } )

        #desc = DivWdg()
        #top.add(desc)
        #desc.add("Dashboard")
        #desc.add_style("width: 600px")

        reports = []

        # read the config file
        """
        from pyasm.widget import WidgetConfig
        tmp_path = __file__
        dir_name = os.path.dirname(tmp_path)
        file_path="%s/../config/reports-conf.xml" % (dir_name)
        config = WidgetConfig.get(file_path=file_path, view="definition")
        element_names = config.get_element_names()

        for element_name in element_names:
            print "element_name: ", element_name
            attrs = config.get_element_attributes(element_name)
            report_data = {}
            kwargs = config.get_display_options(element_name)
            class_name = kwargs.get('class_name')

            report_data['class_name'] = class_name
            report_data['kwargs'] = kwargs
            report_data['title'] = attrs.get("title")
            report_data['description'] = attrs.get("description")

            reports.append(report_data)
        """

        project = Project.get()
        project_code = project.get_code()
        search_type_objs = project.get_search_types()

        filtered = [] 
        for search_type_obj in search_type_objs:
            search_type = search_type_obj.get_value("search_type")

            # FIXME: this code is also present 
            from pyasm.security import get_security_version
            security_version = get_security_version()
            if security_version >= 2 and not search_type.startswith("sthpw/") and not search_type.startswith("config/"):
                security = Environment.get_security()

                table = search_type_obj.get_value("table_name")

                default = "deny"
                key  = { "element": "%s_list" % table }
                key2 = { "element": "%s_list" % table, "project": project_code }
                key3 = { "element": "*" }
                key4 = { "element": "*", "project": project_code }
                keys = [key, key2, key3, key4]
                if not security.check_access("link", keys, "view", default=default):
                    continue

                key = { "code": search_type }
                key2 = { "code": "*" }
                keys = [key, key2]
                if not security.check_access("search_type", keys, "view", default=default):
                    continue
                

                filtered.append(search_type_obj)


        search_type_objs = filtered

        for search_type_sobj in search_type_objs:
            description = search_type_sobj.get_value("description")
            search_type = search_type_sobj.get_value("search_type")



            search = Search(search_type)
            count = search.get_count()

            title_div = DivWdg()
            items_div = DivWdg()
            title_div.add(items_div)
            items_div.add_style("font-size: 9px")
            items_div.add_style("font-weight: italic")
            items_div.add_style("float: right")
            items_div.add("%s item/s" % count)
            title_div.add(search_type_sobj.get_title())

            description_div = DivWdg()
            description_div.add(description)
            description_div.add_style("padding: 5px")
            if not description:
                description_div.add("<br/>(No description)")
                description_div.add_style("font-style: italic")
                description_div.add_style("opacity: 0.3")


            report_data = {
                'title': search_type_sobj.get_title(),
                'title_wdg': title_div,
                'class_name': 'tactic.ui.panel.ViewPanelWdg',
                'kwargs': {
                        'search_type': search_type,
                        'view': 'table',
                        'simple_search_view': 'simple_search'
                    },
                'description': description_div,
                'search_type': search_type_sobj
            }
            reports.append(report_data)


        # create a bunch of panels
        list_div = DivWdg()
        top.add(list_div)
        list_div.add_class("spt_reports_list")


        table = Table()
        list_div.add(table)
        table.add_color("color", "color")
        table.add_style("margin-bottom: 5px")
        table.center()

        top.add("<br clear='all'/>")


        for i, report in enumerate(reports):

            if i == 0 or i%4 == 0:
                tr = table.add_row()

            td = table.add_cell()
            td.add_style("vertical-align: top")
            td.add_style("padding: 3px")

            class_name = report.get("class_name")
            kwargs = report.get("kwargs")
            title = report.get("title")
            description = report.get("description")

            #image = "<img src='/context/images/getting_started_schema.png'/>"
            image = "<img src='/context/images/getting_started_pipeline.png'/>"


            thumb_div = DivWdg()
            image = thumb_div
            thumb_div.add_border()
            thumb_div.set_box_shadow("1px 1px 1px 1px")

            thumb = ThumbWdg()
            thumb_div.add(thumb)
            thumb.set_sobject(report.get("search_type"))
            thumb.set_icon_size(60)




            behavior = {
            'type': 'click_up',
            'title': title,
            'class_name': class_name,
            'kwargs': kwargs,
            'cbjs_action': '''

            var top = bvr.src_el.getParent(".spt_reports_top");
            //spt.tab.set_main_body_tab();
            spt.tab.set_tab_top(top);
            var kwargs = {};
            spt.tab.add_new(bvr.title, bvr.title, bvr.class_name, bvr.kwargs);
            '''
            }
            title_wdg = report.get("title_wdg")
            schema_wdg = my.get_section_wdg(title_wdg, description, image, behavior)
            td.add(schema_wdg)



        from tactic.ui.container import TabWdg
        tab = TabWdg(show_add=False)
        top.add(tab)



        return top
示例#9
0
    def get_display(my):

        top = DivWdg()
        top.add_border()
        top.add_style("padding: 10px")
        top.add_color("color", "color")
        top.add_gradient("background", "background", 0, -5)
        #top.add_style("height: 550px")

        top.add_class("spt_reports_top")
        my.set_as_panel(top)

        inner = DivWdg()
        top.add(inner)


        title = DivWdg()
        title.add("Reports")
        title.add_style("font-size: 18px")
        title.add_style("font-weight: bold")
        title.add_style("text-align: center")
        title.add_style("padding: 10px")
        title.add_style("margin: -10px -10px 0px -10px")

        inner.add(title)
        title.add_gradient("background", "background3", 5, -10)


        from tactic.ui.widget import TitleWdg
        subtitle = TitleWdg(name_of_title='List of Built in Reports',help_alias='main')
        inner.add(subtitle)
        inner.add("<br/>")

        button_div = DivWdg()
        inner.add(button_div)
        button_div.add_class("spt_buttons_top")
        button_div.add_style("margin-top: -5px")
        button_div.add_style("margin-bottom: 30px")
        button_div.add_border()

        button_div.add_style("margin-top: -15px")
        button_div.add_style("margin-bottom: 0px")
        button_div.add_style("width: 100%")
        button_div.add_style("height: 33px")
        button_div.add_color("background", "background2")
        button_div.add_style("margin-left: auto")
        button_div.add_style("margin-right: auto")


        button = SingleButtonWdg(title="Collapse", icon=IconWdg.HOME)
        button_div.add(button)
        button.add_style("float: left")
        button.add_style("left: 5px")
        button.add_style("top: 5px")


        # FIXME: get home for the user
        #home = 'tactic.ui.startup.ContentCreatorWdg'
        home = 'tactic.ui.startup.MainWdg'


        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            spt.tab.set_main_body_tab();
            var class_name = 'tactic.ui.startup.MainWdg';
            var kwargs = {
                help_alias: 'main'
                };
            spt.tab.add_new("_startup", "Startup", class_name, kwargs);

            '''
        } )



        """
        button = SingleButtonWdg(title="Collapse", icon=IconWdg.ARROW_UP)
        button_div.add(button)
        button.add_class("spt_collapse")
        inner.add(button_div)
        button.add_style("float: left")
        button.add_style("left: 5px")
        button.add_style("top: 5px")

        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_reports_top");
            var element = top.getElement(".spt_reports_list");

            var buttons = bvr.src_el.getParent(".spt_buttons_top");
            expand = buttons.getElement(".spt_expand");
            new Fx.Tween(element).start('margin-top', "-400px");
            expand.setStyle("display", "");
            bvr.src_el.setStyle("display", "none");
            '''
        } )

        button = SingleButtonWdg(title="Expand", icon=IconWdg.ARROW_DOWN)
        button.add_style("display: none")
        button.add_class("spt_expand")
        button_div.add(button)
        button.add_style("left: 5px")
        button.add_style("top: 5px")
        inner.add(button_div)
        button.add_style("float: left")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_reports_top");
            var element = top.getElement(".spt_reports_list");

            var buttons = bvr.src_el.getParent(".spt_buttons_top");
            collapse = buttons.getElement(".spt_collapse");
            new Fx.Tween(element).start('margin-top', "0px");
            collapse.setStyle("display", "");
            bvr.src_el.setStyle("display", "none");
            '''
        } )
        """



        reports = []

        # read the config file
        from pyasm.widget import WidgetConfig
        tmp_path = __file__
        dir_name = os.path.dirname(tmp_path)
        file_path="%s/../config/reports-conf.xml" % (dir_name)
        config = WidgetConfig.get(file_path=file_path, view="definition")

        category = my.kwargs.get('category')

        # get all of the configs from the database
        if not category or category in ["custom_reports", "custom_charts"]:
            search = Search("config/widget_config")
            search.add_op("begin")
            if category == "custom_reports":
                search.add_filter("widget_type", "report")
            elif category == "custom_charts":
                search.add_filter("widget_type", "chart")
            elif not category:
                search.add_filters("widget_type", ["chart","report"])

            search.add_op("or")
            db_configs = search.get_sobjects()
        else:
            db_configs = []


        element_names = my.kwargs.get("element_names")
        if element_names is None:
            element_names = config.get_element_names()



        project = Project.get()

        for element_name in element_names:
            key = {'project': project.get_code(), 'element': element_name}
            key2 = {'project': project.get_code(), 'element': '*'}
            key3 = {'element': element_name}
            key4 = {'element': '*'}
            keys = [key, key2, key3, key4]
            if not top.check_access("link", keys, "view", default="deny"):
                continue

            attrs = config.get_element_attributes(element_name)
            report_data = {}
            kwargs = config.get_display_options(element_name)
            class_name = kwargs.get('class_name')

            # the straight xml definition contains the sidebar class_name
            # with LinkWdg ... we shouldn't use this, so build the
            # element from scratch
            #xml = config.get_element_xml(element_name)
            from pyasm.search import WidgetDbConfig
            xml = WidgetDbConfig.build_xml_definition(class_name, kwargs)

            report_data['class_name'] = class_name
            report_data['kwargs'] = kwargs
            report_data['title'] = attrs.get("title")
            report_data['description'] = attrs.get("description")
            report_data['image'] = attrs.get("image")
            report_data['xml'] = xml

            reports.append(report_data)



        for db_config in db_configs:
            element_name = db_config.get_value("view")
            key = {'project': project.get_code(), 'element': element_name}
            key2 = {'project': project.get_code(), 'element': '*'}
            key3 = {'element': element_name}
            key4 = {'element': '*'}
            keys = [key, key2, key3, key4]
            if not top.check_access("link", keys, "view", default="deny"):
                continue

            report_data = {}
            view = db_config.get_value("view")
            kwargs = {
                'view': view
            }
            parts = view.split(".")
            title = Common.get_display_title(parts[-1])

            xml = db_config.get_value("config")

            report_data['class_name'] = "tactic.ui.panel.CustomLayoutWdg"
            report_data['kwargs'] = kwargs
            report_data['title'] = title
            report_data['description'] = title
            report_data['image'] = None
            report_data['xml'] = xml
            report_data['widget_type'] = db_config.get_value("widget_type")
            if report_data['widget_type'] == 'report':
                report_data['category'] = "custom_reports"
            elif report_data['widget_type'] == 'chart':
                report_data['category'] = "custom_charts"


            reports.append(report_data)





        """
        report_data = {
            'title': 'Tasks Completed This Week',
            'class_name': 'tactic.ui.panel.ViewPanelWdg',
            'kwargs': {
                    'search_type': 'sthpw/task',
                    'view': 'table'
                },
        }
        reports.append(report_data)
        """
        if category == 'list_item_reports' or not category:
            search_types = Project.get().get_search_types()
            for search_type in search_types:
                base_key = search_type.get_base_key()

                key = {'project': project.get_code(), 'code': base_key}
                key2 = {'project': project.get_code(), 'code': '*'}
                key3 = {'code': base_key}
                key4 = {'code': '*'}
                keys = [key, key2, key3, key4]
                if not top.check_access("search_type", keys, "view", default="deny"):
                    continue


                if not SearchType.column_exists(base_key, "pipeline_code"):
                    continue

                thumb_div = DivWdg()
                image = thumb_div
                thumb_div.add_border()
                thumb_div.set_box_shadow("1px 1px 1px 1px")
                thumb_div.add_style("width: 60px")

                thumb = ThumbWdg()
                thumb_div.add(thumb)
                thumb.set_sobject(search_type)
                thumb.set_icon_size(60)

                report_data = {
                    'title': '%s Workflow Status' % search_type.get_title(),
                    'description': 'Number of items in each process',
                    'class_name': 'tactic.ui.report.stype_report_wdg.STypeReportWdg',
                    'kwargs': {
                        'search_type': base_key
                    },
                    'image': thumb_div
                }
                reports.append(report_data)

 
                report_data = {
                    'title': '%s Labor Cost Report' % search_type.get_title(),
                    'description': 'Labor Cost Breakdown for each Item',
                    'class_name': 'tactic.ui.panel.ViewPanelWdg',
                    'kwargs': {
                        'search_type': search_type.get_code(),
                        'view': "table",
                        'show_header': False,
                        'mode': 'simple',
                        'element_names': "preview,code,title,cost_breakdown,bid_hours,bid_cost,actual_hours,actual_cost,overbudget,variance"
                    },
                    'image': IconWdg("", IconWdg.REPORT_03)
                }
                reports.append(report_data)



        table2 = Table()
        inner.add(table2)
        table2.add_style("width: 100%")


        categories_div = DivWdg()
        td = table2.add_cell(categories_div)
        td.add_style("vertical-align: top")
        td.add_style("width: 200px")
        td.add_color("background", "background3")
        td.add_border()

        #categories_div.add_style("margin: -1px 0px 0px -1px")
        categories_div.add_style("padding-top: 10px")
        #categories_div.add_style("float: left")
        categories_div.add_color("color", "color3")


        categories = config.get_all_views()
        categories.insert(-1, "list_item_reports")
        categories.insert(-1, "custom_charts")
        categories.insert(-1, "custom_reports")

        table_div = DivWdg()
        td = table2.add_cell(table_div)
        td.add_style("vertical-align: top")
        table_div.add_class("spt_reports_list")
        table_div.add_border()
        table_div.add_color("background", "background", -5)

        table_div.add_style("min-height: 500px")



        for i, category in enumerate(categories):

            if i == len(categories) - 1:
                categories_div.add("<hr/>")


            config.set_view(category)
            element_names = config.get_element_names()

            if category == "definition":
                title = "All Reports"
            else:
                title = Common.get_display_title(category)


            category_div = DivWdg()
            categories_div.add(category_div)
            category_div.add(title)
            category_div.add_style("padding: 5px")
            category_div.add_class("hand")

            category_div.add_behavior( {
            'type': 'click_up',
            'category': category,
            'element_names': element_names,
            'class_name': Common.get_full_class_name(my),
            'cbjs_action': '''
            var kwargs = {
                is_refresh: true,
                category: bvr.category,
                element_names: bvr.element_names
            }

            //spt.panel.refresh(top, kwargs);
            var top = bvr.src_el.getParent(".spt_reports_top");
            spt.panel.load(top, bvr.class_name, kwargs);
            '''
            } )

            bgcolor = category_div.get_color("background3", -10)
            category_div.add_behavior( {
            'type': 'mouseover',
            'bgcolor': bgcolor,
            'cbjs_action': '''
            bvr.src_el.setStyle("background", bvr.bgcolor);
            '''
            } )
            category_div.add_behavior( {
            'type': 'mouseout',
            'bgcolor': bgcolor,
            'cbjs_action': '''
            bvr.src_el.setStyle("background", "");
            '''
            } )








        # create a bunch of panels
        table = Table()
        table_div.add(table)
        table.add_color("color", "color")
        table.add_style("margin-top: 20px")
        table.center()
        table_div.add_style("margin: -3px -3px -1px -2px")


        if not reports:
            tr = table.add_row()
            td = table.add_cell()
            td.add("There are no reports defined.")
            td.add_style("padding: 50px")

            if my.kwargs.get("is_refresh") in ['true', True]:
                return inner
            else:
                return top



        for i, report in enumerate(reports):

            #if i == 0 or i%4 == 0:
            if i%3 == 0:
                tr = table.add_row()

            td = table.add_cell()
            td.add_style("vertical-align: top")
            td.add_style("padding: 3px")
            title = report
            #description = '''The schema is used to layout the basic components of your project.  Each component represents a list of items that you use in your business everyday.'''

            description = report.get("title")

            # Each node will contain a list of "items" and will be stored as a table in the database.'''

            class_name = report.get("class_name")
            kwargs = report.get("kwargs")
            title = report.get("title")
            description = report.get("description")
            widget_type = report.get("widget_type")

            image = report.get("image")
            icon = report.get("icon")
            xml = report.get("xml")

            if image:
                div = DivWdg()
                if isinstance(image, basestring):
                    image = image.upper()
                    image = eval("IconWdg('', IconWdg.%s)" % image)
                    div.add_style("margin-left: 15px")
                    div.add_style("margin-top: 5px")
                else:
                    image = image
                div.add(image)
                image = div

            elif icon:
                icon = icon.upper()
                image = eval("IconWdg('', IconWdg.%s)" % icon)

            else:
                div = DivWdg()
                """
                import random
                num = random.randint(0,3)
                if num == 1:
                    image = IconWdg("Bar Chart", IconWdg.GRAPH_BAR_01)
                elif num == 2:
                    image = IconWdg("Bar Chart", IconWdg.GRAPH_LINE_01)
                else:
                    image = IconWdg("Bar Chart", IconWdg.GRAPH_BAR_02)
                """

                if widget_type == "chart":
                    image = IconWdg("Chart", IconWdg.GRAPH_BAR_02)
                else:
                    image = IconWdg("No Image", IconWdg.WARNING)
                div.add_style("margin-left: 15px")
                div.add_style("margin-top: 5px")
                div.add(image)
                image = div


            behavior = {
            'type': 'click_up',
            'title': title,
            'class_name': class_name,
            'kwargs': kwargs,
            'cbjs_action': '''

            spt.tab.set_main_body_tab();
            //var top = bvr.src_el.getParent(".spt_reports_top");
            //spt.tab.set_tab_top(top);
            spt.tab.add_new(bvr.title, bvr.title, bvr.class_name, bvr.kwargs);
            '''
            }
            schema_wdg = my.get_section_wdg(title, description, image, behavior)

            schema_wdg.add_behavior( {
            'type': 'load',
            'title': title,
            'class_name': class_name,
            'xml': xml,
            'kwargs': kwargs,
            'cbjs_action': '''
                var report_top = bvr.src_el;
                report_top.kwargs = bvr.kwargs;
                report_top.class_name = bvr.class_name;
                report_top.element_name = bvr.title;
                report_top.xml = bvr.xml;
            '''
            } )

            td.add(schema_wdg)


        inner.add("<br/>")



        #from tactic.ui.container import TabWdg
        #tab = TabWdg(show_add=False)
        #inner.add(tab)

        if my.kwargs.get("is_refresh") in ['true', True]:
            return inner
        else:
            return top
示例#10
0
文件: home_wdg.py 项目: mincau/TACTIC
    def get_display(self):

        top = DivWdg()
        top.add_border()
        top.add_style("padding: 10px")
        top.add_color("color", "color")
        top.add_color("background", "background")
        #top.add_style("height: 550px")

        top.add_class("spt_reports_top")


        title = DivWdg()
        title.add("Searchable Lists")
        title.add_style("font-size: 18px")
        title.add_style("font-weight: bold")
        title.add_style("text-align: center")
        title.add_style("padding: 10px")
        title.add_style("margin: -10px -10px 0px -10px")

        top.add(title)
        title.add_gradient("background", "background3", 5, -10)
        top.add("<br/>")

        button_div = DivWdg()
        top.add(button_div)
        button = SingleButtonWdg(title="Collapse", icon=IconWdg.ARROW_UP)
        button_div.add(button)
        top.add(button_div)
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_reports_top");
            var element = top.getElement(".spt_reports_list");
            spt.toggle_show_hide(element)

            '''
        } )

        #desc = DivWdg()
        #top.add(desc)
        #desc.add("Dashboard")
        #desc.add_style("width: 600px")

        reports = []

        # read the config file
        """
        from pyasm.widget import WidgetConfig
        tmp_path = __file__
        dir_name = os.path.dirname(tmp_path)
        file_path="%s/../config/reports-conf.xml" % (dir_name)
        config = WidgetConfig.get(file_path=file_path, view="definition")
        element_names = config.get_element_names()

        for element_name in element_names:
            print "element_name: ", element_name
            attrs = config.get_element_attributes(element_name)
            report_data = {}
            kwargs = config.get_display_options(element_name)
            class_name = kwargs.get('class_name')

            report_data['class_name'] = class_name
            report_data['kwargs'] = kwargs
            report_data['title'] = attrs.get("title")
            report_data['description'] = attrs.get("description")

            reports.append(report_data)
        """

        project = Project.get()
        project_code = project.get_code()
        search_type_objs = project.get_search_types()

        filtered = [] 
        for search_type_obj in search_type_objs:
            search_type = search_type_obj.get_value("search_type")

            # FIXME: this code is also present 
            from pyasm.security import get_security_version
            security_version = get_security_version()
            if security_version >= 2 and not search_type.startswith("sthpw/") and not search_type.startswith("config/"):
                security = Environment.get_security()

                table = search_type_obj.get_value("table_name")

                default = "deny"
                key  = { "element": "%s_list" % table }
                key2 = { "element": "%s_list" % table, "project": project_code }
                key3 = { "element": "*" }
                key4 = { "element": "*", "project": project_code }
                keys = [key, key2, key3, key4]
                if not security.check_access("link", keys, "view", default=default):
                    continue

                key = { "code": search_type }
                key2 = { "code": "*" }
                keys = [key, key2]
                if not security.check_access("search_type", keys, "view", default=default):
                    continue
                

                filtered.append(search_type_obj)


        search_type_objs = filtered

        for search_type_sobj in search_type_objs:
            description = search_type_sobj.get_value("description")
            search_type = search_type_sobj.get_value("search_type")



            search = Search(search_type)
            count = search.get_count()

            title_div = DivWdg()
            items_div = DivWdg()
            title_div.add(items_div)
            items_div.add_style("font-size: 9px")
            items_div.add_style("font-weight: italic")
            items_div.add_style("float: right")
            items_div.add("%s item/s" % count)
            title_div.add(search_type_sobj.get_title())

            description_div = DivWdg()
            description_div.add(description)
            description_div.add_style("padding: 5px")
            if not description:
                description_div.add("<br/>(No description)")
                description_div.add_style("font-style: italic")
                description_div.add_style("opacity: 0.3")


            report_data = {
                'title': search_type_sobj.get_title(),
                'title_wdg': title_div,
                'class_name': 'tactic.ui.panel.ViewPanelWdg',
                'kwargs': {
                        'search_type': search_type,
                        'view': 'table',
                        'simple_search_view': 'simple_search'
                    },
                'description': description_div,
                'search_type': search_type_sobj
            }
            reports.append(report_data)


        # create a bunch of panels
        list_div = DivWdg()
        top.add(list_div)
        list_div.add_class("spt_reports_list")


        table = Table()
        list_div.add(table)
        table.add_color("color", "color")
        table.add_style("margin-bottom: 5px")
        table.center()

        top.add("<br clear='all'/>")


        for i, report in enumerate(reports):

            if i == 0 or i%4 == 0:
                tr = table.add_row()

            td = table.add_cell()
            td.add_style("vertical-align: top")
            td.add_style("padding: 3px")

            class_name = report.get("class_name")
            kwargs = report.get("kwargs")
            title = report.get("title")
            description = report.get("description")

            #image = "<img src='/context/images/getting_started_schema.png'/>"
            image = "<img src='/context/images/getting_started_pipeline.png'/>"


            thumb_div = DivWdg()
            image = thumb_div
            thumb_div.add_border()
            thumb_div.set_box_shadow("1px 1px 1px 1px")

            thumb = ThumbWdg()
            thumb_div.add(thumb)
            thumb.set_sobject(report.get("search_type"))
            thumb.set_icon_size(60)




            behavior = {
            'type': 'click_up',
            'title': title,
            'class_name': class_name,
            'kwargs': kwargs,
            'cbjs_action': '''

            var top = bvr.src_el.getParent(".spt_reports_top");
            //spt.tab.set_main_body_tab();
            spt.tab.set_tab_top(top);
            var kwargs = {};
            spt.tab.add_new(bvr.title, bvr.title, bvr.class_name, bvr.kwargs);
            '''
            }
            title_wdg = report.get("title_wdg")
            schema_wdg = self.get_section_wdg(title_wdg, description, image, behavior)
            td.add(schema_wdg)



        from tactic.ui.container import TabWdg
        tab = TabWdg(show_add=False)
        top.add(tab)



        return top
示例#11
0
    def get_display(my):

        top = DivWdg()
        top.add_border()
        top.add_style("padding: 10px")
        top.add_color("color", "color")
        top.add_color("background", "background")

        title = DivWdg()
        title.add("Advanced Project Setup Tools")
        title.add_style("font-size: 18px")
        title.add_style("font-weight: bold")
        title.add_style("text-align: center")
        title.add_style("padding: 10px")
        title.add_style("margin: -10px -10px 10px -10px")

        top.add(title)
        from tactic.ui.widget import TitleWdg
        subtitle = TitleWdg(name_of_title='',
                            help_alias='project-startup-configuration')
        top.add(subtitle)

        title.add_gradient("background", "background3", 5, -10)
        top.add("<br/>")

        content = DivWdg()
        top.add(content)
        """
        desc = DivWdg()
        content.add(desc)
        desc.add_style("text-align: left")
        desc.add_style("padding-left: 15px")
        desc.center()
        desc.add("The following tools are used for advanced project configuration.<br/><br/>")
        desc.add_style("width: 600px")
        """

        button_div = DivWdg()
        button = SingleButtonWdg(title="Project Startup", icon=IconWdg.HOME)
        button_div.add(button)
        button_div.add_style("float: left")
        button_div.add_style("margin-top: -10px")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            spt.tab.set_main_body_tab();
            var class_name = 'tactic.ui.startup.MainWdg';
            var kwargs = {
                help_alias: 'project-startup-configuration'
            };
            spt.tab.add_new("_startup", "Startup", class_name, kwargs);
        
            '''
        })
        content.add(button_div)

        table = Table()
        content.add(table)
        table.add_color("color", "color")
        table.add_row()
        table.center()

        # Schema Editor
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Create Schema"

        description = '''The schema is a collection of nodes that layout the basic components of a project. Each node represents a separate list of items (sType) used in this project: ie Assets, Shots, Artwork, etc.'''

        #image = "<img src='/context/icons/64x64/schema_64.png'/>"
        image = "<img src='/context/images/getting_started_schema.png'/>"
        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.tools.SchemaToolWdg';
        var kwargs = {
            help_alias: 'project-schema'    
        };
        spt.tab.add_new("create_schema", "Create Schema", class_name, kwargs);
        '''
        }
        schema_wdg = my.get_main_section_wdg(title, description, image,
                                             behavior)
        td.add(schema_wdg)

        # Workflow
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Create Workflow"
        image = "<img src='/context/images/getting_started_pipeline.png'/>"

        description = "Pipelines define how particular items of an sType will move through its lifecycle. Creating pipelines will also allow you to set up automatic triggers and notifications for each process."

        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.tools.PipelineToolWdg';
        var kwargs = {
            help_alias: 'project-workflow'
        };
        spt.tab.add_new("create_workflow", "Create Workflow", class_name, kwargs);
        '''
        }
        pipeline_wdg = my.get_main_section_wdg(title, description, image,
                                               behavior)
        td.add(pipeline_wdg)

        # Sidebar
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Manage Side Bar"

        #image = "<img src='/context/icons/64x64/sidebar_64.png'/>"
        image = "<img src='/context/images/getting_started_sidebar.png'/>"

        description = "The Side Bar can be easily configured to show specific views of your project to each user."
        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.panel.ManageViewPanelWdg';
        var kwargs = {
            help_alias: 'managing-sidebar'
        };
        spt.tab.add_new("manage_project_views", "Manage Side Bar", class_name, kwargs);
        '''
        }

        side_bar_wdg = my.get_main_section_wdg(title, description, image,
                                               behavior)
        td.add(side_bar_wdg)

        tr = table.add_row()

        # Manage View
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Manage Views"

        image = IconWdg("Manage Views", IconWdg.LIST_01)
        div = DivWdg(image)
        image = div

        description = "Manage the views within the project."
        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.manager.ViewManagerWdg';
        var kwargs = {
            help_alias: 'view-manager'
            };
        spt.tab.add_new("manage_views", "Manage Views", class_name, kwargs);
        '''
        }

        manage_view_wdg = my.get_small_section_wdg(title, description, image,
                                                   behavior)
        td.add(manage_view_wdg)

        # Naming Conventions
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Naming Conventions"

        image = IconWdg("Naming Conventions", IconWdg.FOLDERS_01)
        div = DivWdg(image)
        image = div

        description = "Setup custom Directory and File naming conventions."
        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.panel.ViewPanelWdg';
        var kwargs = {
	    'view': 'table',
            'search_type': 'config/naming',
            help_alias: 'project-automation-file-naming'
	};
        spt.tab.add_new("naming_conventions", "Naming Conventions", class_name, kwargs);
        '''
        }

        naming_wdg = my.get_small_section_wdg(title, description, image,
                                              behavior)
        td.add(naming_wdg)

        # Users
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Manage Security"

        image = IconWdg("Manage Security", IconWdg.LOCK_32_01)
        div = DivWdg(image)
        image = div

        description = "Manage users and group permissions"
        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.startup.SecurityWdg';
        var kwargs = { };
        spt.tab.add_new("manage_security", "Manage Security", class_name, kwargs);

        '''
        }

        users_wdg = my.get_small_section_wdg(title, description, image,
                                             behavior)
        td.add(users_wdg)

        tr = table.add_row()

        # Script Editor
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Script Editor"

        image = IconWdg("Script Editor", IconWdg.SCRIPT_EDITOR_01)
        div = DivWdg(image)
        image = div

        description = "Edit and Create custom Python and Javascipt tools, triggers and scripts."
        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        
	var title = "TACTIC Script Editor"
	var class_name = "tactic.ui.app.ShelfEditWdg"
        spt.panel.load_popup(title, class_name, {}, {"load_once": true} )
        
        '''
        }

        script_editor_wdg = my.get_small_section_wdg(title, description, image,
                                                     behavior)
        td.add(script_editor_wdg)

        # Project Settings
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Project Settings"

        image = IconWdg("Project Settings", IconWdg.CONFIGURE_02)
        div = DivWdg(image)
        image = div

        description = "Setting for the current project."
        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.panel.ViewPanelWdg';
        var kwargs = {
	    'view': 'table',
            'search_type': 'config/prod_setting',
            help_alias: 'main'            
	};
        spt.tab.add_new("project_settings", "Project Settings", class_name, kwargs);
        '''
        }

        prod_settings_wdg = my.get_small_section_wdg(title, description, image,
                                                     behavior)
        td.add(prod_settings_wdg)

        # Widget Config
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Widget Config"

        image = IconWdg("Widget Config", IconWdg.WIDGET_CONFIG_01)
        div = DivWdg(image)
        image = div

        description = "Modify the base widget configurations for the project."
        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.panel.ViewPanelWdg';
        var kwargs = {
	    'view': 'table',
            'search_type': 'config/widget_config',
            help_alias: 'tactic-widgets'
	};
        spt.tab.add_new("widget_config", "Widget Config", class_name, kwargs);
        '''
        }

        config_wdg = my.get_small_section_wdg(title, description, image,
                                              behavior)
        td.add(config_wdg)

        # Quicklinks

        tr, td = table.add_row_cell()
        td.add_style("font-size: 14px")
        td.add("<br/>")

        div = DivWdg()
        title = DivWdg()
        div.add(title)
        div.add_color("background", "background")
        div.add_style("margin: 0px 10px 15px 10px")

        title.add("Quick Links")
        title.add_style("font-size: 16px")
        title.add_style("padding: 5px")
        title.add_gradient("background", "background")
        title.add_border()
        title.set_round_corners(corners=['TL', 'TR'])

        content_wdg = DivWdg()
        div.add(content_wdg)
        content_wdg.add_border()
        content_wdg.add_style("padding: 20px")

        content_wdg.add(
            "<div style='font-size: 12px'>The following links will help you find out more information on how to set up or use TACTIC.</div>"
        )
        content_wdg.add("<hr/>")

        hover = title.get_color("background", -10)

        link_div = DivWdg()
        link_div.add_style("padding: 10px")
        content_wdg.add(link_div)
        icon = IconWdg("TACTIC Documentation", IconWdg.JUMP)
        link_div.add(icon)

        link = HtmlElement.href("TACTIC Documentation",
                                "/doc/",
                                target="_blank")
        link.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            spt.help.set_top();
            spt.help.load_alias("main");
            '''
        })

        link.add_behavior({
            'type':
            'hover',
            'color':
            hover,
            'cbjs_action_over':
            '''
        bvr.src_el.setStyle("background", bvr.color);
        ''',
            'cbjs_action_out':
            '''
        bvr.src_el.setStyle("background", "");
        '''
        })
        link_div.add(link)
        link.add_color("color", "color")
        link_div.add("<br/>" * 2)

        icon = IconWdg("Southpaw Web Site", IconWdg.JUMP)
        link_div.add(icon)
        link = HtmlElement.href("Southpaw Web Site",
                                "http://www.southpawtech.com",
                                target="_blank")
        link_div.add(link)
        link.add_color("color", "color")
        link.add_behavior({
            'type':
            'hover',
            'color':
            hover,
            'cbjs_action_over':
            '''
        bvr.src_el.setStyle("background", bvr.color);
        ''',
            'cbjs_action_out':
            '''
        bvr.src_el.setStyle("background", "");
        '''
        })

        link_div.add("<br/>" * 2)

        icon = IconWdg("TACTIC Community", IconWdg.JUMP)
        link_div.add(icon)
        link = HtmlElement.href("TACTIC Community",
                                "http://community.southpawtech.com",
                                target="_blank")
        link_div.add(link)
        link.add_color("color", "color")
        link.add_behavior({
            'type':
            'hover',
            'color':
            hover,
            'cbjs_action_over':
            '''
        bvr.src_el.setStyle("background", bvr.color);
        ''',
            'cbjs_action_out':
            '''
        bvr.src_el.setStyle("background", "");
        '''
        })

        td.add(div)

        return top
    def get_display(my):

        top = my.top

        #top.add_gradient("background", "background", 5, -20)
        top.add_color("background", "background", -5)
        #top.add_style("padding-top: 10px")

        #title = "Sample Chart"
        title = my.kwargs.get("title")
        if title:
            date = "@FORMAT(@STRING($TODAY),'Dec 31, 1999')"
            date = Search.eval(date, single=True)

            title_wdg = DivWdg()
            top.add(title_wdg)
            title_wdg.add(title)
            title_wdg.add(" [%s]" % date)
            title_wdg.add_style("font-size: 1.1em")
            title_wdg.add_color("background", "background3")
            title_wdg.add_color("color", "color3")
            title_wdg.add_style("padding: 10px")
            title_wdg.add_style("font-weight: bold")
            title_wdg.add_style("text-align: center")

        colors = [
            'rgba(255,0,0,0.5)',
            'rgba(0,255,0,0.5)',
            'rgba(0,0,255,0.5)',
            'rgba(128,0,255,0.5)',
            'rgba(0,128,255,0.5)',
            'rgba(255,0,255,0.5)',
        ]

        # draw a legend
        legend = None
        from chart2_wdg import ChartLegend

        #import pdb; pdb.set_trace();

        labels = my.kwargs.get("labels")
        my.user = my.kwargs.get("user")

        if labels:
            legend = ChartLegend()
            labels = labels.split("|")
            legend.set_labels(labels)
            top.add(legend)
            legend.add_style("width: %s" % str(len(labels)*200))
            legend.add_style("margin-left: auto")
            legend.add_style("margin-right: auto")

            #legend.add_style("width: 200px")
            #legend.add_style("position: absolute")
            #legend.add_style("top: 40px")
            #legend.add_style("left: 300px")


        if legend:
            legend.set_colors(colors)


        #############
        # table for start-end date
        search_table = Table()
        search_table.add_style("margin-left: auto")
        search_table.add_style("margin-right: auto")
        search_table.add_style("margin-top: 35px")
        search_table.add_style("margin-bottom: 45px")
        top.add(search_table)
 
        search_table.add_row()

        td = search_table.add_cell()
        start_date = DivWdg("Start Date")
        td.add(start_date)
        start_date.add_style("margin-left: 5px")
        #td = table.add_cell()
        #op = DivWdg(" between&nbsp;&nbsp;&nbsp;")
        #op.add_style("margin-left: 5px")
        #td.add(op)

        from tactic.ui.widget import CalendarInputWdg
        td = search_table.add_cell()
        cal1 = CalendarInputWdg("start_date")
        td.add(cal1)

        search_table.add_row()
        end_date = DivWdg("End Date")
        end_date.add_style("margin-left: 5px")
        td = search_table.add_cell()
        td.add(end_date)
        #td.add(spacing)

        td = search_table.add_cell()
        cal2 = CalendarInputWdg("end_date")
        td.add(cal2)

        search_table.add_row()
        td = search_table.add_cell()

        from pyasm.widget import ButtonWdg
        button = ButtonWdg()
        #button.add_style("width: %s" % top_width)
        button.add_class('spt_label')

        icon = my.kwargs.get("icon")
        if icon:
            icon_div = DivWdg()
            icon = IconWdg(title, icon, width=16 )
            icon_div.add(icon)
            button.add(icon_div)
            my.table.add_style("position: relative")
            icon_div.add_style("position: absolute")
            icon_div.add_style("left: 5px")
            icon_div.add_style("top: 6px")
            title = " &nbsp; &nbsp; %s" % title
            button.add_style("padding: 2px")

        button.set_name("Reload")

        td.add(button)
        #############


        task_data = my.get_task_data()
        
        labels = [label[0] for label in task_data.get(task_data.keys()[0])]

        #labels = ['chr001', 'chr002', 'chr003', 'chr004', 'prop001', 'prop002', 'cow001']
        #labels = ['week 1', 'week 2', 'week 3', 'week 4', 'week 5', 'week 6', 'week 7', 'week 8']
        #values = [1,2,4,5,6,7,8]
        values = [i+1 for i in range(len(labels))]

        width = my.kwargs.get("width")
        if not width:
            width = '1600px'
        height = my.kwargs.get("height")
        if not height:
            height = '1000px'


        chart_div = DivWdg()
        top.add(chart_div)
        chart_div.add_style("text-align: center")

        chart = ChartWdg(
            height=height,
            width=width,
            chart_type='bar',
            labels=labels
        )
        chart_div.add(chart)

        data = ChartData(
            color=colors[0], #"rgba(255, 0, 0, 1.0)",
            #data=[task_data['Pending'], 5.5, 7.5, 14.3, 10.2, 1.1, 3.3],
            data = [data[1] for data in task_data.get('Pending')]
        )
        chart.add(data)

        data = ChartData(
            color=colors[1], #"rgba(0, 255, 0, 1.0)",
            #data=[task_data['Assignment'], 4.3, 8.4, 6.2, 8.4, 2.2],
            data = [data[1] for data in task_data.get('Assignment')]
        )
        chart.add(data)


        data = ChartData(
            color=colors[2], #"rgba(0, 0, 255, 1.0)",
            #data=[task_data['In Progress'], 3.5, 2.2, 6.6, 1.3, 9.4],
            data = [data[1] for data in task_data.get('In Progress')]
        )
        chart.add(data)


        #data = [task_data['Approved'], 17, 15.5, -3, 17, 16.8, 11.4]
        data = [data[1] for data in task_data.get('Approved')]
        data = ChartData(data=data, color=colors[3]) #"rgba(128, 0, 255, 1.0)")
        chart.add(data)


        data = [data[1] for data in task_data.get('Review')] 
        data = ChartData(data=data, color=colors[4]) #"rgba(0, 128, 255, 1.0)")
        chart.add(data)

        table = Table()
        table.add_color("color", "color")
        top.add(table)
        table.add_row()
        table.center()
        table.add_style("width: 1%")


        x_title = my.kwargs.get("x_title")
        y_title = my.kwargs.get("y_title")

        if y_title:
            y_title = y_title.replace(" ", "&nbsp;")

            y_axis_div = DivWdg()
            td = table.add_cell(y_axis_div)
            td.add_style("vertical-align: middle")
            td.add_style("width: 1%")
            y_axis_div.add(y_title)
            y_axis_div.add_style("-moz-transform: rotate(-90deg)")
            y_axis_div.add_style("-webkit-transform: rotate(-90deg)")
            y_axis_div.add_style("font-size: 1.33em")
            y_axis_div.add_style("height: 100%")
            y_axis_div.add_style("width: 30px")

        table.add_row()

        # add the x-axis title
        if x_title:
            x_title = x_title.replace(" ", "&nbsp;")

            x_axis_div = DivWdg()
            td = table.add_cell(x_axis_div)
            td.add_style("text-align: center")
            td.add_style("width: 1%")
            x_axis_div.add(x_title)
            x_axis_div.add_style("font-size: 1.33em")
            x_axis_div.add_style("width: 100%")
            x_axis_div.add_style("height: 30px")

        return top
示例#13
0
    def get_display(self):

        top = self.top

        top.add_color("background", "background")
        top.add_gradient("color", "color")

        #top.add_style("background", "#000")
        #top.add_style("opacity: 0.95")
        #top.add_style("color: #FFF")

        #top.add_style("padding-top: 10px")
        top.add_style("position: relative")

        title = self.kwargs.get("title")
        if title:
            title_wdg = self.get_title_wdg(title)
            top.add(title_wdg)

        # get the column to use as a date for searching
        self.column = self.kwargs.get("column")
        if not self.column:
            self.column = 'timestamp'


        # elements
        elements = self.kwargs.get("elements")
        if elements:
            if isinstance(elements, basestring):
                elements = elements.split("|")
        elif self.kwargs.get("chart_data"):
            elements = []
        else:
            elements = ['{@COUNT()}']


        # set some start and end dates
        start_date = self.kwargs.get("start_date")
        if not start_date:
            start_date = None
        else:
            if start_date.startswith("{") and start_date.endswith("}"):
                start_date = Search.eval(start_date)

            start_date = parser.parse(start_date)

        end_date = self.kwargs.get("end_date")
        if not end_date:
            end_date = None
        else:
            if end_date.startswith("{") and end_date.endswith("}"):
                end_date = Search.eval(end_date)
            end_date = parser.parse(end_date)


        expression = self.kwargs.get("expression")
        search_type = self.kwargs.get("search_type")
        if expression:
            sobjects = Search.eval(expression)
        elif search_type:
            search = Search(search_type)
            if start_date:
                search.add_filter(self.column, start_date, op=">")
            if end_date:
                search.add_filter(self.column, end_date, op="<")
            sobjects = search.get_sobjects()

        else:
            sobjects = []



        # Is this a plot or a chart
        # A plot puts the X-axis at the right place.
        # A chart has a interval in which data is combined

        self.interval = self.kwargs.get("interval")
        if not self.interval:
            self.interval = 'weekly'
            #self.interval = 'monthly'


        if not sobjects:
            if not start_date:
                min_date = datetime.today() - timedelta(days=30)
            else:
                min_date = start_date

            if not end_date:
                max_date = datetime.today() + timedelta(days=30)
            else:
                max_date = end_date
        else:
            min_date = start_date
            max_date = end_date


        for sobject in sobjects:
            timestamp = sobject.get_value(self.column)
            timestamp = parser.parse(timestamp)
            if min_date == None or timestamp < min_date:
                min_date = timestamp
            if max_date == None or timestamp > max_date:
                max_date = timestamp


        # defined the buckets based on interval
        dates = [] 
        if self.interval == 'weekly':
            min_date = datetime(min_date.year, min_date.month, min_date.day)
            max_date = datetime(max_date.year, max_date.month, max_date.day)
            min_date = min_date - timedelta(days=8)
            max_date = max_date + timedelta(days=8)

            dates = list(rrule.rrule(rrule.WEEKLY, byweekday=0, dtstart=min_date, until=max_date))


        elif self.interval == 'daily':
            min_date = datetime(min_date.year, min_date.month, min_date.day)
            max_date = datetime(max_date.year, max_date.month, max_date.day)
            min_date = min_date - timedelta(days=1)
            #max_date = max_date + timedelta(days=1)

            dates = list(rrule.rrule(rrule.DAILY, dtstart=min_date, until=max_date))


        elif self.interval == 'monthly':
            min_date = datetime(min_date.year, min_date.month, 1)
            if max_date.month == 12:
                year = max_date.year+1
                month = 1
            else:
                year = max_date.year
                month = max_date.month + 1
            
            max_date = datetime(year, month, 1)
            dates = list(rrule.rrule(rrule.MONTHLY, bymonthday=1, dtstart=min_date, until=max_date))


        self.dates_dict = {}
        for date in dates:
            self.dates_dict[str(date)] = []


        # put the appropriate sobjects in each date_dict item
        for sobject in sobjects:
            timestamp = sobject.get_value(self.column)
            timestamp = parser.parse(timestamp)

            if self.interval == "weekly":
                # put in the week
                timestamp = list(rrule.rrule(rrule.WEEKLY, byweekday=0, dtstart=timestamp-timedelta(days=7), count=1))
                timestamp = timestamp[0]
                timestamp = datetime(timestamp.year,timestamp.month,timestamp.day)
            elif self.interval == "daily":
                timestamp = datetime(timestamp.year,timestamp.month,timestamp.day)

            else:
                timestamp = datetime(timestamp.year,timestamp.month,1)

            if self.dates_dict:
            	interval_sobjects = self.dates_dict[str(timestamp)]
            	interval_sobjects.append(sobject)



        # get all the chart labels
        chart_labels = []
        for date in dates:
            if self.interval == 'weekly':
                #chart_labels.append("Week %s" % date.strftime("%W"))
                label = (date + timedelta(days=6)).strftime("%d")
                chart_labels.append("%s - %s" % (date.strftime("%b %d"), label))
            elif self.interval == 'daily':
                chart_labels.append(date.strftime("%b %d"))
            else:
                chart_labels.append(date.strftime("%b %Y"))


        self.sobjects = sobjects


        width = self.kwargs.get("width")
        if not width:
            width = "800px"

        height = self.kwargs.get("height")
        if not height:
            height = "500px"


        x_title = self.kwargs.get("x_title")
        #x_title = Search.eval(x_title)
        y_title = self.kwargs.get("y_title")
        #y_title = Search.eval(y_title)




        # draw a legend
        legend = None
        from chart_wdg import ChartLegend
        labels = self.kwargs.get("labels")
        if labels:
            legend = ChartLegend()
            labels = labels.split("|")
            legend.set_labels(labels)
            top.add(legend)
            legend.add_style("width: %s" % str(len(labels)*200))
            legend.add_style("margin-left: auto")
            legend.add_style("margin-right: auto")
            legend.add_style("margin-top: 5px")

            #legend.add_style("width: 200px")
            #legend.add_style("position: absolute")
            #legend.add_style("top: 40px")
            #legend.add_style("left: 300px")




        table = Table()
        table.add_color("color", "color")
        top.add(table)
        table.add_row()
        table.center()
        table.add_style("width: 1%")


        if y_title:
            y_title = y_title.replace(" ", "&nbsp;")

            y_axis_div = DivWdg()
            td = table.add_cell(y_axis_div)
            td.add_style("vertical-align: middle")
            td.add_style("width: 1%")
            y_axis_div.add(y_title)
            y_axis_div.add_style("-moz-transform: rotate(-90deg)")
            y_axis_div.add_style("-webkit-transform: rotate(-90deg)")
            y_axis_div.add_style("font-size: 1.33em")
            y_axis_div.add_style("height: 100%")
            y_axis_div.add_style("width: 30px")



        rotate_x_axis = self.kwargs.get("rotate_x_axis")
        y_axis_mode = self.kwargs.get("y_axis_mode")

        chart = ChartWdg(
            width=width,
            height=height,
            chart_type='bar',
            #legend=self.elements,
            labels=chart_labels,
            label_values=[i+0.5 for i,x in enumerate(chart_labels)],
            rotate_x_axis=rotate_x_axis,
            y_axis_mode=y_axis_mode
        )
        table.add_cell(chart)


        chart_type = self.kwargs.get("chart_type")
        if not chart_type:
            chart_type = 'bar'



        self.colors = self.kwargs.get("colors")
        if not self.colors:
            self.colors = [
                'rgba(0,255,0,0.5)',
                'rgba(0,0,255,0.5)',
                'rgba(255,0,0,0.5)',
                'rgba(255,255,0,0.5)',
                'rgba(0,255,255,0.5)',
                'rgba(255,0,255,0.5)',
            ]
            #while len(self.elements) >= len(self.colors):
            #    self.colors.extend(self.colors)
        else:
            if isinstance(self.colors,basestring):
                self.colors = self.colors.split("|")


        if legend:
            legend.set_colors(self.colors)


        element_count = 0

        x_data=[i+0.5 for i,x in enumerate(chart_labels)]
        for i, element in enumerate(elements):


            data_values = self.get_data_values(self.dates_dict, dates, element, self.sobjects)

            chart_data = ChartData(
                chart_type=chart_type,
                data=data_values,
                color=self.colors[element_count],
                x_data=x_data
            )
            chart.add(chart_data)
            element_count += 1



        # add in individual charts
        chart_data = self.kwargs.get("chart_data")
        if chart_data and isinstance(chart_data, basestring):
            chart_data = jsonloads(chart_data)

        if not chart_data:
            chart_data = []
        else:
            # draw back to front
            chart_data.reverse()

        for options in chart_data:

            column = options.get("column")
            if not column:
                column = self.column


            expression = options.get("expression")
            if expression:

                # extra filters
                extra = {}
                #extra['sthpw/task'] = []
                #if start_date:
                #    extra['sthpw/task'].append([column, '>', start_date])
                #if end_date:
                #    extra['sthpw/task'].append([column, '<', end_date])


                sobjects = Search.eval(expression, extra_filters=extra)
                dates_dict = self.get_dates_dict(sobjects, dates, column)
            else:
                sobjects = self.sobjects
                dates_dict = self.dates_dict

            data = self.get_data_values(dates_dict, dates, options['element'], sobjects)


            options['data'] = data
            options['x_data'] = x_data
            if not options.get("color"):
                options['color'] = self.colors[element_count]

            if not options.get("chart_type"):
                options['chart_type'] = chart_type
                
            str_options = {}
            for x, y in options.items():
                str_options[str(x)] = y

            chart_data = ChartData(**str_options)

            chart.add(chart_data)

            element_count += 1


        table.add_row()


        # add the x-axis title
        if x_title:
            x_title = x_title.replace(" ", "&nbsp;")

            x_axis_div = DivWdg()
            td = table.add_cell(x_axis_div)
            td.add_style("text-align: center")
            td.add_style("width: 1%")
            x_axis_div.add(x_title)
            x_axis_div.add_style("font-size: 1.33em")
            x_axis_div.add_style("width: 100%")
            x_axis_div.add_style("height: 30px")


        return top
示例#14
0
    def get_display(my):

        top = DivWdg()
        top.add_border()
        top.add_style("padding: 10px")
        top.add_color("color", "color")
        top.add_color("background", "background")

        top.add_class("spt_reports_top")


        title = DivWdg()
        title.add("Dashboards")
        title.add_style("font-size: 18px")
        title.add_style("font-weight: bold")
        title.add_style("text-align: center")
        title.add_style("padding: 10px")
        title.add_style("margin: -10px -10px 10px -10px")
        title.add_gradient("background", "background3", 5, -10)
        top.add(title)

        from tactic.ui.widget import TitleWdg
        subtitle = TitleWdg(name_of_title='List of Dashboards',help_alias='project-startup-dashboards')
        top.add(subtitle)

        top.add("<br/>")

        dashboards = []

        # read the config file
        from pyasm.widget import WidgetConfig
        tmp_path = __file__
        dir_name = os.path.dirname(tmp_path)
        file_path="%s/../config/dashboard-conf.xml" % (dir_name)
        config = WidgetConfig.get(file_path=file_path, view="definition")
        element_names = config.get_element_names()

        
        for element_name in element_names:
            attrs = config.get_element_attributes(element_name)
            dashboard_data = {}
            kwargs = config.get_display_options(element_name)
            class_name = kwargs.get('class_name')

            dashboard_data['class_name'] = class_name
            dashboard_data['kwargs'] = kwargs
            dashboard_data['title'] = attrs.get("title")
            dashboard_data['description'] = attrs.get("description")
            dashboard_data['image'] = attrs.get("image")
            dashboard_data['image'] = attrs.get("image")

            dashboards.append(dashboard_data)




        # get all of the configs from the database
        search = Search("config/widget_config")
        search.add_filter("widget_type", "dashboard")
        db_configs = search.get_sobjects()

        for db_config in db_configs:
            dashboard_data = {}
            view = db_config.get_value("view")
            kwargs = {
                'view': view
            }
            parts = view.split(".")
            title = Common.get_display_title(parts[-1])

            xml = db_config.get_value("config")

            dashboard_data['class_name'] = "tactic.ui.panel.CustomLayoutWdg"
            dashboard_data['kwargs'] = kwargs
            dashboard_data['title'] = title
            dashboard_data['description'] = title
            dashboard_data['image'] = None
            dashboard_data['xml'] = xml
            dashboard_data['widget_type'] = db_config.get_value("widget_type")

            dashboards.append(dashboard_data)



        # create a bunch of panels
        table = Table()
        top.add(table)
        table.add_color("color", "color")
        table.add_style("margin-bottom: 20px")
        table.center()



        for i, dashboard in enumerate(dashboards):

            if i == 0 or i%4 == 0:
                tr = table.add_row()

            td = table.add_cell()
            td.add_style("vertical-align: top")
            td.add_style("padding: 3px")
            title = dashboard

            description = dashboard.get("title")

            # Each node will contain a list of "items" and will be stored as a table in the database.'''

            class_name = dashboard.get("class_name")
            kwargs = dashboard.get("kwargs")
            title = dashboard.get("title")
            description = dashboard.get("description")
            xml = dashboard.get("xml") or ""


 
            image = dashboard.get("image")
            icon = dashboard.get("icon")

            if image:
                div = DivWdg()
                if isinstance(image, basestring):
                    image = image.upper()
                    image = eval("IconWdg('', IconWdg.%s)" % image)
                    div.add_style("margin-left: 15px")
                    div.add_style("margin-top: 5px")
                else:
                    image = image
                div.add(image)
                image = div

            elif icon:
                icon = icon.upper()
                image = eval("IconWdg('', IconWdg.%s)" % icon)

            else:
                div = DivWdg()
                #image = IconWdg("Bar Chart", IconWdg.WARNING)
                image = IconWdg("Bar Chart", IconWdg.DASHBOARD_02)
                div.add_style("margin-left: 15px")
                div.add_style("margin-top: 5px")
                div.add(image)
                image = div



            behavior = {
            'type': 'click_up',
            'title': title,
            'class_name': class_name,
            'kwargs': kwargs,
            'cbjs_action': '''

            var top = bvr.src_el.getParent(".spt_reports_top");
            spt.tab.set_main_body_tab();
            //spt.tab.set_tab_top(top);
            var kwargs = {};
            spt.tab.add_new(bvr.title, bvr.title, bvr.class_name, bvr.kwargs);
            '''
            }
            schema_wdg = my.get_section_wdg(title, description, image, behavior)


            schema_wdg.add_behavior( {
            'type': 'load',
            'title': title,
            'class_name': class_name,
            'xml': xml,
            'kwargs': kwargs,
            'cbjs_action': '''
                var report_top = bvr.src_el;
                report_top.kwargs = bvr.kwargs;
                report_top.class_name = bvr.class_name;
                report_top.element_name = bvr.title;
                report_top.xml = bvr.xml;
            '''
            } )

            td.add(schema_wdg)



        #from tactic.ui.container import TabWdg
        #tab = TabWdg(show_add=False)
        #top.add(tab)



        return top
示例#15
0
    def get_display(my):

        web = WebContainer.get_web()
        login_name = web.get_form_value('login')
        hidden = HiddenWdg('login', login_name)
        box = DivWdg(css='login')

        if web.is_IE():
            box.add_style("margin-top: 150px")
            box.add_style("margin-bottom: 150px")
        else:
            box.add_style("margin-top: auto")
            box.add_style("margin-bottom: auto")
        box.add_style("text-align: center")
     
        div = DivWdg()
        div.add_style("margin: 0px 0px")
        div.add_class("centered")



        div.add_style("padding-top: 95px")


        sthpw = SpanWdg("SOUTHPAW TECHNOLOGY INC", css="login_sthpw")
        sthpw.add_style("color: #CCCCCC")
        div.add( sthpw )
        div.add( HtmlElement.br() )
        div.add(hidden)
        box.add(div)


        # hidden element in the form to pass message that this was not
        # actually a typical submitted form, but rather the result
        # of a login page
        div.add( HiddenWdg("is_from_login", "yes") )
        div.add_style("font-size: 10px")

        table = Table(css="login")
        table.center()
        table.set_attr("cellpadding", "3px")
        table.add_row()

    

        table2 = Table(css="login")
        table2.center()
        table2.add_style("width: 240px")

        table2.add_row()

        td = table2.add_header('After reset, the new password will be sent to the email address for [ %s ].'%login_name)
        td.add_color('color','color', + 80)
        table2.add_row_cell('&nbsp;')
        # build the button manually
        from tactic.ui.widget import ActionButtonWdg
        button = ActionButtonWdg(tip='Reset Password', title='Reset')
        button.add_style('margin: auto')
        button.add_event('onclick',"document.form.elements['reset_password'].value='true'; document.form.submit()")
        table2.add_row()
        td = table2.add_cell(button)
        hidden = HiddenWdg('reset_password')
        td.add(hidden)
       
        #th.add_class('center_content')
        
        table2.add_row()
    

        div.add(HtmlElement.br())
        div.add(table)

        div.add( HtmlElement.spacer_div(1,14) )
        div.add(table2)
        #div.add(HiddenWdg(my.LOGIN_MSG))

        #box.add(script)

        widget = Widget()
        #widget.add( HtmlElement.br(3) )
        table = Table()
        table.add_style("width: 100%")
        table.add_style("height: 85%")
        table.add_row()
        td = table.add_cell()
        td.add_style("vertical-align: middle")
        td.add_style("text-align: center")
        td.add_style("background: transparent")
        td.add(box)
        widget.add(table)
        
        return widget
示例#16
0
    def get_display(my):

        top = DivWdg()
        top.add_border()
        top.add_style("padding: 10px")
        top.add_color("color", "color")
        top.add_gradient("background", "background", 0, -5)
        #top.add_style("height: 550px")

        top.add_behavior( {
            'type': 'load',
            'cbjs_action': '''
            spt.named_events.fire_event("side_bar|hide", {} );
            '''
        } )


        project = Project.get()

        title = TitleWdg(title='Client Home')
        top.add(title)


        shelf = DivWdg()
        top.add(shelf)
        shelf.add_style("margin-left: -8px")
        shelf.add_style("width: 130px")

        security = Environment.get_security()
        view_side_bar = security.check_access("builtin", "view_side_bar", "allow", default='allow')
        if view_side_bar:
            button_div = DivWdg()
            shelf.add(button_div)
            button_div.add_style("float: left")
            button_div.add_style("margin-top: -3px")

            button = IconButtonWdg(title="Side Bar", icon=IconWdg.ARROW_LEFT)
            button_div.add(button)
            shelf.add("Toggle Side Bar")
            button.add_behavior( {
                'type': 'click_up',
                'cbjs_action': '''
                spt.named_events.fire_event("side_bar|toggle");
                '''
            } )

            shelf.add_behavior( {
                'type': 'click_up',
                'cbjs_action': '''
                spt.named_events.fire_event("side_bar|toggle");
                '''
            } )
            shelf.add_class("hand")
        else:
            shelf.add("&nbsp;")


        search_wdg = DivWdg()
        search_wdg.add_class("spt_main_top")
        top.add(search_wdg)
        search_wdg.add_style("padding: 10px")
        search_wdg.add_style("margin: 10px auto")
        search_wdg.add_style("width: 430px")
        search_wdg.add("Search: ")
        search_wdg.add("&nbsp;"*3)





        custom_cbk = {}
        custom_cbk['enter'] = '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords != '') {
                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    'search_type': 'sthpw/sobject_list',
                    'view': 'table',
                    'keywords': keywords,
                    'simple_search_view': 'simple_search',
                    //'show_shelf': false,
                }
                spt.tab.set_main_body_tab();
                spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            }
        '''


        from tactic.ui.input import TextInputWdg, LookAheadTextInputWdg
        #text = TextInputWdg(name="search")
        text = LookAheadTextInputWdg(name="search", custom_cbk=custom_cbk)
        #text = TextWdg("search")
        text.add_class("spt_main_search")
        text.add_style("width: 290px")
        search_wdg.add(text)
        search_wdg.add_style("font-weight: bold")
        search_wdg.add_style("font-size: 16px")


        button = ActionButtonWdg(title="Search")
        #search_wdg.add(button)
        button.add_style("float: right")
        #button.add_style("margin-top: -28px")

        icon_div = DivWdg()
        search_wdg.add(icon_div)
        icon_div.add_style("width: 38px")
        icon_div.add_style("height: 27px")
        icon_div.add_style("padding-top: 3px")
        icon_div.add_style("padding-left: 4px")
        icon_div.add_style("text-align: center")
        #icon_div.add_gradient("background", "background3", 15, -10)
        icon_div.add_color("background", "background3", 10)
        over_color = icon_div.get_color("background3", 0)
        out_color = icon_div.get_color("background3", 10)
        icon_div.set_round_corners(5)
        icon_div.set_box_shadow("1px 1px 1px 1px")
        icon = IconWdg("Search", IconWdg.SEARCH_32, width=24)
        icon_div.add(icon)
        icon_div.add_style("float: right")
        icon_div.add_style("margin-top: -5px")
        button = icon_div
        icon_div.add_class("hand")
        icon_div.add_behavior( {
            'type': 'mouseover',
            'color': over_color,
            'cbjs_action': '''
            bvr.src_el.setStyle("background", bvr.color);
            '''
        } )
        icon_div.add_behavior( {
            'type': 'mouseout',
            'color': out_color,
            'cbjs_action': '''
            bvr.src_el.setStyle("background", bvr.color);
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        } )
        icon_div.add_behavior( {
            'type': 'click',
            'color': out_color,
            'cbjs_action': '''
            bvr.src_el.setStyle("box-shadow", "0px 0px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-3");
            bvr.src_el.setStyle("margin-right", "-2");
            '''
        } )
        icon_div.add_behavior( {
            'type': 'click_up',
            'color': out_color,
            'cbjs_action': '''
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        } )





        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords == '') {
                return;
            }

            var class_name = 'tactic.ui.panel.ViewPanelWdg';
            var kwargs = {
                'search_type': 'sthpw/sobject_list',
                'view': 'table',
                'keywords': keywords,
                'simple_search_view': 'simple_search',
                //'show_shelf': false,
            }
            spt.tab.set_main_body_tab();
            spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            '''
        } )

        #desc = DivWdg()
        #top.add(desc)
        #desc.add("Dashboard")
        #desc.add_style("width: 600px")


        # create a bunch of panels
        table = Table()
        table.add_color("color", "color")
        table.add_style("margin-bottom: 20px")
        table.center()
        top.add(table)
        table.add_row()


        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "My Approvals"
        description = '''View all pending items for approval<br/><br/>
        '''
        #image = "<img src='/context/images/getting_started_pipeline.png'/>"
        image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.panel.ViewPanelWdg';
        var kwargs = {
            search_type: 'sthpw/sobject_list',
            view: 'client_approval',
            show_shelf: false,
            show_select: false,
            element_names: ['preview', 'name', 'description', 'task_pipeline_vertical','notes'],
            is_editable: false,
            //expression: "@SOBJECT(sthpw/task['project_code','fickle3'].fickle3/cars.sthpw/sobject_list)"
        };
        spt.tab.add_new("approvals", "Approvals", class_name, kwargs);
        '''
        }
        config_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(config_wdg)



        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "My Dashboard"
        image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''Dashboards display key project data in single views. Drill down further to work on tasks, make status changes or add notes.'''




        # read the config file
        from pyasm.widget import WidgetConfig
        tmp_path = __file__
        dir_name = os.path.dirname(tmp_path)
        file_path="%s/../config/dashboard-conf.xml" % (dir_name)
        config = WidgetConfig.get(file_path=file_path, view="definition")

        #element_name = "my_dashboard"
        element_name = "my_dashboard"
        attrs = config.get_element_attributes(element_name)
        dashboard_data = {}
        kwargs = config.get_display_options(element_name)
        class_name = kwargs.get('class_name')

        dashboard_data['class_name'] = class_name
        dashboard_data['kwargs'] = kwargs
        dashboard_data['title'] = attrs.get("title")
        dashboard_data['description'] = attrs.get("description")
        dashboard_data['image'] = attrs.get("image")

        behavior = {
        'type': 'click_up',
        'dashboard': dashboard_data,
        'cbjs_action': '''
        var class_name = 'tactic.ui.startup.dashboards_wdg.DashboardsWdg';
        var kwargs = {};
        spt.tab.set_main_body_tab();
        spt.tab.add_new("my_dashboard", "My Dashboard", bvr.dashboard.class_name, bvr.dashboard.kwargs);
        '''
        }
        pipeline_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(pipeline_wdg)




        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "My Reports"
        image = "<img src='/context/icons/64x64/report_64.png'/>"
        description = '''TACTIC provides a number of predefined reports that project managers can access instantly to get real-time analytics.'''


        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        var class_name = 'tactic.ui.startup.reports_wdg.ReportsWdg';
        var kwargs = {};
        spt.tab.set_main_body_tab();
        spt.tab.add_new("reports", "Reports", class_name, kwargs);
        //spt.panel.load_popup("Reports", class_name, kwargs);
        '''
        }

        side_bar_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(side_bar_wdg)


        """
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
	title = "Documentation"

        description = '''TACTIC Documentation.
        <br/><br/>
        * Project Setup Documentation<br/>
        <br/>
        * End User Documentation<br/>
        <br/>
        * Developer Documentation<br/>
        <br/>
        * System Administrator Documentation<br/>
        <br/>
        '''
        image = "<img src='/context/images/getting_started_pipeline.png'/>"
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.help.load_alias("main")
        '''
        }
        doc_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(doc_wdg)
        """





        tr, td = table.add_row_cell()
        td.add_style("font-size: 14px")
        td.add("<br/>"*2)


        quick_links_wdg = QuickLinksWdg()
        td.add(quick_links_wdg)


        return top
示例#17
0
    def get_display(my):

        top = DivWdg()
        top.add_border()
        top.add_style("padding: 10px")
        top.add_color("color", "color")
        top.add_color("background", "background")

        top.add_class("spt_reports_top")

        title = DivWdg()
        title.add("Dashboards")
        title.add_style("font-size: 18px")
        title.add_style("font-weight: bold")
        title.add_style("text-align: center")
        title.add_style("padding: 10px")
        title.add_style("margin: -10px -10px 10px -10px")
        title.add_gradient("background", "background3", 5, -10)
        top.add(title)

        from tactic.ui.widget import TitleWdg
        subtitle = TitleWdg(name_of_title='List of Dashboards',
                            help_alias='project-startup-dashboards')
        top.add(subtitle)

        top.add("<br/>")

        dashboards = []

        # read the config file
        from pyasm.widget import WidgetConfig
        tmp_path = __file__
        dir_name = os.path.dirname(tmp_path)
        file_path = "%s/../config/dashboard-conf.xml" % (dir_name)
        config = WidgetConfig.get(file_path=file_path, view="definition")
        element_names = config.get_element_names()

        for element_name in element_names:
            attrs = config.get_element_attributes(element_name)
            dashboard_data = {}
            kwargs = config.get_display_options(element_name)
            class_name = kwargs.get('class_name')

            dashboard_data['class_name'] = class_name
            dashboard_data['kwargs'] = kwargs
            dashboard_data['title'] = attrs.get("title")
            dashboard_data['description'] = attrs.get("description")
            dashboard_data['image'] = attrs.get("image")
            dashboard_data['image'] = attrs.get("image")

            dashboards.append(dashboard_data)

        # get all of the configs from the database
        search = Search("config/widget_config")
        search.add_filter("widget_type", "dashboard")
        db_configs = search.get_sobjects()

        for db_config in db_configs:
            dashboard_data = {}
            view = db_config.get_value("view")
            kwargs = {'view': view}
            parts = view.split(".")
            title = Common.get_display_title(parts[-1])

            xml = db_config.get_value("config")

            dashboard_data['class_name'] = "tactic.ui.panel.CustomLayoutWdg"
            dashboard_data['kwargs'] = kwargs
            dashboard_data['title'] = title
            dashboard_data['description'] = title
            dashboard_data['image'] = None
            dashboard_data['xml'] = xml
            dashboard_data['widget_type'] = db_config.get_value("widget_type")

            dashboards.append(dashboard_data)

        # create a bunch of panels
        table = Table()
        top.add(table)
        table.add_color("color", "color")
        table.add_style("margin-bottom: 20px")
        table.center()

        for i, dashboard in enumerate(dashboards):

            if i == 0 or i % 4 == 0:
                tr = table.add_row()

            td = table.add_cell()
            td.add_style("vertical-align: top")
            td.add_style("padding: 3px")
            title = dashboard

            description = dashboard.get("title")

            # Each node will contain a list of "items" and will be stored as a table in the database.'''

            class_name = dashboard.get("class_name")
            kwargs = dashboard.get("kwargs")
            title = dashboard.get("title")
            description = dashboard.get("description")
            xml = dashboard.get("xml") or ""

            image = dashboard.get("image")
            icon = dashboard.get("icon")

            if image:
                div = DivWdg()
                if isinstance(image, basestring):
                    image = image.upper()
                    image = eval("IconWdg('', IconWdg.%s)" % image)
                    div.add_style("margin-left: 15px")
                    div.add_style("margin-top: 5px")
                else:
                    image = image
                div.add(image)
                image = div

            elif icon:
                icon = icon.upper()
                image = eval("IconWdg('', IconWdg.%s)" % icon)

            else:
                div = DivWdg()
                #image = IconWdg("Bar Chart", IconWdg.WARNING)
                image = IconWdg("Bar Chart", IconWdg.DASHBOARD_02)
                div.add_style("margin-left: 15px")
                div.add_style("margin-top: 5px")
                div.add(image)
                image = div

            behavior = {
                'type':
                'click_up',
                'title':
                title,
                'class_name':
                class_name,
                'kwargs':
                kwargs,
                'cbjs_action':
                '''

            var top = bvr.src_el.getParent(".spt_reports_top");
            spt.tab.set_main_body_tab();
            //spt.tab.set_tab_top(top);
            var kwargs = {};
            spt.tab.add_new(bvr.title, bvr.title, bvr.class_name, bvr.kwargs);
            '''
            }
            schema_wdg = my.get_section_wdg(title, description, image,
                                            behavior)

            schema_wdg.add_behavior({
                'type':
                'load',
                'title':
                title,
                'class_name':
                class_name,
                'xml':
                xml,
                'kwargs':
                kwargs,
                'cbjs_action':
                '''
                var report_top = bvr.src_el;
                report_top.kwargs = bvr.kwargs;
                report_top.class_name = bvr.class_name;
                report_top.element_name = bvr.title;
                report_top.xml = bvr.xml;
            '''
            })

            td.add(schema_wdg)

        #from tactic.ui.container import TabWdg
        #tab = TabWdg(show_add=False)
        #top.add(tab)

        return top
示例#18
0
    def get_display(my):

        top = my.top

        top.add_color("background", "background", -5)
        top.add_gradient("color", "color")

        #top.add_style("background", "#000")
        #top.add_style("opacity: 0.95")
        #top.add_style("color: #FFF")

        #top.add_style("padding-top: 10px")
        top.add_style("position: relative")

        title = my.kwargs.get("title")
        if title:
            title_wdg = my.get_title_wdg(title)
            top.add(title_wdg)

        # get the column to use as a date for searching
        my.column = my.kwargs.get("column")
        if not my.column:
            my.column = 'timestamp'

        # elements
        elements = my.kwargs.get("elements")
        if elements:
            if isinstance(elements, basestring):
                elements = elements.split("|")
        elif my.kwargs.get("chart_data"):
            elements = []
        else:
            elements = ['{@COUNT()}']

        # set some start and end dates
        start_date = my.kwargs.get("start_date")
        if not start_date:
            start_date = None
        else:
            if start_date.startswith("{") and start_date.endswith("}"):
                start_date = Search.eval(start_date)

            start_date = parser.parse(start_date)

        end_date = my.kwargs.get("end_date")
        if not end_date:
            end_date = None
        else:
            if end_date.startswith("{") and end_date.endswith("}"):
                end_date = Search.eval(end_date)
            end_date = parser.parse(end_date)

        expression = my.kwargs.get("expression")
        search_type = my.kwargs.get("search_type")
        if expression:
            sobjects = Search.eval(expression)
        elif search_type:
            search = Search(search_type)
            if start_date:
                search.add_filter(my.column, start_date, op=">")
            if end_date:
                search.add_filter(my.column, end_date, op="<")
            sobjects = search.get_sobjects()

        else:
            sobjects = []

        # Is this a plot or a chart
        # A plot puts the X-axis at the right place.
        # A chart has a interval in which data is combined

        my.interval = my.kwargs.get("interval")
        if not my.interval:
            my.interval = 'weekly'
            #my.interval = 'monthly'

        min_date = None
        max_date = None

        if not sobjects:
            if not start_date:
                min_date = datetime.today() - timedelta(days=30)
            else:
                min_date = start_date

            if not end_date:
                max_date = datetime.today() + timedelta(days=30)
            else:
                max_date = end_date

        for sobject in sobjects:
            timestamp = sobject.get_value(my.column)
            timestamp = parser.parse(timestamp)
            if min_date == None or timestamp < min_date:
                min_date = timestamp
            if max_date == None or timestamp > max_date:
                max_date = timestamp

        # defined the buckets based on interval
        dates = []
        if my.interval == 'weekly':
            min_date = datetime(min_date.year, min_date.month, min_date.day)
            max_date = datetime(max_date.year, max_date.month, max_date.day)
            min_date = min_date - timedelta(days=8)
            max_date = max_date + timedelta(days=8)

            dates = list(
                rrule.rrule(rrule.WEEKLY,
                            byweekday=0,
                            dtstart=min_date,
                            until=max_date))

        elif my.interval == 'daily':
            min_date = datetime(min_date.year, min_date.month, min_date.day)
            max_date = datetime(max_date.year, max_date.month, max_date.day)
            min_date = min_date - timedelta(days=1)
            #max_date = max_date + timedelta(days=1)

            dates = list(
                rrule.rrule(rrule.DAILY, dtstart=min_date, until=max_date))

        elif my.interval == 'monthly':
            min_date = datetime(min_date.year, min_date.month, 1)
            if max_date.month == 12:
                year = max_date.year + 1
                month = 1
            else:
                year = max_date.year
                month = max_date.month + 1

            max_date = datetime(year, month, 1)
            dates = list(
                rrule.rrule(rrule.MONTHLY,
                            bymonthday=1,
                            dtstart=min_date,
                            until=max_date))

        my.dates_dict = {}
        for date in dates:
            my.dates_dict[str(date)] = []

        # put the appropriate sobjects in each date_dict item
        for sobject in sobjects:
            timestamp = sobject.get_value(my.column)
            timestamp = parser.parse(timestamp)

            if my.interval == "weekly":
                # put in the week
                timestamp = list(
                    rrule.rrule(rrule.WEEKLY,
                                byweekday=0,
                                dtstart=timestamp - timedelta(days=7),
                                count=1))
                timestamp = timestamp[0]
                timestamp = datetime(timestamp.year, timestamp.month,
                                     timestamp.day)
            elif my.interval == "daily":
                timestamp = datetime(timestamp.year, timestamp.month,
                                     timestamp.day)

            else:
                timestamp = datetime(timestamp.year, timestamp.month, 1)

            if my.dates_dict:
                interval_sobjects = my.dates_dict[str(timestamp)]
                interval_sobjects.append(sobject)

        # get all the chart labels
        chart_labels = []
        for date in dates:
            if my.interval == 'weekly':
                #chart_labels.append("Week %s" % date.strftime("%W"))
                label = (date + timedelta(days=6)).strftime("%d")
                chart_labels.append("%s - %s" %
                                    (date.strftime("%b %d"), label))
            elif my.interval == 'daily':
                chart_labels.append(date.strftime("%b %d"))
            else:
                chart_labels.append(date.strftime("%b %Y"))

        my.sobjects = sobjects

        width = my.kwargs.get("width")
        if not width:
            width = "800px"

        height = my.kwargs.get("height")
        if not height:
            height = "500px"

        x_title = my.kwargs.get("x_title")
        #x_title = Search.eval(x_title)
        y_title = my.kwargs.get("y_title")
        #y_title = Search.eval(y_title)

        # draw a legend
        legend = None
        from chart_wdg import ChartLegend
        labels = my.kwargs.get("labels")
        if labels:
            legend = ChartLegend()
            labels = labels.split("|")
            legend.set_labels(labels)
            top.add(legend)
            legend.add_style("width: %s" % str(len(labels) * 200))
            legend.add_style("margin-left: auto")
            legend.add_style("margin-right: auto")
            legend.add_style("margin-top: 5px")

            #legend.add_style("width: 200px")
            #legend.add_style("position: absolute")
            #legend.add_style("top: 40px")
            #legend.add_style("left: 300px")

        table = Table()
        table.add_color("color", "color")
        top.add(table)
        table.add_row()
        table.center()
        table.add_style("width: 1%")

        if y_title:
            y_title = y_title.replace(" ", "&nbsp;")

            y_axis_div = DivWdg()
            td = table.add_cell(y_axis_div)
            td.add_style("vertical-align: middle")
            td.add_style("width: 1%")
            y_axis_div.add(y_title)
            y_axis_div.add_style("-moz-transform: rotate(-90deg)")
            y_axis_div.add_style("-webkit-transform: rotate(-90deg)")
            y_axis_div.add_style("font-size: 1.33em")
            y_axis_div.add_style("height: 100%")
            y_axis_div.add_style("width: 30px")

        rotate_x_axis = my.kwargs.get("rotate_x_axis")

        chart = ChartWdg(
            width=width,
            height=height,
            chart_type='bar',
            #legend=my.elements,
            labels=chart_labels,
            label_values=[i + 0.5 for i, x in enumerate(chart_labels)],
            rotate_x_axis=rotate_x_axis,
        )
        table.add_cell(chart)

        chart_type = my.kwargs.get("chart_type")
        if not chart_type:
            chart_type = 'bar'

        my.colors = [
            'rgba(0,255,0,0.5)',
            'rgba(0,0,255,0.5)',
            'rgba(255,0,0,0.5)',
            'rgba(255,255,0,0.5)',
            'rgba(0,255,255,0.5)',
            'rgba(255,0,255,0.5)',
        ]

        if legend:
            legend.set_colors(my.colors)

        element_count = 0

        x_data = [i + 0.5 for i, x in enumerate(chart_labels)]
        for i, element in enumerate(elements):

            data_values = my.get_data_values(my.dates_dict, dates, element,
                                             my.sobjects)

            chart_data = ChartData(chart_type=chart_type,
                                   data=data_values,
                                   color=my.colors[element_count],
                                   x_data=x_data)
            chart.add(chart_data)
            element_count += 1

        # add in individual charts
        chart_data = my.kwargs.get("chart_data")
        if chart_data and isinstance(chart_data, basestring):
            chart_data = jsonloads(chart_data)

        if not chart_data:
            chart_data = []
        else:
            # draw back to front
            chart_data.reverse()

        for options in chart_data:

            column = options.get("column")
            if not column:
                column = my.column

            expression = options.get("expression")
            if expression:

                # extra filters
                extra = {}
                #extra['sthpw/task'] = []
                #if start_date:
                #    extra['sthpw/task'].append([column, '>', start_date])
                #if end_date:
                #    extra['sthpw/task'].append([column, '<', end_date])

                sobjects = Search.eval(expression, extra_filters=extra)
                dates_dict = my.get_dates_dict(sobjects, dates, column)
            else:
                sobjects = my.sobjects
                dates_dict = my.dates_dict

            data = my.get_data_values(dates_dict, dates, options['element'],
                                      sobjects)

            options['data'] = data
            options['x_data'] = x_data
            if not options.get("color"):
                options['color'] = my.colors[element_count]

            if not options.get("chart_type"):
                options['chart_type'] = chart_type

            str_options = {}
            for x, y in options.items():
                str_options[str(x)] = y

            chart_data = ChartData(**str_options)

            chart.add(chart_data)

            element_count += 1

        table.add_row()

        # add the x-axis title
        if x_title:
            x_title = x_title.replace(" ", "&nbsp;")

            x_axis_div = DivWdg()
            td = table.add_cell(x_axis_div)
            td.add_style("text-align: center")
            td.add_style("width: 1%")
            x_axis_div.add(x_title)
            x_axis_div.add_style("font-size: 1.33em")
            x_axis_div.add_style("width: 100%")
            x_axis_div.add_style("height: 30px")

        return top
示例#19
0
    def get_display(self):

        top = DivWdg()
        top.add_border()
        top.add_style("padding: 10px")
        top.add_color("color", "color")
        top.add_gradient("background", "background", 0, -5)
        #top.add_style("height: 550px")

        #top.add_behavior( {
        #    'type': 'load',
        #    'cbjs_action': '''
        #    spt.named_events.fire_event("side_bar|hide_now", {} );
        #    '''
        #} )


        project = Project.get()

        title = TitleWdg(title='Tools')
        top.add(title)


        shelf = DivWdg()
        top.add(shelf)
        shelf.add_style("margin-left: -8px")
        shelf.add_style("width: 130px")

        button_div = DivWdg()
        shelf.add(button_div)
        button_div.add_style("float: left")
        button_div.add_style("margin-top: -3px")



        search_wdg = DivWdg()
        search_wdg.add_class("spt_main_top")
        top.add(search_wdg)
        search_wdg.add_style("padding: 10px")
        search_wdg.add_style("margin: 10px auto")
        search_wdg.add_style("width: 430px")
        search_wdg.add("<div style='float: left; margin: 8px 10px;'>Search: </div>")

        custom_cbk = {}
        custom_cbk['enter'] = '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords != '') {
                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    'search_type': 'sthpw/sobject_list',
                    'view': 'table',
                    'keywords': keywords,
                    'simple_search_view': 'simple_search',
                    //'show_shelf': false,
                }
                spt.tab.set_main_body_tab();
                spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            }
        '''


        from tactic.ui.input import TextInputWdg, LookAheadTextInputWdg
        #text = TextInputWdg(name="search")
        text = LookAheadTextInputWdg(name="search", custom_cbk=custom_cbk, height="42px")
        #text = TextWdg("search")
        text.add_class("spt_main_search")
        text.add_style("width: 290px")
        search_wdg.add(text)
        search_wdg.add_style("font-weight: bold")
        search_wdg.add_style("font-size: 16px")
        text.add_style("float: left")


        #search_wdg.add(button)
        #button.add_style("margin-top: -28px")

        icon_div = DivWdg()
        search_wdg.add(icon_div)
        icon_div.add_style("width: 38px")
        icon_div.add_style("height: 27px")
        icon_div.add_style("padding-top: 3px")
        icon_div.add_style("padding-left: 4px")
        icon_div.add_style("text-align: center")
        #icon_div.add_gradient("background", "background3", 15, -10)
        icon_div.add_color("background", "background3", 10)
        over_color = icon_div.get_color("background3", 0)
        out_color = icon_div.get_color("background3", 10)
        icon_div.set_round_corners(5)
        icon_div.set_box_shadow("1px 1px 1px 1px")
        icon = IconWdg("Search", IconWdg.SEARCH_32, width=24)
        icon_div.add(icon)
        icon_div.add_style("float: right")
        icon_div.add_style("margin-top: 4px")
        button = icon_div
        icon_div.add_class("hand")
        icon_div.add_behavior( {
            'type': 'mouseover',
            'color': over_color,
            'cbjs_action': '''
            bvr.src_el.setStyle("background", bvr.color);
            '''
        } )
        icon_div.add_behavior( {
            'type': 'mouseout',
            'color': out_color,
            'cbjs_action': '''
            bvr.src_el.setStyle("background", bvr.color);
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        } )
        icon_div.add_behavior( {
            'type': 'click',
            'color': out_color,
            'cbjs_action': '''
            bvr.src_el.setStyle("box-shadow", "0px 0px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-3");
            bvr.src_el.setStyle("margin-right", "-2");
            '''
        } )
        icon_div.add_behavior( {
            'type': 'click_up',
            'color': out_color,
            'cbjs_action': '''
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        } )





        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords == '') {
                return;
            }

            var class_name = 'tactic.ui.panel.ViewPanelWdg';
            var kwargs = {
                'search_type': 'sthpw/sobject_list',
                'view': 'table',
                'keywords': keywords,
                'simple_search_view': 'simple_search',
                //'show_shelf': false,
            }
            spt.tab.set_main_body_tab();
            spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            '''
        } )

        #desc = DivWdg()
        #top.add(desc)
        #desc.add("Dashboard")
        #desc.add_style("width: 600px")


        # create a bunch of panels
        table = Table()
        table.add_color("color", "color")
        table.add_style("margin-bottom: 20px")
        table.center()
        top.add(table)
        table.add_row()



        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Themes"
        image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''Themes define the look and feel of a project.'''

        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        var class_name = 'tactic.ui.startup.themes_wdg.ThemesWdg';
        var kwargs = {
            help_alias: 'project-startup-dashboards'
            };
        spt.tab.set_main_body_tab();
        spt.tab.add_new("themes", "Themes", class_name, kwargs);
        '''
        }
        dashboard_wdg = self.get_section_wdg(title, description, image, behavior)
        td.add(dashboard_wdg)





        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Dashboards"
        image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''Dashboards display key project data in single views. Drill down further to work on tasks, make status changes or add notes.'''


        # read the config file
        #from pyasm.widget import WidgetConfig
        #tmp_path = __file__
        #dir_name = os.path.dirname(tmp_path)
        #file_path="%s/../config/dashboard-conf.xml" % (dir_name)
        #config = WidgetConfig.get(file_path=file_path, view="definition")



        # FIXME: this bypasses the link security 
        #element_name = "dashboards"
        #attrs = config.get_element_attributes(element_name)
        #dashboard_data = {}
        #kwargs = config.get_display_options(element_name)
        #class_name = kwargs.get('class_name')

        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        var class_name = 'tactic.ui.startup.dashboards_wdg.DashboardsWdg';
        var kwargs = {
            help_alias: 'project-startup-dashboards'
            };
        spt.tab.set_main_body_tab();
        spt.tab.add_new("dashboards", "Dashboards", class_name, kwargs);
        '''
        }
        dashboard_wdg = self.get_section_wdg(title, description, image, behavior)
        td.add(dashboard_wdg)





        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Reports"
        image = "<img src='/context/icons/64x64/report_64.png'/>"
        description = '''TACTIC provides a number of predefined reports that project managers can access instantly to get real-time analytics.'''


        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        var class_name = 'tactic.ui.startup.reports_wdg.ReportsWdg';
        var kwargs = {};
        spt.tab.set_main_body_tab();
        spt.tab.add_new("reports", "Reports", class_name, kwargs);
        //spt.panel.load_popup("Reports", class_name, kwargs);
        '''
        }

        side_bar_wdg = self.get_section_wdg(title, description, image, behavior)
        td.add(side_bar_wdg)








        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Lists of Items"
        description = '''View all of the lists items for this project<br/><br/>
        '''
        image = "<img src='/context/icons/48x48/search_type_48.png'/>"
        #image = "<img src='/context/images/getting_started_pipeline.png'/>"
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.startup.HomeWdg';
        var kwargs = {};
        spt.tab.add_new("lists", "Lists", class_name, kwargs);
        '''
        }
        config_wdg = self.get_section_wdg(title, description, image, behavior)
        td.add(config_wdg)




        tr, td = table.add_row_cell()
        td.add_style("font-size: 14px")
        td.add("<br/>"*2)


        quick_links_wdg = QuickLinksWdg()
        td.add(quick_links_wdg)


        return top
示例#20
0
    def get_new_custom_widget(self, search_type, view):

        div = DivWdg()
        div.add_style('width: 500px')

        mode_select = SelectWdg("custom_mode")
        mode_select.add_class("spt_custom_mode")
        mode_select.set_option("values", "simple|xml")
        mode_select.set_option("labels", "Simple|XML")
        mode_select.add_class("spt_input")
        behavior = {
            'type': 'change',
            'cbfn_action': 'spt.custom_property_adder.switch_property_mode'
        }
        mode_select.add_behavior(behavior)

        div.add("Mode: ")
        div.add(mode_select)
        div.add("<br/><br/>")

        custom_table = Table()
        custom_table.add_color("color", "color")

        custom_table.set_max_width()
        mode = "simple"
        self.handle_simple_mode(custom_table, mode)
        #self.handle_widget_mode(custom_table, mode)
        self.handle_xml_mode(custom_table, mode)
        div.add(custom_table)

        div.add("<br/>")

        custom_table = Table()
        custom_table.center()
        custom_table.add_row()

        from tactic.ui.widget import ActionButtonWdg
        submit = ActionButtonWdg(title="Add/Next")
        behavior = {
            'type': 'click',
            'mouse_btn': 'LMB',
            'cbfn_action': 'spt.custom_property_adder.add_property_cbk',
            'search_type': self.search_type,
            'view': view
        }
        submit.add_behavior(behavior)
        td = custom_table.add_cell(submit)

        behavior['exit'] = 'true'
        submit_exit = ActionButtonWdg(title="Add/Exit")
        submit_exit.add_behavior(behavior)
        custom_table.add_cell(submit_exit)

        cancel = ActionButtonWdg(title="Cancel")
        behavior = {
            'type': 'click_up',
            'cbjs_action': "spt.popup.close('New Table Column')"
        }
        cancel.add_behavior(behavior)
        custom_table.add_cell(cancel)

        div.add(custom_table)

        return div
    def get_simple_definition_wdg(my):

        detail_wdg = DivWdg()
        detail_wdg.add_color("color", "color")
        detail_wdg.add_style("width: 350px")
        detail_wdg.add_style("margin-top: 10px")
        detail_wdg.add_style("padding: 10px")
        detail_wdg.add_border()
        title = DivWdg()
        title.add_style("margin-top: -23px")
        detail_wdg.add(title)
        if not my.name_string:
            title.add('No database column')
            return detail_wdg

        title.add("Column Definition")

        # add a name entry
        detail_wdg.add("<br/>")
        title = SpanWdg()
        detail_wdg.add("Name: ")
        detail_wdg.add(title)
        input = SpanWdg()
        input.add_style('padding-top: 6px')
        input.set_id("config_element_name")
        input.add(HtmlElement.b(my.name_string))
        detail_wdg.add(input)
        hidden = HiddenWdg('column_name', my.name_string)
        detail_wdg.add(hidden)
        hidden = HiddenWdg('target_search_type', my.search_type)
        detail_wdg.add(hidden)

        detail_wdg.add(HtmlElement.br(2))

        # add data_type entry
        data_type = SpanWdg()
        default_data_types = [
            'varchar(256)', 'varchar', 'character', 'text', 'integer', 'float',
            'boolean', 'timestamp', 'Other...'
        ]
        select = SelectWdg('config_data_type', label='Data Type: ')
        #detail_wdg.add(": ")
        select.set_option('values', default_data_types)
        select.set_value(my.data_type_string)

        select.add_behavior({
            'type':
            'change',
            'cbjs_action':
            "if (bvr.src_el.value=='Other...') {spt.show('config_data_type_custom');}\
                    else {spt.hide('config_data_type_custom');}"
        })
        data_type.add(select)

        text = TextWdg('config_data_type_custom')
        span = SpanWdg("Other: ", css='med')
        span.add(text)
        span.set_id('config_data_type_custom')
        span.add_style('display', 'none')
        text.set_value(my.data_type_string)

        data_type.add("<br/>")
        data_type.add(span)
        detail_wdg.add(data_type)

        detail_wdg.add("<br/>")
        # add a nullable entry
        nullable = SpanWdg()
        checkbox = CheckboxWdg('config_nullable',
                               label='Allow null(empty) value: ')
        #detail_wdg.add(": ")
        nullable.add(checkbox)

        if my.nullable_string in ['True', 'true']:
            checkbox.set_checked()

        detail_wdg.add(nullable)

        #constraint = DivWdg()
        #detail_wdg.add(constraint)
        #constraint.add_style("margin-top: 10px")
        #constraint.add("Constraint: ")
        #select = SelectWdg("config_constraint")
        #constraint.add(select)
        #select.set_option("values", "unique|indexed")
        #select.add_empty_option("-- None --")

        button_div = DivWdg()
        button_div.add_style("text-align: center")

        button_div.add_behavior({
            'type':
            'load',
            'cbjs_action':
            '''
spt.manage_search_type = {};

spt.manage_search_type.change_column_cbk = function(bvr) {
    var class_name = 'tactic.ui.panel.AlterSearchTypeCbk';
    var options ={
        'alter_mode': bvr.alter_mode,
        'title': bvr.title
    };

    try {
        var server = TacticServerStub.get();
        var panel = $('search_type_detail');
        if (! panel.getAttribute("spt_class_name") ) {
            panel = panel.getParent(".spt_panel");
        }
        var values = spt.api.Utility.get_input_values(panel);
        rtn = server.execute_cmd(class_name, options, values);
        if (bvr.alter_mode == 'Remove Column')
            spt.info("Column [" + bvr.column + "] has been deleted.");
        else if (bvr.alter_mode == 'Modify Column')
            spt.notify.show_message("Column [" + bvr.column + "] has been modified.");
    }
    catch (e) {
        spt.alert(spt.exception.handler(e));
    }
    var view = 'db_column';
    spt.panel.refresh("ManageSearchTypeMenuWdg_" + view);
    var view = 'definition';
    spt.panel.refresh("ManageSearchTypeMenuWdg_" + view);
}


            '''
        })

        detail_wdg.add(button_div)
        button_div.add("<hr/><br/>")
        if my.is_new_column:
            button = ActionButtonWdg(title="Commit")
            #button = ProdIconButtonWdg("Commit New Column")
            button.add_behavior({"type": "click_up",
                "cbjs_action": "spt.manage_search_type.change_column_cbk(bvr)", \

                        "alter_mode": my.ADD_COLUMN})
            button_div.add(button)
        else:

            table = Table()
            button_div.add(table)
            table.add_row()
            table.center()

            button = ActionButtonWdg(title="Modify")
            #button = ProdIconButtonWdg("Modify Column")
            button.add_behavior({
                "type": "click_up",
                "cbjs_action":
                '''spt.manage_search_type.change_column_cbk(bvr);
                           ''',
                "alter_mode": my.MODIFY_COLUMN,
                "column": my.name_string,
                "title": my.title_string
            })
            table.add_cell(button)

            button = ActionButtonWdg(title="Delete")
            #button = ProdIconButtonWdg("Delete Column")
            #button.add_style('background-color: #BF462E')
            button.add_behavior({
                "type": "click_up",
                "cbjs_action": '''
                
                var yes = function() {
                    spt.manage_search_type.change_column_cbk(bvr);
                    
                }
                spt.confirm("Are you sure you wish to delete this column?", yes) 
                ''',
                "alter_mode": my.REMOVE_COLUMN,
                "column": my.name_string
            })
            table.add_cell(button)
            button_div.add(HiddenWdg('delete_column'))
            button_div.add(HiddenWdg('modify_column'))

        return detail_wdg
示例#22
0
    def get_display(my):

        top = DivWdg()
        top.add_border()
        top.add_style("padding: 10px")
        top.add_color("color", "color")
        top.add_gradient("background", "background", 0, -5)
        #top.add_style("height: 550px")

        top.add_behavior( {
            'type': 'load',
            'cbjs_action': '''
            spt.named_events.fire_event("side_bar|hide_now", {} );
            '''
        } )


        project = Project.get()
        title = DivWdg()
        title.add("Project Startup and Configuration")
        title.add_style("font-size: 18px")
        title.add_style("font-weight: bold")
        title.add_style("text-align: center")
        title.add_style("padding: 10px")
        title.add_style("margin: -10px -10px 10px -10px")

        top.add(title)
        title.add_gradient("background", "background3", 5, -10)


        shelf = DivWdg()
        top.add(shelf)
        shelf.add_style("margin-left: -8px")
        shelf.add_style("width: 130px")

        button_div = DivWdg()
        shelf.add(button_div)
        button_div.add_style("float: left")
        button_div.add_style("margin-top: -3px")

        security = Environment.get_security()
        view_side_bar = security.check_access("builtin", "view_side_bar", "allow", default='allow')
        if view_side_bar:
            button = IconButtonWdg(title="Side Bar", icon=IconWdg.ARROW_LEFT)
            button_div.add(button)
            shelf.add("Toggle Side Bar")
            shelf.add_attr("title", "Toggle Side Bar (or press '1')")
            button.add_behavior( {
                'type': 'click_up',
                'cbjs_action': '''
                spt.named_events.fire_event("side_bar|toggle");
                '''
            } )
            shelf.add_behavior( {
                'type': 'click_up',
                'cbjs_action': '''
                spt.named_events.fire_event("side_bar|toggle");
                '''
            } )
            shelf.add_class("hand")
        else:
            shelf.add("&nbsp;")


        search_wdg = Table()
        top.add(search_wdg)
        search_wdg.add_row()

        search_wdg.add_class("spt_main_top")
        search_wdg.add_style("padding: 10px")
        search_wdg.add_style("margin: 20px auto")
        search_wdg.add_style("width: 430px")

        td = search_wdg.add_cell("Search: ")
        td.add_style("vertical-align: top")
        td.add_style("padding-top: 8px")


        custom_cbk = {}
        custom_cbk['enter'] = '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords != '') {
                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    'search_type': 'sthpw/sobject_list',
                    'view': 'result_list',
                    'keywords': keywords,
                    'simple_search_view': 'simple_filter',
                    //'show_shelf': false,
                }
                spt.tab.set_main_body_tab();
                spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            }
        '''


        from tactic.ui.input import TextInputWdg, LookAheadTextInputWdg
        #text = TextInputWdg(name="search")
        text = LookAheadTextInputWdg(name="search", custom_cbk=custom_cbk, width='280', height='42px')
        #text = TextWdg("search")
        text.add_class("spt_main_search")
        text.add_style("width: 290px")

        search_wdg.add_cell(text)
        search_wdg.add_style("font-weight: bold")
        search_wdg.add_style("font-size: 16px")


        icon_div = DivWdg()
        td = search_wdg.add_cell(icon_div)
        td.add_style("vertical-align: top")
        icon_div.add_style("width: 38px")
        icon_div.add_style("height: 27px")
        icon_div.add_style("padding-top: 7px")
        icon_div.add_style("padding-left: 4px")
        icon_div.add_style("text-align: center")
        #icon_div.add_gradient("background", "background3", 15, -10)
        icon_div.add_color("background", "background3", 10)
        over_color = icon_div.get_color("background3", 0)
        out_color = icon_div.get_color("background3", 10)
        icon_div.set_round_corners(5)
        icon_div.set_box_shadow("1px 1px 1px 1px")
        icon = IconWdg("Search", IconWdg.SEARCH_32, width=24)
        icon_div.add(icon)
        button = icon_div
        icon_div.add_class("hand")
        icon_div.add_behavior( {
            'type': 'mouseover',
            'color': over_color,
            'cbjs_action': '''
            bvr.src_el.setStyle("background", bvr.color);
            '''
        } )
        icon_div.add_behavior( {
            'type': 'mouseout',
            'color': out_color,
            'cbjs_action': '''
            bvr.src_el.setStyle("background", bvr.color);
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        } )
        icon_div.add_behavior( {
            'type': 'click',
            'color': out_color,
            'cbjs_action': '''
            bvr.src_el.setStyle("box-shadow", "0px 0px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-3");
            bvr.src_el.setStyle("margin-right", "-2");
            '''
        } )
        icon_div.add_behavior( {
            'type': 'click_up',
            'color': out_color,
            'cbjs_action': '''
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        } )





        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords == '') {
                return;
            }

            var class_name = 'tactic.ui.panel.ViewPanelWdg';
            var kwargs = {
                'search_type': 'sthpw/sobject_list',
                'view': 'result_list',
                'keywords': keywords,
                'simple_search_view': 'simple_filter',
                //'show_shelf': false,
            }
            spt.tab.set_main_body_tab();
            spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            '''
        } )

        #desc = DivWdg()
        #top.add(desc)
        #desc.add("Dashboard")
        #desc.add_style("width: 600px")


        # create a bunch of panels
        table = Table()
        table.add_color("color", "color")
        table.add_style("margin-bottom: 20px")
        table.center()
        top.add(table)
        table.add_row()

        #security = Environment.get_security()
        #if not security.check_access("builtin", "view_site_admin", "allow"):

         

        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Configuration"
        #description = '''All TACTIC projects can be uniquely designed and managed using our configuration tools.'''
        description = '''Configure a Project from start to finish.'''
	image = "<img src='/context/icons/64x64/configuration_64.png'/>"
        behavior = {
            'type': 'click_up',
            'cbjs_action': '''
            spt.tab.set_main_body_tab();
            var class_name = 'tactic.ui.startup.ProjectConfigWdg';
            var kwargs = {
                help_alias: 'project-startup-configuration'
                };
            spt.tab.add_new("project_configuration", "Configuration", class_name, kwargs);
            '''
        }
        config_wdg = my.get_main_section_wdg(title, description, image, behavior)
        td.add(config_wdg)



        # Manage Users
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Manage Users and Security"
        image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        image = DivWdg()
        image_link = "<div style='margin-bottom: -64px'><img src='/context/icons/64x64/lock_64.png'/></div>"
        image.add(image_link)

        image1 = IconWdg("Manage Users", IconWdg.USER_32)
        image2 = IconWdg("Manage Users", IconWdg.USER_32)
        image3 = IconWdg("Manage Users", IconWdg.USER_32)
        image4 = IconWdg("Manage Users", IconWdg.USER_32)
        image.add(image1)
        image.add(image2)
        image.add("<br/>")
        image.add(image3)
        image.add(image4)
        description = '''Manage users that can access the system'''

        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.startup.UserConfigWdg';
        var kwargs = {
            help_alias: 'project-startup-manage-users'
            };
        spt.tab.add_new("manage_user", "Manage Users", class_name, kwargs);
        '''
        }
        manage_users_wdg = my.get_main_section_wdg(title, description, image, behavior)
        td.add(manage_users_wdg)



        # custom layout editor 
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Custom Layouts"
        description = '''Create interfaces using the Custom Layout Editor.'''
	image = "<img src='/context/icons/64x64/layout_64.png'/>"
        behavior = {
            'type': 'click_up',
            'cbjs_action': '''
            spt.tab.set_main_body_tab();
            var class_name = 'tactic.ui.tools.CustomLayoutEditWdg';
            var kwargs = {
                help_alias: 'project-startup-configuration'
                };
            spt.tab.add_new("custom_layout_editor", "Custom Layout Editor", class_name, kwargs);
            '''
        }
        config_wdg = my.get_main_section_wdg(title, description, image, behavior)
        td.add(config_wdg)




        tr = table.add_row()

        # Plugins
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Manage Plugin"
        image = IconWdg("Manage Plugin", IconWdg.PLUGIN_32)
        #image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''Upload, install, remove and create TACTIC plugins.'''

        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        var class_name = 'tactic.ui.app.PluginWdg';
        spt.tab.set_main_body_tab();
        spt.tab.add_new("plugins", "Manage Plugin", class_name, kwargs);
        '''
        }
        plugin_wdg = my.get_small_section_wdg(title, description, image, behavior)
        td.add(plugin_wdg)



        # Examples
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Tools"
        image = IconWdg("Tools", IconWdg.SHARE_32)
        #image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''A collection of example views.'''

        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        var class_name = 'tactic.ui.startup.ToolsWdg';
        spt.tab.set_main_body_tab();
        spt.tab.add_new("tools", "Tools", class_name, kwargs);
        '''
        }
        share_wdg = my.get_small_section_wdg(title, description, image, behavior)
        td.add(share_wdg)





        # Share
        """
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Shares"
        image = IconWdg("Shares", IconWdg.SHARE_32)
        #image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''Share project with other TACTIC installs.'''

        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        var class_name = 'tactic.ui.startup.ShareWdg';
        spt.tab.set_main_body_tab();
        spt.tab.add_new("shares", "Shares", class_name, kwargs);
        '''
        }
        share_wdg = my.get_small_section_wdg(title, description, image, behavior)
        td.add(share_wdg)
        """


        # Advanced
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Advanced Setup"
        image = IconWdg("Advanced", IconWdg.ADVANCED_32)
        #image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''A set of advanced configuration tools.'''

        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        var class_name = 'tactic.ui.app.ProjectStartWdg';
        spt.tab.set_main_body_tab()
        spt.tab.add_new("project_setup", "Project Setup", class_name)
        '''
        }
        share_wdg = my.get_small_section_wdg(title, description, image, behavior)
        td.add(share_wdg)




        """
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
	title = "Documentation"

        description = '''TACTIC Documentation.
        * Project Setup Documentation<br/>
        <br/>
        * End User Documentation<br/>
        <br/>
        * Developer Documentation<br/>
        <br/>
        * System Administrator Documentation<br/>
        <br/>
        '''
        image = "<img src='/context/images/getting_started_pipeline.png'/>"
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.help.load_alias("main")
        '''
        }
        doc_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(doc_wdg)
        """





        tr, td = table.add_row_cell()
        td.add_style("font-size: 14px")
        td.add("<br/>")

        from misc_wdg import QuickLinksWdg
        quick_links_wdg = QuickLinksWdg()
        td.add(quick_links_wdg)
        
        #td = table.add_cell()
        #totals_wdg = my.get_totals_wdg()
	#td.add(totals_wdg)

        return top
示例#23
0
    def get_new_custom_widget(my, search_type, view):

        div = DivWdg()
        div.add_style('width: 500px')
        
        mode_select = SelectWdg("custom_mode")
        mode_select.add_class("spt_custom_mode")
        mode_select.set_option("values", "simple|xml")
        mode_select.set_option("labels", "Simple|XML")
        mode_select.add_class("spt_input")
        behavior = {
            'type': 'change',
            'cbfn_action': 'spt.custom_property_adder.switch_property_mode'
        }
        mode_select.add_behavior(behavior)

        div.add("Mode: ")
        div.add(mode_select)
        div.add("<br/><br/>")


        custom_table = Table()
        custom_table.add_color("color", "color")

        custom_table.set_max_width()
        mode = "simple"
        my.handle_simple_mode(custom_table, mode)
        #my.handle_widget_mode(custom_table, mode)
        my.handle_xml_mode(custom_table, mode)
        div.add(custom_table)

        div.add("<br/>")

        custom_table = Table()
        custom_table.center()
        custom_table.add_row()


        from tactic.ui.widget import ActionButtonWdg
        submit = ActionButtonWdg(title="Add/Next")
        behavior = {
            'type': 'click',
            'mouse_btn': 'LMB',
            'cbfn_action': 'spt.custom_property_adder.add_property_cbk',
            'search_type': my.search_type,
            'view': view

        }
        submit.add_behavior(behavior)
        td = custom_table.add_cell(submit)

        behavior['exit'] = 'true'
        submit_exit = ActionButtonWdg(title="Add/Exit")
        submit_exit.add_behavior(behavior)
        custom_table.add_cell(submit_exit)

        cancel = ActionButtonWdg(title="Cancel")
        behavior = {
            'type': 'click_up',
            'cbjs_action': "spt.popup.close('New Table Column')"
        }
        cancel.add_behavior(behavior)
        custom_table.add_cell(cancel)

        div.add(custom_table)

        return div
示例#24
0
    def get_display(my): 

        top = my.top
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_style("padding: 10px")
        top.add_style("min-width: 400px")

        from tactic.ui.app import HelpButtonWdg
        help_wdg = HelpButtonWdg(alias="exporting-csv-data")
        top.add(help_wdg)
        help_wdg.add_style("float: right")
        help_wdg.add_style("margin-top: -3px")
        
        if not my.check(): 
            top.add(DivWdg('Error: %s' %my.error_msg))
            top.add(HtmlElement.br(2))
            return super(CsvExportWdg, my).get_display()

        if my.search_type_list and my.search_type_list[0] != my.search_type:
            st = SearchType.get(my.search_type_list[0])
            title_div =DivWdg('Exporting related items [%s]' % st.get_title())
            top.add(title_div)
            top.add(HtmlElement.br())
            my.search_type = my.search_type_list[0]
            my.view = my.related_view

        if my.mode != 'export_all':
            num = len(my.selected_search_keys)
        else:
            search = Search(my.search_type)
            num = search.get_count()
        msg_div = DivWdg('Total: %s items to export'% num)
        msg_div.add_style("font-size: 12px")
        msg_div.add_style("font-weight: bold")
        msg_div.add_style('margin-left: 4px')
        top.add(msg_div)
        if num > 300:
            msg_div.add_behavior({'type':'load',
            'cbjs_action': "spt.alert('%s items are about to be exported. It may take a while.')" %num})
                
        top.add(HtmlElement.br())

        div  = DivWdg(css='spt_csv_export', id='csv_export_action')
        div.add_color("background", "background", -10)
        div.add_style("padding: 10px")
        div.add_style("margin: 5px")
        
        div.add_styles('max-height: 350px; overflow: auto')
        table = Table( css='minimal')
        table.add_color("color", "color")
        div.add(table)
        table.set_id('csv_export_table')
        table.center()
        
        
        cb_name = 'csv_column_name'
        master_cb = CheckboxWdg('master_control')
        master_cb.set_checked()
        master_cb.add_behavior({'type': 'click_up',
            'propagate_evt': True,
            'cbjs_action': '''
                var inputs = spt.api.Utility.get_inputs(bvr.src_el.getParent('.spt_csv_export'),'%s');
                for (var i = 0; i < inputs.length; i++)
                    inputs[i].checked = !inputs[i].checked;
                    ''' %cb_name})


        span = SpanWdg('Select Columns To Export')
        span.add_style('font-weight','600')
        table.add_row_cell(span)
        table.add_row_cell(HtmlElement.br())

        tr = table.add_row()
        tr.add_style('border-bottom: 1px groove #777')
        td = table.add_cell(master_cb)
        label = HtmlElement.i('toggle all')
        label.add_style('color: #888')
        table.add_cell(label)


        col1 = table.add_col()
        col1.add_style('width: 35px')
        col2 = table.add_col()
        
        if not my.search_type or not my.view:
            return table

        # use overriding element names and derived titles if available
        config = WidgetConfigView.get_by_search_type(my.search_type, my.view)
        if my.element_names and config:
            filtered_columns = my.element_names
            titles = []
            for name in my.element_names:
                title = config.get_element_title(name)
                titles.append(title)

        else:
            
            # excluding FunctionalTableElement
            filtered_columns = []
            titles = []
            if not config:
                columns = search.get_columns()
                filtered_columns = columns
                titles = ['n/a'] * len(filtered_columns)
            else:
                columns = config.get_element_names()
                
                filtered_columns = columns
                titles = config.get_element_titles()

        
            """
            # commented out until it is decided 2.5 widgets will 
            # use this class to differentiate between reg and functional element
            from pyasm.widget import FunctionalTableElement
            for column in columns:
                widget = config.get_display_widget(column)

                if isinstance(widget, FunctionalTableElement):
                    continue
                filtered_columns.append(column)
            """

        for idx, column in enumerate(filtered_columns):
            table.add_row()
            cb = CheckboxWdg(cb_name)
            cb.set_option('value', column)
            cb.set_checked()
            table.add_cell(cb)
            
            
            title = titles[idx]
            table.add_cell('<b>%s</b> (%s) '%(title, column))

        action_div = DivWdg()
        widget = DivWdg()
        table.add_row_cell(widget)
        widget.add_style("margin: 20px 0 10px 0px")
        cb = CheckboxWdg('include_id', label=" Include ID")
        cb.set_default_checked()
        widget.add(cb)
        hint = HintWdg('To update entries with specific ID later, please check this option. For new inserts in this or other table later on, uncheck this option.') 
        widget.add(hint)

        label = string.capwords(my.mode.replace('_', ' '))
        button = ActionButtonWdg(title=label, size='l')
        is_export_all  = my.mode == 'export_all'
        button.add_behavior({
            'type': "click_up",
            'cbfn_action': 'spt.dg_table_action.csv_export',
            'element': 'csv_export',
            'column_names': 'csv_column_name',
            'search_type': my.search_type,
            'view': my.view,
            'search_keys' : my.selected_search_keys,
            'is_export_all' : is_export_all
            
        })

        my.close_action = "var popup = bvr.src_el.getParent('.spt_popup');spt.popup.close(popup)"
        if my.close_action:
            close_button = ActionButtonWdg(title='Close')
            close_button.add_behavior({
                'type': "click",
                'cbjs_action': my.close_action
            })


        table = Table()
        action_div.add(table)
        table.center()
        table.add_row()
        td = table.add_cell(button)
        td.add_style("width: 130px")
        table.add_cell(close_button)

        action_div.add("<br clear='all'/>")

        top.add(div)
        top.add(HtmlElement.br())
        top.add(action_div)

        if my.is_test:
            rtn_data = {'columns': my.element_names, 'count': len(my.selected_search_keys)}
            if my.mode == 'export_matched':
                rtn_data['sql'] =  my.table.search_wdg.search.get_statement()
            from pyasm.common import jsondumps
            rtn_data = jsondumps(rtn_data)
            return rtn_data

        return top
示例#25
0
    def get_display(my): 

        top = my.top
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_style("padding: 10px")
        top.add_style("min-width: 400px")

        from tactic.ui.app import HelpButtonWdg
        help_wdg = HelpButtonWdg(alias="exporting-csv-data")
        top.add(help_wdg)
        help_wdg.add_style("float: right")
        help_wdg.add_style("margin-top: -3px")
        
        if not my.check(): 
            top.add(DivWdg('Error: %s' %my.error_msg))
            top.add(HtmlElement.br(2))
            return super(CsvExportWdg, my).get_display()

        if my.search_type_list and my.search_type_list[0] != my.search_type:
            st = SearchType.get(my.search_type_list[0])
            title_div =DivWdg('Exporting related items [%s]' % st.get_title())
            top.add(title_div)
            top.add(HtmlElement.br())
            my.search_type = my.search_type_list[0]
            my.view = my.related_view

        if my.mode != 'export_all':
            num = len(my.selected_search_keys)
        else:
            search = Search(my.search_type)
            num = search.get_count()
        msg_div = DivWdg('Total: %s items to export'% num)
        msg_div.add_style("font-size: 12px")
        msg_div.add_style("font-weight: bold")
        msg_div.add_style('margin-left: 4px')
        top.add(msg_div)
        if num > 300:
            msg_div.add_behavior({'type':'load',
            'cbjs_action': "spt.alert('%s items are about to be exported. It may take a while.')" %num})
                
        top.add(HtmlElement.br())

        div  = DivWdg(css='spt_csv_export', id='csv_export_action')
        div.add_color("background", "background", -10)
        div.add_style("padding: 10px")
        div.add_style("margin: 5px")
        
        div.add_styles('max-height: 350px; overflow: auto')
        table = Table( css='minimal')
        table.add_color("color", "color")
        div.add(table)
        table.set_id('csv_export_table')
        table.center()
        
        
        cb_name = 'csv_column_name'
        master_cb = CheckboxWdg('master_control')
        master_cb.set_checked()
        master_cb.add_behavior({'type': 'click_up',
            'propagate_evt': True,
            'cbjs_action': '''
                var inputs = spt.api.Utility.get_inputs(bvr.src_el.getParent('.spt_csv_export'),'%s');
                for (var i = 0; i < inputs.length; i++)
                    inputs[i].checked = !inputs[i].checked;
                    ''' %cb_name})


        span = SpanWdg('Select Columns To Export')
        span.add_style('font-weight','600')
        table.add_row_cell(span)
        table.add_row_cell(HtmlElement.br())

        tr = table.add_row()
        tr.add_style('border-bottom: 1px groove #777')
        td = table.add_cell(master_cb)
        label = HtmlElement.i('toggle all')
        label.add_style('color: #888')
        table.add_cell(label)


        col1 = table.add_col()
        col1.add_style('width: 35px')
        col2 = table.add_col()
        
        if not my.search_type or not my.view:
            return table

        
        # use overriding element names and derived titles if available
        config = WidgetConfigView.get_by_search_type(my.search_type, my.view)
        if my.element_names and config:
            filtered_columns = my.element_names
            titles = []
            for name in my.element_names:
                title = config.get_element_title(name)
                titles.append(title)

        else:
            
            # excluding FunctionalTableElement
            filtered_columns = []
            titles = []
            if not config:
                columns = search.get_columns()
                filtered_columns = columns
                titles = ['n/a'] * len(filtered_columns)
            else:
                columns = config.get_element_names()
                
                filtered_columns = columns
                titles = config.get_element_titles()

        
            """
            # commented out until it is decided 2.5 widgets will 
            # use this class to differentiate between reg and functional element
            from pyasm.widget import FunctionalTableElement
            for column in columns:
                widget = config.get_display_widget(column)

                if isinstance(widget, FunctionalTableElement):
                    continue
                filtered_columns.append(column)
            """

        for idx, column in enumerate(filtered_columns):
            table.add_row()
            cb = CheckboxWdg(cb_name)
            cb.set_option('value', column)
            cb.set_checked()
            table.add_cell(cb)
            
            
            title = titles[idx]
            table.add_cell('<b>%s</b> (%s) '%(title, column))

        action_div = DivWdg()
        widget = DivWdg()
        table.add_row_cell(widget)
        widget.add_style("margin: 20px 0 10px 0px")
        cb = CheckboxWdg('include_id', label=" Include ID")
        cb.set_default_checked()
        widget.add(cb)
        hint = HintWdg('To update entries with specific ID later, please check this option. For new inserts in this or other table later on, uncheck this option.') 
        widget.add(hint)

        label = string.capwords(my.mode.replace('_', ' '))
        button = ActionButtonWdg(title=label)

        is_export_all  = my.mode == 'export_all'
        button.add_behavior({
            'type': "click_up",
            'cbfn_action': 'spt.dg_table_action.csv_export',
            'element': 'csv_export',
            'column_names': 'csv_column_name',
            'search_type': my.search_type,
            'view': my.view,
            'search_keys' : my.selected_search_keys,
            'is_export_all' : is_export_all
            
        })

        my.close_action = "var popup = bvr.src_el.getParent('.spt_popup');spt.popup.close(popup)"
        if my.close_action:
            close_button = ActionButtonWdg(title='Close')
            close_button.add_behavior({
                'type': "click",
                'cbjs_action': my.close_action
            })


        table = Table()
        action_div.add(table)
        table.center()
        table.add_row()
        td = table.add_cell(button)
        td.add_style("width: 130px")
        table.add_cell(close_button)

        action_div.add("<br clear='all'/>")

        top.add(div)
        top.add(HtmlElement.br())
        top.add(action_div)
        return top
示例#26
0
    def get_display(my):

        top = DivWdg()
        top.add_border()
        top.add_style("padding: 10px")
        top.add_color("color", "color")
        top.add_color("background", "background")


        title = DivWdg()
        title.add("Advanced Project Setup Tools")
        title.add_style("font-size: 18px")
        title.add_style("font-weight: bold")
        title.add_style("text-align: center")
        title.add_style("padding: 10px")
        title.add_style("margin: -10px -10px 10px -10px")

        top.add(title)
        from tactic.ui.widget import TitleWdg
        subtitle = TitleWdg(name_of_title='',help_alias='project-startup-configuration')
        top.add(subtitle)

        title.add_gradient("background", "background3", 5, -10)
        top.add("<br/>")


        content = DivWdg()
        top.add(content)

	

        """
        desc = DivWdg()
        content.add(desc)
        desc.add_style("text-align: left")
        desc.add_style("padding-left: 15px")
        desc.center()
        desc.add("The following tools are used for advanced project configuration.<br/><br/>")
        desc.add_style("width: 600px")
        """

        button_div = DivWdg()
        button = SingleButtonWdg(title="Project Startup", icon=IconWdg.HOME)
        button_div.add(button)
        button_div.add_style("float: left")
	button_div.add_style("margin-top: -10px")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            spt.tab.set_main_body_tab();
            var class_name = 'tactic.ui.startup.MainWdg';
            var kwargs = {
                help_alias: 'project-startup-configuration'
            };
            spt.tab.add_new("_startup", "Startup", class_name, kwargs);
        
            '''
        }) 
        content.add(button_div)

        table = Table()
        content.add(table)
        table.add_color("color", "color")
        table.add_row()
        table.center()



        # Schema Editor
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Create Schema"

        description = '''The schema is a collection of nodes that layout the basic components of a project. Each node represents a separate list of items (sType) used in this project: ie Assets, Shots, Artwork, etc.'''

	#image = "<img src='/context/icons/64x64/schema_64.png'/>"
	image = "<img src='/context/images/getting_started_schema.png'/>"
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.tools.SchemaToolWdg';
        var kwargs = {
            help_alias: 'project-schema'    
        };
        spt.tab.add_new("create_schema", "Create Schema", class_name, kwargs);
        '''
        }
        schema_wdg = my.get_main_section_wdg(title, description, image, behavior)
        td.add(schema_wdg)


        # Workflow
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Create Workflow"
        image = "<img src='/context/images/getting_started_pipeline.png'/>"

        description = "Pipelines define how particular items of an sType will move through its lifecycle. Creating pipelines will also allow you to set up automatic triggers and notifications for each process."

        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.tools.PipelineToolWdg';
        var kwargs = {
            help_alias: 'project-workflow'
        };
        spt.tab.add_new("create_workflow", "Create Workflow", class_name, kwargs);
        '''
        }
        pipeline_wdg = my.get_main_section_wdg(title, description, image, behavior)
        td.add(pipeline_wdg)


        # Sidebar
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Manage Side Bar"

	#image = "<img src='/context/icons/64x64/sidebar_64.png'/>"
        image = "<img src='/context/images/getting_started_sidebar.png'/>"

	description = "The Side Bar can be easily configured to show specific views of your project to each user."
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.panel.ManageViewPanelWdg';
        var kwargs = {
            help_alias: 'managing-sidebar'
        };
        spt.tab.add_new("manage_project_views", "Manage Side Bar", class_name, kwargs);
        '''
        }

        side_bar_wdg = my.get_main_section_wdg(title, description, image, behavior)
        td.add(side_bar_wdg)


 
        tr = table.add_row()

        # Manage View
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Manage Views"

        image = IconWdg("Manage Views", IconWdg.LIST_01)
        div = DivWdg(image)
        image = div

        description = "Manage the views within the project."
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.manager.ViewManagerWdg';
        var kwargs = {
            help_alias: 'view-manager'
            };
        spt.tab.add_new("manage_views", "Manage Views", class_name, kwargs);
        '''
        }

        manage_view_wdg = my.get_small_section_wdg(title, description, image, behavior)
        td.add(manage_view_wdg)



        # Naming Conventions
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Naming Conventions"

        image = IconWdg("Naming Conventions", IconWdg.FOLDERS_01)
        div = DivWdg(image)
        image = div

        description = "Setup custom Directory and File naming conventions."
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.panel.ViewPanelWdg';
        var kwargs = {
	    'view': 'table',
            'search_type': 'config/naming',
            help_alias: 'project-automation-file-naming'
	};
        spt.tab.add_new("naming_conventions", "Naming Conventions", class_name, kwargs);
        '''
        }

        naming_wdg = my.get_small_section_wdg(title, description, image, behavior)
        td.add(naming_wdg)




        # Users
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Manage Security"

        image = IconWdg("Manage Security", IconWdg.LOCK_32_01)
        div = DivWdg(image)
        image = div

        description = "Manage users and group permissions"
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.startup.SecurityWdg';
        var kwargs = { };
        spt.tab.add_new("manage_security", "Manage Security", class_name, kwargs);

        '''
        }

        users_wdg = my.get_small_section_wdg(title, description, image, behavior)
        td.add(users_wdg)


        tr = table.add_row()




        # Script Editor 
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Script Editor"

        image = IconWdg("Script Editor", IconWdg.SCRIPT_EDITOR_01)
        div = DivWdg(image)
        image = div

        description = "Edit and Create custom Python and Javascipt tools, triggers and scripts."
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        
	var title = "TACTIC Script Editor"
	var class_name = "tactic.ui.app.ShelfEditWdg"
        spt.panel.load_popup(title, class_name, {}, {"load_once": true} )
        
        '''
        }

        script_editor_wdg = my.get_small_section_wdg(title, description, image, behavior)
        td.add(script_editor_wdg)




        # Project Settings
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Project Settings"

        image = IconWdg("Project Settings", IconWdg.CONFIGURE_02)
        div = DivWdg(image)
        image = div

        description = "Setting for the current project."
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.panel.ViewPanelWdg';
        var kwargs = {
	    'view': 'table',
            'search_type': 'prod/prod_setting',
            help_alias: 'main'            
	};
        spt.tab.add_new("project_settings", "Project Settings", class_name, kwargs);
        '''
        }

        prod_settings_wdg = my.get_small_section_wdg(title, description, image, behavior)
        td.add(prod_settings_wdg)


        # Widget Config
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Widget Config"

        image = IconWdg("Widget Config", IconWdg.WIDGET_CONFIG_01)
        div = DivWdg(image)
        image = div

        description = "Modify the base widget configurations for the project."
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.panel.ViewPanelWdg';
        var kwargs = {
	    'view': 'table',
            'search_type': 'config/widget_config',
            help_alias: 'tactic-widgets'
	};
        spt.tab.add_new("widget_config", "Widget Config", class_name, kwargs);
        '''
        }

        config_wdg = my.get_small_section_wdg(title, description, image, behavior)
        td.add(config_wdg)



        # Quicklinks

        tr, td = table.add_row_cell()
        td.add_style("font-size: 14px")
        td.add("<br/>")


        div = DivWdg()
        title = DivWdg()
        div.add(title)
        div.add_color("background", "background")
        div.add_style("margin: 0px 10px 15px 10px")


        title.add("Quick Links")
        title.add_style("font-size: 16px")
        title.add_style("padding: 5px")
        title.add_gradient("background", "background")
        title.add_border()
        title.set_round_corners(corners=['TL','TR'])

        content_wdg = DivWdg()
        div.add(content_wdg)
        content_wdg.add_border()
        content_wdg.add_style("padding: 20px")

        content_wdg.add("<div style='font-size: 12px'>The following links will help you find out more information on how to set up or use TACTIC.</div>")
        content_wdg.add("<hr/>")

        hover = title.get_color("background", -10)


        link_div = DivWdg()
        link_div.add_style("padding: 10px")
        content_wdg.add(link_div)
        icon = IconWdg("TACTIC Documentation", IconWdg.JUMP)
        link_div.add(icon)

        link = HtmlElement.href("TACTIC Documentation", "/doc/", target="_blank")
        link.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            spt.help.set_top();
            spt.help.load_alias("main");
            '''
        } )

        link.add_behavior( {
        'type': 'hover',
        'color': hover,
        'cbjs_action_over': '''
        bvr.src_el.setStyle("background", bvr.color);
        ''',
        'cbjs_action_out': '''
        bvr.src_el.setStyle("background", "");
        '''
        } )
        link_div.add(link)
        link.add_color("color", "color")
        link_div.add("<br/>"*2)

        icon = IconWdg("Southpaw Web Site", IconWdg.JUMP)
        link_div.add(icon)
        link = HtmlElement.href("Southpaw Web Site", "http://www.southpawtech.com", target="_blank")
        link_div.add(link)
        link.add_color("color", "color")
        link.add_behavior( {
        'type': 'hover',
        'color': hover,
        'cbjs_action_over': '''
        bvr.src_el.setStyle("background", bvr.color);
        ''',
        'cbjs_action_out': '''
        bvr.src_el.setStyle("background", "");
        '''
        } )


        link_div.add("<br/>"*2)


        icon = IconWdg("TACTIC Community", IconWdg.JUMP)
        link_div.add(icon)
        link = HtmlElement.href("TACTIC Community", "http://community.southpawtech.com", target="_blank")
        link_div.add(link)
        link.add_color("color", "color")
        link.add_behavior( {
        'type': 'hover',
        'color': hover,
        'cbjs_action_over': '''
        bvr.src_el.setStyle("background", bvr.color);
        ''',
        'cbjs_action_out': '''
        bvr.src_el.setStyle("background", "");
        '''
        } )


        td.add(div)


        return top
示例#27
0
    def get_display(self):

        top = DivWdg()
        top.add_border()
        top.add_style("padding: 10px")
        top.add_color("color", "color")
        top.add_gradient("background", "background", 0, -5)
        #top.add_style("height: 550px")

        top.add_behavior({
            'type':
            'load',
            'cbjs_action':
            '''
            spt.named_events.fire_event("side_bar|hide_now", {} );
            '''
        })

        project = Project.get()
        title = DivWdg()
        title.add("Project Startup and Configuration")
        title.add_style("font-size: 18px")
        title.add_style("font-weight: bold")
        title.add_style("text-align: center")
        title.add_style("padding: 10px")
        title.add_style("margin: -10px -10px 10px -10px")

        top.add(title)
        title.add_gradient("background", "background3", 5, -10)

        shelf = DivWdg()
        top.add(shelf)
        shelf.add_style("margin-left: -8px")
        shelf.add_style("width: 130px")

        button_div = DivWdg()
        shelf.add(button_div)
        button_div.add_style("float: left")
        button_div.add_style("margin-top: -3px")

        security = Environment.get_security()
        view_side_bar = security.check_access("builtin",
                                              "view_side_bar",
                                              "allow",
                                              default='allow')
        if view_side_bar:
            button = IconButtonWdg(title="Side Bar", icon=IconWdg.ARROW_LEFT)
            button_div.add(button)
            shelf.add("Toggle Side Bar")
            shelf.add_attr("title", "Toggle Side Bar (or press '1')")
            button.add_behavior({
                'type':
                'click_up',
                'cbjs_action':
                '''
                spt.named_events.fire_event("side_bar|toggle");
                '''
            })
            shelf.add_behavior({
                'type':
                'click_up',
                'cbjs_action':
                '''
                spt.named_events.fire_event("side_bar|toggle");
                '''
            })
            shelf.add_class("hand")
        else:
            shelf.add("&nbsp;")

        search_wdg = Table()
        top.add(search_wdg)
        search_wdg.add_row()

        search_wdg.add_class("spt_main_top")
        search_wdg.add_style("padding: 10px")
        search_wdg.add_style("margin: 20px auto")
        search_wdg.add_style("width: 430px")

        td = search_wdg.add_cell("Search: ")
        td.add_style("vertical-align: top")
        td.add_style("padding-top: 8px")

        custom_cbk = {}
        custom_cbk['enter'] = '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords != '') {
                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    'search_type': 'sthpw/sobject_list',
                    'view': 'result_list',
                    'keywords': keywords,
                    'simple_search_view': 'simple_filter',
                    //'show_shelf': false,
                }
                spt.tab.set_main_body_tab();
                spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            }
        '''

        from tactic.ui.input import TextInputWdg, LookAheadTextInputWdg
        #text = TextInputWdg(name="search")
        text = LookAheadTextInputWdg(name="search",
                                     custom_cbk=custom_cbk,
                                     width='280',
                                     height='42px')
        #text = TextWdg("search")
        text.add_class("spt_main_search")
        text.add_style("width: 290px")

        search_wdg.add_cell(text)
        search_wdg.add_style("font-weight: bold")
        search_wdg.add_style("font-size: 16px")

        icon_div = DivWdg()
        td = search_wdg.add_cell(icon_div)
        td.add_style("vertical-align: top")
        icon_div.add_style("width: 38px")
        icon_div.add_style("height: 27px")
        icon_div.add_style("padding-top: 7px")
        icon_div.add_style("padding-left: 4px")
        icon_div.add_style("text-align: center")
        #icon_div.add_gradient("background", "background3", 15, -10)
        icon_div.add_color("background", "background3", 10)
        over_color = icon_div.get_color("background3", 0)
        out_color = icon_div.get_color("background3", 10)
        icon_div.set_round_corners(5)
        icon_div.set_box_shadow("1px 1px 1px 1px")
        icon = IconWdg("Search", IconWdg.SEARCH_32, width=24)
        icon_div.add(icon)
        button = icon_div
        icon_div.add_class("hand")
        icon_div.add_behavior({
            'type':
            'mouseover',
            'color':
            over_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("background", bvr.color);
            '''
        })
        icon_div.add_behavior({
            'type':
            'mouseout',
            'color':
            out_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("background", bvr.color);
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        })
        icon_div.add_behavior({
            'type':
            'click',
            'color':
            out_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("box-shadow", "0px 0px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-3");
            bvr.src_el.setStyle("margin-right", "-2");
            '''
        })
        icon_div.add_behavior({
            'type':
            'click_up',
            'color':
            out_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        })

        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords == '') {
                return;
            }

            var class_name = 'tactic.ui.panel.ViewPanelWdg';
            var kwargs = {
                'search_type': 'sthpw/sobject_list',
                'view': 'result_list',
                'keywords': keywords,
                'simple_search_view': 'simple_filter',
                //'show_shelf': false,
            }
            spt.tab.set_main_body_tab();
            spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            '''
        })

        #desc = DivWdg()
        #top.add(desc)
        #desc.add("Dashboard")
        #desc.add_style("width: 600px")

        # create a bunch of panels
        table = Table()
        table.add_color("color", "color")
        table.add_style("margin-bottom: 20px")
        table.center()
        top.add(table)
        table.add_row()

        #security = Environment.get_security()
        #if not security.check_access("builtin", "view_site_admin", "allow"):

        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Configuration"
        #description = '''All TACTIC projects can be uniquely designed and managed using our configuration tools.'''
        description = '''Configure a Project from start to finish.'''
        image = "<img src='/context/icons/64x64/configuration_64.png'/>"
        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
            spt.tab.set_main_body_tab();
            var class_name = 'tactic.ui.startup.ProjectConfigWdg';
            var kwargs = {
                help_alias: 'project-startup-configuration'
                };
            spt.tab.add_new("project_configuration", "Configuration", class_name, kwargs);
            '''
        }
        config_wdg = self.get_main_section_wdg(title, description, image,
                                               behavior)
        td.add(config_wdg)

        # Manage Users
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Manage Users and Security"
        image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        image = DivWdg()
        image_link = "<div style='margin-bottom: -64px'><img src='/context/icons/64x64/lock_64.png'/></div>"
        image.add(image_link)

        image1 = IconWdg("Manage Users", IconWdg.USER_32)
        image2 = IconWdg("Manage Users", IconWdg.USER_32)
        image3 = IconWdg("Manage Users", IconWdg.USER_32)
        image4 = IconWdg("Manage Users", IconWdg.USER_32)
        image.add(image1)
        image.add(image2)
        image.add("<br/>")
        image.add(image3)
        image.add(image4)
        description = '''Manage users that can access the system'''

        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.startup.UserConfigWdg';
        var kwargs = {
            help_alias: 'project-startup-manage-users'
            };
        spt.tab.add_new("manage_user", "Manage Users", class_name, kwargs);
        '''
        }
        manage_users_wdg = self.get_main_section_wdg(title, description, image,
                                                     behavior)
        td.add(manage_users_wdg)

        # custom layout editor
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Custom Layouts"
        description = '''Create interfaces using the Custom Layout Editor.'''
        image = "<img src='/context/icons/64x64/layout_64.png'/>"
        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
            spt.tab.set_main_body_tab();
            var class_name = 'tactic.ui.tools.CustomLayoutEditWdg';
            var kwargs = {
                help_alias: 'project-startup-configuration'
                };
            spt.tab.add_new("custom_layout_editor", "Custom Layout Editor", class_name, kwargs);
            '''
        }
        config_wdg = self.get_main_section_wdg(title, description, image,
                                               behavior)
        td.add(config_wdg)

        tr = table.add_row()

        # Plugins
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Manage Plugins"
        image = IconWdg("Manage Plugins", IconWdg.PLUGIN_32)
        #image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''Upload, install, remove and create TACTIC plugins.'''

        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        var class_name = 'tactic.ui.app.PluginWdg';
        spt.tab.set_main_body_tab();
        spt.tab.add_new("plugins", "Manage Plugin", class_name, kwargs);
        '''
        }
        plugin_wdg = self.get_small_section_wdg(title, description, image,
                                                behavior)
        td.add(plugin_wdg)

        # Examples
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Tools"
        image = IconWdg("Tools", IconWdg.SHARE_32)
        #image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''A collection of example views.'''

        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        var class_name = 'tactic.ui.startup.ToolsWdg';
        spt.tab.set_main_body_tab();
        spt.tab.add_new("tools", "Tools", class_name, kwargs);
        '''
        }
        share_wdg = self.get_small_section_wdg(title, description, image,
                                               behavior)
        td.add(share_wdg)

        # Share
        """
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Shares"
        image = IconWdg("Shares", IconWdg.SHARE_32)
        #image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''Share project with other TACTIC installs.'''

        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        var class_name = 'tactic.ui.startup.ShareWdg';
        spt.tab.set_main_body_tab();
        spt.tab.add_new("shares", "Shares", class_name, kwargs);
        '''
        }
        share_wdg = self.get_small_section_wdg(title, description, image, behavior)
        td.add(share_wdg)
        """

        # Advanced
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Advanced Setup"
        image = IconWdg("Advanced", IconWdg.ADVANCED_32)
        #image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''A set of advanced configuration tools.'''

        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        var class_name = 'tactic.ui.app.ProjectStartWdg';
        spt.tab.set_main_body_tab()
        spt.tab.add_new("project_setup", "Project Setup", class_name)
        '''
        }
        share_wdg = self.get_small_section_wdg(title, description, image,
                                               behavior)
        td.add(share_wdg)
        """
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
	title = "Documentation"

        description = '''TACTIC Documentation.
        * Project Setup Documentation<br/>
        <br/>
        * End User Documentation<br/>
        <br/>
        * Developer Documentation<br/>
        <br/>
        * System Administrator Documentation<br/>
        <br/>
        '''
        image = "<img src='/context/images/getting_started_pipeline.png'/>"
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.help.load_alias("main")
        '''
        }
        doc_wdg = self.get_section_wdg(title, description, image, behavior)
        td.add(doc_wdg)
        """

        tr, td = table.add_row_cell()
        td.add_style("font-size: 14px")
        td.add("<br/>")

        from misc_wdg import QuickLinksWdg
        quick_links_wdg = QuickLinksWdg()
        td.add(quick_links_wdg)

        #td = table.add_cell()
        #totals_wdg = self.get_totals_wdg()
        #td.add(totals_wdg)

        return top
示例#28
0
    def get_display(my):

        top = DivWdg()
        top.add_border()
        top.add_style("padding: 10px")
        top.add_color("color", "color")
        top.add_gradient("background", "background", 0, -5)
        #top.add_style("height: 550px")

        #top.add_behavior( {
        #    'type': 'load',
        #    'cbjs_action': '''
        #    spt.named_events.fire_event("side_bar|hide_now", {} );
        #    '''
        #} )

        project = Project.get()

        title = TitleWdg(title='Tools')
        top.add(title)

        shelf = DivWdg()
        top.add(shelf)
        shelf.add_style("margin-left: -8px")
        shelf.add_style("width: 130px")

        button_div = DivWdg()
        shelf.add(button_div)
        button_div.add_style("float: left")
        button_div.add_style("margin-top: -3px")

        search_wdg = DivWdg()
        search_wdg.add_class("spt_main_top")
        top.add(search_wdg)
        search_wdg.add_style("padding: 10px")
        search_wdg.add_style("margin: 10px auto")
        search_wdg.add_style("width: 430px")
        search_wdg.add(
            "<div style='float: left; margin: 8px 10px;'>Search: </div>")

        custom_cbk = {}
        custom_cbk['enter'] = '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords != '') {
                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    'search_type': 'sthpw/sobject_list',
                    'view': 'table',
                    'keywords': keywords,
                    'simple_search_view': 'simple_search',
                    //'show_shelf': false,
                }
                spt.tab.set_main_body_tab();
                spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            }
        '''

        from tactic.ui.input import TextInputWdg, LookAheadTextInputWdg
        #text = TextInputWdg(name="search")
        text = LookAheadTextInputWdg(name="search",
                                     custom_cbk=custom_cbk,
                                     height="42px")
        #text = TextWdg("search")
        text.add_class("spt_main_search")
        text.add_style("width: 290px")
        search_wdg.add(text)
        search_wdg.add_style("font-weight: bold")
        search_wdg.add_style("font-size: 16px")
        text.add_style("float: left")

        #search_wdg.add(button)
        #button.add_style("margin-top: -28px")

        icon_div = DivWdg()
        search_wdg.add(icon_div)
        icon_div.add_style("width: 38px")
        icon_div.add_style("height: 27px")
        icon_div.add_style("padding-top: 3px")
        icon_div.add_style("padding-left: 4px")
        icon_div.add_style("text-align: center")
        #icon_div.add_gradient("background", "background3", 15, -10)
        icon_div.add_color("background", "background3", 10)
        over_color = icon_div.get_color("background3", 0)
        out_color = icon_div.get_color("background3", 10)
        icon_div.set_round_corners(5)
        icon_div.set_box_shadow("1px 1px 1px 1px")
        icon = IconWdg("Search", IconWdg.SEARCH_32, width=24)
        icon_div.add(icon)
        icon_div.add_style("float: right")
        icon_div.add_style("margin-top: 4px")
        button = icon_div
        icon_div.add_class("hand")
        icon_div.add_behavior({
            'type':
            'mouseover',
            'color':
            over_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("background", bvr.color);
            '''
        })
        icon_div.add_behavior({
            'type':
            'mouseout',
            'color':
            out_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("background", bvr.color);
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        })
        icon_div.add_behavior({
            'type':
            'click',
            'color':
            out_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("box-shadow", "0px 0px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-3");
            bvr.src_el.setStyle("margin-right", "-2");
            '''
        })
        icon_div.add_behavior({
            'type':
            'click_up',
            'color':
            out_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        })

        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords == '') {
                return;
            }

            var class_name = 'tactic.ui.panel.ViewPanelWdg';
            var kwargs = {
                'search_type': 'sthpw/sobject_list',
                'view': 'table',
                'keywords': keywords,
                'simple_search_view': 'simple_search',
                //'show_shelf': false,
            }
            spt.tab.set_main_body_tab();
            spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            '''
        })

        #desc = DivWdg()
        #top.add(desc)
        #desc.add("Dashboard")
        #desc.add_style("width: 600px")

        # create a bunch of panels
        table = Table()
        table.add_color("color", "color")
        table.add_style("margin-bottom: 20px")
        table.center()
        top.add(table)
        table.add_row()

        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Themes"
        image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''Themes define the look and feel of a project.'''

        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        var class_name = 'tactic.ui.startup.themes_wdg.ThemesWdg';
        var kwargs = {
            help_alias: 'project-startup-dashboards'
            };
        spt.tab.set_main_body_tab();
        spt.tab.add_new("themes", "Themes", class_name, kwargs);
        '''
        }
        dashboard_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(dashboard_wdg)

        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Dashboards"
        image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''Dashboards display key project data in single views. Drill down further to work on tasks, make status changes or add notes.'''

        # read the config file
        #from pyasm.widget import WidgetConfig
        #tmp_path = __file__
        #dir_name = os.path.dirname(tmp_path)
        #file_path="%s/../config/dashboard-conf.xml" % (dir_name)
        #config = WidgetConfig.get(file_path=file_path, view="definition")

        # FIXME: this bypasses the link security
        #element_name = "dashboards"
        #attrs = config.get_element_attributes(element_name)
        #dashboard_data = {}
        #kwargs = config.get_display_options(element_name)
        #class_name = kwargs.get('class_name')

        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        var class_name = 'tactic.ui.startup.dashboards_wdg.DashboardsWdg';
        var kwargs = {
            help_alias: 'project-startup-dashboards'
            };
        spt.tab.set_main_body_tab();
        spt.tab.add_new("dashboards", "Dashboards", class_name, kwargs);
        '''
        }
        dashboard_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(dashboard_wdg)

        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Reports"
        image = "<img src='/context/icons/64x64/report_64.png'/>"
        description = '''TACTIC provides a number of predefined reports that project managers can access instantly to get real-time analytics.'''

        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        var class_name = 'tactic.ui.startup.reports_wdg.ReportsWdg';
        var kwargs = {};
        spt.tab.set_main_body_tab();
        spt.tab.add_new("reports", "Reports", class_name, kwargs);
        //spt.panel.load_popup("Reports", class_name, kwargs);
        '''
        }

        side_bar_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(side_bar_wdg)

        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Lists of Items"
        description = '''View all of the lists items for this project<br/><br/>
        '''
        image = "<img src='/context/icons/48x48/search_type_48.png'/>"
        #image = "<img src='/context/images/getting_started_pipeline.png'/>"
        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.startup.HomeWdg';
        var kwargs = {};
        spt.tab.add_new("lists", "Lists", class_name, kwargs);
        '''
        }
        config_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(config_wdg)

        tr, td = table.add_row_cell()
        td.add_style("font-size: 14px")
        td.add("<br/>" * 2)

        quick_links_wdg = QuickLinksWdg()
        td.add(quick_links_wdg)

        return top