Example #1
0
    def add_unassigned_instances(my, widget, shot_inst_names):
        ''' add the unassigned instances into a SwapDisplayWdg '''
        info = []
        session = SessionContents.get()
        if not session:
            return ""

        tactic_nodes = session.get_instance_names(is_tactic_node=True)
        non_tactic_nodes = session.get_node_names(is_tactic_node=False)

        """
        title = HtmlElement.b('Unassigned instances')
        widget.add(title)

                  # this is just a filler for now, can be any sobjects
        snapshots = []
        for tactic_node in tactic_nodes:
            if tactic_node not in shot_inst_names:
                session_version = session.get_version(tactic_node) 
                session_snap = session.get_snapshot(tactic_node)
                if session_snap:
                    snapshots.append(session_snap)
                    info.append({'session_version': session_version, 'instance':\
                    tactic_node})

        div = DivWdg(id="unassigned_table")

        SwapDisplayWdg.create_swap_title( title, swap, div) 
        table = TableWdg('sthpw/snapshot', 'session_items')
        table.set_show_property(False)
        table.set_aux_data(info)
        table.set_sobjects(snapshots)
        div.add(table)
        widget.add(div)
        widget.add(HtmlElement.br())

        """
        # Add other non-tactic nodes
        swap2 = SwapDisplayWdg.get_triangle_wdg()
  
        title2 = HtmlElement.b('Other Nodes')
        div2 = DivWdg(id="other_node_div")
        
        widget.add(swap2)
        widget.add(title2)

        SwapDisplayWdg.create_swap_title( title2, swap2, div2) 
        hidden_table = Table(css='table')
        div2.add(hidden_table)
        hidden_table.set_max_width()
        for node in non_tactic_nodes:
            hidden_table.add_row()
            hidden_table.add_cell(node)
            hidden_table.add_blank_cell()

        widget.add(div2)
Example #2
0
    def add_unassigned_instances(self, widget, shot_inst_names):
        ''' add the unassigned instances into a SwapDisplayWdg '''
        info = []
        session = SessionContents.get()
        if not session:
            return ""

        tactic_nodes = session.get_instance_names(is_tactic_node=True)
        non_tactic_nodes = session.get_node_names(is_tactic_node=False)
        """
        title = HtmlElement.b('Unassigned instances')
        widget.add(title)

                  # this is just a filler for now, can be any sobjects
        snapshots = []
        for tactic_node in tactic_nodes:
            if tactic_node not in shot_inst_names:
                session_version = session.get_version(tactic_node) 
                session_snap = session.get_snapshot(tactic_node)
                if session_snap:
                    snapshots.append(session_snap)
                    info.append({'session_version': session_version, 'instance':\
                    tactic_node})

        div = DivWdg(id="unassigned_table")

        SwapDisplayWdg.create_swap_title( title, swap, div) 
        table = TableWdg('sthpw/snapshot', 'session_items')
        table.set_show_property(False)
        table.set_aux_data(info)
        table.set_sobjects(snapshots)
        div.add(table)
        widget.add(div)
        widget.add(HtmlElement.br())

        """
        # Add other non-tactic nodes
        swap2 = SwapDisplayWdg.get_triangle_wdg()

        title2 = HtmlElement.b('Other Nodes')
        div2 = DivWdg(id="other_node_div")

        widget.add(swap2)
        widget.add(title2)

        SwapDisplayWdg.create_swap_title(title2, swap2, div2)
        hidden_table = Table(css='table')
        div2.add(hidden_table)
        hidden_table.set_max_width()
        for node in non_tactic_nodes:
            hidden_table.add_row()
            hidden_table.add_cell(node)
            hidden_table.add_blank_cell()

        widget.add(div2)
Example #3
0
    def get_item_wdg(my, sobject):

        div = DivWdg()
        div.add_class("spt_item_top")
        div.add_style("padding: 10px")
        SmartMenu.assign_as_local_activator( div, 'DG_DROW_SMENU_CTX' )
        div.add_class("spt_table_row")
        div.add_attr("spt_search_key", sobject.get_search_key(use_id=True))
        div.add_attr("spt_search_code", sobject.get_code())
        name = sobject.get_value("name", no_exception=True)
        if not name:
            name = sobject.get_code()
        div.add_attr("spt_name", name)

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

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

        td = table.add_cell()
        td.add_style("width: %s" % width);
        td.add_style("vertical-align: top")

        """
        from tile_layout_wdg import ThumbWdg2
        thumb_div = DivWdg()
        #td.add(thumb_div)
        thumb_div.add_border()
        thumb_div.set_box_shadow("0px 0px 5px")
        thumb_div.add_color("background", "background", -5)
        thumb_div.add_class("spt_item_content")
        #thumb_div.add_style("min-height: 120px")

        thumb = ThumbWdg2()
        thumb_div.add(thumb)
        thumb.set_sobject(sobject)
        """


        tile_wdg = my.tile_layout.get_tile_wdg(sobject)
        td.add(tile_wdg)

        info_div = my.get_info_wdg(sobject)
        td = table.add_cell(info_div)
        td.add_style("vertical-align: top")


        return div
