コード例 #1
0
    def get_item_div(my, sobjects, related_type):
        item_div = DivWdg()
        item_div.add_style("margin: 15px 10px")

        sobject = sobjects[0]

        checkbox = CheckboxWdg('related_types')
        item_div.add(checkbox)
        checkbox.set_attr("value", related_type)
        if related_type in ["sthpw/snapshot", "sthpw/file"]:
            checkbox.set_checked()

        item_div.add(" ")
        item_div.add(related_type)
        item_div.add(": ")

        if related_type.startswith("@SOBJECT"):
            related_sobjects = Search.eval(related_type, [sobject], list=True)
        else:
            try:
                related_sobjects = []
                for sobject in sobjects:
                    sobjs = sobject.get_related_sobjects(related_type)
                    related_sobjects.extend(sobjs)

            except Exception, e:
                print "WARNING: ", e
                related_sobjects = []
コード例 #2
0
ファイル: delete_wdg.py プロジェクト: asmboom/TACTIC
    def get_item_div(my, sobjects, related_type):
        item_div = DivWdg()
        item_div.add_style("margin: 15px 10px")

        sobject = sobjects[0]

        checkbox = CheckboxWdg('related_types')
        item_div.add(checkbox)
        checkbox.set_attr("value", related_type)
        if related_type in ["sthpw/snapshot", "sthpw/file"]:
            checkbox.set_checked()

        item_div.add(" ")
        item_div.add(related_type)
        item_div.add(": ")

        if related_type.startswith("@SOBJECT"):
            related_sobjects = Search.eval(related_type, [sobject], list=True)
        else:
            try:
                related_sobjects = []
                for sobject in sobjects:
                    sobjs = sobject.get_related_sobjects(related_type)
                    related_sobjects.extend(sobjs)

            except Exception, e:
                print "WARNING: ", e
                related_sobjects = []
コード例 #3
0
ファイル: delete_wdg.py プロジェクト: mincau/TACTIC
    def get_item_div(self, sobjects, related_type):
        item_div = DivWdg()
        item_div.add_style("margin: 15px 10px")

        sobject = sobjects[0]

        checkbox = CheckboxWdg('related_types')
        item_div.add(checkbox)
        checkbox.add_style("vertical-align: bottom")
        checkbox.set_attr("value", related_type)
        if related_type in ["sthpw/snapshot", "sthpw/file"]:
            checkbox.set_checked()

        checked_types = self.kwargs.get("checked_types")
        if checked_types == "__ALL__":
            checkbox.set_checked()

        item_div.add(" ")
        item_div.add(related_type)
        item_div.add(": ")

        if related_type.startswith("@SOBJECT"):
            related_sobjects = Search.eval(related_type, [sobject], list=True)
        else:
            try:
                related_sobjects = []
                for sobject in sobjects:
                    sobjs = sobject.get_related_sobjects(related_type)
                    related_sobjects.extend(sobjs)

            except Exception as e:
                print("WARNING: ", e)
                related_sobjects = []


        item_div.add("(%s)" % len(related_sobjects))

        if len(related_sobjects) == 0:
            item_div.add_style("opacity: 0.5")
            return None
        else:
            # leave them unchecked for now to account for user's careless delete behavior
            pass

            # skip checking login by default to avoid accidental delete
            #if related_type != 'sthpw/login':
            #    checkbox.set_checked()

        return item_div
