Example #1
0
 def preprocess(self):
     if self.get_option('preview') != 'false':
         self.thumb = ThumbWdg()
         self.thumb.set_sobjects(self.sobjects)
         self.thumb.set_icon_size(60)
         # passing options from this to ThumbWdg, shouldn't have conflicts
         options = self.options
         self.thumb.set_options(options)
Example #2
0
    def get_logins_wdg(my, logins):
        logins_div = DivWdg()
        for login in logins:
            login_div = DivWdg()
            logins_div.add(login_div)
            login_div.add_style("padding: 5px")
            # login_div.add_style("height: 30px")
            login_div.add_style("margin: 0 5px 5px 0")
            login_div.add_attr("spt_login", login.get_value("login"))

            thumb_div = DivWdg()
            login_div.add(thumb_div)
            thumb_div.add_style("float: left")
            thumb_div.add_style("margin-right: 5px")
            thumb_div.add_style("padding-top: 1px")

            thumb = ThumbWdg()
            thumb.set_sobject(login)
            thumb_div.add(thumb)
            thumb.set_icon_size(15)

            login_div.add(login.get_full_name())

            login_div.add_behavior(
                {
                    "type": "click_up",
                    "sobject_display_expr": my.sobject_display_expr,
                    "tab_view": my.tab_view,
                    "cbjs_action": """
            var top = bvr.src_el.getParent(".spt_schedule_top");
            var class_name = 'tactic.ui.tools.schedule_wdg.ScheduleUserToolWdg';
            var login = bvr.src_el.getAttribute("spt_login")

            var kwargs = {
                login: login
            };
            if (bvr.sobject_display_expr)
                kwargs['sobject_display_expr'] = bvr.sobject_display_expr;
            if (bvr.tab_view)
                kwargs['tab_view'] = bvr.tab_view;

            var content = top.getElement(".spt_schedule_content");
            spt.panel.load(content, class_name, kwargs);
            """,
                }
            )
            login_div.add_hover()

        return logins_div
Example #3
0
 def preprocess(self):
     if self.get_option('preview') != 'false':
         self.thumb = ThumbWdg()
         self.thumb.set_sobjects(self.sobjects)
         self.thumb.set_icon_size(60)
         # passing options from this to ThumbWdg, shouldn't have conflicts
         options = self.options
         self.thumb.set_options(options)
Example #4
0
 def preprocess(my):
     if my.get_option('preview') != 'false':
         my.thumb = ThumbWdg()
         my.thumb.set_sobjects(my.sobjects)
         my.thumb.set_icon_size(60)
         # passing options from this to ThumbWdg, shouldn't have conflicts
         options = my.options
         my.thumb.set_options(options)
Example #5
0
    def display_shot(my, shot, widget, count, is_current=False):
        thumb = ThumbWdg()
        thumb.set_sobject(shot)
        thumb.set_icon_size(45)

        widget.add( " " * 5 * count + "L ")
        widget.add(thumb)
        widget.add(" ")
        span = SpanWdg()
        if is_current:
            span.add_style("background: #eee")
            span.add_style("font-weight: bold")
            span.add_style("font-size: 1.1em")
        span.add(shot.get_code())
        span.add(" ")
        span.add(shot.get_value("description"))
        widget.add(span)
        widget.add("<br/>")
Example #6
0
class GeneralPublishElementWdg(BaseTableElementWdg):
    ''' A general publish table element with the option of having a thumbnail '''
    def get_arg_keys(self):
        return {'view': 'a custom view other than publish'}

    def preprocess(self):
        if self.get_option('preview') != 'false':
            self.thumb = ThumbWdg()
            self.thumb.set_sobjects(self.sobjects)
            self.thumb.set_icon_size(60)
            # passing options from this to ThumbWdg, shouldn't have conflicts
            options = self.options
            self.thumb.set_options(options)
        # for its own preprocess and data caching

    def get_display(self):
        self.view = self.kwargs.get('view')
        if not self.view:
            self.view = 'publish'
        widget = Widget()
        sobject = self.get_current_sobject()
        search_type = sobject.get_search_type()
        search_id = sobject.get_id()

        if self.get_option('preview') != 'false':
            self.thumb.set_current_index(self.get_current_index())
            widget.add(self.thumb)

        publish_link = PublishLinkWdg(search_type,
                                      search_id,
                                      config_base=self.view)
        div = DivWdg(publish_link)
        div.set_style('clear: left; padding-top: 6px')
        widget.add(div)

        # build a popup link to show publish browsing
        browse_link = IconButtonWdg("Publish Browser", IconWdg.CONTENTS)
        browse_link.add_behavior({
            'type': 'click_up',
            'cbjs_action': 'spt.popup.get_widget(evt, bvr)',
            'options': {
                'popup_id': 'publish_browser',
                'class_name': 'pyasm.prod.web.PublishBrowserWdg',
                'title': 'Publish Browser'
            },
            'args': {
                'search_type': search_type,
                'search_id': search_id
            }
        })
        div.add(browse_link)
        div.set_style('padding-top: 6px')

        return widget
Example #7
0
class GeneralPublishElementWdg(BaseTableElementWdg):
    ''' A general publish table element with the option of having a thumbnail '''
    def get_arg_keys(self):
        return {'view': 'a custom view other than publish'}

    def preprocess(self):
        if self.get_option('preview') != 'false':
            self.thumb = ThumbWdg()
            self.thumb.set_sobjects(self.sobjects)
            self.thumb.set_icon_size(60)
            # passing options from this to ThumbWdg, shouldn't have conflicts
            options = self.options
            self.thumb.set_options(options)
        # for its own preprocess and data caching

    def get_display(self):
        self.view = self.kwargs.get('view')
        if not self.view:
            self.view = 'publish'
        widget = Widget()
        sobject = self.get_current_sobject()
        search_type = sobject.get_search_type()
        search_id = sobject.get_id()

        if self.get_option('preview') != 'false': 
            self.thumb.set_current_index(self.get_current_index())
            widget.add(self.thumb)

        publish_link = PublishLinkWdg(search_type,search_id, config_base=self.view) 
        div = DivWdg(publish_link)
        div.set_style('clear: left; padding-top: 6px')
        widget.add(div)

        # build a popup link to show publish browsing
        browse_link = IconButtonWdg("Publish Browser", IconWdg.CONTENTS)
        browse_link.add_behavior({'type': 'click_up',
            'cbjs_action': 'spt.popup.get_widget(evt, bvr)',
            'options': {'popup_id' : 'publish_browser',
                        'class_name' : 'pyasm.prod.web.PublishBrowserWdg' ,
                        'title': 'Publish Browser'},
            'args' : { 'search_type': search_type,
                        'search_id' : search_id }
            })
        div.add(browse_link)
        div.set_style('padding-top: 6px')


        return widget
Example #8
0
    def get_title_wdg(my):

        if my.parent:
            code = my.parent.get_value("code", no_exception=True)
            name = my.parent.get_value("name", no_exception=True)
            search_type_obj = my.parent.get_search_type_obj()
        else:
            code = my.sobject.get_value("code", no_exception=True)
            name = my.sobject.get_value("name", no_exception=True)
            search_type_obj = my.sobject.get_search_type_obj()

        title = DivWdg()
        search = Search("sthpw/snapshot")
        search.add_filter("search_type", "sthpw/search_type")
        search.add_filter("search_code", search_type_obj.get_value("code"))
        if search.get_sobject():
            thumb = ThumbWdg()
            title.add(thumb)
            thumb.set_icon_size(30)
            thumb.set_sobject(search_type_obj)
            thumb.add_style("float: left")

        title.add_color("background", "background", -5)
        title.add_style("height: 23px")
        title.add_style("padding: 10px")
        title.add_style("font-weight: bold")
        title.add_style("font-size: 1.4em")
        title.add_border()

        stype_title = search_type_obj.get_value("title")
        if stype_title:
            title.add("%s: " % stype_title)

        if name:
            title.add("%s" % name)
            if code:
                title.add(" <i style='font-size: 0.8; opacity: 0.7'>(%s)</i>" %
                          code)
        elif code:
            title.add("%s" % code)
        else:
            title.add("(No name)")

        return title
Example #9
0
    def get_title_wdg(my):

        if my.parent:
            code = my.parent.get_value("code", no_exception=True)
            name = my.parent.get_value("name", no_exception=True)
            search_type_obj = my.parent.get_search_type_obj()
        else:
            code = my.sobject.get_value("code", no_exception=True)
            name = my.sobject.get_value("name", no_exception=True)
            search_type_obj = my.sobject.get_search_type_obj()


        title = DivWdg()
        search = Search("sthpw/snapshot")
        search.add_filter("search_type", "sthpw/search_type")
        search.add_filter("search_code", search_type_obj.get_value("code"))
        if search.get_sobject():
            thumb = ThumbWdg()
            title.add(thumb)
            thumb.set_icon_size(30)
            thumb.set_sobject(search_type_obj)
            thumb.add_style("float: left")



        title.add_color("background", "background3")
        title.add_style("height: 20px")
        title.add_style("padding: 6px")
        title.add_style("font-weight: bold")
        title.add_style("font-size: 1.4em")
        title.add_border()


        stype_title = search_type_obj.get_value("title")
        if stype_title:
            title.add("%s: " % stype_title)

        if name:
            title.add("%s" % name)
            if code:
                title.add(" <i style='font-size: 0.8; opacity: 0.7'>(%s)</i>" % code)
        elif code:
            title.add("%s" % code)
        else:
            title.add("(No name)")


        return title
Example #10
0
    def get_logins_wdg(self, logins):
        logins_div = DivWdg()
        for login in logins:
            login_div = DivWdg()
            logins_div.add(login_div)
            login_div.add_style("padding: 5px")
            #login_div.add_style("height: 30px")
            login_div.add_style("margin: 0 5px 5px 0")
            login_div.add_attr("spt_login", login.get_value("login"))

            thumb_div = DivWdg()
            login_div.add(thumb_div)
            thumb_div.add_style("float: left")
            thumb_div.add_style("margin-right: 5px")
            thumb_div.add_style("padding-top: 1px")

            thumb = ThumbWdg()
            thumb.set_sobject(login)
            thumb_div.add(thumb)
            thumb.set_icon_size(15)

            login_div.add(login.get_full_name())

            login_div.add_behavior({
                'type':
                'click_up',
                'sobject_display_expr':
                self.sobject_display_expr,
                'tab_view':
                self.tab_view,
                'cbjs_action':
                '''
            var top = bvr.src_el.getParent(".spt_schedule_top");
            var class_name = 'tactic.ui.tools.schedule_wdg.ScheduleUserToolWdg';
            var login = bvr.src_el.getAttribute("spt_login")

            var kwargs = {
                login: login
            };
            if (bvr.sobject_display_expr)
                kwargs['sobject_display_expr'] = bvr.sobject_display_expr;
            if (bvr.tab_view)
                kwargs['tab_view'] = bvr.tab_view;

            var content = top.getElement(".spt_schedule_content");
            spt.panel.load(content, class_name, kwargs);
            '''
            })
            login_div.add_hover()

        return logins_div
    def handle_missing_instance(my, table, instance, asset):

        asset_code = asset.get_code()

        table.add_row()

        table.add_blank_cell()

        # add the thumbnail
        thumb = ThumbWdg()
        thumb.set_name("images")
        thumb.set_sobject(asset)
        thumb.set_icon_size(45)
        table.add_cell(thumb)

        info_wdg = Widget()
        info_wdg.add("<b>%s</b>" % instance)
        info_wdg.add("<div style='font-size: 0.8em'>%s</div>" % asset_code)
        table.add_cell(info_wdg)

        table.add_blank_cell()
Example #12
0
class SubmissionInfoWdg(AssetInfoWdg):
    '''widget information about a submission in a condensed manner'''
    def preprocess(self):
        self.thumb = ThumbWdg()
        self.thumb.set_sobjects(self.sobjects)
        self.thumb.preprocess()

    def get_display(self):

        self.sobject = self.get_current_sobject()

        table = Table(css='embed')
        table.add_style("width: 300px")
        table.add_color('color', 'color')
        table.add_row()
        td = table.add_cell(
            "<i>Code: </i> <b style='font-size: 1.2em'>%s</b>" %
            self.sobject.get_code())
        td.add_style("background: #e0e0e0")
        table.add_row()

        self.thumb.set_current_index(self.get_current_index())
        table.add_cell(self.thumb)

        table2 = Table(css='embed')
        table2.add_row()
        table2.add_cell("<i>Status: </i>")
        status = self.sobject.get_value("status")
        if not status:
            table2.add_cell("<i style='color: #c0c0c0'>None</i>")
        else:
            table2.add_cell(self.sobject.get_value("status"))

        self._add_frame_range(table2)
        table.add_cell(table2)

        table.add_row()
        td = table.add_cell("<i>Description: </i>")

        description = self.sobject.get_value("description")
        #td.add(WikiUtil().convert(description))

        expand = ExpandableTextWdg()
        expand.set_id('asset_info_desc')
        expand.set_value(WikiUtil().convert(description))
        expand.set_max_length(300)
        td.add(expand)

        return table
Example #13
0
class SubmissionInfoWdg(AssetInfoWdg):
    '''widget information about a submission in a condensed manner'''

    def preprocess(self):
        self.thumb = ThumbWdg()
        self.thumb.set_sobjects(self.sobjects)
        self.thumb.preprocess()


    def get_display(self):
        
        self.sobject = self.get_current_sobject()

        table = Table(css='embed')
        table.add_style("width: 300px")
        table.add_color('color','color')
        table.add_row()
        td = table.add_cell("<i>Code: </i> <b style='font-size: 1.2em'>%s</b>" % self.sobject.get_code() )
        td.add_style("background: #e0e0e0")
        table.add_row()

        self.thumb.set_current_index(self.get_current_index())
        table.add_cell(self.thumb)

        table2 = Table(css='embed')
        table2.add_row()
        table2.add_cell("<i>Status: </i>")
        status = self.sobject.get_value("status")
        if not status:
            table2.add_cell("<i style='color: #c0c0c0'>None</i>")
        else:
            table2.add_cell(self.sobject.get_value("status") )

        self._add_frame_range(table2)
        table.add_cell( table2 )

        table.add_row()
        td = table.add_cell( "<i>Description: </i>")

        description = self.sobject.get_value("description")
        #td.add(WikiUtil().convert(description))

        expand = ExpandableTextWdg()
        expand.set_id('asset_info_desc')
        expand.set_value( WikiUtil().convert(description) )
        expand.set_max_length(300) 
        td.add(expand)

        return table
Example #14
0
    def display_shot(my, shot, widget, count, is_current=False):
        thumb = ThumbWdg()
        thumb.set_sobject(shot)
        thumb.set_icon_size(45)

        widget.add("&nbsp;" * 5 * count + "L ")
        widget.add(thumb)
        widget.add(" ")
        span = SpanWdg()
        if is_current:
            span.add_style("background: #eee")
            span.add_style("font-weight: bold")
            span.add_style("font-size: 1.1em")
        span.add(shot.get_code())
        span.add(" ")
        span.add(shot.get_value("description"))
        widget.add(span)
        widget.add("<br/>")
Example #15
0
    def handle_missing_instance(my, table, instance, asset):

        asset_code = asset.get_code()

        table.add_row()

        table.add_blank_cell()

        # add the thumbnail
        thumb = ThumbWdg()
        thumb.set_name("images")
        thumb.set_sobject(asset)
        thumb.set_icon_size(45)
        table.add_cell(thumb)


        info_wdg = Widget()
        info_wdg.add("<b>%s</b>" % instance)
        info_wdg.add("<div style='font-size: 0.8em'>%s</div>" % asset_code )
        table.add_cell(info_wdg)

        table.add_blank_cell()
Example #16
0
    def get_category_preview_wdg(self, paths, title=None, tags={}):

        div = DivWdg()

        if not title:
            title = "Paths"
        div.add("%s (%s)<hr/>" % (title, len(paths)) )
        if not paths:
            div.add("-- None --<br/>")

        paths_div = DivWdg()
        div.add(paths_div)

        from pyasm.widget import ThumbWdg

        for path in paths:
            path_div = DivWdg()
            paths_div.add(path_div)
            path_div.add_style("float: left")
            path_div.add_style("min-height: 60px")
            path_div.add_style("margin: 15px")
            path_div.add_style("width: 60px")

            icon_link = ThumbWdg.find_icon_link(path)
            path_div.add("<div><img width='60px' src='%s'/></div>" % icon_link)
            filename = os.path.basename(path)
            #path_div.add(path)
            path_div.add(filename)

            if tags:
                path_tags = tags.get(path)
                path_div.add( "&nbsp;"*10)
                path_div.add(path_tags['sobject'])

        div.add("<br clear='all'/>")
        return div
Example #17
0
    def get_category_preview_wdg(self, paths, title=None, tags={}):

        div = DivWdg()

        if not title:
            title = "Paths"
        div.add("%s (%s)<hr/>" % (title, len(paths)))
        if not paths:
            div.add("-- None --<br/>")

        paths_div = DivWdg()
        div.add(paths_div)

        from pyasm.widget import ThumbWdg

        for path in paths:
            path_div = DivWdg()
            paths_div.add(path_div)
            path_div.add_style("float: left")
            path_div.add_style("min-height: 60px")
            path_div.add_style("margin: 15px")
            path_div.add_style("width: 60px")

            icon_link = ThumbWdg.find_icon_link(path)
            path_div.add("<div><img width='60px' src='%s'/></div>" % icon_link)
            filename = os.path.basename(path)
            #path_div.add(path)
            path_div.add(filename)

            if tags:
                path_tags = tags.get(path)
                path_div.add("&nbsp;" * 10)
                path_div.add(path_tags['sobject'])

        div.add("<br clear='all'/>")
        return div
Example #18
0
    def get_display(my):


        search = Search("sthpw/login")
        logins = search.get_sobjects()

        top = my.top
        top.add_class("spt_panel_user_top")
        top.add_style("min-width: 400px")

        button = SingleButtonWdg(title="Advanced Security", icon=IconWdg.LOCK)
        top.add(button)
        button.add_style("float: right")
        button.add_style("margin-top: -8px")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var class_name = 'tactic.ui.startup.SecurityWdg';
            spt.tab.set_main_body_tab()
            spt.tab.add_new("Security", "Security", class_name)
            '''
        } )



        button = SingleButtonWdg(title="Add", tip="Add New User", icon=IconWdg.ADD)
        top.add(button)
        button.add_style("float: left")
        button.add_style("margin-top: -8px")
        top.add("<br clear='all'/>")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var class_name = 'tactic.ui.panel.EditWdg';
            var kwargs = {
                search_type: "sthpw/login",
                view: "edit",
            }
            var popup = spt.panel.load_popup("Create New User", class_name, kwargs);
            var top = bvr.src_el.getParent(".spt_panel_user_top");
            popup.on_save_cbk = function() {
                spt.panel.refresh(top);
            }

            '''
        } )




        #logins = []
        if not logins:
            arrow_div = DivWdg()
            top.add(arrow_div)
            arrow_div.add("<b><<< Click to Add</b>")
            arrow_div.add_style("position: relative")
            arrow_div.add_style("margin-top: -35px")
            arrow_div.add_style("margin-left: 35px")
            arrow_div.add_style("float: left")
            arrow_div.add_style("padding: 5px")
            arrow_div.set_box_shadow("1px 1px 2px 2px")
            arrow_div.set_round_corners(10, corners=['TL','BL'])

            div = DivWdg()
            top.add(div)
            div.add_border()
            div.add_style("min-height: 180px")
            div.add_style("margin: 15px 30px 30px 30px")
            div.add_style("padding: 20px")
            div.add_color("background", "background3")
            icon = IconWdg( "WARNING", IconWdg.WARNING )
            div.add(icon)
            div.add("<b>No users have been added</b>")
            div.add("<br/><br/>")
            div.add("For more information, read the help docs: ")
            from tactic.ui.app import HelpButtonWdg
            help = HelpButtonWdg(alias=my.get_help_alias())
            div.add(help)
            div.add("<br/>")
            div.add("Click on the 'Add' button above to start adding new users.")

            return top




        div = DivWdg()
        top.add(div)
        #div.add_style("max-height: 300px")
        #div.add_style("overflow-y: auto")


        table = Table()
        table.set_max_width()
        table.add_style("margin-top: 10px")
        div.add(table)


        # group mouse over
        table.add_relay_behavior( {
            'type': "mouseover",
            'bvr_match_class': 'spt_row',
            'cbjs_action': "spt.mouse.table_layout_hover_over({}, {src_el: bvr.src_el, add_color_modifier: -2})"
        } )
        table.add_relay_behavior( {
            'type': "mouseout",
            'bvr_match_class': 'spt_row',
            'cbjs_action': "spt.mouse.table_layout_hover_out({}, {src_el: bvr.src_el})"
        } )




        tr = table.add_row()
        tr.add_color("color", "color")
        tr.add_gradient("background", "background", -10)
        th = table.add_header("&nbsp;")
        th.add_style("text-align: left")
        th = table.add_header("Login")
        th.add_style("text-align: left")
        th = table.add_header("First Name")
        th.add_style("text-align: left")
        th = table.add_header("Last Name")
        th.add_style("text-align: left")
        th = table.add_header("Display Name")
        th.add_style("text-align: left")
        th = table.add_header("Activity")
        th.add_style("text-align: left")
        th = table.add_header("Groups")
        th.add_style("text-align: left")
        th = table.add_header("Security")
        th.add_style("text-align: left")
        th = table.add_header("Edit")
        th.add_style("text-align: left")





        for i, login in enumerate(logins):
            tr = table.add_row()
            tr.add_class("spt_row")

            if not i or not i%2:
                tr.add_color("background", "background3")
            else:
                tr.add_color("background", "background", -2 )

            thumb = ThumbWdg()
            thumb.set_sobject(login)
            thumb.set_icon_size(30)
            td = table.add_cell(thumb)

            td = table.add_cell(login.get_value("login"))
            td.add_style("padding: 3px")
            td = table.add_cell(login.get_value("first_name"))
            td.add_style("padding: 3px")
            td = table.add_cell(login.get_value("last_name"))
            td.add_style("padding: 3px")

            td = table.add_cell(login.get_value("display_name"))
            td.add_style("padding: 3px")           

            search_key = login.get_search_key()
            login_code = login.get_code()
            full_name = login.get_full_name()

            td = table.add_cell()
            button = IconButtonWdg(tip="Activity", icon=IconWdg.CALENDAR)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'login_code': login_code,
                'full_name': full_name,
                'cbjs_action': '''

                var class_name = 'tactic.ui.tools.ScheduleUserToolWdg';
                var kwargs = {
                    login: bvr.login_code
                }

                var title = bvr.full_name + ' Schedule';
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                spt.tab.add_new("user_schedule", title, class_name, kwargs);
                //spt.panel.load_popup("Activty", class_name, kwargs);


                '''
            } )

 
            td = table.add_cell()
            button = IconButtonWdg(title="Groups", icon=IconWdg.GROUP_LINK)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_key': search_key,
                'cbjs_action': '''

                var class_name = 'tactic.ui.startup.GroupAssignWdg';
                var kwargs = {
                    search_key: bvr.search_key
                };
                var popup = spt.panel.load_popup("Group Assignment", class_name, kwargs);
                '''
            } )

  
            td = table.add_cell()
            button = IconButtonWdg(title="Security", icon=IconWdg.LOCK)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_key': search_key,
                'cbjs_action': '''

                var class_name = 'tactic.ui.startup.GroupSummaryWdg';
                var kwargs = {
                    search_key: bvr.search_key
                };
                var popup = spt.panel.load_popup("Security Summary", class_name, kwargs);
                '''
            } )




            td = table.add_cell()
            button = IconButtonWdg(title="Edit User", icon=IconWdg.EDIT)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_key': search_key,
                'cbjs_action': '''

                var top = bvr.src_el.getParent(".spt_panel_user_top");
                var class_name = 'tactic.ui.panel.EditWdg';
                var kwargs = {
                    search_type: "sthpw/login",
                    view: "edit",
                    search_key: bvr.search_key
                }
                var popup = spt.panel.load_popup("Create New User", class_name, kwargs);

                popup.on_save_cbk = function() {
                    spt.panel.refresh(top);
                }

                '''
            } )

        return top