Example #4
0
    def get_item_wdg(my, sobject):

        div = DivWdg()
        div.add_class("spt_item_top")
        div.add_style("padding: 10px")
        SmartMenu.assign_as_local_activator( div, 'DG_DROW_SMENU_CTX' )
        div.add_class("spt_table_row")
        div.add_attr("spt_search_key", sobject.get_search_key(use_id=True))
        div.add_attr("spt_search_code", sobject.get_code())
        name = sobject.get_value("name", no_exception=True)
        if not name:
            name = sobject.get_code()
        div.add_attr("spt_name", name)

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

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

        td = table.add_cell()
        td.add_style("width: %s" % width);
        td.add_style("vertical-align: top")

        """
        from tile_layout_wdg import ThumbWdg2
        thumb_div = DivWdg()
        #td.add(thumb_div)
        thumb_div.add_border()
        thumb_div.set_box_shadow("0px 0px 5px")
        thumb_div.add_color("background", "background", -5)
        thumb_div.add_class("spt_item_content")
        #thumb_div.add_style("min-height: 120px")

        thumb = ThumbWdg2()
        thumb_div.add(thumb)
        thumb.set_sobject(sobject)
        """


        tile_wdg = my.tile_layout.get_tile_wdg(sobject)
        td.add(tile_wdg)

        info_div = my.get_info_wdg(sobject)
        td = table.add_cell(info_div)
        td.add_style("vertical-align: top")


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

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

        inner = DivWdg()
        top.add(inner)

        inner.add("The following projects have databases that are out of date with this version of TACTIC")


        server_version = Environment.get_release_version() 

        server_div = DivWdg()
        inner.add(server_div)
        server_div.add("Installed TACTIC Version: ")
        server_div.add(server_version)
        server_div.add_style("padding: 20px")
        server_div.add_style("font-weight: bold")

        search = Search("sthpw/project")
        projects = search.get_sobjects()


        projects_div = DivWdg()
        inner.add(projects_div)

        table = Table()
        projects_div.add(table)
        table.add_style("margin: 20px")
        table.set_max_width()

        for project in projects:
            project_code = project.get_code()
            if project_code == 'admin':
                continue

            table.add_row()

            project_version = project.get_value("last_version_update")
            if project_version < server_version:

                td = table.add_cell()
                td.add(project_code)
                td = table.add_cell()

                if not project_version:
                    td.add("-")
                else:
                    td.add(project_version)








        button = ActionButtonWdg(title="Update")
        inner.add(button)
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var server = TacticServerStub.get();
            var cmd = 'tactic.ui.app.update_wdg.UpdateCbk';
            server.execute_cmd(cmd);
            '''
        } )


        return top
Example #6
0
    def get_tables_wdg(self):

        div = DivWdg()
        div.set_name("Tables")

        div.add(
            "In order to fully register a database, you must bind it to a TACTIC project"
        )
        div.add("<br/>")

        project_code = "mongodb"
        database = "test_database"

        db_resource = DbResource(server='localhost',
                                 vendor='MongoDb',
                                 database=database)

        try:
            connect = DbContainer.get(db_resource)
        except Exception as e:
            div.add("Could not connect")
            div.add_style("padding: 30px")
            div.add("<br/>" * 2)
            div.add(str(e))
            return div

        # Bind project to this resource
        database_text = TextWdg("database")
        div.add("Database: ")
        div.add(database_text)

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

        project_text = TextWdg("project")
        div.add("Project Code: ")
        div.add(project_text)

        div.add("<br/>")
        div.add("<hr/>")

        # connect and introspect the tables in this database
        tables = connect.get_tables()

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

        for table_name in tables:
            table.add_row()
            search_type = "table/%s?project=%s" % (table_name, project_code)

            td = table.add_cell()
            icon = IconWdg("View Table", IconWdg.FOLDER_GO)
            td.add(icon)
            icon.add_behavior({
                'type':
                'click_up',
                'search_type':
                search_type,
                'cbjs_action':
                '''
                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type
                }
                spt.panel.load_popup("table", class_name, kwargs);
                '''
            })

            td = table.add_cell()
            td.add(table_name)

            td = table.add_cell()
            search = Search(search_type)
            count = search.get_count()
            td.add(" %s item/s" % count)

            columns = search.get_columns()
            td = table.add_cell()
            td.add(columns)

            # search_type
            td = table.add_cell()
            text = TextWdg("search_type")
            td.add(text)
            new_search_type = "%s/%s" % (project_code, table_name)
            text.set_value(new_search_type)

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

        button = ActionButtonWdg(title="Register")
        register_div.add(button)

        return div
Example #7
0
    def get_display(self):

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

        if snapshot:
            self.snapshot = snapshot
        else:
            self.snapshot = SearchKey.get_by_search_key(search_key)

        assert self.snapshot

        metadata = self.snapshot.get_metadata()

        top = self.top
        top.add_color("background", "background")

        table = Table()
        table.set_max_width()
        top.add(table)
        table.set_unique_id()
        table.add_border()

        table.add_smart_styles("spt_cell", {'padding': '3px'})

        tr = table.add_row()
        tr.add_color("background", "background", -5)
        th = table.add_header("Property")
        th.add_style("min-width: 200px")
        th.add_style("padding: 5px")
        th = table.add_header("Value")
        th.add_style("min-width: 400px")
        th.add_style("padding: 5px")

        keys = metadata.get("__keys__")
        if not keys:
            keys = metadata.keys()

        empty = False
        if not keys:
            empty = True
            keys = ['', '', '', '', '', '', '']
            table.add_smart_styles("spt_cell", {'height': '20px'})

        for i, key in enumerate(keys):
            value = metadata.get(key)

            title = Common.get_display_title(key)

            tr = table.add_row()

            if i % 2:
                tr.add_color("background", "background")
                tr.add_color("color", "color")
            else:
                tr.add_color("background", "background", -8)
                tr.add_color("color", "color")

            td = table.add_cell()
            td.add_class("spt_cell")
            td.add(title)

            td = table.add_cell()
            td.add_class("spt_cell")
            td.add(value)

        if empty:
            div = DivWdg()
            top.add(div)
            div.add_style("height: 30px")
            div.add_style("width: 150px")
            div.add_style("margin-top: -110px")
            div.center()
            div.add("<b>No Metadata</b>")
            div.add_border()
            div.add_color("background", "background3")
            div.add_color("color", "color3")
            div.add_style("padding: 20px")
            div.add_style("text-align: center")

            top.add_style("min-height: 200px")

        return top
Example #8
0
    def get_import_wdg(my):
        div = DivWdg()

        if my.data:

            div.add("<br/>" * 2)
            div.add("The following TACTIC share was found: ")
            div.add("<br/>" * 2)

            data_input = TextAreaWdg("data")
            data_input.add_style("display: none")
            div.add(data_input)

            #print "xxxx: ", my.data
            data_str = jsondumps(my.data)
            #data_str = data_str.replace('"', "'")
            print "data: ", data_str
            data_input.set_value(data_str)

            table = Table()
            div.add(table)
            table.set_max_width()
            table.add_style("margin-left: 20px")
            table.add_style("margin-right: 20px")

            for name, value in my.data.items():
                name = Common.get_display_title(name)
                table.add_row()
                table.add_cell(name)
                table.add_cell(value)

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

            div.add(my.get_versions_wdg())

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

            # check to see if the project exists
            project_code = my.data.get("project_code")
            project_code = my.data.get("projects")
            project = Project.get_by_code(project_code)
            #if project:
            if False:
                msg_div = DivWdg()
                div.add(msg_div)
                msg_div.add_style("padding: 20px")
                msg_div.add_color("background", "background3")
                msg_div.add_color("color", "color")
                msg_div.add_border()

                icon = IconWdg("WARNING", IconWdg.WARNING)
                msg_div.add(icon)
                icon.add_style("float: left")

                msg_div.add(
                    "The project with code [%s] already exists.  You must remove the installed project before trying to import this one."
                    % project_code)
                return div

            if my.data.get("is_encrypted") == "true":
                div.add(
                    "The transactions in this share is encrypted.  Please provide an encryption key to decrypt the transactions<br/><br/>"
                )
                div.add("Encryption Key: ")
                text = TextWdg("encryption_key")
                div.add(text)
                div.add("<br/>" * 2)

            button = ActionButtonWdg(title="Import >>")
            button.add_style("float: right")
            div.add(button)
            div.add("<br/>" * 2)
            button.add_behavior({
                'type':
                'click_up',
                'project_code':
                project_code,
                'cbjs_action':
                '''
                spt.app_busy.show("Importing Project "+bvr.project_code+"...");
                var top = bvr.src_el.getParent(".spt_sync_import_top");
                var values = spt.api.Utility.get_input_values(top, null, false);
                var cmd = "tactic.ui.sync.SyncImportCmd";
                var server = TacticServerStub.get();
                server.execute_cmd(cmd, values, {}, {use_transaction: false});
                spt.notify.show_message("Finished importing project");
                spt.app_busy.hide();
                document.location = '/tactic/'+bvr.project_code;
                '''
            })

        return div
Example #9
0
    def get_display(self):

        # get all of the options
        direction = self.get_option("direction")
        if not direction:
            direction = "dst"

        icon_size = self.get_option("icon_size")
        if not icon_size:
            icon_size = 60
        try:
            sobject = self.get_current_sobject()
        except IndexError:
            return ''
        if not hasattr(self, 'info'):
            return ''

        connections, dst_sobjects, sobj = self.info.get(
            sobject.get_search_key())

        src_sobject = sobject

        # may not need this due to preprocess
        if isinstance(src_sobject, SObjectConnection):
            connection = src_sobject
            src_sobject = connection.get_sobject(direction="src")

        div = DivWdg()
        div.set_id("connection_%s" % src_sobject.get_id())

        # set the ajax options
        self.set_ajax_top(div)
        self.set_ajax_option("search_key", src_sobject.get_search_key())
        self.register_cmd("pyasm.widget.SObjectConnectionRemoveCbk")

        table = Table()
        table.set_max_width()
        table.set_class("minimal")
        count = 0

        for dst_sobject in dst_sobjects:
            tr = table.add_row()
            if not dst_sobject:
                table.add_cell("referenced to retired or deleted asset....")
                continue
            if dst_sobject.is_retired():
                tr.add_class("retired_row")

            thumb = ThumbWdg()
            thumb.set_show_filename(True)
            thumb.set_show_orig_icon(True)
            thumb.set_icon_size(icon_size)
            thumb.set_sobject(dst_sobject)
            td = table.add_cell(thumb)
            td.add_style("padding: 1px")
            td.add_style("width: 20%")

            id = dst_sobject.get_id()
            name = dst_sobject.get_name()
            code = dst_sobject.get_code()
            if code == str(id):
                pass
            elif name == code:
                td = table.add_cell(name)
                td.add_style("width: 20%")
            else:
                td = table.add_cell("%s<br/>%s" % (name, code))
                td.add_style("width: 20%")

            if dst_sobject.has_value("title"):
                td = table.add_cell("%s" % dst_sobject.get_value("title"))
            elif dst_sobject.has_value("description"):
                td = table.add_cell("%s" %
                                    dst_sobject.get_value("description"))
                td.add_style("width: 30%")
            if dst_sobject.has_value("keywords"):

                td = table.add_cell("%s" % dst_sobject.get_value("keywords"))
                td.add_style("width: 20%")

            if dst_sobject.has_value("timestamp"):
                td = table.add_cell("%s" % Date(
                    dst_sobject.get_value("timestamp")).get_display_time())
                td.add_style("width: 20%")

            update = UpdateWdg()
            update.set_sobject(dst_sobject)
            update.set_option('delete', 'false')
            table.add_cell(update)

            # remove connection
            connection = connections[count]
            connection_id = connection.get_id()
            self.set_ajax_option("connection_id", connection_id)
            refresh_script = self.get_refresh_script(False)

            remove = IconButtonWdg("Remove Connection", IconWdg.DELETE)
            remove.add_event("onclick", refresh_script)

            table.add_cell(remove)

            count += 1

        div.add(table)
        return div
Example #10
0
    def get_display(my):
        div = DivWdg()

        sobject = my.get_sobject_from_kwargs()
        if not sobject:
            div.add("SObject not found")
            return div

        search_type_obj = sobject.get_search_type_obj()
        title = search_type_obj.get_title()
        title_wdg = DivWdg()
        title_wdg.add_style("font-size: 1.8em")
        title_wdg.add("%s: %s" % (title, sobject.get_code() ) )

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


        table = Table()
        table.set_max_width()

        col1 = table.add_col()
        col1.add_style('width: 200px')
        col2 = table.add_col()
        col2.add_style('width: 320px')
        col3 = table.add_col()
        col3.add_style('width: 400px')
        table.add_row()

        from pyasm.widget import ThumbWdg, DiscussionWdg, SObjectTaskTableElement

        td = table.add_cell()
        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)
        thumb.set_option("detail", "false")
        td.add(thumb)
        from pyasm.prod.web import AssetInfoWdg
        info = AssetInfoWdg()
        info.thumb = thumb
        info.set_sobject(sobject)
        td.add(info)

        # tasks
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding-left: 5px")
        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("Tasks")
        td.add(title)
        task_wdg = SObjectTaskTableElement()
        task_wdg.set_sobject(sobject)
        td.add(task_wdg)
        td.add_style('cell-padding','10')


        # discussion
        td = table.add_cell()
        #td.add_style("min-width: 300px")
        #td.add_style("width: 600px")
        td.add_style("vertical-align: top")
        td.add_style("padding-left: 5px")
        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("Notes")
        td.add(title)
        discussion_wdg = DiscussionWdg()
        discussion_wdg.preprocess()
        discussion_wdg.set_sobject(sobject)
        td.add(discussion_wdg)
        note_panel = discussion_wdg.get_note_menu()
        td.add(note_panel)

        div.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)
        child_types = schema.get_child_types(search_type)




        # 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(25)
        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 )

        parent_key = SearchKey.get_by_sobject(sobject)
        content_wdg = ViewPanelWdg(search_type=search_type, element_name='Snapshots', \
            title='Snapshots', view='table', parent_key=parent_key, do_search=True)
        #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_style("padding-left: 10px")
        content_td.add(content_wdg)

        div.add(table)

        return div
Example #11
0
    def get_tables_wdg(self):
        
        div = DivWdg()
        div.set_name("Tables")

        div.add("In order to fully register a database, you must bind it to a TACTIC project")
        div.add("<br/>")



        project_code = "mongodb"
        database = "test_database"

        db_resource = DbResource(
                server='localhost',
                vendor='MongoDb',
                database=database
        )


        try:
            connect = DbContainer.get(db_resource)
        except Exception as e:
            div.add("Could not connect")
            div.add_style("padding: 30px")
            div.add("<br/>"*2)
            div.add(str(e))
            return div



        # Bind project to this resource
        database_text = TextWdg("database")
        div.add("Database: ")
        div.add(database_text)

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

        project_text = TextWdg("project")
        div.add("Project Code: ")
        div.add(project_text)

        div.add("<br/>")
        div.add("<hr/>")



        # connect and introspect the tables in this database
        tables = connect.get_tables()


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

        for table_name in tables:
            table.add_row()
            search_type = "table/%s?project=%s" % (table_name, project_code)

            td = table.add_cell()
            icon = IconWdg("View Table", IconWdg.FOLDER_GO)
            td.add(icon)
            icon.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'cbjs_action': '''
                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type
                }
                spt.panel.load_popup("table", class_name, kwargs);
                '''
            } )


            td = table.add_cell()
            td.add(table_name)

            td = table.add_cell()
            search = Search(search_type)
            count = search.get_count()
            td.add(" %s item/s" % count)

            columns = search.get_columns()
            td = table.add_cell()
            td.add(columns)

            # search_type
            td = table.add_cell()
            text = TextWdg("search_type")
            td.add(text)
            new_search_type = "%s/%s" % (project_code, table_name)
            text.set_value(new_search_type)



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

        button = ActionButtonWdg(title="Register")
        register_div.add(button)


        return div
Example #12
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 #13
0
    def init(self):

        self.item_cls = self.kwargs.get('left_search_type')
        self.container_cls = self.kwargs.get('right_search_type')
        self.grouping_cls = self.kwargs.get('search_type')

        self.item_sobj = self.container_sobj = None

        # List the items
        search = Search(self.item_cls)
        self._order_search(search)

        items = search.get_sobjects()
        if items:
            self.item_sobj = items[0]
        #select = MultiSelectWdg("item_ids")
        #select.set_search_for_options(search,"login", "get_full_name()")

        user_span = SpanWdg(css='med')

        user_table = Table(css='table')
        user_table.add_style("margin-left: 6px")
        user_table.set_max_width()
        user_table.add_col(css='small')
        user_table.add_col()

        user_table.add_style("min-width: 14em")
        user_table.add_row_cell(search.get_search_type_obj()\
            .get_description(), "heading")

        for item in items:
            user_table.add_row()
            checkbox = CheckboxWdg("item_ids")
            checkbox.set_option("value", item.get_primary_key_value())
            user_table.add_cell(checkbox)

            project_code = item.get_value("project_code", no_exception=True)
            if project_code:
                user_table.add_cell("[ %s ]" % project_code)
            else:
                user_table.add_cell("[ * ]")

            user_table.add_cell(item.get_description())
        user_span.add(user_table)

        # control widget in the middle
        control_div = DivWdg()
        control_div.add_style('padding: 100px 10px 0 10px')

        button = IconSubmitWdg(self.ADD_LABEL, "stock_insert-slide.png", True)
        button.add_style('padding: 2px 30px 4px 30px')
        control_div.add(button)

        main_table = Table(css='collapse')
        main_table.set_max_width()
        main_table.add_row(css='plain_bg')
        main_table.add_cell(user_span, 'valign_top')
        td = main_table.add_cell(control_div, 'valign_top')
        td.add_style('width', '12em')
        main_table.add_cell(self._get_target_span(), 'valign_top')

        self.add(main_table)

        # register command here
        if self.item_sobj and self.container_sobj:
            marshaller = WebContainer.register_cmd(
                "pyasm.widget.SObjectGroupCmd")
            marshaller.set_option("grouping_search_type", self.grouping_cls)
            marshaller.set_option("item_foreign_key",
                                  self.item_sobj.get_foreign_key())
            marshaller.set_option("container_foreign_key",
                                  self.container_sobj.get_foreign_key())
Example #14
0
    def get_item_wdg(self, sobject):

        self.element_names = self.kwargs.get("element_names")
        if not self.element_names:
            self.element_names = [
                "preview",
                "code",
                "name",
                "description",
            ]
        else:
            self.element_names = self.element_names.split(",")

        if self.element_names[0] == "preview":
            has_preview = True
            self.element_names = self.element_names[1:]
        else:
            has_preview = False

        view = self.kwargs.get("view")
        if not view:
            view = "table"
        from pyasm.widget import WidgetConfigView
        search_type = sobject.get_search_type()
        self.config = WidgetConfigView.get_by_search_type(search_type, view)

        div = DivWdg()
        div.add_class("spt_item_top")
        div.add_style("padding: 10px")
        SmartMenu.assign_as_local_activator(div, 'DG_DROW_SMENU_CTX')
        #div.add_class("spt_table_row")
        #div.add_class("spt_table_row_%s" % self.table_id)
        div.add_attr("spt_search_key", sobject.get_search_key(use_id=True))
        div.add_attr("spt_search_code", sobject.get_code())
        name = sobject.get_value("name", no_exception=True)
        if not name:
            name = sobject.get_code()
        div.add_attr("spt_name", name)

        table = Table()

        div.add(table)
        table.set_max_width()
        tr = table.add_row()

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

        if has_preview:
            td = table.add_cell()
            td.add_style("width: %s" % width)
            td.add_style("vertical-align: top")

            options = self.config.get_display_options("preview")
            redirect_expr = options.get("redirect_expr")
            if redirect_expr:
                parent = Search.eval(redirect_expr, sobject, single=True)
                #parent = sobject.get_parent()
                tile_wdg = self.tile_layout.get_tile_wdg(parent)
            else:
                tile_wdg = self.tile_layout.get_tile_wdg(sobject)

            td.add(tile_wdg)

        info_div = self.get_info_wdg(sobject)
        td = table.add_cell(info_div)
        td.add_style("vertical-align: top")

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


        my.search_type = my.kwargs.get('search_type')
        my.texture_search_type = my.kwargs.get('texture_search_type')
        assert my.search_type

        app_name = WebContainer.get_web().get_selected_app()
        # add an outside box


        top = DivWdg(css='spt_view_panel')
        #div = DivWdg(css="maq_search_bar")
        div = DivWdg()
        div.add_color("background", "background2", -15)
        my.set_as_panel(top)

        top.add(div)
        div.add_style("margin: 5px")

        div.add_style("padding: 10px")
        
        div.add_style("font-style: bold")



        process_div = DivWdg()
        process_div.add_style("padding-left: 10px")
        div.add(process_div)
        process_div.add( my.get_process_wdg(my.search_type))
        process_div.add( my.get_context_filter_wdg() )
        process_div.add(HtmlElement.br(clear="all")) 


        div.add( HtmlElement.br() )
        checkin_options = DivWdg(css='spt_ui_options')
        checkin_options.add_style("padding: 10px")

        swap = SwapDisplayWdg()
        #swap.set_off()
        title = SpanWdg("Check in Options")
        SwapDisplayWdg.create_swap_title(title, swap, checkin_options, is_open=False)
        div.add(swap)
        div.add(title)


        checkin_options.add( my.get_file_type_wdg() )
        checkin_options.add( my.get_snapshot_type_wdg() )
        checkin_options.add(HtmlElement.br(1)) 
        checkin_options.add( my.get_export_method_wdg() )
        checkin_options.add( my.get_checkin_as_wdg() )

        #my.add( my.get_render_icon_wdg() )

        # For different export methods
        checkin_options.add( my.get_currency_wdg() )

        checkin_options.add( my.get_reference_option())
        checkin_options.add( my.get_auto_version_wdg())
        checkin_options.add( my.get_texture_option(app=app_name))
        checkin_options.add( my.get_handoff_wdg())
       
        if not my.context_select.get_value(for_display=True):
            my.add(DivWdg('A context must be selected.', css='warning'))
            return

        div.add(checkin_options)
      
        
        top.add( my.get_introspect_wdg() )
        top.add(HtmlElement.br(2))
        
        # create the interface
        table = Table()
        table.set_max_width()
        #table.set_class("table")
        table.add_color('background','background2') 
        #table.add_style('line-height','3.0em')
        #table.add_row(css='smaller')
        tr = table.add_row(css='smaller')
        tr.add_style('height', '3.5em')
        table.add_header("&nbsp;")
        table.add_header("&nbsp;")
        th = table.add_header("Instance")
        th.add_style('text-align: left')
        table.add_header(my.get_checkin())
        table.add_header("Sandbox")
        tr.add_color('background','background2', -15)
        

        # get session and handle case where there is no session
        my.session = SessionContents.get()
        if my.session == None:
            instance_names = []
            asset_codes = []
            node_names = []
        else:
            instance_names = my.session.get_instance_names()
            asset_codes = my.session.get_asset_codes()
            node_names = my.session.get_node_names()

        # get all of the possible assets based on the asset codes
        search = Search(my.search_type)
        search.add_filters("code", asset_codes)
        assets = search.get_sobjects()
        assets_dict = SObject.get_dict(assets, ["code"])

        if my.session:
            my.add("Current Project: <b>%s</b>" % my.session.get_project_dir() )
        else:
            my.add("Current Project: Please press 'Introspect'")


        count = 0
        for i in range(0, len(node_names) ):
            node_name = node_names[i]
            if not my.session.is_tactic_node(node_name) and \
                not my.session.get_node_type(node_name) in ['transform','objectSet']:
                    continue
            instance_name = instance_names[i]

            # backwards compatible:
            try:
                asset_code = asset_codes[i]
            except IndexError, e:
                asset_code = instance_name

            # skip if this is a reference
            if my.list_references == False and \
                    my.session.is_reference(node_name):
                continue

            table.add_row()


            # check that this asset exists
            asset = assets_dict.get(asset_code)
            if not asset:
                continue
           
            # list items if it is a set
            if asset.get_value('asset_type', no_exception=True) in ["set", "section"]:
                my.current_sobject = asset
                my.handle_set( table, instance_name, asset, instance_names)
                count +=1
            # if this asset is in the database, then allow it to checked in
            if asset:
                if my.session.get_snapshot_code(instance_name, snapshot_type='set'):
                    continue

                # hack remember this
                my.current_sobject = asset
                my.handle_instance(table, instance_name, asset, node_name)

            else:
                table.add_blank_cell()
                table.add_cell(instance_name)


            count += 1
Example #16
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 #17
0
    def get_display(self):
        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 = self.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 #18
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 #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
    def get_display(my):

        search_key = my.kwargs.get("search_key")
        snapshot = my.kwargs.get("snapshot")

        if snapshot:
            my.snapshot = snapshot
        else:
            my.snapshot = SearchKey.get_by_search_key(search_key)


        assert my.snapshot

        metadata = my.snapshot.get_metadata()

        top = my.top
        top.add_color("background", "background")


        table = Table()
        table.set_max_width()
        top.add(table)
        table.set_unique_id()
        table.add_border()

        table.add_smart_styles("spt_cell", {
            'padding': '3px'
        } )



        tr = table.add_row()
        tr.add_gradient("background", "background3")
        th = table.add_header("Property")
        th.add_style("min-width: 200px")
        th.add_style("padding: 5px")
        th = table.add_header("Value")
        th.add_style("min-width: 400px")
        th.add_style("padding: 5px")

        keys = metadata.get("__keys__")
        if not keys:
            keys = metadata.keys()

        empty = False
        if not keys:
            empty = True
            keys = ['','','','','','','']
            table.add_smart_styles("spt_cell", {
                'height': '20px'
            } )


        for i, key in enumerate(keys):
            value = metadata.get(key)

            title = Common.get_display_title(key)

            tr = table.add_row()

            if i % 2:
                tr.add_color("background", "background")
                tr.add_color("color", "color")
            else:
                tr.add_color("background", "background", -8)
                tr.add_color("color", "color")

            td = table.add_cell()
            td.add_class("spt_cell")
            td.add(title)

            td = table.add_cell()
            td.add_class("spt_cell")
            td.add(value)


        if empty:
            div = DivWdg()
            top.add(div)
            div.add_style("height: 30px")
            div.add_style("width: 150px")
            div.add_style("margin-top: -110px")
            div.center()
            div.add("<b>No Metadata</b>")
            div.add_border()
            div.add_color("background", "background3")
            div.add_color("color", "color3")
            div.add_style("padding: 20px")
            div.add_style("text-align: center")

            top.add_style("min-height: 200px")

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

        search_key = my.kwargs.get("search_key")
        path = my.kwargs.get("path")
        parser_str = my.kwargs.get("parser")
        use_tactic_tags = my.kwargs.get("use_tactic_tags")

        from pyasm.checkin import PILMetadataParser, ImageMagickMetadataParser, ExifMetadataParser, BaseMetadataParser
        if parser_str:
            parser = BaseMetadataParser.get_parser(parser_str, path)
        else:
            parser = BaseMetadataParser.get_parser_by_path(path)

        if parser:
            if use_tactic_tags in ['true', True]:
                metadata = parser.get_tactic_metadata()
            else:
                metadata = parser.get_metadata()
        else:
            metadata = {}

        top = my.top
        top.add_color("background", "background")

        table = Table()
        table.set_max_width()
        top.add(table)
        table.set_unique_id()
        table.add_border()

        table.add_smart_styles("spt_cell", {'padding': '3px'})

        tr = table.add_row()
        tr.add_gradient("background", "background3")
        th = table.add_header("Property")
        th.add_style("min-width: 200px")
        th.add_style("padding: 5px")
        th = table.add_header("Value")
        th.add_style("min-width: 400px")
        th.add_style("padding: 5px")

        keys = metadata.get("__keys__")
        if not keys:
            keys = metadata.keys()

        empty = False
        if not keys:
            empty = True
            keys = ['', '', '', '', '', '', '']
            table.add_smart_styles("spt_cell", {'height': '20px'})

        for i, key in enumerate(keys):
            value = metadata.get(key)

            title = Common.get_display_title(key)

            tr = table.add_row()

            if i % 2:
                tr.add_color("background", "background")
                tr.add_color("color", "color")
            else:
                tr.add_color("background", "background", -8)
                tr.add_color("color", "color")

            td = table.add_cell()
            td.add_class("spt_cell")
            td.add(title)

            td = table.add_cell()
            td.add_class("spt_cell")

            if len(str(value)) > 500:
                inside = DivWdg()
                td.add(inside)
                value = value[:500]
                inside.add(value)
                inside.add_style("max-width: 600px")
            else:
                td.add(value)

        if empty:
            div = DivWdg()
            top.add(div)
            div.add_style("height: 30px")
            div.add_style("width: 150px")
            div.add_style("margin-top: -110px")
            div.center()
            div.add("<b>No Metadata</b>")
            div.add_border()
            div.add_color("background", "background3")
            div.add_color("color", "color3")
            div.add_style("padding: 20px")
            div.add_style("text-align: center")

            top.add_style("min-height: 200px")

        return top
Example #22
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()

        # add the title
        tr, td = table.add_row_cell()

        title_wdg = my.get_title_wdg()
        td.add(title_wdg)


        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: 100%")


        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")
        td.add_style("padding: 5px 5px")

        title_wdg = DivWdg()
        td.add(title_wdg)
        title_wdg.add_style("width: 100%")
        title_wdg.add("Notes")
        title_wdg.add("<hr/>")
        title_wdg.add_style("font-size: 1.2em")

        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
Example #23
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
Example #24
0
    def get_versions_wdg(my):

        div = DivWdg()
        div.add_class("spt_imports")

        title_wdg = DivWdg()
        div.add(title_wdg)
        title_wdg.add("Imports found:")
        title_wdg.add_style("padding: 0px 0px 8px 0px")

        base_dir = my.kwargs.get("base_dir")
        imports_dir = "%s/imports" % base_dir
        if not os.path.exists(imports_dir):
            imports_dir = base_dir

        basenames = os.listdir(imports_dir)
        basenames.sort()
        basenames.reverse()

        div.add_relay_behavior({
            'type':
            'mouseup',
            'bvr_match_class':
            "spt_import_item",
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_imports");
            var els = top.getElements(".spt_import_info");
            for ( var i = 0; i < els.length; i++) {
                spt.hide(els[i]);
            }

            var el = bvr.src_el.getElement(".spt_import_info");
            spt.show(el);
            '''
        })

        # find all the zip files
        count = 0
        for basename in basenames:
            if not basename.endswith(".txt"):
                continue
            if basename.find("-files-") != -1:
                continue
            if basename.find("-data-") != -1:
                continue

            version_wdg = DivWdg()
            div.add(version_wdg)
            version_wdg.add_style("padding: 3px 3px 3px 12px")
            version_wdg.add_class("spt_import_item")

            radio = RadioWdg("basename")
            version_wdg.add(radio)
            radio.set_option("value", basename)
            if not count:
                radio.set_checked()

            version_wdg.add(basename)

            version_wdg.add("<br/>")

            # add info
            path = "%s/%s" % (imports_dir, basename)
            f = open(path)
            data = f.read()
            f.close()

            data = jsonloads(data)

            table = Table()
            version_wdg.add(table)
            table.add_class("spt_import_info")
            if count:
                table.add_style("display: none")
            table.set_max_width()
            table.add_style("margin-left: 40px")
            table.add_style("margin-right: 20px")

            version_wdg.add(table)
            for name, value in my.data.items():
                name = Common.get_display_title(name)
                table.add_row()
                table.add_cell(name)
                table.add_cell(value)

            count += 1

        if count == 0:
            msg_wdg = DivWdg()
            div.add(msg_wdg)
            msg_wdg.add("<i>No imports found</i>")
            msg_wdg.add_border()
            msg_wdg.add_style("padding: 20px")
            msg_wdg.add_style("padding: 10px")
            msg_wdg.add_style("text-align: center")
            msg_wdg.add_color("background", "background", -10)

        return div
