Exemplo n.º 1
0
    def get_display(self):
        div = DivWdg()
        div.add_class( "spt_view_manager_top" )
        self.set_as_panel(div)

        if not self.search_type or not self.view:
            return div



        div.add( self.get_action_wdg() )

        div.add(HtmlElement.br(2))

        tool_bar = self.get_tool_bar()
        div.add(tool_bar)
 
        div.add(HtmlElement.br())


        # add the template view containing the possible items to be added
        # ie: New Folder, New Entry, New Separator
        menu_div = DivWdg()
        menu_div.set_id("menu_item_template")
        menu_div.add_style("display: none")
        menu_div.add( self.get_section_wdg("_template", editable=False) )
        div.add(menu_div)


        table = Table()
        table.add_row()

        # add the section
        td = table.add_cell()
        project_view = DivWdg()
        project_view.set_id("menu_item_list")
        project_view.add( self.get_section_wdg(self.view ))
        td.add(project_view)
        td.add_style("vertical-align: top")
        #td.add_attr("rowspan", "2")

        tool_bar = self.get_tool_bar()
        td.add(tool_bar)

        td.add("<br/>")

        # add detail information
        td = table.add_cell( self.get_detail_wdg() )


        # FIXME: get rid of hard coded classes
        # set the panel information
        td.set_id("manage_side_bar_detail")
        td.add_class("spt_view_manager_detail")
        td.add_style("display", "table-cell")
        td.add_attr("spt_class_name", "tactic.ui.panel.ManageSideBarDetailWdg")
        td.add_attr("spt_search_type", self.search_type)

        td.add_style("padding: 0 20px 20px 20px")
        td.add_style("vertical-align: top")


        div.add(table)
        return div
Exemplo n.º 2
0
    def get_error_wdg(my):
        div = DivWdg()

        error_div = DivWdg()
        error_div.add("Error %s - Permission Denied" % my.status)
        div.add(error_div)
        error_div.add_style("font-size: 16px")
        error_div.add_style("font-weight: bold")
        error_div.add_style("width: 97%")
        error_div.add_gradient("background", "background")
        error_div.add_border()
        error_div.add_style("margin-left: 5px")
        error_div.add_style("margin-top: -10px")

        div.add("<br/>")

        span = DivWdg()
        #span.add_color("color", "color")
        span.add_style("color", "#FFF")
        if my.status == 403:
            span.add(
                "<b>You have tried to access a url that is not permitted.</b>")
        else:
            span.add(HtmlElement.b(my.message))
        span.add(HtmlElement.br(2))

        web = WebContainer.get_web()
        root = web.get_site_root()

        span.add("Go back to the Main page for a list of valid projects")
        div.add(span)
        div.add(HtmlElement.br())

        table = Table()
        div.add(table)
        table.add_row()
        table.add_style("margin-left: auto")
        table.add_style("margin-right: auto")

        from tactic.ui.widget import ActionButtonWdg
        button = ActionButtonWdg(title="Go to Main",
                                 tip='Click to go to main page')
        table.add_cell(button)
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        document.location = '/projects';
        '''
        })
        button.add_style("margin-left: auto")
        button.add_style("margin-right: auto")

        button = ActionButtonWdg(title="Sign Out", tip='Click to Sign Out')
        table.add_cell(button)
        button.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='%s';
        ''' % root
        })
        button.add_style("margin-left: auto")
        button.add_style("margin-right: auto")

        return div