Example #19
0
    def get_display(self):

        web = WebContainer.get_web()
        palette = web.get_palette()

        widget = DivWdg()
        widget.add_style("width: 100%")
        widget.add_style("text-align: center")

        from tactic.ui.app import PageHeaderWdg
        header = PageHeaderWdg(show_project=False)
        widget.add(header)

        security = Environment.get_security()

        search = Search("sthpw/project")
        search.add_where("\"code\" not in ('sthpw', 'admin', 'unittest')")
        search.add_where("\"type\" not in ('resource')")
        # hide template projects
        if security.check_access("builtin", "view_site_admin",
                                 "allow") or security.check_access(
                                     "builtin", "view_template_projects",
                                     "allow"):
            pass
        else:
            search.add_op("begin")
            search.add_filter("is_template", True, op='!=')
            search.add_filter("is_template", 'NULL', quoted=False, op='is')
            search.add_op("or")

        search.add_order_by("category")

        projects = search.get_sobjects()

        num = len(projects)
        # sort by project
        if num < 5:
            columns = 1
            icon_size = 90
            width = 500
        elif num < 15:
            columns = 2
            icon_size = 60
            width = 700
        else:
            columns = 3
            icon_size = 45
            width = 800

        div = DivWdg()

        div.add_style("margin-left: auto")
        div.add_style("margin-right: auto")
        #div.add_style("width: 520px")
        div.center()
        widget.add(div)

        #logo = TacticLogoWdg()
        #div.add(logo)
        div.add("<br/>" * 3)

        bg_color = palette.color("background")
        #div.add_color("color", "color")

        from tactic.ui.container import RoundedCornerDivWdg
        div = RoundedCornerDivWdg(hex_color_code=bg_color, corner_size="10")
        div.set_dimensions(width_str='%spx' % width, content_height_str='50px')
        div.add_border()
        div.add_style("overflow: hidden")
        div.set_box_shadow()

        div.add_style("margin-left: auto")
        div.add_style("margin-right: auto")
        div.add_style("width: %spx" % width)
        table = Table()
        table.set_max_width()
        table.add_style("margin-left: auto")
        table.add_style("margin-right: auto")
        table.add_style("background-color: %s" % bg_color)
        table.add_color("color", "color")

        tr, td = table.add_row_cell()
        logo_div = DivWdg()
        logo_div.add_gradient("background", "background3", -5, -10)
        td.add(logo_div)
        logo = TacticLogoWdg()
        logo_div.add(logo)
        logo_div.add_style("margin: -6 -6 6 -6")

        app_name = WebContainer.get_web().get_app_name()
        security = Environment.get_security()

        last_category = None
        has_category = False
        index = 0

        # if TACTIC has not been set up, show the configuration page
        # FIXME: what is the requirement for is_installed?
        config_path = Config.get_config_path()
        if not os.path.exists(config_path):
            is_installed = False
        else:
            is_installed = True
        #is_installed = True

        # filter out projects due to security
        filtered = []
        for i, project in enumerate(projects):

            from pyasm.security import get_security_version
            security_version = get_security_version()
            if security_version >= 2:
                key = {"code": project.get_code()}
                key2 = {"code": "*"}
                keys = [key, key2]
                default = "deny"
                if not security.check_access(
                        "project", keys, "allow", default=default):
                    continue
            else:

                if not security.check_access(
                        "project", project.get_code(), "view",
                        default="allow"):
                    continue

            filtered.append(project)

        projects = filtered

        if not is_installed:
            tr, td = table.add_row_cell()

            #from tactic.ui.startup import DbConfigWdg
            #td.add(DbConfigWdg())

            title_div = DivWdg()
            td.add(title_div)
            title_div.add_style("padding: 5px")
            title_div.add_style("font-weight: bold")
            title_div.add("Getting Started ...")
            title_div.add_gradient("background", "background", -10)

            projects_div = DivWdg()
            projects_div.add_style("padding: 20px")
            td.add(projects_div)
            projects_div.add_style("text-align: center")
            projects_div.add("Welcome to TACTIC ...<br/>")
            projects_div.add_style("font-size: 22px")

            msg_div = DivWdg()
            td.add(msg_div)
            msg_div.add(
                "Configure TACTIC to connect to an external database and set up asset folders.<br/><br/>"
            )
            msg_div.add_style("text-align: center")

            action = ActionButtonWdg(title='Confgure', size='medium')
            action.add_style("margin-left: auto")
            action.add_style("margin-right: auto")
            td.add(action)
            action.add_behavior({
                'type':
                'click_up',
                'cbjs_action':
                '''
            document.location = "/tactic/admin/#/link/configure";
            '''
            })

            msg_div = DivWdg()
            td.add(msg_div)
            msg_div.add(
                "<br/><br/>Or start using TACTIC with default configuration with an internal database.<br/><br/>"
            )

            msg_div.add_style("text-align: center")
            action = ActionButtonWdg(title='Start >>', size='medium')
            action.add_style("margin-left: auto")
            action.add_style("margin-right: auto")
            td.add(action)
            action.add_behavior({
                'type':
                'click_up',
                'cbjs_action':
                '''
            document.location = "/tactic";
            '''
            })

            msg_div = DivWdg()
            td.add(msg_div)
            msg_div.add("<br/><br/><br/>")
            msg_div.add_style("text-align: center")

        elif projects:
            num_projets = 0
            for i, project in enumerate(projects):

                category = project.get_value("category")
                if category is not None and category != last_category:

                    table.add_row()
                    tr, td = table.add_row_cell()
                    category_div = DivWdg()
                    td.add(category_div)
                    if has_category and not category:
                        category_div.add("&nbsp;")
                    else:
                        category_div.add(category)
                    category_div.add_style("padding: 8px")
                    category_div.add_style("font-size: 16px")
                    category_div.add_style("font-weight: bold")
                    category_div.add_color("color", "color")
                    category_div.add_gradient("background", "background3", 0,
                                              -10)
                    category_div.add_color("color", "color3")
                    #category_div.set_round_corners()
                    if last_category == None:
                        category_div.add_style("margin: -6 -6 6 -6")
                    else:
                        category_div.add_style("margin: 15 -6 0 -6")
                    table.add_row()
                    has_category = True
                    index = 0

                index += 1
                last_category = category

                thumb = ThumbWdg()
                thumb.set_name("snapshot")
                thumb.set_sobject(project)
                thumb.set_show_clipboard(False)
                thumb.set_has_img_link(False)
                thumb.set_icon_size(icon_size)

                code = project.get_code()
                title = project.get_value("title")
                # Restrict the length of project name
                if len(title) >= 36:
                    title = title[:36] + "..."
                if app_name != 'Browser':
                    href = HtmlElement.href(HtmlElement.h2(title), ref='/tactic/%s/%s'\
                        %(code, app_name))
                    img_href = HtmlElement.href(thumb, ref='/tactic/%s/%s'\
                        %(code, app_name))

                    link = '/tactic/%s/%s' % (code, app_name)
                else:
                    href = HtmlElement.href(HtmlElement.h2(title),
                                            ref="/tactic/%s/" % code)
                    img_href = DivWdg(thumb)
                    img_href.add_behavior({
                        'type':
                        'click_up',
                        'code':
                        code,
                        'cbjs_action':
                        '''
                        document.location = '/tactic/'+bvr.code+'/';
                        '''
                    })

                    link = '/tactic/%s/' % code

                href = href.get_buffer_display()
                if (index - 1) % columns == 0:
                    table.add_row()

                td = table.add_cell()
                img_div = DivWdg()
                img_div.add(img_href)
                img_div.add_style("margin-right: 20px")
                img_div.add_style("float: left")
                img_div.add_border()
                #img_div.set_round_corners()
                img_div.set_box_shadow("0px 1px 5px")

                project_div = DivWdg()
                td.add(project_div)
                td.add_style("width: 230px")
                project_div.add_style("font-size: 16px")
                project_div.add_style("font-weight: bold")
                project_div.add_style("vertical-align: middle")
                project_div.add(img_div)
                #project_div.add(href)
                project_div.add(title)
                if project.get_value("is_template") == True:
                    project_div.add(
                        "<br/><i style='opacity: 0.5; font-size: 12px'>(template)</i>"
                    )
                project_div.add_style("height: %spx" % (icon_size - 10))

                project_div.add_style("padding: 8px 10px 2px 20px")

                project_div.add_color("background", "background")
                project_div.add_behavior({
                    'type':
                    'hover',
                    'add_color_modifier':
                    -3,
                    'cb_set_prefix':
                    'spt.mouse.table_layout_hover',
                })
                project_div.set_round_corners()
                project_div.add_class("hand")

                project_div.add_behavior({
                    'type':
                    'click_up',
                    'link':
                    link,
                    'title':
                    title,
                    'cbjs_action':
                    '''
                document.location = bvr.link;
                '''
                })

        elif not security.check_access(
                "builtin", "view_site_admin", "allow",
                default="deny") and not security.check_access(
                    "builtin", "create_projects", "allow", default="deny"):
            tr, td = table.add_row_cell()

            msg_div = DivWdg()
            td.add(msg_div)
            from pyasm.widget import IconWdg
            icon = IconWdg("WARNING", IconWdg.WARNING)
            msg_div.add(icon)
            msg_div.add("You are not permitted to view any projects")
            msg_div.add_style("font-size: 16px")
            msg_div.add_style("text-align: center")
            msg_div.add_style("font-weight: bold")
            msg_div.add_style("margin: 50px")
            msg_div.add("<br/>" * 2)
            msg_div.add("Please click to Sign Out:<br/>")
            action = ActionButtonWdg(title='Sign Out >>', size='m')
            msg_div.add(action)
            action.add_style('margin: 5px auto')
            action.add_style('text-align: center')
            web = WebContainer.get_web()
            action.add_behavior({
                'type':
                'click_up',
                'login':
                web.get_user_name(),
                'cbjs_action':
                '''
                var server = TacticServerStub.get();
                server.execute_cmd("SignOutCmd", {login: bvr.login} );
                window.location.href='/';
                '''
            })

        else:
            tr, td = table.add_row_cell()

            title_div = DivWdg()
            td.add(title_div)
            title_div.add_style("padding: 10px")
            title_div.add_style("margin: -8px -6px 20px -6px")
            title_div.add_style("font-weight: bold")
            title_div.add("Getting Started ...")
            title_div.add_gradient("background", "background", -10)

            projects_div = DivWdg()
            projects_div.add_style("padding: 20px")
            td.add(projects_div)
            projects_div.add_style("text-align: center")
            projects_div.add("No Projects have been created ...<br/><br/>")
            projects_div.add_style("font-size: 22px")

            action = ActionButtonWdg(title='Create Project >>', size='large')
            action.add_style("margin-left: auto")
            action.add_style("margin-right: auto")
            projects_div.add(action)
            action.add_behavior({
                'type':
                'click_up',
                'cbjs_action':
                '''
            document.location = "/tactic/admin/link/create_project";
            '''
            })

        if security.check_access("builtin", "view_site_admin", "allow"):
            admin_div = DivWdg()
            #href = HtmlElement.href(HtmlElement.h2('Admin Site'), ref='/tactic/admin/')
            #admin_div.add(href)
            #admin_div.add_border()
            admin_div.add_style("font-size: 16px")
            admin_div.add_style("font-weight: bold")
            admin_div.add_style("height: 30px")

            link_div = DivWdg()
            link_div.add_class("hand")
            admin_div.add(link_div)
            link_div.add("Go to Admin Site")
            link_div.add_style("text-align: center")
            link_div.add_behavior({
                'type':
                'click_up',
                'cbjs_action':
                '''
            document.location = '/tactic/admin/';
            '''
            })
            tr, td = table.add_row_cell()
            td.add("<hr/><br/>")
            td.add(admin_div)

        div.add(table)
        widget.add(div)
        # Note sure what this is for
        #BaseAppServer.add_onload_script('spt.first_load=false')
        div.add_behavior({
            'type': 'load',
            'cbjs_action': '''spt.first_load=false'''
        })
        return widget
Example #20
0
class ShotInfoWdg(AssetInfoWdg):
    '''widget to display the code, name and description in one column'''


    def preprocess(self):
        self.thumb = ThumbWdg()
        self.thumb.set_icon_size('60')
        self.thumb.set_sobjects(self.sobjects)
        self.thumb.preprocess()


    def get_display(self):
        if not self.thumb:
            self.preprocess()
        
        self.sobject = self.get_current_sobject()

        table = Table(css='embed')
        table.add_color('color','color')
        table.add_style("width: 300px")
        table.add_row()

        th = table.add_header("<i>Code: </i> <b style='font-size: 1.2em'>%s</b>" % self.sobject.get_code() )
        # add status
        th.add_style('text-align','left')
        status_span = SpanWdg("", css='large')
        th.add(status_span)

        status = self.sobject.get_value("status")
        if status:
            status_span.add(self.sobject.get_value("status"))
        
        table.add_row()
        
        self.thumb.set_current_index(self.get_current_index())
        thumb_td = table.add_cell(self.thumb)
        row_span = 2
       
        if self.sobject.has_value("priority"):
            row_span = 3
            # add priority
            table.add_cell("<i>Priority: </i>")
            priority = self.sobject.get_value("priority")
            if not priority:
                table.add_cell("None")
            else:
                table.add_cell(self.sobject.get_value("priority") )
            # this row should be added only if priority is added
            table.add_row()
        
        thumb_td.set_attr('rowspan', row_span) 

        # add pipeline
        table.add_cell("<i>Pipeline: </i>")
        status = self.sobject.get_value("pipeline_code")
        if not status:
            table.add_cell("None")
        else:
            table.add_cell(self.sobject.get_value("pipeline_code") )

        self._add_frame_range(table)

        table.add_row()
        td = table.add_cell( "<i>Description: </i>")
        description = self.sobject.get_value("description")
        expand = ExpandableTextWdg()
        expand.set_id('asset_info_desc')
        expand.set_value( WikiUtil().convert(description) )
        expand.set_max_length(300) 
        td.add(expand)

        main_div = DivWdg(table)
        
        if self.get_option("publish") == "false":
            return main_div
            
        #self._add_publish_link(main_div)

        return main_div


    def get_simple_display(self):
        sobject = self.get_current_sobject()
        code = sobject.get_code()
        description = sobject.get_value("description")
        status = sobject.get_value("status")
        return "%s, %s, %s" % (code, status, description)



    def _add_frame_range(self, table):

        frame_wdg = FrameRangeWdg()
        frame_wdg.set_sobject(self.sobject)
        table.add_row()
        table.add_cell("<i>Frame Info:</i>")
        table.add_cell( frame_wdg )

    def _add_publish_link(self, main_div):
        publish_link = PublishLinkWdg(self.sobject.get_search_type(), self.sobject.get_id())
        div = DivWdg(publish_link)
        div.add_style('padding-top','5px')
        main_div.add(div)


        # build an iframe to show publish browsing
        search_type = self.sobject.get_search_type()
        search_id = self.sobject.get_id()
        from pyasm.widget import IconButtonWdg, IconWdg
        browse_link = IconButtonWdg("Publish Browser", IconWdg.CONTENTS)
        iframe = WebContainer.get_iframe()
        iframe.set_width(100)

        url = WebContainer.get_web().get_widget_url()
        url.set_option("widget", "pyasm.prod.web.PublishBrowserWdg")
        url.set_option("search_type", search_type)
        url.set_option("search_id", search_id)
        script = iframe.get_on_script(url.to_string())
        browse_link.add_event("onclick", script)

        div.add(browse_link)
        div.set_style('padding-top: 6px')
    def handle_instance(my,
                        table,
                        instance,
                        asset,
                        node_name='',
                        publish=True,
                        allow_ref_checkin=False):

        # handle the case where asset is not defined
        if not asset:
            table.add_row()
            table.add_blank_cell()
            table.add_blank_cell()

            # FIXME: Maya specific
            parts = instance.split(":")
            instance_name = parts[0]
            asset_code = parts[1]

            if instance_name == asset_code:
                table.add_cell(instance_name)
            else:
                table.add_cell(instance)
            td = table.add_cell()
            td.add("< %s node >" % my.session.get_node_type(instance_name))
            table.add_blank_cell()
            return

        # get the pipeline for this asset and handlers for the pipeline
        process_name = my.process_select.get_value()
        handler_hidden = my.get_handler_input(asset, process_name)
        pipeline = Pipeline.get_by_sobject(asset)

        # TEST: switch this to using node name instead, if provided
        if node_name:
            instance_node = my.session.get_node(node_name)
        else:
            instance_node = my.session.get_node(instance)

        if instance_node is None:
            return
        if Xml.get_attribute(instance_node, "reference") == "true":
            is_ref = True
        else:
            is_ref = False

        namespace = Xml.get_attribute(instance_node, "namespace")
        if not namespace:
            namespace = instance

        asset_code = asset.get_code()
        is_set = False
        if asset.get_value('asset_type',
                           no_exception=True) in ['set', 'section']:
            is_set = True

        tr = table.add_row()

        if is_set:
            tr.add_class("group")

        if publish and (allow_ref_checkin or not is_ref):
            checkbox = CheckboxWdg("asset_instances")
            if is_set:
                checkbox = CheckboxWdg("set_instances")

            checkbox.set_option("value", "%s|%s|%s" % \
                        (namespace, asset_code, instance) )
            checkbox.set_persist_on_submit()

            td = table.add_cell(checkbox)

        else:
            td = table.add_blank_cell()

        # only one will be added even if there are multiple
        if handler_hidden:
            td.add(handler_hidden)

        # add the thumbnail
        thumb = ThumbWdg()
        thumb.set_name("images")
        thumb.set_sobject(asset)
        thumb.set_icon_size(60)
        table.add_cell(thumb)

        info_wdg = Widget()
        info_wdg.add(HtmlElement.b(instance))

        if not node_name:
            node_name = '%s - %s' % (asset_code, asset.get_name())
        info_div = DivWdg(node_name)
        info_div.add_style('font-size: 0.8em')
        info_wdg.add(info_div)
        info_div.add(HtmlElement.br(2))
        if pipeline:
            info_div.add(pipeline.get_code())
        table.add_cell(info_wdg)

        #  by default can't checkin references
        if not allow_ref_checkin and is_ref:
            #icon = IconWdg("error", IconWdg.ERROR)
            #td = table.add_cell(icon)
            td = table.add_cell()
            td.add(HtmlElement.b("Ref. instance"))
            '''
            import_button = ProdIconButtonWdg('import')
            import_button.add_event('onclick', "import_instance('%s')"  %instance)
            td.add(import_button)
            '''
            table.add_cell(my.get_save_wdg(my.current_sobject))

        elif publish:
            textarea = TextAreaWdg()
            textarea.set_persist_on_submit()
            textarea.set_name("%s_description" % instance)
            textarea.set_attr("cols", "35")
            textarea.set_attr("rows", "2")
            table.add_cell(textarea)
            table.add_cell(my.get_save_wdg(my.current_sobject))
        else:
            table.add_blank_cell()
            table.add_blank_cell()
Example #22
0
    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
Example #23
0
    def get_display(my):

        top = my.top

        src = my.kwargs.get("src")
        file = my.kwargs.get("file")
        if file:
            src = file.get_web_path()

        opacity = 1.0
        if not src:
            src = "/context/icons/logo/tactic_silver.png"
            opacity = 0.6


        height = my.kwargs.get("height")
        width = my.kwargs.get("width")
        index = my.kwargs.get("index")

        if not height:
            height = "auto"
        if not width:
            width = "100%"

        width = "100%"
        height = "auto"


        #div = DivWdg()
        #top.add(div)
        div = top
        div.add_class("unselectable")
        div.add_style("opacity", opacity)
        div.add_style("overflow-x: hidden")
        div.add_style("overflow-y: hidden")
        div.add_style("margin-left: auto")
        div.add_style("margin-right: auto")
        div.add_style("text-align: center")
        if height:
            div.add_style("height", height)
        if width:
            div.add_style("width", width)


        parts = os.path.splitext(src)
        ext = parts[1]
        ext = ext.lower()

        click = my.kwargs.get("click")
        if click in [False, 'false']:
            click = False
        else:
            click = True

        thumb_path = my.kwargs.get("thumb_path")
        preload = my.kwargs.get("preload")
        if not preload:
            preload = "none"

        ext = ext.lstrip(".")
        if ext in File.IMAGE_EXT:
            embed = HtmlElement.img(src)
            embed.add_style("width: 100%")
            embed.add_style("height: auto")
        elif ext in File.VIDEO_EXT:
            from tactic.ui.widget import VideoWdg
            embed = DivWdg()


            if not thumb_path:
                thumb_path = "/context/icons/logo/tactic_sml.png"
            controls = my.kwargs.get("controls")
            if not controls:
                controls = "true"

            video_id = None
            sources = [src]
            source_types = ["video/mp4"]
            poster = thumb_path
            width = '100%'
            height = '100%'
            #width = "640"
            #height = "480"
            video = VideoWdg(video_id=video_id, sources=sources, source_types=source_types, poster=poster, preload=preload, controls=controls, width=width, height=height, index=index)
            embed.add(video)
            video.get_video().add_class("spt_resizable")

            click = False

        else:
            #embed = HtmlElement.embed(src)
            if thumb_path:
                img = HtmlElement.img(thumb_path)
            else:
                from pyasm.widget import ThumbWdg
                link = ThumbWdg.find_icon_link(src)
                img = HtmlElement.img(link)
            img.add_style("width: 50%")
            img.add_style("margin: 20px 20px")
            embed = DivWdg(img)
        div.add(embed)

        if click:
            embed.add_behavior( {
                'type': 'click_up',
                'src': src,
                'cbjs_action': '''
                window.open(bvr.src);
                '''
            } )
            embed.add_class("hand")

        #embed.add_style("width", "100%")
        # NOTE: to keep true original aspect ratio, don't set this height
        # and let GalleryWdg inner load script to take care of it on load
        # that js portion needs uncommenting as well
        #embed.add_style("height", "100%")
        #embed.set_box_shadow("1px 1px 1px 1px")
        return top