コード例 #4
0
    def get_item_div(self, sobjects, related_type):
        item_div = DivWdg()
        item_div.add_style("margin: 15px 10px")

        sobject = sobjects[0]

        checkbox = CheckboxWdg('related_types')
        item_div.add(checkbox)
        checkbox.add_style("vertical-align: bottom")
        checkbox.set_attr("value", related_type)
        if related_type in ["sthpw/snapshot", "sthpw/file"]:
            checkbox.set_checked()

        checked_types = self.kwargs.get("checked_types")
        if checked_types == "__ALL__":
            checkbox.set_checked()

        item_div.add(" ")
        item_div.add(related_type)
        item_div.add(": ")

        if related_type.startswith("@SOBJECT"):
            related_sobjects = Search.eval(related_type, [sobject], list=True)
        else:
            try:
                related_sobjects = []
                for sobject in sobjects:
                    sobjs = sobject.get_related_sobjects(related_type)
                    related_sobjects.extend(sobjs)

            except Exception as e:
                print("WARNING: ", e)
                related_sobjects = []

        item_div.add("(%s)" % len(related_sobjects))

        if len(related_sobjects) == 0:
            item_div.add_style("opacity: 0.5")
            return None
        else:
            # leave them unchecked for now to account for user's careless delete behavior
            pass

            # skip checking login by default to avoid accidental delete
            #if related_type != 'sthpw/login':
            #    checkbox.set_checked()

        return item_div
コード例 #5
0
ファイル: delete_wdg.py プロジェクト: blezek/TACTIC
    def get_item_div(my, sobjects, related_type):
        item_div = DivWdg()

        sobject = sobjects[0]

        checkbox = CheckboxWdg('related_types')
        item_div.add(checkbox)
        checkbox.set_attr("value", related_type)

        item_div.add(related_type)
        item_div.add(": ")

        if related_type.startswith("@SOBJECT"):
            related_sobjects = Search.eval(related_type, [sobject], list=True)
        else:
            try:
                related_sobjects = []
                for sobject in sobjects:
                    sobjs = sobject.get_related_sobjects(related_type)
                    related_sobjects.extend(sobjs)

            except Exception, e:
                print "WARNING: ", e
                related_sobjects = []
コード例 #6
0
ファイル: delete_wdg.py プロジェクト: hellios78/TACTIC
    def get_item_div(my, sobjects, related_type):
        item_div = DivWdg()

        sobject = sobjects[0]

        checkbox = CheckboxWdg('related_types')
        item_div.add(checkbox)
        checkbox.set_attr("value", related_type)

        item_div.add(related_type)
        item_div.add(": ")

        if related_type.startswith("@SOBJECT"):
            related_sobjects = Search.eval(related_type, [sobject], list=True)
        else:
            try:
                related_sobjects = []
                for sobject in sobjects:
                    sobjs = sobject.get_related_sobjects(related_type)
                    related_sobjects.extend(sobjs)

            except Exception, e:
                print "WARNING: ", e
                related_sobjects = []