Exemplo n.º 3
0
    def get_display(my):
        top = my.top
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_style("width", "400px")
        top.add_border()
        top.add_class("spt_delete_project_tool_top")

        project_code = my.kwargs.get("project_code")
        if project_code:
            project = Project.get_by_code(project_code)
        else:
            search_key = my.kwargs.get("search_key")
            project = Search.get_by_search_key(search_key)
            if project:
                project_code = project.get_code()

        title_wdg = DivWdg()

        if project:
            top.add(title_wdg)
            title_wdg.add(IconWdg(icon=IconWdg.WARNING))
            title_wdg.add("Deleting Project: %s" % project.get_value("title"))
            title_wdg.add_gradient("background", "background", -10, -10)
            title_wdg.add_style("padding: 5px")
            title_wdg.add_style("font-weight: bold")
            title_wdg.add_style("font-size: 14px")

        content = DivWdg()
        top.add(content)
        content.add_style("padding: 10px")

        if not search_key:
            warning_msg = "Projects must be deleted individually"
            content.add(DivWdg(warning_msg, css='warning'))
            content.add("<br/>")
            return top

        warning_msg = "Deleting a project will delete the database associated with this project.  All data will be lost.  Please consider carefully before proceeding."
        if warning_msg:
            content.add(DivWdg(warning_msg, css='warning'))
            content.add("<br/>")

        if not project_code:
            content.add("This project [%s] has been deleted." % search_key)
            return top
        elif not project:
            content.add("This project [%s] has been deleted." % project_code)
            return top

        assert project_code
        assert project

        content.add("<br/>")

        content.add(
            "<b>WARNING: These items will be deleted, but the sTypes entries in search_objects table will be retained.</b> "
        )

        content.add("<br/>")
        content.add("<br/>")

        total_items_wdg = DivWdg()
        total_items = 0
        content.add(total_items_wdg)

        # find all of the sTypes
        details_wdg = DivWdg()
        content.add(details_wdg)
        details_wdg.add_style("max-height: 300px")
        details_wdg.add_style("overflow-y: auto")
        details_wdg.add_style("padding-left: 15px")
        details_wdg.add_border()

        search_types = project.get_search_types()

        related_types = []

        for search_type_obj in search_types:
            search_type_wdg = DivWdg()
            title = search_type_obj.get_title()
            search_type = search_type_obj.get_value("search_type")

            search_type_wdg.add_style("margin-top: 5px")
            search_type_wdg.add_style("margin-bottom: 5px")

            details_wdg.add(search_type_wdg)
            search_type_wdg.add(title)
            search_type_wdg.add(" (%s)" % search_type)

            search = Search(search_type, project_code=project_code)
            count = search.get_count()
            total_items += count
            search_type_wdg.add("&nbsp; - &nbsp; %s item(s)" % count)

            # TODO: this is similar to SearchType.get_related_types(). streamline at some point.
            related_types = my.get_related_types(search_type)
            for related_type in related_types:

                search = Search(related_type)
                full_search_type = "%s?project=%s" % (search_type,
                                                      project_code)
                if related_type.startswith("sthpw/"):
                    search.add_filter("search_type", full_search_type)
                count = search.get_count()
                if count == 0:
                    continue
                total_items += count

                related_wdg = DivWdg()
                related_wdg.add_style('padding-left: 25px')
                search_type_wdg.add(related_wdg)
                related_wdg.add(related_type)
                related_wdg.add("&nbsp; - &nbsp; %s item(s)" % count)

        if total_items:
            total_items_wdg.add("Total # of items to be deleted: ")
            total_items_wdg.add(total_items)
            total_items_wdg.add_style("font-size: 14px")
            total_items_wdg.add_style("font-weight: bold")
            total_items_wdg.add("<br/>")

        content.add("<br/>" * 2)
        content.add("<b>Do you wish to continue deleting? </b>")
        radio = RadioWdg("mode")
        radio.add_class("spt_mode_radio")
        radio.set_value("delete")
        content.add(radio)
        content.add("<br/>" * 2)

        #content.add("<b>Or do you just wish to retire the project? </b>")
        #radio = RadioWdg("mode")
        #radio.add_class("spt_mode_radio")
        #radio.set_value("retire")
        #content.add(radio)
        #content.add(radio)

        #content.add("<br/>"*2)

        #button = ActionButtonWdg(title="Retire")
        #content.add(button)
        #button.add_style("float: left")

        buttons = Table()
        content.add(buttons)
        buttons.add_row()
        buttons.add_style("margin-left: auto")
        buttons.add_style("margin-right: auto")
        buttons.add_style("width: 250px")

        button = ActionButtonWdg(title="Delete")
        buttons.add_cell(button)

        button.add_behavior({
            'type':
            'click_up',
            #'search_type': search_type,
            'project_code':
            project_code,
            'related_types':
            related_types,
            'cbjs_action':
            '''
            spt.app_busy.show("Deleting");
            var class_name = "tactic.ui.tools.DeleteProjectCmd";
            var kwargs = {
                'project_code': bvr.project_code,
                'related_types': bvr.related_types
            };

            var top = bvr.src_el.getParent(".spt_delete_project_tool_top");
            var radios = top.getElements(".spt_mode_radio");

            //if (!radios[0].checked && !radios[1].checked) {
            if (!radios[0].checked) {
                spt.alert("Please confirm the delete by checking the radio button.");
                spt.app_busy.hide();
                return;
            }

            var mode = 'retire';
            if (radios[0].checked == true) {
                mode = 'delete';
            }


            if (mode == 'retire') {
                return;
            }



            var success = false;
            var server = TacticServerStub.get();
            setTimeout(function() {
                spt.app_busy.show("Deleting Project ["+bvr.project_code+"]")
                var error_message = "Error deleting project ["+bvr.project_code+"]";
                try {
                    server.start({'title': 'Deleted Project ', 'description': 'Deleted Project [' + bvr.project_code + ']'});
                    server.execute_cmd(class_name, kwargs);
                    success = true;

                    var top = bvr.src_el.getParent(".spt_popup");
                    spt.popup.destroy(top);
                    server.finish();
                }
                catch(e) {
                    error_message = spt.exception.handler(e);
                }

                
                spt.app_busy.hide();

                if (success) {
                    spt.notify.show_message("Successfully deleted project ["+bvr.project_code+"]");

                    spt.tab.set_main_body_tab();
                    spt.tab.reload_selected();
                }
                else {
                    if (error_message.test(/does not exist/))
                        error_message += '. You are advised to sign out and log in again.';
                    spt.error(error_message);
                }
            }, 100);
       
        '''
        })

        button = ActionButtonWdg(title="Cancel")
        buttons.add_cell(button)
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        var top = bvr.src_el.getParent(".spt_popup");
        spt.popup.destroy(top);
        '''
        })

        return top
Exemplo n.º 4
0
    def get_display(my):
        
        # my.sobjects is preferred, otherwise use
        # search_key.
        search_key = my.kwargs.get('search_key')
        if not my.sobjects and search_key:
            message = Search.get_by_search_key(search_key)
        elif my.sobjects:
            message = my.sobjects[0]
        
        if message.get_search_type() == 'sthpw/message':
            message_code = message.get_value("code")
        else:
            message_code = message.get_value("message_code")

        category = message.get_value("category")
        table = Table()
        table.add_row()
        td = table.add_cell()

        subscription = my.kwargs.get('subscription')
        show_preview = my.kwargs.get('show_preview')
        if show_preview in ['',None]:
            show_preview = True
        show_preview_category_list = ['sobject','chat']

        if (category in show_preview_category_list and show_preview not in ['False','false',False]) or show_preview in ["True" ,"true",True]:  
            td.add( my.get_preview_wdg(subscription, category=category, message_code=message_code ))
    
        message_value = message.get_value("message")
        message_login = message.get_value("login")

        #TODO: implement short_format even for closing html tags properly while truncating 
        short_format = my.kwargs.get('short_format') in  ['true', True]
        if message_value.startswith('{') and message_value.endswith('}'):

            #message_value = message_value.replace(r"\\", "\\");
            message_value = jsonloads(message_value)
            # that doesn't support delete
            
            if category == "sobject":
                update_data = message_value.get("update_data")
                sobject_data = message_value.get("sobject")
                sobject_code = sobject_data.get('code')
                search_type = message_value.get("search_type")
                if search_type == "sthpw/note":
                    description = "<b>Note added:</b><br/>%s" % update_data.get("note")
                elif search_type == "sthpw/task":
                    description = "<b>Task modified:</b><br/>%s" % update_data.get("process")
                elif search_type == "sthpw/snapshot":
                    sobject = message_value.get("sobject")
                    description = "<b>Files checked in:</b><br/>%s" % sobject.get("process")
                else:
                    display = []
                    if update_data:
                        for key, val in update_data.items():
                            display.append('%s &ndash; %s'%(key, val))
                    else:
                        if message_value.get('mode') == 'retire':
                            display.append('Retired')

                    base_search_type = Project.extract_base_search_type(search_type)
                    
                    description = DivWdg()
                    title = DivWdg("<b>%s</b> - %s modified by %s:"%(base_search_type, sobject_code, message_login))
                    title.add_style('margin-bottom: 6px')
                    content = DivWdg()
                    content.add_style('padding-left: 2px')
                    content.add('<br>'.join(display))
                    description.add(title)
                    description.add(content)

            elif category == 'progress':
                description = DivWdg()
                message = message_value.get('message')
                message_div = DivWdg()
                message_div.add(message)
                description.add(message_div)

                percent = message_value.get('progress')
                if not percent:
                    percent = 0.0
                progress = HtmlElement('progress')
                progress.add_attr('value', percent)
                progress.add_attr('max', '100')
                progress.add_styles('''width: 280px; border-radius: 8px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.75) inset''')
                
                progress_size = my.kwargs.get("progress_size")
                if progress_size == "large":
                    progress.add_styles("height: 16px; margin-top: 9px;")
                else:
                    progress.add_styles("height: 5px; margin-top: 4px;")

                description.add(progress)


            else:
                message = message_value.get('message')
                if message:
                    description = message
                else:
                    description = message_value.get("description")


        else:

            if category == "chat":
                login = message.get("login")
                timestamp = message.get("timestamp")

                message_value = message.get("message")
                message_value = message_value.replace("\n", "<br/>")

                description = '''
                <b>%s</b><br/>
                %s
                ''' % (login, message_value)
            else:
                description = message_value
        
        div = DivWdg()
        div.add(description)
        table.add_cell(div)
        return table
Exemplo n.º 5
0
    def get_category_wdg(my, category, mode="new"):

        subscriptions = my.get_subscriptions(category, mode)
        if not subscriptions:
            return

        div = DivWdg()
        div.add_style("width: 100%")

        title_div = DivWdg()
        div.add(title_div)
        title_div.add_style("padding: 10px")
        title_div.add_border()
        title_div.add_color("background", "background3")
        title = category or "Subscriptions"
        title_div.add("%s " % title)
        

        summary_div = SpanWdg()
        title_div.add(summary_div)
        summary_div.add_style("font-size: 0.8em")
        summary_div.add_style("opacity: 0.5")


        search_keys = [x.get_search_key() for x in subscriptions]
        button = ActionButtonWdg(title="Clear All")
        button.add_styles('float: right; padding: 2px')
        button_div = DivWdg(button)
        button_div.add_style('min-height: 26px')
        div.add(button_div)

        button.add_behavior( {
            'type': 'click_up',
            'search_keys': search_keys,
            'cbjs_action': '''
            var server = TacticServerStub.get();
            for (var i = 0; i < bvr.search_keys.length; i++) {
                var search_key = bvr.search_keys[i];
                server.update(search_key, {'last_cleared':'NOW'});
            spt.panel.refresh(bvr.src_el);
            }
            '''
        } )



        # types of subscriptions
        table_div = DivWdg()
        table_div.add_styles('overflow-y: auto; max-height: 500px; width: 100%')
        div.add(table_div)
        table = Table()
        table.add_style('width: 100%')
        table.add_border()
        table.add_color("background", "background3")

        
        table_div.add(table)
        ss = []
        for subscription in subscriptions:
            table.add_row()
            td = table.add_cell()

            message_code = subscription.get_value("message_code")
            search = Search("sthpw/message")
            search.add_filter("code", message_code)
            message = search.get_sobject()

            # show the thumb
            if not message:
                if mode == "all":
                    td = table.add_cell(FormatMessageWdg.get_preview_wdg(subscription))
                    td = table.add_cell()
                    td.add("No Messages")
                continue

            size = 60

            
            show_preview = my.kwargs.get('show_preview')
            if show_preview in ['',None]:
                show_preview = True

            msg_element = FormatMessageWdg(subscription=subscription, short_format='true',show_preview=show_preview)
            # this is optional
            msg_element.set_sobject(message)
            description = msg_element.get_buffer_display() 
          
            #td = table.add_cell()

            history_icon = IconButtonWdg(title="Subscription History", icon=IconWdg.HISTORY)
            #td.add(icon)
            message_code = subscription.get_value("message_code")
            history_icon.add_behavior( {
                'type': 'click_up',
                'message_code': message_code,
                'cbjs_action': '''
                var class_name = 'tactic.ui.panel.FastTableLayoutWdg';
                var message_code = bvr.message_code;
                var kwargs = {
                    search_type: 'sthpw/message_log',
                    show_shelf: false,
                    expression: "@SOBJECT(sthpw/message_log['message_code','"+message_code+"'])",
                    view: 'history'
                };
                spt.tab.set_main_body_tab();
                spt.tab.add_new("Message History", "Message History", class_name, kwargs);
                '''
            } )
 

            # description can take up 70%
            td = table.add_cell()
            td.add_style("width: %spx"%(SubscriptionBarWdg.WIDTH*0.7))

            desc_div = DivWdg()
            td.add(desc_div)
            desc_div.add(description)
            desc_div.add_style("padding: 0px 20px")

            td = table.add_cell()
            #td.add(message.get_value("status"))
            #td = table.add_cell()
            timestamp = message.get_datetime_value("timestamp")
            if timestamp:
                timestamp_str = timestamp.strftime("%b %d, %Y - %H:%M")
            else:
                timestamp_str = ""

            
            show_timestamp = my.kwargs.get('show_timestamp')
            if show_timestamp in ['',None]:
                show_timestamp = True

            if show_timestamp in ["True","true",True]:
                td.add(timestamp_str)

            #td = table.add_cell()
            #td.add(subscription.get_value("last_cleared"))

            td = table.add_cell()
            
            show_message_history = my.kwargs.get('show_message_history')
            if show_message_history in ['',None]:
                show_message_history = True
            if show_message_history in ["True","true",True]:
                td.add(history_icon)

            td.add(HtmlElement.br(2))
            td.add_style('width: 30px')
            icon = IconButtonWdg(title="Unsubscribe", icon=IconWdg.DELETE)
            icon.add_style('bottom: 14px')

            subscription_key = subscription.get_search_key()
            icon.add_behavior( {
                'type': 'click_up',
                'search_key': subscription_key,
                'message_code': message_code,
                'cbjs_action': '''
                    if (!confirm("Unsubscribe from [" + bvr.message_code + "]?")) {
                        return;
                    }
                    var top = bvr.src_el.getParent(".spt_subscription_top");
                    var server = TacticServerStub.get();
                    server.delete_sobject(bvr.search_key);
                    spt.panel.refresh(top);
                '''
            } )
            
            show_unsubscribe = my.kwargs.get('show_unsubscribe')
            if show_unsubscribe in ['',None]: 
                show_unsubscribe = False
            if show_unsubscribe in ["True","true",True]:
                td.add(icon)

            
            






            ss.append(subscription)

        num_sobjects = len(ss)
        if not num_sobjects:
            return None
        summary_div.add("(%s changes)" % num_sobjects)

        #from tactic.ui.panel import FastTableLayoutWdg
        #table = FastTableLayoutWdg(search_type="sthpw/subscription",show_shelf=False)
        #div.add(table)
        #table.set_sobjects(ss)


        return div
Exemplo n.º 6
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
Exemplo n.º 7
0
    def get_shelf_wdg(self):

        process = self.get_value("process")
        versions = self.get_value("versions")

        div = DivWdg()

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

        button = SingleButtonWdg(title="Refresh", icon=IconWdg.REFRESH)
        filter_table.add_cell(button)
        filter_table.add_cell("&nbsp;" * 5)
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            spt.panel.refresh(bvr.src_el);
            '''
        })

        # get all of the pipelnes for this search type
        pipeline_code = self.sobject.get_value("pipeline_code",
                                               no_exception=True)
        processes = []
        if pipeline_code:
            pipeline = Pipeline.get_by_code(pipeline_code)
            if pipeline:
                process_names = pipeline.get_process_names()
                processes.extend(process_names)

        processes.insert(0, "all")

        filter_table.add_cell("Process: ")
        select = SelectWdg("process")
        select.add_style("width: 200px")
        if process != 'all':
            select.set_value(process)

        select.set_option("values", processes)

        filter_table.add_cell(select)

        filter_table.add_cell("&nbsp;" * 10)

        filter_table.add_cell("Versions: ")
        select = SelectWdg("versions")
        select.add_style("width: 200px")
        select.set_option("values", "latest|current|today|last 10|all")
        if versions:
            select.set_value(versions)
        filter_table.add_cell(select)

        asset_dir = Environment.get_asset_dir()

        select = IconButtonWdg(tip="Toggle Selection",
                               icon=IconWdg.SELECT,
                               show_arrow=False)
        div.add(select)
        select.add_style("float: right")
        select.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top_class = 'spt_sobject_dir_list_top'
            var toggle_state = bvr.src_el.getAttribute('toggle');
            if (toggle_state && toggle_state=='true')
                bvr.src_el.setAttribute('toggle','false');
            else
                bvr.src_el.setAttribute('toggle','true');

            var top = bvr.src_el.getParent("."+top_class);
            spt.selection.set_top(top);
            
            toggle_state = bvr.src_el.getAttribute('toggle');
            if (toggle_state == 'true')
                spt.selection.select_all_items();
            else
                spt.selection.unselect_all_items();

            '''
        })

        show = IconButtonWdg(tip="Switch View",
                             icon=IconWdg.VIEW,
                             show_arrow=False)
        div.add(show)
        show.add_style("float: right")
        show.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top_class = 'spt_sobject_dir_list_top'
            var top = bvr.src_el.getParent("."+top_class);
            spt.selection.set_top(top);
            var els = top.getElements(".spt_file_dir_item");
            for (var i = 0; i < els.length; i++) {
                var el = els[i];
                if (el.getStyle("display") == "none") {
                    els[i].setStyle("display", "");
                }
                else {
                    els[i].setStyle("display", "none");
                }
            }
            var els = top.getElements(".spt_file_item");
            for (var i = 0; i < els.length; i++) {
                var el = els[i];
                if (el.getStyle("padding-left") == "6px") {
                    var padding = el.getAttribute("spt_padding_left");
                    el.setStyle("padding-left", padding);
                }
                else {
                    el.setStyle("padding-left", "6px");
                }

            }


            '''
        })

        gear = IconButtonWdg(tip="Download",
                             icon=IconWdg.DOWNLOAD,
                             show_arrow=False)
        div.add(gear)
        gear.add_style("float: right")
        gear.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            spt.app_busy.show('Select a folder to download to...','');
            var top_class = 'spt_sobject_dir_list_top';
            var top = bvr.src_el.getParent("."+top_class);
            spt.selection.set_top(top);
            var items = spt.selection.get_selected();
            
       
            setTimeout( function() {
                var applet = spt.Applet.get();
                var select_dir =true;
                var dir = applet.open_file_browser('', select_dir);
                if (dir.length == 0)
                    dir = applet.get_current_dir();
                else 
                    dir = dir[0];

                if (!dir) {
                    spt.alert("No folder selected to copy to.");
                    spt.app_busy.hide();
                    return;
                }
                if (items.length == 0){
                    spt.alert("Please select at least one file to download.");
                    spt.app_busy.hide();
                    return;
                }
                

                var asset_dir = '%s';
                for (var i = 0; i < items.length; i++) {
                    var path = items[i].getAttribute("spt_path");
                    var env = spt.Environment.get();
                    var server_url = env.get_server_url();
                    var url = server_url + "/assets/" + path.replace(asset_dir, "");
                    var parts = path.split("/");
                    var filename = parts[parts.length-1];
                    spt.app_busy.show("Downloading file", filename);
                    applet.download_file(url, dir + "/" + filename);
                }
                spt.app_busy.hide();
                if (dir)
                    spt.notify.show_message("Download to '" + dir + "' completed.")
            }, 100);

            ''' % asset_dir
        })

        return div
Exemplo n.º 8
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
Exemplo n.º 9
0
    def get_display(self):
        element_name = self.kwargs.get("element_name")
        element_id = self.kwargs.get("element_id")
        display_handler = self.kwargs.get("display_handler")
        display_options = self.kwargs.get("display_options")

        top = self.top
        top.add_class("spt_freeform_attr_top")
        top.add_style("padding: 10px")

        action_wdg = DivWdg()
        top.add(action_wdg)
        #action_wdg.add_gradient("background", "background", -10)

        delete = ActionButtonWdg(title='Remove', tip='Remove from Canvas')
        action_wdg.add(delete)
        delete.add_style("float: right")
        delete.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''

        var attr_top = bvr.src_el.getParent(".spt_freeform_attr_top");
        var values = spt.api.get_input_values(attr_top, null, false);
        var top = bvr.src_el.getParent(".spt_freeform_top");
        var canvas_top = top.getElement(".spt_freeform_canvas_top");
        var canvas = canvas_top.getElement(".spt_freeform_canvas");
        spt.freeform.init(canvas);

        var element_id = values.element_id;

        var element = null;
        var elements = spt.freeform.get_elements();
        for (var i = 0; i < elements.length; i++) {
            if ( elements[i].getAttribute("spt_element_id") == element_id) {
                element = elements[i];
            }
        }

        if (element == null) {
            alert("Element "+element_id+" does not exist on canvas");
            return;
        }

        element.destroy()
        '''
        })

        update = ActionButtonWdg(title='Update')
        action_wdg.add(update)

        update.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        var attr_top = bvr.src_el.getParent(".spt_freeform_attr_top");
        var values = spt.api.get_input_values(attr_top, null, false);
        var top = bvr.src_el.getParent(".spt_freeform_top");
        var canvas_top = top.getElement(".spt_freeform_canvas_top");
        var canvas = canvas_top.getElement(".spt_freeform_canvas");
        spt.freeform.init(canvas);

        var element_id = values.element_id;

        var element = null;
        var elements = spt.freeform.get_elements();
        for (var i = 0; i < elements.length; i++) {
            if ( elements[i].getAttribute("spt_element_id") == element_id) {
                element = elements[i];
            }
        }

        if (element == null) {
            alert("Element "+element_id+" does not exist on canvas");
            return;
        }

        element.setAttribute("spt_element_name", values["element_name"]);
        for (var name in values) {

            if (name.substr(0,3) == 'opt') {
                var parts = name.split("|");
                var attr_name = parts[1];
                var value = values[name];
                if (typeof(element.attrs) == 'undefined') {
                    element.attrs = {};
                }
                element.attrs[attr_name] = value;

            }
        }

        // set the values
        element.element_settings = values;

        // load the widget
        var class_name = values['xxx_option|display_class'];

        var kwargs = {};
        for (key in values) {
            var parts = key.split("|");
            if (parts[0] == 'option') {
                kwargs[parts[1]] = values[key];
            }

        }

        var server = TacticServerStub.get();
        var html = server.get_widget(class_name, {args: kwargs});

        var element_name = values['element_name'];
        var el = spt.freeform.get_element(element_name);
        var content = el.getElement(".spt_element_content");
        spt.behavior.replace_inner_html(content, html);




        '''
        })

        top.add("<hr/>")

        table = Table()
        top.add(table)
        table.add_color("color", "color")
        table.add_style("width: 100%")
        table.add_style("margin: 10px")

        table.add_row()
        td = table.add_cell()
        td.add("Name:")
        td.add_style("width: 150px")
        td = table.add_cell()
        #td.add(element_name)
        hidden = TextWdg("element_name")
        hidden.set_value(element_name)
        td.add(hidden)
        hidden = HiddenWdg("element_id")
        hidden.set_value(element_id)
        td.add(hidden)

        widget_key = ''
        display_class = display_handler

        from tactic.ui.manager import WidgetClassSelectorWdg

        class_labels = ['-- Class Path--']
        class_values = ['__class__']

        # add the widget information
        #class_labels = ['Raw Data', 'Formatted', 'Expression', 'Expression Value', 'Button', 'Link', 'Gantt', 'Hidden Row', 'Custom Layout', '-- Class Path --']
        #class_values = ['raw_data', 'format', 'expression', 'expression_value', 'button', 'link', 'gantt', 'hidden_row', 'custom_layout', '__class__']
        widget_class_wdg = WidgetClassSelectorWdg(
            widget_key=widget_key,
            display_class=display_class,
            display_options=display_options,
            class_labels=class_labels,
            class_values=class_values,
            prefix='option')
        top.add(widget_class_wdg)

        return top
Exemplo n.º 10
0
    def get_info_wdg(my):

        widget = Widget()

        table = Table()
        table.set_class("minimal")
        table.add_style("font-size: 0.8em")

        context_option = my.kwargs.get('context')
        context_expr_option = my.kwargs.get('context_expr')

        pipeline_option = my.kwargs.get('pipeline') in ['true', True, 'True']
        setting_option = my.kwargs.get('setting')
        context_name = "%s|context" % my.get_input_name()
        text = None
        span1 = SpanWdg("Context", id='context_mode')
        span2 = SpanWdg("Context<br/>/Subcontext", id='subcontext_mode')
        span2.add_style('display', 'none')
        table.add_cell(span1)
        table.add_data(span2)
        if context_expr_option or context_option or setting_option:
            # add swap display for subcontext only if there is setting or context option
            swap = SwapDisplayWdg()
            table.add_data(SpanWdg(swap, css='small'))
            swap.set_display_widgets(StringWdg('[+]'), StringWdg('[-]'))
            subcontext_name = "%s|subcontext" % my.get_input_name()
            subcontext = SpanWdg('/ ', css='small')
            subcontext.add(TextWdg(subcontext_name))
            subcontext.add_style('display', 'none')
            subcontext.set_id(subcontext_name)
            on_script = "set_display_on('%s');swap_display('subcontext_mode','context_mode')" % subcontext_name
            off_script = "set_display_off('%s');get_elements('%s').set_value(''); "\
                "swap_display('context_mode','subcontext_mode')"%(subcontext_name, subcontext_name)
            swap.add_action_script(on_script, off_script)
            text = SelectWdg(context_name)
            if my.sobjects:
                text.set_sobject(my.sobjects[0])
            if context_expr_option:
                text.set_option('values_expr', context_expr_option)
            elif context_option:
                text.set_option('values', context_option)
            elif setting_option:
                text.set_option('setting', setting_option)

            td = table.add_cell(text)

            table.add_data(subcontext)

        elif pipeline_option:
            from pyasm.biz import Pipeline
            sobject = my.sobjects[0]
            pipeline = Pipeline.get_by_sobject(sobject)
            context_names = []
            process_names = pipeline.get_process_names(recurse=True)
            for process in process_names:
                context_names.append(pipeline.get_output_contexts(process))
            text = SelectWdg(context_name)
            text.set_option('values', process_names)
            table.add_cell(text)

        else:
            text = TextWdg(context_name)
            table.add_cell(text)
            hint = HintWdg('If not specified, the default is [publish]')
            table.add_data(hint)

        revision_cb = CheckboxWdg('%s|is_revision' %my.get_input_name(),\
            label='is revision', css='med')
        table.add_data(revision_cb)
        table.add_row()
        table.add_cell("Comment")
        textarea = TextAreaWdg("%s|description" % my.get_input_name())
        table.add_cell(textarea)
        widget.add(table)

        return widget
Exemplo n.º 11
0
    def get_display(my):

        top = my.top

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

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

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

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

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

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

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

            start_date = parser.parse(start_date)

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

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

        else:
            sobjects = []

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

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

        min_date = None
        max_date = None

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        my.sobjects = sobjects

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

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

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

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

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

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

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

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

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

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

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

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

        if legend:
            legend.set_colors(my.colors)

        element_count = 0

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

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

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

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

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

        for options in chart_data:

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

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

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

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

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

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

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

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

            chart_data = ChartData(**str_options)

            chart.add(chart_data)

            element_count += 1

        table.add_row()

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

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

        return top
Exemplo n.º 12
0
    def get_group_wdg(self, prev_sobj):
        if not self.is_preprocessed:
            self.preprocess()

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

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

        widget = DivWdg()

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

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

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

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

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

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

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

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

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

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

        widget.add(table)

        return widget
Exemplo n.º 13
0
    def get_display(my):

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

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

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

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

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

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

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

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

        table2.add_row()

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

        #th.add_class('center_content')

        table2.add_row()

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

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

        #box.add(script)

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

        return widget
Exemplo n.º 14
0
    def common_wdg(my, vendor):
        div = DivWdg()
        div.add_class("spt_db_options")
        div.add_style("margin: 20px")
        if vendor != 'MySQL':
            div.add_attr("spt_vendor", "Other")
        table = Table()
        div.add(table)
        table.add_color("color", "color")

        table.add_row()
        table.add_cell("Server: ")
        text = TextInputWdg(name="server")
        text.set_value("localhost")
        table.add_cell(text)
        server = Config.get_value("database", "server")
        if server:
            text.set_value(server)

        table.add_row()
        table.add_cell("Port: ")
        text = TextInputWdg(name="port")
        table.add_cell(text)
        port = Config.get_value("database", "port")
        if port:
            text.set_value(port)

        table.add_row()
        table.add_cell("Login: "******"user")
        table.add_cell(text)
        user = Config.get_value("database", "user")
        if user:
            text.set_value(user)

        table.add_row()
        text = PasswordInputWdg(name="password")
        table.add_cell("Password: "******"database", "password")
        if password:
            text.set_value(password)

        if vendor == 'MySQL':
            div.add_attr("spt_vendor", "MySQL")
            table.add_row()
            text = TextInputWdg(name="encoding")
            table.add_cell("Encoding: ")
            table.add_cell(text)
            encoding = Config.get_value("database", "encoding")
            if encoding:
                text.set_value(encoding)

            table.add_row()
            text = TextInputWdg(name="charset")
            table.add_cell("Charset: ")
            table.add_cell(text)
            charset = Config.get_value("database", "charset")
            if charset:
                text.set_value(charset)
        #from pyasm.search import Sql
        #sql.connect()

        return div
Exemplo n.º 15
0
    def get_display(self):

        sobject = self.get_current_sobject()

        shots = sobject.get_all_children("prod/shot")

        task_dict = {}
        tasks = Task.get_by_sobjects(shots)
        for task in tasks:
            search_type = task.get_value("search_type")
            search_id = task.get_value("search_id")
            key = '%s|%s' % (search_type, search_id)

            task_array = task_dict.get(key)
            if not task_array:
                task_array = []
                task_dict[key] = task_array
            task_array.append(task)

        # TODO: get rid of this hard code
        approved = ['Complete', 'Approved', 'Final']

        widget = Widget()

        total = 0
        completion = {}
        # get all of the tasks in a shot
        for shot in shots:
            key = shot.get_search_key()
            tasks = task_dict.get(key)
            if not tasks:
                tasks = []

            frame_range = shot.get_frame_range()
            frames = frame_range.get_num_frames()

            total += frames

            is_complete = {}
            for task in tasks:
                process = task.get_value("process")
                status = task.get_value("status")

                if not completion.get(process):
                    completion[process] = 0

                if status not in approved:
                    is_complete[process] = False
                elif not is_complete.get(process):
                    is_complete[process] = True
                # only set to true, if no other process has set it to false
                elif is_complete.get(process) != False:
                    is_complete[process] = True

            for process, flag in is_complete.items():
                if flag:
                    completion[process] += frames

        table = Table(css="minimal")
        table.add_style("width: 100%")
        processes = completion.keys()

        table.add_row()
        for process in processes:
            time = self.convert_to_time(completion[process])
            td = table.add_cell("%s (%s)" % (time, completion[process]))
            if completion[process] == 0:
                td.add_style("color: #ccc")

        table.add_cell("%s (%s)" % (self.convert_to_time(total), total))

        table.add_row_cell("<hr size='1'/>")
        table.add_row()
        for process in processes:
            td = table.add_cell("%s" % process)
            if completion[process] == 0:
                td.add_style("color: #ccc")
        table.add_cell("total")

        widget.add(table)
        return widget
Exemplo n.º 16
0
    def get_display(my):

        top = my.top
        top.add_class("spt_branch_content")
        my.set_as_panel(top)
        top.add_color("color", "color")
        top.add_color("background", "background")
        #top.add_border()
        #top.add_style("padding", "10px")
        top.add_style("min-width: 600px")
        top.add_style("min-height: 400px")

        top.add_behavior( {
            'type': 'load',
            'cbjs_action': scm_get_onload_js()
        } )



        sync_dir = Environment.get_sandbox_dir()
        project = Project.get()
        depot = project.get_value("location", no_exception=True)
        if not depot:
            depot = project.get_code()
        location = '//%s' % depot


        branch = my.kwargs.get("branch")
        if not branch:
            branch = WidgetSettings.get_value_by_key("current_branch")
        else:
            WidgetSettings.set_value_by_key("current_branch", branch)

        if not branch:
            branch = 'main'


        branches = my.kwargs.get("branches")
        if not branches:
            branches = []
        elif isinstance(branches, basestring):
            branches = branches.replace("'", '"')
            branches = jsonloads(branches)

        top.add_behavior( {
            'type': 'load',
            'depot': depot,
            'sync_dir': sync_dir,
            'cbjs_action': '''
            spt.scm.sync_dir = bvr.sync_dir;
            spt.scm.depot = bvr.depot;
            '''
        } )



        inner = DivWdg()
        top.add(inner)

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

        table.add_row()
        th = table.add_header("")

        th = table.add_header("Branches")
        th.add_style("text-align: left")
        th = table.add_header("Options")
        th.add_style("text-align: left")
        th = table.add_header("Owner")
        th.add_style("text-align: left")
        th = table.add_header("Check-out")
        th.add_style("text-align: left")

        bgcolor = table.get_color("background", -8)
        table.add_relay_behavior( {
            'type': 'mouseover',
            'bvr_match_class': 'spt_branch_item',
            'bgcolor': bgcolor,
            'cbjs_action': '''
            bvr.src_el.setStyle("background-color", bvr.bgcolor);
            '''
        } )
        table.add_relay_behavior( {
            'type': 'mouseout',
            'bvr_match_class': 'spt_branch_item',
            'cbjs_action': '''
            bvr.src_el.setStyle("background-color", '');
            '''
        } )


        table.add_relay_behavior( {
            'type': 'mouseup',
            'bvr_match_class': "spt_branch_radio",
            'cbjs_action': '''
            var value = bvr.src_el.value;


            spt.app_busy.show("Setting current branch to " + value);
            var server = TacticServerStub.get();

            server.set_widget_setting("current_branch", value);

            var top = bvr.src_el.getParent(".spt_checkin_top");
            top.removeAttribute("spt_sandbox_dir");
            spt.panel.refresh(top);
            spt.app_busy.hide();

            '''
        } )


        for c in branches:
            name = c.get("branch")

            tr = table.add_row()
            tr.add_class("spt_branch_item")

            radio = RadioWdg("branch")
            radio.add_class("spt_branch_radio")
            table.add_cell(radio)
            radio.set_option("value", name)
            if name == branch:
                radio.set_checked()


            table.add_cell(name)
            table.add_cell(c.get("Options"))
            table.add_cell(c.get("Owner"))

            icon = IconButtonWdg(title="Check-out", icon=IconWdg.CHECK_OUT_SM)
            table.add_cell(icon)

            icon.add_behavior( {
                'type': 'click_up',
                'branch': c.get("branch"),
                'cbjs_action': '''
                var top = bvr.src_el.getParent(".spt_branch_content");
                top.setAttribute("spt_brange", bvr.branch);

                spt.app_busy.show("Checking out branch ["+bvr.branch+"]");
                spt.scm.checkout("new_project/"+bvr.branch);
                spt.app_busy.hide();

                '''
            } )



        inner.add("<hr/>")

        if my.kwargs.get("branches") == None:
            inner.add_behavior( {
            'type': 'load',
            'location': location,
            'sync_dir': sync_dir,
            'cbjs_action': '''