Example #24
0
    def get_display(my):

        my.search_key = my.kwargs.get("search_key")
        sobject = Search.get_by_search_key(my.search_key)

        if sobject.get_base_search_type() == "sthpw/snapshot":
            snapshot = sobject
        elif sobject.get_base_search_type() == "sthpw/file":
            # if it is a file object
            snapshot = sobject.get_parent()
        else:
            snapshots = Snapshot.get_by_sobject(sobject)
            snapshot = snapshots[0]

        #parent = snapshot.get_parent()

        top = my.top

        from tactic.ui.container import ResizableTableWdg
        table = ResizableTableWdg()
        top.add(table)
        table.add_row()
        table.add_style("width: 100%")

        from tactic.ui.widget import EmbedWdg
        td = table.add_cell()
        td.add_color(
            "background",
            "background",
        )
        td.add_style("vertical-align: middle")
        td.add_style("height: 200px")
        td.add_style("overflow-x: auto")

        file_type = "icon"
        thumb_path = snapshot.get_web_path_by_type(file_type)

        file_type = "main"
        src = snapshot.get_web_path_by_type(file_type)

        parts = os.path.splitext(src)
        ext = parts[1]
        ext = ext.lower()

        if ext in ['.doc', '.xls']:
            from pyasm.widget import ThumbWdg
            link = ThumbWdg.find_icon_link(src)
            img = HtmlElement.img(src=link)
            href = DivWdg()
            href.add_style("text-align: center")
            href.add(img)
            td.add(href)
            href.add_behavior({
                'type':
                'click_up',
                'src':
                src,
                'cbjs_action':
                '''
                window.open(bvr.src);
                '''
            })
            href.add_class("hand")

        else:
            embed_wdg = EmbedWdg(src=src, thumb_path=thumb_path)
            td.add(embed_wdg)
            embed_wdg.add_style("margin: auto auto")
            embed_wdg.add_class("spt_resizable")
            embed_wdg.add_style("width: 100%")
            embed_wdg.add_style("height: 240px")

            embed_wdg.add_behavior({
                'type':
                'load',
                'cbjs_action':
                '''
                var last_height = spt.container.get_value("last_img_height");
                if (last_height) {
                    bvr.src_el.setStyle("height", last_height);
                }
                '''
            })

            embed_wdg.add_behavior({
                'type':
                'unload',
                'cbjs_action':
                '''
                var last_height = bvr.src_el.getStyle("height");
                spt.container.set_value("last_img_height", last_height);
                '''
            })

        table.add_row()
        td = table.add_cell()

        from tactic.ui.checkin import PathMetadataWdg
        from tactic.ui.checkin import SnapshotMetadataWdg

        metadata_div = DivWdg()
        td.add(metadata_div)
        metadata_div.add_style("max-height: 400px")
        metadata_div.add_style("overflow-y: auto")
        metadata_div.add_style("overflow-x: hidden")

        parser = my.kwargs.get("parser")
        use_tactic_tags = my.kwargs.get("use_tactic_tags")

        file_type = "main"
        server_src = snapshot.get_lib_path_by_type(file_type)

        # get it dynamically by path
        metadata_wdg = PathMetadataWdg(path=server_src,
                                       parser=parser,
                                       use_tactic_tags=use_tactic_tags)
        metadata_div.add(metadata_wdg)

        #else:
        #    metadata_wdg = SnapshotMetadataWdg(snapshot=snapshot)
        #    metadata_div.add(metadata_wdg)

        top.add("<br/>")

        return top
Example #25
0
    def get_display(my):

        my.search_key = my.kwargs.get("search_key")
        sobject = Search.get_by_search_key(my.search_key)

        if sobject.get_base_search_type() == "sthpw/snapshot":
            snapshot = sobject
        elif sobject.get_base_search_type() == "sthpw/file":
            # if it is a file object
            snapshot = sobject.get_parent()
        else:
            snapshots = Snapshot.get_by_sobject(sobject)
            snapshot = snapshots[0]

        #parent = snapshot.get_parent()

        top = my.top

        from tactic.ui.container import ResizableTableWdg
        table = ResizableTableWdg()
        top.add(table)
        table.add_row()
        table.add_style("width: 100%")


        from tactic.ui.widget import EmbedWdg
        td = table.add_cell()
        td.add_color("background", "background",)
        td.add_style("vertical-align: middle")
        td.add_style("height: 200px")
        td.add_style("overflow-x: auto")


        file_type = "icon"
        thumb_path = snapshot.get_web_path_by_type(file_type)

        file_type = "main"
        src = snapshot.get_web_path_by_type(file_type)
        lib_path = snapshot.get_lib_path_by_type(file_type)


        parts = os.path.splitext(src)
        ext = parts[1]
        ext = ext.lower()


        content_div = DivWdg()

        if ext in ['.doc','.xls']:
            from pyasm.widget import ThumbWdg
            link = ThumbWdg.find_icon_link(src)
            img = HtmlElement.img(src=link)
            href = DivWdg()
            href.add_style("text-align: center")
            href.add(img)
            td.add(href)
            href.add_behavior( {
                'type': 'click_up',
                'src': src,
                'cbjs_action': '''
                window.open(bvr.src);
                '''
            } )
            href.add_class("hand")

        elif ext in ['.txt','.html', '.ini']:
            f = open(lib_path, 'r')
            content = f.read(10000)
            f.close()
            if not content:
                text = "No Content"
            else:

                size = os.path.getsize(lib_path)

                from pyasm.common import FormatValue
                value = FormatValue().get_format_value(size, "KB")

                content_div.add("Showing first 10K of %s<hr/>" % value)

                text = TextAreaWdg()
                text.add(content)
                text.add_style("width: 100%")
                text.add_style("height: 300px")
                text.add_style("padding: 10px")
                text.add_style("border: none")
                text.add_attr("readonly", "true")

            content_div.add(text)
            td.add(content_div)
            content_div.add_style("color", "#000")
            content_div.add_style("width", "auto")
            content_div.add_style("margin", "20px")


        elif thumb_path == "__DYNAMIC__":
            td.add("No Preview")
        else:
            embed_wdg = EmbedWdg(src=src, thumb_path=thumb_path)
            td.add(embed_wdg)
            embed_wdg.add_style("margin: auto auto")
            embed_wdg.add_class("spt_resizable")
            embed_wdg.add_style("width: 100%")
            embed_wdg.add_style("height: 240px")

            embed_wdg.add_behavior( {
                'type': 'load',
                'cbjs_action': '''
                var last_height = spt.container.get_value("last_img_height");
                if (last_height) {
                    bvr.src_el.setStyle("height", last_height);
                }
                '''
            } )


            embed_wdg.add_behavior( {
                'type': 'unload',
                'cbjs_action': '''
                var last_height = bvr.src_el.getStyle("height");
                spt.container.set_value("last_img_height", last_height);
                '''
            } )



        table.add_row()
        td = table.add_cell()


        from tactic.ui.checkin import PathMetadataWdg
        from tactic.ui.checkin import SnapshotMetadataWdg


        metadata_div = DivWdg()
        td.add(metadata_div)
        metadata_div.add_style("max-height: 400px")
        metadata_div.add_style("overflow-y: auto")
        metadata_div.add_style("overflow-x: hidden")

        parser = my.kwargs.get("parser")
        use_tactic_tags = my.kwargs.get("use_tactic_tags")

        file_type = "main"
        server_src = snapshot.get_lib_path_by_type(file_type)

        # get it dynamically by path
        metadata_wdg = PathMetadataWdg(path=server_src, parser=parser, use_tactic_tags=use_tactic_tags)
        metadata_div.add(metadata_wdg)

        #else:
        #    metadata_wdg = SnapshotMetadataWdg(snapshot=snapshot)
        #    metadata_div.add(metadata_wdg)


        top.add("<br/>")

        return top
Example #26
0
    def get_display(my):

        web = WebContainer.get_web()
        show_multi_project = web.get_form_value('show_multi_project')
        project = Project.get()
        search_type_objs = project.get_search_types(include_multi_project=show_multi_project)


        top = my.top
        top.add_class("spt_panel_stype_list_top")
        #top.add_style("min-width: 400px")
        #top.add_style("max-width: 1000px")
        #top.add_style("width: 100%")
        top.center()



        button = SingleButtonWdg(title="Advanced Setup", icon=IconWdg.ADVANCED)
        top.add(button)
        button.add_style("float: right")
        button.add_style("margin-top: -8px")
        button.add_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)
            '''
        } )


        button = SingleButtonWdg(title="Add", tip="Add New Searchable Type (sType)", icon=IconWdg.ADD)
        top.add(button)
        button.add_style("float: left")
        button.add_style("margin-top: -8px")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var class_name = 'tactic.ui.app.SearchTypeCreatorWdg';

            var kwargs = {
            };
            var popup = spt.panel.load_popup("Create New Searchable Type", class_name, kwargs);

            var top = bvr.src_el.getParent(".spt_panel_stype_list_top");
            popup.on_register_cbk = function() {
                spt.panel.refresh(top);
            }

            '''
        } )

        cb = CheckboxWdg('show_multi_project', label=' show multi-project')
        if show_multi_project:
            cb.set_checked()
        cb.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
                var panel = bvr.src_el.getParent('.spt_panel_stype_list_top')
                spt.panel.refresh(panel, {show_multi_project: bvr.src_el.checked});
            '''
            })
        span = SpanWdg(css='small')
        top.add(span)
        top.add(cb)
        top.add("<br clear='all'/>")
        #search_type_objs = []
        if not search_type_objs:
            arrow_div = DivWdg()
            top.add(arrow_div)
            icon = IconWdg("Click to Add", IconWdg.ARROW_UP_LEFT_32)
            icon.add_style("margin-top: -20")
            icon.add_style("margin-left: -15")
            icon.add_style("position: absolute")
            arrow_div.add(icon)
            arrow_div.add("&nbsp;"*5)
            arrow_div.add("<b>Click to Add</b>")
            arrow_div.add_style("position: relative")
            arrow_div.add_style("margin-top: 5px")
            arrow_div.add_style("margin-left: 20px")
            arrow_div.add_style("float: left")
            arrow_div.add_style("padding: 25px")
            arrow_div.set_box_shadow("0px 5px 20px")
            arrow_div.set_round_corners(30)
            arrow_div.add_color("background", "background")

            div = DivWdg()
            top.add(div)
            div.add_border()
            div.add_style("min-height: 180px")
            div.add_style("width: 600px")
            div.add_style("margin: 30px auto")
            div.add_style("padding: 20px")
            div.add_color("background", "background3")
            icon = IconWdg( "WARNING", IconWdg.WARNING )
            div.add(icon)
            div.add("<b>No Searchable Types have been created</b>")
            div.add("<br/><br/>")
            div.add("Searchables Types contain lists of items that are managed in this project.  Each item will automatically have the ability to have files checked into it, track tasks and status and record work hours.")
            div.add("<br/>"*2)
            div.add("For more information, read the help docs: ")
            from tactic.ui.app import HelpButtonWdg
            help = HelpButtonWdg(alias="main")
            div.add(help)
            div.add("<br/>")
            div.add("Click on the 'Add' button above to start adding new types.")
            return top


        div = DivWdg()
        top.add(div)
        #div.add_style("max-height: 300px")
        #div.add_style("overflow-y: auto")



        table = Table()
        div.add(table)
        table.add_style("margin-top: 10px")
        table.set_max_width()



        # group mouse over
        table.add_relay_behavior( {
            'type': "mouseover",
            'bvr_match_class': 'spt_row',
            'cbjs_action': "spt.mouse.table_layout_hover_over({}, {src_el: bvr.src_el, add_color_modifier: -2})"
        } )
        table.add_relay_behavior( {
            'type': "mouseout",
            'bvr_match_class': 'spt_row',
            'cbjs_action': "spt.mouse.table_layout_hover_out({}, {src_el: bvr.src_el})"
        } )



        tr = table.add_row()
        tr.add_color("color", "color")
        tr.add_gradient("background", "background", -10)
        th = table.add_header("")
        th.add_style("text-align: left")
        th = table.add_header("Title")
        th.add_style("text-align: left")
        th = table.add_header("# Items")
        th.add_style("text-align: left")
        th = table.add_header("View")
        th.add_style("text-align: left")
        th = table.add_header("Add")
        th.add_style("text-align: left")
        th = table.add_header("Import")
        th.add_style("text-align: left")
        th = table.add_header("Custom Columns")
        th.add_style("text-align: left")
        th = table.add_header("Workflow")
        th.add_style("text-align: left")
        th = table.add_header("Notifications")
        th.add_style("text-align: left")
        th = table.add_header("Triggers")
        th.add_style("text-align: left")
        th = table.add_header("Edit")
        th.add_style("text-align: left")
        #th = table.add_header("Security")
        #th.add_style("text-align: left")



        for i, search_type_obj in enumerate(search_type_objs):
            tr = table.add_row()
            tr.add_class("spt_row")

            if not i or not i%2:
                tr.add_color("background", "background3")
            else:
                tr.add_color("background", "background", -2 )


            thumb = ThumbWdg()
            thumb.set_sobject(search_type_obj)
            thumb.set_icon_size(30)
            td = table.add_cell(thumb)



            search_type = search_type_obj.get_value("search_type")
            title = search_type_obj.get_title()

            table.add_cell(title)

            try:
                search = Search(search_type)
                count = search.get_count()
                if count:
                    table.add_cell("%s item/s" % count)
                else:
                    table.add_cell("&nbsp;")
            except:
                td = table.add_cell("&lt; No table &gt;")
                td.add_style("font-style: italic")
                td.add_style("color: #F00")
                continue



            #search = Search(search_type)
            #search.add_interval_filter("timestamp", "today")
            #created_today = search.get_count()
            #table.add_cell(created_today)



            td = table.add_cell()
            button = IconButtonWdg(title="View", icon=IconWdg.ZOOM)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': title,
                'cbjs_action': '''

                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'table',
                    'simple_search_view': 'simple_search'
                };

                // use tab
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
                //spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            } )
            button.add_style("float: left")


            arrow_button = IconButtonWdg(tip="More Views", icon=IconWdg.ARROWHEAD_DARK_DOWN)
            arrow_button.add_style("margin-left: 20px")
            td.add(arrow_button)

            cbk = '''
            var activator = spt.smenu.get_activator(bvr);

            var class_name = bvr.class_name;
            var layout = bvr.layout;

            var kwargs = {
                search_type: bvr.search_type,
                layout: layout,
                view: bvr.view,
                simple_search_view: 'simple_search',
                element_names: bvr.element_names,
            };

            // use tab
            var top = activator.getParent(".spt_dashboard_top");
            spt.tab.set_tab_top(top);
            spt.tab.add_new('%s', '%s', class_name, kwargs);
            ''' % (title, title)


            from tactic.ui.panel import SwitchLayoutMenu
            SwitchLayoutMenu(search_type=search_type, activator=arrow_button, cbk=cbk, is_refresh=False)

            td = table.add_cell()
            button = IconButtonWdg(title="Add", icon=IconWdg.ADD)
            td.add(button)
            button.add_behavior( {
                'type': 'listen',
                'search_type': search_type,
                'event_name': 'startup_save:' + search_type_obj.get_title(),
                'title': search_type_obj.get_title(),
                'cbjs_action': '''
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'table',
                    'simple_search_view': 'simple_search'
                };

                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
 

                '''
            } )
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': search_type_obj.get_title(),
                'cbjs_action': '''

                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);

                var class_name = 'tactic.ui.panel.EditWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: "insert",
                    save_event: "startup_save:" + bvr.title
                }
                spt.panel.load_popup("Add New Items ("+bvr.title+")", class_name, kwargs);

                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'table',
                    'simple_search_view': 'simple_search'
                };

                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
                '''
            } )


            """
            td = table.add_cell()
            button = IconButtonWdg(title="Check-in", icon=IconWdg.PUBLISH)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': title,
                'cbjs_action': '''

                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'checkin',
                    element_names: ['preview','code','name','description','history','general_checkin','notes']
                };

                // use tab
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
                //spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            } )
            """





            td = table.add_cell()
            button = IconButtonWdg(title="Import", icon=IconWdg.IMPORT)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': "Import Data",
                'cbjs_action': '''

                var class_name = 'tactic.ui.widget.CsvImportWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                };

                spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            } )



            td = table.add_cell()
            button = IconButtonWdg(title="Custom Columns", icon=IconWdg.COLUMNS)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': "Add Custom Columns",
                'cbjs_action': '''
                var class_name = 'tactic.ui.startup.ColumnEditWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            } )





            td = table.add_cell()
            button = IconButtonWdg(title="Workflow", icon=IconWdg.PIPELINE)
            button.add_style("float: left")
            td.add(button)

            search = Search("sthpw/pipeline")
            search.add_filter("search_type", search_type)
            count = search.get_count()
            if count:
                check = IconWdg( "Has Items", IconWdg.CHECK, width=8 )
                td.add(check)
                #check.add_style("margin-left: 0px")
                check.add_style("margin-top: 4px")




            button.add_behavior( {
                'type': 'click_up',
                'title': 'Workflow',
                'search_type': search_type,
                'cbjs_action': '''
                var class_name = 'tactic.ui.startup.PipelineEditWdg';
                var kwargs = {
                    search_type: bvr.search_type
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);
                '''
            } )
 


            td = table.add_cell()
            button = IconButtonWdg(title="Notifications", icon=IconWdg.MAIL)
            button.add_style("float: left")
            td.add(button)

            search = Search("sthpw/notification")
            search.add_filter("search_type", search_type)
            count = search.get_count()
            if count:
                check = IconWdg( "Has Items", IconWdg.CHECK, width=8 )
                td.add(check)
                #check.add_style("margin-left: 0px")
                check.add_style("margin-top: 4px")






            button.add_behavior( {
                'type': 'click_up',
                'title': 'Trigger',
                'search_type': search_type,
                'cbjs_action': '''

                var class_name = 'tactic.ui.tools.TriggerToolWdg';
                var kwargs = {
                    mode: "search_type",
                    search_type: bvr.search_type
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);
                '''
            } )


            td = table.add_cell()
            button = IconButtonWdg(title="Triggers", icon=IconWdg.ARROW_OUT)
            td.add(button)
            button.add_style("float: left")

            search = Search("config/trigger")
            search.add_filter("search_type", search_type)
            count = search.get_count()
            if count:
                check = IconWdg( "Has Items", IconWdg.CHECK, width=8 )
                td.add(check)
                #check.add_style("margin-left: 0px")
                check.add_style("margin-top: 4px")


            button.add_behavior( {
                'type': 'click_up',
                'title': 'Trigger',
                'search_type': search_type,
                'cbjs_action': '''

                var class_name = 'tactic.ui.tools.TriggerToolWdg';
                var kwargs = {
                    mode: "search_type",
                    search_type: bvr.search_type
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);
                '''
            } )





            td = table.add_cell()
            button = IconButtonWdg(title="Edit Searchable Type", icon=IconWdg.EDIT)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_key': search_type_obj.get_search_key(),
                'cbjs_action': '''

                var class_name = 'tactic.ui.panel.EditWdg';
                var kwargs = {
                    search_type: "sthpw/sobject",
                    view: "edit_startup",
                    search_key: bvr.search_key
                }
                spt.panel.load_popup("Edit Searchable Type", class_name, kwargs);


                '''
            } )


 
            """
            td = table.add_cell()
            button = IconButtonWdg(title="Security", icon=IconWdg.LOCK)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'title': 'Trigger',
                'search_type': search_type,
                'cbjs_action': '''
                alert("security");
                '''
            } )
            """


        columns_wdg = DivWdg()
        top.add(columns_wdg)


        return top