Example #25
0
    def get_import_wdg(self):
        div = DivWdg()

        if self.data:

            div.add("<br/>"*2)
            div.add("The following TACTIC share was found: ")
            div.add("<br/>"*2)

            data_input = TextAreaWdg("data")
            data_input.add_style("display: none")
            div.add(data_input)

            #print "xxxx: ", self.data
            data_str = jsondumps(self.data)
            #data_str = data_str.replace('"', "'")
            print "data: ", data_str
            data_input.set_value(data_str)




            table = Table()
            div.add(table)
            table.set_max_width()
            table.add_style("margin-left: 20px")
            table.add_style("margin-right: 20px")

            for name, value in self.data.items():
                name = Common.get_display_title(name)
                table.add_row()
                table.add_cell(name)
                table.add_cell(value)



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

            div.add( self.get_versions_wdg() )

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

            # check to see if the project exists
            project_code = self.data.get("project_code")
            project_code = self.data.get("projects")
            project = Project.get_by_code(project_code)
            #if project:
            if False:
                msg_div = DivWdg()
                div.add(msg_div)
                msg_div.add_style("padding: 20px")
                msg_div.add_color("background", "background3")
                msg_div.add_color("color", "color")
                msg_div.add_border()

                icon = IconWdg("WARNING", IconWdg.WARNING)
                msg_div.add(icon)
                icon.add_style("float: left")

                msg_div.add("The project with code [%s] already exists.  You must remove the installed project before trying to import this one." % project_code)
                return div





            if self.data.get("is_encrypted") == "true":
                div.add("The transactions in this share is encrypted.  Please provide an encryption key to decrypt the transactions<br/><br/>")
                div.add("Encryption Key: ")
                text = TextWdg("encryption_key")
                div.add(text)
                div.add("<br/>"*2)

            button = ActionButtonWdg(title="Import >>")
            button.add_style("float: right")
            div.add(button)
            div.add("<br/>"*2)
            button.add_behavior( {
                'type': 'click_up',
                'project_code': project_code,
                'cbjs_action': '''
                spt.app_busy.show("Importing Project "+bvr.project_code+"...");
                var top = bvr.src_el.getParent(".spt_sync_import_top");
                var values = spt.api.Utility.get_input_values(top, null, false);
                var cmd = "tactic.ui.sync.SyncImportCmd";
                var server = TacticServerStub.get();
                server.execute_cmd(cmd, values, {}, {use_transaction: false});
                spt.notify.show_message("Finished importing project");
                spt.app_busy.hide();
                document.location = '/tactic/'+bvr.project_code;
                '''
            } )



        return div
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_versions_wdg(self):

        div = DivWdg()
        div.add_class("spt_imports")

        title_wdg = DivWdg()
        div.add(title_wdg)
        title_wdg.add("Imports found:")
        title_wdg.add_style("padding: 0px 0px 8px 0px")


        base_dir = self.kwargs.get("base_dir")
        imports_dir = "%s/imports" % base_dir
        if not os.path.exists(imports_dir):
            imports_dir = base_dir

        basenames = os.listdir(imports_dir)
        basenames.sort()
        basenames.reverse()


        div.add_relay_behavior( {
            'type': 'mouseup',
            'bvr_match_class': "spt_import_item",
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_imports");
            var els = top.getElements(".spt_import_info");
            for ( var i = 0; i < els.length; i++) {
                spt.hide(els[i]);
            }

            var el = bvr.src_el.getElement(".spt_import_info");
            spt.show(el);
            '''
        } )



        # find all the zip files
        count = 0
        for basename in basenames:
            if not basename.endswith(".txt"):
                continue
            if basename.find("-files-") != -1:
                continue
            if basename.find("-data-") != -1:
                continue

            version_wdg = DivWdg()
            div.add(version_wdg)
            version_wdg.add_style("padding: 3px 3px 3px 12px")
            version_wdg.add_class("spt_import_item")

            radio = RadioWdg("basename")
            version_wdg.add(radio)
            radio.set_option("value", basename)
            if not count:
                radio.set_checked()


            version_wdg.add(basename)

            version_wdg.add("<br/>")



            # add info
            path = "%s/%s" % (imports_dir, basename)
            f = open(path)
            data = f.read()
            f.close()

            data = jsonloads(data)

            table = Table()
            version_wdg.add(table)
            table.add_class("spt_import_info")
            if count:
                table.add_style("display: none")
            table.set_max_width()
            table.add_style("margin-left: 40px")
            table.add_style("margin-right: 20px")



            version_wdg.add(table)
            for name, value in self.data.items():
                name = Common.get_display_title(name)
                table.add_row()
                table.add_cell(name)
                table.add_cell(value)



            count += 1


        if count == 0:
            msg_wdg = DivWdg()
            div.add(msg_wdg)
            msg_wdg.add("<i>No imports found</i>")
            msg_wdg.add_border()
            msg_wdg.add_style("padding: 20px")
            msg_wdg.add_style("padding: 10px")
            msg_wdg.add_style("text-align: center")
            msg_wdg.add_color("background", "background", -10)


        return div
Example #28
0
    def init(my):
        
 
        my.item_cls = my.kwargs.get('left_search_type')
        my.container_cls = my.kwargs.get('right_search_type')
        my.grouping_cls  = my.kwargs.get('search_type')

        my.item_sobj = my.container_sobj = None 
        
        # List the items
        search = Search(my.item_cls)
        my._order_search(search)    
        
        items = search.get_sobjects()
        if items:
            my.item_sobj = items[0]
        #select = MultiSelectWdg("item_ids")
        #select.set_search_for_options(search,"login", "get_full_name()")

        user_span = SpanWdg(css='med')
        
        user_table = Table(css='table')
        user_table.add_style("margin-left: 6px")
        user_table.set_max_width()
        user_table.add_col(css='small')
        user_table.add_col()
        
        user_table.add_style("min-width: 14em")
        user_table.add_row_cell(search.get_search_type_obj()\
            .get_description(), "heading")

        for item in items:
            user_table.add_row()
            checkbox = CheckboxWdg("item_ids")
            checkbox.set_option("value", item.get_primary_key_value() )
            user_table.add_cell( checkbox )

            project_code = item.get_value("project_code", no_exception=True)
            if project_code:
                user_table.add_cell( "[ %s ]" % project_code )
            else:
                user_table.add_cell( "[ * ]" )

            user_table.add_cell( item.get_description() )
        user_span.add(user_table)

        # control widget in the middle
        control_div = DivWdg()
        control_div.add_style('padding: 100px 10px 0 10px')

        button = IconSubmitWdg(my.ADD_LABEL, "stock_insert-slide.png", True)
        button.add_style('padding: 2px 30px 4px 30px')
        control_div.add(button)
        
        
        main_table = Table(css='collapse')
        main_table.set_max_width()
        main_table.add_row(css='plain_bg')
        main_table.add_cell(user_span, 'valign_top')
        td = main_table.add_cell(control_div, 'valign_top')
        td.add_style('width','12em')
        main_table.add_cell(my._get_target_span(), 'valign_top')

        my.add(main_table)
    
        # register command here
        if my.item_sobj and my.container_sobj:
            marshaller = WebContainer.register_cmd("pyasm.widget.SObjectGroupCmd")
            marshaller.set_option("grouping_search_type", my.grouping_cls)
            marshaller.set_option("item_foreign_key", my.item_sobj.get_foreign_key())
            marshaller.set_option("container_foreign_key", my.container_sobj.get_foreign_key())
Example #29
0
    def get_display(self):

        top = self.top
        top.add_style("padding: 10px")
        top.add_color("background", "background")
        top.add_style("width: 400px")

        inner = DivWdg()
        top.add(inner)

        inner.add("The following projects have databases that are out of date with this version of TACTIC")


        server_version = Environment.get_release_version() 

        server_div = DivWdg()
        inner.add(server_div)
        server_div.add("Installed TACTIC Version: ")
        server_div.add(server_version)
        server_div.add_style("padding: 20px")
        server_div.add_style("font-weight: bold")

        search = Search("sthpw/project")
        projects = search.get_sobjects()


        projects_div = DivWdg()
        inner.add(projects_div)

        table = Table()
        projects_div.add(table)
        table.add_style("margin: 20px")
        table.set_max_width()

        for project in projects:
            project_code = project.get_code()
            if project_code == 'admin':
                continue

            table.add_row()

            project_version = project.get_value("last_version_update")
            if project_version < server_version:

                td = table.add_cell()
                td.add(project_code)
                td = table.add_cell()

                if not project_version:
                    td.add("-")
                else:
                    td.add(project_version)








        button = ActionButtonWdg(title="Update")
        inner.add(button)
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var server = TacticServerStub.get();
            var cmd = 'tactic.ui.app.update_wdg.UpdateCbk';
            server.execute_cmd(cmd);
            '''
        } )


        return top