spt.branch = {}
spt.branch.load = function(el) {
    var branches = spt.scm.run("get_branches",[]);

    var class_name = 'tactic.ui.checkin.branch_wdg.BranchWdg';
    var kwargs = {
        branches: branches,
    }
    var top = el.getParent(".spt_branch_content");
    spt.panel.load(top, class_name, kwargs);
}

spt.branch.load(bvr.src_el);

        ''' } )


        return top
Exemplo n.º 17
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
Exemplo n.º 18
0
    def get_display(my):

        # NOTE: need to add this to fit as a table layout
        my.chunk_size = 10000
        my.edit_permission = True
        my.view_editable = True

        search_key = my.kwargs.get("search_key")
        if search_key:
            sobject = Search.get_by_search_key(search_key)
            my.sobjects = [sobject]

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

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

        inner = DivWdg()
        top.add(inner)
        inner.add_color("background", "background")
        inner.add_color("color", "color")
        # NOTE: this is not the table and is called this for backwards
        # compatibility
        inner.add_class("spt_table")
        inner.add_class("spt_layout")

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

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

        # get all the edit widgets
        """
        if my.view_editable and my.edit_permission:
            edit_wdgs = my.get_edit_wdgs()
            edit_div = DivWdg()
            edit_div.add_class("spt_edit_top")
            edit_div.add_style("display: none")
            inner.add(edit_div)
            for name, edit_wdg in edit_wdgs.items():
                edit_div.add(edit_wdg)
        """

        inner.set_unique_id()
        inner.add_smart_style("spt_header", "vertical-align", "top")
        inner.add_smart_style("spt_header", "text-align", "left")
        inner.add_smart_style("spt_header", "width", "150px")
        inner.add_smart_style("spt_header", "padding", "5px")
        border = inner.get_color("table_border")
        inner.add_smart_style("spt_header", "border", "solid 1px %s" % border)

        inner.add_smart_style("spt_cell_edit", "background-repeat",
                              "no-repeat")
        inner.add_smart_style("spt_cell_edit", "background-position",
                              "bottom right")
        inner.add_smart_style("spt_cell_edit", "padding", "5px")
        inner.add_smart_style("spt_cell_edit", "min-width", "200px")

        for i, sobject in enumerate(my.sobjects):

            table = Table()
            table.add_color("color", "color")
            table.add_style("padding: 10px")
            #table.add_style("margin-bottom: 10px")
            table.add_style("width: 100%")
            inner.add(table)
            for j, widget in enumerate(my.widgets):

                name = widget.get_name()
                if name == 'preview':
                    continue

                widget.set_current_index(i)
                title = widget.get_title()

                tr = table.add_row()
                if isinstance(title, HtmlElement):
                    title.add_style("float: left")
                th = table.add_header(title)
                th.add(" : ")
                th.add_class("spt_header")
                td = table.add_cell(widget.get_buffer_display())
                td.add_class("spt_cell_edit")

                if j % 2 == 0:
                    #th.add_color("background-color", "background", -10)
                    #td.add_color("background-color", "background", -5)
                    tr.add_color("background-color", "background", -5)
                else:
                    #th.add_color("background-color", "background", -10)
                    #td.add_color("background-color", "background")
                    tr.add_color("background-color", "background")

                # indicator that a cell is editable
                #td.add_event( "onmouseover", "$(this).setStyle('background-image', " \
                #                  "'url(/context/icons/silk/page_white_edit.png)')" )
                #td.add_event( "onmouseout",  "$(this).setStyle('background-image', '')")

        # extra stuff to make it work with ViewPanelWdg
        top.add_class("spt_table_top")
        class_name = Common.get_full_class_name(my)
        top.add_attr("spt_class_name", class_name)

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

        if my.kwargs.get("is_refresh") == 'true':
            return inner
        else:
            return top
Exemplo n.º 19
0
    def get_display(self):

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

        from pyasm.checkin import BaseMetadataParser

        #parser_str = "EXIF"
        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 = {}

        parser_title = parser.get_title()

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

        shelf = DivWdg()
        top.add(shelf)
        from tactic.ui.widget import ActionButtonWdg
        button = ActionButtonWdg(title="Add Selected to Keywords", width="200")
        shelf.add(button)
        shelf.add_style("margin: 10px 0px")
        button.add_behavior({
            'search_key':
            search_key,
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_metadata_top");
            var values = spt.api.get_input_values(top, null, true);
            var searchables = values.searchable;
            var items = [];
            for (var i = 0; i < searchables.length; i++) {
                if (searchables[i] == "") {
                    continue;
                }
                items.push(searchables[i]);
            }

            var server = TacticServerStub.get();

            var class_name = 'spt.modules.workflow.AssetAddMetadataToKeywordsCmd';
            var kwargs = {
                search_key: bvr.search_key,
                items: items,
            };
            server.p_execute_cmd(class_name, kwargs)
            .then( function() {
                spt.api.clear_inputs(top);
                spt.notify.show_message("Added Keywords");
            } )


            '''
        })

        table = Table()
        table.add_style("width: 100%")
        #table.add_style("table-layout: fixed")
        top.add(table)
        table.set_unique_id()

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

        tr, td = table.add_row_cell()
        td.add(parser_title)
        td.add_style("height: 20px")
        td.add_style("font-weight: bold")
        td.add_style("padding: 5px 3px")
        td.add_color("background", "background", -5)
        border_color = td.get_color("border")
        td.add_color("border-bottom", "solid 1px %s" % border_color)

        tr.add_class("tactic_hover")
        """
        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'})

        keys.sort()

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

            value = Common.process_unicode_string(value)

            if not isinstance(key, basestring):
                key = str(key)
            #title = Common.get_display_title(key)
            title = key

            tr = table.add_row()
            tr.add_class("tactic_hover")

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

            td = table.add_cell()
            td.add_class("spt_cell")
            td.add(title)
            td.add_style("width: 300px")
            td.add_style("min-width: 200px")

            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)
            td.add_style("max-width: 600px")

            td.add_style("overflow: hidden")
            td.add_style("text-overflow: ellipsis")
            td.add_style("white-space: nowrap")

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

            try:
                is_ascii = True
                for c in str(value):
                    if ord(c) > 128:
                        is_ascii = False
                        break
                if not is_ascii:
                    continue
            except Exception as e:
                print("WARNING: ", e)
                continue

            from pyasm.widget import CheckboxWdg
            checkbox = CheckboxWdg("searchable")
            checkbox.add_attr("spt_is_multiple", "true")
            td.add(checkbox)
            td.add_style("width: 40px")
            td.add_style("max-width: 30px")
            checkbox.set_option("value",
                                "%s|%s|%s" % (parser_title, key, 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
Exemplo n.º 20
0
    def get_display(my):

        widget = Widget()

        div = DivWdg(css='spt_ui_options')
        div.set_unique_id()
        table = Table()
        div.add(table)
        table.add_style("margin: 5px 15px")
        table.add_color('color', 'color')

        swap = SwapDisplayWdg()
        #swap.set_off()
        app = WebContainer.get_web().get_selected_app()
        outer_span = SpanWdg()
        outer_span.add_style('float: right')
        span = SpanWdg(app, css='small')
        icon = IconWdg(icon=eval("IconWdg.%s" % app.upper()), width='13px')
        outer_span.add(span)
        outer_span.add(icon)

        title = SpanWdg("Loading Options")
        title.add(outer_span)

        SwapDisplayWdg.create_swap_title(title, swap, div, is_open=False)

        widget.add(swap)
        widget.add(title)
        widget.add(div)

        if not my.hide_instantiation:
            table.add_row()
            table.add_blank_cell()
            div = DivWdg(HtmlElement.b("Instantiation: "))
            table.add_cell(div)
            div = my.get_instantiation_wdg()
            table.add_cell(div)

        setting = my.get_default_setting()
        default_instantiation = setting.get('instantiation')
        default_connection = setting.get('connection')
        default_dependency = setting.get('texture_dependency')

        if not my.hide_connection:
            table.add_row()
            table.add_blank_cell()
            con_div = DivWdg(HtmlElement.b("Connection: "))
            table.add_cell(con_div)
            td = table.add_cell()

            is_unchecked = True
            default_cb = None
            for value in ['http', 'file system']:
                name = my.get_element_name("connection")
                checkbox = CheckboxWdg(name)
                checkbox.set_option("value", value)
                checkbox.set_persistence()
                if value == default_connection:
                    default_cb = checkbox
                if checkbox.is_checked():
                    is_unchecked = False
                checkbox.add_behavior({
                    'type':
                    'click_up',
                    'propagate_evt':
                    True,
                    "cbjs_action":
                    "spt.toggle_checkbox(bvr, '.spt_ui_options', '%s')" % name
                })
                span = SpanWdg(checkbox, css='small')
                span.add(value)

                td.add(span)
            if is_unchecked:
                default_cb.set_checked()

        if not my.hide_dependencies:
            table.add_row()
            table.add_blank_cell()
            div = DivWdg(HtmlElement.b("Texture Dependencies: "))
            table.add_cell(div)
            td = table.add_cell()

            is_unchecked = True
            default_cb = None
            for value in ['as checked in', 'latest', 'current']:
                name = my.get_element_name("dependency")
                checkbox = CheckboxWdg(name)

                checkbox.set_option("value", value)
                checkbox.set_persistence()
                checkbox.add_behavior({
                    'type':
                    'click_up',
                    'propagate_evt':
                    True,
                    "cbjs_action":
                    "spt.toggle_checkbox(bvr, '.spt_ui_options', '%s')" % name
                })
                if value == default_dependency:
                    default_cb = checkbox
                if checkbox.is_checked():
                    is_unchecked = False

                span = SpanWdg(checkbox, css='small')
                span.add(value)
                td.add(span)
            if is_unchecked:
                default_cb.set_checked()

        from connection_select_wdg import ConnectionSelectWdg
        table.add_row()
        table.add_blank_cell()
        div = DivWdg(HtmlElement.b("Connection Type: "))
        table.add_cell(div)
        table.add_cell(ConnectionSelectWdg())

        table.add_row()
        table.add_blank_cell()
        div = DivWdg(HtmlElement.b("Connection Port: "))
        table.add_cell(div)
        port_div = DivWdg()
        port_text = TextWdg("port")
        port_text.set_option('size', '6')
        port_div.add(port_text)
        port_div.add_style("padding-left: 7px")
        port_div.add_style("width: 40px")
        table.add_cell(port_div)

        from pyasm.prod.web import WidgetSettings
        value = WidgetSettings.get_value_by_key("CGApp:connection_port")
        if value:
            port_text.set_value(value)
        elif WebContainer.get_web().get_selected_app() == 'Houdini':
            port_text.set_value("13000")
        else:
            port_text.set_value("4444")

        port_text.add_behavior({
            'type':
            'change',
            'cbjs_action':
            '''
                var value = bvr.src_el.value;
                value = parseInt(value);
                var kwargs = {
                    'data': value,
                    'key': 'CGApp:connection_port'
                }
                var cmd = "pyasm.web.WidgetSettingSaveCbk"
                var server = TacticServerStub.get();
                server.execute_cmd(cmd, kwargs);

                // FIXME: this is dangerous use of a global var
                app.port = value;
            '''
        })

        return widget
Exemplo n.º 21
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
Exemplo n.º 22
0
    def get_display(my):
        div = DivWdg()
        div.add_class( "spt_view_manager_top" )
        my.set_as_panel(div)

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


        # try to get the search objct
        try:
            search_type_sobj = SearchType.get(my.search_type)
        except SearchException:
            if my.kwargs.get("show_create") in [True, 'true']:
                inner.add("<b>Create New Search Type</b><br/><br/>")
                inner.add("Search Type [%s] does not yet exist.<br/>Fill out the following form to register this Search Type.<br/>" % my.search_type)
                from tactic.ui.app import SearchTypeCreatorWdg
                creator = SearchTypeCreatorWdg(search_type=my.search_type)
                inner.add(creator)
                return div


        #title_wdg = DivWdg()
        #title_wdg.add_style("font-size: 18px")
        #title_wdg.add("Config View Manager")
        #inner.add(title_wdg)

        inner.add (my.get_filter_wdg() )


        if not my.search_type or not my.view:
            return div

        inner.add(HtmlElement.br())

        tool_bar = my.get_tool_bar()
 
        inner.add(tool_bar)


        # add the template view containing the possible items to be added
        # ie: New Folder, New Entry, New Separator
        menu_div = DivWdg()
        inner.add(menu_div)
        menu_div.add_class("spt_menu_item_template")
        menu_div.add_style("display: none")
        menu_div.add( my.get_section_wdg("_template", editable=False) )


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

        # add the section
        td = table.add_cell()
        view_list_wdg = DivWdg()
        view_list_wdg.add_style('min-width: 250px')
        view_list_wdg.add_class("spt_menu_item_list")
        view_list_wdg.add( my.get_section_wdg(my.view ))
        td.add(view_list_wdg)
        td.add_style("vertical-align: top")
        #td.add_attr("rowspan", "2")

        td.add("<br/>")

        # add the definition section
        if my.view != 'definition':
            def_list_wdg = DivWdg()
            #def_list_wdg.add( my.get_section_wdg("default_definition" ))
            def_list_wdg.add( my.get_section_wdg("definition" ))
            td.add(def_list_wdg)
 
            td.add("<br/>")

            # HACK: we need to figure out how this default definition
            # fits in
            if my.search_type.startswith('prod/') or my.search_type.startswith('sthpw/'):
                def_list_wdg = DivWdg()
                def_list_wdg.add( my.get_section_wdg("default_definition" ))
                td.add(def_list_wdg)
                td.add("<br/>")

        # add detail information
        td = table.add_cell( my.get_detail_wdg() )


        # set the panel information
        td.add_class("spt_view_manager_detail")
        td.add_style("display", "table-cell")
        td.add_attr("spt_search_type", my.search_type)

        td.add_style("padding: 0 20px 20px 20px")
        td.add_style("vertical-align: top")


        return div
Exemplo n.º 23
0
    def get_chat_wdg(my, key, interval=False):

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

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

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

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


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

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

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


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

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


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

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

        

            if login != last_login:

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

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

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

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


                display_name = login_sobj.get("display_name")

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


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


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

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

            td.add(msg)

            

            last_login = login
            last_date = date_str

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


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




        if interval:

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

                var tmp = message.message || "";

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

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

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

                // remember last message
                history_el.last_msg = msg;


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

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

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

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



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

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

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

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

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

        text_el.value = "";

            '''
        } )

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


        return div
Exemplo n.º 24
0
    def get_first_row_wdg(self):

        # read the csv file
        self.file_path = ""

        div = DivWdg()

        div.add(self.get_upload_wdg())

        if not self.search_type:
            return div

        if not self.file_path:
            return div

        if not self.file_path.endswith(".csv"):
            div.add("Uploaded file [%s] is not a csv file" % self.file_path)
            return div

        if not os.path.exists(self.file_path):
            raise Exception("Path '%s' does not exists" % self.file_path)

        div.add(HtmlElement.br(2))

        div.add(
            HtmlElement.
            b("The following is taken from first line in the uploaded csv file.  Select the appropriate column to match."
              ))
        div.add(HtmlElement.br())
        div.add(
            HtmlElement.b(
                "Make sure you have all the required columns** in the csv."))
        option_div = DivWdg()

        option_div.add_style("float: left")
        option_div.add_style("margin-right: 30px")

        option_div.add("<p>3. Parsing Options:</p>")

        self.search_type_obj = SearchType.get(self.search_type)

        # first row and second row
        option_div.add(HtmlElement.br(2))
        option_div.add("Use Title Row: ")
        title_row_checkbox = FilterCheckboxWdg("has_title")
        title_row_checkbox.set_default_checked()
        option_div.add(title_row_checkbox)
        option_div.add(
            HintWdg(
                "Set this to use the first row as a title row to match up columns in the database"
            ))

        option_div.add(HtmlElement.br(2))
        option_div.add("Sample Data Row: ")
        data_row_text = TextWdg("data_row")
        data_row_text.set_attr("size", "3")
        option_div.add(data_row_text)
        option_div.add(
            HintWdg(
                "Set this as a sample data row to match the columns to the database"
            ))

        option_div.add(HtmlElement.br(2))

        div.add(option_div)
        self.has_title = title_row_checkbox.is_checked()

        # parse the first fow
        csv_parser = CsvParser(self.file_path)
        if self.has_title:
            csv_parser.set_has_title_row(True)
        else:
            csv_parser.set_has_title_row(False)
        csv_parser.parse()
        csv_titles = csv_parser.get_titles()
        csv_data = csv_parser.get_data()

        data_row = data_row_text.get_value()
        if not data_row:
            data_row = 0
        else:
            try:
                data_row = int(data_row)
            except ValueError:
                data_row = 0

            if data_row >= len(csv_data):
                data_row = len(csv_data) - 1
        data_row_text.set_value(data_row)

        table = Table()
        table.set_attr("cellpadding", "10")

        table.add_row()
        table.add_header("CSV Column Value")
        table.add_header("TACTIC Column")
        table.add_header("Create New Column")

        columns = self.search_type_obj.get_columns()
        search_type = self.search_type_obj.get_base_search_type()
        sobj = SObjectFactory.create(search_type)
        required_columns = sobj.get_required_columns()

        row = csv_data[data_row]
        labels = []
        for column in columns:
            if column in required_columns:
                label = '%s**' % column
            else:
                label = column
            labels.append(label)

        for j, cell in enumerate(row):
            table.add_row()
            table.add_cell(cell)

            column_select = SelectWdg("column_%s" % j)
            column_select.add_event(
                "onchange",
                "if (this.value!='') {set_display_off('new_column_div_%s')} else {set_display_on('new_column_div_%s')}"
                % (j, j))

            column_select.add_empty_option("-- Select --")
            column_select.set_option("values", columns)
            column_select.set_option("labels", labels)

            # only set the value if it is actually in there
            if csv_titles[j] in columns:
                column_select.set_option("default", csv_titles[j])
            column_select.set_persist_on_submit()
            column_select_value = column_select.get_value()

            display = column_select.get_buffer_display()
            td = table.add_cell(display)

            if csv_titles[j] not in columns:
                td.add(" <b style='color: red'>*</b>")

                # new property
                new_column_div = DivWdg()

                if column_select_value:
                    new_column_div.add_style("display", "none")
                else:
                    new_column_div.add_style("display", "block")

                new_column_div.set_id("new_column_div_%s" % j)

                td = table.add_cell(new_column_div)
                text = TextWdg("new_column_%s" % j)
                text.set_persist_on_submit()

                if self.has_title:
                    text.set_value(csv_titles[j])

                new_column_div.add(" ... or ...")
                new_column_div.add(text)

        self.num_columns = len(row)
        hidden = HiddenWdg("num_columns", self.num_columns)

        # need to somehow specify defaults for columns

        div.add(table)

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

        div.add(self.get_preview_wdg())

        return div
Exemplo n.º 25
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
Exemplo n.º 26
0
    def get_preview_wdg(self):

        widget = Widget()

        web = WebContainer.get_web()

        csv_parser = CsvParser(self.file_path)
        csv_parser.parse()
        csv_titles = csv_parser.get_titles()
        csv_data = csv_parser.get_data()

        ajax = AjaxCmd()
        ajax.set_option("search_type", self.search_type)
        ajax.set_option("file_path", self.file_path)
        ajax.add_element_name("has_title")

        event = WebContainer.get_event_container()
        caller = event.get_event_caller(SiteMenuWdg.EVENT_ID)
        div = ajax.generate_div()
        div.set_post_ajax_script(caller)
        widget.add(div)

        columns = []
        num_columns = len(csv_titles)
        ajax.set_option("num_columns", num_columns)
        for i in range(0, num_columns):
            column = web.get_form_value("column_%s" % i)
            if column:
                column = csv_titles[i]
            else:
                column = web.get_form_value("column_new_%s" % i)

            columns.append(column)

            ajax.add_element_name("column_%s" % i)
            ajax.add_element_name("new_column_%s" % i)

        ajax.register_cmd("pyasm.command.csv_import_cmd.CsvImportCmd")
        import_button = IconButtonWdg("Import", IconWdg.REFRESH, True)
        import_button.add_event("onclick",
                                ajax.get_on_script(show_progress=False))
        import_button.add_style("float: right")
        widget.add(import_button)

        preview_submit = IconSubmitWdg("Preview", IconWdg.REFRESH, True)
        preview_submit.add_style("float: right")
        widget.add(preview_submit)

        sobject_title = self.search_type_obj.get_title()
        widget.add("<p>4. Import</p>")
        widget.add(HtmlElement.br())
        widget.add(
            "<p>The following table will be imported into %s (Showing Max: 100)</p>"
            % sobject_title)

        table = Table(css="table")
        table.add_style("width: 100%")

        table.add_row()
        for i, title in enumerate(columns):
            if not title:
                title = "<b style='color:red'>*</b>"
            table.add_header(title)

        for i, row in enumerate(csv_data):
            if i > 100:
                break
            table.add_row()
            for j, cell in enumerate(row):
                table.add_cell(cell)

        widget.add(table)

        return widget
Exemplo n.º 27
0
    def get_display(my):

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        tr = table.add_row()

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

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

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

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

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

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

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

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

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

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

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

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

        return top
Exemplo n.º 28
0
    def get_upload_wdg(self):
        widget = Widget()

        # get the search type
        widget.add("1. Select type of asset: ")

        # handle new search_types
        new_search_type = CheckboxWdg("new_search_type_checkbox")
        new_search_type.add_event("onclick",
                                  "toggle_display('new_search_type_div')")
        #span = SpanWdg(css="med")
        #span.add(new_search_type)
        #span.add("Create new type")
        #span.add(" ... or ... ")
        #widget.add(span)

        new_search_type_div = DivWdg()
        new_search_type_div.set_id("new_search_type_div")

        name_input = TextWdg("asset_name")
        title = TextWdg("asset_title")
        description = TextAreaWdg("asset_description")

        table = Table()
        table.add_style("margin: 10px 20px")
        table.add_col().set_attr('width', '140')
        table.add_col().set_attr('width', '400')

        table.add_row()
        table.add_header("Search Type: ").set_attr('align', 'left')
        table.add_cell(name_input)
        table.add_row()
        table.add_header("Title: ").set_attr('align', 'left')
        table.add_cell(title)
        table.add_row()
        table.add_header("Description: ").set_attr('align', 'left')
        table.add_cell(description)
        new_search_type_div.add(table)
        new_search_type_div.add_style("display: none")
        #widget.add(new_search_type_div)

        # or use a pre-existing one
        search_type_select = SearchTypeSelectWdg("filter|search_type")
        search_type_select.add_empty_option("-- Select --")
        search_type_select.set_persist_on_submit()
        search_type_select.set_submit_onchange()
        widget.add(search_type_select)

        self.search_type = search_type_select.get_value()
        if self.search_type:
            sobj = SObjectFactory.create(self.search_type)
            required_columns = sobj.get_required_columns()

            widget.add(SpanWdg("Required Columns: ", css='med'))
            if not required_columns:
                required_columns = ['n/a']
            widget.add(SpanWdg(', '.join(required_columns), css='med'))

        widget.add(HtmlElement.br(2))
        widget.add("2. Upload a csv file: ")
        upload_wdg = HtmlElement.upload("uploaded_file")
        widget.add(upload_wdg)
        submit = IconSubmitWdg("Upload", IconWdg.UPLOAD, True)
        widget.add(submit)

        web = WebContainer.get_web()
        field_storage = web.get_form_value("uploaded_file")
        if field_storage != "":
            upload = FileUpload()
            upload.set_field_storage(field_storage)
            upload.set_create_icon(False)
            upload.execute()

            files = upload.get_files()
            if files:
                self.file_path = files[0]
            else:
                self.file_path = web.get_form_value("file_path")

        if self.file_path:
            hidden = HiddenWdg("file_path", self.file_path)
            widget.add(hidden)

        return widget
Exemplo n.º 29
0
    def get_display(self):

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

        from tactic.ui.widget import ActionButtonWdg
        button = ActionButtonWdg(title="Upload")
        top.add(button)

        cancel = ActionButtonWdg(title="Cancel")
        top.add(cancel)
        cancel.add_behavior({
            'type': 'click_up',
            'cbjs_action': '''spt.progress.cancel_jobs()'''
        })

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

        from pyasm.web import Table
        table = Table()
        top.add(table)

        paths = []
        #paths = ['C:/Data/ab.avi', 'C:/Data/ab2.avi']
        paths = ['C:/Data/ab.avi']
        for i in range(0, 7):
            paths.append("C:/Data/Test2/test%0.2d.nkple" % i)
        progress_ids = []
        for path in paths:
            table.add_row()
            td = table.add_cell()
            td.add_style("padding: 5px")

            path_div = DivWdg()
            td.add(path_div)
            path_div.add_style("width: 100%")
            path_div.add(path)

            td = table.add_cell()
            progress_wdg = ProgressWdg()
            td.add(progress_wdg)

            progress_id = progress_wdg.get_progress_id()
            progress_ids.append(progress_id)

        button.add_behavior({
            'type':
            'click_up',
            'paths':
            paths,
            'progress_ids':
            progress_ids,
            'cbjs_action':
            '''

        var applet = spt.Applet.get();

        var update_cbk = function() {
            var progress = spt.progress.complete;
            var path = spt.progress.get_path();
            var index = spt.progress.get_index();
            var num_jobs = spt.progress.get_num_jobs();
            //console.log("job [" + index + " of " +num_jobs+ "] = " + path + ": " + progress);
        };

        for (var i = 0; i < bvr.paths.length; i++) {
            var path = bvr.paths[i] + "";
            path = path.replace(/\\\\/g, "/");
            var progress_id = bvr.progress_ids[i];
            if (!progress_id) {
                progress_id = bvr.progress_ids[0];
            }
            var job = {
                progress_id: progress_id,
                path: path,
                on_update: update_cbk
            }
            spt.progress.add_job(job);
        }
        spt.progress.run_jobs();

        '''
        })

        return top
 def get_display(my):
     element_auds = []
     server = TacticServerStub.get()
     wo_code = str(my.kwargs.get('wo_code'))
     if 'code' in my.kwargs.keys():
         code = my.kwargs.get('code')
         element_auds = server.eval(
             "@SOBJECT(twog/element_eval_audio['element_eval_code','%s']['@ORDER_BY','channel'])"
             % code)
     force_it = False
     if 'force_it' in my.kwargs.keys():
         if my.kwargs.get('force_it') == 'true':
             force_it = True
     channels = 21
     if 'channels' in my.kwargs.keys():
         channels = int(my.kwargs.get('channels'))
     if len(element_auds) > 0 and not force_it:
         channels = len(element_auds)
     leng = len(element_auds)
     for i in range(leng, channels - leng):
         element_auds.append(None)
     a_third = int(channels / 3)
     if int(float(
             float(float(channels) / float(3)) * 1000)) != a_third * 1000:
         a_third += 1
     grand_table = Table()
     grand_table.add_attr('id', 'audio_information')
     grand_table.add_attr('channels', channels)
     grand_table.add_row()
     atable = None
     for i in range(0, channels):
         if i in [0, a_third, (a_third * 2)]:
             atable = Table()
             atable.add_attr('class', 'atable')
             atable.add_attr('border', '1')
             atable.add_row()
             atable.add_cell('Channel')
             atable.add_cell('Content')
             atable.add_cell('Tone')
             atable.add_cell('Peak')
         atable.add_row()
         the_code = ''
         channel = ''
         content = ''
         tone = ''
         peak = ''
         if i < len(element_auds):
             if element_auds[i] != None:
                 the_code = element_auds[i].get('code')
                 channel = element_auds[i].get('channel')
                 content = element_auds[i].get('content')
                 tone = element_auds[i].get('tone')
                 peak = element_auds[i].get('peak')
         atable.add_cell(
             my.txtbox('channel-%s' % i,
                       channel,
                       the_code,
                       channel,
                       width='68px',
                       js='yes'))
         sellie = atable.add_cell(
             my.txtbox('content-%s' % i,
                       content,
                       the_code,
                       content,
                       width='132px'))
         atable.add_cell(
             my.txtbox('tone-%s' % i, tone, the_code, tone, width='68px'))
         atable.add_cell(
             my.txtbox('peak-%s' % i, peak, the_code, peak, width='68px'))
         if i in [a_third - 1, (a_third * 2) - 1, channels - 1]:
             grand_cell = grand_table.add_cell(atable)
             grand_cell.add_attr('valign', 'top')
             if i != channels - 1:
                 grand_table.add_cell('&nbsp;')
             atable = None
     return grand_table