Example #27
0
    def get_display(my):

        top = my.top
        login = my.kwargs.get("login")
        if not login or login == "$LOGIN":
            login = Environment.get_user_name()

        login_sobj = Login.get_by_code(login)

        # top.add_style("margin-top: -2px")
        # top.add_style("margin-left: -2px")

        thumb_div = DivWdg()
        thumb_div.add_style("float: left")
        thumb_div.add_style("margin-right: 5px")
        thumb_div.add_style("margin-bottom: 5px")
        thumb_div.add_style("padding-top: 1px")
        thumb = ThumbWdg()
        thumb.set_sobject(login_sobj)
        thumb_div.add(thumb)
        thumb.set_icon_size(90)
        thumb.set_aspect("height")

        full_name = login_sobj.get_full_name()

        info_wdg = DivWdg()
        top.add(info_wdg)

        name_wdg = DivWdg()
        info_wdg.add(thumb_div)
        info_wdg.add(name_wdg)
        name_wdg.add("&nbsp;" * 3)
        name_wdg.add(full_name)
        name_wdg.add_style("font-size: 1.5em")
        name_wdg.add_style("font-weight: bold")
        name_wdg.add_style("padding: 5px")
        # name_wdg.add_style("margin-left: -10px")
        name_wdg.add_color("background", "background3")
        name_wdg.add_style("height: 20px")
        name_wdg.add_style("margin-bottom: 0px")
        name_wdg.add_border()

        info_wdg.add("<br/>")

        from tactic.ui.container import TabWdg

        # return if the supplied tab view has a config xml
        if my.tab_view:
            search = Search("config/widget_config")
            search.add_filter("category", "TabWdg")
            search.add_filter("view", my.tab_view)
            config_sobj = search.get_sobject()
            if config_sobj:

                config_xml = config_sobj.get_value("config")
                # replace the variable $login with the login clicked
                if login:
                    config_xml = config_xml.replace("$login", login)

                tab = TabWdg(config_xml=config_xml, view=my.tab_view, show_add=False, show_remove=False)
                top.add(tab)
                return top

        config_xml = []
        config_xml.append("<config>")
        config_xml.append("<tab>")

        config_xml.append(
            """
        <element name='activity'>
          <display class='tactic.ui.widget.ActivityCalendarWdg'>
            <login>%s</login>
            <cell_width>100px</cell_width>
            <cell_height>50px</cell_height>
            <show_header>true</show_header>
            <show_border>false</show_border>
          </display>
        </element> 
        """
            % login
        )

        config_xml.append(
            """
        <element name='schedule'>
          <display class='tactic.ui.widget.TaskCalendarWdg'>
            <assigned>%s</assigned>
            <sobject_display_expr>%s</sobject_display_expr>
            <show_header>true</show_header>
            <show_border>false</show_border>
          </display>
        </element> 
        """
            % (login, my.sobject_display_expr)
        )
        config_xml.append(
            """
        <element name='tasks'>
          <display class='tactic.ui.panel.FastTableLayoutWdg'>
            <search_type>sthpw/task</search_type>
            <view>table</view>
            <expression>@SOBJECT(sthpw/task['assigned','%s']['@ORDER_BY', 'bid_start_date desc'])</expression>
            <mode>simple</mode>
          </display>
        </element> 
        """
            % login
        )

        config_xml.append(
            """
        <element name='work_hours'>
          <display class='tactic.ui.widget.SObjectCalendarWdg'>
            <login>%s</login>
            <!--
            <cell_width>100px</cell_width>
            -->
            <cell_height>50px</cell_height>
            <show_header>true</show_header>
            <show_border>false</show_border>
            <search_type>sthpw/work_hour</search_type>
            <handler>tactic.ui.widget.WorkHourCalendarDayWdg</handler>
            <start_date_col>day</start_date_col>
            <end_date_col>day</end_date_col>
          </display>
        </element> 
        """
            % login
        )

        config_xml.append(
            """
         <element name='recent transactions'>
          <display class='tactic.ui.panel.FastTableLayoutWdg'>
            <search_type>sthpw/transaction_log</search_type>
            <view>table</view>
            <expression>@SOBJECT(sthpw/transaction_log['login','%s']['@ORDER_BY','timestamp desc']['@LIMIT','30'])</expression>
            <element_names>code,timestamp,namespace,description,transaction_log_hidden</element_names>
            <show_shelf>false</show_shelf>
            <show_select>false</show_select>
          </display>
        </element> 
        """
            % login
        )

        config_xml.append("</tab>")
        config_xml.append("</config>")
        config_xml = "".join(config_xml)

        tab = TabWdg(config_xml=config_xml, view="tab", show_add=False, show_remove=False)
        top.add(tab)
        tab.add_style("margin-left: -2px")
        tab.add_style("margin-right: -2px")

        return top
Example #28
0
    def get_display(self):

        self.is_refresh = self.kwargs.get('is_refresh') =='true'
      
        if not self.is_refresh:
            top = DivWdg(css='spt_view_panel')
            self.set_as_panel(top)
        else:
            top = Widget() 

        div = DivWdg(css="filter_box")
        div.add("<b>Current Session</b>")
        top.add(div)

        # the button which initiates the introspection
        button = IntrospectWdg()
        #button.add_style("float", "right")
        top.add(button)

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


        session = SessionContents.get()
        if not session:
            widget.add("<h3>No contents in session</h3>")
            return widget

        table = Table()
        table.add_class("table")
        table.add_style("width: 100%")
        table.add_row()
        table.add_header("&nbsp;")
        table.add_header("Type")
        table.add_header("Asset")
        table.add_header("Node Name")
        table.add_header("Node Type")
        table.add_header("Reference")
        table.add_header("Session")
        table.add_header("Latest")

        node_names = session.get_node_names()
        for node_name in node_names:
            table.add_row()


            # snapshot_code
            snapshot_code = session.get_snapshot_code(node_name, "shot")
            if not snapshot_code:
                snapshot_code = session.get_snapshot_code(node_name, "anim")
            if not snapshot_code:
                snapshot_code = session.get_snapshot_code(node_name, "asset")

            snapshot = Snapshot.get_by_code(snapshot_code)
            sobject = None

            if snapshot:

                sobject = snapshot.get_sobject()
                base = sobject.get_search_type_obj().get_base_search_type()

                thumb = ThumbWdg()
                thumb.set_icon_size(60)

                # FIXME: make this more automatic
                if base == "prod/shot_instance":
                    thumb_sobj = sobject.get_parent("prod/asset")
                    thumb.set_sobject(thumb_sobj)
                else:
                    thumb.set_sobject(sobject)

                table.add_cell(thumb)

                title = sobject.get_search_type_obj().get_title()
                table.add_cell( title )

                # TODO: this should be more automatic!
                if base == "prod/shot_instance":
                    asset_code = sobject.get_value("asset_code")
                    shot_code = sobject.get_value("shot_code")
                    name = sobject.get_value("name")
                    table.add_cell("%s: %s in %s" % (name,asset_code,shot_code))
                else:
                    code = sobject.get_code()
                    name = sobject.get_name()
                    if code == name:
                        table.add_cell( "%s" % (code) )
                    else:
                        table.add_cell( "%s - %s" % (code, name) )

            else:
                table.add_cell("<i>No snapshot</i>")
                table.add_cell("---")
                table.add_cell("---")
                

            # display the node name
            table.add_cell(node_name)

            # display node type
            table.add_cell( session.get_node_type(node_name) )


            # display if it is a reference
            is_reference = session.is_reference(node_name)
            if is_reference:
                table.add_cell( "Yes" )
            else:
                table.add_cell( "No" )


            if snapshot:
                # add the snapshot info
                context = snapshot.get_value("context")
                version = snapshot.get_value("version")
                table.add_cell( "%s v%0.2d" % (context, version))
            else:
                table.add_cell("---")

            table.add_cell( self.get_version_wdg(session,snapshot,node_name) )

        top.add(table)
        return top       
 def find_icon_link(my, file_path, repo_path=None):
     from pyasm.widget import ThumbWdg
     return ThumbWdg.find_icon_link(file_path, repo_path)
Example #30
0
    def get_preview_wdg(cls, subscription, category='', message_code=''):

        size = 60
        
        if subscription:
            category = subscription.get_value("category")
            message_code = subscription.get_value("message_code")


        if category == 'sobject':
            sobject = Search.get_by_search_key(message_code)
            thumb = DivWdg()

            thumb_wdg = ThumbWdg()
            thumb.add(thumb_wdg)
            thumb_wdg.set_sobject(sobject)
            thumb_wdg.set_icon_size(size)

            search_code = sobject.get_code()

            thumb.add_behavior( {
                'type': 'click_up',
                'search_key': message_code,
                'search_code': search_code,
                'cbjs_action': '''
                var class_name = 'tactic.ui.tools.SObjectDetailWdg';
                var kwargs = {
                    search_key: bvr.search_key
                }
                spt.tab.set_main_body_tab();
                var title = "Detail ["+bvr.search_code+"]";
                spt.app_busy.show("Loading " + bvr.search_code);
                spt.tab.add_new(bvr.search_code, title, class_name, kwargs);
                spt.app_busy.hide();
                '''
                } )

            

        elif category == 'chat':
            thumb = DivWdg()
            thumb.add_style("width: %s" % size)
            thumb.add_style("height: %s" % (size*3/4))
            thumb.add_border()
            thumb.add_style('text-align: center')
            thumb.add_class("hand")

            message = Search.get_by_code("sthpw/message", message_code)
            login_code = message.get_value("login")

            login = Search.get_by_code("sthpw/login", login_code)
            thumb_wdg = ThumbWdg()
            thumb.add(thumb_wdg)
            thumb_wdg.set_sobject(login)
            thumb_wdg.set_icon_size(size)

            if subscription:
                key = subscription.get_value("message_code")
                thumb.add_behavior( {
                    'type': 'click_up',
                    'key': key,
                    'cbjs_action': '''
                    var class_name = 'tactic.ui.app.ChatSessionWdg';
                    var kwargs = {
                        'key': bvr.key,
                    }
                    spt.panel.load_popup("Chat: " + bvr.key, class_name, kwargs);
                    '''
                } )

        else:
            if not category:
                category = "default"
            preview_text = "No Preview Available"
            thumb = DivWdg()
            thumb.add_style("width: %s" % size)
            thumb.add_style("height: %s" % (size*3/4))
            thumb.add_border()
            thumb.add_color("background", "background")
            #thumb.add("<br/>")
            thumb.add(preview_text)
            thumb.add_style('text-align: center')
            thumb.add_class("hand")





        thumb.add_style("margin: 3px")
        return thumb
Example #31
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
Example #32
0
    def get_display(my):

        my.view_editable = True

        if my.kwargs.get("do_search") != "false":
            my.handle_search()

        #my.kwargs['show_gear'] = 'false'


        # set the sobjects to all the widgets then preprocess
        for widget in my.widgets:
            widget.set_sobjects(my.sobjects)
            widget.set_parent_wdg(my)
            # preprocess the elements
            widget.preprocess()


        """
        # TEST code to return only the content
        temp = my.kwargs.get("temp")
        if temp:
            content = DivWdg()
            content.add( my.get_content_wdg() )
            return content
        """





        # extraneous variables inherited from TableLayoutWdg
        my.edit_permission = True

        top = DivWdg()
        my.set_as_panel(top)
        top.add_class("spt_sobject_top")

        inner = DivWdg()
        top.add(inner)
        inner.add_color("background", "background")
        inner.add_color("color", "color")
        inner.add_attr("spt_version", "2")
        inner.add_class("spt_table")
        inner.add_class("spt_layout")


        from tactic.ui.input import Html5UploadWdg
        upload_wdg = Html5UploadWdg()
        inner.add(upload_wdg)
        my.upload_id = upload_wdg.get_upload_id()

        # set up the context menus
        menus_in = {
            'DG_HEADER_CTX': [ my.get_smart_header_context_menu_data() ],
            'DG_DROW_SMENU_CTX': [ my.get_data_row_smart_context_menu_details() ]
        }
        SmartMenu.attach_smart_context_menu( inner, menus_in, False )


        thumb = ThumbWdg()
        thumb.handle_layout_behaviors(inner)

        is_refresh = my.kwargs.get("is_refresh")
        if my.kwargs.get("show_shelf") not in ['false', False]:
            action = my.get_action_wdg()
            inner.add(action)

        content = DivWdg()
        inner.add( content )
        content.add( my.get_content_wdg() )


        # NOTE: a lot of scaffolding to convince that search_cbk that this
        # is a proper layout
        top.add_class("spt_table_top");
        class_name = Common.get_full_class_name(my)
        top.add_attr("spt_class_name", class_name)


        # NOTE: adding a fake header to conform to a table layout.  Not
        # sure if this is the correct interface for this
        header_row_div = DivWdg()
        header_row_div.add_class("spt_table_header_row")
        content.add(header_row_div)
        content.add_class("spt_table_table")
        content.set_id(my.table_id)

        my.handle_load_behaviors(content)


        inner.add_class("spt_table_content");
        inner.add_attr("spt_search_type", my.kwargs.get('search_type'))
        inner.add_attr("spt_view", my.kwargs.get('view'))


        limit_span = DivWdg()
        inner.add(limit_span)
        limit_span.add_style("margin-top: 4px")
        limit_span.add_class("spt_table_search")
        limit_span.add_style("width: 250px")
        limit_span.add_style("margin: 5 auto")

        info = my.search_limit.get_info()
        if info.get("count") == None:
            info["count"] = len(my.sobjects)


        from tactic.ui.app import SearchLimitSimpleWdg
        limit_wdg = SearchLimitSimpleWdg(
            count=info.get("count"),
            search_limit=info.get("search_limit"),
            current_offset=info.get("current_offset"),
        )
        inner.add(limit_wdg)


        my.add_layout_behaviors(inner)

        if my.kwargs.get("is_refresh") == 'true':
            return inner
        else:
            return top
Example #33
0
    def get_display(my):

        my.sobject = my.get_sobject()

        top = DivWdg()
        top.add_class("spt_detail_top")
        top.add_color("background", "background")
        top.add_color("color", "color")

        if not my.sobject:
            top.add("No SObject defined for this widget")
            return top

        if my.parent:
            my.search_type = my.parent.get_base_search_type()
            my.search_key = SearchKey.get_by_sobject(my.parent)
            top.add_attr("spt_parent_key", my.search_key) 
            my.pipeline_code = my.parent.get_value("pipeline_code", no_exception=True)
            my.full_search_type = my.parent.get_search_type()
        else:
            my.pipeline_code = my.sobject.get_value("pipeline_code", no_exception=True)
            my.search_type = my.sobject.get_base_search_type()
            my.search_key = SearchKey.get_by_sobject(my.sobject)
            my.full_search_type = my.sobject.get_search_type()

        if not my.pipeline_code:
            my.pipeline_code = 'default'


        top.add_style("text-align: left")
        my.set_as_panel(top)

        table = Table()
        #from tactic.ui.container import ResizableTableWdg
        #table = ResizableTableWdg()
        table.add_color("background", "background")
        table.add_color("color", "color")
        top.add(table)
        table.set_max_width()

        table.add_row()

        # left
        #td = table.add_cell(resize=False)
        td = table.add_cell()
        #td.add_style("padding: 10px")
        td.add_style("width: 200px")
        td.add_style("min-width: 200px")
        td.add_style("vertical-align: top")
        #td.add_border()
        #td.add_style("border-style: solid")
        #td.add_style("border-width: 1px 0 1px 1px")
        #td.add_color("border-color", "border")
        #td.add_color("background", "background", -10)


        if my.parent:
            code = my.parent.get_code()
        else:
            code = my.sobject.get_code()

        # add the tile
        title = DivWdg()
        td.add(title)
        title.add_gradient("background", "background3", 0, -10)
        title.add_style("height: 20px")
        title.add_style("padding: 4px")
        title.add_style("font-weight: bold")
        title.add_style("font-size: 1.4em")
        title.add("%s" % code)
        title.add_border()


        div = DivWdg()
        td.add(div)
        div.add_class("spt_sobject_detail_top")

        thumb_table = Table()
        div.add(thumb_table)
        thumb_table.add_row()

        thumb = ThumbWdg()

        # use a larger version for clearer display
        thumb.set_icon_type('web')
        # prefer to see the original image, then web
        thumb.set_option('image_link_order', 'main|web|.swf')
        thumb.set_option("detail", "false")
        thumb.set_option("icon_size", "100%")

        td = thumb_table.add_cell(thumb)
        td.add_style("vertical-align: top")
        td.add_style("width: 200px")
        td.add_style("padding: 20px")

        if my.parent:
            thumb.set_sobject(my.parent)
        else:
            thumb.set_sobject(my.sobject)

        sobject_info_wdg = my.get_sobject_info_wdg()
        sobject_info_wdg.add_style("width: 200px")


        td.add(sobject_info_wdg)

        if my.search_type == 'sthpw/task' and not my.parent:
            pass
        else:
            sobject_info_wdg = my.get_sobject_detail_wdg()
            td = table.add_cell()
            td.add(sobject_info_wdg)
            td.add_style("vertical-align: top")
            #td.add_color("background", "background", -10)
            td.add_style("overflow: hidden")
            #td.add_style("border-style: solid")
            #td.add_style("border-width: 1px 1px 1px 0px")
            #td.add_color("border-color", "border")


        # right
        td = table.add_cell()
        td.add_style("text-align: left")
        td.add_style("vertical-align: top")
        #td.add_color("background", "background", -10)
        td.add_class("spt_notes_wrapper")
        #td.add_border()

        # add the title
        title = DivWdg()
        td.add(title)
        title.add_gradient("background", "background3", 0, -10)
        title.add_style("height: 20px")
        title.add_style("padding: 4px")
        title.add_style("font-weight: bold")
        title.add("Notes")
        title.add_border()

        notes_div = DivWdg()
        td.add(notes_div)
        from tactic.ui.widget.discussion_wdg import DiscussionWdg
        discussion_wdg = DiscussionWdg(search_key=my.search_key, context_hidden=False, show_note_expand=False)
        notes_div.add(discussion_wdg)
        notes_div.add_style("min-width: 300px")
        notes_div.add_style("height: 200")
        notes_div.add_style("overflow-y: auto")
        notes_div.add_class("spt_resizable")



        # get the process
        if my.parent:
            process = my.sobject.get_value("process")
        else:
            process = ''



        # content
        tr = table.add_row()
        td = table.add_cell()
        td.add_attr("colspan", "5")
        #td.add_attr("colspan", "3")

        # create a state for tab.  The tab only passes a search key
        # parent key
        search_key = SearchKey.get_by_sobject(my.sobject)
        parent = my.sobject.get_parent()
        if parent:
            parent_key = parent.get_search_key()
        else:
            parent_key = ""

        state = {
            'search_key': search_key,
            'parent_key': parent_key,
            'process': process,
        }
        WebState.get().push(state)


        config_xml = my.get_config_xml()
        config = WidgetConfig.get(view="tab", xml=config_xml)


        if process:
            custom_view = "tab_config_%s" % process
        else:
            custom_view = "tab_config"
        search = Search("config/widget_config")
        search.add_filter("category", "TabWdg")
        search.add_filter("search_type", my.search_type)
        search.add_filter("view", custom_view)
        custom_config_sobj = search.get_sobject()
        if custom_config_sobj:
            custom_config_xml = custom_config_sobj.get_value("config")
            custom_config = WidgetConfig.get(view=custom_view, xml=custom_config_xml)
            config = WidgetConfigView(search_type='TabWdg', view=custom_view, configs=[custom_config, config])

        #menu = my.get_extra_menu()
        #tab = TabWdg(config=config, state=state, extra_menu=menu)
        tab = TabWdg(config=config, state=state, show_add=False, show_remove=False, tab_offset=5 )
        tab.add_style("margin: 0px -2px -2px -2px")
        td.add(tab)
        td.add_style("padding-top: 10px")

        return top
Example #34
0
 def preprocess(my):
     my.thumb = ThumbWdg()
     my.thumb.set_icon_size('60')
     my.thumb.set_sobjects(my.sobjects)
     my.thumb.preprocess()
Example #35
0
 def preprocess(self):
     self.thumb = ThumbWdg()
     self.thumb.set_sobjects(self.sobjects)
     self.thumb.preprocess()
Example #36
0
 def preprocess(my):
     my.thumb = ThumbWdg()
     my.thumb.set_sobjects(my.sobjects)
     my.thumb.preprocess()