Example #30
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 #31
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
    def get_display(my):

        my.search_type = my.kwargs.get('search_type')
        my.texture_search_type = my.kwargs.get('texture_search_type')
        assert my.search_type

        app_name = WebContainer.get_web().get_selected_app()
        # add an outside box

        top = DivWdg(css='spt_view_panel')
        #div = DivWdg(css="maq_search_bar")
        div = DivWdg()
        div.add_color("background", "background2", -15)
        my.set_as_panel(top)

        top.add(div)
        div.add_style("margin: 5px")

        div.add_style("padding: 10px")

        div.add_style("font-style: bold")

        process_div = DivWdg()
        process_div.add_style("padding-left: 10px")
        div.add(process_div)
        process_div.add(my.get_process_wdg(my.search_type))
        process_div.add(my.get_context_filter_wdg())
        process_div.add(HtmlElement.br(clear="all"))

        div.add(HtmlElement.br())
        checkin_options = DivWdg(css='spt_ui_options')
        checkin_options.add_style("padding: 10px")

        swap = SwapDisplayWdg()
        #swap.set_off()
        title = SpanWdg("Check in Options")
        SwapDisplayWdg.create_swap_title(title,
                                         swap,
                                         checkin_options,
                                         is_open=False)
        div.add(swap)
        div.add(title)

        checkin_options.add(my.get_file_type_wdg())
        checkin_options.add(my.get_snapshot_type_wdg())
        checkin_options.add(HtmlElement.br(1))
        checkin_options.add(my.get_export_method_wdg())
        checkin_options.add(my.get_checkin_as_wdg())

        #my.add( my.get_render_icon_wdg() )

        # For different export methods
        checkin_options.add(my.get_currency_wdg())

        checkin_options.add(my.get_reference_option())
        checkin_options.add(my.get_auto_version_wdg())
        checkin_options.add(my.get_texture_option(app=app_name))
        checkin_options.add(my.get_handoff_wdg())

        if not my.context_select.get_value(for_display=True):
            my.add(DivWdg('A context must be selected.', css='warning'))
            return

        div.add(checkin_options)

        top.add(my.get_introspect_wdg())
        top.add(HtmlElement.br(2))

        # create the interface
        table = Table()
        table.set_max_width()
        #table.set_class("table")
        table.add_color('background', 'background2')
        #table.add_style('line-height','3.0em')
        #table.add_row(css='smaller')
        tr = table.add_row(css='smaller')
        tr.add_style('height', '3.5em')
        table.add_header("&nbsp;")
        table.add_header("&nbsp;")
        th = table.add_header("Instance")
        th.add_style('text-align: left')
        table.add_header(my.get_checkin())
        table.add_header("Sandbox")
        tr.add_color('background', 'background2', -15)

        # get session and handle case where there is no session
        my.session = SessionContents.get()
        if my.session == None:
            instance_names = []
            asset_codes = []
            node_names = []
        else:
            instance_names = my.session.get_instance_names()
            asset_codes = my.session.get_asset_codes()
            node_names = my.session.get_node_names()

        # get all of the possible assets based on the asset codes
        search = Search(my.search_type)
        search.add_filters("code", asset_codes)
        assets = search.get_sobjects()
        assets_dict = SObject.get_dict(assets, ["code"])

        if my.session:
            my.add("Current Project: <b>%s</b>" % my.session.get_project_dir())
        else:
            my.add("Current Project: Please press 'Introspect'")

        count = 0
        for i in range(0, len(node_names)):
            node_name = node_names[i]
            if not my.session.is_tactic_node(node_name) and \
                not my.session.get_node_type(node_name) in ['transform','objectSet']:
                continue
            instance_name = instance_names[i]

            # backwards compatible:
            try:
                asset_code = asset_codes[i]
            except IndexError, e:
                asset_code = instance_name

            # skip if this is a reference
            if my.list_references == False and \
                    my.session.is_reference(node_name):
                continue

            table.add_row()

            # check that this asset exists
            asset = assets_dict.get(asset_code)
            if not asset:
                continue

            # list items if it is a set
            if asset.get_value('asset_type',
                               no_exception=True) in ["set", "section"]:
                my.current_sobject = asset
                my.handle_set(table, instance_name, asset, instance_names)
                count += 1
            # if this asset is in the database, then allow it to checked in
            if asset:
                if my.session.get_snapshot_code(instance_name,
                                                snapshot_type='set'):
                    continue

                # hack remember this
                my.current_sobject = asset
                my.handle_instance(table, instance_name, asset, node_name)

            else:
                table.add_blank_cell()
                table.add_cell(instance_name)

            count += 1