コード例 #7
0
ファイル: delete_wdg.py プロジェクト: mincau/TACTIC
    def get_display(self):
        top = self.top
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_style("width", "400px")
        top.add_class('spt_delete_stype_top')
        top.add_border()

        project_code = Project.get_project_code()
        # Note search types should only really be deleted if they were just
        # created

        search_type = self.kwargs.get("search_type")
        if not search_type:
            node_name = self.kwargs.get("node_name")
            if node_name:
                #project_code = Project.get_project_code()
                search_type = "%s/%s" % (project_code, node_name)

        assert search_type
        built_in_stypes = ['task','note','work_hour','login','login_group','schema','project','login_in_group','snapshot','file','trigger','spt_trigger','widget_config','custom_script','notification','notification_log','file_access','cache','exception_log','milestone','pipeline','pref_list','pref_setting','project_type','repo','remote_repo','search_sobject','sobject_list','ticket','db_resource','wdg_settings','status_log','debug_log','transaction_log', 'sobject_log']

        for tbl in built_in_stypes:
            if search_type == 'sthpw/%s'%tbl:
                top.add("sType [%s] is internal and cannot be deleted!" % search_type)
                top.add_style("font-size: 14px")
                top.add_style('padding: 20px')
                return top

        search_type_obj = SearchType.get(search_type)
        if not search_type:
            top.add("sType [%s] does not exist!" % search_type)
            top.add_style("font-size: 14px")
            top.add_style('padding: 20px')
            return top
        table = search_type_obj.get_table()

        db_val = search_type_obj.get_value('database')
        if db_val == '{project}':
            label = ''
        elif db_val == 'sthpw':
            label = 'built-in'
        else:
            label = 'project-specific'

        
        # warn if more than 1 sType point to the same table in the same project
        expr = "@GET(sthpw/search_type['table_name', '%s']['database', 'in',  '{project}|%s']['namespace','%s'].search_type)" %(table, project_code, project_code)
        rtn = Search.eval(expr)
        
        warning_msg = ''
        if len(rtn) > 1:
            warning_msg = 'Warning: There is more than 1 sType [%s] pointing to the same table [%s]. Deleting will affect both sTypes.' %(', '.join(rtn), table)
           
        title_wdg = DivWdg()

        top.add(title_wdg)
        title_wdg.add(IconWdg(icon=IconWdg.WARNING))
        title_wdg.add("Delete %s sType: %s" % (label,search_type))
        title_wdg.add_color("background", "background", -10)
        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 warning_msg:
            content.add(DivWdg(warning_msg, css='warning'))
            content.add("<br/>")
        content.add("This sType uses the table \"%s\" to store items.<br/>" % table)


        content.add("<br/>")

        search = Search(search_type)
        count = search.get_count()
        content.add("Number of items in the table: %s<br/>" % count)

        content.add("<br/>")

        search.add_column("id")
        sobjects = search.get_sobjects()

        if sobjects:
            items_search_type = sobjects[0].get_search_type()

            search_ids = [x.get_id() for x in sobjects]

            notes_search = Search("sthpw/note")
            notes_search.add_filters("search_id", search_ids)
            notes_search.add_filter("search_type", items_search_type)
            note_count = notes_search.get_count()
            cb = CheckboxWdg('related_types')
            cb.set_attr('value', 'sthpw/note')
            content.add(cb)
            content.add(SpanWdg("Number of related notes: %s"% note_count, css='small') )
            content.add(HtmlElement.br())

            tasks_search = Search("sthpw/task")
            tasks_search.add_filters("search_id", search_ids)
            tasks_search.add_filter("search_type", items_search_type)
            task_count = tasks_search.get_count()
            cb = CheckboxWdg('related_types')
            cb.set_attr('value', 'sthpw/task')
            content.add(cb)
            content.add(SpanWdg("Number of related tasks: %s"% task_count, css='small') )
            content.add(HtmlElement.br())


            snapshots_search = Search("sthpw/snapshot")
            snapshots_search.add_filters("search_id", search_ids)
            snapshots_search.add_filter("search_type", items_search_type)
            snapshot_count = snapshots_search.get_count()
            cb = CheckboxWdg('related_types')
            cb.set_attr('value', 'sthpw/snapshot')
            content.add(cb)
            content.add(SpanWdg("Number of related snapshots: %s"% snapshot_count, css='small') )
            content.add(HtmlElement.br())

        pipelines_search = Search("sthpw/pipeline")
        pipelines_search.add_filter("search_type", search_type)
        pipeline_count = pipelines_search.get_count()
        cb = CheckboxWdg('related_types')
        cb.set_attr('value','sthpw/pipeline')
        content.add(cb)
        content.add(SpanWdg("Number of related pipelines: %s"% pipeline_count, css='small') )
        content.add(HtmlElement.br(2))




        content.add("<b>WARNING: Deleting the sType will delete all of these items.</b> ")
        content.add("<br/>"*2)
        content.add("Do you wish to continue deleting?")
        content.add("<br/>"*2)

        button_div = DivWdg()
        button_div.add_styles('width: 300px; height: 50px')
        button = ActionButtonWdg(title="Delete")
        button_div.add(button)
        content.add(button_div)
        button.add_style("float: left")

        button.add_behavior( {
        'type': 'click_up',
        'search_type': search_type,
        'cbjs_action': '''
        spt.app_busy.show("Deleting sType");
        var class_name = "tactic.ui.tools.DeleteSearchTypeCmd";
        var ui_top = bvr.src_el.getParent(".spt_delete_stype_top");
        var values = spt.api.Utility.get_input_values(ui_top);
        var kwargs = {
            'search_type': bvr.search_type,
             'values': values
        };
        var server = TacticServerStub.get();
        try {
            server.start({'title': 'Delete sType', 'description': 'Delete sType [' + bvr.search_type + ']'});
            server.execute_cmd(class_name, kwargs);
            var top = bvr.src_el.getParent(".spt_popup");
            spt.pipeline.remove_node(top.stype_node);

            // force a schema save
            spt.named_events.fire_event('schema|save', bvr)
            top.destroy();
            
            server.finish();
        
        }
        catch(e) {
            spt.alert(spt.exception.handler(e));
        }

        spt.app_busy.hide();

        spt.notify.show_message("Successfully deleted sType ["+bvr.search_type+"]");
       
        '''
        } )



        button = ActionButtonWdg(title="Cancel")
        button.add_style("float: left")
        button_div.add(button)
        button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        var top = bvr.src_el.getParent(".spt_popup");
        top.destroy();
        '''
        } )


        return top
コード例 #8
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_class('spt_delete_stype_top')
        top.add_border()

        project_code = Project.get_project_code()
        # Note search types should only really be deleted if they were just
        # created

        search_type = my.kwargs.get("search_type")
        if not search_type:
            node_name = my.kwargs.get("node_name")
            if node_name:
                #project_code = Project.get_project_code()
                search_type = "%s/%s" % (project_code, node_name)

        assert search_type
        built_in_stypes = [
            'task', 'note', 'work_hour', 'login', 'login_group', 'schema',
            'project', 'login_in_group', 'snapshot', 'file', 'trigger',
            'spt_trigger', 'widget_config', 'custom_script', 'notification',
            'notification_log', 'file_access', 'cache', 'exception_log',
            'milestone', 'pipeline', 'pref_list', 'pref_setting',
            'project_type', 'repo', 'remote_repo', 'search_sobject',
            'sobject_list', 'ticket', 'db_resource', 'wdg_settings',
            'status_log', 'debug_log', 'transaction_log', 'sobject_log'
        ]

        for tbl in built_in_stypes:
            if search_type == 'sthpw/%s' % tbl:
                top.add("sType [%s] is internal and cannot be deleted!" %
                        search_type)
                top.add_style("font-size: 14px")
                top.add_style('padding: 20px')
                return top

        search_type_obj = SearchType.get(search_type)
        if not search_type:
            top.add("sType [%s] does not exist!" % search_type)
            top.add_style("font-size: 14px")
            top.add_style('padding: 20px')
            return top
        table = search_type_obj.get_table()

        db_val = search_type_obj.get_value('database')
        if db_val == '{project}':
            label = ''
        elif db_val == 'sthpw':
            label = 'built-in'
        else:
            label = 'project-specific'

        # warn if more than 1 sType point to the same table in the same project
        expr = "@GET(sthpw/search_type['table_name', '%s']['database', 'in',  '{project}|%s']['namespace','%s'].search_type)" % (
            table, project_code, project_code)
        rtn = Search.eval(expr)

        warning_msg = ''
        if len(rtn) > 1:
            warning_msg = 'Warning: There is more than 1 sType [%s] pointing to the same table [%s]. Deleting will affect both sTypes.' % (
                ', '.join(rtn), table)

        title_wdg = DivWdg()

        top.add(title_wdg)
        title_wdg.add(IconWdg(icon=IconWdg.WARNING))
        title_wdg.add("Delete %s sType: %s" % (label, search_type))
        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 warning_msg:
            content.add(DivWdg(warning_msg, css='warning'))
            content.add("<br/>")
        content.add("This sType uses the table \"%s\" to store items.<br/>" %
                    table)

        content.add("<br/>")

        search = Search(search_type)
        count = search.get_count()
        content.add("Number of items in the table: %s<br/>" % count)

        content.add("<br/>")

        search.add_column("id")
        sobjects = search.get_sobjects()

        if sobjects:
            items_search_type = sobjects[0].get_search_type()

            search_ids = [x.get_id() for x in sobjects]

            notes_search = Search("sthpw/note")
            notes_search.add_filters("search_id", search_ids)
            notes_search.add_filter("search_type", items_search_type)
            note_count = notes_search.get_count()
            cb = CheckboxWdg('related_types')
            cb.set_attr('value', 'sthpw/note')
            content.add(cb)
            content.add(
                SpanWdg("Number of related notes: %s" % note_count,
                        css='small'))
            content.add(HtmlElement.br())

            tasks_search = Search("sthpw/task")
            tasks_search.add_filters("search_id", search_ids)
            tasks_search.add_filter("search_type", items_search_type)
            task_count = tasks_search.get_count()
            cb = CheckboxWdg('related_types')
            cb.set_attr('value', 'sthpw/task')
            content.add(cb)
            content.add(
                SpanWdg("Number of related tasks: %s" % task_count,
                        css='small'))
            content.add(HtmlElement.br())

            snapshots_search = Search("sthpw/snapshot")
            snapshots_search.add_filters("search_id", search_ids)
            snapshots_search.add_filter("search_type", items_search_type)
            snapshot_count = snapshots_search.get_count()
            cb = CheckboxWdg('related_types')
            cb.set_attr('value', 'sthpw/snapshot')
            content.add(cb)
            content.add(
                SpanWdg("Number of related snapshots: %s" % snapshot_count,
                        css='small'))
            content.add(HtmlElement.br())

        pipelines_search = Search("sthpw/pipeline")
        pipelines_search.add_filter("search_type", search_type)
        pipeline_count = pipelines_search.get_count()
        cb = CheckboxWdg('related_types')
        cb.set_attr('value', 'sthpw/pipeline')
        content.add(cb)
        content.add(
            SpanWdg("Number of related pipelines: %s" % pipeline_count,
                    css='small'))
        content.add(HtmlElement.br(2))

        content.add(
            "<b>WARNING: Deleting the sType will delete all of these items.</b> "
        )
        content.add("<br/>" * 2)
        content.add("Do you wish to continue deleting?")
        content.add("<br/>" * 2)

        button_div = DivWdg()
        button_div.add_styles('width: 300px; height: 50px')
        button = ActionButtonWdg(title="Delete")
        button_div.add(button)
        content.add(button_div)
        button.add_style("float: left")

        button.add_behavior({
            'type':
            'click_up',
            'search_type':
            search_type,
            'cbjs_action':
            '''
        spt.app_busy.show("Deleting sType");
        var class_name = "tactic.ui.tools.DeleteSearchTypeCmd";
        var ui_top = bvr.src_el.getParent(".spt_delete_stype_top");
        var values = spt.api.Utility.get_input_values(ui_top);
        var kwargs = {
            'search_type': bvr.search_type,
             'values': values
        };
        var server = TacticServerStub.get();
        try {
            server.start({'title': 'Delete sType', 'description': 'Delete sType [' + bvr.search_type + ']'});
            server.execute_cmd(class_name, kwargs);
            var top = bvr.src_el.getParent(".spt_popup");
            spt.pipeline.remove_node(top.stype_node);

            // force a schema save
            spt.named_events.fire_event('schema|save', bvr)
            top.destroy();
            
            server.finish();
        
        }
        catch(e) {
            spt.alert(spt.exception.handler(e));
        }

        spt.app_busy.hide();

        spt.notify.show_message("Successfully deleted sType ["+bvr.search_type+"]");
       
        '''
        })

        button = ActionButtonWdg(title="Cancel")
        button.add_style("float: left")
        button_div.add(button)
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        var top = bvr.src_el.getParent(".spt_popup");
        top.destroy();
        '''
        })

        return top