Example #37
0
    def get_display(my):

        web = WebContainer.get_web()

        
        tactic_header = Table()
        tactic_header.add_row()
        tactic_header.add_color("color", "color2")


        # tactic logo and release info
        skin = web.get_skin()
        src = '/context/skins/' + skin + '/images/tactic_logo.png'
        img = HtmlElement.img(src)
        img.add_class('hand')
        img.add_attr('title', 'Go to home page')
        img.add_behavior({'type': 'click_up', 'cbjs_action': "window.location='/tactic/'"})

        rel_div = DivWdg()
        rel_div.add("&nbsp;"*3)
        rel_div.add("Release: %s" %Environment.get_release_version() )
        rel_div.add_style("font-size: 9px")
        # Need this to override the above color in add_looks
        rel_div.add_color("color", "color2")

        tactic_wdg = Table()

        tactic_wdg.add_style("width: 180px")
        tactic_wdg.add_row()
        td = tactic_wdg.add_cell( img )
        td.set_style("width:100px")
        tactic_wdg.add_row()
        td = tactic_wdg.add_cell( rel_div )
        td.set_style("text-align: left") 

        td = tactic_header.add_cell( tactic_wdg )
       
        # add the project thumb and title
        project = Project.get()

        if my.show_project:
            thumb_div = DivWdg()
            td = tactic_header.add_cell( thumb_div )
            thumb_div.add_style("height: 28px")
            thumb_div.add_style("overflow: hidden")
            thumb_div.add_border(modifier=-10)
            thumb_div.add_style("-moz-border-radius: 3px")

            thumb = ThumbWdg()
            thumb_div.add(thumb)
            thumb.set_sobject(project)
            thumb.set_icon_size("45")
            td.set_style("vertical-align: top; padding-right:14px;padding-left: 3px")

            td = tactic_header.add_cell( project.get_value("title") )
            #td.add_looks( "fnt_title_1" )
            td.add_style("font-size: 20px")
            td.add_style("white-space: nowrap")
            td.add_style("padding-left: 14px")

            # project selection 
            td = tactic_header.add_cell()
            project_div = DivWdg()
            project_div.add_style("margin-top: -5px")
            project_div.add(ProjectSelectWdg() )
            td.add( project_div )
            td.set_style("padding-left: 14px")
             

            # Global Actions Gear Menu (contains links to Documentation) ...
            action_bar_btn_dd = PageHeaderGearMenuWdg()
            action_div = DivWdg(action_bar_btn_dd)
            action_div.add_style("margin-top: -5px")
            td = tactic_header.add_cell( action_div )

            if PrefSetting.get_value_by_key('subscription_bar') == 'true':
                from message_wdg import SubscriptionBarWdg
                sub = SubscriptionBarWdg(mode='popup')
                tactic_header.add_cell(sub)

        # user login

        # user
        user = Environment.get_login()
        full_name = user.get_full_name()
        user_div = SpanWdg( HtmlElement.b( "%s&nbsp;&nbsp;" % full_name) , css='hand')       
        user_div.set_style("padding-right:10px")

        # signout
        login = Environment.get_security().get_login()
        search_key = SearchKey.get_by_sobject(login)
        span = SpanWdg()
        span.add( user_div )
        user_div.add_attr('spt_nudge_menu_vert', '20')
       
        td = tactic_header.add_cell(span)       
        td.set_style("width:100%; text-align:right; white-space: nowrap")



        from tactic.ui.widget import SingleButtonWdg
        button = SingleButtonWdg(title='My Account', icon=IconWdg.USER, show_arrow=True)
        button_div = DivWdg(button)
        button_div.add_style("margin-top: -5px")
        button.add_attr('spt_nudge_menu_horiz', '-80')
        button.add_attr('spt_nudge_menu_vert', '10')

        td = tactic_header.add_cell(button_div)
    

        menus = my.get_smart_menu()
        # TODO: this part seems redundant to attach to both
        SmartMenu.add_smart_menu_set(user_div, [menus])
        SmartMenu.assign_as_local_activator(user_div, None, True)

        SmartMenu.add_smart_menu_set(button, [menus])
        SmartMenu.assign_as_local_activator(button, None, True)

   


        td.set_style("width:100%;")
        button = SingleButtonWdg(title='Help', icon=IconWdg.HELP_BUTTON, show_arrow=False)
        #button.add_behavior( {
        #'type': 'click_up',
        #'cbjs_action': '''
        #window.open("/doc/")
        #'''
        #} )

        button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        spt.named_events.fire_event("show_help")
        '''
        } )


        from tactic.ui.container import DialogWdg
        help_dialog = DialogWdg(z_index=900, show_pointer=False)
        td.add(help_dialog)
        help_dialog.add_title("Help")
        help_dialog.add_class("spt_help")


        # container for help
        help_div = DivWdg()
        help_dialog.add(help_div)

        from help_wdg import HelpWdg
        help_wdg = HelpWdg()
        help_div.add(help_wdg)


        button_div = DivWdg(button)
        button_div.add_style("margin-top: -5px")
        td = tactic_header.add_cell(button_div)
        td.set_style("width:100%; text-align:right; white-space: nowrap")


        # Layout the Main Header Table
        main_div = DivWdg()

        # TEST: NEW LAYOUT
        if Config.get_value("install", "layout") == "fixed":
            main_div.add_style("position: fixed")
            main_div.add_style("z-index: 100")
            main_div.add_style("width: 100%")

        license = Environment.get_security().get_license()

        if not license.is_licensed():
            from tactic.ui.app import LicenseManagerWdg
            license_manager = LicenseManagerWdg(use_popup=True)
            main_div.add(license_manager)

        

        # create the header table
        tactic_header_div = DivWdg()
        tactic_header_div.add(tactic_header)
        tactic_header_div.add_gradient("background", "background2", 10, -10)

        main_div.add(tactic_header_div)

        main_div.add( my.get_js_popup() )


        """
        main_div.add( HelpPopupWdg() )

        # FIXME: is this even used at all?
        action_bar_popup = PopupWdg( id="ActionBarWdg_popup", allow_page_activity=True, width="636px" )
        action_bar_popup.add_title( "TACTIC&trade; Action Bar" )
        action_bar_popup.add( ActionBarWdg() )
        main_div.add( action_bar_popup )
        """

        # FIXME(?): does this CommonPopup need to be at z_start=300? By default popups will be at z_start=200
        popup = PopupWdg( id="CommonPopup", allow_page_activity=True, width="600px", z_start=300 )
        popup.add('Tools', 'title')

        main_div.add( popup )

        
        return main_div
Example #38
0
    def get_preview_wdg(cls, subscription, category='', message_code=''):

        size = 60
        
        if subscription:
            category = subscription.get_value("category")
            message_code = subscription.get_value("message_code")


        if category == 'sobject':
            sobject = Search.get_by_search_key(message_code)
            thumb = DivWdg()

            thumb_wdg = ThumbWdg()
            thumb.add(thumb_wdg)
            thumb_wdg.set_sobject(sobject)
            thumb_wdg.set_icon_size(size)

            search_code = sobject.get_code()

            thumb.add_behavior( {
                'type': 'click_up',
                'search_key': message_code,
                'search_code': search_code,
                'cbjs_action': '''
                var class_name = 'tactic.ui.tools.SObjectDetailWdg';
                var kwargs = {
                    search_key: bvr.search_key
                }
                spt.tab.set_main_body_tab();
                var title = "Detail ["+bvr.search_code+"]";
                spt.app_busy.show("Loading " + bvr.search_code);
                spt.tab.add_new(bvr.search_code, title, class_name, kwargs);
                spt.app_busy.hide();
                '''
                } )



        elif category == 'chat':
            thumb = DivWdg()
            thumb.add_style("width: %s" % size)
            thumb.add_style("height: %s" % (size*3/4))
            thumb.add_border()
            thumb.add_style('text-align: center')
            thumb.add_class("hand")

            message = Search.get_by_code("sthpw/message", message_code)
            login_code = message.get_value("login")

            login = Search.get_by_code("sthpw/login", login_code)
            thumb_wdg = ThumbWdg()
            thumb.add(thumb_wdg)
            thumb_wdg.set_sobject(login)
            thumb_wdg.set_icon_size(size)

            if subscription:
                key = subscription.get_value("message_code")
                thumb.add_behavior( {
                    'type': 'click_up',
                    'key': key,
                    'cbjs_action': '''
                    var class_name = 'tactic.ui.app.ChatSessionWdg';
                    var kwargs = {
                        'key': bvr.key,
                    }
                    spt.panel.load_popup("Chat: " + bvr.key, class_name, kwargs);
                    '''
                } )

        else:
            if not category:
                category = "default"
            thumb = DivWdg()
            thumb.add_style("width: %s" % size)
            thumb.add_style("height: %s" % (size*3/4))
            thumb.add_border()
            thumb.add_color("background", "background")
            thumb.add("<br/>")
            thumb.add(category)
            thumb.add_style('text-align: center')
            thumb.add_class("hand")





        thumb.add_style("margin: 3px")
        return thumb
Example #39
0
    def get_display(my):

        my.is_refresh = my.kwargs.get('is_refresh') =='true'
      
        if not my.is_refresh:
            top = DivWdg(css='spt_view_panel')
            my.set_as_panel(top)
        else:
            top = Widget() 

        div = DivWdg(css="filter_box")
        div.add("<b>Current Session</b>")
        top.add(div)

        # the button which initiates the introspection
        button = IntrospectWdg()
        #button.add_style("float", "right")
        top.add(button)

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


        session = SessionContents.get()
        if not session:
            widget.add("<h3>No contents in session</h3>")
            return widget

        table = Table()
        table.add_class("table")
        table.add_style("width: 100%")
        table.add_row()
        table.add_header("&nbsp;")
        table.add_header("Type")
        table.add_header("Asset")
        table.add_header("Node Name")
        table.add_header("Node Type")
        table.add_header("Reference")
        table.add_header("Session")
        table.add_header("Latest")

        node_names = session.get_node_names()
        for node_name in node_names:
            table.add_row()


            # snapshot_code
            snapshot_code = session.get_snapshot_code(node_name, "shot")
            if not snapshot_code:
                snapshot_code = session.get_snapshot_code(node_name, "anim")
            if not snapshot_code:
                snapshot_code = session.get_snapshot_code(node_name, "asset")

            snapshot = Snapshot.get_by_code(snapshot_code)
            sobject = None

            if snapshot:

                sobject = snapshot.get_sobject()
                base = sobject.get_search_type_obj().get_base_search_type()

                thumb = ThumbWdg()
                thumb.set_icon_size(60)

                # FIXME: make this more automatic
                if base == "prod/shot_instance":
                    thumb_sobj = sobject.get_parent("prod/asset")
                    thumb.set_sobject(thumb_sobj)
                else:
                    thumb.set_sobject(sobject)

                table.add_cell(thumb)

                title = sobject.get_search_type_obj().get_title()
                table.add_cell( title )

                # TODO: this should be more automatic!
                if base == "prod/shot_instance":
                    asset_code = sobject.get_value("asset_code")
                    shot_code = sobject.get_value("shot_code")
                    name = sobject.get_value("name")
                    table.add_cell("%s: %s in %s" % (name,asset_code,shot_code))
                else:
                    code = sobject.get_code()
                    name = sobject.get_name()
                    if code == name:
                        table.add_cell( "%s" % (code) )
                    else:
                        table.add_cell( "%s - %s" % (code, name) )

            else:
                table.add_cell("<i>No snapshot</i>")
                table.add_cell("---")
                table.add_cell("---")
                

            # display the node name
            table.add_cell(node_name)

            # display node type
            table.add_cell( session.get_node_type(node_name) )


            # display if it is a reference
            is_reference = session.is_reference(node_name)
            if is_reference:
                table.add_cell( "Yes" )
            else:
                table.add_cell( "No" )


            if snapshot:
                # add the snapshot info
                context = snapshot.get_value("context")
                version = snapshot.get_value("version")
                table.add_cell( "%s v%0.2d" % (context, version))
            else:
                table.add_cell("---")

            table.add_cell( my.get_version_wdg(session,snapshot,node_name) )

        top.add(table)
        return top       
Example #40
0
    def get_chat_wdg(my, key, interval=False):

        div = DivWdg()
        div.add_class("spt_chat_session_top")
        div.add_color("background", "background")

        title_wdg = DivWdg()
        div.add(title_wdg)
        title_wdg.add_color("background", "background3")
        title_wdg.add_style("padding: 5px")
        title_wdg.add_style("font-weight: bold")
        title_wdg.add_border()

        icon = IconButtonWdg(title="Remove Chat", icon=IconWdg.DELETE)
        icon.add_style("float: right")
        icon.add_style("margin-top: -5px")
        title_wdg.add(icon)
        icon.add_behavior( {
            'type': 'click_up',
            'key': key,
            'cbjs_action': '''
            var server = TacticServerStub.get();

            var top = bvr.src_el.getParent(".spt_chat_session_top");
            spt.behavior.destroy_element(top);
            '''
        } )


        current_user = Environment.get_user_name()
        logins = Search.eval("@SOBJECT(sthpw/subscription['message_code','%s'].sthpw/login)" % key)
        for login in logins:
            if login.get_value("login") == current_user:
                continue

            thumb = ThumbWdg()
            thumb.set_icon_size(45)
            thumb.set_sobject(login)
            thumb.add_style("float: left")
            thumb.add_style("margin: -5px 10px 0px -5px")
            title_wdg.add(thumb)
            title_wdg.add(login.get_value("display_name"))

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


        history_div = DivWdg()
        div.add(history_div)
        history_div.add_class("spt_chat_history")
        history_div.add_style("width: auto")
        history_div.add_style("height: auto")
        history_div.add_style("max-height: 400px")
        history_div.add_style("padding: 5px")
        history_div.add_class("spt_resizable")

        history_div.add_border()
        history_div.add_style("overflow-y: auto")
        #history_div.add_style("font-size: 0.9em")


        search = Search("sthpw/message_log")
        search.add_filter("message_code", key)
        search.add_order_by("timestamp")
        message_logs = search.get_sobjects()
        last_login = None;
        last_date = None;
        for message_log in message_logs:

            login = message_log.get("login")
            message = message_log.get("message")
            timestamp = message_log.get_datetime_value("timestamp")
            #timestamp = timestamp.strftime("%b %d, %Y - %H:%M")
            timestamp_str = timestamp.strftime("%H:%M")
            date_str = timestamp.strftime("%b %d, %Y")
        
            msg = "";
            msg += "<table style='margin-top: 5px; font-size: 0.9em; width: 100%'><tr><td colspan='2'>";

            if date_str != last_date:
                msg += "<br/><b style='font-size: 1.0em'>"+date_str+"</b><hr/></td></tr>";
                msg += "<tr><td>";
                last_login = None

            if login != last_login:
                msg += "<b>"+login+"</b><br/>";
            msg += message.replace("\n",'<br/>');
            msg += "</td><td style='text-align: right; margin-bottom: 5px; width: 75px; vertical-align: top'>";
            msg += timestamp_str;
            msg += "</td></tr></table>";

            history_div.add(msg)

            last_login = login
            last_date = date_str

        history_div.add_behavior( {
            'type': 'load',
            'cbjs_action': '''
            bvr.src_el.scrollTop = bvr.src_el.scrollHeight;
            '''
        } )


        if message_logs:
            last_message = message_logs[-1].get("message")
            last_login = message_logs[-1].get("login")
        else:
            last_message = ""
            last_login = ""
        div.add_attr("spt_last_message", last_message)
        div.add_attr("spt_last_login", last_login)




        if interval:

            div.add_behavior( {
            'type': 'load',
            'key': key,
            'cbjs_action': r'''
            var text_el = bvr.src_el.getElement(".spt_chat_text");
            var history_el = bvr.src_el.getElement(".spt_chat_history");
            var callback = function(message) {
                //history_el.setStyle("background", "red");
                var login = message.login;
                var timestamp = message.timestamp;
                if (timestamp) {
                    var parts = timestamp.split(" ");
                    parts = parts[1].split(".");
                    timestamp = parts[0];
                }
                else {
                    timestamp = "";
                }

                var tmp = message.message || "";

                var last_message = bvr.src_el.getAttribute("spt_last_message");
                var last_login = bvr.src_el.getAttribute("spt_last_login");
                if (tmp == last_message && login == last_login) {
                    return;
                }
                bvr.src_el.setAttribute("spt_last_message", tmp);
                bvr.src_el.setAttribute("spt_last_login", login);

                var msg = "";
                msg += "<table style='margin-top: 5px; font-size: 0.9em; width: 100%'><tr><td>";
                if (login != last_login) {
                    msg += "<b>"+login+"</b><br/>";
                }
                msg += tmp.replace(/\n/g,'<br/>');
                msg += "</td><td style='text-align: right; margin-bottom: 5px; width: 75px; vertical-align: top'>";
                msg += timestamp;
                msg += "</td></tr></table>";

                if (msg == history_el.last_msg) {
                    return;
                }
                history_el.innerHTML =  history_el.innerHTML + msg;

                // remember last message
                history_el.last_msg = msg;


                history_el.scrollTop = history_el.scrollHeight;
            }
            spt.message.set_interval(bvr.key, callback, 3000, bvr.src_el);
            '''
            } )

        text = TextAreaWdg("chat")
        div.add(text)
        text.add_class("spt_chat_text")
        text.add_style("width: 100%")
        text.add_style("padding: 5px")
        text.add_style("margin-top: -1px")
        
        text.add_behavior( {
        'type': 'load',
        'cbjs_action': '''
        bvr.src_el.addEvent("keydown", function(e) {

        var keys = ['tab','keys(control+enter)', 'enter'];
        var key = e.key;
        var input = bvr.src_el
        if (keys.indexOf(key) > -1) e.stop();

        if (key == 'tab') {
        }
        else if (key == 'enter') {
            if (e.control == false) {
                pass;
            }
            else {
                 // TODO: check if it's multi-line first 
                 //... use ctrl-ENTER for new-line, regular ENTER (RETURN) accepts value
                //var tvals = parse_selected_text(input);
                //input.value = tvals[0] + "\\n" + tvals[1];
                //spt.set_cursor_position( input, tvals[0].length + 1 );
            }
        }
        } )
        '''
        } )



        button = ActionButtonWdg(title="Send")
        div.add(button)
        button.add_behavior( {
        'type': 'click_up',
        'key': key,
        'cbjs_action': '''

        var top = bvr.src_el.getParent(".spt_chat_session_top");
        var text_el = top.getElement(".spt_chat_text");
        var message = text_el.value;
        if (!message) {
            return;
        }

        var history_el = top.getElement(".spt_chat_history");

        var category = "chat";
        var server = TacticServerStub.get();

        var key = bvr.key;
        var last_message = server.log_message(key, message, {category:category, status:"in_progress"});

        text_el.value = "";

            '''
        } )


        return div
Example #41
0
 def preprocess(self):
     self.thumb = ThumbWdg()
     self.thumb.set_icon_size('60')
     self.thumb.set_sobjects(self.sobjects)
     self.thumb.preprocess()
Example #42
0
    def get_display(self):

        self.search_key = self.kwargs.get("search_key") 
        self.context = self.kwargs.get("context") 

        assert self.search_key
        assert self.context

        top = DivWdg()
        self.set_as_panel(top)
        top.add_class("spt_review_top")

        table = Table()
        top.add(table)
        table.add_row()
        left = table.add_cell()
        left.add_style("vertical-align: top")



        button = IconButtonWdg("Visual Notes", IconWdg.EDIT)
        button.add_behavior( {
        'type': 'click_up',
        'kwargs': {
            'search_key': self.search_key,
            'context': self.context,
        },
        'cbjs_action': '''
        var top = bvr.src_el.getParent(".spt_review_top");
        var content = top.getElement(".spt_review_content");
        spt.panel.load(content, "tactic.ui.widget.visual_notes_wdg.VisualNotesWdg", bvr.kwargs);
        '''
        } )
        left.add(button)


        # add a refresh button and a gear menu
        button = IconButtonWdg("Refresh", IconWdg.REFRESH)
        button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        var panel = bvr.src_el.getParent(".spt_review_top");
        spt.panel.refresh(panel);
        '''
        } )
        left.add(button)






        right = table.add_cell()
        right.add_style("vertical-align: top")
        right.add("Image Area")


        content_div = DivWdg()
        content_div.add_class("spt_review_content")
        content_div.add_style("padding: 5px")
        content_div.add_style("margin: 5px")
        content_div.add_style("border: solid 1px #999")
        content_div.add_style("min-width: 500px")
        content_div.add_style("min-height: 400px")
        content_div.add_style("height: 100%")

        right.add(content_div)



        sobject = Search.get_by_search_key(self.search_key)

        note_context = "%s|note" % self.context
        snapshots = Search.eval("@SOBJECT(sthpw/snapshot['context','=','%s'])" % note_context, [sobject])

        vnotes_div = DivWdg()
        vnotes_div.add_style("overflow: auto")
        vnotes_div.add_style("width: 200px")
        vnotes_div.add_style("min-height: 400px")
        vnotes_div.add_style("max-height: 600px")
        vnotes_div.add_style("border: solid 1px #999")
        vnotes_div.add_style("padding: 5px")
        vnotes_div.add_style("margin: 5px")

        left.add(vnotes_div)

        if not snapshots:
            vnotes_div.add("<b>No review notes available</b>")

            notes_wdg = VisualNotesWdg(search_key=self.search_key,context=self.context)
            content_div.add(notes_wdg)



        for snapshot in snapshots:
            vnote_div = DivWdg()
            vnotes_div.add(vnote_div)

            file_obj = snapshot.get_file_by_type('main')
            if not file_obj:
                vnote_div.add("None found")
                continue

            rel_path = file_obj.get_value("relative_dir")
            file_name = file_obj.get_value("file_name")
            image_url = "/assets/%s/%s" % (rel_path, file_name)


            login = snapshot.get_value("login")
            date = snapshot.get_value("timestamp")
            import dateutil
            date_str = dateutil.parser.parse(date).strftime("%b %m %Y - %H:%M")


            login_div = DivWdg()
            login_div.add_style("padding: 2px")
            login_div.add("User: "******"<b>%s</b><br/>" % login )
            login_div.add("Date: ")
            login_div.add( "<b>%s</b><br/>" % date_str )
            vnote_div.add(login_div)



            from pyasm.widget import ThumbWdg
            thumb_div = DivWdg()
            thumb_div.add_style("margin-left: 10px")
            thumb = ThumbWdg()
            thumb_div.add(thumb)
            thumb.set_has_img_link(False)
            thumb.set_option("detail", "false")
            thumb.set_option("icon_size", "80")
            thumb.set_sobject(snapshot)
            vnote_div.add(thumb_div)
            #file_obj = snapshot.get_file_by_type('icon')
            #rel_path = file_obj.get_value("relative_dir")
            #file_name = file_obj.get_value("file_name")
            #icon_url = "/assets/%s/%s" % (rel_path, file_name)
            #vnote_div.add("<img src='%s'/>" % icon_url )

            #vnote_div.add(snapshot.get_code() )
            vnote_div.add_attr("spt_image_url", image_url )
            vnote_div.add_class('hand')

            vnote_div.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var value = bvr.src_el.innerHTML;
            var image_url = bvr.src_el.getAttribute("spt_image_url");

            var top = bvr.src_el.getParent(".spt_review_top");
            var content = top.getElement(".spt_review_content");
            content.innerHTML = "<img src='"+image_url+"'/>";
            '''
            } )




            # get the related note to this vnote
            #notes = vnotes_div.get_related_notes()
            search = Search("sthpw/note")
            search.add_parent_filter(sobject)
            notes = search.get_sobjects()

            #for note in notes:
            #    vnote_div.add(note.get_value("note"))

            from pyasm.biz import SObjectConnection 
            connections, related_notes = SObjectConnection.get_connected_sobjects(snapshot, direction='src')
            for related_note in related_notes:
                vnote_div.add(related_note.get_value("note") )
                
            print "related_notes: ", related_notes


            vnote_div.add("<hr/>")




        return top
Example #43
0
 def preprocess(self):
     self.thumb = ThumbWdg()
     self.thumb.set_sobjects(self.sobjects)
     self.thumb.preprocess()
Example #44
0
    def get_display(my):
        my.init_kwargs()
        sobject = my.get_current_sobject()

        table = Table(css='minimal')
        table.add_color("color", "color")
        table.add_style("font-size: 0.9em")

        snapshots = my.get_snapshot(my.mode)
        for snapshot in snapshots:
            table.add_row()

            value = my.get_input_value(sobject, snapshot)

            current_version = snapshot.get_value("version")
            current_context = snapshot.get_value("context")
            current_revision = snapshot.get_value("revision",
                                                  no_exception=True)
            current_snapshot_type = snapshot.get_value("snapshot_type")

            # hack hard coded type translation
            if current_snapshot_type == "anim_export":
                current_snapshot_type = "anim"

            # ignore icon context completely
            if current_context == "icon":
                table.add_blank_cell()
                table.add_cell("(---)")
                return table

            checkbox = CheckboxWdg('%s_%s' % (my.search_type, my.CB_NAME))

            # this is added back in for now to work with 3.7 Fast table
            checkbox.add_behavior({'type': 'click_up', 'propagate_evt': True})

            checkbox.add_class('spt_latest_%s' % my.mode)
            checkbox.set_option("value", value)
            table.add_cell(checkbox)

            load_all = False
            if load_all:
                checkbox.set_checked()

            # add the file type icon
            xml = snapshot.get_snapshot_xml()
            file_name = xml.get_value("snapshot/file/@name")
            icon_link = ThumbWdg.find_icon_link(file_name)
            image = HtmlElement.img(icon_link)
            image.add_style("width: 15px")
            table.add_cell(image)

            namespace = my.get_namespace(sobject, snapshot)
            asset_code = my.get_asset_code()

            # force asset mode = True
            my.session.set_asset_mode(asset_mode=my.get_session_asset_mode())
            node_name = my.get_node_name(snapshot, asset_code, namespace)
            # get session info
            session_context = session_version = session_revision = None
            if my.session:

                session_context = my.session.get_context(
                    node_name, asset_code, current_snapshot_type)
                session_version = my.session.get_version(
                    node_name, asset_code, current_snapshot_type)
                session_revision = my.session.get_revision(
                    node_name, asset_code, current_snapshot_type)

                # Maya Specific: try with namespace in front of it for referencing
                referenced_name = '%s:%s' % (namespace, node_name)
                if not session_context or not session_version:
                    session_context = my.session.get_context(
                        referenced_name, asset_code, current_snapshot_type)
                    session_version = my.session.get_version(
                        referenced_name, asset_code, current_snapshot_type)
                    session_revision = my.session.get_revision(
                        referenced_name, asset_code, current_snapshot_type)

            from version_wdg import CurrentVersionContextWdg, SubRefWdg

            version_wdg = CurrentVersionContextWdg()
            data = {'session_version': session_version, \
                'session_context': session_context,  \
                'session_revision': session_revision,  \
                'current_context': current_context, \
                'current_version': current_version, \
                'current_revision': current_revision }
            version_wdg.set_options(data)

            table.add_cell(version_wdg, "no_wrap")
            td = table.add_cell(HtmlElement.b("(%s)" % current_context))
            td.add_tip("Snapshot code: %s" % snapshot.get_code())
            #table.add_cell(snapshot.get_code() )

            #if snapshot.is_current():
            #    current = IconWdg("current", IconWdg.CURRENT)
            #    table.add_cell(current)
            #else:
            #    table.add_blank_cell()

            # handle subreferences
            has_subreferences = True
            xml = snapshot.get_xml_value("snapshot")
            refs = xml.get_nodes("snapshot/file/ref")
            if my.mode == "output" and refs:
                table.add_row()
                td = table.add_cell()
                swap = SwapDisplayWdg.get_triangle_wdg()
                td.add(swap)
                td.add("[ %s reference(s)" % len(refs))
                #td.add_style("text-align: right")

                sub_ref_wdg = SubRefWdg()
                sub_ref_wdg.set_info(snapshot, my.session, namespace)
                swap.add_action_script(
                    sub_ref_wdg.get_on_script(),
                    "toggle_display('%s')" % sub_ref_wdg.get_top_id())

                status = sub_ref_wdg.get_overall_status()
                td.add(SpanWdg(VersionWdg.get(status), css='small_left'))
                td.add(']')

                td.add(sub_ref_wdg)
                td.add_style('padding-left: 10px')

        #else:
        if not snapshots:
            table.add_row()
            table.add_blank_cell()
            table.add_cell("(---)")

        return table
Example #45
0
    def get_display(my):

        top = my.top

        src = my.kwargs.get("src")
        file = my.kwargs.get("file")
        if file:
            src = file.get_web_path()

        opacity = 1.0
        if not src:
            src = "/context/icons/logo/tactic_silver.png"
            opacity = 0.6

        height = my.kwargs.get("height")
        width = my.kwargs.get("width")
        index = my.kwargs.get("index")

        if not height:
            height = "auto"
        if not width:
            width = "100%"

        width = "100%"
        height = "auto"

        #div = DivWdg()
        #top.add(div)
        div = top
        div.add_class("unselectable")
        div.add_style("opacity", opacity)
        div.add_style("overflow-x: hidden")
        div.add_style("overflow-y: hidden")
        div.add_style("margin-left: auto")
        div.add_style("margin-right: auto")
        div.add_style("text-align: center")
        if height:
            div.add_style("height", height)
        if width:
            div.add_style("width", width)

        parts = os.path.splitext(src)
        ext = parts[1]
        ext = ext.lower()

        click = my.kwargs.get("click")
        if click in [False, 'false']:
            click = False
        else:
            click = True

        thumb_path = my.kwargs.get("thumb_path")
        preload = my.kwargs.get("preload")
        if not preload:
            preload = "none"

        ext = ext.lstrip(".")
        if ext in File.IMAGE_EXT:
            embed = HtmlElement.img(src)
            embed.add_style("width: 100%")
            embed.add_style("height: auto")
        elif ext in File.VIDEO_EXT:
            from tactic.ui.widget import VideoWdg
            embed = DivWdg()

            if not thumb_path:
                thumb_path = "/context/icons/logo/tactic_sml.png"
            controls = my.kwargs.get("controls")
            if not controls:
                controls = "true"

            video_id = None
            sources = [src]
            source_types = ["video/mp4"]
            poster = thumb_path
            width = '100%'
            height = '100%'
            #width = "640"
            #height = "480"
            video = VideoWdg(video_id=video_id,
                             sources=sources,
                             source_types=source_types,
                             poster=poster,
                             preload=preload,
                             controls=controls,
                             width=width,
                             height=height,
                             index=index)
            embed.add(video)
            video.get_video().add_class("spt_resizable")

            click = False

        else:
            #embed = HtmlElement.embed(src)
            if thumb_path:
                img = HtmlElement.img(thumb_path)
            else:
                from pyasm.widget import ThumbWdg
                link = ThumbWdg.find_icon_link(src)
                img = HtmlElement.img(link)
            img.add_style("width: 50%")
            img.add_style("margin: 20px 20px")
            embed = DivWdg(img)
        div.add(embed)

        if click:
            embed.add_behavior({
                'type':
                'click_up',
                'src':
                src,
                'cbjs_action':
                '''
                window.open(bvr.src);
                '''
            })
            embed.add_class("hand")

        #embed.add_style("width", "100%")
        # NOTE: to keep true original aspect ratio, don't set this height
        # and let GalleryWdg inner load script to take care of it on load
        # that js portion needs uncommenting as well
        #embed.add_style("height", "100%")
        #embed.set_box_shadow("1px 1px 1px 1px")
        return top
Example #46
0
    def get_display(self):

        top = self.top
        login = self.kwargs.get("login")
        if not login or login == "$LOGIN":
            login = Environment.get_user_name()

        login_sobj = Login.get_by_code(login)

        #top.add_style("margin-top: -2px")
        #top.add_style("margin-left: -2px")

        thumb_div = DivWdg()
        thumb_div.add_style("float: left")
        thumb_div.add_style("margin-right: 5px")
        thumb_div.add_style("margin-bottom: 5px")
        thumb_div.add_style("padding-top: 1px")
        thumb = ThumbWdg()
        thumb.set_sobject(login_sobj)
        thumb_div.add(thumb)
        thumb.set_icon_size(90)
        thumb.set_aspect("height")

        full_name = login_sobj.get_full_name()

        info_wdg = DivWdg()
        top.add(info_wdg)

        name_wdg = DivWdg()
        info_wdg.add(thumb_div)
        info_wdg.add(name_wdg)
        name_wdg.add("&nbsp;" * 3)
        name_wdg.add(full_name)
        name_wdg.add_style("font-size: 1.5em")
        name_wdg.add_style("font-weight: bold")
        name_wdg.add_style("padding: 5px")
        #name_wdg.add_style("margin-left: -10px")
        name_wdg.add_color("background", "background3")
        name_wdg.add_style("height: 20px")
        name_wdg.add_style("margin-bottom: 0px")
        name_wdg.add_border()

        info_wdg.add("<br/>")

        from tactic.ui.container import TabWdg

        # return if the supplied tab view has a config xml
        if self.tab_view:
            search = Search("config/widget_config")
            search.add_filter("category", "TabWdg")
            search.add_filter("view", self.tab_view)
            config_sobj = search.get_sobject()
            if config_sobj:

                config_xml = config_sobj.get_value('config')
                # replace the variable $login with the login clicked
                if login:
                    config_xml = config_xml.replace('$login', login)

                tab = TabWdg(config_xml=config_xml,
                             view=self.tab_view,
                             show_add=False,
                             show_remove=False)
                top.add(tab)
                return top

        config_xml = []
        config_xml.append('<config>')
        config_xml.append('<tab>')

        config_xml.append('''
        <element name='schedule'>
          <display class='tactic.ui.widget.TaskCalendarWdg'>
            <assigned>%s</assigned>
            <sobject_display_expr>%s</sobject_display_expr>
            <show_header>true</show_header>
            <show_border>false</show_border>
          </display>
        </element> 
        ''' % (login, self.sobject_display_expr))

        config_xml.append('''
        <element name='activity'>
          <display class='tactic.ui.widget.ActivityCalendarWdg'>
            <login>%s</login>
            <cell_width>100px</cell_width>
            <cell_height>50px</cell_height>
            <show_header>true</show_header>
            <show_border>false</show_border>
          </display>
        </element> 
        ''' % login)

        config_xml.append('''
        <element name='tasks'>
          <display class='tactic.ui.panel.FastTableLayoutWdg'>
            <search_type>sthpw/task</search_type>
            <view>table</view>
            <expression>@SOBJECT(sthpw/task['assigned','%s']['@ORDER_BY', 'bid_start_date desc'])</expression>
            <mode>simple</mode>
          </display>
        </element> 
        ''' % login)

        config_xml.append('''
        <element name='work_hours'>
          <display class='tactic.ui.widget.SObjectCalendarWdg'>
            <login>%s</login>
            <!--
            <cell_width>100px</cell_width>
            -->
            <cell_height>50px</cell_height>
            <show_header>true</show_header>
            <show_border>false</show_border>
            <search_type>sthpw/work_hour</search_type>
            <handler>tactic.ui.widget.WorkHourCalendarDayWdg</handler>
            <start_date_col>day</start_date_col>
            <end_date_col>day</end_date_col>
          </display>
        </element> 
        ''' % login)

        config_xml.append('''
         <element name='recent transactions'>
          <display class='tactic.ui.panel.FastTableLayoutWdg'>
            <search_type>sthpw/transaction_log</search_type>
            <view>table</view>
            <expression>@SOBJECT(sthpw/transaction_log['login','%s']['@ORDER_BY','timestamp desc']['@LIMIT','30'])</expression>
            <element_names>code,timestamp,namespace,description,transaction_log_hidden</element_names>
            <show_shelf>false</show_shelf>
            <show_select>false</show_select>
          </display>
        </element> 
        ''' % login)

        config_xml.append('</tab>')
        config_xml.append('</config>')
        config_xml = "".join(config_xml)

        tab = TabWdg(config_xml=config_xml,
                     view='tab',
                     show_add=False,
                     show_remove=False)
        top.add(tab)
        tab.add_style("margin-left: -2px")
        tab.add_style("margin-right: -2px")

        return top
Example #47
0
    def get_chat_wdg(self, key, interval=False):

        div = DivWdg()
        div.add_class("spt_chat_session_top")
        div.add_color("background", "background")

        title_wdg = DivWdg()
        div.add(title_wdg)
        title_wdg.add_color("background", "background3")
        title_wdg.add_style("padding: 5px")
        title_wdg.add_style("font-weight: bold")
        title_wdg.add_border()

        icon = IconButtonWdg(title="Remove Chat", icon=IconWdg.DELETE)
        icon.add_style("float: right")
        icon.add_style("margin-top: -5px")
        title_wdg.add(icon)
        icon.add_behavior( {
            'type': 'click_up',
            'key': key,
            'cbjs_action': '''
            var server = TacticServerStub.get();

            var top = bvr.src_el.getParent(".spt_chat_session_top");
            spt.behavior.destroy_element(top);
            '''
        } )


        current_user = Environment.get_user_name()
        logins = Search.eval("@SOBJECT(sthpw/subscription['message_code','%s'].sthpw/login)" % key)
        for login in logins:
            if login.get_value("login") == current_user:
                continue

            thumb = ThumbWdg()
            thumb.set_icon_size(45)
            thumb.set_sobject(login)
            thumb.add_style("float: left")
            thumb.add_style("margin: -5px 10px 0px -5px")
            title_wdg.add(thumb)
            title_wdg.add(login.get_value("display_name"))

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


        history_div = DivWdg()
        div.add(history_div)
        history_div.add_class("spt_chat_history")
        history_div.add_style("width: auto")
        history_div.add_style("height: auto")
        history_div.add_style("max-height: 400px")
        history_div.add_style("padding: 5px")
        history_div.add_class("spt_resizable")

        history_div.add_border()
        history_div.add_style("overflow-y: auto")
        #history_div.add_style("font-size: 0.9em")


        search = Search("sthpw/message_log")
        search.add_filter("message_code", key)
        search.add_order_by("timestamp")
        message_logs = search.get_sobjects()
        last_login = None;
        last_date = None;
        for message_log in message_logs:

            login = message_log.get("login")
            message = message_log.get("message")
            timestamp = message_log.get_datetime_value("timestamp")
            #timestamp = timestamp.strftime("%b %d, %Y - %H:%M")
            timestamp_str = timestamp.strftime("%H:%M")
            date_str = timestamp.strftime("%b %d, %Y")

        

            if login != last_login:

                table = Table()
                history_div.add(table)
                table.add_row()
                table.add_style("width: 100%")
                table.add_style("margin-top: 15px")

                login_sobj = Search.get_by_code("sthpw/login", login)
                thumb_div = DivWdg()
                td = table.add_cell()
                td.add_style("vertical-align: top")
                td.add_style("width: 75px")

                thumb_div = DivWdg()
                td.add(thumb_div)
                thumb_div.add_style("overflow: hidden")

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


                display_name = login_sobj.get("display_name")

                td = table.add_cell()
                td.add_style("padding-top: 3px")
                
                name_div = DivWdg()
                td.add(name_div)
                name_div.add_style("color", "#214e75")
                name_div.add_style("font-size", "1.3em")
                name_div.add(display_name)


            msg = "";
            msg += "<table style='margin-top: 5px; font-size: 1.0em; width: 100%'>";


            if date_str != last_date:
                msg += "<tr><td colspan='2' style='text-align: right'><br/><b style='font-size: 1.0em'>"+date_str+"</b></td></tr>";
                last_login = None

            msg += "<tr><td>"
            msg += message.replace("\n",'<br/>')
            msg += "</td><td style='vertical-align: top; text-align: right; margin-bottom: 5px; width: 75px; vertical-align: top; opacity: 0.7;'>";
            msg += timestamp_str;
            msg += "</td></tr></table>";

            td.add(msg)

            

            last_login = login
            last_date = date_str

        history_div.add_behavior( {
            'type': 'load',
            'cbjs_action': '''
            bvr.src_el.scrollTop = bvr.src_el.scrollHeight;
            '''
        } )


        if message_logs:
            last_message = message_logs[-1].get("message")
            last_login = message_logs[-1].get("login")
        else:
            last_message = ""
            last_login = ""
        div.add_attr("spt_last_message", last_message)
        div.add_attr("spt_last_login", last_login)




        if interval:

            div.add_behavior( {
            'type': 'load',
            'key': key,
            'cbjs_action': r'''
            var text_el = bvr.src_el.getElement(".spt_chat_text");
            var history_el = bvr.src_el.getElement(".spt_chat_history");
            var callback = function(message) {
                //history_el.setStyle("background", "red");
                var login = message.login;
                var timestamp = message.timestamp;
                if (timestamp) {
                    var parts = timestamp.split(" ");
                    parts = parts[1].split(".");
                    timestamp = parts[0];
                }
                else {
                    timestamp = "";
                }

                var tmp = message.message || "";

                var last_message = bvr.src_el.getAttribute("spt_last_message");
                var last_login = bvr.src_el.getAttribute("spt_last_login");
                if (tmp == last_message && login == last_login) {
                    return;
                }
                bvr.src_el.setAttribute("spt_last_message", tmp);
                bvr.src_el.setAttribute("spt_last_login", login);

                var msg = "";
                msg += "<table style='margin-top: 5px; font-size: 1.0em; width: 100%'><tr><td>";
                if (login != last_login) {
                    msg += "<b>"+login+"</b><br/>";
                }
                msg += tmp.replace(/\n/g,'<br/>');
                msg += "</td><td style='text-align: right; margin-bottom: 5px; width: 75px; vertical-align: top'>";
                msg += timestamp;
                msg += "</td></tr></table>";

                if (msg == history_el.last_msg) {
                    return;
                }
                history_el.innerHTML =  history_el.innerHTML + msg;

                // remember last message
                history_el.last_msg = msg;


                history_el.scrollTop = history_el.scrollHeight;
            }
            spt.message.set_interval(bvr.key, callback, 3000, bvr.src_el);
            '''
            } )

        text = TextAreaWdg("chat")
        div.add(text)
        text.add_class("spt_chat_text")
        text.add_style("width: 100%")
        text.add_style("padding: 5px")
        #text.add_style("margin-top: -1px")
        text.add_style("margin-top: 5px")
        
        text.add_behavior( {
        'type': 'load',
        'cbjs_action': '''
        bvr.src_el.addEvent("keydown", function(e) {

        var keys = ['tab','keys(control+enter)', 'enter'];
        var key = e.key;
        var input = bvr.src_el
        if (keys.indexOf(key) > -1) e.stop();

        if (key == 'tab') {
        }
        else if (key == 'enter') {
            if (e.control == false) {
                pass;
            }
            else {
                 // TODO: check if it's multi-line first 
                 //... use ctrl-ENTER for new-line, regular ENTER (RETURN) accepts value
                //var tvals = parse_selected_text(input);
                //input.value = tvals[0] + "\\n" + tvals[1];
                //spt.set_cursor_position( input, tvals[0].length + 1 );
            }
        }
        } )
        '''
        } )



        button = ActionButtonWdg(title="Send")
        div.add(button)
        button.add_style("float: right")
        button.add_style("margin: 5px")
        button.add_behavior( {
        'type': 'click_up',
        'key': key,
        'cbjs_action': '''

        var top = bvr.src_el.getParent(".spt_chat_session_top");
        var text_el = top.getElement(".spt_chat_text");
        var message = text_el.value;
        if (!message) {
            return;
        }

        var history_el = top.getElement(".spt_chat_history");

        var category = "chat";
        var server = TacticServerStub.get();

        var key = bvr.key;
        var last_message = server.log_message(key, message, {category:category, status:"in_progress"});

        text_el.value = "";

            '''
        } )

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


        return div
Example #48
0
    def get_display(my):

        web = WebContainer.get_web()
        show_multi_project = web.get_form_value('show_multi_project')
        project = Project.get()
        search_type_objs = project.get_search_types(include_multi_project=show_multi_project)


        top = my.top
        top.add_class("spt_panel_stype_list_top")
        #top.add_style("min-width: 400px")
        #top.add_style("max-width: 1000px")
        #top.add_style("width: 100%")
        top.center()



        button = SingleButtonWdg(title="Advanced Setup", icon=IconWdg.ADVANCED)
        top.add(button)
        button.add_style("float: right")
        button.add_style("margin-top: -8px")
        button.add_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)
            '''
        } )


        button = SingleButtonWdg(title="Add", tip="Add New Searchable Type (sType)", icon=IconWdg.ADD)
        top.add(button)
        button.add_style("float: left")
        button.add_style("margin-top: -8px")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var class_name = 'tactic.ui.app.SearchTypeCreatorWdg';

            var kwargs = {
            };
            var popup = spt.panel.load_popup("Create New Searchable Type", class_name, kwargs);

            var top = bvr.src_el.getParent(".spt_panel_stype_list_top");
            popup.on_register_cbk = function() {
                spt.panel.refresh(top);
            }

            '''
        } )

        cb = CheckboxWdg('show_multi_project', label=' show multi-project')
        if show_multi_project:
            cb.set_checked()
        cb.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
                var panel = bvr.src_el.getParent('.spt_panel_stype_list_top')
                spt.panel.refresh(panel, {show_multi_project: bvr.src_el.checked});
            '''
            })
        span = SpanWdg(css='small')
        top.add(span)
        top.add(cb)
        top.add("<br clear='all'/>")
        #search_type_objs = []
        if not search_type_objs:
            arrow_div = DivWdg()
            top.add(arrow_div)
            icon = IconWdg("Click to Add", IconWdg.ARROW_UP_LEFT_32)
            icon.add_style("margin-top: -20")
            icon.add_style("margin-left: -15")
            icon.add_style("position: absolute")
            arrow_div.add(icon)
            arrow_div.add("&nbsp;"*5)
            arrow_div.add("<b>Click to Add</b>")
            arrow_div.add_style("position: relative")
            arrow_div.add_style("margin-top: 5px")
            arrow_div.add_style("margin-left: 20px")
            arrow_div.add_style("float: left")
            arrow_div.add_style("padding: 25px")
            arrow_div.set_box_shadow("0px 5px 20px")
            arrow_div.set_round_corners(30)
            arrow_div.add_color("background", "background")

            div = DivWdg()
            top.add(div)
            div.add_border()
            div.add_style("min-height: 180px")
            div.add_style("width: 600px")
            div.add_style("margin: 30px auto")
            div.add_style("padding: 20px")
            div.add_color("background", "background3")
            icon = IconWdg( "WARNING", IconWdg.WARNING )
            div.add(icon)
            div.add("<b>No Searchable Types have been created</b>")
            div.add("<br/><br/>")
            div.add("Searchables Types contain lists of items that are managed in this project.  Each item will automatically have the ability to have files checked into it, track tasks and status and record work hours.")
            div.add("<br/>"*2)
            div.add("For more information, read the help docs: ")
            from tactic.ui.app import HelpButtonWdg
            help = HelpButtonWdg(alias="main")
            div.add(help)
            div.add("<br/>")
            div.add("Click on the 'Add' button above to start adding new types.")
            return top


        div = DivWdg()
        top.add(div)
        #div.add_style("max-height: 300px")
        #div.add_style("overflow-y: auto")



        table = Table()
        div.add(table)
        table.add_style("margin-top: 10px")
        table.set_max_width()



        # group mouse over
        table.add_relay_behavior( {
            'type': "mouseover",
            'bvr_match_class': 'spt_row',
            'cbjs_action': "spt.mouse.table_layout_hover_over({}, {src_el: bvr.src_el, add_color_modifier: -2})"
        } )
        table.add_relay_behavior( {
            'type': "mouseout",
            'bvr_match_class': 'spt_row',
            'cbjs_action': "spt.mouse.table_layout_hover_out({}, {src_el: bvr.src_el})"
        } )



        tr = table.add_row()
        tr.add_color("color", "color")
        tr.add_gradient("background", "background", -10)
        th = table.add_header("")
        th.add_style("text-align: left")
        th = table.add_header("Title")
        th.add_style("text-align: left")
        th = table.add_header("# Items")
        th.add_style("text-align: left")
        th = table.add_header("View")
        th.add_style("text-align: left")
        th = table.add_header("Add")
        th.add_style("text-align: left")
        th = table.add_header("Import")
        th.add_style("text-align: left")
        th = table.add_header("Custom Columns")
        th.add_style("text-align: left")
        th = table.add_header("Workflow")
        th.add_style("text-align: left")
        th = table.add_header("Notifications")
        th.add_style("text-align: left")
        th = table.add_header("Triggers")
        th.add_style("text-align: left")
        th = table.add_header("Edit")
        th.add_style("text-align: left")
        #th = table.add_header("Security")
        #th.add_style("text-align: left")



        for i, search_type_obj in enumerate(search_type_objs):
            tr = table.add_row()
            tr.add_class("spt_row")

            if not i or not i%2:
                tr.add_color("background", "background3")
            else:
                tr.add_color("background", "background", -2 )


            thumb = ThumbWdg()
            thumb.set_sobject(search_type_obj)
            thumb.set_icon_size(30)
            td = table.add_cell(thumb)



            search_type = search_type_obj.get_value("search_type")
            title = search_type_obj.get_title()

            table.add_cell(title)

            try:
                search = Search(search_type)
                count = search.get_count()
                if count:
                    table.add_cell("%s item/s" % count)
                else:
                    table.add_cell("&nbsp;")
            except:
                td = table.add_cell("&lt; No table &gt;")
                td.add_style("font-style: italic")
                td.add_style("color: #F00")
                continue



            #search = Search(search_type)
            #search.add_interval_filter("timestamp", "today")
            #created_today = search.get_count()
            #table.add_cell(created_today)



            td = table.add_cell()
            button = IconButtonWdg(title="View", icon=IconWdg.ZOOM)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': title,
                'cbjs_action': '''

                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'table',
                    'simple_search_view': 'simple_search'
                };

                // use tab
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
                //spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            } )
            button.add_style("float: left")


            arrow_button = IconButtonWdg(tip="More Views", icon=IconWdg.ARROWHEAD_DARK_DOWN)
            arrow_button.add_style("margin-left: 20px")
            td.add(arrow_button)

            cbk = '''
            var activator = spt.smenu.get_activator(bvr);

            var class_name = bvr.class_name;
            var layout = bvr.layout;

            var kwargs = {
                search_type: bvr.search_type,
                layout: layout,
                view: bvr.view,
                simple_search_view: 'simple_search',
                element_names: bvr.element_names,
            };

            // use tab
            var top = activator.getParent(".spt_dashboard_top");
            spt.tab.set_tab_top(top);
            spt.tab.add_new('%s', '%s', class_name, kwargs);
            ''' % (title, title)


            from tactic.ui.panel import SwitchLayoutMenu
            SwitchLayoutMenu(search_type=search_type, activator=arrow_button, cbk=cbk, is_refresh=False)

            td = table.add_cell()
            button = IconButtonWdg(title="Add", icon=IconWdg.ADD)
            td.add(button)
            button.add_behavior( {
                'type': 'listen',
                'search_type': search_type,
                'event_name': 'startup_save:' + search_type_obj.get_title(),
                'title': search_type_obj.get_title(),
                'cbjs_action': '''
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'table',
                    'simple_search_view': 'simple_search'
                };

                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
 

                '''
            } )
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': search_type_obj.get_title(),
                'cbjs_action': '''

                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);

                var class_name = 'tactic.ui.panel.EditWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: "insert",
                    save_event: "startup_save:" + bvr.title
                }
                spt.panel.load_popup("Add New Items ("+bvr.title+")", class_name, kwargs);

                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'table',
                    'simple_search_view': 'simple_search'
                };

                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
                '''
            } )


            """
            td = table.add_cell()
            button = IconButtonWdg(title="Check-in", icon=IconWdg.PUBLISH)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': title,
                'cbjs_action': '''

                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'checkin',
                    element_names: ['preview','code','name','description','history','general_checkin','notes']
                };

                // use tab
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
                //spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            } )
            """





            td = table.add_cell()
            button = IconButtonWdg(title="Import", icon=IconWdg.IMPORT)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': "Import Data",
                'cbjs_action': '''

                var class_name = 'tactic.ui.widget.CsvImportWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                };

                spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            } )



            td = table.add_cell()
            button = IconButtonWdg(title="Custom Columns", icon=IconWdg.COLUMNS)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': "Add Custom Columns",
                'cbjs_action': '''
                var class_name = 'tactic.ui.startup.ColumnEditWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            } )





            td = table.add_cell()
            button = IconButtonWdg(title="Workflow", icon=IconWdg.PIPELINE)
            button.add_style("float: left")
            td.add(button)

            search = Search("sthpw/pipeline")
            search.add_filter("search_type", search_type)
            count = search.get_count()
            if count:
                check = IconWdg( "Has Items", IconWdg.CHECK, width=8 )
                td.add(check)
                #check.add_style("margin-left: 0px")
                check.add_style("margin-top: 4px")




            button.add_behavior( {
                'type': 'click_up',
                'title': 'Workflow',
                'search_type': search_type,
                'cbjs_action': '''
                var class_name = 'tactic.ui.startup.PipelineEditWdg';
                var kwargs = {
                    search_type: bvr.search_type
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);
                '''
            } )
 


            td = table.add_cell()
            button = IconButtonWdg(title="Notifications", icon=IconWdg.MAIL)
            button.add_style("float: left")
            td.add(button)

            search = Search("sthpw/notification")
            search.add_filter("search_type", search_type)
            count = search.get_count()
            if count:
                check = IconWdg( "Has Items", IconWdg.CHECK, width=8 )
                td.add(check)
                #check.add_style("margin-left: 0px")
                check.add_style("margin-top: 4px")






            button.add_behavior( {
                'type': 'click_up',
                'title': 'Trigger',
                'search_type': search_type,
                'cbjs_action': '''

                var class_name = 'tactic.ui.tools.TriggerToolWdg';
                var kwargs = {
                    mode: "search_type",
                    search_type: bvr.search_type
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);
                '''
            } )


            td = table.add_cell()
            button = IconButtonWdg(title="Triggers", icon=IconWdg.ARROW_OUT)
            td.add(button)
            button.add_style("float: left")

            search = Search("config/trigger")
            search.add_filter("search_type", search_type)
            count = search.get_count()
            if count:
                check = IconWdg( "Has Items", IconWdg.CHECK, width=8 )
                td.add(check)
                #check.add_style("margin-left: 0px")
                check.add_style("margin-top: 4px")


            button.add_behavior( {
                'type': 'click_up',
                'title': 'Trigger',
                'search_type': search_type,
                'cbjs_action': '''

                var class_name = 'tactic.ui.tools.TriggerToolWdg';
                var kwargs = {
                    mode: "search_type",
                    search_type: bvr.search_type
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);
                '''
            } )





            td = table.add_cell()
            button = IconButtonWdg(title="Edit Searchable Type", icon=IconWdg.EDIT)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_key': search_type_obj.get_search_key(),
                'cbjs_action': '''

                var class_name = 'tactic.ui.panel.EditWdg';
                var kwargs = {
                    search_type: "sthpw/sobject",
                    view: "edit_startup",
                    search_key: bvr.search_key
                }
                spt.panel.load_popup("Edit Searchable Type", class_name, kwargs);


                '''
            } )


 
            """
            td = table.add_cell()
            button = IconButtonWdg(title="Security", icon=IconWdg.LOCK)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'title': 'Trigger',
                'search_type': search_type,
                'cbjs_action': '''
                alert("security");
                '''
            } )
            """


        columns_wdg = DivWdg()
        top.add(columns_wdg)


        return top
Example #49
0
    def get_display(my):
        my.init_kwargs()
        sobject = my.get_current_sobject()

        table = Table(css='minimal')
        table.add_color("color", "color")
        table.add_style("font-size: 0.9em")

       
        
        snapshots = my.get_snapshot(my.mode)
        for snapshot in snapshots:
            table.add_row()

            value = my.get_input_value(sobject, snapshot)

            current_version = snapshot.get_value("version")
            current_context = snapshot.get_value("context")
            current_revision = snapshot.get_value("revision", no_exception=True)
            current_snapshot_type = snapshot.get_value("snapshot_type")

            # hack hard coded type translation
            if current_snapshot_type == "anim_export":
                current_snapshot_type = "anim"

            # ignore icon context completely
            if current_context == "icon":
                table.add_blank_cell()
                table.add_cell("(---)")
                return table

            checkbox = CheckboxWdg('%s_%s' %(my.search_type, my.CB_NAME))
            
            # this is added back in for now to work with 3.7 Fast table
            checkbox.add_behavior({'type': 'click_up',
            'propagate_evt': True})

            checkbox.add_class('spt_latest_%s' %my.mode)
            checkbox.set_option("value", value )
            table.add_cell( checkbox )

            load_all = False
            if load_all:
                checkbox.set_checked()


            # add the file type icon
            xml = snapshot.get_snapshot_xml()
            file_name = xml.get_value("snapshot/file/@name")
            icon_link = ThumbWdg.find_icon_link(file_name)
            image = HtmlElement.img(icon_link)
            image.add_style("width: 15px")
            table.add_cell(image)

            namespace = my.get_namespace(sobject, snapshot) 
            asset_code = my.get_asset_code()
          
            # force asset mode = True   
            my.session.set_asset_mode(asset_mode=my.get_session_asset_mode())
            node_name = my.get_node_name(snapshot, asset_code, namespace)
            # get session info
            session_context = session_version = session_revision = None
            if my.session:
                
                session_context = my.session.get_context(node_name, asset_code, current_snapshot_type)
                session_version = my.session.get_version(node_name, asset_code, current_snapshot_type)
                session_revision = my.session.get_revision(node_name, asset_code,current_snapshot_type)


                # Maya Specific: try with namespace in front of it for referencing
                referenced_name = '%s:%s' %(namespace, node_name)
                if not session_context or not session_version:
                    session_context = my.session.get_context(referenced_name, asset_code, current_snapshot_type)
                    session_version = my.session.get_version(referenced_name, asset_code, current_snapshot_type)
                    session_revision = my.session.get_revision(referenced_name, asset_code, current_snapshot_type)

            from version_wdg import CurrentVersionContextWdg, SubRefWdg

            version_wdg = CurrentVersionContextWdg()
            data = {'session_version': session_version, \
                'session_context': session_context,  \
                'session_revision': session_revision,  \
                'current_context': current_context, \
                'current_version': current_version, \
                'current_revision': current_revision }
            version_wdg.set_options(data)
            
            table.add_cell(version_wdg, "no_wrap")
            td = table.add_cell(HtmlElement.b("(%s)" %current_context))
            td.add_tip("Snapshot code: %s" % snapshot.get_code())
            #table.add_cell(snapshot.get_code() )

            #if snapshot.is_current():
            #    current = IconWdg("current", IconWdg.CURRENT)
            #    table.add_cell(current)
            #else:
            #    table.add_blank_cell()


            # handle subreferences
            has_subreferences = True
            xml = snapshot.get_xml_value("snapshot")
            refs = xml.get_nodes("snapshot/file/ref")
            if my.mode == "output" and refs:
                table.add_row()
                td = table.add_cell()
                swap = SwapDisplayWdg.get_triangle_wdg()
                td.add(swap)
                td.add("[ %s reference(s)" % len(refs))
                #td.add_style("text-align: right")

                sub_ref_wdg = SubRefWdg()
                sub_ref_wdg.set_info(snapshot, my.session, namespace)
                swap.add_action_script( sub_ref_wdg.get_on_script(), "toggle_display('%s')" % sub_ref_wdg.get_top_id() )

                status = sub_ref_wdg.get_overall_status()
                td.add(SpanWdg(VersionWdg.get(status), css='small_left'))
                td.add(']')
             
                td.add( sub_ref_wdg )
                td.add_style('padding-left: 10px')



        #else:
        if not snapshots:
            table.add_row()
            table.add_blank_cell()
            table.add_cell("(---)")

        return table
Example #50
0
 def preprocess(self):
     self.thumb = ThumbWdg()
     self.thumb.set_icon_size('60')
     self.thumb.set_sobjects(self.sobjects)
     self.thumb.preprocess()
Example #51
0
    def get_display(my):

        my.search_key = my.kwargs.get("search_key")
        sobject = Search.get_by_search_key(my.search_key)

        if sobject.get_base_search_type() == "sthpw/snapshot":
            snapshot = sobject
        elif sobject.get_base_search_type() == "sthpw/file":
            # if it is a file object
            snapshot = sobject.get_parent()
        else:
            snapshots = Snapshot.get_by_sobject(sobject)
            snapshot = snapshots[0]

        #parent = snapshot.get_parent()

        top = my.top

        from tactic.ui.container import ResizableTableWdg
        table = ResizableTableWdg()
        top.add(table)
        table.add_row()
        table.add_style("width: 100%")


        from tactic.ui.widget import EmbedWdg
        td = table.add_cell()
        td.add_color("background", "background",)
        td.add_style("vertical-align: middle")
        td.add_style("height: 200px")
        td.add_style("overflow-x: auto")


        file_type = "icon"
        thumb_path = snapshot.get_web_path_by_type(file_type)

        file_type = "main"
        src = snapshot.get_web_path_by_type(file_type)


        parts = os.path.splitext(src)
        ext = parts[1]
        ext = ext.lower()

        if ext in ['.doc','.xls']:
            from pyasm.widget import ThumbWdg
            link = ThumbWdg.find_icon_link(src)
            img = HtmlElement.img(src=link)
            href = DivWdg()
            href.add_style("text-align: center")
            href.add(img)
            td.add(href)
            href.add_behavior( {
                'type': 'click_up',
                'src': src,
                'cbjs_action': '''
                window.open(bvr.src);
                '''
            } )
            href.add_class("hand")

        else:
            embed_wdg = EmbedWdg(src=src, thumb_path=thumb_path)
            td.add(embed_wdg)
            embed_wdg.add_style("margin: auto auto")
            embed_wdg.add_class("spt_resizable")
            embed_wdg.add_style("width: 100%")
            embed_wdg.add_style("height: 240px")

            embed_wdg.add_behavior( {
                'type': 'load',
                'cbjs_action': '''
                var last_height = spt.container.get_value("last_img_height");
                if (last_height) {
                    bvr.src_el.setStyle("height", last_height);
                }
                '''
            } )


            embed_wdg.add_behavior( {
                'type': 'unload',
                'cbjs_action': '''
                var last_height = bvr.src_el.getStyle("height");
                spt.container.set_value("last_img_height", last_height);
                '''
            } )



        table.add_row()
        td = table.add_cell()


        from tactic.ui.checkin import PathMetadataWdg
        from tactic.ui.checkin import SnapshotMetadataWdg


        metadata_div = DivWdg()
        td.add(metadata_div)
        metadata_div.add_style("max-height: 400px")
        metadata_div.add_style("overflow-y: auto")
        metadata_div.add_style("overflow-x: hidden")

        parser = my.kwargs.get("parser")
        use_tactic_tags = my.kwargs.get("use_tactic_tags")

        file_type = "main"
        server_src = snapshot.get_lib_path_by_type(file_type)

        # get it dynamically by path
        metadata_wdg = PathMetadataWdg(path=server_src, parser=parser, use_tactic_tags=use_tactic_tags)
        metadata_div.add(metadata_wdg)

        #else:
        #    metadata_wdg = SnapshotMetadataWdg(snapshot=snapshot)
        #    metadata_div.add(metadata_wdg)


        top.add("<br/>")

        return top
Example #52
0
    def get_display(my):
        div = DivWdg()

        search_type = "prod/asset"

        search_type_obj = SearchType.get(search_type)
        title = search_type_obj.get_title()
        title_wdg = DivWdg()
        title_wdg.add_style("font-size: 1.8em")
        title_wdg.add("%s" % (title) )

        div.add(title_wdg)
        div.add(HtmlElement.hr())


        table = Table()
        div.add(table)
        table.set_max_width()

        table.add_row()

        from pyasm.widget import ThumbWdg, DiscussionWdg, SObjectTaskTableElement

        td = table.add_cell()
        td.add_style("width: 250px")
        td.add_style("vertical-align: top")
        td.add_style("border-right: solid 1px")
        title = DivWdg()
        title.add_class("maq_search_bar")
        x = DivWdg("[?] [x]")
        x.add_style("float: right")
        title.add(x)
        title.add("Info")
        td.add(title)
        thumb = ThumbWdg()
        thumb.set_sobject(sobject)
        td.add(thumb)
        from pyasm.prod.web import AssetInfoWdg
        info = AssetInfoWdg()
        info.thumb = thumb
        info.set_sobject(sobject)
        td.add(info)

        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding-left: 5px")
        td.add_style("border-right: solid 1px")
       
        # notes
        title = DivWdg()
        title.add_class("maq_search_bar")
        x = DivWdg("[x]")
        x.add_style("float: right")
        title.add(x)
        title.add("Notes")
        td.add(title)
        discussion_wdg = DiscussionWdg()
        discussion_wdg.preprocess()
        discussion_wdg.set_sobject(sobject)
        td.add(discussion_wdg)

        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding-left: 5px")
        td.add_style("border-right: solid 1px")
 

        # tasks
        title = DivWdg()
        title.add_class("maq_search_bar")
        x = DivWdg("[x]")
        x.add_style("float: right")
        title.add(x)
        title.add("Custom Properties")
        td.add(title)
        search = Search("prod/custom_property")
        search.add_filter("search_type", "sample3d/book")
        sobjects = search.get_sobjects()
        table = TableLayoutWdg(search_type="prod/custom_property", view='table')
        table.set_sobjects(sobjects)
        td.add(table)

        div.add(HtmlElement.hr())
        div.add(HtmlElement.br(clear="all"))





        title_wdg = DivWdg()
        title_wdg.add_class("maq_search_bar")
        x = DivWdg("[x]")
        x.add_style("float: right")
        title_wdg.add(x)
        #title_wdg.add_style("font-size: 1.5em")
        title_wdg.add("Detail" )
        div.add(title_wdg)
        div.add(HtmlElement.br())



        # TEST getting schema
        search_type = sobject.get_base_search_type()
        schema = Schema.get_by_sobject(sobject)

        



        # add a second table
        table = Table()
        table.set_max_width()


        # show the snapshots for this sobject
        search_type = "sthpw/snapshot"
        search = Search(search_type)
        search.add_sobject_filter(sobject)
        search.set_limit(50)
        sobjects = search.get_sobjects()


        table.add_row()
        nav_td = table.add_cell()
        nav_td.add_style("width: 100px")
        nav_td.add_style("vertical-align: top")
        #section_wdg = my.get_section_wdg(sobject)
        #nav_td.add( section_wdg )

        #from tactic.ui.panel import ManageViewPanelWdg
        #defined = ManageViewPanelWdg()
        from tactic.ui.panel import ManageViewWdg
        defined = ManageViewWdg()
        nav_td.add(defined)

        #content_wdg = TableLayoutWdg(search_type=search_type, view='table')
        #content_wdg.set_sobjects(sobjects)
        #content_td = table.add_cell()
        #content_td.set_id("sobject_relation")
        #content_td.add_style("display: table-cell")
        #content_td.add_style("vertical-align: top")
        #content_td.add(content_wdg)

        div.add(table)

        return div
Example #53
0
    def handle_instance(my, table, instance, asset, node_name='', publish=True, allow_ref_checkin=False):

        # handle the case where asset is not defined
        if not asset:
            table.add_row()
            table.add_blank_cell()
            table.add_blank_cell()

            # FIXME: Maya specific
            parts = instance.split(":")
            instance_name = parts[0]
            asset_code = parts[1]

            
            if instance_name == asset_code:
                table.add_cell(instance_name)
            else:
                table.add_cell(instance)
            td = table.add_cell()
            td.add("< %s node >" % my.session.get_node_type(instance_name))
            table.add_blank_cell()
            return 

        # get the pipeline for this asset and handlers for the pipeline
        process_name = my.process_select.get_value() 
        handler_hidden = my.get_handler_input(asset, process_name)
        pipeline = Pipeline.get_by_sobject(asset) 
        



        # TEST: switch this to using node name instead, if provided
        if node_name:
            instance_node = my.session.get_node(node_name)
        else:
            instance_node = my.session.get_node(instance)

        if instance_node is None:
            return
        if Xml.get_attribute(instance_node,"reference") == "true":
            is_ref = True
        else:
            is_ref = False

        namespace = Xml.get_attribute(instance_node, "namespace")
        if not namespace:
            namespace = instance

        asset_code = asset.get_code()
        is_set = False
        if asset.get_value('asset_type', no_exception=True) in ['set','section']:
            is_set = True
            
        tr = table.add_row()
        
        if is_set:
            tr.add_class("group")

        if publish and (allow_ref_checkin or not is_ref):
            checkbox = CheckboxWdg("asset_instances")
            if is_set:
                checkbox = CheckboxWdg("set_instances")
               
            checkbox.set_option("value", "%s|%s|%s" % \
                        (namespace, asset_code, instance) )
            checkbox.set_persist_on_submit()

            td = table.add_cell(checkbox)
            
        else:
            td = table.add_blank_cell()

        # only one will be added even if there are multiple
        if handler_hidden:
            td.add(handler_hidden)

        # add the thumbnail
        thumb = ThumbWdg()
        thumb.set_name("images")
        thumb.set_sobject(asset)
        thumb.set_icon_size(60)
        table.add_cell(thumb)


        info_wdg = Widget()
        info_wdg.add(HtmlElement.b(instance))

        if not node_name:
            node_name = '%s - %s' %(asset_code, asset.get_name()) 
        info_div = DivWdg(node_name)
        info_div.add_style('font-size: 0.8em')
        info_wdg.add(info_div)
        info_div.add(HtmlElement.br(2))
        if pipeline:
            info_div.add(pipeline.get_code())
        table.add_cell(info_wdg)

        #  by default can't checkin references
        if not allow_ref_checkin and is_ref:
            #icon = IconWdg("error", IconWdg.ERROR)
            #td = table.add_cell(icon)
            td = table.add_cell()
            td.add(HtmlElement.b("Ref. instance"))
            '''
            import_button = ProdIconButtonWdg('import')
            import_button.add_event('onclick', "import_instance('%s')"  %instance)
            td.add(import_button)
            '''
            table.add_cell(my.get_save_wdg(my.current_sobject) )

        elif publish:
            textarea = TextAreaWdg()
            textarea.set_persist_on_submit()
            textarea.set_name("%s_description" % instance)
            textarea.set_attr("cols", "35")
            textarea.set_attr("rows", "2")
            table.add_cell(textarea)
            table.add_cell(my.get_save_wdg(my.current_sobject) )
        else:
            table.add_blank_cell()
            table.add_blank_cell()
Example #54
0
    def get_group_wdg(self, prev_sobj):
        if not self.is_preprocessed:
            self.preprocess()

        sobject = self.get_current_sobject()
        ref_sobj = self.get_ref_obj(sobject)
        self.current_ref_sobj = ref_sobj

        if not ref_sobj:
            return "Undetermined parent: [%s]" % SearchKey.get_by_sobject(
                sobject)

        widget = DivWdg()

        # add add button
        #from tactic.ui.widget import TextBtnWdg, TextBtnSetWdg
        #buttons_list = []
        #buttons_list.append( {
        #    'label': '+', 'tip': 'Add Another Item',
        #    'bvr': { 'cbjs_action': "spt.dg_table.add_item_cbk(evt, bvr)" }
        #} )
        #add_btn = TextBtnSetWdg( float="right", buttons=buttons_list,
        #                     spacing=6, size='small', side_padding=0 )
        #widget.add(add_btn)

        from tactic.ui.widget import ActionButtonWdg
        button = ActionButtonWdg(title='+',
                                 tip='Add Another Item',
                                 size='small')
        widget.add(button)
        button.add_style("float: right")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            "spt.dg_table.add_item_cbk(evt, bvr)"
        })

        label = "Attach"
        label_option = self.get_option("label")
        if label_option:
            label = label_option

        table = Table()
        table.add_color("color", "color")
        table.add_row()

        search_key = sobject.get_search_key()
        # add a thumbe widget
        thumb = ThumbWdg()
        thumb.set_icon_size(40)
        thumb.set_sobject(ref_sobj)
        thumb.set_option('latest_icon', 'true')
        table.add_cell(thumb)

        # add the text description
        name_span = DivWdg(ref_sobj.get_code())
        name_span.add_style('margin-left: 20px')
        table.add_cell(name_span)

        if ref_sobj.has_value("name"):
            name_span.add(" - ")
            name_span.add(ref_sobj.get_value("name"))

        #status = ref_sobj.get_value("status", no_exception=True)
        #if status:
        #    span = SpanWdg("(status:%s)" % ref_sobj.get_value("status"))
        #    table.add_cell(span)

        if ref_sobj.has_value("description"):
            description_wdg = ExpandableTextWdg("description")
            description_wdg.set_max_length(200)
            description_wdg.set_sobject(ref_sobj)
            td = table.add_cell(description_wdg)
            td.add_style("padding-left: 15px")

        # FIXME: not sure about the layout here
        #if ref_sobj.has_value("pipeline_code"):
        #    pipeline_code = ref_sobj.get_value("pipeline_code")
        #    span = SpanWdg("(pipeline:%s)" % pipeline_code )
        #    td = table.add_cell(span)
        #    td.add_style("padding-left: 15px")

        widget.add(table)

        return widget
Example #55
0
    def get_group_wdg(self, prev_sobj):
        if not self.is_preprocessed:
            self.preprocess()

        sobject = self.get_current_sobject()
        ref_sobj = self.get_ref_obj(sobject)
        self.current_ref_sobj = ref_sobj
        
        if not ref_sobj:
            return "Undetermined parent: [%s]" % SearchKey.get_by_sobject(sobject)

        widget = DivWdg()

        # add add button
        #from tactic.ui.widget import TextBtnWdg, TextBtnSetWdg
        #buttons_list = []
        #buttons_list.append( {
        #    'label': '+', 'tip': 'Add Another Item',
        #    'bvr': { 'cbjs_action': "spt.dg_table.add_item_cbk(evt, bvr)" }
        #} )
        #add_btn = TextBtnSetWdg( float="right", buttons=buttons_list,
        #                     spacing=6, size='small', side_padding=0 )
        #widget.add(add_btn)

        from tactic.ui.widget import ActionButtonWdg
        button = ActionButtonWdg(title='+', tip='Add Another Item', size='small')
        widget.add(button)
        button.add_style("float: right")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': "spt.dg_table.add_item_cbk(evt, bvr)"
        } )

 
        label = "Attach"
        label_option = self.get_option("label")
        if label_option:
            label = label_option 
       
        table = Table()
        table.add_color("color", "color")
        table.add_row()

        search_key = sobject.get_search_key()
        # add a thumbe widget
        thumb = ThumbWdg()
        thumb.set_icon_size(40)
        thumb.set_sobject(ref_sobj)
        thumb.set_option('latest_icon', 'true') 
        table.add_cell(thumb)


        # add the text description
        name_span = DivWdg(ref_sobj.get_code())
        name_span.add_style('margin-left: 20px')
        table.add_cell(name_span)


        if ref_sobj.has_value("name"):
            name_span.add( " - " )
            name_span.add( ref_sobj.get_value("name") )

        #status = ref_sobj.get_value("status", no_exception=True)
        #if status:
        #    span = SpanWdg("(status:%s)" % ref_sobj.get_value("status"))
        #    table.add_cell(span)

        
        if ref_sobj.has_value("description"):
            description_wdg = ExpandableTextWdg("description")
            description_wdg.set_max_length(200)
            description_wdg.set_sobject(ref_sobj)
            td = table.add_cell( description_wdg )
            td.add_style("padding-left: 15px")



        # FIXME: not sure about the layout here
        #if ref_sobj.has_value("pipeline_code"):
        #    pipeline_code = ref_sobj.get_value("pipeline_code")
        #    span = SpanWdg("(pipeline:%s)" % pipeline_code )
        #    td = table.add_cell(span)
        #    td.add_style("padding-left: 15px")
        
        widget.add(table)
            

        return widget
Example #56
0
class ShotInfoWdg(AssetInfoWdg):
    '''widget to display the code, name and description in one column'''
    def preprocess(self):
        self.thumb = ThumbWdg()
        self.thumb.set_icon_size('60')
        self.thumb.set_sobjects(self.sobjects)
        self.thumb.preprocess()

    def get_display(self):
        if not self.thumb:
            self.preprocess()

        self.sobject = self.get_current_sobject()

        table = Table(css='embed')
        table.add_color('color', 'color')
        table.add_style("width: 300px")
        table.add_row()

        th = table.add_header(
            "<i>Code: </i> <b style='font-size: 1.2em'>%s</b>" %
            self.sobject.get_code())
        # add status
        th.add_style('text-align', 'left')
        status_span = SpanWdg("", css='large')
        th.add(status_span)

        status = self.sobject.get_value("status")
        if status:
            status_span.add(self.sobject.get_value("status"))

        table.add_row()

        self.thumb.set_current_index(self.get_current_index())
        thumb_td = table.add_cell(self.thumb)
        row_span = 2

        if self.sobject.has_value("priority"):
            row_span = 3
            # add priority
            table.add_cell("<i>Priority: </i>")
            priority = self.sobject.get_value("priority")
            if not priority:
                table.add_cell("None")
            else:
                table.add_cell(self.sobject.get_value("priority"))
            # this row should be added only if priority is added
            table.add_row()

        thumb_td.set_attr('rowspan', row_span)

        # add pipeline
        table.add_cell("<i>Pipeline: </i>")
        status = self.sobject.get_value("pipeline_code")
        if not status:
            table.add_cell("None")
        else:
            table.add_cell(self.sobject.get_value("pipeline_code"))

        self._add_frame_range(table)

        table.add_row()
        td = table.add_cell("<i>Description: </i>")
        description = self.sobject.get_value("description")
        expand = ExpandableTextWdg()
        expand.set_id('asset_info_desc')
        expand.set_value(WikiUtil().convert(description))
        expand.set_max_length(300)
        td.add(expand)

        main_div = DivWdg(table)

        if self.get_option("publish") == "false":
            return main_div

        #self._add_publish_link(main_div)

        return main_div

    def get_simple_display(self):
        sobject = self.get_current_sobject()
        code = sobject.get_code()
        description = sobject.get_value("description")
        status = sobject.get_value("status")
        return "%s, %s, %s" % (code, status, description)

    def _add_frame_range(self, table):

        frame_wdg = FrameRangeWdg()
        frame_wdg.set_sobject(self.sobject)
        table.add_row()
        table.add_cell("<i>Frame Info:</i>")
        table.add_cell(frame_wdg)

    def _add_publish_link(self, main_div):
        publish_link = PublishLinkWdg(self.sobject.get_search_type(),
                                      self.sobject.get_id())
        div = DivWdg(publish_link)
        div.add_style('padding-top', '5px')
        main_div.add(div)

        # build an iframe to show publish browsing
        search_type = self.sobject.get_search_type()
        search_id = self.sobject.get_id()
        from pyasm.widget import IconButtonWdg, IconWdg
        browse_link = IconButtonWdg("Publish Browser", IconWdg.CONTENTS)
        iframe = WebContainer.get_iframe()
        iframe.set_width(100)

        url = WebContainer.get_web().get_widget_url()
        url.set_option("widget", "pyasm.prod.web.PublishBrowserWdg")
        url.set_option("search_type", search_type)
        url.set_option("search_id", search_id)
        script = iframe.get_on_script(url.to_string())
        browse_link.add_event("onclick", script)

        div.add(browse_link)
        div.set_style('padding-top: 6px')
Example #57
0
    def get_display(my):

        my.sobject = my.get_sobject()

        top = DivWdg()
        top.add_class("spt_detail_top")
        top.add_color("background", "background")
        top.add_color("color", "color")

        if not my.sobject:
            top.add("No SObject defined for this widget")
            return top

        if my.parent:
            my.search_type = my.parent.get_base_search_type()
            my.search_key = SearchKey.get_by_sobject(my.parent)
            top.add_attr("spt_parent_key", my.search_key)
            my.pipeline_code = my.parent.get_value("pipeline_code",
                                                   no_exception=True)
            my.full_search_type = my.parent.get_search_type()
        else:
            my.pipeline_code = my.sobject.get_value("pipeline_code",
                                                    no_exception=True)
            my.search_type = my.sobject.get_base_search_type()
            my.search_key = SearchKey.get_by_sobject(my.sobject)
            my.full_search_type = my.sobject.get_search_type()

        if not my.pipeline_code:
            my.pipeline_code = 'default'

        top.add_style("text-align: left")
        my.set_as_panel(top)

        table = Table()
        #from tactic.ui.container import ResizableTableWdg
        #table = ResizableTableWdg()
        table.add_color("background", "background")
        table.add_color("color", "color")
        top.add(table)
        table.set_max_width()

        table.add_row()

        # left
        #td = table.add_cell(resize=False)
        td = table.add_cell()
        #td.add_style("padding: 10px")
        td.add_style("width: 200px")
        td.add_style("min-width: 200px")
        td.add_style("vertical-align: top")
        #td.add_border()
        #td.add_style("border-style: solid")
        #td.add_style("border-width: 1px 0 1px 1px")
        #td.add_color("border-color", "border")
        #td.add_color("background", "background", -10)

        if my.parent:
            code = my.parent.get_code()
        else:
            code = my.sobject.get_code()

        # add the tile
        title = DivWdg()
        td.add(title)
        title.add_gradient("background", "background3", 0, -10)
        title.add_style("height: 20px")
        title.add_style("padding: 4px")
        title.add_style("font-weight: bold")
        title.add_style("font-size: 1.4em")
        title.add("%s" % code)
        title.add_border()

        div = DivWdg()
        td.add(div)
        div.add_class("spt_sobject_detail_top")

        thumb_table = Table()
        div.add(thumb_table)
        thumb_table.add_row()

        thumb = ThumbWdg()
        # use a larger version for clearer display
        thumb.set_icon_type('web')

        # prefer to see the original image, then web
        thumb.set_option('image_link_order', 'main|web|icon')
        thumb.set_option("detail", "false")
        thumb.set_option("icon_size", "100%")

        td = thumb_table.add_cell(thumb)
        td.add_style("vertical-align: top")
        td.add_style("width: 240px")
        td.add_style("padding: 15px")

        if my.parent:
            thumb.set_sobject(my.parent)
        else:
            thumb.set_sobject(my.sobject)

        sobject_info_wdg = my.get_sobject_info_wdg()
        sobject_info_wdg.add_style("width: 200px")

        td.add(sobject_info_wdg)

        if my.search_type == 'sthpw/task' and not my.parent:
            pass
        else:
            sobject_info_wdg = my.get_sobject_detail_wdg()
            td = table.add_cell()
            td.add(sobject_info_wdg)
            td.add_style("vertical-align: top")
            td.add_style("overflow: hidden")

        # right
        td = table.add_cell()
        td.add_style("text-align: left")
        td.add_style("vertical-align: top")
        #td.add_color("background", "background", -10)
        td.add_class("spt_notes_wrapper")
        #td.add_border()

        # add the title
        title = DivWdg()
        td.add(title)
        title.add_gradient("background", "background3", 0, -10)
        title.add_style("height: 20px")
        title.add_style("padding: 4px")
        title.add_style("font-weight: bold")
        title.add("Notes")
        title.add_border()

        notes_div = DivWdg()
        td.add(notes_div)
        from tactic.ui.widget.discussion_wdg import DiscussionWdg
        discussion_wdg = DiscussionWdg(search_key=my.search_key,
                                       context_hidden=False,
                                       show_note_expand=False)
        notes_div.add(discussion_wdg)
        notes_div.add_style("min-width: 300px")
        notes_div.add_style("height: 200")
        notes_div.add_style("overflow-y: auto")
        notes_div.add_class("spt_resizable")

        # get the process
        if my.parent:
            process = my.sobject.get_value("process")
        else:
            process = ''

        # content
        tr = table.add_row()
        td = table.add_cell()
        td.add_attr("colspan", "5")
        #td.add_attr("colspan", "3")

        # create a state for tab.  The tab only passes a search key
        # parent key
        search_key = SearchKey.get_by_sobject(my.sobject)
        parent = my.sobject.get_parent()
        if parent:
            parent_key = parent.get_search_key()
        else:
            parent_key = ""

        state = {
            'search_key': search_key,
            'parent_key': parent_key,
            'process': process,
        }
        WebState.get().push(state)

        config_xml = my.get_config_xml()
        config = WidgetConfig.get(view="tab", xml=config_xml)

        if process:
            custom_view = "tab_config_%s" % process
        else:
            custom_view = "tab_config"
        search = Search("config/widget_config")
        search.add_filter("category", "TabWdg")
        search.add_filter("search_type", my.search_type)
        search.add_filter("view", custom_view)
        custom_config_sobj = search.get_sobject()
        if custom_config_sobj:
            custom_config_xml = custom_config_sobj.get_value("config")
            custom_config = WidgetConfig.get(view=custom_view,
                                             xml=custom_config_xml)
            config = WidgetConfigView(search_type='TabWdg',
                                      view=custom_view,
                                      configs=[custom_config, config])

        #menu = my.get_extra_menu()
        #tab = TabWdg(config=config, state=state, extra_menu=menu)
        tab = TabWdg(config=config,
                     state=state,
                     show_add=False,
                     show_remove=False,
                     tab_offset=5)
        tab.add_style("margin: 0px -2px -2px -2px")
        td.add(tab)
        td.add_style("padding-top: 10px")

        return top
Example #58
0
    def get_display(my):

        my.sobject = my.get_sobject()

        top = DivWdg()
        top.add_class("spt_detail_top")
        top.add_color("background", "background")
        top.add_color("color", "color")

        if not my.sobject:
            top.add("No SObject defined for this widget")
            return top

        if my.parent:
            my.search_type = my.parent.get_base_search_type()
            my.search_key = SearchKey.get_by_sobject(my.parent)
            top.add_attr("spt_parent_key", my.search_key)
            my.pipeline_code = my.parent.get_value("pipeline_code",
                                                   no_exception=True)
            my.full_search_type = my.parent.get_search_type()
        else:
            my.pipeline_code = my.sobject.get_value("pipeline_code",
                                                    no_exception=True)
            my.search_type = my.sobject.get_base_search_type()
            my.search_key = SearchKey.get_by_sobject(my.sobject)
            my.full_search_type = my.sobject.get_search_type()

        if not my.pipeline_code:
            my.pipeline_code = 'default'

        top.add_style("text-align: left")
        my.set_as_panel(top)

        table = Table()
        #from tactic.ui.container import ResizableTableWdg
        #table = ResizableTableWdg()
        table.add_color("background", "background")
        table.add_color("color", "color")
        top.add(table)
        table.set_max_width()

        table.add_row()

        if my.parent:
            code = my.parent.get_value("code", no_exception=True)
            name = my.parent.get_value("name", no_exception=True)
            search_type_obj = my.parent.get_search_type_obj()
        else:
            code = my.sobject.get_value("code", no_exception=True)
            name = my.sobject.get_value("name", no_exception=True)
            search_type_obj = my.sobject.get_search_type_obj()

        # add the title
        td = table.add_cell()
        td.add_attr("colspan", "3")
        title = DivWdg()

        search = Search("sthpw/snapshot")
        search.add_filter("search_type", "sthpw/search_type")
        search.add_filter("search_code", search_type_obj.get_value("code"))
        if search.get_sobject():
            thumb = ThumbWdg()
            title.add(thumb)
            thumb.set_icon_size(30)
            thumb.set_sobject(search_type_obj)
            thumb.add_style("float: left")

        td.add(title)

        title.add_color("background", "background3")
        title.add_style("height: 20px")
        title.add_style("padding: 6px")
        title.add_style("font-weight: bold")
        title.add_style("font-size: 1.4em")

        stype_title = search_type_obj.get_value("title")
        if stype_title:
            title.add("%s: " % stype_title)

        if name:
            title.add("%s" % name)
            if code:
                title.add(" <i style='font-size: 0.8; opacity: 0.7'>(%s)</i>" %
                          code)
        elif code:
            title.add("%s" % code)
        else:
            title.add("(No name)")

        title.add_border()

        table.add_row()

        # left
        td = table.add_cell()
        td.add_style("width: 300px")
        td.add_style("min-width: 300px")
        td.add_style("vertical-align: top")

        div = DivWdg()
        td.add(div)
        div.add_class("spt_sobject_detail_top")

        thumb_table = Table()
        div.add(thumb_table)
        thumb_table.add_row()

        from tactic.ui.panel import ThumbWdg2
        thumb = ThumbWdg2()
        # use a larger version for clearer display
        #thumb.set_icon_type('web')

        if my.parent:
            thumb.set_sobject(my.parent)
            search_key = my.parent.get_search_key()
        else:
            thumb.set_sobject(my.sobject)
            search_key = my.sobject.get_search_key()

        gallery_div = DivWdg()
        div.add(gallery_div)
        gallery_div.add_class("spt_tile_gallery")

        thumb_table.add_behavior({
            'type':
            'click_up',
            'search_key':
            search_key,
            'cbjs_action':
            '''
                var top = bvr.src_el.getParent(".spt_sobject_detail_top");
                var gallery_el = top.getElement(".spt_tile_gallery");

                var class_name = 'tactic.ui.widget.gallery_wdg.GalleryWdg';
                var kwargs = {
                    search_key: bvr.search_key,
                    search_keys: [bvr.search_key],
                };
                spt.panel.load(gallery_el, class_name, kwargs);
            '''
        })

        # prefer to see the original image, then web
        #thumb.set_option('image_link_order', 'main|web|icon')
        #thumb.set_option("detail", "false")
        #thumb.set_option("icon_size", "100%")

        td = thumb_table.add_cell(thumb)
        td.add_style("vertical-align: top")
        td.add_style("width: auto")
        td.add_style("padding: 15px")

        sobject_info_wdg = my.get_sobject_info_wdg()
        sobject_info_wdg.add_style("width: auto")

        td.add(sobject_info_wdg)

        if my.search_type == 'sthpw/task' and not my.parent:
            pass
        else:
            sobject_info_wdg = my.get_sobject_detail_wdg()
            td = table.add_cell()
            td.add(sobject_info_wdg)
            td.add_style("vertical-align: top")
            td.add_style("overflow: hidden")

        # right
        td = table.add_cell()
        td.add_style("text-align: left")
        td.add_style("vertical-align: top")
        td.add_class("spt_notes_wrapper")

        notes_div = DivWdg()
        td.add(notes_div)
        from tactic.ui.widget.discussion_wdg import DiscussionWdg
        discussion_wdg = DiscussionWdg(search_key=my.search_key,
                                       context_hidden=False,
                                       show_note_expand=False)
        notes_div.add(discussion_wdg)
        notes_div.add_style("min-width: 300px")
        notes_div.add_style("height: 200")
        notes_div.add_style("overflow-y: auto")
        notes_div.add_class("spt_resizable")

        # get the process
        if my.parent:
            process = my.sobject.get_value("process")
        else:
            process = ''

        # content
        tr = table.add_row()
        td = table.add_cell()
        td.add_attr("colspan", "5")
        #td.add_attr("colspan", "3")

        # create a state for tab.  The tab only passes a search key
        # parent key
        search_key = SearchKey.get_by_sobject(my.sobject)
        parent_key = ""
        if search_key.startswith("sthpw/"):
            parent = my.sobject.get_parent()
            if parent:
                parent_key = parent.get_search_key()

        state = {
            'search_key': search_key,
            'parent_key': parent_key,
            'process': process,
        }
        WebState.get().push(state)

        config_xml = my.get_config_xml()
        config = WidgetConfig.get(view="tab", xml=config_xml)

        if process:
            custom_view = "tab_config_%s" % process
        else:
            custom_view = "tab_config"
        search = Search("config/widget_config")
        search.add_filter("category", "TabWdg")
        search.add_filter("search_type", my.search_type)
        search.add_filter("view", custom_view)
        custom_config_sobj = search.get_sobject()
        if custom_config_sobj:
            custom_config_xml = custom_config_sobj.get_value("config")
            custom_config = WidgetConfig.get(view=custom_view,
                                             xml=custom_config_xml)
            config = WidgetConfigView(search_type='TabWdg',
                                      view=custom_view,
                                      configs=[custom_config, config])

        #menu = my.get_extra_menu()
        #tab = TabWdg(config=config, state=state, extra_menu=menu)
        tab = TabWdg(config=config,
                     state=state,
                     show_add=False,
                     show_remove=False,
                     tab_offset=5)
        tab.add_style("margin: 0px -2px -2px -2px")
        td.add(tab)
        td.add_style("padding-top: 10px")

        return top