Example #33
0
class ResizableTableWdg(BaseRefreshWdg):
    def __init__(self, **kwargs):
        self.table = Table()
        self.table.add_style("border-collapse: collapse")
        self.table.add_style("padding: 0px")
        self.table.set_attr("cellpadding", "0px")
        self.table.set_attr("cellspacing", "0px")
        self.is_first_row = True
        self.hilight = self.table.get_color("background", -40)
        super(ResizableTableWdg, self).__init__(**kwargs)


    def set_style(self, name, value=None):
        self.table.set_style(name, value)

    def set_max_width(self):
        self.table.set_max_width()

    def add_class(self, name):
        self.table.add_class(name)

    def get_display(self):
        top = self.top

        self.table.add_class("spt_resizable_table_top")


        self.table.add_behavior( {
        'type': 'load',
        'cbjs_action': self.get_onload_js()
        } )


        self.table.add_behavior( {
        'type': 'load',
        'cbjs_action': '''
        var resizable_cells = bvr.src_el.getElements(".spt_resizable_cell");
        for (var i = 0; i < resizable_cells.length; i++) {
            var resizable_el = resizable_cells[i].getElement(".spt_resizable");
            if (!resizable_el) {
                continue;
            }

            var size = resizable_cells[i].getSize();

            resizable_el.setStyle("width", size.x);
            resizable_el.setAttribute("width", size.x);
        }
        '''
        } )


        top.add(self.table)

        return top


    def set_keep_table_size(self):
        self.table.add_class("spt_resizable_keep_size")


    def add_color(self, color, modifier=0):
        self.table.add_color(color, modifier)

    def add_border(self, modifier=0):
        self.table.add_border(modifier=modifier)

    def add_style(self, name, value=None):
        self.table.add_style(name, value=value)




    def add_row(self, resize=True):

        # add resize row
        if not self.is_first_row and resize == True:
            tr, td = self.table.add_row_cell()
            td.add_style("height: 3px")
            td.add_style("min-height: 3px")
            td.add_style("cursor: n-resize")

            tr.add_behavior( {
            'type': 'drag',
            'cb_set_prefix': 'spt.resizable_table.row_drag'
            } )

            tr.add_behavior( {
            'type': 'hover',
            'hilight': self.hilight,
            'cbjs_action_over': '''
            var color = bvr.src_el.getStyle("background-color");
            bvr.src_el.setStyle("background-color", bvr.hilight);
            bvr.src_el.setAttribute("spt_last_background", color);
            ''',
            'cbjs_action_out': '''
            var color = bvr.src_el.getAttribute("spt_last_background");
            bvr.src_el.setStyle("background-color", color);
            '''
            } )

            icon = IconWdg("Drag to Resize", IconWdg.RESIZE_VERTICAL)
            td.add(icon)
            td.add_style("text-align: center")

        content_tr = self.table.add_row()

        self.is_first_row = False
 
        return content_tr


    def add_resize_row(self):
        tr, td = self.table.add_row_cell()
        td.add_style("height: 3px")
        td.add_style("min-height: 3px")
        td.add_style("cursor: n-resize")

        tr.add_behavior( {
        'type': 'drag',
        'cb_set_prefix': 'spt.resizable_table.row_drag'
        } )

        tr.add_behavior( {
        'type': 'hover',
        'hilight': self.hilight,
        'cbjs_action_over': '''
        var color = bvr.src_el.getStyle("background-color");
        bvr.src_el.setStyle("background-color", bvr.hilight);
        bvr.src_el.setAttribute("spt_last_background", color);
        ''',
        'cbjs_action_out': '''
        var color = bvr.src_el.getAttribute("spt_last_background");
        bvr.src_el.setStyle("background-color", color);
        '''
        } )
        icon = IconWdg("Drag to Resize", IconWdg.RESIZE_VERTICAL)
        td.add(icon)

        return tr, td


    def add_cell(self, widget=None, resize=True, rowspan=1, colspan=1):
        td_content = self.table.add_cell()
        td_content.add_style("vertical-align: top")
        td_content.add_class("spt_resizable_cell")

        if rowspan > 1:
            td_content.add_attr("rowspan", rowspan+1)
        if colspan > 1:
            td_content.add_attr("colspan", colspan+1)



        if not resize:
            return td_content

        # add resize cell
        td = self.table.add_cell()
        td.add_style("width: 4px")
        td.add_style("min-width: 4px")
        td.add_style("cursor: e-resize")

        icon_div = DivWdg()
        icon_div.add_style("width: 4px")
        icon_div.add_style("overflow: hidden")
        icon = IconWdg("Drag to Resize", IconWdg.RESIZE_HORIZ)
        icon_div.add(icon)
        td.add(icon_div)

        td.add_style("vertical-align: middle")

        td.add_behavior( {
        'type': 'drag',
        'cb_set_prefix': 'spt.resizable_table.cell_drag'
        } )


        td.add_behavior( {
        'type': 'hover',
        'hilight': self.hilight,
        'cbjs_action_over': '''
        var color = bvr.src_el.getStyle("background-color");
        bvr.src_el.setStyle("background-color", bvr.hilight);
        bvr.src_el.setAttribute("spt_last_background", color);
        ''',
        'cbjs_action_out': '''
        var color = bvr.src_el.getAttribute("spt_last_background");
        bvr.src_el.setStyle("background-color", color);
        '''
        } )


        if rowspan > 1:
            td.add_attr("rowspan", rowspan+1)
        if colspan > 1:
            td.add_attr("colspan", colspan+1)



        if widget:
            td_content.add(widget)

        
        return td_content


    def get_onload_js(self):
        return r'''
Example #34
0
    def get_new_custom_widget(my, search_type, view):

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

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


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

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

        div.add("<br/>")

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


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

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

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

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

        div.add(custom_table)

        return div
Example #35
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 #36
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 #37
0
    def get_display(self):

        # get all of the options
        direction = self.get_option("direction")
        if not direction:
            direction = "dst"

        icon_size = self.get_option("icon_size")
        if not icon_size:
            icon_size = 60

        src_sobject = self.get_current_sobject()
        dst_sobjects = []

        if isinstance(src_sobject, SObjectConnection):
            connection = src_sobject

            dst_sobject = connection.get_sobject(direction)
            src_sobject = connection.get_sobject(direction="src")

            connections = [connection]
            dst_sobjects = [dst_sobject]
        else:
            connections, dst_sobjects = SObjectConnection.get_connected_sobjects(src_sobject, direction)


        div = DivWdg()
        div.set_id("connection_%s" % src_sobject.get_id() )

        # set the ajax options
        self.set_ajax_top(div)
        self.set_ajax_option("search_key", src_sobject.get_search_key() )
        self.register_cmd("pyasm.widget.SObjectConnectionRemoveCbk")

        table = Table()
        table.set_max_width()
        table.set_class("minimal")
        count = 0
        for dst_sobject in dst_sobjects:
            tr = table.add_row()
            if not dst_sobject:
                table.add_cell("referenced to retired or deleted asset....")
                continue
            if dst_sobject.is_retired():
                tr.add_class("retired_row")

            thumb = ThumbWdg()
            thumb.set_show_filename(True)

            thumb.set_icon_size(icon_size)
            thumb.set_sobject(dst_sobject)
            td = table.add_cell(thumb)
            td.add_style("padding: 1px")
            td.add_style("width: 20%")

            id = dst_sobject.get_id()
            name = dst_sobject.get_name()
            code = dst_sobject.get_code()
            if code == str(id):
                pass 
            elif name == code:
                td = table.add_cell(name)
                td.add_style("width: 20%")
            else:
                td = table.add_cell("%s<br/>%s" % (name,code) )
                td.add_style("width: 20%")
            if dst_sobject.has_value("title"):
                td = table.add_cell(dst_sobject.get_value("title") )
            elif dst_sobject.has_value("description"):
                td = table.add_cell(dst_sobject.get_value("description") )
                if dst_sobject.has_value("keywords"):
                     table.add_cell(dst_sobject.get_value("keywords") )
            
            # remove connection
            connection = connections[count]
            connection_id = connection.get_id()
            self.set_ajax_option("connection_id", connection_id )
            refresh_script = self.get_refresh_script(False)

            remove = IconButtonWdg("Remove Connection", IconWdg.DELETE)
            remove.add_event("onclick", refresh_script)

            table.add_cell(remove)

            count += 1

        div.add(table)
        return div
Example #38
0
    def get_display(self):

        # get all of the options
        direction = self.get_option("direction")
        if not direction:
            direction = "dst"

        icon_size = self.get_option("icon_size")
        if not icon_size:
            icon_size = 60

        src_sobject = self.get_current_sobject()
        dst_sobjects = []

        if isinstance(src_sobject, SObjectConnection):
            connection = src_sobject

            dst_sobject = connection.get_sobject(direction)
            src_sobject = connection.get_sobject(direction="src")

            connections = [connection]
            dst_sobjects = [dst_sobject]
        else:
            connections, dst_sobjects = SObjectConnection.get_connected_sobjects(
                src_sobject, direction)

        div = DivWdg()
        div.set_id("connection_%s" % src_sobject.get_id())

        # set the ajax options
        self.set_ajax_top(div)
        self.set_ajax_option("search_key", src_sobject.get_search_key())
        self.register_cmd("pyasm.widget.SObjectConnectionRemoveCbk")

        table = Table()
        table.set_max_width()
        table.set_class("minimal")
        count = 0
        for dst_sobject in dst_sobjects:
            tr = table.add_row()
            if not dst_sobject:
                table.add_cell("referenced to retired or deleted asset....")
                continue
            if dst_sobject.is_retired():
                tr.add_class("retired_row")

            thumb = ThumbWdg()
            thumb.set_show_filename(True)

            thumb.set_icon_size(icon_size)
            thumb.set_sobject(dst_sobject)
            td = table.add_cell(thumb)
            td.add_style("padding: 1px")
            td.add_style("width: 20%")

            id = dst_sobject.get_id()
            name = dst_sobject.get_name()
            code = dst_sobject.get_code()
            if code == str(id):
                pass
            elif name == code:
                td = table.add_cell(name)
                td.add_style("width: 20%")
            else:
                td = table.add_cell("%s<br/>%s" % (name, code))
                td.add_style("width: 20%")
            if dst_sobject.has_value("title"):
                td = table.add_cell(dst_sobject.get_value("title"))
            elif dst_sobject.has_value("description"):
                td = table.add_cell(dst_sobject.get_value("description"))
                if dst_sobject.has_value("keywords"):
                    table.add_cell(dst_sobject.get_value("keywords"))

            # remove connection
            connection = connections[count]
            connection_id = connection.get_id()
            self.set_ajax_option("connection_id", connection_id)
            refresh_script = self.get_refresh_script(False)

            remove = IconButtonWdg("Remove Connection", IconWdg.DELETE)
            remove.add_event("onclick", refresh_script)

            table.add_cell(remove)

            count += 1

        div.add(table)
        return div
Example #39
0
    def get_display(self):

        # get all of the options
        direction = self.get_option("direction")
        if not direction:
            direction = "dst"
        

        icon_size = self.get_option("icon_size")
        if not icon_size:
            icon_size = 60
        try:
            sobject = self.get_current_sobject()
        except IndexError:
            return ''
        if not hasattr(self, 'info'):
            return ''
        
        connections, dst_sobjects, sobj = self.info.get(sobject.get_search_key())
      
        src_sobject = sobject

        # may not need this due to preprocess
        if isinstance(src_sobject, SObjectConnection):
            connection = src_sobject
            src_sobject = connection.get_sobject(direction="src")


        div = DivWdg()
        div.set_id("connection_%s" % src_sobject.get_id() )

        # set the ajax options
        self.set_ajax_top(div)
        self.set_ajax_option("search_key", src_sobject.get_search_key() )
        self.register_cmd("pyasm.widget.SObjectConnectionRemoveCbk")

        table = Table()
        table.set_max_width()
        table.set_class("minimal")
        count = 0
        
        for dst_sobject in dst_sobjects:
            tr = table.add_row()
            if not dst_sobject:
                table.add_cell("referenced to retired or deleted asset....")
                continue
            if dst_sobject.is_retired():
                tr.add_class("retired_row")

            thumb = ThumbWdg()
            thumb.set_show_filename(True)
            thumb.set_show_orig_icon(True) 
            thumb.set_icon_size(icon_size)
            thumb.set_sobject(dst_sobject)
            td = table.add_cell(thumb)
            td.add_style("padding: 1px")
            td.add_style("width: 20%")

            id = dst_sobject.get_id()
            name = dst_sobject.get_name()
            code = dst_sobject.get_code()
            if code == str(id):
                pass 
            elif name == code:
                td = table.add_cell(name)
                td.add_style("width: 20%")
            else:
                td = table.add_cell("%s<br/>%s" % (name,code) )
                td.add_style("width: 20%")

            if dst_sobject.has_value("title"):
                td = table.add_cell("%s" % dst_sobject.get_value("title") )
            elif dst_sobject.has_value("description"):
                td = table.add_cell("%s" % dst_sobject.get_value("description") )
                td.add_style("width: 30%")
            if dst_sobject.has_value("keywords"):

                td = table.add_cell("%s" % dst_sobject.get_value("keywords") )
                td.add_style("width: 20%")

            if dst_sobject.has_value("timestamp"):
                td = table.add_cell("%s" % Date(dst_sobject.get_value("timestamp")).get_display_time() )
                td.add_style("width: 20%")

            update = UpdateWdg()
            update.set_sobject(dst_sobject)
            update.set_option('delete', 'false')
            table.add_cell(update)
             
            # remove connection
            connection = connections[count]
            connection_id = connection.get_id()
            self.set_ajax_option("connection_id", connection_id )
            refresh_script = self.get_refresh_script(False)

            remove = IconButtonWdg("Remove Connection", IconWdg.DELETE)
            remove.add_event("onclick", refresh_script)

            table.add_cell(remove)

            count += 1

        div.add(table)
        return div
Example #40
0
    def get_display(my):

        search_key = my.kwargs.get("search_key")
        path = my.kwargs.get("path")
        parser_str = my.kwargs.get("parser")
        use_tactic_tags = my.kwargs.get("use_tactic_tags")


        from pyasm.checkin import PILMetadataParser, ImageMagickMetadataParser, ExifMetadataParser, BaseMetadataParser
        if parser_str:
            parser = BaseMetadataParser.get_parser(parser_str, path)
        else:
            parser = BaseMetadataParser.get_parser_by_path(path)

        if parser:
            if use_tactic_tags in ['true', True]:
                metadata = parser.get_tactic_metadata()
            else:
                metadata = parser.get_metadata()
        else:
            metadata = {}


        top = my.top
        top.add_color("background", "background")


        table = Table()
        table.set_max_width()
        top.add(table)
        table.set_unique_id()
        table.add_border()

        table.add_smart_styles("spt_cell", {
            'padding': '3px'
        } )



        tr = table.add_row()
        tr.add_gradient("background", "background3")
        th = table.add_header("Property")
        th.add_style("min-width: 200px")
        th.add_style("padding: 5px")
        th = table.add_header("Value")
        th.add_style("min-width: 400px")
        th.add_style("padding: 5px")

        keys = metadata.get("__keys__")
        if not keys:
            keys = metadata.keys()

        empty = False
        if not keys:
            empty = True
            keys = ['','','','','','','']
            table.add_smart_styles("spt_cell", {
                'height': '20px'
            } )


        for i, key in enumerate(keys):
            value = metadata.get(key)

            title = Common.get_display_title(key)

            tr = table.add_row()

            if i % 2:
                tr.add_color("background", "background")
                tr.add_color("color", "color")
            else:
                tr.add_color("background", "background", -8)
                tr.add_color("color", "color")

            td = table.add_cell()
            td.add_class("spt_cell")
            td.add(title)

            td = table.add_cell()
            td.add_class("spt_cell")

            if len(str(value)) > 500:
                inside = DivWdg()
                td.add(inside)
                value = value[:500]
                inside.add(value)
                inside.add_style("max-width: 600px")
            else:
                td.add(value)


        if empty:
            div = DivWdg()
            top.add(div)
            div.add_style("height: 30px")
            div.add_style("width: 150px")
            div.add_style("margin-top: -110px")
            div.center()
            div.add("<b>No Metadata</b>")
            div.add_border()
            div.add_color("background", "background3")
            div.add_color("color", "color3")
            div.add_style("padding: 20px")
            div.add_style("text-align: center")

            top.add_style("min-height: 200px")

        return top
Example #41
0
    def get_new_custom_widget(self, search_type, view):

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

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

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

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

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

        div.add("<br/>")

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

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

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

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

        div.add(custom_table)

        return div
Example #42
0
    def get_item_wdg(self, sobject):

        self.element_names = self.kwargs.get("element_names")
        if not self.element_names:
            self.element_names = ["preview","code","name","description",]
        else:
            self.element_names = self.element_names.split(",")

        if self.element_names[0] == "preview":
            has_preview = True
            self.element_names = self.element_names[1:]
        else:
            has_preview = False

        view = self.kwargs.get("view")
        if not view:
            view = "table"
        from pyasm.widget import WidgetConfigView
        search_type = sobject.get_search_type()
        self.config = WidgetConfigView.get_by_search_type(search_type, view)



        div = DivWdg()
        div.add_class("spt_item_top")
        div.add_style("padding: 10px")
        SmartMenu.assign_as_local_activator( div, 'DG_DROW_SMENU_CTX' )
        #div.add_class("spt_table_row")
        #div.add_class("spt_table_row_%s" % self.table_id)
        div.add_attr("spt_search_key", sobject.get_search_key(use_id=True))
        div.add_attr("spt_search_code", sobject.get_code())
        name = sobject.get_value("name", no_exception=True)
        if not name:
            name = sobject.get_code()
        div.add_attr("spt_name", name)

        table = Table()

        div.add(table)
        table.set_max_width()
        tr = table.add_row()

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

        if has_preview:
            td = table.add_cell()
            td.add_style("width: %s" % width);
            td.add_style("vertical-align: top")

            options = self.config.get_display_options("preview")
            redirect_expr = options.get("redirect_expr")
            if redirect_expr:
                parent = Search.eval(redirect_expr, sobject, single=True)
                #parent = sobject.get_parent()
                tile_wdg = self.tile_layout.get_tile_wdg(parent)
            else:
                tile_wdg = self.tile_layout.get_tile_wdg(sobject)

            td.add(tile_wdg)

        info_div = self.get_info_wdg(sobject)
        td = table.add_cell(info_div)
        td.add_style("vertical-align: top")


        return div
Example #43
0
    def get_display(my):
        # specially made for "load" view
        if not my.view.endswith("load"):
            return DivWdg()



        widget = Widget()
        # first use
        filter_top = DivWdg(css="maq_search_bar")
        filter_top.add_color("background", "background2", -15)

        # so dg_table.search_cbk will obtain values from this widget
        filter_top.add_class('spt_table_search')
        filter_top.add_style("padding: 3px")

        # this is used by get_process() in LoaderWdg
        filter_top.add(HiddenWdg('prefix', 'view_action_option'))

        for name, value in my.kwargs.items():
            filter_top.set_attr("spt_%s" % name, value)


        from tactic.ui.cgapp import SObjectLoadWdg, LoaderButtonWdg, LoaderElementWdg, IntrospectWdg

        # this contains the process filter and load options
        sobject_load = SObjectLoadWdg(search_type=my.search_type, load_options_class = my.load_options_class)
        filter_top.add(sobject_load)

       

        # set the process
        #class foo:
        #    def get_value(my):
        #        return "texture"
        #Container.put("process_filter", foo())

        filter_top.add( HtmlElement.br() )

        table = Table()
        table.add_class('spt_action_wdg')

        table.set_max_width()
        td = table.add_cell()       
     
        # create the loader button
        button = LoaderButtonWdg()


        # -------------
        # test an event mechanism
        event_name = '%s|load_snapshot' % my.search_type
        #event_name = 'load_snapshot'

        # get triggers with this event
        from pyasm.search import Search
        search = Search("config/client_trigger")
        search.add_filter("event", event_name)
        triggers = search.get_sobjects()

        if triggers:
            for trigger in triggers:
                #callback = trigger.get_value("custom_script_code")
                callback = trigger.get_value("callback")

                event_script = '''
                spt.app_busy.show("Loading ...", "Loading selected [%s] in to session");
                var script = spt.CustomProject.get_script_by_path("%s");
                bvr['script'] = script;
                spt.CustomProject.exec_custom_script(evt, bvr);
                spt.app_busy.hide();
                ''' % (my.search_type, callback)

                loader_script = '''spt.named_events.fire_event('%s', {})''' % event_name
                table.add_behavior( {
                    'type': 'listen',
                    'event_name': event_name,
                    'cbjs_action': event_script
                } )

        # test a passed in script path
        elif my.load_script_path:

            # an event is called
            event_name = 'load_snapshot'
            event_script = '''var script = spt.CustomProject.get_script_by_path("%s");spt.CustomProject.exec_script(script)''' % my.load+script_path

            loader_script = '''spt.named_events.fire_event('%s', {})''' % event_name
            table.add_behavior( {
                'type': 'listen',
                'event_name': event_name,
                'cbjs_action': event_script
            } )

        # end test
        # ---------------



        elif my.load_script:
            loader_script = my.load_script
        else:
            loader_script = LoaderElementWdg.get_load_script(my.search_type)

        #print LoaderElementWdg.get_load_script(my.search_type)
        
        # add the introspect button
        introspect_button = IntrospectWdg()
        introspect_button.add_style('float: left')
        introspect_button.add_style('margin-bottom: 6px')
        td.add(introspect_button)

        # to be attached
        smart_menu = LoaderElementWdg.get_smart_menu(my.search_type)
        button.set_load_script(loader_script)
        button.set_smart_menu(smart_menu)

        td.add(button)
        td.add_style('text-align','right')
        td.add_style('padding-right', '40px') 
        widget.add(filter_top)
        widget.add( HtmlElement.br() )
        widget.add(table)

        return widget